@fastagent-sh/fastagent 0.14.0 → 0.16.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 +16 -6
- package/dist/agent.d.ts +20 -0
- package/dist/agent.js +9 -0
- package/dist/channels/agentcore-limits.d.ts +7 -0
- package/dist/channels/agentcore-limits.js +9 -0
- package/dist/channels/agentcore-state.d.ts +83 -0
- package/dist/channels/agentcore-state.js +258 -0
- package/dist/channels/agentcore.d.ts +98 -0
- package/dist/channels/agentcore.js +260 -0
- package/dist/channels/busy.d.ts +23 -0
- package/dist/channels/busy.js +53 -0
- package/dist/channels/context-buffer.d.ts +35 -0
- package/dist/channels/context-buffer.js +103 -0
- package/dist/channels/control.d.ts +28 -0
- package/dist/channels/control.js +214 -0
- package/dist/channels/feishu/card.js +1 -1
- package/dist/channels/feishu/context-buffer.d.ts +15 -13
- package/dist/channels/feishu/context-buffer.js +62 -69
- package/dist/channels/feishu/feishu-api.d.ts +11 -3
- package/dist/channels/feishu/feishu-api.js +24 -3
- package/dist/channels/feishu/feishu.d.ts +27 -27
- package/dist/channels/feishu/feishu.js +318 -207
- package/dist/channels/feishu/invoke-turn.d.ts +7 -20
- package/dist/channels/feishu/invoke-turn.js +44 -79
- package/dist/channels/feishu/model.d.ts +2 -2
- package/dist/channels/feishu/normalize.d.ts +2 -1
- package/dist/channels/feishu/normalize.js +0 -1
- package/dist/channels/feishu/parse.d.ts +22 -8
- package/dist/channels/feishu/parse.js +24 -7
- package/dist/channels/feishu/preview.d.ts +4 -7
- package/dist/channels/feishu/preview.js +27 -142
- package/dist/channels/feishu/register-app.d.ts +2 -1
- package/dist/channels/feishu/register-webhook.d.ts +2 -1
- package/dist/channels/feishu/scaffold/channel.ts +9 -8
- package/dist/channels/feishu/scaffold/feishu-send.ts +6 -4
- package/dist/channels/feishu/setup-mode.d.ts +37 -0
- package/dist/channels/feishu/setup-mode.js +28 -0
- package/dist/channels/feishu/ws-ingress.d.ts +28 -0
- package/dist/channels/feishu/ws-ingress.js +136 -0
- package/dist/channels/github/github.js +16 -7
- package/dist/channels/http.d.ts +14 -0
- package/dist/channels/http.js +36 -3
- package/dist/channels/invoke-turn-kit.d.ts +65 -0
- package/dist/channels/invoke-turn-kit.js +87 -0
- package/dist/channels/lark/lark.d.ts +4 -2
- package/dist/channels/lark/lark.js +4 -1
- package/dist/channels/lark/onboard.d.ts +8 -4
- package/dist/channels/lark/onboard.js +8 -0
- package/dist/channels/lark/scaffold/channel.ts +9 -8
- package/dist/channels/lark/scaffold/lark-send.ts +6 -4
- package/dist/channels/preview-kit.d.ts +115 -0
- package/dist/channels/preview-kit.js +184 -0
- package/dist/channels/seen.d.ts +5 -0
- package/dist/channels/seen.js +35 -0
- package/dist/channels/slack/bot-auth.d.ts +15 -0
- package/dist/channels/slack/bot-auth.js +146 -0
- package/dist/channels/slack/config-api.d.ts +60 -0
- package/dist/channels/slack/config-api.js +149 -0
- package/dist/channels/slack/context-buffer.d.ts +24 -0
- package/dist/channels/slack/context-buffer.js +37 -0
- package/dist/channels/slack/invoke-turn.d.ts +19 -0
- package/dist/channels/slack/invoke-turn.js +63 -0
- package/dist/channels/slack/manifest.d.ts +49 -0
- package/dist/channels/slack/manifest.js +69 -0
- package/dist/channels/slack/model.d.ts +67 -0
- package/dist/channels/slack/model.js +2 -0
- package/dist/channels/slack/onboard.d.ts +41 -0
- package/dist/channels/slack/onboard.js +120 -0
- package/dist/channels/slack/onboarding-state.d.ts +31 -0
- package/dist/channels/slack/onboarding-state.js +69 -0
- package/dist/channels/slack/parse.d.ts +38 -0
- package/dist/channels/slack/parse.js +124 -0
- package/dist/channels/slack/preview.d.ts +23 -0
- package/dist/channels/slack/preview.js +403 -0
- package/dist/channels/slack/reaction.d.ts +24 -0
- package/dist/channels/slack/reaction.js +62 -0
- package/dist/channels/slack/register-webhook.d.ts +10 -0
- package/dist/channels/slack/register-webhook.js +49 -0
- package/dist/channels/slack/scaffold/channel.ts +33 -0
- package/dist/channels/slack/scaffold/slack-send.ts +171 -0
- package/dist/channels/slack/setup-server.d.ts +17 -0
- package/dist/channels/slack/setup-server.js +103 -0
- package/dist/channels/slack/slack-api.d.ts +57 -0
- package/dist/channels/slack/slack-api.js +399 -0
- package/dist/channels/slack/slack.d.ts +51 -0
- package/dist/channels/slack/slack.js +496 -0
- package/dist/channels/slack/welcomed.d.ts +5 -0
- package/dist/channels/slack/welcomed.js +32 -0
- package/dist/channels/state.d.ts +11 -4
- package/dist/channels/state.js +22 -15
- package/dist/channels/stop-command.d.ts +6 -0
- package/dist/channels/stop-command.js +36 -0
- package/dist/channels/tasks.d.ts +7 -0
- package/dist/channels/tasks.js +25 -0
- package/dist/channels/telegram/context-buffer.d.ts +8 -17
- package/dist/channels/telegram/context-buffer.js +6 -85
- package/dist/channels/telegram/invoke-turn.d.ts +5 -22
- package/dist/channels/telegram/invoke-turn.js +11 -58
- package/dist/channels/telegram/parse.d.ts +0 -7
- package/dist/channels/telegram/parse.js +4 -2
- package/dist/channels/telegram/preview.d.ts +4 -7
- package/dist/channels/telegram/preview.js +24 -142
- package/dist/channels/telegram/scaffold/telegram-send.ts +6 -3
- package/dist/channels/telegram/telegram.js +24 -10
- package/dist/channels/{feishu/text.d.ts → text.d.ts} +15 -1
- package/dist/channels/{feishu/text.js → text.js} +15 -1
- package/dist/channels/thread-participants.d.ts +21 -0
- package/dist/channels/thread-participants.js +132 -0
- package/dist/channels/turn-queue.js +8 -1
- package/dist/channels/turn-store.d.ts +1 -1
- package/dist/channels/turn-store.js +2 -3
- package/dist/cli/add-feishu.d.ts +30 -0
- package/dist/cli/add-feishu.js +366 -0
- package/dist/cli/add-slack.d.ts +11 -0
- package/dist/cli/add-slack.js +199 -0
- package/dist/{cli-auth.d.ts → cli/auth-view.d.ts} +1 -1
- package/dist/{cli-auth.js → cli/auth-view.js} +1 -1
- package/dist/cli/commands/add.d.ts +4 -0
- package/dist/cli/commands/add.js +191 -60
- package/dist/cli/commands/attach.d.ts +82 -0
- package/dist/cli/commands/attach.js +563 -0
- package/dist/cli/commands/chat.d.ts +1 -0
- package/dist/cli/commands/chat.js +12 -7
- package/dist/cli/commands/deploy.d.ts +3 -1
- package/dist/cli/commands/deploy.js +384 -82
- package/dist/cli/commands/dev.js +34 -26
- package/dist/cli/commands/fire.js +17 -18
- package/dist/cli/commands/info.js +36 -29
- package/dist/cli/commands/init.d.ts +1 -1
- package/dist/cli/commands/init.js +65 -53
- package/dist/cli/commands/invoke.js +11 -9
- package/dist/cli/commands/login.js +48 -45
- package/dist/cli/commands/models.js +1 -1
- package/dist/cli/commands/schedule.js +6 -8
- package/dist/cli/commands/start.js +102 -39
- package/dist/cli/commands/tool.js +23 -18
- package/dist/cli/fail.d.ts +17 -2
- package/dist/cli/fail.js +25 -1
- package/dist/{invoke-stream.d.ts → cli/invoke-stream.d.ts} +1 -1
- package/dist/{invoke-stream.js → cli/invoke-stream.js} +4 -0
- package/dist/cli/kernel.d.ts +3 -2
- package/dist/cli/models-view.d.ts +21 -0
- package/dist/cli/models-view.js +66 -0
- package/dist/cli/program.js +135 -56
- package/dist/cli/serve.d.ts +60 -20
- package/dist/cli/serve.js +252 -47
- package/dist/cli/shared.d.ts +40 -7
- package/dist/cli/shared.js +180 -38
- package/dist/collect.d.ts +14 -3
- package/dist/collect.js +24 -0
- package/dist/core.d.ts +3 -1
- package/dist/core.js +2 -0
- package/dist/deploy/agentcore/plan.d.ts +117 -0
- package/dist/deploy/agentcore/plan.js +721 -0
- package/dist/deploy/agentcore/run.d.ts +73 -0
- package/dist/deploy/agentcore/run.js +412 -0
- package/dist/deploy/agentcore/zip.d.ts +17 -0
- package/dist/deploy/agentcore/zip.js +68 -0
- package/dist/deploy/container.d.ts +26 -25
- package/dist/deploy/container.js +93 -89
- package/dist/deploy/docker/plan.d.ts +3 -3
- package/dist/deploy/docker/plan.js +20 -23
- package/dist/deploy/fly/plan.d.ts +5 -1
- package/dist/deploy/fly/plan.js +39 -26
- package/dist/deploy/fly/run.d.ts +17 -5
- package/dist/deploy/fly/run.js +52 -7
- package/dist/deploy/preflight.d.ts +20 -8
- package/dist/deploy/preflight.js +267 -71
- package/dist/deploy/railway/plan.d.ts +10 -1
- package/dist/deploy/railway/plan.js +53 -20
- package/dist/deploy/railway/run.d.ts +13 -5
- package/dist/deploy/railway/run.js +22 -7
- package/dist/deploy/runner.d.ts +7 -3
- package/dist/deploy/runner.js +9 -3
- package/dist/deploy/secrets.d.ts +2 -1
- package/dist/deploy/secrets.js +23 -3
- package/dist/dev-supervisor.d.ts +11 -10
- package/dist/dev-supervisor.js +56 -50
- package/dist/engines/pi/auth.d.ts +8 -7
- package/dist/engines/pi/auth.js +12 -10
- package/dist/engines/pi/channel.d.ts +22 -16
- package/dist/engines/pi/channel.js +92 -62
- package/dist/engines/pi/chat.d.ts +4 -16
- package/dist/engines/pi/chat.js +8 -261
- package/dist/engines/pi/config.d.ts +20 -55
- package/dist/engines/pi/config.js +49 -121
- package/dist/engines/pi/create.d.ts +30 -10
- package/dist/engines/pi/create.js +33 -26
- package/dist/engines/pi/definition.d.ts +7 -26
- package/dist/engines/pi/definition.js +8 -54
- package/dist/engines/pi/harness.d.ts +49 -0
- package/dist/engines/pi/harness.js +90 -2
- package/dist/engines/pi/invoke.d.ts +55 -2
- package/dist/engines/pi/invoke.js +304 -19
- package/dist/engines/pi/login.d.ts +12 -1
- package/dist/engines/pi/login.js +16 -4
- package/dist/engines/pi/models.d.ts +59 -13
- package/dist/engines/pi/models.js +62 -24
- package/dist/engines/pi/open.d.ts +114 -0
- package/dist/engines/pi/open.js +127 -0
- package/dist/engines/pi/session-builder.d.ts +16 -0
- package/dist/engines/pi/session-builder.js +308 -0
- package/dist/engines/pi/session-control.d.ts +50 -0
- package/dist/engines/pi/session-control.js +604 -0
- package/dist/engines/pi/sessions.d.ts +17 -2
- package/dist/engines/pi/sessions.js +9 -0
- package/dist/engines/pi/tool-context.d.ts +18 -11
- package/dist/engines/pi/tool-context.js +3 -9
- package/dist/engines/pi/tool.d.ts +6 -8
- package/dist/engines/pi/tool.js +10 -1
- package/dist/engines/pi/wake-tool.d.ts +0 -3
- package/dist/engines/pi/wake-tool.js +9 -7
- package/dist/env.d.ts +16 -4
- package/dist/env.js +43 -5
- package/dist/feishu.d.ts +1 -1
- package/dist/feishu.js +1 -1
- package/dist/host/node.d.ts +25 -8
- package/dist/host/node.js +5 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lark.d.ts +1 -1
- package/dist/lark.js +1 -1
- package/dist/loader.d.ts +2 -2
- package/dist/loader.js +3 -3
- package/dist/log.d.ts +1 -1
- package/dist/log.js +1 -1
- package/dist/observe.js +3 -0
- package/dist/paths.d.ts +138 -0
- package/dist/paths.js +326 -0
- package/dist/pi.d.ts +6 -5
- package/dist/pi.js +4 -3
- package/dist/runtime.d.ts +7 -5
- package/dist/runtime.js +2 -2
- package/dist/scaffold/add-channel.d.ts +26 -9
- package/dist/scaffold/add-channel.js +175 -40
- package/dist/scaffold/init.d.ts +32 -41
- package/dist/scaffold/init.js +161 -185
- package/dist/scaffold/templates/env.example +15 -6
- package/dist/scaffold/templates/fastagent.config.mjs +5 -4
- package/dist/scaffold/templates/gitignore +14 -6
- package/dist/scaffold/templates/persona.md +4 -2
- package/dist/scaffold/templates/secrets.gitignore +5 -0
- package/dist/scaffold/templates.d.ts +1 -7
- package/dist/scaffold/templates.js +3 -25
- package/dist/scaffold/vendor-skill.d.ts +2 -2
- package/dist/scaffold/vendor-skill.js +13 -13
- package/dist/schedule/discover.js +4 -4
- package/dist/schedule/scheduler.d.ts +40 -1
- package/dist/schedule/scheduler.js +89 -56
- package/dist/schedule/state.js +1 -1
- package/dist/schedule/wake-alarm.d.ts +47 -0
- package/dist/schedule/wake-alarm.js +136 -0
- package/dist/schedule/wakeups.d.ts +1 -3
- package/dist/schedule/wakeups.js +19 -1
- package/dist/session-remote.d.ts +53 -0
- package/dist/session-remote.js +336 -0
- package/dist/session.d.ts +265 -0
- package/dist/session.js +37 -0
- package/dist/slack.d.ts +2 -0
- package/dist/slack.js +2 -0
- package/dist/tunnel.d.ts +7 -4
- package/dist/tunnel.js +23 -12
- package/package.json +22 -7
- package/dist/channels/feishu/owned-threads.d.ts +0 -11
- package/dist/channels/feishu/owned-threads.js +0 -47
- package/dist/channels/feishu/seen.d.ts +0 -5
- package/dist/channels/feishu/seen.js +0 -47
- package/dist/cli-add-feishu.d.ts +0 -8
- package/dist/cli-add-feishu.js +0 -223
- package/dist/cli-models.d.ts +0 -11
- package/dist/cli-models.js +0 -20
- package/dist/engines/pi/workspace.d.ts +0 -56
- package/dist/engines/pi/workspace.js +0 -72
- package/dist/scaffold/templates/gitignore.agentdir-root +0 -5
- package/dist/scaffold/templates/gitignore.kit +0 -2
- package/dist/workspace.d.ts +0 -9
- package/dist/workspace.js +0 -45
package/dist/cli/program.js
CHANGED
|
@@ -8,14 +8,18 @@ import { fastagentVersion } from "../version.js";
|
|
|
8
8
|
import { buildProgram } from "./kernel.js";
|
|
9
9
|
// Help groups (clig: most common commands first) — the authoring loop leads, operations close.
|
|
10
10
|
// Shared flags — same name, same meaning, on every command that supports them (clig: consistency).
|
|
11
|
-
const DIR_ARG = {
|
|
11
|
+
const DIR_ARG = {
|
|
12
|
+
name: "[dir]",
|
|
13
|
+
description: "workspace directory (the agent is here, or in a directory inside it)",
|
|
14
|
+
default: ".",
|
|
15
|
+
};
|
|
12
16
|
const MODEL = {
|
|
13
17
|
flags: "--model <provider/modelId>",
|
|
14
18
|
description: "model override (precedence: --model > FASTAGENT_MODEL > config)",
|
|
15
19
|
};
|
|
16
20
|
const AUTH_PATH = {
|
|
17
21
|
flags: "--auth-path <file>",
|
|
18
|
-
description: "credentials file (default: <
|
|
22
|
+
description: "credentials file (default: <agent dir>/.secrets/auth.json; env: FASTAGENT_AUTH_PATH)",
|
|
19
23
|
};
|
|
20
24
|
const JSON_FLAG = { flags: "--json", description: "machine-readable JSON output" };
|
|
21
25
|
const NO_INPUT = {
|
|
@@ -26,37 +30,49 @@ const PORT = { flags: "--port <n>", description: "HTTP port" };
|
|
|
26
30
|
const TUNNEL = {
|
|
27
31
|
flags: "--tunnel",
|
|
28
32
|
description: "expose a public HTTPS URL via a Cloudflare quick tunnel (needs cloudflared) and auto-register " +
|
|
29
|
-
"webhook channels (telegram, feishu, lark; github
|
|
33
|
+
"webhook channels (telegram, onboarded slack, feishu, lark; github/manual slack print the URL) — for hosting a bot from your " +
|
|
30
34
|
"own box without deploying (the quick-tunnel URL is ephemeral, not for production)",
|
|
31
35
|
};
|
|
32
36
|
const init = {
|
|
33
37
|
name: "init",
|
|
34
38
|
summary: "scaffold a runnable agent and install its dependencies",
|
|
35
|
-
description: "Scaffold a runnable agent
|
|
36
|
-
"agent
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
+
description: "Scaffold a runnable agent and run npm install. By default the agent goes into ./fastagent/ in dir " +
|
|
40
|
+
"(default .; --agent-dir names it otherwise) — the rest of the directory gets zero writes, and it is " +
|
|
41
|
+
"the WORKSPACE the agent works ON when you point fastagent there. Default content is a " +
|
|
42
|
+
"self-iterating agent: persona.md (its identity), a writing-great-skills " +
|
|
43
|
+
"example skill, a fetch-url code tool, config, package.json, .gitignore. An existing AGENTS.md is " +
|
|
44
|
+
"kept as project context.",
|
|
39
45
|
args: [DIR_ARG],
|
|
40
46
|
flags: [
|
|
41
47
|
{ flags: "--minimal", description: "persona.md + the example skill + config only (no code tool / package.json)" },
|
|
42
48
|
{ flags: "--no-install", description: "scaffold everything but skip npm install" },
|
|
43
|
-
{ flags: "--
|
|
44
|
-
{
|
|
49
|
+
{ flags: "--agent-dir <name>", description: "name the agent directory (default fastagent; . = dir itself)" },
|
|
50
|
+
{
|
|
51
|
+
flags: "--flat",
|
|
52
|
+
description: "alias for --agent-dir . — the directory IS the agent; keeps existing files",
|
|
53
|
+
// Two spellings of ONE knob: `--flat --agent-dir bot` names the same thing twice with different
|
|
54
|
+
// values, which is a usage error, not a precedence question to settle silently.
|
|
55
|
+
conflicts: ["agentDir"],
|
|
56
|
+
},
|
|
45
57
|
],
|
|
46
58
|
examples: [
|
|
47
|
-
{ cmd: "fastagent init
|
|
48
|
-
{ cmd: "fastagent init", note: "
|
|
59
|
+
{ cmd: "fastagent init", note: "the agent lands in ./fastagent/" },
|
|
60
|
+
{ cmd: "fastagent init my-project", note: "my-project/fastagent/ (created)" },
|
|
61
|
+
{ cmd: "fastagent init . --agent-dir bot", note: "./bot/ — any name works" },
|
|
62
|
+
{ cmd: "fastagent init . --flat", note: "this repo IS the agent" },
|
|
49
63
|
],
|
|
50
|
-
notes:
|
|
51
|
-
"the
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
64
|
+
notes: "An agent is a directory holding a fastagent.config.* — never its NAME, so --agent-dir can call it " +
|
|
65
|
+
"anything (the name decides only which agent answers when a workspace holds several: see " +
|
|
66
|
+
"FASTAGENT_AGENT). What the agent works ON (its cwd, where its AGENTS.md context is read from) is " +
|
|
67
|
+
"whatever directory you later point fastagent at: point at the project and the agent inside it " +
|
|
68
|
+
"serves with the project as its workspace; point at the agent directory (all a deployed box may " +
|
|
69
|
+
"hold) and it works on itself. A directory resolves to ONE agent, at it or one level inside.",
|
|
55
70
|
run: async (args, f) => (await import("./commands/init.js")).runInit(args[0], {
|
|
56
71
|
minimal: f.minimal === true,
|
|
57
72
|
install: f.install !== false,
|
|
58
|
-
|
|
59
|
-
|
|
73
|
+
// `--flat` is the spelling for the common case of the same knob (they conflict, so only one is
|
|
74
|
+
// ever set); both land in ONE value, so the scaffolder never sees two ways to say ".".
|
|
75
|
+
agentDir: f.flat === true ? "." : typeof f.agentDir === "string" ? f.agentDir : undefined,
|
|
60
76
|
}),
|
|
61
77
|
};
|
|
62
78
|
const dev = {
|
|
@@ -64,8 +80,8 @@ const dev = {
|
|
|
64
80
|
summary: "serve the agent locally, restarting on code edits",
|
|
65
81
|
description: "Assemble the agent in dir (default .) and serve a local HTTP channel. persona.md/AGENTS.md/skills " +
|
|
66
82
|
"are re-read every turn (edits go live next turn); edits to code inputs — tools/, channels/, " +
|
|
67
|
-
"fastagent.config.*, package.json, .env — restart the worker. Files the agent writes as
|
|
68
|
-
"product never trigger a restart.",
|
|
83
|
+
"fastagent.config.*, package.json, .secrets/.env — restart the worker. Files the agent writes as " +
|
|
84
|
+
"work product never trigger a restart.",
|
|
69
85
|
args: [DIR_ARG],
|
|
70
86
|
flags: [
|
|
71
87
|
PORT,
|
|
@@ -77,7 +93,7 @@ const dev = {
|
|
|
77
93
|
],
|
|
78
94
|
examples: [
|
|
79
95
|
{ cmd: "fastagent dev" },
|
|
80
|
-
{ cmd: "fastagent dev --tunnel", note: "public URL +
|
|
96
|
+
{ cmd: "fastagent dev --tunnel", note: "public URL + registered/guided webhooks" },
|
|
81
97
|
],
|
|
82
98
|
run: async (args, f) => (await import("./commands/dev.js")).runDev(args[0], {
|
|
83
99
|
port: f.port,
|
|
@@ -88,16 +104,38 @@ const dev = {
|
|
|
88
104
|
input: f.input !== false,
|
|
89
105
|
}),
|
|
90
106
|
};
|
|
107
|
+
const attach = {
|
|
108
|
+
name: "attach",
|
|
109
|
+
summary: "watch a session's live events from a running serve and steer it",
|
|
110
|
+
description: "Attach to a session served by a running dev/start with `sessionControl: true` in the config: " +
|
|
111
|
+
"stream its live events (text, tools, run boundaries), steer the active run by typing — or, with " +
|
|
112
|
+
"no run active, start one (detaching cancels a run YOU started) — /abort to stop a run. Discovers " +
|
|
113
|
+
"the local endpoint from <stateRoot>/control.json; --url/--token reach a remote serve. The same " +
|
|
114
|
+
"wire protocol a Web panel or desktop app uses.",
|
|
115
|
+
args: [{ name: "<session>", description: "the session id to attach to" }, DIR_ARG],
|
|
116
|
+
flags: [
|
|
117
|
+
{ flags: "--url <url>", description: "control endpoint (skip control.json discovery)" },
|
|
118
|
+
{ flags: "--token <token>", description: "bearer token for --url" },
|
|
119
|
+
],
|
|
120
|
+
examples: [{ cmd: "fastagent attach tg-chat-42" }],
|
|
121
|
+
run: async (args, f) => (await import("./commands/attach.js")).runAttach(args[0], args[1], {
|
|
122
|
+
url: f.url,
|
|
123
|
+
token: f.token,
|
|
124
|
+
}),
|
|
125
|
+
};
|
|
91
126
|
const chat = {
|
|
92
127
|
name: "chat",
|
|
93
128
|
summary: "open the SAME assembled agent in pi's interactive TUI",
|
|
94
129
|
description: "Open the SAME assembled agent in pi's interactive TUI (the real harness, not a crude REPL) — to " +
|
|
95
|
-
"try it locally before serving. Same model/tool/skill resolution as dev; pi handles
|
|
96
|
-
"sessions, and /resume natively.",
|
|
130
|
+
"try it locally before serving. Same model/tool/skill/auth resolution as dev; pi handles " +
|
|
131
|
+
"rendering, sessions, and /resume natively (its /login writes to the same fastagent auth file).",
|
|
97
132
|
args: [DIR_ARG],
|
|
98
|
-
flags: [MODEL],
|
|
133
|
+
flags: [MODEL, AUTH_PATH],
|
|
99
134
|
examples: [{ cmd: "fastagent chat" }],
|
|
100
|
-
run: async (args, f) => (await import("./commands/chat.js")).runChat(args[0], {
|
|
135
|
+
run: async (args, f) => (await import("./commands/chat.js")).runChat(args[0], {
|
|
136
|
+
model: f.model,
|
|
137
|
+
authPath: f.authPath,
|
|
138
|
+
}),
|
|
101
139
|
};
|
|
102
140
|
const info = {
|
|
103
141
|
name: "info",
|
|
@@ -192,14 +230,14 @@ const start = {
|
|
|
192
230
|
],
|
|
193
231
|
notes: "Precedence chains:\n" +
|
|
194
232
|
" port: --port > PORT env > fastagent.config.ts http.port > 8787\n" +
|
|
195
|
-
" state: FASTAGENT_STATE_DIR > <dir>/.
|
|
196
|
-
"
|
|
197
|
-
"
|
|
198
|
-
"
|
|
233
|
+
" state: FASTAGENT_STATE_DIR > <agent dir>/.state — mutable machine state\n" +
|
|
234
|
+
" (sessions, channel state, schedule state); point it at a mounted\n" +
|
|
235
|
+
" volume so a redeploy that replaces the directory never wipes it\n" +
|
|
236
|
+
" secrets: FASTAGENT_SECRETS_DIR > <agent dir>/.secrets — .env + auth.json\n" +
|
|
199
237
|
" sessions: --sessions-dir > FASTAGENT_SESSIONS_DIR > <state>/sessions\n" +
|
|
200
|
-
" auth: --auth-path > FASTAGENT_AUTH_PATH > <
|
|
201
|
-
" (project-level; point it at ~/.fastagent/auth.json to
|
|
202
|
-
" credential across projects)",
|
|
238
|
+
" auth: --auth-path > FASTAGENT_AUTH_PATH > <secrets>/auth.json\n" +
|
|
239
|
+
" (project-level; point it at ~/.fastagent/.secrets/auth.json to\n" +
|
|
240
|
+
" share one credential across projects)",
|
|
203
241
|
run: async (args, f) => (await import("./commands/start.js")).runStart(args[0], {
|
|
204
242
|
port: f.port,
|
|
205
243
|
model: f.model,
|
|
@@ -211,37 +249,70 @@ const start = {
|
|
|
211
249
|
};
|
|
212
250
|
/** The retired app-creation flag — parsed so it can explain itself, hidden from help. */
|
|
213
251
|
const CREATE_APP = { flags: "--create-app", description: "(retired)", hidden: true };
|
|
252
|
+
const INGRESS = {
|
|
253
|
+
flags: "--ingress <mode>",
|
|
254
|
+
description: "Feishu/Lark ingress: websocket or webhook (interactive when omitted)",
|
|
255
|
+
};
|
|
256
|
+
const GROUP_BEHAVIOR = {
|
|
257
|
+
flags: "--group-behavior <behavior>",
|
|
258
|
+
description: "Slack/Feishu/Lark groups: context (recommended) or mentions (least privilege)",
|
|
259
|
+
};
|
|
260
|
+
const NO_ONBOARD = {
|
|
261
|
+
flags: "--no-onboard",
|
|
262
|
+
description: "Slack: scaffold only; skip internal-app creation/OAuth",
|
|
263
|
+
};
|
|
264
|
+
const REPLACE_CONFIG = {
|
|
265
|
+
flags: "--replace-config",
|
|
266
|
+
description: "Slack: replace the local App Configuration token pair (repairs automatic dev/deploy Request URL " +
|
|
267
|
+
"updates after the tokens expire or are revoked; runs on the machine that onboarded the app)",
|
|
268
|
+
};
|
|
214
269
|
const channelSub = (kind, summary, description, notes) => ({
|
|
215
270
|
name: kind,
|
|
216
271
|
summary,
|
|
217
272
|
description,
|
|
218
273
|
args: [DIR_ARG],
|
|
219
|
-
flags: [
|
|
274
|
+
flags: [
|
|
275
|
+
CREATE_APP,
|
|
276
|
+
...(kind === "feishu" || kind === "lark"
|
|
277
|
+
? [INGRESS, GROUP_BEHAVIOR]
|
|
278
|
+
: kind === "slack"
|
|
279
|
+
? [GROUP_BEHAVIOR, NO_ONBOARD, REPLACE_CONFIG]
|
|
280
|
+
: []),
|
|
281
|
+
],
|
|
220
282
|
examples: [{ cmd: `fastagent add ${kind}` }],
|
|
221
283
|
...(notes ? { notes } : {}),
|
|
222
|
-
run: async (args, f) => (await import("./commands/add.js")).runAddChannel(kind, args[0], {
|
|
284
|
+
run: async (args, f) => (await import("./commands/add.js")).runAddChannel(kind, args[0], {
|
|
285
|
+
createApp: f.createApp === true,
|
|
286
|
+
ingress: f.ingress,
|
|
287
|
+
groupBehavior: f.groupBehavior,
|
|
288
|
+
onboard: f.onboard !== false,
|
|
289
|
+
replaceConfig: f.replaceConfig === true,
|
|
290
|
+
}),
|
|
223
291
|
});
|
|
224
292
|
const add = {
|
|
225
293
|
name: "add",
|
|
226
|
-
summary: "connect a channel (github, telegram, feishu, lark) or vendor a skill",
|
|
227
|
-
description: "Scaffold channels/<kind>.ts —
|
|
228
|
-
"events in on(); telegram/feishu/lark route in the optional route()) — or vendor an Agent Skills " +
|
|
294
|
+
summary: "connect a channel (github, telegram, slack, feishu, lark) or vendor a skill",
|
|
295
|
+
description: "Scaffold channels/<kind>.ts — first-party adapter glue with the policy to edit (github maps " +
|
|
296
|
+
"events in on(); telegram/slack/feishu/lark route in the optional route()) — or vendor an Agent Skills " +
|
|
229
297
|
"skill into skills/<name>/.",
|
|
230
298
|
subcommands: [
|
|
231
299
|
channelSub("github", "scaffold the GitHub webhook channel (issues/PRs → agent turns)", "Scaffold channels/github.ts — webhook adapter glue that maps repository events (issues, PRs, " +
|
|
232
300
|
"comments) to agent turns in its on() policy."),
|
|
233
301
|
channelSub("telegram", "scaffold the Telegram bot channel (durable turns, live preview)", "Scaffold channels/telegram.ts — the Telegram bot channel with durable turns, a live-preview " +
|
|
234
302
|
"message pump, and an optional route() policy."),
|
|
235
|
-
channelSub("
|
|
236
|
-
"
|
|
237
|
-
|
|
238
|
-
"
|
|
239
|
-
"
|
|
240
|
-
channelSub("
|
|
241
|
-
"
|
|
242
|
-
"
|
|
243
|
-
"
|
|
244
|
-
|
|
303
|
+
channelSub("slack", "scaffold the Slack Events API channel (files, threads, context, live preview)", "Choose group visibility, scaffold channels/slack.ts plus slack-send.ts, create a single-workspace " +
|
|
304
|
+
"internal Slack app from a manifest, and install it through OAuth. The channel provides signed " +
|
|
305
|
+
"Events API ingress, durable turns, files, threads, context, and an edited live preview.", "Automated onboarding requires Slack App Configuration access + refresh tokens and a temporary " +
|
|
306
|
+
"cloudflared tunnel. They stay in owner-readable local state and are never deployed; --no-onboard " +
|
|
307
|
+
"keeps the explicit manual/scaffold-only path."),
|
|
308
|
+
channelSub("feishu", "scaffold the Feishu channel AND create/configure the platform app", "Choose WebSocket or webhook, scaffold channels/feishu.ts, and create/configure the Feishu app " +
|
|
309
|
+
"through scan-to-create, writing the matching credentials to .env.", "Feishu (open.feishu.cn) is the canonical implementation. WebSocket needs only App ID/Secret and " +
|
|
310
|
+
"no public URL; webhook additionally captures the Verification Token through a temporary tunnel. " +
|
|
311
|
+
"Context-aware groups (recommended) request admin approval for im:message.group_msg before publish."),
|
|
312
|
+
channelSub("lark", "scaffold the Lark (international) channel with guided credential setup", "Choose WebSocket or webhook, scaffold channels/lark.ts, and guide credential setup against the " +
|
|
313
|
+
"international developer console.", "Lark international (open.larksuite.com) is Feishu's compatibility profile. WebSocket stops after " +
|
|
314
|
+
"App ID/Secret validation; webhook and recommended context-aware group setup probe config " +
|
|
315
|
+
"automation and fall back to explicit manual steps on the international config-route 404."),
|
|
245
316
|
{
|
|
246
317
|
name: "skill",
|
|
247
318
|
summary: "vendor an Agent Skills skill into skills/<name>/ (copied in, git-tracked)",
|
|
@@ -269,19 +340,22 @@ const add = {
|
|
|
269
340
|
};
|
|
270
341
|
const deploy = {
|
|
271
342
|
name: "deploy",
|
|
272
|
-
summary: "generate deploy artifacts + a runbook for docker, fly, or
|
|
343
|
+
summary: "generate deploy artifacts + a runbook for docker, fly, railway, or agentcore (--run drives it)",
|
|
273
344
|
description: "Generate Dockerfile/.dockerignore plus the target config and print an ordered runbook. " +
|
|
274
345
|
"docker: fastagent.compose.yml, loopback port, persistent state volume. fly: fly.toml " +
|
|
275
346
|
"(autostop=suspend, state→volume). railway: railway.json (healthcheck /health); its " +
|
|
276
|
-
"volume/variables/App-Sleeping are dashboard/CLI steps the runbook states.
|
|
277
|
-
"
|
|
278
|
-
|
|
347
|
+
"volume/variables/App-Sleeping are dashboard/CLI steps the runbook states. agentcore: one " +
|
|
348
|
+
"CloudFormation stack (AWS Bedrock AgentCore Runtime + forwarder Lambda for webhooks + " +
|
|
349
|
+
"EventBridge rules for schedules; linux/arm64 image built locally). Durable ingress " +
|
|
350
|
+
"remains operator-owned (agentcore's forwarder URL is the exception — the stack owns it).",
|
|
351
|
+
args: [{ name: "<host>", description: "deploy target", choices: ["docker", "fly", "railway", "agentcore"] }, DIR_ARG],
|
|
279
352
|
flags: [
|
|
280
353
|
{
|
|
281
354
|
flags: "--run",
|
|
282
355
|
description: "drive the target CLI to completion. Docker runs `docker compose up -d --build`; with a tunnel " +
|
|
283
356
|
"service, reads its URL and registers webhooks. Fly/Railway provision app/service + volume + " +
|
|
284
|
-
"secrets + deploy + webhook setup.
|
|
357
|
+
"secrets + deploy + webhook setup. AgentCore builds/pushes the arm64 image and deploys the " +
|
|
358
|
+
"stack (aws + docker CLIs). Carries your local credential (env key or OAuth auth.json). " +
|
|
285
359
|
"Stops at a gate (missing CLI/daemon/login/secret) with one actionable line. Without it: prints " +
|
|
286
360
|
"the runbook",
|
|
287
361
|
},
|
|
@@ -306,11 +380,13 @@ const deploy = {
|
|
|
306
380
|
},
|
|
307
381
|
MODEL,
|
|
308
382
|
AUTH_PATH,
|
|
383
|
+
NO_INPUT,
|
|
309
384
|
],
|
|
310
385
|
examples: [
|
|
311
386
|
{ cmd: "fastagent deploy fly --run", note: "provision + deploy + webhooks" },
|
|
312
387
|
{ cmd: "fastagent deploy docker --tunnel --run", note: "Compose + a public URL" },
|
|
313
388
|
{ cmd: "fastagent deploy railway", note: "print the runbook only" },
|
|
389
|
+
{ cmd: "fastagent deploy agentcore --run", note: "arm64 image + stack + webhooks" },
|
|
314
390
|
],
|
|
315
391
|
notes: "Definition-read-only: the only writes are generated artifacts (never clobbered without " +
|
|
316
392
|
"--force). A routine redeploy of an already-provisioned agent is just the host's own command " +
|
|
@@ -324,6 +400,7 @@ const deploy = {
|
|
|
324
400
|
intoLinked: f.intoLinked === true,
|
|
325
401
|
model: f.model,
|
|
326
402
|
authPath: f.authPath,
|
|
403
|
+
input: f.input !== false,
|
|
327
404
|
}),
|
|
328
405
|
};
|
|
329
406
|
const schedule = {
|
|
@@ -370,10 +447,11 @@ const schedule = {
|
|
|
370
447
|
const login = {
|
|
371
448
|
name: "login",
|
|
372
449
|
summary: "authenticate a model provider (subscription/OAuth or API key)",
|
|
373
|
-
description: "Authenticate a model provider into the project-level <
|
|
374
|
-
"
|
|
375
|
-
"(subscription/OAuth or API
|
|
376
|
-
"
|
|
450
|
+
description: "Authenticate a model provider into the project-level <agent dir>/.secrets/auth.json (outside an " +
|
|
451
|
+
"agent it writes the global ~/.fastagent/.secrets/auth.json, and says so): pick a method " +
|
|
452
|
+
"(subscription/OAuth or API " +
|
|
453
|
+
"key), then a provider that offers it (configured status shown). [provider] takes the method from " +
|
|
454
|
+
"what that provider supports, asked only when both.",
|
|
377
455
|
args: [{ name: "[provider]", description: "provider id (skip the provider menu)" }],
|
|
378
456
|
flags: [AUTH_PATH, NO_INPUT],
|
|
379
457
|
examples: [{ cmd: "fastagent login" }, { cmd: "fastagent login openai" }],
|
|
@@ -395,6 +473,7 @@ export const specs = [
|
|
|
395
473
|
schedule,
|
|
396
474
|
dev,
|
|
397
475
|
chat,
|
|
476
|
+
attach,
|
|
398
477
|
start,
|
|
399
478
|
add,
|
|
400
479
|
deploy,
|
package/dist/cli/serve.d.ts
CHANGED
|
@@ -1,28 +1,68 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The serving spine shared by `dev` (its worker) and `start`: route assembly from discovered
|
|
3
|
-
* channels/, the Node host binding, the scheduler lifecycle, and the optional Cloudflare quick
|
|
4
|
-
* tunnel. Bodies moved verbatim from cli.ts; `values.tunnel` became a parameter.
|
|
5
|
-
*/
|
|
6
1
|
import type { Agent } from "../agent.ts";
|
|
2
|
+
import { type LoadedLongConnectionChannel } from "../engines/pi/channel.ts";
|
|
7
3
|
import { type Routes } from "../host/node.ts";
|
|
4
|
+
import type { LoadedSchedule } from "../schedule/schedule.ts";
|
|
5
|
+
import type { SessionControl } from "../session.ts";
|
|
6
|
+
export interface ServingSurface {
|
|
7
|
+
routes: Routes;
|
|
8
|
+
longConnections: LoadedLongConnectionChannel[];
|
|
9
|
+
/** Route-channel basenames; the tunnel registers only this subset. */
|
|
10
|
+
routeChannels: string[];
|
|
11
|
+
builtinInvoke: boolean;
|
|
12
|
+
/** Marks the built-in health route ready after every long-connection channel first connects. */
|
|
13
|
+
markReady(): void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The surface this deployment serves: default `GET /health` plus discovered channels, or the default
|
|
17
|
+
* POST `/invoke` only when neither a route nor a long-connection channel was declared.
|
|
18
|
+
*/
|
|
19
|
+
export declare function routesFor(agentDir: string, agent: Agent, stateRoot: string, control?: SessionControl, options?: {
|
|
20
|
+
builtinInvoke?: boolean;
|
|
21
|
+
}): Promise<ServingSurface>;
|
|
22
|
+
/**
|
|
23
|
+
* Mount the session control plane (`/control/*`) when the agent enabled it
|
|
24
|
+
* (`config.sessionControl`): merge the bearer-authenticated routes and return an announcer that
|
|
25
|
+
* writes `<stateRoot>/control.json` — `{ url, token }`, 0600 — once the port is known. The file is
|
|
26
|
+
* the LOCAL discovery channel (`fastagent attach`, a local desktop app); filesystem permissions are
|
|
27
|
+
* its trust boundary, and each boot overwrites it with a fresh per-boot token. A user channel
|
|
28
|
+
* colliding on `/control/*` fails startup — the same disposition as a channel-channel collision
|
|
29
|
+
* (routesFor): `sessionControl` is an explicit opt-in, so declaring both is a configuration error,
|
|
30
|
+
* and silently shadowing either side would serve a surface the author didn't write.
|
|
31
|
+
*/
|
|
32
|
+
export declare function mountSessionControl(routes: Routes, control: SessionControl | undefined, stateRoot: string, options?: {
|
|
33
|
+
tunnel?: boolean;
|
|
34
|
+
agent?: Agent;
|
|
35
|
+
}): {
|
|
36
|
+
routes: Routes;
|
|
37
|
+
announce: (boundPort: number) => void;
|
|
38
|
+
};
|
|
8
39
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
40
|
+
* Mount the AgentCore Runtime adapter (`POST /invocations` + `GET /ping`) over the serving routes —
|
|
41
|
+
* the deployed container's ONLY reachable surface (channels/agentcore.ts). Wired by `start` when
|
|
42
|
+
* `FASTAGENT_AGENTCORE=1` (set by the generated deploy artifacts, never by hand). A channel colliding
|
|
43
|
+
* on either path fails startup, same disposition as the control-plane mount: the adapter's paths are
|
|
44
|
+
* the platform's contract, so a channel shadowing them would silently unserve the whole deployment.
|
|
11
45
|
*/
|
|
12
|
-
export declare function
|
|
13
|
-
|
|
14
|
-
|
|
46
|
+
export declare function mountAgentcore(routes: Routes, options: {
|
|
47
|
+
agent: Agent;
|
|
48
|
+
stateRoot: string;
|
|
49
|
+
schedules: LoadedSchedule[];
|
|
50
|
+
onStateReady?: () => void;
|
|
51
|
+
}): Routes;
|
|
15
52
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
53
|
+
* Bind HTTP, open long-connection channels, and report ready only when both forms are usable. Each
|
|
54
|
+
* adapter owns reconnects; a terminal close rejects `closed` and fails the process visibly. Abort is
|
|
55
|
+
* the sole clean-shutdown command.
|
|
19
56
|
*/
|
|
20
|
-
export declare function
|
|
57
|
+
export declare function serve(surface: ServingSurface, port: number, onListening?: (boundPort: number) => void): void;
|
|
58
|
+
/** Start a Cloudflare tunnel for route channels only. */
|
|
59
|
+
export declare function maybeTunnel(agentDir: string, routeChannels: string[], boundPort: number, tunnel: boolean, stateRoot?: string): void;
|
|
21
60
|
/**
|
|
22
|
-
* Load and start the
|
|
23
|
-
* there are static schedules OR `selfSchedule` is on
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* watch restart re-reads schedules with the worker (schedules are a code input). Single-process.
|
|
61
|
+
* Load and start the agent's `schedules/` — a time-trigger firing the agent on each cron. Starts iff
|
|
62
|
+
* there are static schedules OR `selfSchedule` is on. Best-effort stop on process signals. Returns the
|
|
63
|
+
* loaded schedules so a serving surface that needs them (the AgentCore adapter's fire binding) shares
|
|
64
|
+
* ONE load instead of re-discovering. `externalClock` (AgentCore) arms no resident cron timers.
|
|
27
65
|
*/
|
|
28
|
-
export declare function startSchedules(
|
|
66
|
+
export declare function startSchedules(agentDir: string, agent: Agent, stateRoot: string, selfSchedule: boolean, options?: {
|
|
67
|
+
externalClock?: boolean;
|
|
68
|
+
}): Promise<LoadedSchedule[]>;
|