@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
@@ -4,6 +4,16 @@ import type { AgentChannel, AgentProvider, AgentRuntime, AccessMode } from "../i
4
4
  import type { LoadedAgentCapsule } from "./config";
5
5
  import { loadAgentCapsule } from "./config";
6
6
  import { loadCapsuleEnv } from "./env";
7
+ import {
8
+ createManagedComposioTools,
9
+ managedComposioRequiredSecrets,
10
+ resolveManagedComposioIntegrations,
11
+ } from "./integrations/composio";
12
+ import { resolveKnowledgeConfig } from "./knowledge/config";
13
+ import { KNOWLEDGE_SEARCH_TOOL_NAME } from "./knowledge/tool";
14
+ import { resolveRuntimeTimeZone } from "./prompt-context";
15
+ import { checkDefaultSkillStatus, type DefaultSkillStatus } from "./skills";
16
+ import { resolveTranscriptionConfig } from "./transcription";
7
17
 
8
18
  export type SecretState = "set" | "missing";
9
19
 
@@ -11,9 +21,41 @@ export type AgentInspectState = {
11
21
  agent: string;
12
22
  runtime: AgentRuntime;
13
23
  provider: AgentProvider;
24
+ timeZone: {
25
+ configured: string | null;
26
+ effective: string;
27
+ };
14
28
  prompt: string;
15
29
  tools: string[];
30
+ integrations: AgentInspectIntegration[];
16
31
  channels: AgentInspectChannel[];
32
+ transcription: {
33
+ enabled: boolean;
34
+ provider: string | null;
35
+ model: string | null;
36
+ secret: string | null;
37
+ language: string | null;
38
+ prompt: string | null;
39
+ limits: {
40
+ maxDurationSeconds: number | null;
41
+ maxBytes: number | null;
42
+ };
43
+ rawAudioTtlSeconds: number | null;
44
+ };
45
+ knowledge: {
46
+ enabled: boolean;
47
+ sources: string[];
48
+ embedding: {
49
+ provider: string;
50
+ model: string | null;
51
+ dimensions: number | null;
52
+ };
53
+ retrieval: {
54
+ topK: number;
55
+ hybrid: boolean;
56
+ };
57
+ internalTool: string | null;
58
+ };
17
59
  access: {
18
60
  mode: AccessMode;
19
61
  };
@@ -36,6 +78,8 @@ export type AgentInspectState = {
36
78
  secrets: Record<string, SecretState>;
37
79
  managedSecrets: string[];
38
80
  userSecrets: string[];
81
+ skills: AgentInspectSkills;
82
+ warnings: AgentInspectWarning[];
39
83
  };
40
84
 
41
85
  export type AgentInspectDatabase = {
@@ -43,11 +87,13 @@ export type AgentInspectDatabase = {
43
87
  driver: "sqlite";
44
88
  path: string | null;
45
89
  schema: string | null;
90
+ migrations: string | null;
46
91
  };
47
92
  hosted: {
48
93
  driver: "none" | "turso";
49
94
  provisioning: "none" | "agentkit-managed";
50
95
  schema: string | null;
96
+ migrations: string | null;
51
97
  };
52
98
  };
53
99
 
@@ -56,6 +102,31 @@ export type AgentInspectChannel = {
56
102
  type: AgentChannel["type"];
57
103
  provider: AgentChannel["provider"];
58
104
  secrets: string[];
105
+ buffer?: AgentChannel["buffer"];
106
+ audio?: AgentChannel["audio"];
107
+ };
108
+
109
+ export type AgentInspectSkills = {
110
+ status: "current" | "missing" | "outdated" | "not_checked";
111
+ checked: number;
112
+ missing: string[];
113
+ outdated: string[];
114
+ syncCommand: string | null;
115
+ };
116
+
117
+ export type AgentInspectWarning = {
118
+ code: string;
119
+ message: string;
120
+ command?: string;
121
+ };
122
+
123
+ export type AgentInspectIntegration = {
124
+ name: string;
125
+ provider: "composio";
126
+ mode: "managed";
127
+ toolkits: string[];
128
+ tools: string[];
129
+ userId: string;
59
130
  };
60
131
 
61
132
  export async function inspectAgentCapsule(
@@ -63,16 +134,20 @@ export async function inspectAgentCapsule(
63
134
  env: Record<string, string | undefined> = process.env,
64
135
  ): Promise<AgentInspectState> {
65
136
  const capsule = await loadAgentCapsule(cwd);
66
- return buildInspectState(capsule, await loadCapsuleEnv(capsule.root, env));
137
+ return buildInspectState(capsule, await loadCapsuleEnv(capsule.root, env), await checkDefaultSkillStatus(capsule.root));
67
138
  }
68
139
 
69
140
  export function buildInspectState(
70
141
  capsule: LoadedAgentCapsule,
71
142
  env: Record<string, string | undefined> = process.env,
143
+ skillStatus: DefaultSkillStatus | null = null,
72
144
  ): AgentInspectState {
73
145
  const declaredSecrets = new Set(capsule.config.secrets);
146
+ const knowledge = resolveKnowledgeConfig(capsule.config);
147
+ const integrationTools = createManagedComposioTools(capsule.config);
148
+ const transcription = resolveTranscriptionConfig(capsule.config.transcription);
74
149
 
75
- for (const tool of capsule.config.tools ?? []) {
150
+ for (const tool of [...integrationTools, ...(capsule.config.tools ?? [])]) {
76
151
  for (const secret of tool.secrets ?? []) {
77
152
  declaredSecrets.add(secret);
78
153
  }
@@ -84,8 +159,19 @@ export function buildInspectState(
84
159
  }
85
160
  }
86
161
 
162
+ if (knowledge.embedding.secret) {
163
+ declaredSecrets.add(knowledge.embedding.secret);
164
+ }
165
+
166
+ if (transcription.secret) {
167
+ declaredSecrets.add(transcription.secret);
168
+ }
169
+
87
170
  const managedSecrets = managedCloudSecrets(capsule);
88
- const userSecrets = Array.from(declaredSecrets).sort();
171
+ const managedSecretSet = new Set(managedSecrets);
172
+ const userSecrets = Array.from(declaredSecrets)
173
+ .filter((secret) => !managedSecretSet.has(secret))
174
+ .sort();
89
175
  const secrets: Record<string, SecretState> = {};
90
176
 
91
177
  for (const secret of userSecrets) {
@@ -94,18 +180,63 @@ export function buildInspectState(
94
180
 
95
181
  const database = inspectDatabase(capsule);
96
182
 
183
+ const skills = inspectSkills(skillStatus);
184
+ const warnings = inspectWarnings(capsule, transcription, skills);
185
+
97
186
  return {
98
187
  agent: capsule.config.name,
99
188
  runtime: capsule.config.runtime,
100
189
  provider: capsule.config.provider,
190
+ timeZone: {
191
+ configured: capsule.config.timeZone ?? null,
192
+ effective: resolveRuntimeTimeZone({
193
+ timeZone: capsule.config.timeZone,
194
+ env,
195
+ }),
196
+ },
101
197
  prompt: toCapsulePath(capsule.root, capsule.instructionsPath),
102
- tools: (capsule.config.tools ?? []).map((tool) => tool.name),
198
+ tools: [...integrationTools, ...(capsule.config.tools ?? [])].map((tool) => tool.name),
199
+ integrations: resolveManagedComposioIntegrations(capsule.config).map((integration) => ({
200
+ name: integration.name,
201
+ provider: integration.provider,
202
+ mode: integration.mode,
203
+ toolkits: integration.toolkits,
204
+ tools: integration.allowedTools,
205
+ userId: integration.userId,
206
+ confirmExternalWrites: integration.confirmExternalWrites !== false,
207
+ })),
103
208
  channels: (capsule.config.channels ?? []).map((channel) => ({
104
209
  name: channel.name,
105
210
  type: channel.type,
106
211
  provider: channel.provider,
107
212
  secrets: [...channel.secrets],
213
+ ...(channel.buffer ? { buffer: channel.buffer } : {}),
214
+ ...(channel.audio ? { audio: channel.audio } : {}),
108
215
  })),
216
+ transcription: {
217
+ enabled: transcription.enabled,
218
+ provider: transcription.enabled ? transcription.provider : null,
219
+ model: transcription.enabled ? transcription.model : null,
220
+ secret: transcription.secret,
221
+ language: transcription.language,
222
+ prompt: transcription.prompt,
223
+ limits: {
224
+ maxDurationSeconds: transcription.limits.maxDurationSeconds ?? null,
225
+ maxBytes: transcription.limits.maxBytes ?? null,
226
+ },
227
+ rawAudioTtlSeconds: transcription.rawAudioTtlSeconds,
228
+ },
229
+ knowledge: {
230
+ enabled: knowledge.enabled,
231
+ sources: knowledge.sources.map((source) => source.value),
232
+ embedding: {
233
+ provider: knowledge.embedding.provider,
234
+ model: knowledge.embedding.model,
235
+ dimensions: knowledge.embedding.dimensions,
236
+ },
237
+ retrieval: knowledge.retrieval,
238
+ internalTool: knowledge.enabled ? KNOWLEDGE_SEARCH_TOOL_NAME : null,
239
+ },
109
240
  access: capsule.config.access,
110
241
  storage: capsule.storagePath ? toCapsulePath(capsule.root, capsule.storagePath) : null,
111
242
  database,
@@ -126,6 +257,8 @@ export function buildInspectState(
126
257
  secrets,
127
258
  managedSecrets,
128
259
  userSecrets,
260
+ skills,
261
+ warnings,
129
262
  };
130
263
  }
131
264
 
@@ -137,21 +270,74 @@ function toCapsulePath(root: string, path: string): string {
137
270
  function inspectDatabase(capsule: LoadedAgentCapsule): AgentInspectDatabase {
138
271
  const database = capsule.config.storage.database;
139
272
  const schema = database?.driver === "turso" && database.schema ? database.schema : null;
273
+ const migrations = database?.driver === "turso" ? database.migrations ?? "migrations" : null;
140
274
 
141
275
  return {
142
276
  local: {
143
277
  driver: "sqlite",
144
278
  path: capsule.storagePath ? toCapsulePath(capsule.root, capsule.storagePath) : null,
145
279
  schema,
280
+ migrations,
146
281
  },
147
282
  hosted: {
148
283
  driver: database?.driver === "turso" ? "turso" : "none",
149
284
  provisioning: database?.driver === "turso" ? "agentkit-managed" : "none",
150
285
  schema,
286
+ migrations,
151
287
  },
152
288
  };
153
289
  }
154
290
 
291
+ function inspectSkills(status: DefaultSkillStatus | null): AgentInspectSkills {
292
+ if (!status) {
293
+ return {
294
+ status: "not_checked",
295
+ checked: 0,
296
+ missing: [],
297
+ outdated: [],
298
+ syncCommand: null,
299
+ };
300
+ }
301
+
302
+ return {
303
+ status: status.status,
304
+ checked: status.checked,
305
+ missing: status.missing,
306
+ outdated: status.outdated,
307
+ syncCommand: status.status === "current" ? null : "npm run agentkit -- skills sync",
308
+ };
309
+ }
310
+
311
+ function inspectWarnings(
312
+ capsule: LoadedAgentCapsule,
313
+ transcription: ReturnType<typeof resolveTranscriptionConfig>,
314
+ skills: AgentInspectSkills,
315
+ ): AgentInspectWarning[] {
316
+ const warnings: AgentInspectWarning[] = [];
317
+
318
+ if (skills.status === "missing" || skills.status === "outdated") {
319
+ warnings.push({
320
+ code: "local_skills_outdated",
321
+ message: "Local AgentKit skills are older than or missing from the installed package docs.",
322
+ command: "npm run agentkit -- skills sync",
323
+ });
324
+ }
325
+
326
+ if (
327
+ transcription.enabled &&
328
+ transcription.provider === "openai" &&
329
+ (capsule.config.channels ?? []).some((channel) => channel.type === "telegram" && channel.audio?.mode === "transcribe")
330
+ ) {
331
+ warnings.push({
332
+ code: "telegram_audio_openai_format",
333
+ message: "Telegram voice notes arrive as OGG/Opus; use Groq for the default Telegram voice-note transcription path.",
334
+ command: "Set transcription.provider to \"groq\" and secret to \"GROQ_API_KEY\".",
335
+ });
336
+ }
337
+
338
+ return warnings;
339
+ }
340
+
155
341
  function managedCloudSecrets(capsule: LoadedAgentCapsule): string[] {
156
342
  const secrets = new Set<string>();
157
343
 
@@ -160,5 +346,9 @@ function managedCloudSecrets(capsule: LoadedAgentCapsule): string[] {
160
346
  secrets.add("TURSO_DATABASE_URL");
161
347
  }
162
348
 
349
+ for (const secret of managedComposioRequiredSecrets(capsule.config)) {
350
+ secrets.add(secret);
351
+ }
352
+
163
353
  return Array.from(secrets).sort();
164
354
  }