@andreprado/agentkit 0.1.0-alpha.9 → 0.1.1

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 (122) hide show
  1. package/README.md +18 -1
  2. package/docs/guides/add-channel.md +251 -7
  3. package/docs/guides/add-knowledge.md +10 -0
  4. package/docs/guides/add-managed-composio.md +165 -0
  5. package/docs/guides/add-tool.md +10 -3
  6. package/docs/guides/channel-security.md +162 -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 +61 -1
  10. package/docs/guides/connect-whatsapp-evolution.md +121 -0
  11. package/docs/guides/connect-whatsapp-uazapi.md +139 -0
  12. package/docs/guides/connect-whatsapp-zapster.md +119 -16
  13. package/docs/guides/create-agent.md +31 -4
  14. package/docs/guides/debug-channel.md +159 -0
  15. package/docs/guides/improve-from-production.md +151 -0
  16. package/docs/guides/prepare-deploy.md +32 -14
  17. package/docs/guides/replay-production-traces.md +72 -0
  18. package/docs/guides/run-evals.md +95 -25
  19. package/docs/guides/security-rules.md +9 -5
  20. package/docs/guides/send-feedback.md +135 -0
  21. package/docs/guides/use-jev.md +67 -0
  22. package/docs/guides/use-provider.md +70 -3
  23. package/docs/llms-full.txt +295 -25
  24. package/docs/llms.txt +54 -7
  25. package/package.json +3 -7
  26. package/src/cli/args.ts +23 -2
  27. package/src/cli/cloud-client.ts +121 -9
  28. package/src/cli/commands/channels.ts +856 -36
  29. package/src/cli/commands/feedback.ts +438 -0
  30. package/src/cli/commands/provider.ts +47 -0
  31. package/src/cli/commands/transcribe.ts +171 -0
  32. package/src/cli/deploy-chat-ui.ts +232 -18
  33. package/src/cli/deploy-readiness.ts +227 -14
  34. package/src/cli/help.ts +67 -9
  35. package/src/cli/index.ts +740 -35
  36. package/src/cli/new-command.ts +41 -0
  37. package/src/cloud/client.ts +4 -3
  38. package/src/cloud/contracts.ts +1 -1
  39. package/src/create-project.ts +18 -35
  40. package/src/index.ts +565 -11
  41. package/src/providers/codex-auth.ts +111 -0
  42. package/src/providers/pi.ts +88 -19
  43. package/src/providers/test.ts +36 -0
  44. package/src/providers/types.ts +8 -0
  45. package/src/runtime/channel-test-harness.ts +21 -1
  46. package/src/runtime/channels/discord.ts +904 -0
  47. package/src/runtime/channels/generic-webhook.ts +682 -0
  48. package/src/runtime/channels/net-guard.ts +480 -0
  49. package/src/runtime/channels/provider-fetch.ts +54 -0
  50. package/src/runtime/channels/slack.ts +652 -0
  51. package/src/runtime/channels/telegram.ts +379 -15
  52. package/src/runtime/channels/whatsapp-evolution.ts +1330 -0
  53. package/src/runtime/channels/whatsapp-meta.ts +9 -0
  54. package/src/runtime/channels/whatsapp-uazapi.ts +1192 -0
  55. package/src/runtime/channels/whatsapp-zapster.ts +702 -40
  56. package/src/runtime/channels.ts +83 -3
  57. package/src/runtime/chat.ts +70 -44
  58. package/src/runtime/config.ts +512 -20
  59. package/src/runtime/core/manifest.ts +75 -5
  60. package/src/runtime/core/targets.ts +5 -5
  61. package/src/runtime/deploy-readiness.ts +34 -4
  62. package/src/runtime/dev-server.ts +639 -39
  63. package/src/runtime/env.ts +8 -3
  64. package/src/runtime/evals.ts +445 -74
  65. package/src/runtime/improve.ts +868 -0
  66. package/src/runtime/inspect.ts +173 -4
  67. package/src/runtime/integrations/composio.ts +425 -0
  68. package/src/runtime/knowledge/embeddings.ts +45 -7
  69. package/src/runtime/knowledge/ingest.ts +69 -6
  70. package/src/runtime/knowledge/retrieve.ts +25 -5
  71. package/src/runtime/knowledge/schema.ts +45 -1
  72. package/src/runtime/knowledge/vector.ts +30 -30
  73. package/src/runtime/prompt-context.ts +141 -0
  74. package/src/runtime/runtime-contract.ts +71 -7
  75. package/src/runtime/skills.ts +95 -0
  76. package/src/runtime/targets/cloudflare/build.ts +1010 -208
  77. package/src/runtime/targets/container/server.ts +1 -1
  78. package/src/runtime/targets/vps/deploy.ts +26 -9
  79. package/src/runtime/tool-runner.ts +9 -1
  80. package/src/runtime/tools.ts +26 -2
  81. package/src/runtime/transcription.ts +483 -0
  82. package/src/storage/sqlite.ts +7 -2
  83. package/src/templates/blank.ts +37 -9
  84. package/src/templates/dentista.ts +40 -14
  85. package/src/templates/skills/agentkit-build-agent/SKILL.md +34 -5
  86. package/src/templates/skills/agentkit-build-agent/templates/appointment-intake.instructions.md +2 -1
  87. package/src/templates/skills/agentkit-capsule/SKILL.md +32 -3
  88. package/src/templates/skills/agentkit-capsule/references/docs-router.md +2 -2
  89. package/src/templates/skills/agentkit-channels/SKILL.md +66 -1
  90. package/src/templates/skills/agentkit-channels/references/channel-buffering.md +8 -1
  91. package/src/templates/skills/agentkit-channels/references/channel-debugging.md +28 -3
  92. package/src/templates/skills/agentkit-channels/references/discord.md +93 -0
  93. package/src/templates/skills/agentkit-channels/references/slack.md +56 -0
  94. package/src/templates/skills/agentkit-channels/references/telegram.md +34 -0
  95. package/src/templates/skills/agentkit-channels/references/whatsapp-evolution.md +57 -0
  96. package/src/templates/skills/agentkit-channels/references/whatsapp-uazapi.md +54 -0
  97. package/src/templates/skills/agentkit-channels/references/whatsapp-zapster.md +42 -8
  98. package/src/templates/skills/agentkit-database/SKILL.md +11 -0
  99. package/src/templates/skills/agentkit-deploy/SKILL.md +9 -1
  100. package/src/templates/skills/agentkit-evals/SKILL.md +77 -13
  101. package/src/templates/skills/agentkit-evals/templates/multi-turn.eval.md +13 -6
  102. package/src/templates/skills/agentkit-evals/templates/no-leak.eval.md +8 -4
  103. package/src/templates/skills/agentkit-evals/templates/smoke.eval.md +8 -4
  104. package/src/templates/skills/agentkit-evals/templates/tool-call.eval.md +16 -7
  105. package/src/templates/skills/agentkit-improve/SKILL.md +96 -0
  106. package/src/templates/skills/agentkit-improve/references/replay-side-effects.md +18 -0
  107. package/src/templates/skills/agentkit-improve/references/trace-packets.md +22 -0
  108. package/src/templates/skills/agentkit-improve/templates/regression.eval.md +18 -0
  109. package/src/templates/skills/agentkit-integrations/SKILL.md +98 -0
  110. package/src/templates/skills/agentkit-knowledge/SKILL.md +4 -1
  111. package/src/templates/skills/agentkit-prompts/SKILL.md +3 -1
  112. package/src/templates/skills/agentkit-provider/SKILL.md +29 -4
  113. package/src/templates/skills/agentkit-security/SKILL.md +5 -2
  114. package/src/templates/skills/agentkit-tools/SKILL.md +8 -1
  115. package/src/templates/skills/agentkit-tools/examples/eval-safe-external-action.tool.md +8 -8
  116. package/src/templates/skills/agentkit-tools/examples/jev-service-fit.tool.md +110 -0
  117. package/src/templates/skills/agentkit-troubleshooting/SKILL.md +25 -1
  118. package/src/templates/support.ts +42 -12
  119. package/docs/guides/agentkit-skills-architecture.md +0 -471
  120. package/docs/guides/channels-implementation-map.md +0 -243
  121. package/docs/guides/channels-production-handoff.md +0 -101
  122. package/docs/portable-deploy-release-checklist.md +0 -41
@@ -0,0 +1,41 @@
1
+ import { createInterface } from "node:readline/promises";
2
+
3
+ const newUsage = "agentkit new [name] [--template blank|support|dentista] [--no-install]";
4
+
5
+ export async function resolveNewProjectName(
6
+ positional: string[],
7
+ promptProjectName: () => Promise<string> = promptForProjectName,
8
+ ): Promise<string> {
9
+ const [name] = positional;
10
+
11
+ if (name) {
12
+ return name;
13
+ }
14
+
15
+ const promptedName = (await promptProjectName()).trim();
16
+
17
+ if (!promptedName) {
18
+ throw new Error(`Project name is required. Usage: ${newUsage}`);
19
+ }
20
+
21
+ return promptedName;
22
+ }
23
+
24
+ async function promptForProjectName(): Promise<string> {
25
+ if (!process.stdin.isTTY || !process.stdout.isTTY) {
26
+ throw new Error(
27
+ `Missing project name. Usage: ${newUsage}. Run \`agentkit new\` in an interactive terminal to be prompted, or pass \`agentkit new <name>\` / \`agentkit new .\` in scripts.`,
28
+ );
29
+ }
30
+
31
+ const readline = createInterface({
32
+ input: process.stdin,
33
+ output: process.stdout,
34
+ });
35
+
36
+ try {
37
+ return await readline.question("Project folder name (or . for current directory): ");
38
+ } finally {
39
+ readline.close();
40
+ }
41
+ }
@@ -1,4 +1,4 @@
1
- import { mkdir, writeFile } from "node:fs/promises";
1
+ import { chmod, mkdir, writeFile } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
3
 
4
4
  import type { AgentBuildResult } from "../runtime/targets/cloudflare/build";
@@ -15,7 +15,7 @@ export async function deployBuildToAgentKitCloud(
15
15
  const headers = new Headers({
16
16
  "Content-Type": "application/json",
17
17
  });
18
- const apiToken = options.apiToken ?? process.env.AGENTKIT_CLOUD_API_TOKEN;
18
+ const apiToken = options.anonymous ? undefined : options.apiToken ?? process.env.AGENTKIT_CLOUD_API_TOKEN;
19
19
 
20
20
  if (apiToken) {
21
21
  headers.set("Authorization", `Bearer ${apiToken}`);
@@ -70,7 +70,8 @@ export async function writeLocalDeployState(root: string, deploy: CreateDeployRe
70
70
  };
71
71
 
72
72
  await mkdir(join(root, ".agentkit"), { recursive: true });
73
- await writeFile(statePath, `${JSON.stringify(state, null, 2)}\n`);
73
+ await writeFile(statePath, `${JSON.stringify(state, null, 2)}\n`, { mode: 0o600 });
74
+ await chmod(statePath, 0o600);
74
75
  return statePath;
75
76
  }
76
77
 
@@ -58,6 +58,6 @@ export type CreateDeployResponse = {
58
58
 
59
59
  export type AgentKitCloudDeployOptions = {
60
60
  apiUrl: string;
61
- apiToken?: string;
61
+ apiToken?: string | null;
62
62
  anonymous?: boolean;
63
63
  };
@@ -1,10 +1,11 @@
1
1
  import { execFile } from "node:child_process";
2
- import { mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
3
- import { basename, dirname, join, relative, resolve } from "node:path";
2
+ import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
3
+ import { basename, dirname, join, resolve } from "node:path";
4
4
  import { promisify } from "node:util";
5
5
  import { fileURLToPath } from "node:url";
6
6
 
7
- import { getTemplate, type TemplateFile } from "./templates";
7
+ import { loadDefaultSkillFiles } from "./runtime/skills";
8
+ import { getTemplate } from "./templates";
8
9
 
9
10
  const execFileAsync = promisify(execFile);
10
11
  const moduleDir = dirname(fileURLToPath(import.meta.url));
@@ -41,8 +42,7 @@ export async function createProject(options: CreateProjectOptions): Promise<Crea
41
42
  }
42
43
 
43
44
  for (const file of files) {
44
- const absolutePath = join(projectPath, file.path);
45
- const directory = absolutePath.slice(0, absolutePath.lastIndexOf("/"));
45
+ const { absolutePath, directory } = resolveProjectFilePath(projectPath, file.path);
46
46
 
47
47
  await mkdir(directory, { recursive: true });
48
48
  await writeFile(absolutePath, file.contents);
@@ -57,6 +57,18 @@ export async function createProject(options: CreateProjectOptions): Promise<Crea
57
57
  };
58
58
  }
59
59
 
60
+ export function resolveProjectFilePath(
61
+ projectPath: string,
62
+ filePath: string,
63
+ pathApi: Pick<typeof import("node:path"), "dirname" | "join"> = { dirname, join },
64
+ ): { absolutePath: string; directory: string } {
65
+ const absolutePath = pathApi.join(projectPath, filePath);
66
+ return {
67
+ absolutePath,
68
+ directory: pathApi.dirname(absolutePath),
69
+ };
70
+ }
71
+
60
72
  function resolveProjectTarget(options: CreateProjectOptions): { name: string; path: string; currentDirectory: boolean } {
61
73
  if (options.name === ".") {
62
74
  const path = resolve(options.cwd);
@@ -114,7 +126,7 @@ async function resolveAgentKitDependency(): Promise<string> {
114
126
 
115
127
  const packageRoot = resolve(moduleDir, "..");
116
128
 
117
- if (await directoryExists(resolve(packageRoot, "../..", ".git"))) {
129
+ if (await pathExists(resolve(packageRoot, "../..", ".git"))) {
118
130
  return `file:${packageRoot}`;
119
131
  }
120
132
 
@@ -129,35 +141,6 @@ async function resolveAgentKitDependency(): Promise<string> {
129
141
  return packageJson.version;
130
142
  }
131
143
 
132
- async function loadDefaultSkillFiles(): Promise<TemplateFile[]> {
133
- const sourceRoot = join(moduleDir, "templates", "skills");
134
- const sourceFiles = await listFiles(sourceRoot);
135
-
136
- return Promise.all(
137
- sourceFiles.map(async (sourcePath) => ({
138
- path: join("skills", relative(sourceRoot, sourcePath)).replaceAll("\\", "/"),
139
- contents: await readFile(sourcePath, "utf8"),
140
- })),
141
- );
142
- }
143
-
144
- async function listFiles(directory: string): Promise<string[]> {
145
- const entries = await readdir(directory, { withFileTypes: true });
146
- const files = await Promise.all(
147
- entries.map(async (entry) => {
148
- const path = join(directory, entry.name);
149
-
150
- if (entry.isDirectory()) {
151
- return listFiles(path);
152
- }
153
-
154
- return entry.isFile() ? [path] : [];
155
- }),
156
- );
157
-
158
- return files.flat().sort();
159
- }
160
-
161
144
  async function directoryExists(path: string): Promise<boolean> {
162
145
  try {
163
146
  const result = await stat(path);