@simple-ai-lab/sdk 0.4.0 → 0.8.0
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 +79 -1
- package/dist/actions.cjs +452 -0
- package/dist/actions.d.cts +348 -0
- package/dist/actions.d.ts +348 -0
- package/dist/actions.js +443 -0
- package/dist/agents.cjs +1176 -0
- package/dist/agents.d.cts +1138 -0
- package/dist/agents.d.ts +1138 -0
- package/dist/agents.js +1166 -0
- package/dist/built-in-actions.cjs +456 -0
- package/dist/built-in-actions.d.cts +53 -0
- package/dist/built-in-actions.d.ts +53 -0
- package/dist/built-in-actions.js +453 -0
- package/dist/client.cjs +29 -0
- package/dist/client.d.cts +15 -0
- package/dist/client.d.ts +15 -0
- package/dist/client.js +25 -0
- package/dist/code-action/defaults.cjs +11 -0
- package/dist/code-action/defaults.d.cts +7 -0
- package/dist/code-action/defaults.d.ts +7 -0
- package/dist/code-action/defaults.js +8 -0
- package/dist/code-action/define-action.cjs +78 -0
- package/dist/code-action/define-action.d.cts +99 -0
- package/dist/code-action/define-action.d.ts +99 -0
- package/dist/code-action/define-action.js +73 -0
- package/dist/code-action/index.cjs +11 -0
- package/dist/code-action/index.d.cts +4 -0
- package/dist/code-action/index.d.ts +4 -0
- package/dist/code-action/index.js +3 -0
- package/dist/code-action/llm.cjs +34 -0
- package/dist/code-action/llm.d.cts +28 -0
- package/dist/code-action/llm.d.ts +28 -0
- package/dist/code-action/llm.js +31 -0
- package/dist/code-action/types.cjs +14 -0
- package/dist/code-action/types.d.cts +19 -0
- package/dist/code-action/types.d.ts +19 -0
- package/dist/code-action/types.js +11 -0
- package/dist/code-action/workflow.cjs +29 -0
- package/dist/code-action/workflow.d.cts +53 -0
- package/dist/code-action/workflow.d.ts +53 -0
- package/dist/code-action/workflow.js +26 -0
- package/dist/data.cjs +98 -0
- package/dist/data.d.cts +44 -0
- package/dist/data.d.ts +44 -0
- package/dist/data.js +94 -0
- package/dist/http.cjs +72 -0
- package/dist/http.d.cts +14 -0
- package/dist/http.d.ts +14 -0
- package/dist/http.js +69 -0
- package/dist/index.cjs +71 -1597
- package/dist/index.d.cts +12 -780
- package/dist/index.d.ts +12 -780
- package/dist/index.js +10 -1311
- package/dist/projects.cjs +234 -0
- package/dist/projects.d.cts +24 -0
- package/dist/projects.d.ts +24 -0
- package/dist/projects.js +228 -0
- package/dist/schemas.cjs +50 -0
- package/dist/schemas.d.cts +81 -0
- package/dist/schemas.d.ts +81 -0
- package/dist/schemas.js +47 -0
- package/dist/shared/errors.cjs +31 -0
- package/dist/shared/errors.d.cts +22 -0
- package/dist/shared/errors.d.ts +22 -0
- package/dist/shared/errors.js +26 -0
- package/package.json +27 -31
- package/dist/chunk-V4E5PSKB.js +0 -267
- package/dist/chunk-V4E5PSKB.js.map +0 -1
- package/dist/code-action-CDt77m7I.d.cts +0 -191
- package/dist/code-action-CDt77m7I.d.ts +0 -191
- package/dist/code-action.cjs +0 -282
- package/dist/code-action.cjs.map +0 -1
- package/dist/code-action.d.cts +0 -2
- package/dist/code-action.d.ts +0 -2
- package/dist/code-action.js +0 -9
- package/dist/code-action.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { builtInOperationSchema } from "./built-in-actions.cjs";
|
|
3
|
+
export type ActionsIoScalarType = 'string' | 'number' | 'boolean';
|
|
4
|
+
export type ActionsIoSchemaNode = {
|
|
5
|
+
type: ActionsIoScalarType;
|
|
6
|
+
description: string;
|
|
7
|
+
nullable: boolean;
|
|
8
|
+
} | {
|
|
9
|
+
type: 'object';
|
|
10
|
+
description: string;
|
|
11
|
+
nullable: boolean;
|
|
12
|
+
properties: Record<string, ActionsIoSchemaNode>;
|
|
13
|
+
required: string[];
|
|
14
|
+
additionalProperties: boolean;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'array';
|
|
17
|
+
description: string;
|
|
18
|
+
nullable: boolean;
|
|
19
|
+
items?: ActionsIoSchemaNode;
|
|
20
|
+
};
|
|
21
|
+
export type ActionsIoSchema = {
|
|
22
|
+
type: 'object';
|
|
23
|
+
description: string;
|
|
24
|
+
properties: Record<string, ActionsIoSchemaNode>;
|
|
25
|
+
required: string[];
|
|
26
|
+
additionalProperties: boolean;
|
|
27
|
+
};
|
|
28
|
+
export type HttpActionValues = {
|
|
29
|
+
actionType: 'http';
|
|
30
|
+
name: string;
|
|
31
|
+
description: string;
|
|
32
|
+
inputSchema: ActionsIoSchema;
|
|
33
|
+
outputSchema: ActionsIoSchema;
|
|
34
|
+
outputMappings: Record<string, string>;
|
|
35
|
+
operation: {
|
|
36
|
+
type: 'request';
|
|
37
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
38
|
+
urlTemplate: string;
|
|
39
|
+
headers: {
|
|
40
|
+
name: string;
|
|
41
|
+
valueTemplate: string;
|
|
42
|
+
}[];
|
|
43
|
+
bodyTemplate: string | null;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export type CodeActionValues = {
|
|
47
|
+
actionType: 'code';
|
|
48
|
+
name: string;
|
|
49
|
+
description: string;
|
|
50
|
+
inputSchema: ActionsIoSchema;
|
|
51
|
+
outputSchema: ActionsIoSchema;
|
|
52
|
+
outputMappings: Record<string, string>;
|
|
53
|
+
operation: {
|
|
54
|
+
type: 'execute';
|
|
55
|
+
language: 'typescript';
|
|
56
|
+
source: string;
|
|
57
|
+
compiledJs: string | null;
|
|
58
|
+
runtime: 'cloudflare-worker';
|
|
59
|
+
timeoutMs: number;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export type CustomDataActionValues = {
|
|
63
|
+
actionType: 'custom_data';
|
|
64
|
+
name: string;
|
|
65
|
+
description: string;
|
|
66
|
+
inputSchema: ActionsIoSchema;
|
|
67
|
+
outputSchema: ActionsIoSchema;
|
|
68
|
+
outputMappings: Record<string, string>;
|
|
69
|
+
operation: {
|
|
70
|
+
type: 'agent_search';
|
|
71
|
+
table: string;
|
|
72
|
+
aiFacetingEnabled: boolean;
|
|
73
|
+
transform: CustomDataTransformValues | null;
|
|
74
|
+
} | {
|
|
75
|
+
type: 'query';
|
|
76
|
+
sql: string;
|
|
77
|
+
transform: CustomDataTransformValues | null;
|
|
78
|
+
} | {
|
|
79
|
+
type: 'search';
|
|
80
|
+
table: string;
|
|
81
|
+
bodyTemplate: string;
|
|
82
|
+
transform: CustomDataTransformValues | null;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
export type CustomDataTransformValues = Omit<CodeActionValues['operation'], 'type'>;
|
|
86
|
+
export type KnowledgeBaseActionValues = {
|
|
87
|
+
actionType: 'knowledge_base';
|
|
88
|
+
name: string;
|
|
89
|
+
description: string;
|
|
90
|
+
inputSchema: ActionsIoSchema;
|
|
91
|
+
outputSchema: ActionsIoSchema;
|
|
92
|
+
outputMappings: Record<string, string>;
|
|
93
|
+
operation: {
|
|
94
|
+
type: 'search';
|
|
95
|
+
knowledgeBaseIds: string[];
|
|
96
|
+
bodyTemplate: string;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* A built-in Action. Its operation names the built-in behavior and the
|
|
101
|
+
* organization resource it acts through; the input and output schemas and the
|
|
102
|
+
* output mappings are fixed by Agent v2 and validated at save time.
|
|
103
|
+
*/
|
|
104
|
+
export type BuiltInOperation = z.infer<typeof builtInOperationSchema>;
|
|
105
|
+
export type BuiltInActionValues = {
|
|
106
|
+
actionType: 'built_in';
|
|
107
|
+
name: string;
|
|
108
|
+
description: string;
|
|
109
|
+
inputSchema: ActionsIoSchema;
|
|
110
|
+
outputSchema: ActionsIoSchema;
|
|
111
|
+
outputMappings: Record<string, string>;
|
|
112
|
+
operation: BuiltInOperation;
|
|
113
|
+
};
|
|
114
|
+
export type ActionVersionValues = HttpActionValues | CodeActionValues | CustomDataActionValues | KnowledgeBaseActionValues | BuiltInActionValues;
|
|
115
|
+
type ActionContract = {
|
|
116
|
+
inputSchema: ActionsIoSchema;
|
|
117
|
+
outputSchema: ActionsIoSchema;
|
|
118
|
+
};
|
|
119
|
+
export type InlineActionDefinition = {
|
|
120
|
+
kind: 'inline';
|
|
121
|
+
key: string;
|
|
122
|
+
contract: ActionContract;
|
|
123
|
+
compile: (options: ActionCompileOptions) => ActionVersionValues;
|
|
124
|
+
};
|
|
125
|
+
export type ReferencedActionDefinition = {
|
|
126
|
+
kind: 'reference';
|
|
127
|
+
key: string;
|
|
128
|
+
versionUuid: string;
|
|
129
|
+
contract: ActionContract | null;
|
|
130
|
+
};
|
|
131
|
+
export type ActionDefinition = InlineActionDefinition | ReferencedActionDefinition;
|
|
132
|
+
export type AgentActionInput = {
|
|
133
|
+
source: 'agent';
|
|
134
|
+
description: string;
|
|
135
|
+
} | {
|
|
136
|
+
source: 'template';
|
|
137
|
+
value: string;
|
|
138
|
+
description?: string;
|
|
139
|
+
};
|
|
140
|
+
/** Maps each Action output name to the Agent parameter that should receive its value. */
|
|
141
|
+
export type ActionOutputParameters = Record<string, string>;
|
|
142
|
+
/**
|
|
143
|
+
* What the agent says while a callable Action runs. `authored` speaks `text`
|
|
144
|
+
* verbatim; `model` treats `text` as instructions and lets the model phrase it.
|
|
145
|
+
* `null`, the default, says nothing.
|
|
146
|
+
*/
|
|
147
|
+
export type BackgroundMessage = {
|
|
148
|
+
source: 'authored' | 'model';
|
|
149
|
+
text: string;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Where an Action's outputs are saved, keyed by Agent parameter and valued by
|
|
153
|
+
* the template that fills it, as Agent v2 stores it. `outputParameters` covers
|
|
154
|
+
* one output saved straight into one parameter; this covers the rest.
|
|
155
|
+
*/
|
|
156
|
+
export type ActionOutputParameterMappings = Record<string, string>;
|
|
157
|
+
export type CallableActionDefinition = {
|
|
158
|
+
kind: 'callable';
|
|
159
|
+
key: string;
|
|
160
|
+
action: ActionDefinition;
|
|
161
|
+
name: string;
|
|
162
|
+
description: string;
|
|
163
|
+
inputs: Record<string, AgentActionInput>;
|
|
164
|
+
outputParameters?: ActionOutputParameters;
|
|
165
|
+
outputParameterMappings?: ActionOutputParameterMappings;
|
|
166
|
+
backgroundMessage: BackgroundMessage | null;
|
|
167
|
+
};
|
|
168
|
+
export type ActionRunDefinition = {
|
|
169
|
+
kind: 'run';
|
|
170
|
+
key: string;
|
|
171
|
+
action: ActionDefinition;
|
|
172
|
+
inputs: Record<string, string>;
|
|
173
|
+
outputParameters?: ActionOutputParameters;
|
|
174
|
+
outputParameterMappings?: ActionOutputParameterMappings;
|
|
175
|
+
};
|
|
176
|
+
export type SourceFileReference = {
|
|
177
|
+
kind: 'source-file';
|
|
178
|
+
path: string;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* An Action's input or output. `ActionsIoSchema` is what Agent v2 stores and Zod
|
|
182
|
+
* is a convenience over it, so the stored form is accepted directly for the
|
|
183
|
+
* shapes Zod has no equivalent for.
|
|
184
|
+
*/
|
|
185
|
+
export type ActionIoInput = z.ZodObject<z.ZodRawShape> | ActionsIoSchema;
|
|
186
|
+
/**
|
|
187
|
+
* An HTTP Action's headers. Agent v2 stores an ordered list, so the same name
|
|
188
|
+
* may appear twice; the record form covers the ordinary case.
|
|
189
|
+
*/
|
|
190
|
+
export type ActionHttpHeaders = Record<string, string> | {
|
|
191
|
+
name: string;
|
|
192
|
+
valueTemplate: string;
|
|
193
|
+
}[];
|
|
194
|
+
export declare function resolveActionHttpHeaders(headers: ActionHttpHeaders | undefined): {
|
|
195
|
+
name: string;
|
|
196
|
+
valueTemplate: string;
|
|
197
|
+
}[];
|
|
198
|
+
export declare function resolveActionIoSchema(schema: ActionIoInput): ActionsIoSchema;
|
|
199
|
+
type SchemaPair = {
|
|
200
|
+
input: ActionIoInput;
|
|
201
|
+
output: ActionIoInput;
|
|
202
|
+
};
|
|
203
|
+
type CommonActionConfig<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape> = {
|
|
204
|
+
key: string;
|
|
205
|
+
name: string;
|
|
206
|
+
description: string;
|
|
207
|
+
input: ActionIoInput;
|
|
208
|
+
output: ActionIoInput;
|
|
209
|
+
outputMappings: Record<string, string>;
|
|
210
|
+
};
|
|
211
|
+
type HttpActionConfig<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape> = CommonActionConfig<TInputShape, TOutputShape> & {
|
|
212
|
+
request: {
|
|
213
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
214
|
+
url: string;
|
|
215
|
+
headers?: ActionHttpHeaders;
|
|
216
|
+
body?: string | null;
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
type CodeActionConfig<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape> = CommonActionConfig<TInputShape, TOutputShape> & {
|
|
220
|
+
source: string | SourceFileReference;
|
|
221
|
+
timeoutMs?: number;
|
|
222
|
+
};
|
|
223
|
+
type CustomDataQueryActionConfig<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape> = CommonActionConfig<TInputShape, TOutputShape> & {
|
|
224
|
+
sql: string;
|
|
225
|
+
transform?: CustomDataTransformConfig | null;
|
|
226
|
+
};
|
|
227
|
+
type CustomDataSearchActionConfig<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape> = CommonActionConfig<TInputShape, TOutputShape> & {
|
|
228
|
+
table: string;
|
|
229
|
+
body: string;
|
|
230
|
+
transform?: CustomDataTransformConfig | null;
|
|
231
|
+
};
|
|
232
|
+
type CustomDataTransformConfig = {
|
|
233
|
+
source: string | SourceFileReference;
|
|
234
|
+
timeoutMs?: number;
|
|
235
|
+
};
|
|
236
|
+
type CustomDataActionCommonConfig<TOutputShape extends z.ZodRawShape> = {
|
|
237
|
+
key: string;
|
|
238
|
+
name: string;
|
|
239
|
+
description: string;
|
|
240
|
+
output: ActionIoInput;
|
|
241
|
+
outputMappings: Record<string, string>;
|
|
242
|
+
transform?: CustomDataTransformConfig | null;
|
|
243
|
+
};
|
|
244
|
+
type CustomDataActionConfig<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape> = CustomDataActionCommonConfig<TOutputShape> & ({
|
|
245
|
+
operation: {
|
|
246
|
+
type: 'agent_search';
|
|
247
|
+
table: string;
|
|
248
|
+
aiFacetingEnabled?: boolean;
|
|
249
|
+
};
|
|
250
|
+
input?: never;
|
|
251
|
+
} | {
|
|
252
|
+
operation: {
|
|
253
|
+
type: 'query';
|
|
254
|
+
sql: string;
|
|
255
|
+
};
|
|
256
|
+
input: ActionIoInput;
|
|
257
|
+
} | {
|
|
258
|
+
operation: {
|
|
259
|
+
type: 'search';
|
|
260
|
+
table: string;
|
|
261
|
+
body: string;
|
|
262
|
+
};
|
|
263
|
+
input: ActionIoInput;
|
|
264
|
+
});
|
|
265
|
+
type KnowledgeBaseSearchActionConfig<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape> = CommonActionConfig<TInputShape, TOutputShape> & {
|
|
266
|
+
knowledgeBaseIds: string[];
|
|
267
|
+
body: string;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Built-ins use the Agent v2 contract unless a pulled version supplies its
|
|
271
|
+
* complete stored contract, using the same schema parameters as other Actions.
|
|
272
|
+
*/
|
|
273
|
+
type BuiltInActionConfig = {
|
|
274
|
+
key: string;
|
|
275
|
+
name: string;
|
|
276
|
+
description: string;
|
|
277
|
+
contract?: never;
|
|
278
|
+
} & ((SchemaPair & {
|
|
279
|
+
outputMappings: Record<string, string>;
|
|
280
|
+
}) | {
|
|
281
|
+
input?: never;
|
|
282
|
+
output?: never;
|
|
283
|
+
outputMappings?: never;
|
|
284
|
+
});
|
|
285
|
+
type SendEmailActionConfig = BuiltInActionConfig & {
|
|
286
|
+
sendingDomainUuid: string;
|
|
287
|
+
fromLocalPart: string;
|
|
288
|
+
fromDisplayName?: string | null;
|
|
289
|
+
};
|
|
290
|
+
type SendTextMessageActionConfig = BuiltInActionConfig & {
|
|
291
|
+
senderPhoneNumberUuid: string;
|
|
292
|
+
};
|
|
293
|
+
type ValidateAddressActionConfig = BuiltInActionConfig;
|
|
294
|
+
type WebSearchActionConfig = BuiltInActionConfig & {
|
|
295
|
+
/**
|
|
296
|
+
* Only search these sites. Empty or omitted searches the open web. Each entry is a
|
|
297
|
+
* lowercase domain (`example.com`), a section of a site (`example.com/help`), or an
|
|
298
|
+
* ending (`.gov`).
|
|
299
|
+
*/
|
|
300
|
+
allowedDomains?: string[];
|
|
301
|
+
/** Never search these sites. Only applies to the open web, so it can't be combined with `allowedDomains`. */
|
|
302
|
+
blockedDomains?: string[];
|
|
303
|
+
};
|
|
304
|
+
export type ActionCompileOptions = {
|
|
305
|
+
readSourceFile?: (path: string) => string;
|
|
306
|
+
};
|
|
307
|
+
export declare function actionsIoSchemaFromZod<TShape extends z.ZodRawShape>(schema: z.ZodObject<TShape>): ActionsIoSchema;
|
|
308
|
+
/**
|
|
309
|
+
* Code Action source shared by SDK compilation, CLI comparisons, and file hashes.
|
|
310
|
+
* Surrounding whitespace is trimmed to match Agent v2. Line endings use LF for
|
|
311
|
+
* consistent comparisons across operating systems. Publishing writes this form.
|
|
312
|
+
*/
|
|
313
|
+
export declare function canonicalActionSource(source: string): string;
|
|
314
|
+
declare function compileCustomDataAction<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape>(config: CustomDataActionConfig<TInputShape, TOutputShape>): InlineActionDefinition;
|
|
315
|
+
export declare const action: {
|
|
316
|
+
http<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape>(config: HttpActionConfig<TInputShape, TOutputShape>): InlineActionDefinition;
|
|
317
|
+
code<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape>(config: CodeActionConfig<TInputShape, TOutputShape>): InlineActionDefinition;
|
|
318
|
+
customData: typeof compileCustomDataAction;
|
|
319
|
+
customDataAgentSearch<TOutputShape extends z.ZodRawShape>(config: CustomDataActionCommonConfig<TOutputShape> & {
|
|
320
|
+
table: string;
|
|
321
|
+
aiFacetingEnabled?: boolean;
|
|
322
|
+
}): InlineActionDefinition;
|
|
323
|
+
customDataQuery<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape>(config: CustomDataQueryActionConfig<TInputShape, TOutputShape>): InlineActionDefinition;
|
|
324
|
+
customDataSearch<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape>(config: CustomDataSearchActionConfig<TInputShape, TOutputShape>): InlineActionDefinition;
|
|
325
|
+
knowledgeBaseSearch<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape>(config: KnowledgeBaseSearchActionConfig<TInputShape, TOutputShape>): InlineActionDefinition;
|
|
326
|
+
/** Sends an email through a verified sending domain of the organization. */
|
|
327
|
+
sendEmail(config: SendEmailActionConfig): InlineActionDefinition;
|
|
328
|
+
/** Sends a text message from one of the organization's phone numbers. */
|
|
329
|
+
sendTextMessage(config: SendTextMessageActionConfig): InlineActionDefinition;
|
|
330
|
+
/** Validates and standardizes a postal address. */
|
|
331
|
+
validateAddress(config: ValidateAddressActionConfig): InlineActionDefinition;
|
|
332
|
+
/** Searches the web and returns the passages of each page most relevant to the question. */
|
|
333
|
+
webSearch(config: WebSearchActionConfig): InlineActionDefinition;
|
|
334
|
+
ref(config: {
|
|
335
|
+
key: string;
|
|
336
|
+
versionUuid: string;
|
|
337
|
+
contract?: ActionContract;
|
|
338
|
+
}): ReferencedActionDefinition;
|
|
339
|
+
callable(config: Omit<CallableActionDefinition, "kind" | "backgroundMessage"> & {
|
|
340
|
+
backgroundMessage?: BackgroundMessage | null;
|
|
341
|
+
}): CallableActionDefinition;
|
|
342
|
+
run(config: Omit<ActionRunDefinition, "kind">): ActionRunDefinition;
|
|
343
|
+
fromAgent(description: string): AgentActionInput;
|
|
344
|
+
from(value: string, description?: string): AgentActionInput;
|
|
345
|
+
};
|
|
346
|
+
export declare function compileAction(definition: InlineActionDefinition, options?: ActionCompileOptions): ActionVersionValues;
|
|
347
|
+
export declare function sourceFile(path: string): SourceFileReference;
|
|
348
|
+
export {};
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { builtInOperationSchema } from "./built-in-actions.js";
|
|
3
|
+
export type ActionsIoScalarType = 'string' | 'number' | 'boolean';
|
|
4
|
+
export type ActionsIoSchemaNode = {
|
|
5
|
+
type: ActionsIoScalarType;
|
|
6
|
+
description: string;
|
|
7
|
+
nullable: boolean;
|
|
8
|
+
} | {
|
|
9
|
+
type: 'object';
|
|
10
|
+
description: string;
|
|
11
|
+
nullable: boolean;
|
|
12
|
+
properties: Record<string, ActionsIoSchemaNode>;
|
|
13
|
+
required: string[];
|
|
14
|
+
additionalProperties: boolean;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'array';
|
|
17
|
+
description: string;
|
|
18
|
+
nullable: boolean;
|
|
19
|
+
items?: ActionsIoSchemaNode;
|
|
20
|
+
};
|
|
21
|
+
export type ActionsIoSchema = {
|
|
22
|
+
type: 'object';
|
|
23
|
+
description: string;
|
|
24
|
+
properties: Record<string, ActionsIoSchemaNode>;
|
|
25
|
+
required: string[];
|
|
26
|
+
additionalProperties: boolean;
|
|
27
|
+
};
|
|
28
|
+
export type HttpActionValues = {
|
|
29
|
+
actionType: 'http';
|
|
30
|
+
name: string;
|
|
31
|
+
description: string;
|
|
32
|
+
inputSchema: ActionsIoSchema;
|
|
33
|
+
outputSchema: ActionsIoSchema;
|
|
34
|
+
outputMappings: Record<string, string>;
|
|
35
|
+
operation: {
|
|
36
|
+
type: 'request';
|
|
37
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
38
|
+
urlTemplate: string;
|
|
39
|
+
headers: {
|
|
40
|
+
name: string;
|
|
41
|
+
valueTemplate: string;
|
|
42
|
+
}[];
|
|
43
|
+
bodyTemplate: string | null;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export type CodeActionValues = {
|
|
47
|
+
actionType: 'code';
|
|
48
|
+
name: string;
|
|
49
|
+
description: string;
|
|
50
|
+
inputSchema: ActionsIoSchema;
|
|
51
|
+
outputSchema: ActionsIoSchema;
|
|
52
|
+
outputMappings: Record<string, string>;
|
|
53
|
+
operation: {
|
|
54
|
+
type: 'execute';
|
|
55
|
+
language: 'typescript';
|
|
56
|
+
source: string;
|
|
57
|
+
compiledJs: string | null;
|
|
58
|
+
runtime: 'cloudflare-worker';
|
|
59
|
+
timeoutMs: number;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export type CustomDataActionValues = {
|
|
63
|
+
actionType: 'custom_data';
|
|
64
|
+
name: string;
|
|
65
|
+
description: string;
|
|
66
|
+
inputSchema: ActionsIoSchema;
|
|
67
|
+
outputSchema: ActionsIoSchema;
|
|
68
|
+
outputMappings: Record<string, string>;
|
|
69
|
+
operation: {
|
|
70
|
+
type: 'agent_search';
|
|
71
|
+
table: string;
|
|
72
|
+
aiFacetingEnabled: boolean;
|
|
73
|
+
transform: CustomDataTransformValues | null;
|
|
74
|
+
} | {
|
|
75
|
+
type: 'query';
|
|
76
|
+
sql: string;
|
|
77
|
+
transform: CustomDataTransformValues | null;
|
|
78
|
+
} | {
|
|
79
|
+
type: 'search';
|
|
80
|
+
table: string;
|
|
81
|
+
bodyTemplate: string;
|
|
82
|
+
transform: CustomDataTransformValues | null;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
export type CustomDataTransformValues = Omit<CodeActionValues['operation'], 'type'>;
|
|
86
|
+
export type KnowledgeBaseActionValues = {
|
|
87
|
+
actionType: 'knowledge_base';
|
|
88
|
+
name: string;
|
|
89
|
+
description: string;
|
|
90
|
+
inputSchema: ActionsIoSchema;
|
|
91
|
+
outputSchema: ActionsIoSchema;
|
|
92
|
+
outputMappings: Record<string, string>;
|
|
93
|
+
operation: {
|
|
94
|
+
type: 'search';
|
|
95
|
+
knowledgeBaseIds: string[];
|
|
96
|
+
bodyTemplate: string;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* A built-in Action. Its operation names the built-in behavior and the
|
|
101
|
+
* organization resource it acts through; the input and output schemas and the
|
|
102
|
+
* output mappings are fixed by Agent v2 and validated at save time.
|
|
103
|
+
*/
|
|
104
|
+
export type BuiltInOperation = z.infer<typeof builtInOperationSchema>;
|
|
105
|
+
export type BuiltInActionValues = {
|
|
106
|
+
actionType: 'built_in';
|
|
107
|
+
name: string;
|
|
108
|
+
description: string;
|
|
109
|
+
inputSchema: ActionsIoSchema;
|
|
110
|
+
outputSchema: ActionsIoSchema;
|
|
111
|
+
outputMappings: Record<string, string>;
|
|
112
|
+
operation: BuiltInOperation;
|
|
113
|
+
};
|
|
114
|
+
export type ActionVersionValues = HttpActionValues | CodeActionValues | CustomDataActionValues | KnowledgeBaseActionValues | BuiltInActionValues;
|
|
115
|
+
type ActionContract = {
|
|
116
|
+
inputSchema: ActionsIoSchema;
|
|
117
|
+
outputSchema: ActionsIoSchema;
|
|
118
|
+
};
|
|
119
|
+
export type InlineActionDefinition = {
|
|
120
|
+
kind: 'inline';
|
|
121
|
+
key: string;
|
|
122
|
+
contract: ActionContract;
|
|
123
|
+
compile: (options: ActionCompileOptions) => ActionVersionValues;
|
|
124
|
+
};
|
|
125
|
+
export type ReferencedActionDefinition = {
|
|
126
|
+
kind: 'reference';
|
|
127
|
+
key: string;
|
|
128
|
+
versionUuid: string;
|
|
129
|
+
contract: ActionContract | null;
|
|
130
|
+
};
|
|
131
|
+
export type ActionDefinition = InlineActionDefinition | ReferencedActionDefinition;
|
|
132
|
+
export type AgentActionInput = {
|
|
133
|
+
source: 'agent';
|
|
134
|
+
description: string;
|
|
135
|
+
} | {
|
|
136
|
+
source: 'template';
|
|
137
|
+
value: string;
|
|
138
|
+
description?: string;
|
|
139
|
+
};
|
|
140
|
+
/** Maps each Action output name to the Agent parameter that should receive its value. */
|
|
141
|
+
export type ActionOutputParameters = Record<string, string>;
|
|
142
|
+
/**
|
|
143
|
+
* What the agent says while a callable Action runs. `authored` speaks `text`
|
|
144
|
+
* verbatim; `model` treats `text` as instructions and lets the model phrase it.
|
|
145
|
+
* `null`, the default, says nothing.
|
|
146
|
+
*/
|
|
147
|
+
export type BackgroundMessage = {
|
|
148
|
+
source: 'authored' | 'model';
|
|
149
|
+
text: string;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Where an Action's outputs are saved, keyed by Agent parameter and valued by
|
|
153
|
+
* the template that fills it, as Agent v2 stores it. `outputParameters` covers
|
|
154
|
+
* one output saved straight into one parameter; this covers the rest.
|
|
155
|
+
*/
|
|
156
|
+
export type ActionOutputParameterMappings = Record<string, string>;
|
|
157
|
+
export type CallableActionDefinition = {
|
|
158
|
+
kind: 'callable';
|
|
159
|
+
key: string;
|
|
160
|
+
action: ActionDefinition;
|
|
161
|
+
name: string;
|
|
162
|
+
description: string;
|
|
163
|
+
inputs: Record<string, AgentActionInput>;
|
|
164
|
+
outputParameters?: ActionOutputParameters;
|
|
165
|
+
outputParameterMappings?: ActionOutputParameterMappings;
|
|
166
|
+
backgroundMessage: BackgroundMessage | null;
|
|
167
|
+
};
|
|
168
|
+
export type ActionRunDefinition = {
|
|
169
|
+
kind: 'run';
|
|
170
|
+
key: string;
|
|
171
|
+
action: ActionDefinition;
|
|
172
|
+
inputs: Record<string, string>;
|
|
173
|
+
outputParameters?: ActionOutputParameters;
|
|
174
|
+
outputParameterMappings?: ActionOutputParameterMappings;
|
|
175
|
+
};
|
|
176
|
+
export type SourceFileReference = {
|
|
177
|
+
kind: 'source-file';
|
|
178
|
+
path: string;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* An Action's input or output. `ActionsIoSchema` is what Agent v2 stores and Zod
|
|
182
|
+
* is a convenience over it, so the stored form is accepted directly for the
|
|
183
|
+
* shapes Zod has no equivalent for.
|
|
184
|
+
*/
|
|
185
|
+
export type ActionIoInput = z.ZodObject<z.ZodRawShape> | ActionsIoSchema;
|
|
186
|
+
/**
|
|
187
|
+
* An HTTP Action's headers. Agent v2 stores an ordered list, so the same name
|
|
188
|
+
* may appear twice; the record form covers the ordinary case.
|
|
189
|
+
*/
|
|
190
|
+
export type ActionHttpHeaders = Record<string, string> | {
|
|
191
|
+
name: string;
|
|
192
|
+
valueTemplate: string;
|
|
193
|
+
}[];
|
|
194
|
+
export declare function resolveActionHttpHeaders(headers: ActionHttpHeaders | undefined): {
|
|
195
|
+
name: string;
|
|
196
|
+
valueTemplate: string;
|
|
197
|
+
}[];
|
|
198
|
+
export declare function resolveActionIoSchema(schema: ActionIoInput): ActionsIoSchema;
|
|
199
|
+
type SchemaPair = {
|
|
200
|
+
input: ActionIoInput;
|
|
201
|
+
output: ActionIoInput;
|
|
202
|
+
};
|
|
203
|
+
type CommonActionConfig<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape> = {
|
|
204
|
+
key: string;
|
|
205
|
+
name: string;
|
|
206
|
+
description: string;
|
|
207
|
+
input: ActionIoInput;
|
|
208
|
+
output: ActionIoInput;
|
|
209
|
+
outputMappings: Record<string, string>;
|
|
210
|
+
};
|
|
211
|
+
type HttpActionConfig<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape> = CommonActionConfig<TInputShape, TOutputShape> & {
|
|
212
|
+
request: {
|
|
213
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
214
|
+
url: string;
|
|
215
|
+
headers?: ActionHttpHeaders;
|
|
216
|
+
body?: string | null;
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
type CodeActionConfig<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape> = CommonActionConfig<TInputShape, TOutputShape> & {
|
|
220
|
+
source: string | SourceFileReference;
|
|
221
|
+
timeoutMs?: number;
|
|
222
|
+
};
|
|
223
|
+
type CustomDataQueryActionConfig<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape> = CommonActionConfig<TInputShape, TOutputShape> & {
|
|
224
|
+
sql: string;
|
|
225
|
+
transform?: CustomDataTransformConfig | null;
|
|
226
|
+
};
|
|
227
|
+
type CustomDataSearchActionConfig<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape> = CommonActionConfig<TInputShape, TOutputShape> & {
|
|
228
|
+
table: string;
|
|
229
|
+
body: string;
|
|
230
|
+
transform?: CustomDataTransformConfig | null;
|
|
231
|
+
};
|
|
232
|
+
type CustomDataTransformConfig = {
|
|
233
|
+
source: string | SourceFileReference;
|
|
234
|
+
timeoutMs?: number;
|
|
235
|
+
};
|
|
236
|
+
type CustomDataActionCommonConfig<TOutputShape extends z.ZodRawShape> = {
|
|
237
|
+
key: string;
|
|
238
|
+
name: string;
|
|
239
|
+
description: string;
|
|
240
|
+
output: ActionIoInput;
|
|
241
|
+
outputMappings: Record<string, string>;
|
|
242
|
+
transform?: CustomDataTransformConfig | null;
|
|
243
|
+
};
|
|
244
|
+
type CustomDataActionConfig<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape> = CustomDataActionCommonConfig<TOutputShape> & ({
|
|
245
|
+
operation: {
|
|
246
|
+
type: 'agent_search';
|
|
247
|
+
table: string;
|
|
248
|
+
aiFacetingEnabled?: boolean;
|
|
249
|
+
};
|
|
250
|
+
input?: never;
|
|
251
|
+
} | {
|
|
252
|
+
operation: {
|
|
253
|
+
type: 'query';
|
|
254
|
+
sql: string;
|
|
255
|
+
};
|
|
256
|
+
input: ActionIoInput;
|
|
257
|
+
} | {
|
|
258
|
+
operation: {
|
|
259
|
+
type: 'search';
|
|
260
|
+
table: string;
|
|
261
|
+
body: string;
|
|
262
|
+
};
|
|
263
|
+
input: ActionIoInput;
|
|
264
|
+
});
|
|
265
|
+
type KnowledgeBaseSearchActionConfig<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape> = CommonActionConfig<TInputShape, TOutputShape> & {
|
|
266
|
+
knowledgeBaseIds: string[];
|
|
267
|
+
body: string;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Built-ins use the Agent v2 contract unless a pulled version supplies its
|
|
271
|
+
* complete stored contract, using the same schema parameters as other Actions.
|
|
272
|
+
*/
|
|
273
|
+
type BuiltInActionConfig = {
|
|
274
|
+
key: string;
|
|
275
|
+
name: string;
|
|
276
|
+
description: string;
|
|
277
|
+
contract?: never;
|
|
278
|
+
} & ((SchemaPair & {
|
|
279
|
+
outputMappings: Record<string, string>;
|
|
280
|
+
}) | {
|
|
281
|
+
input?: never;
|
|
282
|
+
output?: never;
|
|
283
|
+
outputMappings?: never;
|
|
284
|
+
});
|
|
285
|
+
type SendEmailActionConfig = BuiltInActionConfig & {
|
|
286
|
+
sendingDomainUuid: string;
|
|
287
|
+
fromLocalPart: string;
|
|
288
|
+
fromDisplayName?: string | null;
|
|
289
|
+
};
|
|
290
|
+
type SendTextMessageActionConfig = BuiltInActionConfig & {
|
|
291
|
+
senderPhoneNumberUuid: string;
|
|
292
|
+
};
|
|
293
|
+
type ValidateAddressActionConfig = BuiltInActionConfig;
|
|
294
|
+
type WebSearchActionConfig = BuiltInActionConfig & {
|
|
295
|
+
/**
|
|
296
|
+
* Only search these sites. Empty or omitted searches the open web. Each entry is a
|
|
297
|
+
* lowercase domain (`example.com`), a section of a site (`example.com/help`), or an
|
|
298
|
+
* ending (`.gov`).
|
|
299
|
+
*/
|
|
300
|
+
allowedDomains?: string[];
|
|
301
|
+
/** Never search these sites. Only applies to the open web, so it can't be combined with `allowedDomains`. */
|
|
302
|
+
blockedDomains?: string[];
|
|
303
|
+
};
|
|
304
|
+
export type ActionCompileOptions = {
|
|
305
|
+
readSourceFile?: (path: string) => string;
|
|
306
|
+
};
|
|
307
|
+
export declare function actionsIoSchemaFromZod<TShape extends z.ZodRawShape>(schema: z.ZodObject<TShape>): ActionsIoSchema;
|
|
308
|
+
/**
|
|
309
|
+
* Code Action source shared by SDK compilation, CLI comparisons, and file hashes.
|
|
310
|
+
* Surrounding whitespace is trimmed to match Agent v2. Line endings use LF for
|
|
311
|
+
* consistent comparisons across operating systems. Publishing writes this form.
|
|
312
|
+
*/
|
|
313
|
+
export declare function canonicalActionSource(source: string): string;
|
|
314
|
+
declare function compileCustomDataAction<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape>(config: CustomDataActionConfig<TInputShape, TOutputShape>): InlineActionDefinition;
|
|
315
|
+
export declare const action: {
|
|
316
|
+
http<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape>(config: HttpActionConfig<TInputShape, TOutputShape>): InlineActionDefinition;
|
|
317
|
+
code<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape>(config: CodeActionConfig<TInputShape, TOutputShape>): InlineActionDefinition;
|
|
318
|
+
customData: typeof compileCustomDataAction;
|
|
319
|
+
customDataAgentSearch<TOutputShape extends z.ZodRawShape>(config: CustomDataActionCommonConfig<TOutputShape> & {
|
|
320
|
+
table: string;
|
|
321
|
+
aiFacetingEnabled?: boolean;
|
|
322
|
+
}): InlineActionDefinition;
|
|
323
|
+
customDataQuery<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape>(config: CustomDataQueryActionConfig<TInputShape, TOutputShape>): InlineActionDefinition;
|
|
324
|
+
customDataSearch<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape>(config: CustomDataSearchActionConfig<TInputShape, TOutputShape>): InlineActionDefinition;
|
|
325
|
+
knowledgeBaseSearch<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape>(config: KnowledgeBaseSearchActionConfig<TInputShape, TOutputShape>): InlineActionDefinition;
|
|
326
|
+
/** Sends an email through a verified sending domain of the organization. */
|
|
327
|
+
sendEmail(config: SendEmailActionConfig): InlineActionDefinition;
|
|
328
|
+
/** Sends a text message from one of the organization's phone numbers. */
|
|
329
|
+
sendTextMessage(config: SendTextMessageActionConfig): InlineActionDefinition;
|
|
330
|
+
/** Validates and standardizes a postal address. */
|
|
331
|
+
validateAddress(config: ValidateAddressActionConfig): InlineActionDefinition;
|
|
332
|
+
/** Searches the web and returns the passages of each page most relevant to the question. */
|
|
333
|
+
webSearch(config: WebSearchActionConfig): InlineActionDefinition;
|
|
334
|
+
ref(config: {
|
|
335
|
+
key: string;
|
|
336
|
+
versionUuid: string;
|
|
337
|
+
contract?: ActionContract;
|
|
338
|
+
}): ReferencedActionDefinition;
|
|
339
|
+
callable(config: Omit<CallableActionDefinition, "kind" | "backgroundMessage"> & {
|
|
340
|
+
backgroundMessage?: BackgroundMessage | null;
|
|
341
|
+
}): CallableActionDefinition;
|
|
342
|
+
run(config: Omit<ActionRunDefinition, "kind">): ActionRunDefinition;
|
|
343
|
+
fromAgent(description: string): AgentActionInput;
|
|
344
|
+
from(value: string, description?: string): AgentActionInput;
|
|
345
|
+
};
|
|
346
|
+
export declare function compileAction(definition: InlineActionDefinition, options?: ActionCompileOptions): ActionVersionValues;
|
|
347
|
+
export declare function sourceFile(path: string): SourceFileReference;
|
|
348
|
+
export {};
|