@simple-ai-lab/sdk 0.3.0 → 0.6.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.
Files changed (64) hide show
  1. package/README.md +56 -3
  2. package/dist/actions.cjs +438 -0
  3. package/dist/actions.d.cts +336 -0
  4. package/dist/actions.d.ts +336 -0
  5. package/dist/actions.js +429 -0
  6. package/dist/agents.cjs +1054 -0
  7. package/dist/agents.d.cts +1016 -0
  8. package/dist/agents.d.ts +1016 -0
  9. package/dist/agents.js +1044 -0
  10. package/dist/built-in-actions.cjs +356 -0
  11. package/dist/built-in-actions.d.cts +41 -0
  12. package/dist/built-in-actions.d.ts +41 -0
  13. package/dist/built-in-actions.js +353 -0
  14. package/dist/client.cjs +29 -0
  15. package/dist/client.d.cts +15 -0
  16. package/dist/client.d.ts +15 -0
  17. package/dist/client.js +25 -0
  18. package/dist/code-action/defaults.cjs +11 -0
  19. package/dist/code-action/defaults.d.cts +7 -0
  20. package/dist/code-action/defaults.d.ts +7 -0
  21. package/dist/code-action/defaults.js +8 -0
  22. package/dist/code-action/define-action.cjs +74 -0
  23. package/dist/code-action/define-action.d.cts +94 -0
  24. package/dist/code-action/define-action.d.ts +94 -0
  25. package/dist/code-action/define-action.js +69 -0
  26. package/dist/code-action/index.cjs +11 -0
  27. package/dist/code-action/index.d.cts +4 -0
  28. package/dist/code-action/index.d.ts +4 -0
  29. package/dist/code-action/index.js +3 -0
  30. package/dist/code-action/types.cjs +13 -0
  31. package/dist/code-action/types.d.cts +13 -0
  32. package/dist/code-action/types.d.ts +13 -0
  33. package/dist/code-action/types.js +10 -0
  34. package/dist/code-action/workflow.cjs +29 -0
  35. package/dist/code-action/workflow.d.cts +53 -0
  36. package/dist/code-action/workflow.d.ts +53 -0
  37. package/dist/code-action/workflow.js +26 -0
  38. package/dist/data.cjs +98 -0
  39. package/dist/data.d.cts +44 -0
  40. package/dist/data.d.ts +44 -0
  41. package/dist/data.js +94 -0
  42. package/dist/http.cjs +65 -0
  43. package/dist/http.d.cts +14 -0
  44. package/dist/http.d.ts +14 -0
  45. package/dist/http.js +62 -0
  46. package/dist/index.cjs +68 -1593
  47. package/dist/index.d.cts +12 -961
  48. package/dist/index.d.ts +12 -961
  49. package/dist/index.js +10 -1540
  50. package/dist/projects.cjs +234 -0
  51. package/dist/projects.d.cts +24 -0
  52. package/dist/projects.d.ts +24 -0
  53. package/dist/projects.js +228 -0
  54. package/dist/schemas.cjs +50 -0
  55. package/dist/schemas.d.cts +81 -0
  56. package/dist/schemas.d.ts +81 -0
  57. package/dist/schemas.js +47 -0
  58. package/dist/shared/errors.cjs +31 -0
  59. package/dist/shared/errors.d.cts +22 -0
  60. package/dist/shared/errors.d.ts +22 -0
  61. package/dist/shared/errors.js +26 -0
  62. package/package.json +27 -21
  63. package/dist/index.cjs.map +0 -1
  64. package/dist/index.js.map +0 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Simple AI SDK
2
2
 
3
- Typed TypeScript client for the [Simple AI](https://usesimple.ai) API. Use it inside Simple AI code actions (preinstalled and authenticated automatically) or in your own applications with an API key.
3
+ Typed TypeScript client for the [Simple AI](https://usesimple.ai) API. Use it inside Simple AI code actions (bundled and authenticated automatically) or in your own applications with an API key.
4
4
 
5
5
  ```bash
6
6
  npm install @simple-ai-lab/sdk
@@ -16,11 +16,52 @@ export default defineAction(async ({ inputs, config, client }) => {
16
16
  tableName: 'customers',
17
17
  filters: [{ column: 'email', values: [inputs.email] }],
18
18
  });
19
+
19
20
  return { found: records.length > 0 };
20
21
  });
21
22
  ```
22
23
 
23
- No API key handling needed — the sandbox injects short-lived, organization-scoped credentials automatically.
24
+ No API key handling needed. Simple routes SDK requests through a protected outbound binding that injects a short-lived, organization-scoped credential without exposing it to action code.
25
+
26
+ ### Steering the conversation
27
+
28
+ An action invoked from a workflow can send the caller somewhere else. `workflow.transitionTo` records the node to run next, so the agent goes there instead of following the node's own edges. It returns normally: the rest of your handler still runs, and the value you return is still mapped to the action's outputs.
29
+
30
+ ```typescript
31
+ import { defineAction } from '@simple-ai-lab/sdk';
32
+
33
+ export default defineAction(async ({ inputs, client, workflow }) => {
34
+ const { records } = await client.data.query({
35
+ tableName: 'accounts',
36
+ filters: [{ column: 'email', values: [inputs.email] }],
37
+ });
38
+
39
+ if (records[0]?.status === 'delinquent') {
40
+ workflow.transitionTo({
41
+ nodeName: 'Collections',
42
+ message: 'Let me get you to the right team.',
43
+ reason: 'account is delinquent',
44
+ });
45
+ }
46
+
47
+ return { status: records[0]?.status ?? 'unknown' };
48
+ });
49
+ ```
50
+
51
+ A transition accompanies the result rather than replacing it, so the example above both writes `status` to its outputs and moves the conversation. Asking twice keeps the last request, and an action that throws transitions nowhere.
52
+
53
+ The same action can run where there is no conversation to steer — as a per-turn action, an automatic before/after-call action, or in data sync. Those invocations do not grant `WORKFLOW_TRANSITION`, and `transitionTo` throws `MissingCapabilityError` instead. If your action runs in both places, check first:
54
+
55
+ ```typescript
56
+ import { ActionCapability, defineAction } from '@simple-ai-lab/sdk';
57
+
58
+ export default defineAction(async ({ metadata, workflow }) => {
59
+ if (metadata.capabilities.includes(ActionCapability.WORKFLOW_TRANSITION)) {
60
+ workflow.transitionTo({ nodeName: 'Collections' });
61
+ }
62
+ return { escalated: false };
63
+ });
64
+ ```
24
65
 
25
66
  ## In your own application
26
67
 
@@ -40,7 +81,7 @@ const { records, total } = await client.data.query({
40
81
 
41
82
  ## Define an agent
42
83
 
43
- Agent authoring is action-first: integrations are immutable Actions, and Agent commits pin exact Action versions. New source does not create legacy tools or HTTP graph nodes.
84
+ Agents use immutable Actions for integrations, and Agent commits pin exact Action versions. New source does not create legacy tools or HTTP graph nodes.
44
85
 
45
86
  ```typescript
46
87
  import { action, defineAgent, node, prompt } from '@simple-ai-lab/sdk';
@@ -89,6 +130,18 @@ export default defineAgent({
89
130
  });
90
131
  ```
91
132
 
133
+ `action.fromAgent(...)` sets an explicit input description override for that callable.
134
+ Inputs omitted from `inputs` inherit their Action schema descriptions at runtime;
135
+ the SDK leaves those overrides absent in the compiled Agent.
136
+
137
+ Built-in Actions use Agent v2 schemas by default. To preserve a pulled Action
138
+ version's stored schemas, provide `input`, `output`, and `outputMappings` together.
139
+
140
+ `call.backgroundNoise` takes the Agent v2 block, `{ trackName, gainMultiplier }`.
141
+ Leave `gainMultiplier` out to keep it out of the commit, and pass
142
+ `backgroundNoise: null` for an Agent with no background noise configured at all.
143
+ Left unset, the block follows `voice.backgroundNoise` at gain 1.
144
+
92
145
  Install `@simple-ai-lab/cli` for `simple init`, `pull`, `typecheck`, `diff`, and `publish`.
93
146
 
94
147
  ## Documentation
@@ -0,0 +1,438 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.action = void 0;
4
+ exports.resolveActionHttpHeaders = resolveActionHttpHeaders;
5
+ exports.resolveActionIoSchema = resolveActionIoSchema;
6
+ exports.actionsIoSchemaFromZod = actionsIoSchemaFromZod;
7
+ exports.canonicalActionSource = canonicalActionSource;
8
+ exports.compileAction = compileAction;
9
+ exports.sourceFile = sourceFile;
10
+ const zod_1 = require("zod");
11
+ const built_in_actions_1 = require("./built-in-actions.cjs");
12
+ function resolveActionHttpHeaders(headers) {
13
+ if (headers === undefined) {
14
+ return [];
15
+ }
16
+ return Array.isArray(headers)
17
+ ? headers
18
+ : Object.entries(headers).map(([name, valueTemplate]) => ({ name, valueTemplate }));
19
+ }
20
+ function resolveActionIoSchema(schema) {
21
+ return schema instanceof zod_1.z.ZodType ? actionsIoSchemaFromZod(schema) : schema;
22
+ }
23
+ function isRecord(value) {
24
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
25
+ }
26
+ function nullableJsonSchema(value) {
27
+ const type = value.type;
28
+ if (Array.isArray(type)) {
29
+ const nonNullTypes = type.filter((item) => item !== 'null');
30
+ if (nonNullTypes.length === 1 && typeof nonNullTypes[0] === 'string') {
31
+ return { schema: { ...value, type: nonNullTypes[0] }, nullable: type.includes('null') };
32
+ }
33
+ }
34
+ const anyOf = value.anyOf;
35
+ if (Array.isArray(anyOf)) {
36
+ const schemas = anyOf.filter(isRecord);
37
+ const nonNullSchemas = schemas.filter((schema) => schema.type !== 'null');
38
+ const containsNull = schemas.some((schema) => schema.type === 'null');
39
+ if (containsNull && nonNullSchemas.length === 1) {
40
+ const nonNullSchema = nonNullSchemas[0] ?? {};
41
+ return {
42
+ schema: {
43
+ ...nonNullSchema,
44
+ ...(typeof value.description === 'string' ? { description: value.description } : {}),
45
+ },
46
+ nullable: true,
47
+ };
48
+ }
49
+ }
50
+ return { schema: value, nullable: false };
51
+ }
52
+ function schemaDescription(schema) {
53
+ return typeof schema.description === 'string' ? schema.description : '';
54
+ }
55
+ function convertJsonSchemaNode(value, path) {
56
+ if (!isRecord(value)) {
57
+ throw new Error(`${path} is not a representable Zod schema`);
58
+ }
59
+ const { schema, nullable } = nullableJsonSchema(value);
60
+ if (schema.enum !== undefined || schema.const !== undefined) {
61
+ throw new Error(`${path} uses enum/const, which Actions I/O schemas do not support`);
62
+ }
63
+ switch (schema.type) {
64
+ case 'string':
65
+ case 'number':
66
+ case 'boolean':
67
+ return {
68
+ type: schema.type,
69
+ description: schemaDescription(schema),
70
+ nullable,
71
+ };
72
+ case 'object': {
73
+ const rawProperties = isRecord(schema.properties) ? schema.properties : {};
74
+ const properties = {};
75
+ for (const [name, child] of Object.entries(rawProperties)) {
76
+ if (!/^[A-Za-z_]\w*$/.test(name) || ['__proto__', 'constructor', 'prototype'].includes(name)) {
77
+ throw new Error(`${path}.${name} is not a valid Actions I/O property name`);
78
+ }
79
+ properties[name] = convertJsonSchemaNode(child, `${path}.${name}`);
80
+ }
81
+ const required = Array.isArray(schema.required)
82
+ ? schema.required.filter((name) => typeof name === 'string')
83
+ : [];
84
+ const additionalProperties = schema.additionalProperties === true;
85
+ return {
86
+ type: 'object',
87
+ description: schemaDescription(schema),
88
+ nullable,
89
+ properties,
90
+ required,
91
+ additionalProperties,
92
+ };
93
+ }
94
+ case 'array':
95
+ return {
96
+ type: 'array',
97
+ description: schemaDescription(schema),
98
+ nullable,
99
+ ...(schema.items === undefined ? {} : { items: convertJsonSchemaNode(schema.items, `${path}[]`) }),
100
+ };
101
+ case 'integer':
102
+ return {
103
+ type: 'number',
104
+ description: schemaDescription(schema),
105
+ nullable,
106
+ };
107
+ default:
108
+ throw new Error(`${path} uses unsupported Zod/JSON Schema type "${String(schema.type)}"`);
109
+ }
110
+ }
111
+ function actionsIoSchemaFromZod(schema) {
112
+ const converted = convertJsonSchemaNode(zod_1.z.toJSONSchema(schema), 'schema');
113
+ if (converted.type !== 'object') {
114
+ throw new Error('Action input and output schemas must be Zod objects');
115
+ }
116
+ return {
117
+ type: 'object',
118
+ description: converted.description,
119
+ properties: converted.properties,
120
+ required: converted.required,
121
+ additionalProperties: converted.additionalProperties,
122
+ };
123
+ }
124
+ function pointerForName(name) {
125
+ const escaped = name.replace(/~/g, '~0').replace(/\//g, '~1');
126
+ return `/${escaped}`;
127
+ }
128
+ function normalizeOutputMappings({ mappings, outputSchema, }) {
129
+ const normalized = Object.fromEntries(Object.entries(mappings).map(([name, template]) => [name.startsWith('/') ? name : pointerForName(name), template]));
130
+ for (const name of Object.keys(outputSchema.properties)) {
131
+ const pointer = pointerForName(name);
132
+ if (normalized[pointer] === undefined) {
133
+ throw new Error(`Action output "${name}" needs an output mapping`);
134
+ }
135
+ }
136
+ for (const pointer of Object.keys(normalized)) {
137
+ const firstToken = pointer.slice(1).split('/')[0]?.replace(/~1/g, '/').replace(/~0/g, '~');
138
+ if (firstToken === undefined || outputSchema.properties[firstToken] === undefined) {
139
+ throw new Error(`Action output mapping "${pointer}" does not reference a declared output`);
140
+ }
141
+ }
142
+ return normalized;
143
+ }
144
+ function compileContracts({ input, output }) {
145
+ return {
146
+ inputSchema: resolveActionIoSchema(input),
147
+ outputSchema: resolveActionIoSchema(output),
148
+ };
149
+ }
150
+ /**
151
+ * Code Action source shared by SDK compilation, CLI comparisons, and file hashes.
152
+ * Surrounding whitespace is trimmed to match Agent v2. Line endings use LF for
153
+ * consistent comparisons across operating systems. Publishing writes this form.
154
+ */
155
+ function canonicalActionSource(source) {
156
+ return source.replace(/\r\n?/g, '\n').trim();
157
+ }
158
+ /**
159
+ * Resolves a handler's TypeScript, whether it is written inline or kept in the
160
+ * file a `sourceFile(...)` reference names, in its canonical form.
161
+ */
162
+ function resolveActionSource({ source, options, }) {
163
+ if (typeof source === 'string') {
164
+ return canonicalActionSource(source);
165
+ }
166
+ if (options.readSourceFile === undefined) {
167
+ throw new Error(`Action source file "${source.path}" requires a readSourceFile compiler option`);
168
+ }
169
+ return canonicalActionSource(options.readSourceFile(source.path));
170
+ }
171
+ function compileHttpAction(config) {
172
+ const contract = compileContracts(config);
173
+ return {
174
+ kind: 'inline',
175
+ key: config.key,
176
+ contract,
177
+ compile: () => ({
178
+ actionType: 'http',
179
+ name: config.name,
180
+ description: config.description,
181
+ ...contract,
182
+ outputMappings: normalizeOutputMappings({
183
+ mappings: config.outputMappings,
184
+ outputSchema: contract.outputSchema,
185
+ }),
186
+ operation: {
187
+ type: 'request',
188
+ method: config.request.method,
189
+ urlTemplate: config.request.url,
190
+ headers: resolveActionHttpHeaders(config.request.headers),
191
+ bodyTemplate: config.request.body ?? null,
192
+ },
193
+ }),
194
+ };
195
+ }
196
+ function compileCodeAction(config) {
197
+ const contract = compileContracts(config);
198
+ return {
199
+ kind: 'inline',
200
+ key: config.key,
201
+ contract,
202
+ compile: (options) => ({
203
+ actionType: 'code',
204
+ name: config.name,
205
+ description: config.description,
206
+ ...contract,
207
+ outputMappings: normalizeOutputMappings({
208
+ mappings: config.outputMappings,
209
+ outputSchema: contract.outputSchema,
210
+ }),
211
+ operation: {
212
+ type: 'execute',
213
+ language: 'typescript',
214
+ source: resolveActionSource({ source: config.source, options }),
215
+ compiledJs: null,
216
+ runtime: 'cloudflare-worker',
217
+ timeoutMs: config.timeoutMs ?? 30_000,
218
+ },
219
+ }),
220
+ };
221
+ }
222
+ const CUSTOM_DATA_AGENT_SEARCH_INPUT_SCHEMA = {
223
+ type: 'object',
224
+ description: 'System-managed Custom Data search inputs.',
225
+ properties: {},
226
+ required: [],
227
+ additionalProperties: true,
228
+ };
229
+ function compileCustomDataTransform({ transform, options, }) {
230
+ if (transform == null) {
231
+ return null;
232
+ }
233
+ return {
234
+ language: 'typescript',
235
+ source: resolveActionSource({ source: transform.source, options }),
236
+ compiledJs: null,
237
+ runtime: 'cloudflare-worker',
238
+ timeoutMs: transform.timeoutMs ?? 30_000,
239
+ };
240
+ }
241
+ function compileCustomDataAction(config) {
242
+ const outputSchema = resolveActionIoSchema(config.output);
243
+ let inputSchema;
244
+ switch (config.operation.type) {
245
+ case 'agent_search':
246
+ inputSchema = CUSTOM_DATA_AGENT_SEARCH_INPUT_SCHEMA;
247
+ break;
248
+ case 'query':
249
+ case 'search':
250
+ if (config.input === undefined) {
251
+ throw new Error(`Custom Data ${config.operation.type} Actions require an input schema`);
252
+ }
253
+ inputSchema = resolveActionIoSchema(config.input);
254
+ break;
255
+ }
256
+ const contract = { inputSchema, outputSchema };
257
+ return {
258
+ kind: 'inline',
259
+ key: config.key,
260
+ contract,
261
+ compile: (options) => {
262
+ const transform = compileCustomDataTransform({ transform: config.transform, options });
263
+ const common = {
264
+ actionType: 'custom_data',
265
+ name: config.name,
266
+ description: config.description,
267
+ ...contract,
268
+ outputMappings: normalizeOutputMappings({
269
+ mappings: config.outputMappings,
270
+ outputSchema: contract.outputSchema,
271
+ }),
272
+ };
273
+ switch (config.operation.type) {
274
+ case 'agent_search':
275
+ return {
276
+ ...common,
277
+ operation: {
278
+ ...config.operation,
279
+ aiFacetingEnabled: config.operation.aiFacetingEnabled ?? false,
280
+ transform,
281
+ },
282
+ };
283
+ case 'query':
284
+ return { ...common, operation: { ...config.operation, transform } };
285
+ case 'search': {
286
+ const { body, ...operation } = config.operation;
287
+ return { ...common, operation: { ...operation, bodyTemplate: body, transform } };
288
+ }
289
+ }
290
+ },
291
+ };
292
+ }
293
+ function compileCustomDataQueryAction(config) {
294
+ const { sql, ...common } = config;
295
+ return compileCustomDataAction({ ...common, operation: { type: 'query', sql } });
296
+ }
297
+ function compileCustomDataSearchAction(config) {
298
+ const { table, body, ...common } = config;
299
+ return compileCustomDataAction({ ...common, operation: { type: 'search', table, body } });
300
+ }
301
+ function compileKnowledgeBaseSearchAction(config) {
302
+ const contract = compileContracts(config);
303
+ return {
304
+ kind: 'inline',
305
+ key: config.key,
306
+ contract,
307
+ compile: () => ({
308
+ actionType: 'knowledge_base',
309
+ name: config.name,
310
+ description: config.description,
311
+ ...contract,
312
+ outputMappings: normalizeOutputMappings({
313
+ mappings: config.outputMappings,
314
+ outputSchema: contract.outputSchema,
315
+ }),
316
+ operation: {
317
+ type: 'search',
318
+ knowledgeBaseIds: config.knowledgeBaseIds,
319
+ bodyTemplate: config.body,
320
+ },
321
+ }),
322
+ };
323
+ }
324
+ /** Compiles built-in schema parameters through the same path as other Actions. */
325
+ function compileBuiltInAction({ config, operation, }) {
326
+ // Validate against the Agent v2 operation schema without applying its transforms:
327
+ // historical versions must retain their stored strings when pulled and diffed.
328
+ built_in_actions_1.builtInOperationSchema.parse(operation);
329
+ const { key, name, description } = config;
330
+ if ('contract' in config) {
331
+ throw new Error(`Built-in Action "${key}" no longer accepts contract; use input, output, and outputMappings`);
332
+ }
333
+ // JavaScript callers and CLI compilation do not run TypeScript checks.
334
+ // A partial stored contract must never be mixed with Agent v2 defaults.
335
+ const hasSchemas = config.input !== undefined || config.output !== undefined || config.outputMappings !== undefined;
336
+ if (hasSchemas &&
337
+ (config.input === undefined || config.output === undefined || config.outputMappings === undefined)) {
338
+ throw new Error(`Built-in Action "${key}" requires input, output, and outputMappings together`);
339
+ }
340
+ const fixed = built_in_actions_1.BUILT_IN_ACTION_CONTRACTS[operation.type];
341
+ const schemas = config.input === undefined
342
+ ? { input: fixed.inputSchema, output: fixed.outputSchema, outputMappings: fixed.outputMappings }
343
+ : config;
344
+ const contract = compileContracts(schemas);
345
+ return {
346
+ kind: 'inline',
347
+ key,
348
+ contract,
349
+ compile: () => ({
350
+ actionType: 'built_in',
351
+ name,
352
+ description,
353
+ ...contract,
354
+ outputMappings: normalizeOutputMappings({
355
+ mappings: schemas.outputMappings,
356
+ outputSchema: contract.outputSchema,
357
+ }),
358
+ operation,
359
+ }),
360
+ };
361
+ }
362
+ exports.action = {
363
+ http(config) {
364
+ return compileHttpAction(config);
365
+ },
366
+ code(config) {
367
+ return compileCodeAction(config);
368
+ },
369
+ customData: compileCustomDataAction,
370
+ customDataAgentSearch(config) {
371
+ const { table, aiFacetingEnabled = false, ...common } = config;
372
+ return compileCustomDataAction({
373
+ ...common,
374
+ operation: { type: 'agent_search', table, aiFacetingEnabled },
375
+ });
376
+ },
377
+ customDataQuery(config) {
378
+ return compileCustomDataQueryAction(config);
379
+ },
380
+ customDataSearch(config) {
381
+ return compileCustomDataSearchAction(config);
382
+ },
383
+ knowledgeBaseSearch(config) {
384
+ return compileKnowledgeBaseSearchAction(config);
385
+ },
386
+ /** Sends an email through a verified sending domain of the organization. */
387
+ sendEmail(config) {
388
+ const { sendingDomainUuid, fromLocalPart, fromDisplayName = null } = config;
389
+ return compileBuiltInAction({
390
+ config,
391
+ operation: { type: 'send_email', sendingDomainUuid, fromLocalPart, fromDisplayName },
392
+ });
393
+ },
394
+ /** Sends a text message from one of the organization's phone numbers. */
395
+ sendTextMessage(config) {
396
+ const { senderPhoneNumberUuid } = config;
397
+ return compileBuiltInAction({
398
+ config,
399
+ operation: { type: 'send_text_message', senderPhoneNumberUuid },
400
+ });
401
+ },
402
+ /** Validates and standardizes a postal address. */
403
+ validateAddress(config) {
404
+ return compileBuiltInAction({
405
+ config,
406
+ operation: { type: 'validate_address' },
407
+ });
408
+ },
409
+ ref(config) {
410
+ return {
411
+ kind: 'reference',
412
+ key: config.key,
413
+ versionUuid: config.versionUuid,
414
+ contract: config.contract ?? null,
415
+ };
416
+ },
417
+ callable(config) {
418
+ const { backgroundMessage = null, ...rest } = config;
419
+ return { kind: 'callable', ...rest, backgroundMessage };
420
+ },
421
+ run(config) {
422
+ return { kind: 'run', ...config };
423
+ },
424
+ fromAgent(description) {
425
+ return { source: 'agent', description };
426
+ },
427
+ from(value, description) {
428
+ // The description is kept separately on the wire, so a prefilled input can
429
+ // still carry the text the agent is shown.
430
+ return { source: 'template', value, ...(description === undefined ? {} : { description }) };
431
+ },
432
+ };
433
+ function compileAction(definition, options = {}) {
434
+ return definition.compile(options);
435
+ }
436
+ function sourceFile(path) {
437
+ return { kind: 'source-file', path };
438
+ }