New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@fadeaway-ai/sdk

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fadeaway-ai/sdk - npm Package Compare versions

Comparing version 0.1.11 to 0.1.12

102

dist/index.d.ts

@@ -10,27 +10,23 @@ import { ChatCompletionRequestMessage } from 'openai-edge';

declare abstract class LLMComponent<Input, State = {}> {
interface FadeawayRedirect {
__typename: 'redirect';
href: string;
}
interface FadeawayStop {
__typename: 'stop';
}
interface FadeawayView {
__typename: 'view';
fadeawayViewId: string;
props: any;
}
interface FadeawayContextMessage {
__typename: 'context';
name: string;
props: Input;
state: State;
description: string;
schema?: ZodType<Input>;
constructor(session: FadeawaySession);
abstract run: (data: Input) => void | Promise<void>;
setState(state: Partial<State>): void;
abstract getFunctions(): LLMFunction<any>[];
render(): View | null | undefined;
getContent(): string;
props: any;
state?: any;
view?: View;
}
type FadeawayMessage = number | string | boolean | FadeawayRedirect | FadeawayStop | FadeawayView | FadeawayContextMessage;
declare class FadeawayMessage {
data?: any;
constructor(data: any);
static view(view: View): FadeawayMessage;
static component(component: FadeawayComponent): FadeawayMessage;
static data(data: string | number | boolean): FadeawayMessage;
static stop(): FadeawayMessage;
static redirect(href: string): FadeawayMessage;
serialize(): string;
}
interface LLMFunctionMeta<Input> {

@@ -51,2 +47,14 @@ name: string;

type IFunctionResponse = FadeawayMessage[];
declare const FadeawayFunctionResponse: {
data: (data: string | number | boolean) => string | number | boolean;
view: (view: View) => FadeawayView;
redirect: (href: string) => FadeawayRedirect;
stop: () => FadeawayStop;
context: (ctx: {
name: string;
props: any;
view?: View;
state?: any;
}) => FadeawayContextMessage;
};

@@ -61,8 +69,23 @@ type RouteSegmentFunction = (arg: {

prompt?: string;
functions?: (LLMFunction<any> | LLMComponent<any>)[];
functions?: LLMFunction<any>[];
init?: string;
}
interface IFadeawayContext<Props, State = {}> {
name: string;
prompt?: string;
initState: State;
props: Props;
functions?: LLMFunction<any>[];
view?: View;
}
interface FadeawaySession {
id: string;
api: string;
contexts: {
[key: string]: {
props: any;
state: any;
view: View;
name: string;
};
};
messages: ChatCompletionRequestMessage[];

@@ -79,2 +102,11 @@ }

}) => IFadeawayRoute;
type FadeawayContextHandler<Props, State> = (arg: {
props: Props;
session: FadeawaySession;
setState: (state: Partial<State>) => void;
getState: () => State;
}) => IFadeawayContext<Props, State>;
declare function FadeawayContext<T extends {
[key: string]: string;
} = {}, State = {}>(handler: FadeawayContextHandler<T, State>): FadeawayContextHandler<T, State>;
declare class FadeawayAPI {

@@ -90,22 +122,2 @@ private routes;

declare class FadeawayComponent {
name: string;
props: any;
state: any;
fadeawayViewId: string;
content: string;
constructor(name: string, fadeawayViewId: string, props: any, state: any, content: string);
}
declare class FadeawayRedirect {
href: string;
constructor(href: string);
}
declare class FadeawayStop {
}
declare function serializeWithTypename<T extends Object>(obj: T): string;
declare function deserializeFromTypename(obj: string): View | string | number | boolean | FadeawayStop | FadeawayComponent;
export { FadeawayAPI, FadeawayComponent, FadeawayMessage, FadeawayRedirect, FadeawayRoute, FadeawaySession, FadeawayStop, IFadeawayRoute, IFunctionResponse, LLMComponent, LLMFunction, View, deserializeFromTypename, llmFunction, serializeWithTypename };
export { FadeawayAPI, FadeawayContext, FadeawayContextHandler, FadeawayContextMessage, FadeawayFunctionResponse, FadeawayMessage, FadeawayRedirect, FadeawayRoute, FadeawaySession, FadeawayStop, FadeawayView, IFadeawayContext, IFadeawayRoute, IFunctionResponse, LLMFunction, View, llmFunction };

@@ -24,12 +24,7 @@ "use strict";

FadeawayAPI: () => FadeawayAPI,
FadeawayComponent: () => FadeawayComponent,
FadeawayMessage: () => FadeawayMessage,
FadeawayRedirect: () => FadeawayRedirect,
FadeawayContext: () => FadeawayContext,
FadeawayFunctionResponse: () => FadeawayFunctionResponse,
FadeawayRoute: () => FadeawayRoute,
FadeawayStop: () => FadeawayStop,
LLMComponent: () => LLMComponent,
View: () => View,
deserializeFromTypename: () => deserializeFromTypename,
llmFunction: () => llmFunction,
serializeWithTypename: () => serializeWithTypename
llmFunction: () => llmFunction
});

@@ -43,2 +38,5 @@ module.exports = __toCommonJS(src_exports);

}
function FadeawayContext(handler) {
return handler;
}
var FadeawayAPI = class {

@@ -87,74 +85,2 @@ constructor() {

// src/FadeawayComponent.ts
var FadeawayComponent = class {
constructor(name, fadeawayViewId, props, state, content) {
this.name = name;
this.fadeawayViewId = fadeawayViewId;
this.props = props;
this.state = state;
this.content = content;
}
};
// src/FadeawayStop.ts
var FadeawayStop = class {
};
// src/FadeawayMessage.ts
var FadeawayMessage = class _FadeawayMessage {
constructor(data) {
this.data = data;
}
static view(view) {
return new _FadeawayMessage(view);
}
static component(component) {
return new _FadeawayMessage(component);
}
static data(data) {
return new _FadeawayMessage(data);
}
static stop() {
return new _FadeawayMessage(new FadeawayStop());
}
static redirect(href) {
return new _FadeawayMessage(new FadeawayRedirect(href));
}
serialize() {
return serializeWithTypename(this.data);
}
};
// src/FadeawayRedirect.ts
var FadeawayRedirect = class {
constructor(href) {
this.href = href;
}
};
// src/LLMComponent.ts
var LLMComponent = class {
constructor(session) {
this.name = this.constructor.name;
const component = session.messages.find((m) => m.role === "function" && m.name === this.name);
const arg = (component == null ? void 0 : component.content) ? JSON.parse(component.content) : void 0;
this.props = (arg == null ? void 0 : arg.props) || {};
this.state = (arg == null ? void 0 : arg.state) || {};
}
setState(state) {
this.state = { ...this.state || {}, ...state };
}
render() {
return null;
}
getContent() {
var _a;
return JSON.stringify({
view: (_a = this.render()) == null ? void 0 : _a.fadeawayViewId,
props: this.props,
state: this.state
});
}
};
// src/LLMFunction.ts

@@ -177,2 +103,17 @@ var import_zod = require("zod");

}
var FadeawayFunctionResponse = {
data: (data) => data,
view: (view) => {
return { __typename: "view", fadeawayViewId: view.fadeawayViewId, props: view.props };
},
redirect: (href) => {
return { __typename: "redirect", href };
},
stop: () => {
return { __typename: "stop" };
},
context: (ctx) => {
return { __typename: "context", ...ctx };
}
};

@@ -186,53 +127,11 @@ // src/View.ts

};
// src/serializors.ts
function serializeWithTypename(obj) {
if (typeof obj === "number" || typeof obj === "string" || typeof obj === "boolean") {
return JSON.stringify(obj);
} else {
return JSON.stringify({
__typename: obj.constructor.name,
...obj
});
}
}
function deserializeFromTypename(obj) {
const parsedObj = JSON.parse(obj);
if (typeof parsedObj === "number" || typeof parsedObj === "string" || typeof parsedObj === "boolean") {
return parsedObj;
}
if (parsedObj.__typename === View.name) {
return new View(parsedObj.fadeawayViewId, parsedObj.props);
}
if (parsedObj.__typename === FadeawayStop.name) {
return new FadeawayStop();
}
if (parsedObj.__typename === FadeawayRedirect.name) {
return new FadeawayRedirect(parsedObj.href);
}
if (parsedObj.__typename === FadeawayComponent.name) {
return new FadeawayComponent(
parsedObj.name,
parsedObj.fadeawayViewId,
parsedObj.props,
parsedObj.state,
parsedObj.content
);
}
throw new Error(`Not implemented to deserialize __typename ${parsedObj.__typename}`);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
FadeawayAPI,
FadeawayComponent,
FadeawayMessage,
FadeawayRedirect,
FadeawayContext,
FadeawayFunctionResponse,
FadeawayRoute,
FadeawayStop,
LLMComponent,
View,
deserializeFromTypename,
llmFunction,
serializeWithTypename
llmFunction
});
//# sourceMappingURL=index.js.map
{
"name": "@fadeaway-ai/sdk",
"version": "0.1.11",
"version": "0.1.12",
"description": "",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc