@andreprado/agentkit 0.1.0-alpha.2 → 0.1.0-alpha.20

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 (135) hide show
  1. package/README.md +67 -6
  2. package/docs/guides/add-channel.md +118 -7
  3. package/docs/guides/add-knowledge.md +144 -0
  4. package/docs/guides/add-managed-composio.md +163 -0
  5. package/docs/guides/add-tool.md +1 -1
  6. package/docs/guides/channel-security.md +97 -32
  7. package/docs/guides/connect-discord.md +178 -0
  8. package/docs/guides/connect-slack.md +126 -0
  9. package/docs/guides/connect-telegram.md +78 -1
  10. package/docs/guides/connect-whatsapp-zapster.md +112 -8
  11. package/docs/guides/create-agent.md +45 -4
  12. package/docs/guides/debug-channel.md +147 -0
  13. package/docs/guides/improve-from-production.md +151 -0
  14. package/docs/guides/prepare-deploy.md +47 -17
  15. package/docs/guides/replay-production-traces.md +72 -0
  16. package/docs/guides/run-evals.md +147 -20
  17. package/docs/guides/security-rules.md +7 -6
  18. package/docs/guides/send-feedback.md +135 -0
  19. package/docs/guides/use-provider.md +27 -3
  20. package/docs/llms-full.txt +303 -55
  21. package/docs/llms.txt +57 -7
  22. package/package.json +2 -5
  23. package/src/cli/args.ts +57 -0
  24. package/src/cli/cloud-client.ts +377 -0
  25. package/src/cli/commands/channels.ts +1315 -0
  26. package/src/cli/commands/feedback.ts +438 -0
  27. package/src/cli/commands/knowledge.ts +136 -0
  28. package/src/cli/commands/transcribe.ts +171 -0
  29. package/src/cli/constants.ts +4 -0
  30. package/src/cli/deploy-chat-ui.ts +535 -0
  31. package/src/cli/deploy-readiness.ts +481 -0
  32. package/src/cli/flags.ts +162 -0
  33. package/src/cli/help.ts +236 -0
  34. package/src/cli/index.ts +1167 -1005
  35. package/src/cli/process.ts +31 -0
  36. package/src/cloud/artifact.ts +139 -0
  37. package/src/cloud/client.ts +80 -0
  38. package/src/cloud/contracts.ts +63 -0
  39. package/src/cloud/index.ts +3 -0
  40. package/src/create-project.ts +21 -6
  41. package/src/index.ts +479 -7
  42. package/src/providers/pi.ts +70 -16
  43. package/src/providers/test.ts +88 -1
  44. package/src/providers/types.ts +7 -0
  45. package/src/runtime/channel-buffer.ts +30 -0
  46. package/src/runtime/channel-test-harness.ts +8 -1
  47. package/src/runtime/channels/discord.ts +896 -0
  48. package/src/runtime/channels/slack.ts +646 -0
  49. package/src/runtime/channels/telegram.ts +466 -23
  50. package/src/runtime/channels/whatsapp-meta.ts +9 -0
  51. package/src/runtime/channels/whatsapp-zapster.ts +677 -40
  52. package/src/runtime/channels.ts +86 -3
  53. package/src/runtime/chat.ts +130 -38
  54. package/src/runtime/config.ts +483 -18
  55. package/src/runtime/core/manifest.ts +103 -5
  56. package/src/runtime/core/targets.ts +5 -5
  57. package/src/runtime/database.ts +93 -2
  58. package/src/runtime/db-commands.ts +9 -0
  59. package/src/runtime/deploy-readiness.ts +46 -4
  60. package/src/runtime/deploy.ts +1 -1
  61. package/src/runtime/dev-server.ts +759 -41
  62. package/src/runtime/env.ts +8 -3
  63. package/src/runtime/evals.ts +589 -43
  64. package/src/runtime/improve.ts +868 -0
  65. package/src/runtime/inspect.ts +194 -4
  66. package/src/runtime/integrations/composio.ts +423 -0
  67. package/src/runtime/knowledge/chunk.ts +333 -0
  68. package/src/runtime/knowledge/config.ts +135 -0
  69. package/src/runtime/knowledge/embeddings.ts +133 -0
  70. package/src/runtime/knowledge/ingest.ts +521 -0
  71. package/src/runtime/knowledge/prompt-policy.ts +30 -0
  72. package/src/runtime/knowledge/retrieve.ts +303 -0
  73. package/src/runtime/knowledge/schema.ts +100 -0
  74. package/src/runtime/knowledge/tool.ts +64 -0
  75. package/src/runtime/knowledge/vector.ts +258 -0
  76. package/src/runtime/prompt-context.ts +141 -0
  77. package/src/runtime/runtime-contract.ts +86 -8
  78. package/src/runtime/skills.ts +95 -0
  79. package/src/runtime/spec.ts +152 -0
  80. package/src/runtime/sync.ts +144 -0
  81. package/src/runtime/targets/cloudflare/build.ts +1430 -185
  82. package/src/runtime/targets/container/server.ts +1 -1
  83. package/src/runtime/targets/vps/deploy.ts +26 -9
  84. package/src/runtime/tool-runner.ts +9 -1
  85. package/src/runtime/tools.ts +128 -2
  86. package/src/runtime/traces.ts +41 -0
  87. package/src/runtime/transcription.ts +483 -0
  88. package/src/storage/sqlite.ts +149 -3
  89. package/src/templates/blank.ts +76 -17
  90. package/src/templates/dentista.ts +1011 -0
  91. package/src/templates/index.ts +2 -0
  92. package/src/templates/skills/agentkit-build-agent/SKILL.md +52 -0
  93. package/src/templates/skills/agentkit-build-agent/templates/appointment-intake.instructions.md +21 -0
  94. package/src/templates/skills/agentkit-build-agent/templates/sales-qualifier.instructions.md +17 -0
  95. package/src/templates/skills/agentkit-build-agent/templates/support-agent.instructions.md +16 -0
  96. package/src/templates/skills/agentkit-capsule/SKILL.md +70 -0
  97. package/src/templates/skills/agentkit-capsule/references/docs-router.md +15 -0
  98. package/src/templates/skills/agentkit-channels/SKILL.md +104 -0
  99. package/src/templates/skills/agentkit-channels/references/channel-buffering.md +65 -0
  100. package/src/templates/skills/agentkit-channels/references/channel-debugging.md +66 -0
  101. package/src/templates/skills/agentkit-channels/references/discord.md +93 -0
  102. package/src/templates/skills/agentkit-channels/references/slack.md +56 -0
  103. package/src/templates/skills/agentkit-channels/references/telegram.md +72 -0
  104. package/src/templates/skills/agentkit-channels/references/whatsapp-zapster.md +77 -0
  105. package/src/templates/skills/agentkit-database/SKILL.md +45 -0
  106. package/src/templates/skills/agentkit-database/templates/appointments.schema.sql +15 -0
  107. package/src/templates/skills/agentkit-database/templates/leads.schema.sql +17 -0
  108. package/src/templates/skills/agentkit-deploy/SKILL.md +50 -0
  109. package/src/templates/skills/agentkit-evals/SKILL.md +109 -0
  110. package/src/templates/skills/agentkit-evals/templates/multi-turn.eval.md +29 -0
  111. package/src/templates/skills/agentkit-evals/templates/no-leak.eval.md +18 -0
  112. package/src/templates/skills/agentkit-evals/templates/smoke.eval.md +18 -0
  113. package/src/templates/skills/agentkit-evals/templates/tool-call.eval.md +27 -0
  114. package/src/templates/skills/agentkit-improve/SKILL.md +86 -0
  115. package/src/templates/skills/agentkit-improve/references/replay-side-effects.md +18 -0
  116. package/src/templates/skills/agentkit-improve/references/trace-packets.md +22 -0
  117. package/src/templates/skills/agentkit-improve/templates/regression.eval.md +18 -0
  118. package/src/templates/skills/agentkit-integrations/SKILL.md +76 -0
  119. package/src/templates/skills/agentkit-knowledge/SKILL.md +43 -0
  120. package/src/templates/skills/agentkit-knowledge/templates/faq.md +14 -0
  121. package/src/templates/skills/agentkit-knowledge/templates/policies.md +14 -0
  122. package/src/templates/skills/agentkit-knowledge/templates/prices.csv +3 -0
  123. package/src/templates/skills/agentkit-prompts/SKILL.md +47 -0
  124. package/src/templates/skills/agentkit-prompts/templates/knowledge-grounded-faq.instructions.md +11 -0
  125. package/src/templates/skills/agentkit-provider/SKILL.md +60 -0
  126. package/src/templates/skills/agentkit-security/SKILL.md +56 -0
  127. package/src/templates/skills/agentkit-tools/SKILL.md +37 -0
  128. package/src/templates/skills/agentkit-tools/examples/database-write.tool.md +35 -0
  129. package/src/templates/skills/agentkit-tools/examples/eval-safe-external-action.tool.md +37 -0
  130. package/src/templates/skills/agentkit-tools/examples/lookup-order.tool.md +46 -0
  131. package/src/templates/skills/agentkit-troubleshooting/SKILL.md +76 -0
  132. package/src/templates/support.ts +77 -18
  133. package/docs/guides/channels-production-handoff.md +0 -99
  134. package/docs/portable-deploy-release-checklist.md +0 -41
  135. package/src/runtime/targets/cloudflare/deploy.ts +0 -5475
package/src/index.ts CHANGED
@@ -2,10 +2,13 @@ export type AgentRuntime = "local" | "edge";
2
2
  export type AgentProviderName = "test" | "openai" | "anthropic" | "openrouter" | "custom";
3
3
  export type AccessMode = "private" | "token" | "public";
4
4
  export type ToolVisibility = "user" | "internal";
5
- export type ChannelType = "website" | "telegram" | "whatsapp";
6
- export type ChannelProvider = "agentkit" | "telegram" | "zapster" | "meta";
5
+ export type ChannelType = "website" | "telegram" | "whatsapp" | "discord" | "slack";
6
+ export type ChannelProvider = "agentkit" | "telegram" | "zapster" | "meta" | "discord" | "slack";
7
7
  export type WhatsappChannelProvider = "zapster" | "meta";
8
+ export type DiscordChannelMode = "interactions" | "bot";
8
9
  export type TelegramAllowedUpdate = "message";
10
+ export type ChannelAudioMode = "off" | "reject" | "transcribe";
11
+ export type TranscriptionProviderName = "test" | "openai" | "groq";
9
12
 
10
13
  export type AgentProvider = {
11
14
  name: AgentProviderName;
@@ -17,6 +20,67 @@ export type ChannelLimits = {
17
20
  usdPerDay?: number;
18
21
  };
19
22
 
23
+ export type ChannelBufferMode = "off" | "debounce";
24
+
25
+ export type ChannelBufferInput = {
26
+ mode?: ChannelBufferMode;
27
+ quietWindowMs?: number;
28
+ maxWaitMs?: number;
29
+ maxMessages?: number;
30
+ maxChars?: number;
31
+ };
32
+
33
+ export type ChannelBufferConfig =
34
+ | {
35
+ mode: "off";
36
+ }
37
+ | {
38
+ mode: "debounce";
39
+ quietWindowMs: number;
40
+ maxWaitMs: number;
41
+ maxMessages: number;
42
+ maxChars: number;
43
+ };
44
+
45
+ export type ChannelAudioInput = {
46
+ mode?: ChannelAudioMode;
47
+ fallbackMessage?: string;
48
+ maxDurationSeconds?: number;
49
+ maxBytes?: number;
50
+ };
51
+
52
+ export type ChannelAudioConfig =
53
+ | {
54
+ mode: "off";
55
+ }
56
+ | {
57
+ mode: "reject";
58
+ fallbackMessage: string;
59
+ maxDurationSeconds?: number;
60
+ maxBytes?: number;
61
+ }
62
+ | {
63
+ mode: "transcribe";
64
+ fallbackMessage: string;
65
+ maxDurationSeconds?: number;
66
+ maxBytes?: number;
67
+ };
68
+
69
+ export type AgentTranscriptionLimits = {
70
+ maxDurationSeconds?: number;
71
+ maxBytes?: number;
72
+ };
73
+
74
+ export type AgentTranscriptionConfig = {
75
+ provider: TranscriptionProviderName;
76
+ model: string;
77
+ secret?: string;
78
+ language?: string;
79
+ prompt?: string;
80
+ limits?: AgentTranscriptionLimits;
81
+ rawAudioTtlSeconds?: number;
82
+ };
83
+
20
84
  export type WebsiteChannelAccess = {
21
85
  mode: "token";
22
86
  };
@@ -26,6 +90,8 @@ export type WebsiteChannelInput = {
26
90
  access?: WebsiteChannelAccess;
27
91
  secrets?: string[];
28
92
  limits?: ChannelLimits;
93
+ buffer?: ChannelBufferInput;
94
+ audio?: ChannelAudioInput;
29
95
  };
30
96
 
31
97
  export type WebsiteChannelConfig = {
@@ -35,6 +101,8 @@ export type WebsiteChannelConfig = {
35
101
  access: WebsiteChannelAccess;
36
102
  secrets: string[];
37
103
  limits?: ChannelLimits;
104
+ buffer?: ChannelBufferConfig;
105
+ audio?: ChannelAudioConfig;
38
106
  };
39
107
 
40
108
  export type TelegramChannelInput = {
@@ -42,6 +110,8 @@ export type TelegramChannelInput = {
42
110
  secrets?: string[];
43
111
  allowedUpdates?: TelegramAllowedUpdate[];
44
112
  limits?: ChannelLimits;
113
+ buffer?: ChannelBufferInput;
114
+ audio?: ChannelAudioInput;
45
115
  };
46
116
 
47
117
  export type TelegramChannelConfig = {
@@ -51,6 +121,8 @@ export type TelegramChannelConfig = {
51
121
  secrets: string[];
52
122
  allowedUpdates: TelegramAllowedUpdate[];
53
123
  limits?: ChannelLimits;
124
+ buffer?: ChannelBufferConfig;
125
+ audio?: ChannelAudioConfig;
54
126
  };
55
127
 
56
128
  export type WhatsappChannelInput = {
@@ -58,6 +130,8 @@ export type WhatsappChannelInput = {
58
130
  provider: WhatsappChannelProvider;
59
131
  secrets?: string[];
60
132
  limits?: ChannelLimits;
133
+ buffer?: ChannelBufferInput;
134
+ audio?: ChannelAudioInput;
61
135
  };
62
136
 
63
137
  export type WhatsappChannelConfig = {
@@ -66,9 +140,78 @@ export type WhatsappChannelConfig = {
66
140
  name: string;
67
141
  secrets: string[];
68
142
  limits?: ChannelLimits;
143
+ buffer?: ChannelBufferConfig;
144
+ audio?: ChannelAudioConfig;
69
145
  };
70
146
 
71
- export type AgentChannel = WebsiteChannelConfig | TelegramChannelConfig | WhatsappChannelConfig;
147
+ export type DiscordChannelInput = {
148
+ name: string;
149
+ mode?: DiscordChannelMode;
150
+ secrets?: string[];
151
+ limits?: ChannelLimits;
152
+ buffer?: ChannelBufferInput;
153
+ };
154
+
155
+ export type DiscordChannelConfig = {
156
+ type: "discord";
157
+ provider: "discord";
158
+ name: string;
159
+ mode: DiscordChannelMode;
160
+ secrets: string[];
161
+ limits?: ChannelLimits;
162
+ buffer?: ChannelBufferConfig;
163
+ audio?: never;
164
+ };
165
+
166
+ export type SlackChannelInput = {
167
+ name: string;
168
+ secrets?: string[];
169
+ limits?: ChannelLimits;
170
+ buffer?: ChannelBufferInput;
171
+ };
172
+
173
+ export type SlackChannelConfig = {
174
+ type: "slack";
175
+ provider: "slack";
176
+ name: string;
177
+ secrets: string[];
178
+ limits?: ChannelLimits;
179
+ buffer?: ChannelBufferConfig;
180
+ audio?: never;
181
+ };
182
+
183
+ export type AgentChannel =
184
+ | WebsiteChannelConfig
185
+ | TelegramChannelConfig
186
+ | WhatsappChannelConfig
187
+ | DiscordChannelConfig
188
+ | SlackChannelConfig;
189
+
190
+ export type IntegrationTagsConfig = {
191
+ enable?: string[];
192
+ disable?: string[];
193
+ };
194
+
195
+ export type ComposioManagedIntegrationInput = {
196
+ name?: string;
197
+ toolkits: string[];
198
+ tools?: Record<string, string[]>;
199
+ tags?: IntegrationTagsConfig;
200
+ confirmExternalWrites?: boolean;
201
+ };
202
+
203
+ export type ComposioManagedIntegration = {
204
+ type: "composio";
205
+ provider: "composio";
206
+ mode: "managed";
207
+ name: string;
208
+ toolkits: string[];
209
+ tools?: Record<string, string[]>;
210
+ tags?: IntegrationTagsConfig;
211
+ confirmExternalWrites?: boolean;
212
+ };
213
+
214
+ export type AgentIntegration = ComposioManagedIntegration;
72
215
 
73
216
  export type AgentDatabaseConfig =
74
217
  | {
@@ -77,6 +220,7 @@ export type AgentDatabaseConfig =
77
220
  | {
78
221
  driver: "turso";
79
222
  schema?: string;
223
+ migrations?: string;
80
224
  };
81
225
 
82
226
  export type AgentFilesConfig =
@@ -90,6 +234,37 @@ export type AgentFilesConfig =
90
234
  maxUploadBytes?: number;
91
235
  };
92
236
 
237
+ export type AgentKnowledgeSource =
238
+ | string
239
+ | {
240
+ path: string;
241
+ title?: string;
242
+ }
243
+ | {
244
+ url: string;
245
+ title?: string;
246
+ };
247
+
248
+ export type AgentKnowledgeEmbeddingProvider = "none" | "test" | "openai";
249
+
250
+ export type AgentKnowledgeEmbeddingConfig = {
251
+ provider?: AgentKnowledgeEmbeddingProvider;
252
+ model?: string;
253
+ dimensions?: number;
254
+ secret?: string;
255
+ };
256
+
257
+ export type AgentKnowledgeRetrievalConfig = {
258
+ topK?: number;
259
+ hybrid?: boolean;
260
+ };
261
+
262
+ export type AgentKnowledgeConfig = {
263
+ sources?: AgentKnowledgeSource[];
264
+ embedding?: AgentKnowledgeEmbeddingConfig;
265
+ retrieval?: AgentKnowledgeRetrievalConfig;
266
+ };
267
+
93
268
  export type JsonSchema = {
94
269
  type: string | string[];
95
270
  properties?: Record<string, JsonSchema>;
@@ -119,17 +294,61 @@ export type DatabaseRunner = {
119
294
  batch(statements: DatabaseStatement[]): Promise<DatabaseResult[]>;
120
295
  };
121
296
 
297
+ export type ToolRenderField = {
298
+ label: string;
299
+ value: string;
300
+ };
301
+
302
+ export type ToolRenderAction = {
303
+ label: string;
304
+ href?: string;
305
+ };
306
+
307
+ export type ToolRenderBlock =
308
+ | {
309
+ type: "text";
310
+ text: string;
311
+ }
312
+ | {
313
+ type: "card";
314
+ title: string;
315
+ subtitle?: string;
316
+ fields?: ToolRenderField[];
317
+ actions?: ToolRenderAction[];
318
+ };
319
+
320
+ export type ToolRenderResult = {
321
+ text: string;
322
+ blocks?: ToolRenderBlock[];
323
+ };
324
+
325
+ export type ToolRenderContext<Input = unknown> = {
326
+ input: Input;
327
+ runtime: ToolRuntimeContext;
328
+ clock: ToolClockContext;
329
+ };
330
+
122
331
  export type ToolRuntimeContext = {
123
332
  environment: "local" | "hosted" | "eval" | "test";
124
- invocation: "chat" | "tool" | "dev" | "channel" | "eval";
333
+ invocation: "chat" | "tool" | "dev" | "channel" | "eval" | "sync";
125
334
  target: "bun" | "cloudflare";
126
335
  database: "sqlite" | "turso" | "none";
127
336
  };
128
337
 
338
+ export type ToolClockContext = {
339
+ now: Date;
340
+ isoTimestamp: string;
341
+ timeZone: string;
342
+ localDate: string;
343
+ localWeekday: string;
344
+ localDateTime: string;
345
+ };
346
+
129
347
  export type ToolContext = {
130
348
  secrets: Record<string, string>;
131
349
  signal: AbortSignal;
132
350
  runtime: ToolRuntimeContext;
351
+ clock: ToolClockContext;
133
352
  database: DatabaseRunner;
134
353
  db: DatabaseRunner;
135
354
  storage: {
@@ -137,6 +356,13 @@ export type ToolContext = {
137
356
  };
138
357
  };
139
358
 
359
+ export type SyncContext = {
360
+ env: Record<string, string | undefined>;
361
+ database: DatabaseRunner;
362
+ db: DatabaseRunner;
363
+ runtime: ToolRuntimeContext;
364
+ };
365
+
140
366
  export type AgentTool<Input = unknown, Output = unknown> = {
141
367
  name: string;
142
368
  description: string;
@@ -147,16 +373,21 @@ export type AgentTool<Input = unknown, Output = unknown> = {
147
373
  permissions?: string[];
148
374
  timeoutMs?: number;
149
375
  execute(input: Input, ctx: ToolContext): Promise<Output> | Output;
376
+ render?(output: Output, ctx: ToolRenderContext<Input>): string | ToolRenderResult;
150
377
  };
151
378
 
152
379
  export type AgentConfig = {
153
380
  name: string;
154
381
  runtime: AgentRuntime;
155
382
  provider: AgentProvider;
383
+ timeZone?: string;
156
384
  instructions: string;
157
385
  secrets: string[];
158
386
  tools?: AgentTool[];
387
+ integrations?: AgentIntegration[];
159
388
  channels?: AgentChannel[];
389
+ transcription?: AgentTranscriptionConfig;
390
+ knowledge?: AgentKnowledgeConfig;
160
391
  access: {
161
392
  mode: AccessMode;
162
393
  };
@@ -176,6 +407,25 @@ export function defineTool<Input = unknown, Output = unknown>(tool: AgentTool<In
176
407
  return tool;
177
408
  }
178
409
 
410
+ export function composioManaged(input: ComposioManagedIntegrationInput): ComposioManagedIntegration {
411
+ const name = normalizeIntegrationName(input.name ?? "composio", "composio integration name");
412
+ const toolkits = normalizeToolkitList(input.toolkits, "composioManaged.toolkits");
413
+ const tools = input.tools ? normalizeComposioToolMap(input.tools, toolkits) : undefined;
414
+ const tags = input.tags ? normalizeIntegrationTags(input.tags) : undefined;
415
+ const confirmExternalWrites = input.confirmExternalWrites;
416
+
417
+ return {
418
+ type: "composio",
419
+ provider: "composio",
420
+ mode: "managed",
421
+ name,
422
+ toolkits,
423
+ ...(tools ? { tools } : {}),
424
+ ...(tags ? { tags } : {}),
425
+ ...(confirmExternalWrites === undefined ? {} : { confirmExternalWrites }),
426
+ };
427
+ }
428
+
179
429
  export function websiteChannel(input: WebsiteChannelInput): WebsiteChannelConfig {
180
430
  return {
181
431
  type: "website",
@@ -184,6 +434,8 @@ export function websiteChannel(input: WebsiteChannelInput): WebsiteChannelConfig
184
434
  access: input.access ?? { mode: "token" },
185
435
  secrets: normalizeChannelSecrets(input.secrets ?? ["AGENTKIT_WEBSITE_CHANNEL_TOKEN"], "website channel"),
186
436
  ...(input.limits ? { limits: input.limits } : {}),
437
+ ...(input.buffer ? { buffer: normalizeChannelBuffer(input.buffer, "website channel") } : {}),
438
+ ...(input.audio ? { audio: normalizeChannelAudio(input.audio, "website channel") } : {}),
187
439
  };
188
440
  }
189
441
 
@@ -198,6 +450,8 @@ export function telegramChannel(input: TelegramChannelInput): TelegramChannelCon
198
450
  ),
199
451
  allowedUpdates: input.allowedUpdates ?? ["message"],
200
452
  ...(input.limits ? { limits: input.limits } : {}),
453
+ ...(input.buffer ? { buffer: normalizeChannelBuffer(input.buffer, "telegram channel") } : {}),
454
+ ...(input.audio ? { audio: normalizeChannelAudio(input.audio, "telegram channel") } : {}),
201
455
  };
202
456
  }
203
457
 
@@ -211,12 +465,43 @@ export function whatsappChannel(input: WhatsappChannelInput): WhatsappChannelCon
211
465
  `${input.provider} whatsapp channel`,
212
466
  ),
213
467
  ...(input.limits ? { limits: input.limits } : {}),
468
+ ...(input.buffer ? { buffer: normalizeChannelBuffer(input.buffer, `${input.provider} whatsapp channel`) } : {}),
469
+ ...(input.audio ? { audio: normalizeChannelAudio(input.audio, `${input.provider} whatsapp channel`) } : {}),
470
+ };
471
+ }
472
+
473
+ export function discordChannel(input: DiscordChannelInput): DiscordChannelConfig {
474
+ const mode = input.mode ?? "interactions";
475
+
476
+ return {
477
+ type: "discord",
478
+ provider: "discord",
479
+ name: input.name,
480
+ mode,
481
+ secrets: normalizeChannelSecrets(input.secrets ?? defaultDiscordChannelSecrets(mode), "discord channel"),
482
+ ...(input.limits ? { limits: input.limits } : {}),
483
+ ...(input.buffer ? { buffer: normalizeChannelBuffer(input.buffer, "discord channel") } : {}),
484
+ };
485
+ }
486
+
487
+ export function slackChannel(input: SlackChannelInput): SlackChannelConfig {
488
+ return {
489
+ type: "slack",
490
+ provider: "slack",
491
+ name: input.name,
492
+ secrets: normalizeChannelSecrets(input.secrets ?? ["SLACK_BOT_TOKEN", "SLACK_SIGNING_SECRET"], "slack channel"),
493
+ ...(input.limits ? { limits: input.limits } : {}),
494
+ ...(input.buffer ? { buffer: normalizeChannelBuffer(input.buffer, "slack channel") } : {}),
214
495
  };
215
496
  }
216
497
 
498
+ function defaultDiscordChannelSecrets(mode: DiscordChannelMode): string[] {
499
+ return mode === "bot" ? ["DISCORD_BOT_TOKEN"] : ["DISCORD_PUBLIC_KEY"];
500
+ }
501
+
217
502
  function defaultWhatsappChannelSecrets(provider: WhatsappChannelProvider): string[] {
218
503
  if (provider === "zapster") {
219
- return ["ZAPSTER_API_KEY", "ZAPSTER_WEBHOOK_SECRET"];
504
+ return ["ZAPSTER_API_KEY", "ZAPSTER_INSTANCE_ID", "ZAPSTER_WEBHOOK_ID"];
220
505
  }
221
506
 
222
507
  return ["META_WHATSAPP_ACCESS_TOKEN", "META_WHATSAPP_APP_SECRET", "META_WHATSAPP_VERIFY_TOKEN"];
@@ -236,32 +521,219 @@ function normalizeChannelSecrets(secrets: string[], context: string): string[] {
236
521
  return Array.from(uniqueSecrets).sort();
237
522
  }
238
523
 
524
+ function normalizeIntegrationName(value: string, context: string): string {
525
+ const name = value.trim();
526
+
527
+ if (!/^[a-z][a-z0-9-]*$/.test(name)) {
528
+ throw new Error(`${context} must start with a lowercase letter and contain only lowercase letters, numbers, and hyphens.`);
529
+ }
530
+
531
+ return name;
532
+ }
533
+
534
+ function normalizeToolkitList(values: string[], context: string): string[] {
535
+ if (!Array.isArray(values) || values.length === 0) {
536
+ throw new Error(`${context} must include at least one toolkit slug.`);
537
+ }
538
+
539
+ const toolkits = new Set<string>();
540
+
541
+ for (const value of values) {
542
+ if (typeof value !== "string") {
543
+ throw new Error(`${context} entries must be toolkit slug strings.`);
544
+ }
545
+
546
+ const toolkit = value.trim().toLowerCase();
547
+
548
+ if (!/^[a-z][a-z0-9_-]*$/.test(toolkit)) {
549
+ throw new Error(`${context} entries must start with a letter and contain only letters, numbers, underscores, and hyphens.`);
550
+ }
551
+
552
+ toolkits.add(toolkit);
553
+ }
554
+
555
+ return Array.from(toolkits).sort();
556
+ }
557
+
558
+ function normalizeComposioToolMap(values: Record<string, string[]>, toolkits: string[]): Record<string, string[]> | undefined {
559
+ const toolkitSet = new Set(toolkits);
560
+ const normalized: Record<string, string[]> = {};
561
+
562
+ for (const [rawToolkit, rawTools] of Object.entries(values)) {
563
+ const toolkit = rawToolkit.trim().toLowerCase();
564
+
565
+ if (!toolkitSet.has(toolkit)) {
566
+ throw new Error(`composioManaged.tools.${rawToolkit} must reference a toolkit listed in composioManaged.toolkits.`);
567
+ }
568
+
569
+ if (!Array.isArray(rawTools) || rawTools.length === 0) {
570
+ throw new Error(`composioManaged.tools.${rawToolkit} must include at least one Composio action slug.`);
571
+ }
572
+
573
+ const tools = new Set<string>();
574
+
575
+ for (const rawTool of rawTools) {
576
+ if (typeof rawTool !== "string") {
577
+ throw new Error(`composioManaged.tools.${rawToolkit} entries must be Composio action slug strings.`);
578
+ }
579
+
580
+ const tool = rawTool.trim().toUpperCase();
581
+
582
+ if (!/^[A-Z][A-Z0-9_]*$/.test(tool)) {
583
+ throw new Error(`composioManaged.tools.${rawToolkit} entries must be uppercase Composio action slugs.`);
584
+ }
585
+
586
+ tools.add(tool);
587
+ }
588
+
589
+ normalized[toolkit] = Array.from(tools).sort();
590
+ }
591
+
592
+ return Object.keys(normalized).length > 0 ? normalized : undefined;
593
+ }
594
+
595
+ function normalizeIntegrationTags(tags: IntegrationTagsConfig): IntegrationTagsConfig {
596
+ const normalized: IntegrationTagsConfig = {};
597
+
598
+ if (tags.enable !== undefined) {
599
+ normalized.enable = normalizeTagList(tags.enable, "composioManaged.tags.enable");
600
+ }
601
+
602
+ if (tags.disable !== undefined) {
603
+ normalized.disable = normalizeTagList(tags.disable, "composioManaged.tags.disable");
604
+ }
605
+
606
+ return normalized;
607
+ }
608
+
609
+ function normalizeTagList(values: string[], context: string): string[] {
610
+ if (!Array.isArray(values)) {
611
+ throw new Error(`${context} must be an array of tag strings.`);
612
+ }
613
+
614
+ return Array.from(
615
+ new Set(
616
+ values.map((value) => {
617
+ if (typeof value !== "string" || value.trim().length === 0) {
618
+ throw new Error(`${context} entries must be non-empty strings.`);
619
+ }
620
+
621
+ return value.trim();
622
+ }),
623
+ ),
624
+ ).sort();
625
+ }
626
+
627
+ function normalizeChannelBuffer(input: ChannelBufferInput, context: string): ChannelBufferConfig {
628
+ if (input.mode === "off") {
629
+ return { mode: "off" };
630
+ }
631
+
632
+ if (input.mode !== undefined && input.mode !== "debounce") {
633
+ throw new Error(`${context} buffer.mode must be "off" or "debounce".`);
634
+ }
635
+
636
+ const buffer: ChannelBufferConfig = {
637
+ mode: "debounce",
638
+ quietWindowMs: input.quietWindowMs ?? 2500,
639
+ maxWaitMs: input.maxWaitMs ?? 12000,
640
+ maxMessages: input.maxMessages ?? 20,
641
+ maxChars: input.maxChars ?? 8000,
642
+ };
643
+
644
+ validatePositiveInteger(buffer.quietWindowMs, `${context} buffer.quietWindowMs`);
645
+ validatePositiveInteger(buffer.maxWaitMs, `${context} buffer.maxWaitMs`);
646
+ validatePositiveInteger(buffer.maxMessages, `${context} buffer.maxMessages`);
647
+ validatePositiveInteger(buffer.maxChars, `${context} buffer.maxChars`);
648
+
649
+ if (buffer.maxWaitMs < buffer.quietWindowMs) {
650
+ throw new Error(`${context} buffer.maxWaitMs must be greater than or equal to buffer.quietWindowMs.`);
651
+ }
652
+
653
+ return buffer;
654
+ }
655
+
656
+ function normalizeChannelAudio(input: ChannelAudioInput, context: string): ChannelAudioConfig {
657
+ const mode = input.mode ?? "transcribe";
658
+
659
+ if (mode !== "off" && mode !== "reject" && mode !== "transcribe") {
660
+ throw new Error(`${context} audio.mode must be "off", "reject", or "transcribe".`);
661
+ }
662
+
663
+ if (mode === "off") {
664
+ return { mode: "off" };
665
+ }
666
+
667
+ if (input.maxDurationSeconds !== undefined) {
668
+ validatePositiveInteger(input.maxDurationSeconds, `${context} audio.maxDurationSeconds`);
669
+ }
670
+
671
+ if (input.maxBytes !== undefined) {
672
+ validatePositiveInteger(input.maxBytes, `${context} audio.maxBytes`);
673
+ }
674
+
675
+ return {
676
+ mode,
677
+ fallbackMessage: input.fallbackMessage ?? "I received an audio message, but I could not transcribe it. Please send the message as text.",
678
+ ...(input.maxDurationSeconds !== undefined ? { maxDurationSeconds: input.maxDurationSeconds } : {}),
679
+ ...(input.maxBytes !== undefined ? { maxBytes: input.maxBytes } : {}),
680
+ };
681
+ }
682
+
683
+ function validatePositiveInteger(value: number, field: string): void {
684
+ if (!Number.isInteger(value) || value <= 0) {
685
+ throw new Error(`${field} must be a positive integer.`);
686
+ }
687
+ }
688
+
239
689
  export { loadAgentCapsule, findAgentCapsuleRoot } from "./runtime/config";
240
690
  export { runAgentMessage, runAgentMessageFromCwd } from "./runtime/chat";
241
691
  export { listConversationsFromCwd, getConversationFromCwd } from "./runtime/conversations";
242
- export { runEvalsFromCwd } from "./runtime/evals";
692
+ export { defineEval, runEvalsFromCwd } from "./runtime/evals";
693
+ export type {
694
+ EvalCase,
695
+ EvalExpect,
696
+ EvalResponseExpectation,
697
+ EvalRunSummary,
698
+ EvalResult,
699
+ EvalToolsContainerExpectation,
700
+ EvalToolsExpectation,
701
+ EvalTurn,
702
+ ToolExpectation,
703
+ } from "./runtime/evals";
704
+ export { getConversationTraceFromCwd } from "./runtime/traces";
243
705
  export { runToolFromCwd } from "./runtime/tool-runner";
244
706
  export { startAgentDevServer } from "./runtime/dev-server";
245
707
  export { inspectAgentCapsule } from "./runtime/inspect";
246
708
  export { buildAgentCapsule } from "./runtime/build";
247
- export { deployBuildToAgentKitCloud, startAgentKitCloudServer } from "./runtime/deploy";
709
+ export { deployBuildToAgentKitCloud } from "./runtime/deploy";
248
710
  export { AgentKitError } from "./runtime/errors";
249
711
  export type {
250
712
  ChannelAdapter,
251
713
  ChannelAdapterId,
714
+ ChannelAudioAttachment,
252
715
  ChannelDeliveryDirection,
253
716
  ChannelDeliveryState,
254
717
  ChannelEventKind,
255
718
  ChannelExternalIdentity,
719
+ ChannelMediaDownloadInput,
720
+ ChannelMediaDownloadResult,
256
721
  ChannelMessageContentType,
257
722
  ChannelMessageRole,
723
+ ChannelReplyTarget,
258
724
  ChannelSendInput,
259
725
  ChannelSendResult,
260
726
  ChannelStatusInput,
261
727
  ChannelStatusResult,
728
+ ChannelWebhookResponse,
262
729
  NormalizedChannelEvent,
263
730
  NormalizedChannelMessage,
264
731
  RawWebhookEvent,
265
732
  WebhookVerificationInput,
266
733
  WebhookVerificationResult,
267
734
  } from "./runtime/channels";
735
+ export type {
736
+ TranscriptionAdapter,
737
+ TranscriptionInput,
738
+ TranscriptionResult,
739
+ } from "./runtime/transcription";