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

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