experimental-agent 0.0.0 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +118 -55
- package/dist/agent-workflow.d.mts +1 -1
- package/dist/agent-workflow.d.ts +1 -1
- package/dist/agent-workflow.js +474 -66
- package/dist/agent-workflow.mjs +1 -1
- package/dist/{chunk-DPPQO7DA.mjs → chunk-24DJSI7C.mjs} +34 -3
- package/dist/chunk-4RGMKC2M.mjs +755 -0
- package/dist/{chunk-2YI7MQGZ.mjs → chunk-6ICYKNCC.mjs} +24 -1
- package/dist/chunk-PGYYQ3WZ.mjs +1088 -0
- package/dist/{client-FCFZYOOB.mjs → client-4Y3UPWFR.mjs} +3 -3
- package/dist/client-BBpD9kKL.d.ts +193 -0
- package/dist/client-BGJViybU.d.mts +193 -0
- package/dist/{client-RRX3GDQD.mjs → client-HUG4HT5L.mjs} +1 -1
- package/dist/index.d.mts +5 -106
- package/dist/index.d.ts +5 -106
- package/dist/index.js +526 -77
- package/dist/index.mjs +57 -16
- package/dist/{lifecycle-workflow-steps-6BLGTYVB.mjs → lifecycle-workflow-steps-HHN46ZAD.mjs} +2 -2
- package/dist/lifecycle-workflow.d.mts +2 -2
- package/dist/lifecycle-workflow.d.ts +2 -2
- package/dist/lifecycle-workflow.js +217 -19
- package/dist/lifecycle-workflow.mjs +1 -1
- package/dist/{local-J6QFWSWB.mjs → local-BYPFRMLZ.mjs} +42 -4
- package/dist/{sandbox-Y3ENCNUA.mjs → sandbox-BFA4ECEQ.mjs} +3 -3
- package/dist/{storage-QSTSE2ZB.mjs → storage-2U2QFNWI.mjs} +2 -2
- package/dist/{types-vRxN1Qz1.d.mts → types-DPXFq_r6.d.mts} +110 -1
- package/dist/{types-vRxN1Qz1.d.ts → types-DPXFq_r6.d.ts} +110 -1
- package/package.json +13 -12
- package/dist/chunk-JQPR6M7D.mjs +0 -649
- package/dist/chunk-MR4UWCJT.mjs +0 -878
- package/dist/types-Lwut_0_u.d.mts +0 -80
- package/dist/types-ctZeJ3iQ.d.ts +0 -80
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { f as SandboxRecord, d as SandboxError, k as Storage, e as SandboxNotFoundError, j as StorageError, i as StorageConfig, c as SandboxConfig, h as SessionNotFoundError, l as SessionError, b as MessageNotFoundError } from './types-DPXFq_r6.js';
|
|
2
|
+
import * as ai from 'ai';
|
|
3
|
+
import { GatewayModelId, UIMessage } from 'ai';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Summary of a discovered skill, used in the system prompt
|
|
8
|
+
* to inform the LLM about available skills.
|
|
9
|
+
*/
|
|
10
|
+
type SkillSummary = {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
/** Full path to the SKILL.md file inside the sandbox */
|
|
14
|
+
skillMdPath: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A file ready to be uploaded to the sandbox.
|
|
18
|
+
* Content can be text (string) or binary (Buffer).
|
|
19
|
+
*/
|
|
20
|
+
type UploadableFile = {
|
|
21
|
+
/** Relative path within the upload destination */
|
|
22
|
+
path: string;
|
|
23
|
+
content: string | Buffer;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Path or paths to skills directories inside the sandbox.
|
|
27
|
+
*/
|
|
28
|
+
type SkillsDir = string | string[];
|
|
29
|
+
|
|
30
|
+
type SandboxLifecycleInput = {
|
|
31
|
+
id: string;
|
|
32
|
+
storageConfig: StorageConfig;
|
|
33
|
+
initialConfig: SandboxConfig;
|
|
34
|
+
};
|
|
35
|
+
type LogEntry = {
|
|
36
|
+
stream: "stdout" | "stderr";
|
|
37
|
+
data: string;
|
|
38
|
+
};
|
|
39
|
+
type ExecResult = {
|
|
40
|
+
commandId: string;
|
|
41
|
+
logs: () => AsyncIterable<LogEntry>;
|
|
42
|
+
result: Promise<{
|
|
43
|
+
stdout: string;
|
|
44
|
+
stderr: string;
|
|
45
|
+
exitCode: number;
|
|
46
|
+
}>;
|
|
47
|
+
};
|
|
48
|
+
type SandboxStatus = "pending" | "running" | "stopping" | "stopped" | "failed";
|
|
49
|
+
interface SandboxLifecycle {
|
|
50
|
+
start: () => Promise<SandboxError | SandboxStatus>;
|
|
51
|
+
snapshot: () => Promise<SandboxError | {
|
|
52
|
+
snapshotId: string;
|
|
53
|
+
}>;
|
|
54
|
+
stop: () => Promise<SandboxError | undefined>;
|
|
55
|
+
getStatus: () => Promise<SandboxError | SandboxStatus>;
|
|
56
|
+
getCreatedAt: () => Promise<SandboxError | Date>;
|
|
57
|
+
getRemainingTimeout: () => Promise<SandboxError | number>;
|
|
58
|
+
}
|
|
59
|
+
interface Sandbox<TTags extends TagsSchema = TagsSchema> {
|
|
60
|
+
id: SandboxRecord["id"];
|
|
61
|
+
config: SandboxRecord["config"];
|
|
62
|
+
exec: (opts: {
|
|
63
|
+
command: string;
|
|
64
|
+
args?: string[];
|
|
65
|
+
signal?: AbortSignal;
|
|
66
|
+
}) => Promise<SandboxError | ExecResult>;
|
|
67
|
+
/**
|
|
68
|
+
* Get the public domain URL for an exposed port.
|
|
69
|
+
* Only available for Vercel sandboxes with exposed ports.
|
|
70
|
+
*/
|
|
71
|
+
getDomain: (port: number) => Promise<SandboxError | string>;
|
|
72
|
+
kill: (opts: {
|
|
73
|
+
commandId: string;
|
|
74
|
+
storage: Storage;
|
|
75
|
+
}) => Promise<SandboxError | undefined>;
|
|
76
|
+
writeFiles: (opts: {
|
|
77
|
+
files: UploadableFile[];
|
|
78
|
+
destPath: string;
|
|
79
|
+
}) => Promise<void>;
|
|
80
|
+
lifecycle?: SandboxLifecycle;
|
|
81
|
+
tag: {
|
|
82
|
+
list: () => Promise<SandboxNotFoundError | StorageError | TTags>;
|
|
83
|
+
get: (key: string) => Promise<SandboxNotFoundError | StorageError | TTags[typeof key] | undefined>;
|
|
84
|
+
set: (key: string, value: unknown) => Promise<StorageError | undefined>;
|
|
85
|
+
setMany: (tags: Record<string, unknown>) => Promise<StorageError | undefined>;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
type McpToolDef = {
|
|
90
|
+
description: string;
|
|
91
|
+
inputSchema: z.ZodType;
|
|
92
|
+
outputSchema?: z.ZodType;
|
|
93
|
+
};
|
|
94
|
+
type McpServerDef<TTools extends Record<string, McpToolDef> = Record<string, McpToolDef>, THeaders extends z.ZodType = z.ZodType> = {
|
|
95
|
+
url: string;
|
|
96
|
+
description?: string;
|
|
97
|
+
headersSchema?: THeaders;
|
|
98
|
+
tools: TTools;
|
|
99
|
+
};
|
|
100
|
+
type McpConfig = Record<string, McpServerDef>;
|
|
101
|
+
type ExtractHeaders<T> = T extends McpServerDef<infer _TTools, infer THeaders> ? THeaders extends z.ZodType ? z.infer<THeaders> : Record<string, string> : Record<string, string>;
|
|
102
|
+
type HasRequiredHeaders<T extends McpServerDef> = T extends {
|
|
103
|
+
headersSchema: z.ZodType;
|
|
104
|
+
} ? true : false;
|
|
105
|
+
type ServerSendOptions<T extends McpServerDef> = HasRequiredHeaders<T> extends true ? {
|
|
106
|
+
headers: ExtractHeaders<T>;
|
|
107
|
+
disabled?: false;
|
|
108
|
+
} | {
|
|
109
|
+
disabled: true;
|
|
110
|
+
headers?: ExtractHeaders<T>;
|
|
111
|
+
} : {
|
|
112
|
+
headers?: ExtractHeaders<T>;
|
|
113
|
+
disabled?: boolean;
|
|
114
|
+
};
|
|
115
|
+
type McpSendOptions<TMcp extends McpConfig> = {
|
|
116
|
+
[K in keyof TMcp]?: ServerSendOptions<TMcp[K]>;
|
|
117
|
+
};
|
|
118
|
+
declare function mcp<THeaders extends z.ZodType, TTools extends Record<string, McpToolDef>>(opts: {
|
|
119
|
+
url: string;
|
|
120
|
+
description?: string;
|
|
121
|
+
headersSchema?: THeaders;
|
|
122
|
+
tools: TTools;
|
|
123
|
+
}): McpServerDef<TTools, THeaders>;
|
|
124
|
+
|
|
125
|
+
type SendInput = string | {
|
|
126
|
+
role?: UIMessage["role"];
|
|
127
|
+
parts: UIMessage["parts"];
|
|
128
|
+
id?: string;
|
|
129
|
+
};
|
|
130
|
+
type SessionOptions<TMcp extends McpConfig = {}, TTags extends TagsSchema = TagsSchema> = {
|
|
131
|
+
model?: GatewayModelId;
|
|
132
|
+
instructions?: string;
|
|
133
|
+
sandbox?: SandboxConfig | string;
|
|
134
|
+
tags?: TTags;
|
|
135
|
+
skillsDir?: SkillsDir;
|
|
136
|
+
mcp?: TMcp;
|
|
137
|
+
};
|
|
138
|
+
type McpToolCallBody = {
|
|
139
|
+
server: string;
|
|
140
|
+
tool: string;
|
|
141
|
+
input: unknown;
|
|
142
|
+
sessionId: string;
|
|
143
|
+
messageId: string;
|
|
144
|
+
hookToken: string;
|
|
145
|
+
};
|
|
146
|
+
type AgentOptions<TMcp extends McpConfig = {}> = {
|
|
147
|
+
storage?: StorageConfig;
|
|
148
|
+
generateId?: (resource: "session" | "message" | "part" | "sandbox" | "command") => string;
|
|
149
|
+
} & SessionOptions<TMcp>;
|
|
150
|
+
type TagsSchema = Record<string, unknown>;
|
|
151
|
+
declare const agent: <TMcp extends McpConfig = {}>(options: AgentOptions<TMcp>) => {
|
|
152
|
+
session: <TTags extends TagsSchema = TagsSchema, TMcpOverride extends McpConfig = {}>(sessionId: string, sessionOptions?: SessionOptions<TMcp & TMcpOverride, TTags>) => Promise<{
|
|
153
|
+
send: ({ input, mcpContext, interruptIfStreaming, }: {
|
|
154
|
+
input: SendInput | SendInput[];
|
|
155
|
+
mcpContext?: McpSendOptions<TMcp & TMcpOverride>;
|
|
156
|
+
interruptIfStreaming?: boolean;
|
|
157
|
+
}) => Promise<void | SessionNotFoundError | SessionError | StorageError | MessageNotFoundError>;
|
|
158
|
+
stream: (opts?: {
|
|
159
|
+
messageId?: string;
|
|
160
|
+
}) => Promise<SessionNotFoundError | SessionError | StorageError | ReadableStream<any>>;
|
|
161
|
+
ui: () => Promise<StorageError | {
|
|
162
|
+
messages: UIMessage<unknown, ai.UIDataTypes, ai.UITools>[];
|
|
163
|
+
streamingMessageId: string | null;
|
|
164
|
+
}>;
|
|
165
|
+
tag: {
|
|
166
|
+
list: () => Promise<SessionNotFoundError | StorageError | TTags>;
|
|
167
|
+
get: (key: string) => Promise<SessionNotFoundError | StorageError | TTags[string] | undefined>;
|
|
168
|
+
set: (key: string, value: unknown) => Promise<StorageError | undefined>;
|
|
169
|
+
setMany: (tags: Record<string, unknown>) => Promise<StorageError | undefined>;
|
|
170
|
+
};
|
|
171
|
+
sandbox: Sandbox<TagsSchema>;
|
|
172
|
+
interrupt: () => Promise<SessionNotFoundError | StorageError | MessageNotFoundError | undefined>;
|
|
173
|
+
}>;
|
|
174
|
+
sandbox: <TTags extends TagsSchema = TagsSchema>(sandboxId: string, opts?: {
|
|
175
|
+
config?: SandboxConfig;
|
|
176
|
+
tags?: TTags;
|
|
177
|
+
}) => Promise<Sandbox<TTags>>;
|
|
178
|
+
storage: Storage;
|
|
179
|
+
handleMcpToolCall: (body: McpToolCallBody, handlers: Record<string, (opts: {
|
|
180
|
+
input: unknown;
|
|
181
|
+
headers: Record<string, string>;
|
|
182
|
+
body: McpToolCallBody;
|
|
183
|
+
}) => Promise<unknown>>) => Promise<{
|
|
184
|
+
result: unknown;
|
|
185
|
+
} | {
|
|
186
|
+
error: {
|
|
187
|
+
code: string;
|
|
188
|
+
message: string;
|
|
189
|
+
};
|
|
190
|
+
}>;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export { type AgentOptions as A, type ExecResult as E, type Sandbox as S, type TagsSchema as T, type UploadableFile as U, type SendInput as a, type SessionOptions as b, type SkillSummary as c, agent as d, type SandboxLifecycleInput as e, mcp as m };
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { f as SandboxRecord, d as SandboxError, k as Storage, e as SandboxNotFoundError, j as StorageError, i as StorageConfig, c as SandboxConfig, h as SessionNotFoundError, l as SessionError, b as MessageNotFoundError } from './types-DPXFq_r6.mjs';
|
|
2
|
+
import * as ai from 'ai';
|
|
3
|
+
import { GatewayModelId, UIMessage } from 'ai';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Summary of a discovered skill, used in the system prompt
|
|
8
|
+
* to inform the LLM about available skills.
|
|
9
|
+
*/
|
|
10
|
+
type SkillSummary = {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
/** Full path to the SKILL.md file inside the sandbox */
|
|
14
|
+
skillMdPath: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A file ready to be uploaded to the sandbox.
|
|
18
|
+
* Content can be text (string) or binary (Buffer).
|
|
19
|
+
*/
|
|
20
|
+
type UploadableFile = {
|
|
21
|
+
/** Relative path within the upload destination */
|
|
22
|
+
path: string;
|
|
23
|
+
content: string | Buffer;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Path or paths to skills directories inside the sandbox.
|
|
27
|
+
*/
|
|
28
|
+
type SkillsDir = string | string[];
|
|
29
|
+
|
|
30
|
+
type SandboxLifecycleInput = {
|
|
31
|
+
id: string;
|
|
32
|
+
storageConfig: StorageConfig;
|
|
33
|
+
initialConfig: SandboxConfig;
|
|
34
|
+
};
|
|
35
|
+
type LogEntry = {
|
|
36
|
+
stream: "stdout" | "stderr";
|
|
37
|
+
data: string;
|
|
38
|
+
};
|
|
39
|
+
type ExecResult = {
|
|
40
|
+
commandId: string;
|
|
41
|
+
logs: () => AsyncIterable<LogEntry>;
|
|
42
|
+
result: Promise<{
|
|
43
|
+
stdout: string;
|
|
44
|
+
stderr: string;
|
|
45
|
+
exitCode: number;
|
|
46
|
+
}>;
|
|
47
|
+
};
|
|
48
|
+
type SandboxStatus = "pending" | "running" | "stopping" | "stopped" | "failed";
|
|
49
|
+
interface SandboxLifecycle {
|
|
50
|
+
start: () => Promise<SandboxError | SandboxStatus>;
|
|
51
|
+
snapshot: () => Promise<SandboxError | {
|
|
52
|
+
snapshotId: string;
|
|
53
|
+
}>;
|
|
54
|
+
stop: () => Promise<SandboxError | undefined>;
|
|
55
|
+
getStatus: () => Promise<SandboxError | SandboxStatus>;
|
|
56
|
+
getCreatedAt: () => Promise<SandboxError | Date>;
|
|
57
|
+
getRemainingTimeout: () => Promise<SandboxError | number>;
|
|
58
|
+
}
|
|
59
|
+
interface Sandbox<TTags extends TagsSchema = TagsSchema> {
|
|
60
|
+
id: SandboxRecord["id"];
|
|
61
|
+
config: SandboxRecord["config"];
|
|
62
|
+
exec: (opts: {
|
|
63
|
+
command: string;
|
|
64
|
+
args?: string[];
|
|
65
|
+
signal?: AbortSignal;
|
|
66
|
+
}) => Promise<SandboxError | ExecResult>;
|
|
67
|
+
/**
|
|
68
|
+
* Get the public domain URL for an exposed port.
|
|
69
|
+
* Only available for Vercel sandboxes with exposed ports.
|
|
70
|
+
*/
|
|
71
|
+
getDomain: (port: number) => Promise<SandboxError | string>;
|
|
72
|
+
kill: (opts: {
|
|
73
|
+
commandId: string;
|
|
74
|
+
storage: Storage;
|
|
75
|
+
}) => Promise<SandboxError | undefined>;
|
|
76
|
+
writeFiles: (opts: {
|
|
77
|
+
files: UploadableFile[];
|
|
78
|
+
destPath: string;
|
|
79
|
+
}) => Promise<void>;
|
|
80
|
+
lifecycle?: SandboxLifecycle;
|
|
81
|
+
tag: {
|
|
82
|
+
list: () => Promise<SandboxNotFoundError | StorageError | TTags>;
|
|
83
|
+
get: (key: string) => Promise<SandboxNotFoundError | StorageError | TTags[typeof key] | undefined>;
|
|
84
|
+
set: (key: string, value: unknown) => Promise<StorageError | undefined>;
|
|
85
|
+
setMany: (tags: Record<string, unknown>) => Promise<StorageError | undefined>;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
type McpToolDef = {
|
|
90
|
+
description: string;
|
|
91
|
+
inputSchema: z.ZodType;
|
|
92
|
+
outputSchema?: z.ZodType;
|
|
93
|
+
};
|
|
94
|
+
type McpServerDef<TTools extends Record<string, McpToolDef> = Record<string, McpToolDef>, THeaders extends z.ZodType = z.ZodType> = {
|
|
95
|
+
url: string;
|
|
96
|
+
description?: string;
|
|
97
|
+
headersSchema?: THeaders;
|
|
98
|
+
tools: TTools;
|
|
99
|
+
};
|
|
100
|
+
type McpConfig = Record<string, McpServerDef>;
|
|
101
|
+
type ExtractHeaders<T> = T extends McpServerDef<infer _TTools, infer THeaders> ? THeaders extends z.ZodType ? z.infer<THeaders> : Record<string, string> : Record<string, string>;
|
|
102
|
+
type HasRequiredHeaders<T extends McpServerDef> = T extends {
|
|
103
|
+
headersSchema: z.ZodType;
|
|
104
|
+
} ? true : false;
|
|
105
|
+
type ServerSendOptions<T extends McpServerDef> = HasRequiredHeaders<T> extends true ? {
|
|
106
|
+
headers: ExtractHeaders<T>;
|
|
107
|
+
disabled?: false;
|
|
108
|
+
} | {
|
|
109
|
+
disabled: true;
|
|
110
|
+
headers?: ExtractHeaders<T>;
|
|
111
|
+
} : {
|
|
112
|
+
headers?: ExtractHeaders<T>;
|
|
113
|
+
disabled?: boolean;
|
|
114
|
+
};
|
|
115
|
+
type McpSendOptions<TMcp extends McpConfig> = {
|
|
116
|
+
[K in keyof TMcp]?: ServerSendOptions<TMcp[K]>;
|
|
117
|
+
};
|
|
118
|
+
declare function mcp<THeaders extends z.ZodType, TTools extends Record<string, McpToolDef>>(opts: {
|
|
119
|
+
url: string;
|
|
120
|
+
description?: string;
|
|
121
|
+
headersSchema?: THeaders;
|
|
122
|
+
tools: TTools;
|
|
123
|
+
}): McpServerDef<TTools, THeaders>;
|
|
124
|
+
|
|
125
|
+
type SendInput = string | {
|
|
126
|
+
role?: UIMessage["role"];
|
|
127
|
+
parts: UIMessage["parts"];
|
|
128
|
+
id?: string;
|
|
129
|
+
};
|
|
130
|
+
type SessionOptions<TMcp extends McpConfig = {}, TTags extends TagsSchema = TagsSchema> = {
|
|
131
|
+
model?: GatewayModelId;
|
|
132
|
+
instructions?: string;
|
|
133
|
+
sandbox?: SandboxConfig | string;
|
|
134
|
+
tags?: TTags;
|
|
135
|
+
skillsDir?: SkillsDir;
|
|
136
|
+
mcp?: TMcp;
|
|
137
|
+
};
|
|
138
|
+
type McpToolCallBody = {
|
|
139
|
+
server: string;
|
|
140
|
+
tool: string;
|
|
141
|
+
input: unknown;
|
|
142
|
+
sessionId: string;
|
|
143
|
+
messageId: string;
|
|
144
|
+
hookToken: string;
|
|
145
|
+
};
|
|
146
|
+
type AgentOptions<TMcp extends McpConfig = {}> = {
|
|
147
|
+
storage?: StorageConfig;
|
|
148
|
+
generateId?: (resource: "session" | "message" | "part" | "sandbox" | "command") => string;
|
|
149
|
+
} & SessionOptions<TMcp>;
|
|
150
|
+
type TagsSchema = Record<string, unknown>;
|
|
151
|
+
declare const agent: <TMcp extends McpConfig = {}>(options: AgentOptions<TMcp>) => {
|
|
152
|
+
session: <TTags extends TagsSchema = TagsSchema, TMcpOverride extends McpConfig = {}>(sessionId: string, sessionOptions?: SessionOptions<TMcp & TMcpOverride, TTags>) => Promise<{
|
|
153
|
+
send: ({ input, mcpContext, interruptIfStreaming, }: {
|
|
154
|
+
input: SendInput | SendInput[];
|
|
155
|
+
mcpContext?: McpSendOptions<TMcp & TMcpOverride>;
|
|
156
|
+
interruptIfStreaming?: boolean;
|
|
157
|
+
}) => Promise<void | SessionNotFoundError | SessionError | StorageError | MessageNotFoundError>;
|
|
158
|
+
stream: (opts?: {
|
|
159
|
+
messageId?: string;
|
|
160
|
+
}) => Promise<SessionNotFoundError | SessionError | StorageError | ReadableStream<any>>;
|
|
161
|
+
ui: () => Promise<StorageError | {
|
|
162
|
+
messages: UIMessage<unknown, ai.UIDataTypes, ai.UITools>[];
|
|
163
|
+
streamingMessageId: string | null;
|
|
164
|
+
}>;
|
|
165
|
+
tag: {
|
|
166
|
+
list: () => Promise<SessionNotFoundError | StorageError | TTags>;
|
|
167
|
+
get: (key: string) => Promise<SessionNotFoundError | StorageError | TTags[string] | undefined>;
|
|
168
|
+
set: (key: string, value: unknown) => Promise<StorageError | undefined>;
|
|
169
|
+
setMany: (tags: Record<string, unknown>) => Promise<StorageError | undefined>;
|
|
170
|
+
};
|
|
171
|
+
sandbox: Sandbox<TagsSchema>;
|
|
172
|
+
interrupt: () => Promise<SessionNotFoundError | StorageError | MessageNotFoundError | undefined>;
|
|
173
|
+
}>;
|
|
174
|
+
sandbox: <TTags extends TagsSchema = TagsSchema>(sandboxId: string, opts?: {
|
|
175
|
+
config?: SandboxConfig;
|
|
176
|
+
tags?: TTags;
|
|
177
|
+
}) => Promise<Sandbox<TTags>>;
|
|
178
|
+
storage: Storage;
|
|
179
|
+
handleMcpToolCall: (body: McpToolCallBody, handlers: Record<string, (opts: {
|
|
180
|
+
input: unknown;
|
|
181
|
+
headers: Record<string, string>;
|
|
182
|
+
body: McpToolCallBody;
|
|
183
|
+
}) => Promise<unknown>>) => Promise<{
|
|
184
|
+
result: unknown;
|
|
185
|
+
} | {
|
|
186
|
+
error: {
|
|
187
|
+
code: string;
|
|
188
|
+
message: string;
|
|
189
|
+
};
|
|
190
|
+
}>;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export { type AgentOptions as A, type ExecResult as E, type Sandbox as S, type TagsSchema as T, type UploadableFile as U, type SendInput as a, type SessionOptions as b, type SkillSummary as c, agent as d, type SandboxLifecycleInput as e, mcp as m };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { E as ExecResult, b as SkillSummary, U as UploadableFile } from './types-Lwut_0_u.mjs';
|
|
5
|
-
import * as ai from 'ai';
|
|
6
|
-
import { UIMessage, GatewayModelId } from 'ai';
|
|
1
|
+
export { A as AgentOptions, E as ExecResult, S as Sandbox, a as SendInput, b as SessionOptions, c as SkillSummary, T as TagsSchema, U as UploadableFile, d as agent, m as mcp } from './client-BGJViybU.mjs';
|
|
2
|
+
import { M as MethodName, S as StorageMethods } from './types-DPXFq_r6.mjs';
|
|
3
|
+
export { L as ListResult, a as Message, b as MessageNotFoundError, P as Part, R as ResolvedStorage, c as SandboxConfig, d as SandboxError, e as SandboxNotFoundError, f as SandboxRecord, g as Session, h as SessionNotFoundError, i as StorageConfig, j as StorageError } from './types-DPXFq_r6.mjs';
|
|
7
4
|
import { z } from 'zod';
|
|
5
|
+
import 'ai';
|
|
8
6
|
import 'errore';
|
|
9
7
|
|
|
10
8
|
type Handlers = {
|
|
@@ -26,103 +24,4 @@ type RpcErrorResponse = {
|
|
|
26
24
|
type RpcResponse<T = unknown> = RpcSuccessResponse<T> | RpcErrorResponse;
|
|
27
25
|
declare function handleStorageRpc(body: RpcRequest, handlers: Handlers): Promise<RpcResponse>;
|
|
28
26
|
|
|
29
|
-
type
|
|
30
|
-
description: string;
|
|
31
|
-
inputSchema: z.ZodType;
|
|
32
|
-
outputSchema?: z.ZodType;
|
|
33
|
-
};
|
|
34
|
-
type McpServerDef<TTools extends Record<string, McpToolDef> = Record<string, McpToolDef>, THeaders extends z.ZodType = z.ZodType> = {
|
|
35
|
-
url: string;
|
|
36
|
-
description?: string;
|
|
37
|
-
headersSchema?: THeaders;
|
|
38
|
-
tools: TTools;
|
|
39
|
-
};
|
|
40
|
-
type McpConfig = Record<string, McpServerDef>;
|
|
41
|
-
type ExtractHeaders<T> = T extends McpServerDef<infer _TTools, infer THeaders> ? THeaders extends z.ZodType ? z.infer<THeaders> : Record<string, string> : Record<string, string>;
|
|
42
|
-
type HasRequiredHeaders<T extends McpServerDef> = T extends {
|
|
43
|
-
headersSchema: z.ZodType;
|
|
44
|
-
} ? true : false;
|
|
45
|
-
type ServerSendOptions<T extends McpServerDef> = HasRequiredHeaders<T> extends true ? {
|
|
46
|
-
headers: ExtractHeaders<T>;
|
|
47
|
-
disabled?: false;
|
|
48
|
-
} | {
|
|
49
|
-
disabled: true;
|
|
50
|
-
headers?: ExtractHeaders<T>;
|
|
51
|
-
} : {
|
|
52
|
-
headers?: ExtractHeaders<T>;
|
|
53
|
-
disabled?: boolean;
|
|
54
|
-
};
|
|
55
|
-
type McpSendOptions<TMcp extends McpConfig> = {
|
|
56
|
-
[K in keyof TMcp]?: ServerSendOptions<TMcp[K]>;
|
|
57
|
-
};
|
|
58
|
-
declare function mcp<THeaders extends z.ZodType, TTools extends Record<string, McpToolDef>>(opts: {
|
|
59
|
-
url: string;
|
|
60
|
-
description?: string;
|
|
61
|
-
headersSchema?: THeaders;
|
|
62
|
-
tools: TTools;
|
|
63
|
-
}): McpServerDef<TTools, THeaders>;
|
|
64
|
-
|
|
65
|
-
type SendInput = string | {
|
|
66
|
-
role?: UIMessage["role"];
|
|
67
|
-
parts: UIMessage["parts"];
|
|
68
|
-
id?: string;
|
|
69
|
-
};
|
|
70
|
-
type SessionOptions<TMcp extends McpConfig = {}, TTags extends TagsSchema = TagsSchema> = {
|
|
71
|
-
model?: GatewayModelId;
|
|
72
|
-
instructions?: string;
|
|
73
|
-
sandbox?: SandboxConfig | string;
|
|
74
|
-
tags?: TTags;
|
|
75
|
-
skillsDir?: SkillsDir;
|
|
76
|
-
mcp?: TMcp;
|
|
77
|
-
};
|
|
78
|
-
type McpToolCallBody = {
|
|
79
|
-
server: string;
|
|
80
|
-
tool: string;
|
|
81
|
-
input: unknown;
|
|
82
|
-
sessionId: string;
|
|
83
|
-
messageId: string;
|
|
84
|
-
hookToken: string;
|
|
85
|
-
};
|
|
86
|
-
type AgentOptions<TMcp extends McpConfig = {}> = {
|
|
87
|
-
storage?: StorageConfig;
|
|
88
|
-
generateId?: (resource: "session" | "message" | "part" | "sandbox" | "command") => string;
|
|
89
|
-
} & SessionOptions<TMcp>;
|
|
90
|
-
type TagsSchema = Record<string, unknown>;
|
|
91
|
-
declare const agent: <TMcp extends McpConfig = {}>(options: AgentOptions<TMcp>) => {
|
|
92
|
-
session: <TTags extends TagsSchema = TagsSchema, TMcpOverride extends McpConfig = {}>(sessionId: string, sessionOptions?: SessionOptions<TMcp & TMcpOverride, TTags>) => Promise<{
|
|
93
|
-
send: ({ input, mcpContext, }: {
|
|
94
|
-
input: SendInput | SendInput[];
|
|
95
|
-
mcpContext?: McpSendOptions<TMcp & TMcpOverride>;
|
|
96
|
-
}) => Promise<void | SessionError>;
|
|
97
|
-
stream: (opts?: {
|
|
98
|
-
messageId?: string;
|
|
99
|
-
}) => Promise<SessionNotFoundError | SessionError | StorageError | ReadableStream<any>>;
|
|
100
|
-
ui: () => Promise<StorageError | {
|
|
101
|
-
messages: UIMessage<unknown, ai.UIDataTypes, ai.UITools>[];
|
|
102
|
-
streamingMessageId: string | null;
|
|
103
|
-
}>;
|
|
104
|
-
tag: {
|
|
105
|
-
list: () => Promise<SessionNotFoundError | StorageError | TTags>;
|
|
106
|
-
get: (key: string) => Promise<SessionNotFoundError | StorageError | TTags[string] | undefined>;
|
|
107
|
-
set: (key: string, value: unknown) => Promise<StorageError | undefined>;
|
|
108
|
-
setMany: (tags: Record<string, unknown>) => Promise<StorageError | undefined>;
|
|
109
|
-
};
|
|
110
|
-
sandbox: Sandbox;
|
|
111
|
-
}>;
|
|
112
|
-
sandbox: (sandboxId: string, config?: SandboxConfig) => Promise<Sandbox>;
|
|
113
|
-
storage: Storage;
|
|
114
|
-
handleMcpToolCall: (body: McpToolCallBody, handlers: Record<string, (opts: {
|
|
115
|
-
input: unknown;
|
|
116
|
-
headers: Record<string, string>;
|
|
117
|
-
body: McpToolCallBody;
|
|
118
|
-
}) => Promise<unknown>>) => Promise<{
|
|
119
|
-
result: unknown;
|
|
120
|
-
} | {
|
|
121
|
-
error: {
|
|
122
|
-
code: string;
|
|
123
|
-
message: string;
|
|
124
|
-
};
|
|
125
|
-
}>;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
export { type AgentOptions, type Handlers, type RpcRequest, type RpcResponse, Sandbox, SandboxConfig, type SendInput, SessionNotFoundError, StorageConfig, StorageError, type TagsSchema, agent, handleStorageRpc, mcp };
|
|
27
|
+
export { type Handlers, type RpcRequest, type RpcResponse, handleStorageRpc };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { E as ExecResult, b as SkillSummary, U as UploadableFile } from './types-ctZeJ3iQ.js';
|
|
5
|
-
import * as ai from 'ai';
|
|
6
|
-
import { UIMessage, GatewayModelId } from 'ai';
|
|
1
|
+
export { A as AgentOptions, E as ExecResult, S as Sandbox, a as SendInput, b as SessionOptions, c as SkillSummary, T as TagsSchema, U as UploadableFile, d as agent, m as mcp } from './client-BBpD9kKL.js';
|
|
2
|
+
import { M as MethodName, S as StorageMethods } from './types-DPXFq_r6.js';
|
|
3
|
+
export { L as ListResult, a as Message, b as MessageNotFoundError, P as Part, R as ResolvedStorage, c as SandboxConfig, d as SandboxError, e as SandboxNotFoundError, f as SandboxRecord, g as Session, h as SessionNotFoundError, i as StorageConfig, j as StorageError } from './types-DPXFq_r6.js';
|
|
7
4
|
import { z } from 'zod';
|
|
5
|
+
import 'ai';
|
|
8
6
|
import 'errore';
|
|
9
7
|
|
|
10
8
|
type Handlers = {
|
|
@@ -26,103 +24,4 @@ type RpcErrorResponse = {
|
|
|
26
24
|
type RpcResponse<T = unknown> = RpcSuccessResponse<T> | RpcErrorResponse;
|
|
27
25
|
declare function handleStorageRpc(body: RpcRequest, handlers: Handlers): Promise<RpcResponse>;
|
|
28
26
|
|
|
29
|
-
type
|
|
30
|
-
description: string;
|
|
31
|
-
inputSchema: z.ZodType;
|
|
32
|
-
outputSchema?: z.ZodType;
|
|
33
|
-
};
|
|
34
|
-
type McpServerDef<TTools extends Record<string, McpToolDef> = Record<string, McpToolDef>, THeaders extends z.ZodType = z.ZodType> = {
|
|
35
|
-
url: string;
|
|
36
|
-
description?: string;
|
|
37
|
-
headersSchema?: THeaders;
|
|
38
|
-
tools: TTools;
|
|
39
|
-
};
|
|
40
|
-
type McpConfig = Record<string, McpServerDef>;
|
|
41
|
-
type ExtractHeaders<T> = T extends McpServerDef<infer _TTools, infer THeaders> ? THeaders extends z.ZodType ? z.infer<THeaders> : Record<string, string> : Record<string, string>;
|
|
42
|
-
type HasRequiredHeaders<T extends McpServerDef> = T extends {
|
|
43
|
-
headersSchema: z.ZodType;
|
|
44
|
-
} ? true : false;
|
|
45
|
-
type ServerSendOptions<T extends McpServerDef> = HasRequiredHeaders<T> extends true ? {
|
|
46
|
-
headers: ExtractHeaders<T>;
|
|
47
|
-
disabled?: false;
|
|
48
|
-
} | {
|
|
49
|
-
disabled: true;
|
|
50
|
-
headers?: ExtractHeaders<T>;
|
|
51
|
-
} : {
|
|
52
|
-
headers?: ExtractHeaders<T>;
|
|
53
|
-
disabled?: boolean;
|
|
54
|
-
};
|
|
55
|
-
type McpSendOptions<TMcp extends McpConfig> = {
|
|
56
|
-
[K in keyof TMcp]?: ServerSendOptions<TMcp[K]>;
|
|
57
|
-
};
|
|
58
|
-
declare function mcp<THeaders extends z.ZodType, TTools extends Record<string, McpToolDef>>(opts: {
|
|
59
|
-
url: string;
|
|
60
|
-
description?: string;
|
|
61
|
-
headersSchema?: THeaders;
|
|
62
|
-
tools: TTools;
|
|
63
|
-
}): McpServerDef<TTools, THeaders>;
|
|
64
|
-
|
|
65
|
-
type SendInput = string | {
|
|
66
|
-
role?: UIMessage["role"];
|
|
67
|
-
parts: UIMessage["parts"];
|
|
68
|
-
id?: string;
|
|
69
|
-
};
|
|
70
|
-
type SessionOptions<TMcp extends McpConfig = {}, TTags extends TagsSchema = TagsSchema> = {
|
|
71
|
-
model?: GatewayModelId;
|
|
72
|
-
instructions?: string;
|
|
73
|
-
sandbox?: SandboxConfig | string;
|
|
74
|
-
tags?: TTags;
|
|
75
|
-
skillsDir?: SkillsDir;
|
|
76
|
-
mcp?: TMcp;
|
|
77
|
-
};
|
|
78
|
-
type McpToolCallBody = {
|
|
79
|
-
server: string;
|
|
80
|
-
tool: string;
|
|
81
|
-
input: unknown;
|
|
82
|
-
sessionId: string;
|
|
83
|
-
messageId: string;
|
|
84
|
-
hookToken: string;
|
|
85
|
-
};
|
|
86
|
-
type AgentOptions<TMcp extends McpConfig = {}> = {
|
|
87
|
-
storage?: StorageConfig;
|
|
88
|
-
generateId?: (resource: "session" | "message" | "part" | "sandbox" | "command") => string;
|
|
89
|
-
} & SessionOptions<TMcp>;
|
|
90
|
-
type TagsSchema = Record<string, unknown>;
|
|
91
|
-
declare const agent: <TMcp extends McpConfig = {}>(options: AgentOptions<TMcp>) => {
|
|
92
|
-
session: <TTags extends TagsSchema = TagsSchema, TMcpOverride extends McpConfig = {}>(sessionId: string, sessionOptions?: SessionOptions<TMcp & TMcpOverride, TTags>) => Promise<{
|
|
93
|
-
send: ({ input, mcpContext, }: {
|
|
94
|
-
input: SendInput | SendInput[];
|
|
95
|
-
mcpContext?: McpSendOptions<TMcp & TMcpOverride>;
|
|
96
|
-
}) => Promise<void | SessionError>;
|
|
97
|
-
stream: (opts?: {
|
|
98
|
-
messageId?: string;
|
|
99
|
-
}) => Promise<SessionNotFoundError | SessionError | StorageError | ReadableStream<any>>;
|
|
100
|
-
ui: () => Promise<StorageError | {
|
|
101
|
-
messages: UIMessage<unknown, ai.UIDataTypes, ai.UITools>[];
|
|
102
|
-
streamingMessageId: string | null;
|
|
103
|
-
}>;
|
|
104
|
-
tag: {
|
|
105
|
-
list: () => Promise<SessionNotFoundError | StorageError | TTags>;
|
|
106
|
-
get: (key: string) => Promise<SessionNotFoundError | StorageError | TTags[string] | undefined>;
|
|
107
|
-
set: (key: string, value: unknown) => Promise<StorageError | undefined>;
|
|
108
|
-
setMany: (tags: Record<string, unknown>) => Promise<StorageError | undefined>;
|
|
109
|
-
};
|
|
110
|
-
sandbox: Sandbox;
|
|
111
|
-
}>;
|
|
112
|
-
sandbox: (sandboxId: string, config?: SandboxConfig) => Promise<Sandbox>;
|
|
113
|
-
storage: Storage;
|
|
114
|
-
handleMcpToolCall: (body: McpToolCallBody, handlers: Record<string, (opts: {
|
|
115
|
-
input: unknown;
|
|
116
|
-
headers: Record<string, string>;
|
|
117
|
-
body: McpToolCallBody;
|
|
118
|
-
}) => Promise<unknown>>) => Promise<{
|
|
119
|
-
result: unknown;
|
|
120
|
-
} | {
|
|
121
|
-
error: {
|
|
122
|
-
code: string;
|
|
123
|
-
message: string;
|
|
124
|
-
};
|
|
125
|
-
}>;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
export { type AgentOptions, type Handlers, type RpcRequest, type RpcResponse, Sandbox, SandboxConfig, type SendInput, SessionNotFoundError, StorageConfig, StorageError, type TagsSchema, agent, handleStorageRpc, mcp };
|
|
27
|
+
export { type Handlers, type RpcRequest, type RpcResponse, handleStorageRpc };
|