@fastagent-sh/fastagent 0.21.1 → 0.22.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 +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 +209 -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 +153 -228
- 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/service.d.ts
CHANGED
|
@@ -1,158 +1,197 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The product, as one call: an agent directory becomes a live service.
|
|
3
|
-
*
|
|
4
|
-
* That phrase is the promise on the README, and until this existed only the CLI could keep it. The
|
|
5
|
-
* assembly parts live here too — `routesFor`, `mountSessionControl`, `startSchedules` — because a
|
|
6
|
-
* public entry may not reach into `cli/`: that directory decides process-level things (`fail.ts`
|
|
7
|
-
* calls `process.exit`) which a library mounted inside someone's app does not get to decide.
|
|
8
|
-
* Everything else was parts: assemble the agent, discover channels, mount the control plane, start
|
|
9
|
-
* schedules, open long connections, compose a router. An embedder had to know that list and get its
|
|
10
|
-
* order right, and getting it wrong is silent: a plane that 404s while advertising itself, a
|
|
11
|
-
* schedule that never fires.
|
|
12
|
-
*
|
|
13
|
-
* So the assembly lives here, and `dev`/`start` are callers. AgentCore is the one exception, and a
|
|
14
|
-
* substantive one: its channels load lazily after a state-snapshot restore, so it cannot use an
|
|
15
|
-
* assembly that discovers them eagerly (cli/commands/start.ts says so at the branch).
|
|
16
|
-
*/
|
|
17
1
|
import type { Agent } from "./agent.ts";
|
|
18
2
|
import { type PrefixMount } from "./channels/serve.ts";
|
|
19
3
|
import { type LoadedLongConnectionChannel } from "./channels/discover.ts";
|
|
20
4
|
import type { SessionControl } from "./session.ts";
|
|
21
5
|
import type { ChannelHandler, Routes } from "./channel.ts";
|
|
22
|
-
import type {
|
|
6
|
+
import type { LoadedRoutine } from "./schedule/routine.ts";
|
|
23
7
|
export interface ServingSurface {
|
|
24
|
-
|
|
8
|
+
/**
|
|
9
|
+
* The routes that AUTHENTICATE NOBODY — `GET /health`, `POST /invoke`, and `POST /run` where the definition
|
|
10
|
+
* declares routines, minus what a channel took over or `http.invoke: false` withheld. Kept APART from the channels' rather than merged with a list of which keys are
|
|
11
|
+
* which: three separate decisions read this (browser reachability, the JSON body gate, what the startup line
|
|
12
|
+
* calls unauthenticated), and while it was a derived list each of them could answer differently.
|
|
13
|
+
*/
|
|
14
|
+
unverified: Routes;
|
|
15
|
+
/**
|
|
16
|
+
* What the `channels/` files serve. Exempt from both guards because a channel checks its platform's signature
|
|
17
|
+
* inside itself — an assumption about the author for a CUSTOM channel, not a property we enforce (§14).
|
|
18
|
+
*/
|
|
19
|
+
selfVerifying: Routes;
|
|
25
20
|
/** Prefix-owning handlers mounted beside the routes (the session control plane). */
|
|
26
21
|
mounts?: readonly PrefixMount[];
|
|
27
22
|
longConnections: LoadedLongConnectionChannel[];
|
|
28
23
|
/** Route-channel basenames; the tunnel registers only this subset. */
|
|
29
24
|
routeChannels: string[];
|
|
30
|
-
|
|
31
|
-
/** Flip health between 200 and 503. Two-way on purpose: a long connection that dies after coming
|
|
32
|
-
* up leaves the surface serving something it no longer has, and a load balancer should hear it. */
|
|
25
|
+
/** Flip health between 200 and 503. */
|
|
33
26
|
setReady(value: boolean): void;
|
|
34
27
|
}
|
|
28
|
+
/** The port a serve binds when neither a flag, `PORT` (start only) nor `http.port` names one. */
|
|
29
|
+
export declare const DEFAULT_HTTP_PORT = 8787;
|
|
35
30
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
31
|
+
* What a serve publishes on its port, and to which browsers — the config file's `http` block minus `port`, carried
|
|
32
|
+
* as-is into the assembly so every reader (the routes, the startup report, deploy's pre-flight, AgentCore's inert-key
|
|
33
|
+
* warnings) reads ONE value. The port is not here: the assembly binds nothing, so only the CLI reads it.
|
|
38
34
|
*/
|
|
39
|
-
export
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
export interface HttpSurface {
|
|
36
|
+
/**
|
|
37
|
+
* The origins a BROWSER may call this serve from. The default, with this unset, answers EVERY origin: any page your
|
|
38
|
+
* users visit can call this port and read the reply, and every route here is unauthenticated. Set it to your front
|
|
39
|
+
* end's real domain to take that back (`["*"]` is the default said out loud; an empty list is refused, because it
|
|
40
|
+
* reads as "nobody" and would mean the opposite).
|
|
41
|
+
*/
|
|
42
|
+
cors?: readonly string[];
|
|
43
|
+
/**
|
|
44
|
+
* Serve the data plane, `POST /invoke`. On by default: it is the framework's interface, and a deployment that can
|
|
45
|
+
* only be reached through a chat channel is still worth curling. Set it `false` when this port is public and the
|
|
46
|
+
* channels' own signature checks are meant to be the only way in — the route is unauthenticated and runs a turn
|
|
47
|
+
* with the agent's full tool authority.
|
|
48
|
+
*/
|
|
49
|
+
invoke?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Serve `POST /run` (and `GET /routines`), which run a routine this definition declares by name. It follows
|
|
52
|
+
* `invoke` unless set: turning the anonymous turn endpoint off must not leave a second one open behind it. Set it
|
|
53
|
+
* `true` for the one combination that gets wrong — no `/invoke`, but an external clock (a crontab, a CI job) driving
|
|
54
|
+
* the routines. It has no effect where `routines/` declares nothing; there is no route then.
|
|
55
|
+
*/
|
|
56
|
+
run?: boolean;
|
|
57
|
+
}
|
|
42
58
|
/**
|
|
43
|
-
*
|
|
59
|
+
* Does this surface serve `POST /run`, given a routine to run? It FOLLOWS `invoke` unless `run` says otherwise (see
|
|
60
|
+
* {@link HttpSurface.run}). ONE function because the assembly mounts the route and `preflightDeploy` names it; a
|
|
61
|
+
* default spelled twice is a default that moves once.
|
|
62
|
+
*/
|
|
63
|
+
export declare function shouldServeRun(http: HttpSurface | undefined): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* What an anonymous caller of a port can do, worst first — the ONE wording the startup report and deploy's pre-flight
|
|
66
|
+
* both print, each from its own facts (what mounted vs what will mount).
|
|
67
|
+
*/
|
|
68
|
+
export declare function describeAnonymousSurface(open: {
|
|
69
|
+
invoke: boolean;
|
|
70
|
+
run: boolean;
|
|
71
|
+
controlPrefix?: string;
|
|
72
|
+
}): string[];
|
|
73
|
+
/**
|
|
74
|
+
* The surface this deployment serves: the DATA plane (`POST /invoke`), `GET /health`, and the discovered channels.
|
|
44
75
|
*
|
|
45
|
-
* `
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
|
|
76
|
+
* `/invoke` is the framework's interface, so it is served whatever channels a definition declares (unless
|
|
77
|
+
* `http.invoke: false`). It is RESERVED for the same reason `/control/*` is: a channel taking that path would silently replace the one route every client,
|
|
78
|
+
* every doc and the startup line all name. `/health` stays overridable — a probe is the deployment's to shape.
|
|
79
|
+
*/
|
|
80
|
+
export declare function routesFor(agentDir: string, agent: Agent, stateRoot: string, control: SessionControl | undefined,
|
|
81
|
+
/**
|
|
82
|
+
* `http.invoke: false` withholds the data plane. Two callers, two reasons: the AgentCore adapter serves the
|
|
83
|
+
* Runtime's `/invocations` contract instead, and an author sets it to leave the channels' signature checks as the
|
|
84
|
+
* only way into a public port.
|
|
49
85
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
86
|
+
* `routines` mounts `POST /run` and `GET /routines` (per {@link shouldServeRun}). Passed in rather than loaded here
|
|
87
|
+
* so the routes and the resident clock cannot disagree about which routines exist (`loadServingRoutines`).
|
|
52
88
|
*/
|
|
89
|
+
options?: {
|
|
90
|
+
http?: HttpSurface;
|
|
91
|
+
routines?: readonly LoadedRoutine[];
|
|
92
|
+
}): Promise<ServingSurface>;
|
|
93
|
+
/** Refuse channel routes the control plane would swallow. */
|
|
53
94
|
export declare function assertNoControlPlaneCollision(channelRoutes: Routes, plane: PrefixMount): void;
|
|
54
|
-
export declare function mountSessionControl(routes: Routes, control: SessionControl | undefined
|
|
55
|
-
agent?: Agent;
|
|
56
|
-
}): {
|
|
95
|
+
export declare function mountSessionControl(routes: Routes, control: SessionControl | undefined): {
|
|
57
96
|
routes: Routes;
|
|
58
97
|
mounts: PrefixMount[];
|
|
59
|
-
/** The plane
|
|
60
|
-
|
|
61
|
-
control?: {
|
|
62
|
-
token: string;
|
|
63
|
-
prefix: string;
|
|
64
|
-
};
|
|
98
|
+
/** The prefix the plane owns, when it is published — what a startup line names. */
|
|
99
|
+
controlPrefix?: string;
|
|
65
100
|
};
|
|
66
101
|
/**
|
|
67
|
-
* Load
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
102
|
+
* Load the agent's `routines/`, gated.
|
|
103
|
+
*
|
|
104
|
+
* Separate from {@link startSchedules} because two things need the SAME list and one of them runs first: the
|
|
105
|
+
* `POST /run` route is built with the routes (so a channel cannot take that path unnoticed), and the resident
|
|
106
|
+
* clock starts later, inside the service's scope. Loading twice would let them disagree about which routines exist.
|
|
107
|
+
*/
|
|
108
|
+
export declare function loadServingRoutines(agentDir: string): Promise<LoadedRoutine[]>;
|
|
109
|
+
/**
|
|
110
|
+
* Start the clock over routines {@link loadServingRoutines} already gated — on every serve, routines or not: the
|
|
111
|
+
* agent's own wake-ups are a default capability, and this is what fires them.
|
|
71
112
|
*/
|
|
72
|
-
export declare function startSchedules(
|
|
113
|
+
export declare function startSchedules(agent: Agent, stateRoot: string, routines: LoadedRoutine[], options?: {
|
|
73
114
|
externalClock?: boolean;
|
|
74
|
-
}):
|
|
75
|
-
|
|
115
|
+
}): {
|
|
116
|
+
routines: LoadedRoutine[];
|
|
76
117
|
stop: () => void;
|
|
77
|
-
}
|
|
118
|
+
};
|
|
78
119
|
export interface AgentService {
|
|
79
|
-
/** The assembled Fetch handler: channel routes, the control plane, and health.
|
|
80
|
-
* your host speaks `(Request) => Response`; `nodeListener` bridges it to Node's `(req, res)`. */
|
|
120
|
+
/** The assembled Fetch handler: channel routes, the control plane, and health. */
|
|
81
121
|
handler: ChannelHandler;
|
|
82
122
|
/** The agent behind it — invoke it directly when you also want a programmatic path. */
|
|
83
123
|
agent: Agent;
|
|
84
|
-
/** The literal routes `handler` was composed from — for a startup line naming what is served.
|
|
85
|
-
* Mounted prefixes are not here: nothing outside the assembly needed them, and a field kept for a
|
|
86
|
-
* hypothetical caller is a field nobody maintains. */
|
|
124
|
+
/** The literal routes `handler` was composed from — for a startup line naming what is served. */
|
|
87
125
|
routes: Routes;
|
|
88
126
|
agentDir: string;
|
|
89
127
|
workspace: string;
|
|
90
|
-
/**
|
|
91
|
-
*
|
|
92
|
-
|
|
93
|
-
* `POST /invoke` with a protocol of its own. */
|
|
128
|
+
/**
|
|
129
|
+
* What actually mounted, for a startup line: channel files serving routes, and long connections.
|
|
130
|
+
*/
|
|
94
131
|
channels: {
|
|
95
132
|
routes: string[];
|
|
96
133
|
longConnections: string[];
|
|
97
|
-
builtinInvoke: boolean;
|
|
98
134
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
*
|
|
102
|
-
*
|
|
135
|
+
/**
|
|
136
|
+
* The route keys on this port that AUTHENTICATE NOBODY — `GET /health`, `POST /invoke`, and `POST /run` where
|
|
137
|
+
* the definition declares routines, minus what a channel took over or `http.invoke: false` withheld. The FACT a caller needs to describe this surface: reading it off
|
|
138
|
+
* `routes` instead answers a different question, since a channel may serve one of those paths with a protocol of
|
|
139
|
+
* its own. That mistake ran in both directions here — a try-it curl for a route that 404s, and a warning about an
|
|
140
|
+
* unauthenticated `/invoke` that was really a signature-checked channel.
|
|
141
|
+
*/
|
|
142
|
+
unverifiedRoutes: readonly string[];
|
|
143
|
+
/**
|
|
144
|
+
* The cross-origin allow-list this service was assembled with (`http.cors`), or `undefined` for the `*` default.
|
|
145
|
+
* Read by the startup report for the same reason as {@link AgentService.unverifiedRoutes}: what a caller says
|
|
146
|
+
* about this surface must come from what was actually assembled, not from re-deriving it.
|
|
147
|
+
*/
|
|
148
|
+
corsOrigins?: readonly string[];
|
|
149
|
+
routines: readonly LoadedRoutine[];
|
|
150
|
+
/** Settles when every long connection is up — immediately when there are none. */
|
|
103
151
|
ready: Promise<void>;
|
|
104
|
-
/** The control plane's
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
*
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
152
|
+
/** The control plane's prefix, when `sessionControl` is on. */
|
|
153
|
+
controlPrefix?: string;
|
|
154
|
+
/**
|
|
155
|
+
* Stop long connections and routines. It does NOT drain agent turns: a turn takes seconds to minutes, and the
|
|
156
|
+
* deployment wants the old process gone in under a second (`SHUTDOWN_GRACE_MS` in `src/cli/serve.ts`). What makes
|
|
157
|
+
* that safe is replay, not waiting — a chat turn's intent is durable before it is accepted and its channel
|
|
158
|
+
* replays it on the next boot (`channels/kit/turn-store.ts`), and an in-flight HTTP/SSE caller sees the stream
|
|
159
|
+
* drop and retries. The one path with neither is a routine fire, whose claim is written before the turn: it
|
|
160
|
+
* stays skipped, and the next boot records it as `interrupted` rather than losing it silently.
|
|
161
|
+
*/
|
|
113
162
|
close(): Promise<void>;
|
|
114
163
|
}
|
|
115
164
|
/** What {@link mountAgentService} needs beyond an opened directory. */
|
|
116
165
|
export interface MountAgentServiceOptions {
|
|
117
|
-
/** Wrap the agent before anything consumes it
|
|
118
|
-
* must get the SAME one, which is why this is a hook rather than the caller's own call. `dev`
|
|
119
|
-
* passes `logAgentLoop`. */
|
|
166
|
+
/** Wrap the agent before anything consumes it. */
|
|
120
167
|
wrapAgent?: (agent: Agent) => Agent;
|
|
121
168
|
/** Aborting this closes the service, exactly like calling {@link AgentService.close}. */
|
|
122
169
|
signal?: AbortSignal;
|
|
123
|
-
/** Called when a long connection ends on its own — a dropped socket-mode channel, say.
|
|
124
|
-
* exits; an embedded host may prefer to log. Default: log an error. */
|
|
170
|
+
/** Called when a long connection ends on its own — a dropped socket-mode channel, say. */
|
|
125
171
|
onChannelClosed?: (name: string, error?: unknown) => void;
|
|
126
|
-
/** How long `close()` waits for a channel to stop before reporting it stuck (default 5s).
|
|
127
|
-
* shortens it so its own forced exit lands after this answer, not before it. */
|
|
172
|
+
/** How long `close()` waits for a channel to stop before reporting it stuck (default 5s). */
|
|
128
173
|
closeTimeoutMs?: number;
|
|
129
174
|
}
|
|
130
|
-
/**
|
|
131
|
-
* What the assembly needs from an opened agent directory — the whole of it. Spelled as its own type
|
|
132
|
-
* rather than an engine's return shape: every field here is either the SPEC contract or a path, so
|
|
133
|
-
* an engine that is not pi can satisfy it without either side knowing about the other.
|
|
134
|
-
*/
|
|
175
|
+
/** What the assembly needs from an opened agent directory — the whole of it. */
|
|
135
176
|
export interface MountableAgent {
|
|
136
177
|
agent: Agent;
|
|
137
|
-
/** The definition dir: where channels/, tools/ and
|
|
178
|
+
/** The definition dir: where channels/, tools/ and routines/ are read from. */
|
|
138
179
|
agentDir: string;
|
|
139
180
|
/** The agent's cwd. */
|
|
140
181
|
workspace: string;
|
|
141
|
-
/** Where durable state lives (channel state, sessions,
|
|
182
|
+
/** Where durable state lives (channel state, sessions, routine fires). */
|
|
142
183
|
stateRoot: string;
|
|
143
|
-
/**
|
|
184
|
+
/** The session-control hub, when the opener built one. A serve has it whether or not `/control/*` is published:
|
|
185
|
+
* a chat channel's stop command reaches the running turn through it. */
|
|
144
186
|
sessionControl?: SessionControl;
|
|
145
|
-
/** Whether
|
|
146
|
-
*
|
|
147
|
-
|
|
148
|
-
|
|
187
|
+
/** Whether that hub is ALSO served as `/control/*` (`config.sessionControl`). Required, not defaulted: an
|
|
188
|
+
* embedder assembling this by hand would otherwise lose the plane to a 404 with nothing said anywhere. */
|
|
189
|
+
publishControl: boolean;
|
|
190
|
+
/** What the port publishes, and to which browsers — the config's `http` block ({@link HttpSurface}). */
|
|
191
|
+
http?: HttpSurface;
|
|
149
192
|
}
|
|
150
193
|
/**
|
|
151
|
-
* The assembly itself, over an already-opened directory: channels, the control plane,
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
* {@link createAgentService} is this plus opening the directory. `dev`/`start` open separately — their
|
|
155
|
-
* startup report needs the opened values before anything mounts — and then arrive here, so there is
|
|
156
|
-
* one assembly rather than one per caller.
|
|
194
|
+
* The assembly itself, over an already-opened directory: channels, the control plane, routines and long connections,
|
|
195
|
+
* composed into one handler.
|
|
157
196
|
*/
|
|
158
197
|
export declare function mountAgentService(opened: MountableAgent, options?: MountAgentServiceOptions): Promise<AgentService>;
|