@andreprado/agentkit 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/README.md +8 -77
  2. package/docs/guides/add-channel.md +14 -92
  3. package/docs/guides/add-knowledge.md +0 -21
  4. package/docs/guides/add-tool.md +5 -11
  5. package/docs/guides/channel-security.md +3 -207
  6. package/docs/guides/connect-discord.md +7 -172
  7. package/docs/guides/connect-slack.md +6 -121
  8. package/docs/guides/connect-telegram.md +6 -165
  9. package/docs/guides/connect-whatsapp-evolution.md +6 -116
  10. package/docs/guides/connect-whatsapp-uazapi.md +6 -134
  11. package/docs/guides/connect-whatsapp-zapster.md +6 -202
  12. package/docs/guides/create-agent.md +5 -14
  13. package/docs/guides/debug-channel.md +4 -156
  14. package/docs/guides/improve-local.md +13 -0
  15. package/docs/guides/local-only-migration.md +35 -0
  16. package/docs/guides/replay-local-traces.md +11 -0
  17. package/docs/guides/run-evals.md +2 -4
  18. package/docs/guides/security-rules.md +5 -154
  19. package/docs/guides/use-jev.md +3 -6
  20. package/docs/guides/use-provider.md +0 -3
  21. package/docs/guides/write-feedback.md +10 -0
  22. package/docs/llms-full.txt +27 -448
  23. package/docs/llms.txt +8 -44
  24. package/package.json +2 -4
  25. package/src/cli/commands/channels.ts +8 -1613
  26. package/src/cli/commands/feedback.ts +8 -86
  27. package/src/cli/constants.ts +0 -3
  28. package/src/cli/flags.ts +0 -28
  29. package/src/cli/help.ts +16 -92
  30. package/src/cli/index.ts +15 -1091
  31. package/src/index.ts +6 -158
  32. package/src/providers/pi.ts +2 -0
  33. package/src/runtime/channels/discord.ts +2 -2
  34. package/src/runtime/chat.ts +5 -3
  35. package/src/runtime/config.ts +14 -148
  36. package/src/runtime/database.ts +2 -2
  37. package/src/runtime/dev-server.ts +8 -8
  38. package/src/runtime/env.ts +11 -0
  39. package/src/runtime/improve.ts +2 -262
  40. package/src/runtime/inspect.ts +13 -73
  41. package/src/runtime/knowledge/ingest.ts +1 -1
  42. package/src/runtime/knowledge/tool.ts +16 -2
  43. package/src/runtime/knowledge/vector.ts +1 -1
  44. package/src/runtime/tool-runner.ts +5 -3
  45. package/src/runtime/tools.ts +10 -14
  46. package/src/storage/sqlite.ts +11 -32
  47. package/src/templates/blank.ts +15 -102
  48. package/src/templates/common.ts +60 -0
  49. package/src/templates/dentista.ts +7 -74
  50. package/src/templates/skills/agentkit-capsule/SKILL.md +5 -7
  51. package/src/templates/skills/agentkit-capsule/references/docs-router.md +2 -3
  52. package/src/templates/skills/agentkit-channels/SKILL.md +6 -119
  53. package/src/templates/skills/agentkit-channels/references/channel-buffering.md +0 -9
  54. package/src/templates/skills/agentkit-channels/references/channel-debugging.md +1 -64
  55. package/src/templates/skills/agentkit-channels/references/discord.md +2 -92
  56. package/src/templates/skills/agentkit-channels/references/slack.md +2 -55
  57. package/src/templates/skills/agentkit-channels/references/telegram.md +2 -71
  58. package/src/templates/skills/agentkit-channels/references/whatsapp-evolution.md +2 -56
  59. package/src/templates/skills/agentkit-channels/references/whatsapp-uazapi.md +2 -53
  60. package/src/templates/skills/agentkit-channels/references/whatsapp-zapster.md +2 -70
  61. package/src/templates/skills/agentkit-database/SKILL.md +2 -4
  62. package/src/templates/skills/agentkit-evals/SKILL.md +1 -1
  63. package/src/templates/skills/agentkit-improve/SKILL.md +6 -85
  64. package/src/templates/skills/agentkit-improve/references/trace-packets.md +1 -1
  65. package/src/templates/skills/agentkit-provider/SKILL.md +0 -1
  66. package/src/templates/skills/agentkit-security/SKILL.md +1 -3
  67. package/src/templates/skills/agentkit-tools/SKILL.md +1 -1
  68. package/src/templates/skills/agentkit-tools/examples/database-write.tool.md +1 -2
  69. package/src/templates/skills/agentkit-troubleshooting/SKILL.md +5 -11
  70. package/src/templates/support.ts +8 -92
  71. package/docs/guides/add-managed-composio.md +0 -165
  72. package/docs/guides/improve-from-production.md +0 -151
  73. package/docs/guides/prepare-deploy.md +0 -227
  74. package/docs/guides/replay-production-traces.md +0 -72
  75. package/docs/guides/send-feedback.md +0 -135
  76. package/src/cli/cloud-client.ts +0 -377
  77. package/src/cli/deploy-chat-ui.ts +0 -606
  78. package/src/cli/deploy-readiness.ts +0 -561
  79. package/src/cloud/artifact.ts +0 -139
  80. package/src/cloud/client.ts +0 -80
  81. package/src/cloud/contracts.ts +0 -63
  82. package/src/cloud/index.ts +0 -3
  83. package/src/runtime/build.ts +0 -43
  84. package/src/runtime/core/deploy-state.ts +0 -54
  85. package/src/runtime/core/manifest.ts +0 -283
  86. package/src/runtime/core/targets.ts +0 -133
  87. package/src/runtime/deploy-readiness.ts +0 -135
  88. package/src/runtime/deploy.ts +0 -1
  89. package/src/runtime/integrations/composio.ts +0 -425
  90. package/src/runtime/targets/cloudflare/build.ts +0 -3319
  91. package/src/runtime/targets/container/build.ts +0 -146
  92. package/src/runtime/targets/container/server.ts +0 -33
  93. package/src/runtime/targets/vps/deploy.ts +0 -223
  94. package/src/templates/skills/agentkit-deploy/SKILL.md +0 -52
  95. package/src/templates/skills/agentkit-integrations/SKILL.md +0 -98
@@ -1,80 +0,0 @@
1
- import { chmod, mkdir, writeFile } from "node:fs/promises";
2
- import { join } from "node:path";
3
-
4
- import type { AgentBuildResult } from "../runtime/targets/cloudflare/build";
5
- import type { LocalDeployState } from "../runtime/core/deploy-state";
6
- import { AgentKitError } from "../runtime/errors";
7
- import { createHostedDeployArtifact } from "./artifact";
8
- import type { AgentKitCloudDeployOptions, CreateDeployRequest, CreateDeployResponse } from "./contracts";
9
-
10
- export async function deployBuildToAgentKitCloud(
11
- build: AgentBuildResult,
12
- options: AgentKitCloudDeployOptions,
13
- ): Promise<CreateDeployResponse> {
14
- const artifact = await createHostedDeployArtifact(build);
15
- const headers = new Headers({
16
- "Content-Type": "application/json",
17
- });
18
- const apiToken = options.anonymous ? undefined : options.apiToken ?? process.env.AGENTKIT_CLOUD_API_TOKEN;
19
-
20
- if (apiToken) {
21
- headers.set("Authorization", `Bearer ${apiToken}`);
22
- }
23
-
24
- const response = await fetch(new URL("/v1/deploys", normalizeApiUrl(options.apiUrl)), {
25
- method: "POST",
26
- headers,
27
- body: JSON.stringify({
28
- project_name: artifact.manifest.name,
29
- anonymous: options.anonymous ?? !apiToken,
30
- artifact,
31
- } satisfies CreateDeployRequest),
32
- });
33
- const payload = await response.json().catch(() => null);
34
-
35
- if (!response.ok) {
36
- const code =
37
- payload && typeof payload === "object" && "error" in payload
38
- ? String((payload as { error?: { code?: unknown } }).error?.code ?? "cloud_deploy_failed")
39
- : "cloud_deploy_failed";
40
- const message =
41
- payload && typeof payload === "object" && "error" in payload
42
- ? String((payload as { error?: { message?: unknown } }).error?.message ?? "AgentKit Cloud deploy failed.")
43
- : `AgentKit Cloud deploy failed with HTTP ${response.status}.`;
44
- throw new AgentKitError(code, message);
45
- }
46
-
47
- return payload as CreateDeployResponse;
48
- }
49
-
50
- export async function writeLocalDeployState(root: string, deploy: CreateDeployResponse): Promise<string> {
51
- const statePath = join(root, ".agentkit/deploy.json");
52
- const state: LocalDeployState = {
53
- project_id: deploy.project.id,
54
- deploy_id: deploy.deploy.id,
55
- url: deploy.deploy.url,
56
- target: "cloudflare",
57
- runtime: "edge",
58
- resources: {
59
- cloudflare: {
60
- worker_url: deploy.deploy.url,
61
- durable_object_class: "AgentKitConversationStore",
62
- },
63
- },
64
- owner_state: deploy.project.owner_state,
65
- access: {
66
- mode: deploy.deploy.access.mode,
67
- private_token: deploy.deploy.access.private_token ?? undefined,
68
- },
69
- created_at: new Date().toISOString(),
70
- };
71
-
72
- await mkdir(join(root, ".agentkit"), { recursive: true });
73
- await writeFile(statePath, `${JSON.stringify(state, null, 2)}\n`, { mode: 0o600 });
74
- await chmod(statePath, 0o600);
75
- return statePath;
76
- }
77
-
78
- function normalizeApiUrl(value: string): string {
79
- return value.endsWith("/") ? value : `${value}/`;
80
- }
@@ -1,63 +0,0 @@
1
- import type { AgentManifestWithBundle } from "../runtime/targets/cloudflare/build";
2
-
3
- export type HostedDeployArtifact = {
4
- manifest: AgentManifestWithBundle;
5
- worker: {
6
- content_type: "application/javascript";
7
- source: string;
8
- sha256: string;
9
- };
10
- wrangler: {
11
- content_type: "application/json";
12
- source: string;
13
- };
14
- turso_schema?: {
15
- content_type: "text/sql";
16
- source: string;
17
- sha256: string;
18
- };
19
- knowledge_sources?: {
20
- content_type: "application/json";
21
- sources: Array<{
22
- kind: "file";
23
- source_key: string;
24
- title: string | null;
25
- content: string;
26
- sha256: string;
27
- }>;
28
- sha256: string;
29
- };
30
- };
31
-
32
- export type CreateDeployRequest = {
33
- project_name: string;
34
- anonymous: boolean;
35
- artifact: HostedDeployArtifact;
36
- };
37
-
38
- export type CreateDeployResponse = {
39
- project: {
40
- id: string;
41
- owner_state: "anonymous" | "claimed";
42
- };
43
- deploy: {
44
- id: string;
45
- status: "ready" | "failed";
46
- url: string;
47
- access: {
48
- mode: string;
49
- private_token?: string;
50
- };
51
- knowledge?: {
52
- enabled: boolean;
53
- sources: number;
54
- chunks: number;
55
- };
56
- };
57
- };
58
-
59
- export type AgentKitCloudDeployOptions = {
60
- apiUrl: string;
61
- apiToken?: string | null;
62
- anonymous?: boolean;
63
- };
@@ -1,3 +0,0 @@
1
- export * from "./artifact";
2
- export * from "./client";
3
- export * from "./contracts";
@@ -1,43 +0,0 @@
1
- import { resolveBuildTarget, type RuntimeTargetId } from "./core/targets";
2
- import { buildContainerAgentCapsule, type ContainerBuildResult } from "./targets/container/build";
3
- import {
4
- buildCloudflareAgentCapsule,
5
- type AgentBuildResult as CloudflareBuildResult,
6
- type AgentManifest,
7
- type AgentManifestWithBundle,
8
- } from "./targets/cloudflare/build";
9
-
10
- export type BuildTarget = RuntimeTargetId;
11
-
12
- export type BuildAgentOptions = {
13
- target?: string;
14
- };
15
-
16
- export type AgentBuildResult = CloudflareBuildResult | ContainerBuildResult;
17
- export type { AgentManifest, AgentManifestWithBundle };
18
-
19
- export async function buildAgentCapsule(
20
- cwd?: string,
21
- options?: { target?: "cloudflare" },
22
- ): Promise<CloudflareBuildResult>;
23
- export async function buildAgentCapsule(
24
- cwd: string | undefined,
25
- options: { target: "container" },
26
- ): Promise<ContainerBuildResult>;
27
- export async function buildAgentCapsule(cwd?: string, options?: BuildAgentOptions): Promise<AgentBuildResult>;
28
- export async function buildAgentCapsule(
29
- cwd = process.cwd(),
30
- options: BuildAgentOptions = {},
31
- ): Promise<AgentBuildResult> {
32
- const target = resolveBuildTarget(options.target);
33
-
34
- if (target.id === "cloudflare") {
35
- return buildCloudflareAgentCapsule(cwd);
36
- }
37
-
38
- if (target.id === "container") {
39
- return buildContainerAgentCapsule(cwd);
40
- }
41
-
42
- throw new Error(`Target registry returned unsupported build target "${target.id}".`);
43
- }
@@ -1,54 +0,0 @@
1
- import { readFile } from "node:fs/promises";
2
- import { join } from "node:path";
3
-
4
- import { findAgentCapsuleRoot } from "../config";
5
- import type { RuntimeTargetId } from "./targets";
6
-
7
- export type LocalDeployState = {
8
- project_id?: string;
9
- deploy_id: string;
10
- url?: string;
11
- target: RuntimeTargetId;
12
- runtime: "edge" | "container";
13
- resources: Record<string, unknown>;
14
- owner_state?: "anonymous" | "claimed";
15
- access?: {
16
- mode?: string;
17
- private_token?: string;
18
- };
19
- created_at?: string;
20
- };
21
-
22
- export function normalizeDeployState(input: unknown): LocalDeployState | null {
23
- if (!input || typeof input !== "object") {
24
- return null;
25
- }
26
-
27
- const state = input as Partial<LocalDeployState>;
28
-
29
- if (typeof state.deploy_id !== "string" || state.deploy_id.length === 0) {
30
- return null;
31
- }
32
-
33
- return {
34
- ...state,
35
- deploy_id: state.deploy_id,
36
- target: isRuntimeTarget(state.target) ? state.target : "cloudflare",
37
- runtime: state.runtime === "container" ? "container" : "edge",
38
- resources: state.resources && typeof state.resources === "object" ? state.resources : {},
39
- };
40
- }
41
-
42
- export async function readLocalDeployStateIfExists(cwd: string): Promise<LocalDeployState | null> {
43
- try {
44
- const root = await findAgentCapsuleRoot(cwd);
45
- const source = await readFile(join(root, ".agentkit/deploy.json"), "utf8");
46
- return normalizeDeployState(JSON.parse(source));
47
- } catch {
48
- return null;
49
- }
50
- }
51
-
52
- function isRuntimeTarget(value: unknown): value is RuntimeTargetId {
53
- return value === "local" || value === "cloudflare" || value === "container" || value === "vps";
54
- }
@@ -1,283 +0,0 @@
1
- import { relative, resolve } from "node:path";
2
-
3
- import { AgentKitError } from "../errors";
4
-
5
- import type { AgentConfig, AgentTool } from "../../index";
6
- import type { LoadedAgentCapsule } from "../config";
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 { resolveTranscriptionConfig } from "../transcription";
15
-
16
- export type ManifestSchema = {
17
- source: string;
18
- sha256: string;
19
- };
20
-
21
- export type SharedAgentManifest = {
22
- schema_version: 1;
23
- name: string;
24
- runtime: AgentConfig["runtime"];
25
- provider: AgentConfig["provider"];
26
- timeZone: string | null;
27
- prompt: string;
28
- secrets: string[];
29
- tools: Array<{
30
- name: string;
31
- description: string;
32
- inputSchema: AgentTool["inputSchema"];
33
- outputSchema?: AgentTool["outputSchema"];
34
- secrets: string[];
35
- permissions: string[];
36
- timeoutMs: number | null;
37
- }>;
38
- integrations: Array<{
39
- name: string;
40
- provider: "composio";
41
- mode: "managed";
42
- toolkits: string[];
43
- tools: string[];
44
- userId: string;
45
- confirmExternalWrites: boolean;
46
- }>;
47
- channels: NonNullable<AgentConfig["channels"]>;
48
- transcription: {
49
- enabled: boolean;
50
- provider: string | null;
51
- model: string | null;
52
- secret: string | null;
53
- language: string | null;
54
- prompt: string | null;
55
- limits: {
56
- maxDurationSeconds: number | null;
57
- maxBytes: number | null;
58
- };
59
- rawAudioTtlSeconds: number | null;
60
- };
61
- knowledge: {
62
- enabled: boolean;
63
- sources: Array<{
64
- kind: "file" | "url";
65
- value: string;
66
- title: string | null;
67
- }>;
68
- embedding: {
69
- provider: string;
70
- model: string | null;
71
- dimensions: number | null;
72
- secret: string | null;
73
- };
74
- retrieval: {
75
- topK: number;
76
- hybrid: boolean;
77
- };
78
- internalTool: string | null;
79
- };
80
- access: AgentConfig["access"];
81
- storage: {
82
- driver: AgentConfig["storage"]["driver"];
83
- database:
84
- | {
85
- driver: "none";
86
- }
87
- | {
88
- driver: "turso";
89
- schema: string | null;
90
- schema_sha256: string | null;
91
- };
92
- files:
93
- | {
94
- driver: "none";
95
- }
96
- | {
97
- driver: "object";
98
- bucket: string;
99
- prefix: string;
100
- maxUploadBytes: number;
101
- };
102
- };
103
- };
104
-
105
- export function buildSharedAgentManifest(
106
- capsule: LoadedAgentCapsule,
107
- options: { databaseSchema?: ManifestSchema | null } = {},
108
- ): SharedAgentManifest {
109
- if (capsule.config.provider.name === "openai-codex") {
110
- throw new AgentKitError(
111
- "target_runtime_incompatible",
112
- "openai-codex uses a local ChatGPT login. Use agentkit dev/chat/eval locally, or select an API-key provider with managed secrets for Cloudflare, container, or VPS deployment.",
113
- );
114
- }
115
-
116
- const requiredSecrets = new Set(capsule.config.secrets);
117
- const database = buildDatabaseManifest(capsule, options.databaseSchema ?? null);
118
- const files = buildFilesManifest(capsule);
119
- const knowledge = resolveKnowledgeConfig(capsule.config);
120
- const integrationTools = createManagedComposioTools(capsule.config);
121
- const tools = [...integrationTools, ...(capsule.config.tools ?? [])];
122
- const transcription = resolveTranscriptionConfig(capsule.config.transcription);
123
-
124
- requiredSecrets.add("AGENTKIT_PRIVATE_TOKEN");
125
-
126
- if (capsule.config.access.mode === "token") {
127
- requiredSecrets.add("AGENTKIT_ACCESS_TOKEN");
128
- }
129
-
130
- if (capsule.config.provider.name === "openai") {
131
- requiredSecrets.add("OPENAI_API_KEY");
132
- }
133
-
134
- if (database.driver === "turso") {
135
- requiredSecrets.add("TURSO_DATABASE_URL");
136
- requiredSecrets.add("TURSO_AUTH_TOKEN");
137
- }
138
-
139
- if (knowledge.embedding.secret) {
140
- requiredSecrets.add(knowledge.embedding.secret);
141
- }
142
-
143
- if (transcription.secret) {
144
- requiredSecrets.add(transcription.secret);
145
- }
146
-
147
- for (const secret of managedComposioRequiredSecrets(capsule.config)) {
148
- requiredSecrets.add(secret);
149
- }
150
-
151
- for (const tool of tools) {
152
- for (const secret of tool.secrets ?? []) {
153
- requiredSecrets.add(secret);
154
- }
155
- }
156
-
157
- for (const channel of capsule.config.channels ?? []) {
158
- for (const secret of channel.secrets) {
159
- requiredSecrets.add(secret);
160
- }
161
- }
162
-
163
- return {
164
- schema_version: 1,
165
- name: capsule.config.name,
166
- runtime: capsule.config.runtime,
167
- provider: capsule.config.provider,
168
- timeZone: capsule.config.timeZone ?? null,
169
- prompt: toCapsulePath(capsule, capsule.instructionsPath),
170
- secrets: Array.from(requiredSecrets).sort(),
171
- tools: tools.map((tool) => ({
172
- name: tool.name,
173
- description: tool.description,
174
- inputSchema: tool.inputSchema,
175
- outputSchema: tool.outputSchema,
176
- secrets: [...(tool.secrets ?? [])].sort(),
177
- permissions: [...(tool.permissions ?? [])].sort(),
178
- timeoutMs: tool.timeoutMs ?? null,
179
- })),
180
- integrations: resolveManagedComposioIntegrations(capsule.config).map((integration) => ({
181
- name: integration.name,
182
- provider: integration.provider,
183
- mode: integration.mode,
184
- toolkits: integration.toolkits,
185
- tools: integration.allowedTools,
186
- userId: integration.userId,
187
- confirmExternalWrites: integration.confirmExternalWrites !== false,
188
- })),
189
- channels: capsule.config.channels ?? [],
190
- transcription: {
191
- enabled: transcription.enabled,
192
- provider: transcription.enabled ? transcription.provider : null,
193
- model: transcription.enabled ? transcription.model : null,
194
- secret: transcription.secret,
195
- language: transcription.language,
196
- prompt: transcription.prompt,
197
- limits: {
198
- maxDurationSeconds: transcription.limits.maxDurationSeconds ?? null,
199
- maxBytes: transcription.limits.maxBytes ?? null,
200
- },
201
- rawAudioTtlSeconds: transcription.rawAudioTtlSeconds,
202
- },
203
- knowledge: {
204
- enabled: knowledge.enabled,
205
- sources: knowledge.sources.map((source) => ({
206
- kind: source.kind,
207
- value: source.value,
208
- title: source.title,
209
- })),
210
- embedding: knowledge.embedding,
211
- retrieval: knowledge.retrieval,
212
- internalTool: knowledge.enabled ? KNOWLEDGE_SEARCH_TOOL_NAME : null,
213
- },
214
- access: capsule.config.access,
215
- storage: {
216
- driver: capsule.config.storage.driver,
217
- database,
218
- files,
219
- },
220
- };
221
- }
222
-
223
- export function toCapsulePath(capsule: LoadedAgentCapsule, path: string): string {
224
- const localPath = relative(capsule.root, path);
225
- return localPath.length > 0 ? localPath : ".";
226
- }
227
-
228
- function buildDatabaseManifest(
229
- capsule: LoadedAgentCapsule,
230
- schema: ManifestSchema | null,
231
- ): SharedAgentManifest["storage"]["database"] {
232
- const database = capsule.config.storage.database;
233
-
234
- if (!database || database.driver === "none") {
235
- return { driver: "none" };
236
- }
237
-
238
- const schemaPath = database.schema ? resolve(capsule.root, database.schema) : null;
239
-
240
- return {
241
- driver: "turso",
242
- schema: schemaPath ? toCapsulePath(capsule, schemaPath) : null,
243
- schema_sha256: schema?.sha256 ?? null,
244
- };
245
- }
246
-
247
- function buildFilesManifest(capsule: LoadedAgentCapsule): SharedAgentManifest["storage"]["files"] {
248
- const files = capsule.config.storage.files;
249
-
250
- if (!files || files.driver === "none") {
251
- return { driver: "none" };
252
- }
253
-
254
- return {
255
- driver: "object",
256
- bucket: files.bucket ?? `agentkit-${slugify(capsule.config.name)}-files`,
257
- prefix: normalizePrefix(files.prefix ?? capsule.config.name),
258
- maxUploadBytes: files.maxUploadBytes ?? 10 * 1024 * 1024,
259
- };
260
- }
261
-
262
- function slugify(value: string): string {
263
- const slug = value
264
- .toLowerCase()
265
- .replace(/[^a-z0-9-]+/g, "-")
266
- .replace(/^-+|-+$/g, "")
267
- .slice(0, 48);
268
-
269
- return slug || "agent";
270
- }
271
-
272
- function normalizePrefix(value: string): string {
273
- return value
274
- .split("/")
275
- .map((part) =>
276
- part
277
- .toLowerCase()
278
- .replace(/[^a-z0-9_-]+/g, "-")
279
- .replace(/^-+|-+$/g, ""),
280
- )
281
- .filter(Boolean)
282
- .join("/");
283
- }
@@ -1,133 +0,0 @@
1
- import { AgentKitError } from "../errors";
2
-
3
- export const runtimeTargetIds = ["local", "cloudflare", "container", "vps"] as const;
4
-
5
- export type RuntimeTargetId = (typeof runtimeTargetIds)[number];
6
- export type RuntimeTargetCapabilityState = "available" | "planned" | "unsupported";
7
- export type RuntimeStorageCapability = "agentkit" | "durable-object-sqlite" | "local-sqlite" | "postgres";
8
- export type RuntimeFilesCapability = "none" | "r2" | "local-disk" | "s3-compatible";
9
- export type RuntimeChannelCapability = "website" | "telegram" | "whatsapp" | "discord" | "slack" | "webhook";
10
- export type RuntimeProviderSupport = "pi-local" | "edge-compatible" | "server-env";
11
-
12
- export type RuntimeTargetCapabilities = {
13
- build: RuntimeTargetCapabilityState;
14
- deploy: RuntimeTargetCapabilityState;
15
- dev: RuntimeTargetCapabilityState;
16
- storage: readonly RuntimeStorageCapability[];
17
- files: readonly RuntimeFilesCapability[];
18
- channels: readonly RuntimeChannelCapability[];
19
- providers: readonly RuntimeProviderSupport[];
20
- };
21
-
22
- export type RuntimeTarget = {
23
- id: RuntimeTargetId;
24
- label: string;
25
- capabilities: RuntimeTargetCapabilities;
26
- };
27
-
28
- export const runtimeTargets: Readonly<Record<RuntimeTargetId, RuntimeTarget>> = {
29
- local: {
30
- id: "local",
31
- label: "Local dev server",
32
- capabilities: {
33
- build: "unsupported",
34
- deploy: "unsupported",
35
- dev: "available",
36
- storage: ["local-sqlite"],
37
- files: ["local-disk"],
38
- channels: ["website", "slack", "webhook"],
39
- providers: ["pi-local"],
40
- },
41
- },
42
- cloudflare: {
43
- id: "cloudflare",
44
- label: "Cloudflare Worker",
45
- capabilities: {
46
- build: "available",
47
- deploy: "available",
48
- dev: "planned",
49
- storage: ["agentkit", "durable-object-sqlite", "postgres"],
50
- files: ["none", "r2"],
51
- channels: ["website", "telegram", "whatsapp", "discord", "slack", "webhook"],
52
- providers: ["edge-compatible"],
53
- },
54
- },
55
- container: {
56
- id: "container",
57
- label: "Container runtime",
58
- capabilities: {
59
- build: "available",
60
- deploy: "planned",
61
- dev: "planned",
62
- storage: ["local-sqlite", "postgres"],
63
- files: ["none", "local-disk", "s3-compatible"],
64
- channels: ["website", "telegram", "whatsapp", "discord", "slack", "webhook"],
65
- providers: ["server-env"],
66
- },
67
- },
68
- vps: {
69
- id: "vps",
70
- label: "VPS handoff",
71
- capabilities: {
72
- build: "unsupported",
73
- deploy: "available",
74
- dev: "unsupported",
75
- storage: ["local-sqlite", "postgres"],
76
- files: ["none", "local-disk", "s3-compatible"],
77
- channels: ["website", "telegram", "whatsapp", "discord", "slack", "webhook"],
78
- providers: ["server-env"],
79
- },
80
- },
81
- };
82
-
83
- export function resolveRuntimeTarget(id: string): RuntimeTarget {
84
- if (isRuntimeTargetId(id)) {
85
- return runtimeTargets[id];
86
- }
87
-
88
- throw new AgentKitError(
89
- "unsupported_target",
90
- `Unsupported target "${id}". Supported targets: ${runtimeTargetIds.join(", ")}.`,
91
- );
92
- }
93
-
94
- export function resolveBuildTarget(id = "cloudflare"): RuntimeTarget {
95
- const target = resolveRuntimeTarget(id);
96
-
97
- if (target.capabilities.build !== "available") {
98
- throw unsupportedCapability("build", target.id, listTargetsWithCapability("build"));
99
- }
100
-
101
- return target;
102
- }
103
-
104
- export function resolveDeployTarget(id = "cloudflare"): RuntimeTarget {
105
- const target = resolveRuntimeTarget(id);
106
-
107
- if (target.capabilities.deploy !== "available") {
108
- throw unsupportedCapability("deploy", target.id, listTargetsWithCapability("deploy"));
109
- }
110
-
111
- return target;
112
- }
113
-
114
- export function isRuntimeTargetId(id: string): id is RuntimeTargetId {
115
- return Object.prototype.hasOwnProperty.call(runtimeTargets, id);
116
- }
117
-
118
- export function listTargetsWithCapability(
119
- capability: "build" | "deploy" | "dev",
120
- ): readonly RuntimeTargetId[] {
121
- return runtimeTargetIds.filter((id) => runtimeTargets[id].capabilities[capability] === "available");
122
- }
123
-
124
- function unsupportedCapability(
125
- capability: "build" | "deploy" | "dev",
126
- id: RuntimeTargetId,
127
- supportedTargets: readonly RuntimeTargetId[],
128
- ): AgentKitError {
129
- return new AgentKitError(
130
- "unsupported_target",
131
- `Unsupported ${capability} target "${id}". Supported ${capability} targets: ${supportedTargets.join(", ")}.`,
132
- );
133
- }