@fastagent-sh/fastagent 0.21.1 → 0.22.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.
- package/README.md +9 -12
- package/dist/agent.d.ts +24 -37
- package/dist/agent.js +7 -15
- package/dist/atomic-write.d.ts +13 -17
- package/dist/atomic-write.js +18 -29
- package/dist/bind.d.ts +12 -22
- package/dist/bind.js +18 -27
- package/dist/channel.d.ts +11 -33
- package/dist/channels/agentcore-limits.d.ts +2 -13
- package/dist/channels/agentcore-limits.js +2 -13
- package/dist/channels/agentcore-protocol.d.ts +67 -58
- package/dist/channels/agentcore-protocol.js +23 -15
- package/dist/channels/agentcore-service.d.ts +19 -33
- package/dist/channels/agentcore-service.js +176 -59
- package/dist/channels/agentcore.d.ts +39 -33
- package/dist/channels/agentcore.js +90 -224
- package/dist/channels/body.d.ts +15 -2
- package/dist/channels/body.js +24 -2
- package/dist/channels/busy.d.ts +1 -21
- package/dist/channels/busy.js +2 -39
- package/dist/channels/control.d.ts +17 -62
- package/dist/channels/control.js +74 -182
- package/dist/channels/define-channel.d.ts +39 -0
- package/dist/channels/define-channel.js +9 -0
- package/dist/channels/discover.d.ts +10 -31
- package/dist/channels/discover.js +37 -31
- package/dist/channels/feishu/bootstrap-token.d.ts +1 -8
- package/dist/channels/feishu/bootstrap-token.js +7 -23
- package/dist/channels/feishu/card.d.ts +14 -28
- package/dist/channels/feishu/card.js +16 -30
- package/dist/channels/feishu/cloud.d.ts +1 -5
- package/dist/channels/feishu/context-buffer.d.ts +4 -23
- package/dist/channels/feishu/context-buffer.js +8 -31
- package/dist/channels/feishu/crypto.d.ts +10 -5
- package/dist/channels/feishu/crypto.js +12 -19
- package/dist/channels/feishu/feishu-api.d.ts +2 -1
- package/dist/channels/feishu/feishu-api.js +5 -4
- package/dist/channels/feishu/feishu.d.ts +4 -10
- package/dist/channels/feishu/feishu.js +113 -227
- package/dist/channels/feishu/invoke-turn.d.ts +5 -4
- package/dist/channels/feishu/invoke-turn.js +36 -54
- package/dist/channels/feishu/model.d.ts +4 -21
- package/dist/channels/feishu/model.js +1 -8
- package/dist/channels/feishu/normalize.d.ts +2 -10
- package/dist/channels/feishu/normalize.js +7 -42
- package/dist/channels/feishu/parse.d.ts +9 -29
- package/dist/channels/feishu/parse.js +8 -26
- package/dist/channels/feishu/preview.d.ts +12 -14
- package/dist/channels/feishu/preview.js +108 -207
- package/dist/channels/feishu/register-app.d.ts +8 -23
- package/dist/channels/feishu/register-app.js +7 -20
- package/dist/channels/feishu/register-webhook.d.ts +2 -9
- package/dist/channels/feishu/register-webhook.js +9 -33
- package/dist/channels/feishu/scaffold/channel.ts +27 -19
- package/dist/channels/feishu/scaffold/channel.websocket.ts +31 -0
- package/dist/channels/feishu/setup-mode.d.ts +11 -36
- package/dist/channels/feishu/setup-mode.js +7 -26
- package/dist/channels/feishu/ws-ingress.d.ts +1 -2
- package/dist/channels/feishu/ws-ingress.js +6 -8
- package/dist/channels/http.d.ts +15 -15
- package/dist/channels/http.js +19 -9
- package/dist/channels/kit/attachment-path.d.ts +4 -5
- package/dist/channels/kit/attachment-path.js +10 -34
- package/dist/channels/kit/context-buffer.d.ts +14 -21
- package/dist/channels/kit/context-buffer.js +25 -38
- package/dist/channels/kit/delivery.d.ts +35 -0
- package/dist/channels/kit/delivery.js +129 -0
- package/dist/channels/kit/event-stream.d.ts +5 -0
- package/dist/channels/kit/event-stream.js +29 -0
- package/dist/channels/kit/invoke-turn-kit.d.ts +53 -26
- package/dist/channels/kit/invoke-turn-kit.js +89 -32
- package/dist/channels/kit/preview-kit.d.ts +18 -72
- package/dist/channels/kit/preview-kit.js +22 -88
- package/dist/channels/kit/signature.d.ts +3 -9
- package/dist/channels/kit/signature.js +3 -9
- package/dist/channels/kit/state.d.ts +1 -2
- package/dist/channels/kit/state.js +5 -14
- package/dist/channels/kit/stop-command.d.ts +1 -2
- package/dist/channels/kit/stop-command.js +6 -9
- package/dist/channels/kit/tasks.d.ts +1 -1
- package/dist/channels/kit/tasks.js +8 -21
- package/dist/channels/kit/text.d.ts +2 -16
- package/dist/channels/kit/text.js +23 -31
- package/dist/channels/kit/thread-participants.d.ts +4 -17
- package/dist/channels/kit/thread-participants.js +8 -55
- package/dist/channels/kit/transport.d.ts +26 -0
- package/dist/channels/kit/transport.js +20 -0
- package/dist/channels/kit/turn-queue.d.ts +7 -11
- package/dist/channels/kit/turn-queue.js +21 -39
- package/dist/channels/kit/turn-runner.d.ts +32 -18
- package/dist/channels/kit/turn-runner.js +98 -53
- package/dist/channels/kit/turn-store.d.ts +32 -32
- package/dist/channels/kit/turn-store.js +45 -88
- package/dist/channels/lark/lark.d.ts +1 -5
- package/dist/channels/lark/onboard.d.ts +3 -12
- package/dist/channels/lark/onboard.js +3 -13
- package/dist/channels/lark/scaffold/channel.ts +27 -19
- package/dist/channels/lark/scaffold/channel.websocket.ts +31 -0
- package/dist/channels/registration.d.ts +9 -35
- package/dist/channels/registration.js +6 -37
- package/dist/channels/secret.js +2 -5
- package/dist/channels/serve.d.ts +47 -44
- package/dist/channels/serve.js +165 -101
- package/dist/channels/slack/config-api.d.ts +4 -27
- package/dist/channels/slack/config-api.js +5 -34
- package/dist/channels/slack/context-buffer.d.ts +2 -3
- package/dist/channels/slack/context-buffer.js +5 -5
- package/dist/channels/slack/invoke-turn.d.ts +3 -1
- package/dist/channels/slack/invoke-turn.js +25 -34
- package/dist/channels/slack/manifest.js +1 -3
- package/dist/channels/slack/model.d.ts +1 -2
- package/dist/channels/slack/model.js +1 -1
- package/dist/channels/slack/onboard.d.ts +4 -3
- package/dist/channels/slack/onboard.js +8 -11
- package/dist/channels/slack/onboarding-state.d.ts +3 -5
- package/dist/channels/slack/onboarding-state.js +9 -6
- package/dist/channels/slack/parse.d.ts +4 -13
- package/dist/channels/slack/parse.js +7 -28
- package/dist/channels/slack/preview.d.ts +12 -2
- package/dist/channels/slack/preview.js +292 -269
- package/dist/channels/slack/reaction.d.ts +11 -3
- package/dist/channels/slack/reaction.js +19 -8
- package/dist/channels/slack/register-webhook.js +4 -7
- package/dist/channels/slack/scaffold/channel.ts +20 -13
- package/dist/channels/slack/scaffold/slack-send.ts +2 -2
- package/dist/channels/slack/setup-server.d.ts +1 -5
- package/dist/channels/slack/setup-server.js +1 -5
- package/dist/channels/slack/shared-api.d.ts +1 -4
- package/dist/channels/slack/shared-api.js +2 -13
- package/dist/channels/slack/slack-api.d.ts +2 -1
- package/dist/channels/slack/slack-api.js +6 -4
- package/dist/channels/slack/slack.d.ts +11 -14
- package/dist/channels/slack/slack.js +121 -122
- package/dist/channels/sse.d.ts +1 -1
- package/dist/channels/sse.js +1 -1
- package/dist/channels/telegram/context-buffer.d.ts +7 -22
- package/dist/channels/telegram/context-buffer.js +6 -23
- package/dist/channels/telegram/invoke-turn.d.ts +7 -7
- package/dist/channels/telegram/invoke-turn.js +24 -43
- package/dist/channels/telegram/parse.d.ts +24 -51
- package/dist/channels/telegram/parse.js +32 -84
- package/dist/channels/telegram/preview.d.ts +10 -1
- package/dist/channels/telegram/preview.js +79 -100
- package/dist/channels/telegram/register-webhook.js +5 -23
- package/dist/channels/telegram/scaffold/channel.ts +25 -18
- package/dist/channels/telegram/scaffold/telegram-send.ts +6 -4
- package/dist/channels/telegram/telegram-api.d.ts +4 -3
- package/dist/channels/telegram/telegram-api.js +9 -7
- package/dist/channels/telegram/telegram.d.ts +4 -18
- package/dist/channels/telegram/telegram.js +38 -94
- package/dist/channels/telegram/turn-store.d.ts +11 -14
- package/dist/channels/telegram/turn-store.js +8 -6
- package/dist/channels/wait-health.d.ts +4 -6
- package/dist/channels/wait-health.js +10 -14
- package/dist/cli/add-feishu.d.ts +2 -12
- package/dist/cli/add-feishu.js +24 -71
- package/dist/cli/add-slack.d.ts +5 -3
- package/dist/cli/add-slack.js +53 -76
- package/dist/cli/auth-view.d.ts +2 -16
- package/dist/cli/auth-view.js +2 -16
- package/dist/cli/commands/add.js +25 -40
- package/dist/cli/commands/chat.d.ts +0 -1
- package/dist/cli/commands/chat.js +5 -6
- package/dist/cli/commands/deploy/agentcore.js +60 -65
- package/dist/cli/commands/deploy/docker.js +50 -23
- package/dist/cli/commands/deploy/fly.js +23 -61
- package/dist/cli/commands/deploy/railway.js +23 -18
- package/dist/cli/commands/deploy/shared.d.ts +38 -57
- package/dist/cli/commands/deploy/shared.js +40 -59
- package/dist/cli/commands/deploy.d.ts +10 -27
- package/dist/cli/commands/deploy.js +38 -60
- package/dist/cli/commands/destroy.d.ts +4 -0
- package/dist/cli/commands/destroy.js +56 -0
- package/dist/cli/commands/dev.d.ts +2 -1
- package/dist/cli/commands/dev.js +20 -23
- package/dist/cli/commands/info.d.ts +0 -2
- package/dist/cli/commands/info.js +83 -49
- package/dist/cli/commands/init.d.ts +1 -2
- package/dist/cli/commands/init.js +16 -55
- package/dist/cli/commands/invoke.d.ts +0 -1
- package/dist/cli/commands/invoke.js +5 -7
- package/dist/cli/commands/login.d.ts +2 -1
- package/dist/cli/commands/login.js +33 -38
- package/dist/cli/commands/logs.js +3 -4
- package/dist/cli/commands/models.js +1 -5
- package/dist/cli/commands/routine-run.d.ts +6 -0
- package/dist/cli/commands/routine-run.js +47 -0
- package/dist/cli/commands/routine.d.ts +25 -0
- package/dist/cli/commands/routine.js +122 -0
- package/dist/cli/commands/start.d.ts +31 -3
- package/dist/cli/commands/start.js +131 -81
- package/dist/cli/commands/tool.js +26 -12
- package/dist/cli/fail.d.ts +13 -23
- package/dist/cli/fail.js +20 -23
- package/dist/cli/invoke-stream.d.ts +1 -8
- package/dist/cli/kernel.d.ts +6 -38
- package/dist/cli/kernel.js +14 -77
- package/dist/cli/models-view.d.ts +1 -9
- package/dist/cli/models-view.js +11 -22
- package/dist/cli/program.d.ts +5 -6
- package/dist/cli/program.js +120 -157
- package/dist/cli/serve.d.ts +57 -41
- package/dist/cli/serve.js +94 -121
- package/dist/cli/shared.d.ts +15 -61
- package/dist/cli/shared.js +55 -181
- package/dist/cli.js +1 -8
- package/dist/collect.d.ts +6 -0
- package/dist/collect.js +6 -0
- package/dist/core.d.ts +4 -1
- package/dist/core.js +9 -7
- package/dist/declared-secrets.d.ts +55 -0
- package/dist/declared-secrets.js +88 -0
- package/dist/deploy/agentcore/aws-cli.d.ts +91 -0
- package/dist/deploy/agentcore/aws-cli.js +64 -0
- package/dist/deploy/agentcore/destroy.d.ts +51 -0
- package/dist/deploy/agentcore/destroy.js +273 -0
- package/dist/deploy/agentcore/forwarder.js +28 -79
- package/dist/deploy/agentcore/logs.d.ts +2 -18
- package/dist/deploy/agentcore/logs.js +27 -51
- package/dist/deploy/agentcore/plan.d.ts +85 -105
- package/dist/deploy/agentcore/plan.js +152 -314
- package/dist/deploy/agentcore/run.d.ts +28 -28
- package/dist/deploy/agentcore/run.js +227 -306
- package/dist/deploy/agentcore/zip.d.ts +2 -15
- package/dist/deploy/agentcore/zip.js +3 -17
- package/dist/deploy/build-context.d.ts +21 -0
- package/dist/deploy/build-context.js +137 -0
- package/dist/deploy/channel-ingress.d.ts +26 -39
- package/dist/deploy/channel-ingress.js +57 -28
- package/dist/deploy/container.d.ts +20 -34
- package/dist/deploy/container.js +49 -100
- package/dist/deploy/docker/plan.d.ts +12 -11
- package/dist/deploy/docker/plan.js +43 -24
- package/dist/deploy/docker/run.d.ts +22 -25
- package/dist/deploy/docker/run.js +39 -37
- package/dist/deploy/fly/plan.d.ts +15 -44
- package/dist/deploy/fly/plan.js +41 -73
- package/dist/deploy/fly/run.d.ts +16 -51
- package/dist/deploy/fly/run.js +42 -95
- package/dist/deploy/hosts.d.ts +24 -3
- package/dist/deploy/hosts.js +24 -3
- package/dist/deploy/preflight.d.ts +47 -41
- package/dist/deploy/preflight.js +282 -383
- package/dist/deploy/railway/plan.d.ts +16 -42
- package/dist/deploy/railway/plan.js +42 -60
- package/dist/deploy/railway/run.d.ts +30 -68
- package/dist/deploy/railway/run.js +86 -100
- package/dist/deploy/registration-gate.d.ts +6 -13
- package/dist/deploy/residency.d.ts +37 -0
- package/dist/deploy/residency.js +24 -0
- package/dist/deploy/runner.d.ts +10 -9
- package/dist/deploy/runner.js +7 -18
- package/dist/deploy/secrets.d.ts +40 -41
- package/dist/deploy/secrets.js +117 -103
- package/dist/deploy/workspace.d.ts +50 -0
- package/dist/deploy/workspace.js +197 -0
- package/dist/dev-supervisor.d.ts +1 -9
- package/dist/dev-supervisor.js +21 -64
- package/dist/effect-port.d.ts +50 -0
- package/dist/effect-port.js +77 -0
- package/dist/engines/pi/agent-session-factory.d.ts +50 -69
- package/dist/engines/pi/agent-session-factory.js +249 -146
- package/dist/engines/pi/auth.d.ts +15 -11
- package/dist/engines/pi/auth.js +96 -99
- package/dist/engines/pi/chat.d.ts +1 -5
- package/dist/engines/pi/chat.js +2 -14
- package/dist/engines/pi/config.d.ts +53 -51
- package/dist/engines/pi/config.js +83 -92
- package/dist/engines/pi/create.d.ts +60 -75
- package/dist/engines/pi/create.js +108 -141
- package/dist/engines/pi/definition.d.ts +14 -58
- package/dist/engines/pi/definition.js +21 -85
- package/dist/engines/pi/invoke-session.d.ts +5 -25
- package/dist/engines/pi/invoke-session.js +233 -244
- package/dist/engines/pi/login.d.ts +95 -35
- package/dist/engines/pi/login.js +259 -107
- package/dist/engines/pi/machine.d.ts +31 -0
- package/dist/engines/pi/machine.js +106 -0
- package/dist/engines/pi/models.d.ts +70 -89
- package/dist/engines/pi/models.js +188 -81
- package/dist/engines/pi/open.d.ts +65 -53
- package/dist/engines/pi/open.js +129 -69
- package/dist/engines/pi/report.d.ts +3 -12
- package/dist/engines/pi/report.js +2 -16
- package/dist/engines/pi/search-tools.d.ts +1 -9
- package/dist/engines/pi/search-tools.js +26 -57
- package/dist/engines/pi/service.d.ts +2 -16
- package/dist/engines/pi/service.js +2 -16
- package/dist/engines/pi/session-builder.d.ts +5 -9
- package/dist/engines/pi/session-builder.js +44 -82
- package/dist/engines/pi/session-control.js +286 -269
- package/dist/engines/pi/session-effects.d.ts +14 -0
- package/dist/engines/pi/session-effects.js +30 -0
- package/dist/engines/pi/session-inheritance.d.ts +9 -18
- package/dist/engines/pi/session-inheritance.js +103 -160
- package/dist/engines/pi/session-markers.d.ts +31 -30
- package/dist/engines/pi/session-markers.js +26 -25
- package/dist/engines/pi/session-settings.d.ts +6 -22
- package/dist/engines/pi/session-settings.js +10 -21
- package/dist/engines/pi/session-store.d.ts +26 -92
- package/dist/engines/pi/session-store.js +96 -310
- package/dist/engines/pi/tool-context.d.ts +17 -45
- package/dist/engines/pi/tool-context.js +7 -26
- package/dist/engines/pi/tool.d.ts +45 -36
- package/dist/engines/pi/tool.js +43 -57
- package/dist/engines/pi/turn-kit.d.ts +14 -52
- package/dist/engines/pi/turn-kit.js +18 -67
- package/dist/engines/pi/wake-tool.d.ts +2 -10
- package/dist/engines/pi/wake-tool.js +7 -27
- package/dist/env.d.ts +27 -28
- package/dist/env.js +45 -50
- package/dist/index.js +0 -2
- package/dist/lark.d.ts +1 -2
- package/dist/lark.js +1 -2
- package/dist/loader.d.ts +14 -55
- package/dist/loader.js +24 -43
- package/dist/log.d.ts +2 -12
- package/dist/log.js +3 -24
- package/dist/node.d.ts +2 -15
- package/dist/node.js +2 -18
- package/dist/observe.d.ts +2 -8
- package/dist/open-url.d.ts +1 -1
- package/dist/open-url.js +1 -1
- package/dist/paths.d.ts +70 -134
- package/dist/paths.js +165 -232
- package/dist/pi.d.ts +4 -6
- package/dist/pi.js +3 -3
- package/dist/proxy.d.ts +16 -6
- package/dist/proxy.js +52 -16
- package/dist/runtime.d.ts +18 -12
- package/dist/runtime.js +18 -11
- package/dist/scaffold/add-channel.d.ts +14 -31
- package/dist/scaffold/add-channel.js +48 -112
- package/dist/scaffold/init.d.ts +9 -31
- package/dist/scaffold/init.js +45 -138
- package/dist/scaffold/templates/env.example +6 -4
- package/dist/scaffold/templates/fastagent.config.ts +36 -0
- package/dist/scaffold/templates.d.ts +3 -3
- package/dist/scaffold/templates.js +5 -8
- package/dist/scaffold/vendor-skill.d.ts +2 -5
- package/dist/scaffold/vendor-skill.js +19 -29
- package/dist/schedule/cron.d.ts +9 -5
- package/dist/schedule/cron.js +9 -11
- package/dist/schedule/discover.d.ts +12 -12
- package/dist/schedule/discover.js +43 -34
- package/dist/schedule/routine.d.ts +43 -0
- package/dist/schedule/routine.js +32 -0
- package/dist/schedule/run.d.ts +55 -0
- package/dist/schedule/run.js +146 -0
- package/dist/schedule/scheduler.d.ts +44 -55
- package/dist/schedule/scheduler.js +291 -265
- package/dist/schedule/state.d.ts +105 -10
- package/dist/schedule/state.js +293 -19
- package/dist/schedule/wake-alarm.d.ts +10 -23
- package/dist/schedule/wake-alarm.js +91 -121
- package/dist/schedule/wakeups.d.ts +23 -39
- package/dist/schedule/wakeups.js +33 -75
- package/dist/secrets-gate.d.ts +32 -0
- package/dist/secrets-gate.js +33 -0
- package/dist/service.d.ts +137 -98
- package/dist/service.js +250 -252
- package/dist/session-remote.d.ts +33 -44
- package/dist/session-remote.js +203 -192
- package/dist/session.d.ts +166 -229
- package/dist/session.js +33 -55
- package/dist/tunnel.d.ts +8 -36
- package/dist/tunnel.js +24 -65
- package/dist/version.d.ts +2 -2
- package/dist/version.js +2 -2
- package/package.json +10 -16
- package/dist/channels/agentcore-state.d.ts +0 -77
- package/dist/channels/agentcore-state.js +0 -276
- package/dist/channels/github/github.d.ts +0 -31
- package/dist/channels/github/github.js +0 -89
- package/dist/channels/github/scaffold/channel.ts +0 -25
- package/dist/cli/commands/attach.d.ts +0 -108
- package/dist/cli/commands/attach.js +0 -637
- package/dist/cli/commands/fire.d.ts +0 -7
- package/dist/cli/commands/fire.js +0 -38
- package/dist/cli/commands/schedule.d.ts +0 -12
- package/dist/cli/commands/schedule.js +0 -87
- package/dist/github.d.ts +0 -3
- package/dist/github.js +0 -2
- package/dist/scaffold/templates/fastagent.config.mjs +0 -23
- package/dist/schedule/audit.d.ts +0 -18
- package/dist/schedule/audit.js +0 -57
- package/dist/schedule/schedule.d.ts +0 -35
- package/dist/schedule/schedule.js +0 -23
package/dist/cli/kernel.js
CHANGED
|
@@ -1,59 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLI kernel — commands as data. A {@link CommandSpec} carries everything the CLI surface needs
|
|
3
|
-
* (summary, args/flags, examples, narrative notes, a lazy `run`), and {@link buildProgram} renders
|
|
4
|
-
* the set through commander. Commander is called ONLY from this module; the notation specs are
|
|
5
|
-
* written in — docopt-style argument brackets (`<required>`/`[optional]`), the flag DSL
|
|
6
|
-
* (`--auth-path <file>`, `--no-x` negation), and the derived option keys ({@link optionKey}) — is a
|
|
7
|
-
* contract this module owns and validates at build time. Replacing the parser means re-implementing
|
|
8
|
-
* that notation here (one module), not editing the specs.
|
|
9
|
-
*
|
|
10
|
-
* Follows clig.dev: per-command help in four spellings (`-h`/`--help`/`help <cmd>`/bare-with-missing-args),
|
|
11
|
-
* examples in help, "did you mean" suggestions (never auto-run), and one exit-code policy — 0 success,
|
|
12
|
-
* 1 runtime failure (owned by the command bodies), 2 usage error (anything the parser itself rejects).
|
|
13
|
-
*/
|
|
1
|
+
/** CLI kernel — commands as data. */
|
|
14
2
|
import { Argument, Command, Help, InvalidArgumentError, Option } from "commander";
|
|
15
3
|
import { errorPrefix } from "./fail.js";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* camelCase of the long name (`--auth-path` → `authPath`); a `--no-x` flag negates and stores under
|
|
19
|
-
* `x` (absent ⇒ `x !== false`). Owned and enforced here so `conflicts` references and run-body reads
|
|
20
|
-
* answer to one authority, not to an implicit parser behavior. Throws on a flag without a long form
|
|
21
|
-
* (clig: every flag has a full-length spelling).
|
|
22
|
-
*/
|
|
23
|
-
export function optionKey(flags) {
|
|
24
|
-
const long = flags
|
|
25
|
-
.split(/[\s,|]+/)
|
|
26
|
-
.filter((part) => part.startsWith("--"))
|
|
27
|
-
.at(-1);
|
|
28
|
-
if (!long)
|
|
29
|
-
throw new Error(`flag "${flags}" has no long form (clig: have full-length flags)`);
|
|
30
|
-
let name = long.replace(/^--/, "").replace(/[=<[].*$/, "");
|
|
31
|
-
if (name.startsWith("no-"))
|
|
32
|
-
name = name.slice(3);
|
|
33
|
-
return name.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
34
|
-
}
|
|
35
|
-
// Help styling (clig: formatting with intention): section headings are BOLD, nothing in help is
|
|
36
|
-
// colored — the only color in the whole CLI is the red error prefix. The style is always embedded;
|
|
37
|
-
// commander strips every SGR code from the assembled help whenever the target stream has no colors
|
|
38
|
-
// (non-TTY pipe, NO_COLOR, TERM=dumb).
|
|
4
|
+
// Help styling (clig: formatting with intention): section headings are BOLD, nothing in help is colored — the only
|
|
5
|
+
// color in the whole CLI is the red error prefix.
|
|
39
6
|
const title = (s) => `\x1b[1m${s}\x1b[0m`; // bold — section headings
|
|
40
7
|
/** The spec behind each registered command — how the Help renderer reaches Examples/notes. */
|
|
41
8
|
const specOf = new WeakMap();
|
|
42
|
-
/** Build the commander program for `specs`. The CLI entry parses with it; tests inject the IO seams. */
|
|
43
9
|
export function buildProgram(specs, options = {}) {
|
|
44
10
|
const exit = options.exit ?? ((code) => process.exit(code));
|
|
45
11
|
const program = new Command("fastagent");
|
|
46
12
|
program.description("Serve a file-defined agent — persona.md, skills/, tools/, channels/ — as a live service.");
|
|
47
|
-
// The exit-code policy: commander throws only for parse-level events — help/version displays carry
|
|
48
|
-
//
|
|
49
|
-
// through here; command bodies exit 1 themselves.
|
|
13
|
+
// The exit-code policy: commander throws only for parse-level events — help/version displays carry exitCode 0 (→
|
|
14
|
+
// 0), everything else it rejects is a usage error (→ 2).
|
|
50
15
|
program.exitOverride((err) => exit(err.exitCode === 0 ? 0 : 2));
|
|
51
16
|
program.configureHelp({
|
|
52
17
|
...(options.helpWidth !== undefined ? { helpWidth: options.helpWidth } : {}),
|
|
53
18
|
styleTitle: title,
|
|
54
|
-
// ONE renderer for the whole page: commander's standard sections, then our Examples/notes
|
|
55
|
-
// rendered with the SAME helper (helpWidth, styleTitle), so custom sections wrap and style
|
|
56
|
-
// exactly like native ones on any terminal.
|
|
19
|
+
// ONE renderer for the whole page: commander's standard sections, then our Examples/notes.
|
|
57
20
|
formatHelp: (cmd, helper) => Help.prototype.formatHelp.call(helper, cmd, helper) + extraSections(cmd, helper),
|
|
58
21
|
});
|
|
59
22
|
program.configureOutput({
|
|
@@ -62,8 +25,7 @@ export function buildProgram(specs, options = {}) {
|
|
|
62
25
|
...(options.colors !== undefined
|
|
63
26
|
? { getOutHasColors: () => options.colors, getErrHasColors: () => options.colors }
|
|
64
27
|
: {}),
|
|
65
|
-
// Every parse-level error carries the ONE unified prefix: bold-red `Error:` (plain when stderr
|
|
66
|
-
// has no colors). Command bodies get the same prefix through failStartup/failUsage.
|
|
28
|
+
// Every parse-level error carries the ONE unified prefix: bold-red `Error:` (plain when stderr has no colors).
|
|
67
29
|
outputError: (str, write) => write(str.startsWith("error:") ? `${errorPrefix(options.colors)}${str.slice("error:".length)}` : str),
|
|
68
30
|
});
|
|
69
31
|
program.showSuggestionAfterError(); // "did you mean models?" — suggest only, never run it (clig on DWIM)
|
|
@@ -79,17 +41,6 @@ export function buildProgram(specs, options = {}) {
|
|
|
79
41
|
return program;
|
|
80
42
|
}
|
|
81
43
|
function register(parent, spec) {
|
|
82
|
-
// Validate the spec's option references BEFORE handing anything to commander: every flag must
|
|
83
|
-
// have a long form (optionKey throws), and conflicts must name keys that exist on THIS command —
|
|
84
|
-
// commander matches conflicts by name at parse time, so a typo would otherwise silently never fire.
|
|
85
|
-
const keys = new Set((spec.flags ?? []).map((f) => optionKey(f.flags)));
|
|
86
|
-
for (const f of spec.flags ?? []) {
|
|
87
|
-
for (const target of f.conflicts ?? []) {
|
|
88
|
-
if (!keys.has(target)) {
|
|
89
|
-
throw new Error(`command "${spec.name}": "${f.flags}" conflicts with unknown option key "${target}"`);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
44
|
const cmd = parent.command(spec.name);
|
|
94
45
|
specOf.set(cmd, spec);
|
|
95
46
|
cmd.summary(spec.summary);
|
|
@@ -100,9 +51,7 @@ function register(parent, spec) {
|
|
|
100
51
|
arg.default(a.default);
|
|
101
52
|
if (a.choices)
|
|
102
53
|
arg.choices(a.choices);
|
|
103
|
-
// A required argument means a non-empty VALUE, not just a present token
|
|
104
|
-
// usage error, not an empty turn (the old dispatch's falsy guards, kept at the parse boundary).
|
|
105
|
-
// choices args validate membership already ("" is never a member).
|
|
54
|
+
// A required argument means a non-empty VALUE, not just a present token.
|
|
106
55
|
if (a.name.startsWith("<") && !a.choices) {
|
|
107
56
|
arg.argParser((value) => {
|
|
108
57
|
if (value.trim() === "")
|
|
@@ -112,12 +61,8 @@ function register(parent, spec) {
|
|
|
112
61
|
}
|
|
113
62
|
cmd.addArgument(arg);
|
|
114
63
|
}
|
|
115
|
-
for (const f of spec.flags ?? [])
|
|
116
|
-
|
|
117
|
-
if (f.conflicts)
|
|
118
|
-
opt.conflicts(f.conflicts);
|
|
119
|
-
cmd.addOption(opt);
|
|
120
|
-
}
|
|
64
|
+
for (const f of spec.flags ?? [])
|
|
65
|
+
cmd.addOption(new Option(f.flags, f.description));
|
|
121
66
|
for (const sub of spec.subcommands ?? [])
|
|
122
67
|
register(cmd, sub);
|
|
123
68
|
const run = spec.run;
|
|
@@ -129,11 +74,7 @@ function register(parent, spec) {
|
|
|
129
74
|
});
|
|
130
75
|
}
|
|
131
76
|
}
|
|
132
|
-
/**
|
|
133
|
-
* The Examples/notes sections a spec appends after commander's standard ones. Examples are
|
|
134
|
-
* preformatted (column-aligned `$ cmd # note` lines); notes are logical prose the renderer
|
|
135
|
-
* reflows to `helper.helpWidth` — the exact width the sections above were wrapped to.
|
|
136
|
-
*/
|
|
77
|
+
/** The Examples/notes sections a spec appends after commander's standard ones. */
|
|
137
78
|
function extraSections(cmd, helper) {
|
|
138
79
|
const spec = specOf.get(cmd);
|
|
139
80
|
if (!spec || ((spec.examples?.length ?? 0) === 0 && !spec.notes))
|
|
@@ -142,8 +83,8 @@ function extraSections(cmd, helper) {
|
|
|
142
83
|
const lines = [];
|
|
143
84
|
if (spec.examples && spec.examples.length > 0) {
|
|
144
85
|
lines.push(helper.styleTitle("Examples:"));
|
|
145
|
-
// Inline, column-aligned notes (`$ cmd
|
|
146
|
-
//
|
|
86
|
+
// Inline, column-aligned notes (`$ cmd # note`) — a note on its own line reads as a stray fragment when
|
|
87
|
+
// neighboring examples have none.
|
|
147
88
|
const w = Math.max(...spec.examples.map((e) => e.cmd.length));
|
|
148
89
|
for (const e of spec.examples) {
|
|
149
90
|
lines.push(e.note ? ` $ ${e.cmd.padEnd(w)} # ${e.note}` : ` $ ${e.cmd}`);
|
|
@@ -156,11 +97,7 @@ function extraSections(cmd, helper) {
|
|
|
156
97
|
}
|
|
157
98
|
return `\n${lines.join("\n")}`;
|
|
158
99
|
}
|
|
159
|
-
/**
|
|
160
|
-
* Reflow notes to the help width: plain lines are prose (joined and wrapped via the helper's own
|
|
161
|
-
* `boxWrap`); indented lines are preformatted (aligned tables like start's precedence chains) and
|
|
162
|
-
* pass through verbatim; blank lines separate paragraphs.
|
|
163
|
-
*/
|
|
100
|
+
/** Reflow notes to the help width: plain lines are prose (joined and wrapped via the helper's own `boxWrap`). */
|
|
164
101
|
function reflow(text, width, helper) {
|
|
165
102
|
const out = [];
|
|
166
103
|
let prose = [];
|
|
@@ -5,16 +5,8 @@ export interface ModelPickerOption {
|
|
|
5
5
|
label: string;
|
|
6
6
|
hint: string;
|
|
7
7
|
}
|
|
8
|
-
/**
|
|
9
|
-
* The first-run picker menu: the FULL model catalog, each spec annotated with its provider's auth
|
|
10
|
-
* status — ready first (usable now, with the credential source so "which account pays" is visible at
|
|
11
|
-
* the decision point), then the rest with their remedy. Order within each group preserves `specs`
|
|
12
|
-
* (sorted by the caller). A broken provider (expired/corrupt credential) is annotated, not dropped —
|
|
13
|
-
* fail visibly.
|
|
14
|
-
*/
|
|
8
|
+
/** The first-run picker menu: the FULL model catalog, each spec annotated with its provider's auth status. */
|
|
15
9
|
export declare function buildModelPickerOptions(specs: string[], statuses: Map<string, ProviderAuthStatus>): ModelPickerOption[];
|
|
16
|
-
/** The output of `fastagent models [search]`: the spec `lines` to print to stdout (a case-insensitive
|
|
17
|
-
* substring filter; no search → all), and an stderr `error` diagnostic when a search matches nothing. */
|
|
18
10
|
export declare function formatModelsCommand(specs: string[], search?: string): {
|
|
19
11
|
lines: string[];
|
|
20
12
|
error?: string;
|
package/dist/cli/models-view.js
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* CLI presenter for the model-facing commands: `fastagent models [search]` output and the first-run
|
|
3
|
-
*
|
|
4
|
-
* model resolution / listModels), so this process-boundary behavior is unit-testable without
|
|
5
|
-
* spawning the CLI.
|
|
2
|
+
* CLI presenter for the model-facing commands: `fastagent models [search]` output and the first-run picker's option
|
|
3
|
+
* list.
|
|
6
4
|
*/
|
|
7
5
|
import { providerOf } from "../engines/pi/config.js";
|
|
8
|
-
/** The remedy hint for a non-ready provider, by what picking it actually does
|
|
9
|
-
* "login required"; an interactive key prompt → "API key required"; no flow at all → the env var. */
|
|
6
|
+
/** The remedy hint for a non-ready provider, by what picking it actually does. */
|
|
10
7
|
function remedy(login) {
|
|
11
8
|
if (login === "oauth")
|
|
12
9
|
return "login required";
|
|
13
10
|
return login === "api_key" ? "API key required" : "API key required — set the provider's env var";
|
|
14
11
|
}
|
|
15
|
-
/**
|
|
16
|
-
* The first-run picker menu: the FULL model catalog, each spec annotated with its provider's auth
|
|
17
|
-
* status — ready first (usable now, with the credential source so "which account pays" is visible at
|
|
18
|
-
* the decision point), then the rest with their remedy. Order within each group preserves `specs`
|
|
19
|
-
* (sorted by the caller). A broken provider (expired/corrupt credential) is annotated, not dropped —
|
|
20
|
-
* fail visibly.
|
|
21
|
-
*/
|
|
12
|
+
/** The first-run picker menu: the FULL model catalog, each spec annotated with its provider's auth status. */
|
|
22
13
|
export function buildModelPickerOptions(specs, statuses) {
|
|
23
14
|
const ready = [];
|
|
24
15
|
const rest = [];
|
|
@@ -28,8 +19,8 @@ export function buildModelPickerOptions(specs, statuses) {
|
|
|
28
19
|
ready.push({ value: spec, label: spec, hint: status.source ? `ready — ${status.source}` : "ready" });
|
|
29
20
|
}
|
|
30
21
|
else if (status?.state === "broken") {
|
|
31
|
-
// A broken stored credential OWNS the provider (env is consulted only when nothing is stored),
|
|
32
|
-
//
|
|
22
|
+
// A broken stored credential OWNS the provider (env is consulted only when nothing is stored), so with no login
|
|
23
|
+
// flow the remedy is fixing the store.
|
|
33
24
|
rest.push({
|
|
34
25
|
value: spec,
|
|
35
26
|
label: spec,
|
|
@@ -42,15 +33,13 @@ export function buildModelPickerOptions(specs, statuses) {
|
|
|
42
33
|
rest.push({ value: spec, label: spec, hint: remedy(status.login) });
|
|
43
34
|
}
|
|
44
35
|
else {
|
|
45
|
-
// Unreachable when `specs` and `statuses` come from the same Models (every listed provider is
|
|
46
|
-
//
|
|
36
|
+
// Unreachable when `specs` and `statuses` come from the same Models (every listed provider is probed); if a
|
|
37
|
+
// caller ever mixes sources, promise nothing.
|
|
47
38
|
rest.push({ value: spec, label: spec, hint: "auth required" });
|
|
48
39
|
}
|
|
49
40
|
}
|
|
50
41
|
return [...ready, ...rest];
|
|
51
42
|
}
|
|
52
|
-
/** The output of `fastagent models [search]`: the spec `lines` to print to stdout (a case-insensitive
|
|
53
|
-
* substring filter; no search → all), and an stderr `error` diagnostic when a search matches nothing. */
|
|
54
43
|
export function formatModelsCommand(specs, search) {
|
|
55
44
|
if (!search)
|
|
56
45
|
return { lines: specs };
|
|
@@ -58,9 +47,9 @@ export function formatModelsCommand(specs, search) {
|
|
|
58
47
|
const matches = specs.filter((spec) => spec.toLowerCase().includes(q));
|
|
59
48
|
if (matches.length === 0)
|
|
60
49
|
return { lines: matches, error: `no model matches "${search}"` };
|
|
61
|
-
// Rank a PROVIDER-name match (query in the part before "/") above an incidental model-id match, so
|
|
62
|
-
//
|
|
63
|
-
//
|
|
50
|
+
// Rank a PROVIDER-name match (query in the part before "/") above an incidental model-id match, so `models
|
|
51
|
+
// anthropic` leads with anthropic/* rather than burying it under amazon-bedrock/anthropic.* and
|
|
52
|
+
// google-vertex/…-anthropic-… (which only match in the model id).
|
|
64
53
|
const providerMatch = (spec) => providerOf(spec).toLowerCase().includes(q);
|
|
65
54
|
return { lines: [...matches.filter(providerMatch), ...matches.filter((s) => !providerMatch(s))] };
|
|
66
55
|
}
|
package/dist/cli/program.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { type CommandSpec, type ProgramOptions } from "./kernel.ts";
|
|
2
|
-
/** Registration order = help order — the ORIGINAL usage wall's order, kept verbatim (this is a
|
|
3
|
-
* commander refactor of the same CLI, not a redesign). Exported for the kernel conformance tests. */
|
|
4
|
-
export declare const specs: readonly CommandSpec[];
|
|
5
2
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* Registration order = help order — the ORIGINAL usage wall's order, kept verbatim (this is a commander refactor of
|
|
4
|
+
* the same CLI, not a redesign).
|
|
8
5
|
*/
|
|
6
|
+
export declare const specs: readonly CommandSpec[];
|
|
7
|
+
/** The production program assembly (specs + the top-level examples/docs). */
|
|
9
8
|
export declare function buildCliProgram(overrides?: ProgramOptions): import("commander").Command;
|
|
10
|
-
/** Parse and run one CLI invocation (`argv` = process.argv).
|
|
9
|
+
/** Parse and run one CLI invocation (`argv` = process.argv). */
|
|
11
10
|
export declare function runCli(argv: readonly string[]): Promise<void>;
|