@andreprado/agentkit 0.1.0-alpha.9 → 0.1.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.
- package/README.md +18 -1
- package/docs/guides/add-channel.md +251 -7
- package/docs/guides/add-knowledge.md +10 -0
- package/docs/guides/add-managed-composio.md +165 -0
- package/docs/guides/add-tool.md +10 -3
- package/docs/guides/channel-security.md +162 -32
- package/docs/guides/connect-discord.md +178 -0
- package/docs/guides/connect-slack.md +126 -0
- package/docs/guides/connect-telegram.md +61 -1
- package/docs/guides/connect-whatsapp-evolution.md +121 -0
- package/docs/guides/connect-whatsapp-uazapi.md +139 -0
- package/docs/guides/connect-whatsapp-zapster.md +119 -16
- package/docs/guides/create-agent.md +31 -4
- package/docs/guides/debug-channel.md +159 -0
- package/docs/guides/improve-from-production.md +151 -0
- package/docs/guides/prepare-deploy.md +32 -14
- package/docs/guides/replay-production-traces.md +72 -0
- package/docs/guides/run-evals.md +95 -25
- package/docs/guides/security-rules.md +9 -5
- package/docs/guides/send-feedback.md +135 -0
- package/docs/guides/use-jev.md +67 -0
- package/docs/guides/use-provider.md +70 -3
- package/docs/llms-full.txt +295 -25
- package/docs/llms.txt +54 -7
- package/package.json +3 -7
- package/src/cli/args.ts +23 -2
- package/src/cli/cloud-client.ts +121 -9
- package/src/cli/commands/channels.ts +856 -36
- package/src/cli/commands/feedback.ts +438 -0
- package/src/cli/commands/provider.ts +47 -0
- package/src/cli/commands/transcribe.ts +171 -0
- package/src/cli/deploy-chat-ui.ts +232 -18
- package/src/cli/deploy-readiness.ts +227 -14
- package/src/cli/help.ts +67 -9
- package/src/cli/index.ts +740 -35
- package/src/cli/new-command.ts +41 -0
- package/src/cloud/client.ts +4 -3
- package/src/cloud/contracts.ts +1 -1
- package/src/create-project.ts +18 -35
- package/src/index.ts +565 -11
- package/src/providers/codex-auth.ts +111 -0
- package/src/providers/pi.ts +88 -19
- package/src/providers/test.ts +36 -0
- package/src/providers/types.ts +8 -0
- package/src/runtime/channel-test-harness.ts +21 -1
- package/src/runtime/channels/discord.ts +896 -0
- package/src/runtime/channels/generic-webhook.ts +974 -0
- package/src/runtime/channels/slack.ts +646 -0
- package/src/runtime/channels/telegram.ts +343 -12
- package/src/runtime/channels/whatsapp-evolution.ts +1357 -0
- package/src/runtime/channels/whatsapp-meta.ts +9 -0
- package/src/runtime/channels/whatsapp-uazapi.ts +1323 -0
- package/src/runtime/channels/whatsapp-zapster.ts +674 -40
- package/src/runtime/channels.ts +83 -3
- package/src/runtime/chat.ts +70 -44
- package/src/runtime/config.ts +489 -20
- package/src/runtime/core/manifest.ts +75 -5
- package/src/runtime/core/targets.ts +5 -5
- package/src/runtime/deploy-readiness.ts +34 -4
- package/src/runtime/dev-server.ts +639 -39
- package/src/runtime/env.ts +8 -3
- package/src/runtime/evals.ts +445 -74
- package/src/runtime/improve.ts +868 -0
- package/src/runtime/inspect.ts +173 -4
- package/src/runtime/integrations/composio.ts +425 -0
- package/src/runtime/knowledge/retrieve.ts +25 -5
- package/src/runtime/knowledge/schema.ts +45 -1
- package/src/runtime/prompt-context.ts +141 -0
- package/src/runtime/runtime-contract.ts +71 -7
- package/src/runtime/skills.ts +95 -0
- package/src/runtime/targets/cloudflare/build.ts +1010 -208
- package/src/runtime/targets/container/server.ts +1 -1
- package/src/runtime/targets/vps/deploy.ts +26 -9
- package/src/runtime/tool-runner.ts +9 -1
- package/src/runtime/tools.ts +26 -2
- package/src/runtime/transcription.ts +483 -0
- package/src/storage/sqlite.ts +7 -2
- package/src/templates/blank.ts +37 -9
- package/src/templates/dentista.ts +40 -14
- package/src/templates/skills/agentkit-build-agent/SKILL.md +34 -5
- package/src/templates/skills/agentkit-build-agent/templates/appointment-intake.instructions.md +2 -1
- package/src/templates/skills/agentkit-capsule/SKILL.md +32 -3
- package/src/templates/skills/agentkit-capsule/references/docs-router.md +2 -2
- package/src/templates/skills/agentkit-channels/SKILL.md +66 -1
- package/src/templates/skills/agentkit-channels/references/channel-buffering.md +8 -1
- package/src/templates/skills/agentkit-channels/references/channel-debugging.md +28 -3
- package/src/templates/skills/agentkit-channels/references/discord.md +93 -0
- package/src/templates/skills/agentkit-channels/references/slack.md +56 -0
- package/src/templates/skills/agentkit-channels/references/telegram.md +34 -0
- package/src/templates/skills/agentkit-channels/references/whatsapp-evolution.md +57 -0
- package/src/templates/skills/agentkit-channels/references/whatsapp-uazapi.md +54 -0
- package/src/templates/skills/agentkit-channels/references/whatsapp-zapster.md +42 -8
- package/src/templates/skills/agentkit-database/SKILL.md +11 -0
- package/src/templates/skills/agentkit-deploy/SKILL.md +9 -1
- package/src/templates/skills/agentkit-evals/SKILL.md +77 -13
- package/src/templates/skills/agentkit-evals/templates/multi-turn.eval.md +13 -6
- package/src/templates/skills/agentkit-evals/templates/no-leak.eval.md +8 -4
- package/src/templates/skills/agentkit-evals/templates/smoke.eval.md +8 -4
- package/src/templates/skills/agentkit-evals/templates/tool-call.eval.md +16 -7
- package/src/templates/skills/agentkit-improve/SKILL.md +96 -0
- package/src/templates/skills/agentkit-improve/references/replay-side-effects.md +18 -0
- package/src/templates/skills/agentkit-improve/references/trace-packets.md +22 -0
- package/src/templates/skills/agentkit-improve/templates/regression.eval.md +18 -0
- package/src/templates/skills/agentkit-integrations/SKILL.md +98 -0
- package/src/templates/skills/agentkit-knowledge/SKILL.md +4 -1
- package/src/templates/skills/agentkit-prompts/SKILL.md +3 -1
- package/src/templates/skills/agentkit-provider/SKILL.md +29 -4
- package/src/templates/skills/agentkit-security/SKILL.md +5 -2
- package/src/templates/skills/agentkit-tools/SKILL.md +8 -1
- package/src/templates/skills/agentkit-tools/examples/eval-safe-external-action.tool.md +8 -8
- package/src/templates/skills/agentkit-tools/examples/jev-service-fit.tool.md +110 -0
- package/src/templates/skills/agentkit-troubleshooting/SKILL.md +25 -1
- package/src/templates/support.ts +42 -12
- package/docs/guides/agentkit-skills-architecture.md +0 -471
- package/docs/guides/channels-implementation-map.md +0 -243
- package/docs/guides/channels-production-handoff.md +0 -101
- package/docs/portable-deploy-release-checklist.md +0 -41
package/docs/llms.txt
CHANGED
|
@@ -8,27 +8,37 @@ Task guides:
|
|
|
8
8
|
|
|
9
9
|
- Create a capsule: `docs/guides/create-agent.md`
|
|
10
10
|
- Add a TypeScript tool: `docs/guides/add-tool.md`
|
|
11
|
+
- Use TypeSafe/Jev inside a capsule tool: `docs/guides/use-jev.md`
|
|
11
12
|
- Add Knowledge from local docs/CSVs: `docs/guides/add-knowledge.md`
|
|
12
13
|
- Run or prepare evals: `docs/guides/run-evals.md`
|
|
14
|
+
- Improve from production traces: `docs/guides/improve-from-production.md`
|
|
15
|
+
- Replay collected traces locally: `docs/guides/replay-production-traces.md`
|
|
16
|
+
- Send AgentKit product feedback safely: `docs/guides/send-feedback.md`
|
|
13
17
|
- Switch from `test/fake` to a real provider: `docs/guides/use-provider.md`
|
|
14
18
|
- Prepare for hosted deploy: `docs/guides/prepare-deploy.md`
|
|
15
19
|
- Build Cloudflare artifact: `agentkit build --target cloudflare`
|
|
16
20
|
- Build container artifact: `agentkit build --target container`
|
|
17
21
|
- Generate VPS handoff: `agentkit deploy --target vps --host agent.example.com --dry-run`
|
|
18
22
|
- Add hosted channels: `docs/guides/add-channel.md`
|
|
23
|
+
- Route replies across channels or add generic output webhooks: `docs/guides/add-channel.md#reply-through-another-channel`
|
|
24
|
+
- Add AgentKit-managed Composio: `docs/guides/add-managed-composio.md`
|
|
19
25
|
- Buffer rapid channel messages: `docs/guides/add-channel.md#buffer-bursty-messages`
|
|
26
|
+
- Connect Discord: `docs/guides/connect-discord.md`
|
|
27
|
+
- Connect Slack: `docs/guides/connect-slack.md`
|
|
20
28
|
- Connect Telegram: `docs/guides/connect-telegram.md`
|
|
29
|
+
- Connect WhatsApp through Evolution API: `docs/guides/connect-whatsapp-evolution.md`
|
|
30
|
+
- Connect WhatsApp through UAZAPI: `docs/guides/connect-whatsapp-uazapi.md`
|
|
21
31
|
- Connect WhatsApp through Zapster: `docs/guides/connect-whatsapp-zapster.md`
|
|
22
32
|
- Follow channel webhook and delivery-log safety rules: `docs/guides/channel-security.md`
|
|
23
|
-
-
|
|
33
|
+
- Debug channel delivery and cross-channel reply routing: `docs/guides/debug-channel.md`
|
|
24
34
|
- Follow secret, access, and tool safety rules: `docs/guides/security-rules.md`
|
|
25
|
-
- Plan repo-local skills for coding agents: `docs/guides/agentkit-skills-architecture.md`
|
|
26
35
|
|
|
27
36
|
Current local commands:
|
|
28
37
|
|
|
29
38
|
```sh
|
|
30
|
-
agentkit new
|
|
31
|
-
agentkit new
|
|
39
|
+
agentkit new [name] --template blank|support|dentista
|
|
40
|
+
agentkit new . --template blank
|
|
41
|
+
agentkit new [name] --template blank --no-install
|
|
32
42
|
agentkit docs full
|
|
33
43
|
agentkit env set <NAME> --stdin
|
|
34
44
|
agentkit env list
|
|
@@ -41,15 +51,37 @@ agentkit knowledge sync
|
|
|
41
51
|
agentkit knowledge inspect
|
|
42
52
|
agentkit knowledge search <query> [--top-k <number>]
|
|
43
53
|
agentkit eval run
|
|
54
|
+
agentkit improve collect --deploy --since 24h
|
|
55
|
+
agentkit improve evals .agentkit/improve/<run>
|
|
56
|
+
agentkit replay .agentkit/improve/<run> --against local
|
|
57
|
+
agentkit feedback create --about last-run --kind bug --summary "what failed"
|
|
58
|
+
agentkit feedback send .agentkit/feedback/<draft>.json
|
|
44
59
|
agentkit conversations list
|
|
45
60
|
agentkit conversations show <conversation-id>
|
|
61
|
+
agentkit conversations trace <conversation-id> [--deploy]
|
|
46
62
|
agentkit channels list
|
|
47
63
|
agentkit channels add telegram support-telegram
|
|
64
|
+
agentkit channels connect whatsapp main-whatsapp --provider evolution
|
|
65
|
+
agentkit channels connect whatsapp support-whatsapp --provider uazapi
|
|
66
|
+
agentkit channels connect discord support-discord
|
|
67
|
+
agentkit channels connect discord server-discord --mode bot
|
|
68
|
+
agentkit channels connect slack support-slack
|
|
69
|
+
agentkit channels connect webhook n8n-webhook
|
|
48
70
|
agentkit channels setup support-telegram
|
|
49
71
|
agentkit channels status support-telegram
|
|
50
72
|
agentkit channels test support-telegram --message "hello"
|
|
73
|
+
agentkit channels test-audio support-telegram --fixture voice-note
|
|
74
|
+
agentkit transcribe smoke --provider groq
|
|
51
75
|
agentkit channels deliveries list support-telegram
|
|
76
|
+
agentkit integrations status [--toolkit googlecalendar]
|
|
77
|
+
agentkit integrations connect composio --toolkit gmail
|
|
78
|
+
agentkit skills status
|
|
79
|
+
agentkit skills sync
|
|
80
|
+
agentkit billing checkout --slots 1 --email user@example.com
|
|
81
|
+
agentkit billing claim billint_... --secret bsec_...
|
|
52
82
|
agentkit login --token agk_user_...
|
|
83
|
+
agentkit account token create new-laptop --use
|
|
84
|
+
agentkit account token list
|
|
53
85
|
agentkit deploy doctor
|
|
54
86
|
agentkit deploy --smoke "hello"
|
|
55
87
|
agentkit deploy status
|
|
@@ -65,11 +97,21 @@ agentkit dev
|
|
|
65
97
|
agentkit open
|
|
66
98
|
```
|
|
67
99
|
|
|
68
|
-
|
|
100
|
+
On Windows PowerShell, if `npm.ps1` or `npx.ps1` is blocked with `PSSecurityException`, run capsule scripts through the `.cmd` shims, for example `npm.cmd run agentkit -- inspect`, `npm.cmd run agentkit -- knowledge sync`, or `npm.cmd run eval`.
|
|
101
|
+
|
|
102
|
+
Generated capsules include `AGENTKIT.md`, `AGENTS.md`, and a repo-local `skills/` pack so Codex, Claude Code, or another coding agent can treat the owner's natural-language request as the brief and start building immediately without loading the full contract by default. Start with `skills/agentkit-capsule/SKILL.md`, then load the task skill for the current work. `agentkit handoff codex "Develop an ophthalmology office intake agent"` is an optional prompt-printing shortcut for users who are not already inside a coding-agent workspace. There is no AgentKit CLI wizard in the normal flow: the coding agent edits the capsule directly from the scaffold and contract.
|
|
69
103
|
|
|
70
104
|
UI testing is part of the handoff. For local UI testing, run `agentkit dev`, open the printed `Chat:` URL, and tell the owner the exact URL. After hosted deploy, run `agentkit chat-ui --deploy`, open the printed `Chat:` URL, and tell the owner it is connected to the deploy.
|
|
71
105
|
|
|
72
|
-
|
|
106
|
+
Hosted Chat UI shows the current conversation id, tool calls, tool errors, and a new-conversation control. Use `agentkit conversations trace <conversation-id> --deploy` to pull the hosted trace from the last deploy.
|
|
107
|
+
|
|
108
|
+
`test/fake` is deterministic and validates scaffold, direct tool calls, and fake-provider evals. It does not validate natural conversation quality. Before claiming real conversation behavior has been tested, ask the owner which provider to use: OpenRouter, OpenAI, Anthropic, OpenCode Zen, OpenCode Go, or another supported provider. Do not choose for them.
|
|
109
|
+
|
|
110
|
+
For OpenRouter, prefer model ids or aliases known to the installed Pi SDK, such as `~google/gemini-flash-latest`. If an OpenRouter id is newer than Pi's registry, AgentKit passes the raw id through to OpenRouter with conservative unknown-model metadata; OpenRouter can still reject invalid, inaccessible, or unsupported models.
|
|
111
|
+
|
|
112
|
+
For OpenCode Zen, use `provider: { name: "opencode", model: "big-pickle" }`. For OpenCode Go, use `provider: { name: "opencode-go", model: "deepseek-v4-flash" }`. Both use `OPENCODE_API_KEY` in `secrets` and `.env.schema`.
|
|
113
|
+
|
|
114
|
+
AgentKit injects the current ISO timestamp, local date, weekday, local date/time, and timezone dynamically into every chat run. Set `timeZone` in `agentkit.config.ts` for scheduling agents so "today", "tomorrow", and weekdays resolve in the business/user timezone; otherwise AgentKit falls back to `AGENTKIT_TIME_ZONE`, valid `TZ`, then the runtime default. Do not hardcode today's date in prompts.
|
|
73
115
|
|
|
74
116
|
Current local endpoints from `agentkit dev`:
|
|
75
117
|
|
|
@@ -78,6 +120,11 @@ GET /_agentkit
|
|
|
78
120
|
POST /v1/chat
|
|
79
121
|
GET /v1/conversations
|
|
80
122
|
GET /v1/conversations/:id
|
|
123
|
+
GET /v1/conversations/:id/trace
|
|
124
|
+
POST /channels/<name>/<type>/<provider>/webhook
|
|
125
|
+
POST /channels/<name>/webhook
|
|
81
126
|
```
|
|
82
127
|
|
|
83
|
-
|
|
128
|
+
Only authenticated channel webhook routes may arrive through a public HTTPS tunnel. Other local endpoints remain loopback-only. UAZAPI and Zapster use user-generated AgentKit URL secrets in `?token=...`; the providers do not issue those values.
|
|
129
|
+
|
|
130
|
+
Local `.env` is for development only. Use `.env.schema` as the committed secret-name contract; local AgentKit commands load `.env` directly. Hosted deploys require an AgentKit Cloud account with `cloudflare_deploy_alpha` or purchased/manual deploy slots. Use `agentkit billing checkout` + `agentkit billing claim` for first-time paid access, or `agentkit login --token ...` when the user already has an `agk_user_...` token. Production uses managed secrets in the hosted contract.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andreprado/agentkit",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -18,9 +18,6 @@
|
|
|
18
18
|
"!src/**/*.test.ts",
|
|
19
19
|
"!src/runtime/fixtures",
|
|
20
20
|
"docs",
|
|
21
|
-
"!docs/guides/backend-contracts.md",
|
|
22
|
-
"!docs/guides/debug-channel.md",
|
|
23
|
-
"!docs/guides/deploy-agentkit-cloud-hostinger.md",
|
|
24
21
|
"README.md"
|
|
25
22
|
],
|
|
26
23
|
"publishConfig": {
|
|
@@ -34,10 +31,9 @@
|
|
|
34
31
|
},
|
|
35
32
|
"dependencies": {
|
|
36
33
|
"@earendil-works/pi-ai": "^0.75.5",
|
|
37
|
-
"@earendil-works/pi-coding-agent": "^0.75.5",
|
|
38
34
|
"@libsql/client": "^0.15.15",
|
|
39
|
-
"esbuild": "^0.28.
|
|
40
|
-
"tsx": "^4.
|
|
35
|
+
"esbuild": "^0.28.2",
|
|
36
|
+
"tsx": "^4.23.12",
|
|
41
37
|
"typebox": "^1.1.38"
|
|
42
38
|
},
|
|
43
39
|
"devDependencies": {
|
package/src/cli/args.ts
CHANGED
|
@@ -4,6 +4,15 @@ export type ParsedArgs = {
|
|
|
4
4
|
flags: Record<string, string | boolean>;
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
+
const dashPrefixedValueFlags = new Set([
|
|
8
|
+
"brief",
|
|
9
|
+
"input",
|
|
10
|
+
"input-json",
|
|
11
|
+
"message",
|
|
12
|
+
"prompt",
|
|
13
|
+
"smoke",
|
|
14
|
+
]);
|
|
15
|
+
|
|
7
16
|
export function parseArgs(argv: string[]): ParsedArgs {
|
|
8
17
|
const [command, ...rest] = argv;
|
|
9
18
|
const positional: string[] = [];
|
|
@@ -12,15 +21,27 @@ export function parseArgs(argv: string[]): ParsedArgs {
|
|
|
12
21
|
for (let index = 0; index < rest.length; index += 1) {
|
|
13
22
|
const value = rest[index];
|
|
14
23
|
|
|
24
|
+
if (value === "--") {
|
|
25
|
+
positional.push(...rest.slice(index + 1));
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
|
|
15
29
|
if (!value.startsWith("--")) {
|
|
16
30
|
positional.push(value);
|
|
17
31
|
continue;
|
|
18
32
|
}
|
|
19
33
|
|
|
20
|
-
const
|
|
34
|
+
const equalsIndex = value.indexOf("=");
|
|
35
|
+
const name = equalsIndex === -1 ? value.slice(2) : value.slice(2, equalsIndex);
|
|
36
|
+
|
|
37
|
+
if (equalsIndex !== -1) {
|
|
38
|
+
flags[name] = value.slice(equalsIndex + 1);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
|
|
21
42
|
const next = rest[index + 1];
|
|
22
43
|
|
|
23
|
-
if (next && !next.startsWith("--")) {
|
|
44
|
+
if (next && (dashPrefixedValueFlags.has(name) || !next.startsWith("--"))) {
|
|
24
45
|
flags[name] = next;
|
|
25
46
|
index += 1;
|
|
26
47
|
} else {
|
package/src/cli/cloud-client.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
1
|
+
import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
|
|
@@ -39,12 +39,37 @@ export type CloudLimitsResponse = {
|
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
+
export type CloudManagedComposioResponse = {
|
|
43
|
+
managed_composio?: {
|
|
44
|
+
entitlement?: "active" | "missing" | string;
|
|
45
|
+
api_key?: "set" | "missing" | string;
|
|
46
|
+
toolkits?: Array<{
|
|
47
|
+
toolkit?: string;
|
|
48
|
+
auth_config_env?: string;
|
|
49
|
+
auth_config?: "set" | "missing" | string;
|
|
50
|
+
auth_config_source?: "project" | "account" | "global" | "env" | string;
|
|
51
|
+
}>;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type CloudProjectResolveResponse = {
|
|
56
|
+
project?: {
|
|
57
|
+
id?: string;
|
|
58
|
+
name?: string;
|
|
59
|
+
owner_state?: "anonymous" | "claimed";
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
|
|
42
63
|
export type DeployAccessTokenCreateResponse = {
|
|
43
64
|
access_token?: {
|
|
44
65
|
id?: string;
|
|
45
66
|
deploy_id?: string;
|
|
67
|
+
account_id?: string;
|
|
46
68
|
name?: string;
|
|
47
69
|
token?: string;
|
|
70
|
+
created_at?: string;
|
|
71
|
+
expires_at?: string;
|
|
72
|
+
last_used_at?: string;
|
|
48
73
|
};
|
|
49
74
|
};
|
|
50
75
|
|
|
@@ -52,10 +77,76 @@ export type DeployAccessTokenListResponse = {
|
|
|
52
77
|
access_tokens?: Array<{
|
|
53
78
|
id?: string;
|
|
54
79
|
deploy_id?: string;
|
|
80
|
+
account_id?: string;
|
|
55
81
|
name?: string;
|
|
82
|
+
created_at?: string;
|
|
83
|
+
expires_at?: string;
|
|
84
|
+
last_used_at?: string;
|
|
56
85
|
}>;
|
|
57
86
|
};
|
|
58
87
|
|
|
88
|
+
export type AccountApiTokenCreateResponse = {
|
|
89
|
+
token?: {
|
|
90
|
+
id?: string;
|
|
91
|
+
account_id?: string;
|
|
92
|
+
name?: string;
|
|
93
|
+
token?: string;
|
|
94
|
+
created_at?: string;
|
|
95
|
+
expires_at?: string;
|
|
96
|
+
last_used_at?: string;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export type AccountApiTokenListResponse = {
|
|
101
|
+
tokens?: Array<{
|
|
102
|
+
id?: string;
|
|
103
|
+
account_id?: string;
|
|
104
|
+
name?: string;
|
|
105
|
+
created_at?: string;
|
|
106
|
+
expires_at?: string;
|
|
107
|
+
last_used_at?: string;
|
|
108
|
+
revoked_at?: string;
|
|
109
|
+
}>;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export type BillingCheckoutResponse = {
|
|
113
|
+
checkout?: {
|
|
114
|
+
id?: string;
|
|
115
|
+
url?: string;
|
|
116
|
+
};
|
|
117
|
+
billing_intent?: {
|
|
118
|
+
id?: string;
|
|
119
|
+
account_id?: string;
|
|
120
|
+
email?: string;
|
|
121
|
+
requested_slots?: number;
|
|
122
|
+
status?: string;
|
|
123
|
+
secret?: string;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export type BillingCheckoutIntentResponse = {
|
|
128
|
+
billing_intent?: {
|
|
129
|
+
id?: string;
|
|
130
|
+
account_id?: string;
|
|
131
|
+
email?: string;
|
|
132
|
+
requested_slots?: number;
|
|
133
|
+
status?: string;
|
|
134
|
+
checkout_session_id?: string;
|
|
135
|
+
stripe_customer_id?: string;
|
|
136
|
+
stripe_subscription_id?: string;
|
|
137
|
+
completed_at?: string;
|
|
138
|
+
token_claimed_at?: string;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export type BillingClaimResponse = BillingCheckoutIntentResponse & AccountApiTokenCreateResponse;
|
|
143
|
+
|
|
144
|
+
export type BillingPortalResponse = {
|
|
145
|
+
portal?: {
|
|
146
|
+
url?: string;
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
|
|
59
150
|
export type CloudSecretsResponse = {
|
|
60
151
|
secrets?: Array<{
|
|
61
152
|
name?: string;
|
|
@@ -64,6 +155,18 @@ export type CloudSecretsResponse = {
|
|
|
64
155
|
}>;
|
|
65
156
|
};
|
|
66
157
|
|
|
158
|
+
export type FeedbackSendResponse = {
|
|
159
|
+
feedback?: {
|
|
160
|
+
id?: string;
|
|
161
|
+
account_id?: string;
|
|
162
|
+
kind?: string;
|
|
163
|
+
summary?: string;
|
|
164
|
+
status?: string;
|
|
165
|
+
client_report_id?: string;
|
|
166
|
+
created_at?: string;
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
|
|
67
170
|
export function cloudAuthPath(): string {
|
|
68
171
|
return join(homedir(), ".agentkit", "cloud.json");
|
|
69
172
|
}
|
|
@@ -94,9 +197,20 @@ export async function readCloudAuth(): Promise<CloudAuthConfig | null> {
|
|
|
94
197
|
return null;
|
|
95
198
|
}
|
|
96
199
|
|
|
200
|
+
export async function readCloudAuthForApiUrl(apiUrl: string): Promise<CloudAuthConfig | null> {
|
|
201
|
+
const auth = await readCloudAuth();
|
|
202
|
+
|
|
203
|
+
if (auth?.source === "file" && !cloudAuthMatchesApiUrl(auth, apiUrl)) {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return auth;
|
|
208
|
+
}
|
|
209
|
+
|
|
97
210
|
export async function writeCloudAuth(config: CloudAuthConfig): Promise<void> {
|
|
98
211
|
await mkdir(join(homedir(), ".agentkit"), { recursive: true });
|
|
99
212
|
await writeFile(cloudAuthPath(), `${JSON.stringify(config, null, 2)}\n`, { mode: 0o600 });
|
|
213
|
+
await chmod(cloudAuthPath(), 0o600);
|
|
100
214
|
}
|
|
101
215
|
|
|
102
216
|
export async function clearCloudAuth(): Promise<void> {
|
|
@@ -155,11 +269,8 @@ export async function cloudPost<T>(apiUrl: string, path: string, body: unknown):
|
|
|
155
269
|
|
|
156
270
|
export async function cloudFetch(apiUrl: string, path: string, init: RequestInit = {}): Promise<Response> {
|
|
157
271
|
const headers = new Headers(init.headers);
|
|
158
|
-
const auth = await
|
|
159
|
-
const apiToken =
|
|
160
|
-
auth?.source === "file" && !cloudAuthMatchesApiUrl(auth, apiUrl)
|
|
161
|
-
? undefined
|
|
162
|
-
: auth?.token;
|
|
272
|
+
const auth = await readCloudAuthForApiUrl(apiUrl);
|
|
273
|
+
const apiToken = auth?.token;
|
|
163
274
|
|
|
164
275
|
if (apiToken && !headers.has("Authorization")) {
|
|
165
276
|
headers.set("Authorization", `Bearer ${apiToken}`);
|
|
@@ -176,15 +287,16 @@ function cloudAuthMatchesApiUrl(auth: CloudAuthConfig, apiUrl: string): boolean
|
|
|
176
287
|
}
|
|
177
288
|
|
|
178
289
|
export async function cloudApiRequest(apiUrl: string, path: string, init: RequestInit): Promise<unknown> {
|
|
179
|
-
const auth = await
|
|
290
|
+
const auth = await readCloudAuthForApiUrl(apiUrl);
|
|
180
291
|
const headers = new Headers(init.headers);
|
|
292
|
+
const apiToken = auth?.token;
|
|
181
293
|
|
|
182
294
|
if (!headers.has("Content-Type") && init.body !== undefined) {
|
|
183
295
|
headers.set("Content-Type", "application/json");
|
|
184
296
|
}
|
|
185
297
|
|
|
186
|
-
if (
|
|
187
|
-
headers.set("Authorization", `Bearer ${
|
|
298
|
+
if (apiToken && !headers.has("Authorization")) {
|
|
299
|
+
headers.set("Authorization", `Bearer ${apiToken}`);
|
|
188
300
|
}
|
|
189
301
|
|
|
190
302
|
const response = await fetch(new URL(path, parseCloudApiUrl(apiUrl)).href, {
|