@fastagent-sh/fastagent 0.24.4 → 0.26.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 +54 -82
- package/dist/agent-api.d.ts +460 -0
- package/dist/agent-api.js +209 -0
- package/dist/answer-text.d.ts +8 -0
- package/dist/answer-text.js +18 -0
- package/dist/atomic-write.d.ts +2 -2
- package/dist/atomic-write.js +2 -2
- package/dist/authoring.d.ts +81 -0
- package/dist/authoring.js +245 -0
- package/dist/channel.d.ts +29 -15
- package/dist/channel.js +4 -1
- package/dist/channels/agentcore-protocol.d.ts +36 -50
- package/dist/channels/agentcore-protocol.js +3 -3
- package/dist/channels/agentcore-service.d.ts +8 -18
- package/dist/channels/agentcore-service.js +108 -127
- package/dist/channels/agentcore.d.ts +8 -24
- package/dist/channels/agentcore.js +32 -65
- package/dist/channels/body.d.ts +0 -16
- package/dist/channels/body.js +0 -25
- package/dist/channels/busy.js +6 -1
- package/dist/channels/context.d.ts +4 -0
- package/dist/channels/context.js +35 -0
- package/dist/channels/discover.d.ts +18 -20
- package/dist/channels/discover.js +41 -99
- package/dist/channels/feishu/feishu-api.d.ts +54 -4
- package/dist/channels/feishu/feishu-api.js +192 -149
- package/dist/channels/feishu/feishu.d.ts +3 -0
- package/dist/channels/feishu/feishu.js +117 -106
- package/dist/channels/feishu/history.d.ts +55 -0
- package/dist/channels/feishu/history.js +199 -0
- package/dist/channels/feishu/invoke-turn.d.ts +13 -11
- package/dist/channels/feishu/invoke-turn.js +9 -10
- package/dist/channels/feishu/model.d.ts +2 -1
- package/dist/channels/feishu/normalize.js +100 -0
- package/dist/channels/feishu/preview.d.ts +2 -2
- package/dist/channels/feishu/register-webhook.d.ts +1 -0
- package/dist/channels/feishu/register-webhook.js +3 -2
- package/dist/channels/feishu/scaffold/channel.ts +65 -46
- package/dist/channels/feishu/scaffold/feishu-send.ts +38 -33
- package/dist/channels/feishu/scaffold/feishu-threads.ts +25 -0
- package/dist/channels/feishu/setup-mode.d.ts +45 -25
- package/dist/channels/feishu/setup-mode.js +74 -23
- package/dist/channels/feishu/shared-api.d.ts +24 -6
- package/dist/channels/feishu/shared-api.js +30 -24
- package/dist/channels/kit/context-buffer.d.ts +11 -2
- package/dist/channels/kit/context-buffer.js +7 -4
- package/dist/channels/kit/delivery.d.ts +19 -3
- package/dist/channels/kit/delivery.js +74 -15
- package/dist/channels/kit/event-stream.js +2 -1
- package/dist/channels/kit/invoke-turn-kit.d.ts +41 -41
- package/dist/channels/kit/invoke-turn-kit.js +62 -71
- package/dist/channels/kit/place-history.d.ts +107 -0
- package/dist/channels/kit/place-history.js +182 -0
- package/dist/channels/kit/preview-kit.d.ts +9 -5
- package/dist/channels/kit/preview-kit.js +36 -15
- package/dist/channels/kit/room-threads.d.ts +46 -0
- package/dist/channels/kit/room-threads.js +81 -0
- package/dist/channels/kit/seen.js +1 -1
- package/dist/channels/kit/stop-command.d.ts +6 -3
- package/dist/channels/kit/stop-command.js +20 -18
- package/dist/channels/kit/thread-fork.d.ts +17 -0
- package/dist/channels/kit/thread-fork.js +43 -0
- package/dist/channels/kit/thread-participants.js +1 -1
- package/dist/channels/kit/transport.d.ts +5 -0
- package/dist/channels/kit/transport.js +5 -0
- package/dist/channels/kit/turn-runner.d.ts +10 -9
- package/dist/channels/kit/turn-runner.js +17 -19
- package/dist/channels/kit/turn-store.d.ts +5 -4
- package/dist/channels/kit/turn-store.js +5 -5
- package/dist/channels/lark/lark.d.ts +3 -0
- package/dist/channels/lark/lark.js +5 -0
- package/dist/channels/lark/onboard.d.ts +5 -3
- package/dist/channels/lark/onboard.js +14 -14
- package/dist/channels/lark/scaffold/channel.ts +67 -44
- package/dist/channels/lark/scaffold/lark-send.ts +38 -33
- package/dist/channels/lark/scaffold/lark-threads.ts +25 -0
- package/dist/channels/respond.d.ts +0 -4
- package/dist/channels/respond.js +1 -1
- package/dist/channels/router.d.ts +18 -0
- package/dist/channels/router.js +68 -0
- package/dist/channels/serve.d.ts +5 -70
- package/dist/channels/serve.js +105 -287
- package/dist/channels/slack/history.d.ts +42 -0
- package/dist/channels/slack/history.js +282 -0
- package/dist/channels/slack/invoke-turn.d.ts +12 -5
- package/dist/channels/slack/invoke-turn.js +7 -5
- package/dist/channels/slack/manifest.d.ts +1 -4
- package/dist/channels/slack/manifest.js +22 -10
- package/dist/channels/slack/model.d.ts +2 -1
- package/dist/channels/slack/onboard.d.ts +0 -2
- package/dist/channels/slack/onboard.js +2 -4
- package/dist/channels/slack/onboarding-state.d.ts +0 -2
- package/dist/channels/slack/onboarding-state.js +0 -1
- package/dist/channels/slack/parse.d.ts +0 -5
- package/dist/channels/slack/parse.js +1 -16
- package/dist/channels/slack/preview.d.ts +2 -3
- package/dist/channels/slack/preview.js +78 -52
- package/dist/channels/slack/register-webhook.d.ts +1 -0
- package/dist/channels/slack/register-webhook.js +6 -5
- package/dist/channels/slack/scaffold/channel.ts +23 -24
- package/dist/channels/slack/scaffold/slack-send.ts +50 -43
- package/dist/channels/slack/scaffold/slack-threads.ts +29 -0
- package/dist/channels/slack/setup-server.d.ts +19 -0
- package/dist/channels/slack/setup-server.js +113 -11
- package/dist/channels/slack/shared-api.d.ts +15 -4
- package/dist/channels/slack/shared-api.js +19 -14
- package/dist/channels/slack/slack-api.d.ts +61 -2
- package/dist/channels/slack/slack-api.js +28 -5
- package/dist/channels/slack/slack.js +97 -52
- package/dist/channels/slack/welcomed.js +1 -1
- package/dist/channels/telegram/context-buffer.d.ts +6 -1
- package/dist/channels/telegram/context-buffer.js +19 -0
- package/dist/channels/telegram/invoke-turn.d.ts +8 -4
- package/dist/channels/telegram/invoke-turn.js +7 -7
- package/dist/channels/telegram/parse.d.ts +7 -2
- package/dist/channels/telegram/parse.js +7 -0
- package/dist/channels/telegram/preview.d.ts +2 -2
- package/dist/channels/telegram/register-webhook.d.ts +1 -0
- package/dist/channels/telegram/register-webhook.js +3 -2
- package/dist/channels/telegram/scaffold/channel.ts +27 -28
- package/dist/channels/telegram/scaffold/telegram-send.ts +61 -108
- package/dist/channels/telegram/shared-api.d.ts +34 -0
- package/dist/channels/telegram/shared-api.js +79 -0
- package/dist/channels/telegram/telegram-api.d.ts +15 -5
- package/dist/channels/telegram/telegram-api.js +10 -6
- package/dist/channels/telegram/telegram.js +27 -21
- package/dist/channels/telegram/turn-store.js +1 -1
- package/dist/channels/{kit/turn-queue.d.ts → turn-queue.d.ts} +2 -2
- package/dist/channels/{kit/turn-queue.js → turn-queue.js} +10 -10
- package/dist/cli/add-feishu.d.ts +42 -12
- package/dist/cli/add-feishu.js +177 -124
- package/dist/cli/add-slack.d.ts +8 -3
- package/dist/cli/add-slack.js +116 -64
- package/dist/cli/auth-view.d.ts +10 -3
- package/dist/cli/auth-view.js +8 -6
- package/dist/cli/box-login.d.ts +18 -7
- package/dist/cli/box-login.js +46 -12
- package/dist/cli/commands/add.d.ts +15 -4
- package/dist/cli/commands/add.js +253 -143
- package/dist/cli/commands/auth.d.ts +6 -0
- package/dist/cli/commands/auth.js +50 -0
- package/dist/cli/commands/content.d.ts +6 -0
- package/dist/cli/commands/content.js +45 -0
- package/dist/cli/commands/deploy/agentcore.js +50 -77
- package/dist/cli/commands/deploy/docker.js +38 -39
- package/dist/cli/commands/deploy/fly.js +21 -18
- package/dist/cli/commands/deploy/host-login.d.ts +26 -0
- package/dist/cli/commands/deploy/host-login.js +90 -0
- package/dist/cli/commands/deploy/railway.js +21 -26
- package/dist/cli/commands/deploy/shared.d.ts +45 -17
- package/dist/cli/commands/deploy/shared.js +34 -15
- package/dist/cli/commands/deploy.d.ts +0 -4
- package/dist/cli/commands/deploy.js +237 -50
- package/dist/cli/commands/destroy.js +8 -6
- package/dist/cli/commands/dev.d.ts +0 -2
- package/dist/cli/commands/dev.js +20 -19
- package/dist/cli/commands/env.d.ts +12 -0
- package/dist/cli/commands/env.js +191 -0
- package/dist/cli/commands/info.js +95 -156
- package/dist/cli/commands/init.d.ts +2 -2
- package/dist/cli/commands/init.js +35 -33
- package/dist/cli/commands/invoke.d.ts +6 -0
- package/dist/cli/commands/invoke.js +132 -16
- package/dist/cli/commands/login.d.ts +31 -2
- package/dist/cli/commands/login.js +416 -65
- package/dist/cli/commands/logout.d.ts +4 -0
- package/dist/cli/commands/logout.js +53 -0
- package/dist/cli/commands/logs.js +8 -6
- package/dist/cli/commands/models.d.ts +2 -1
- package/dist/cli/commands/models.js +39 -37
- package/dist/cli/commands/schedules.d.ts +21 -0
- package/dist/cli/commands/schedules.js +143 -0
- package/dist/cli/commands/start.d.ts +11 -10
- package/dist/cli/commands/start.js +35 -62
- package/dist/cli/content-view.d.ts +9 -0
- package/dist/cli/content-view.js +26 -0
- package/dist/cli/fail.d.ts +9 -12
- package/dist/cli/fail.js +17 -14
- package/dist/cli/invoke-stream.d.ts +12 -3
- package/dist/cli/invoke-stream.js +85 -23
- package/dist/cli/kernel.d.ts +9 -2
- package/dist/cli/kernel.js +15 -6
- package/dist/cli/login-relay.d.ts +6 -4
- package/dist/cli/login-relay.js +19 -7
- package/dist/cli/models-view.d.ts +5 -1
- package/dist/cli/models-view.js +1 -1
- package/dist/cli/person.d.ts +10 -0
- package/dist/cli/person.js +23 -0
- package/dist/cli/program.js +421 -203
- package/dist/cli/serve.d.ts +13 -63
- package/dist/cli/serve.js +31 -121
- package/dist/cli/shared.d.ts +21 -48
- package/dist/cli/shared.js +70 -89
- package/dist/cli/ticket.d.ts +136 -0
- package/dist/cli/ticket.js +476 -0
- package/dist/client.d.ts +7 -0
- package/dist/client.js +2 -0
- package/dist/content/declare.d.ts +70 -0
- package/dist/content/declare.js +163 -0
- package/dist/content/file.d.ts +32 -0
- package/dist/content/file.js +119 -0
- package/dist/content/git.d.ts +41 -0
- package/dist/content/git.js +220 -0
- package/dist/content/mount.d.ts +2 -0
- package/dist/content/mount.js +15 -0
- package/dist/content/resolve.d.ts +52 -0
- package/dist/content/resolve.js +151 -0
- package/dist/content/source.d.ts +27 -0
- package/dist/content/source.js +53 -0
- package/dist/conversation-sessions.d.ts +26 -0
- package/dist/conversation-sessions.js +99 -0
- package/dist/declared-secrets.d.ts +19 -37
- package/dist/declared-secrets.js +16 -58
- package/dist/deploy/agentcore/destroy.d.ts +3 -3
- package/dist/deploy/agentcore/destroy.js +46 -28
- package/dist/deploy/agentcore/forwarder.js +105 -22
- package/dist/deploy/agentcore/logs.js +1 -1
- package/dist/deploy/agentcore/plan.d.ts +10 -24
- package/dist/deploy/agentcore/plan.js +31 -135
- package/dist/deploy/agentcore/run.d.ts +1 -1
- package/dist/deploy/agentcore/run.js +8 -5
- package/dist/deploy/agentcore/shell.d.ts +1 -1
- package/dist/deploy/agentcore/shell.js +5 -5
- package/dist/deploy/api.d.ts +34 -0
- package/dist/deploy/api.js +50 -0
- package/dist/deploy/box-shell.d.ts +6 -0
- package/dist/deploy/box-shell.js +7 -0
- package/dist/deploy/build-context.d.ts +7 -5
- package/dist/deploy/build-context.js +41 -35
- package/dist/deploy/channel-ingress.d.ts +6 -1
- package/dist/deploy/channel-ingress.js +18 -5
- package/dist/deploy/container.d.ts +22 -9
- package/dist/deploy/container.js +96 -55
- package/dist/deploy/docker/plan.d.ts +3 -2
- package/dist/deploy/docker/plan.js +13 -14
- package/dist/deploy/docker/run.d.ts +2 -2
- package/dist/deploy/docker/run.js +8 -4
- package/dist/deploy/fly/plan.d.ts +1 -1
- package/dist/deploy/fly/plan.js +12 -21
- package/dist/deploy/fly/run.d.ts +10 -6
- package/dist/deploy/fly/run.js +11 -6
- package/dist/deploy/hosts.d.ts +2 -1
- package/dist/deploy/hosts.js +2 -1
- package/dist/deploy/preflight.d.ts +21 -23
- package/dist/deploy/preflight.js +223 -202
- package/dist/deploy/railway/plan.d.ts +8 -6
- package/dist/deploy/railway/plan.js +15 -58
- package/dist/deploy/railway/run.d.ts +8 -3
- package/dist/deploy/railway/run.js +12 -8
- package/dist/deploy/residency.d.ts +5 -11
- package/dist/deploy/residency.js +0 -6
- package/dist/deploy/runner.d.ts +1 -1
- package/dist/deploy/runner.js +1 -1
- package/dist/deploy/secrets.d.ts +16 -2
- package/dist/deploy/secrets.js +33 -6
- package/dist/deploy/workspace.d.ts +11 -6
- package/dist/deploy/workspace.js +55 -38
- package/dist/dev-supervisor.d.ts +11 -2
- package/dist/dev-supervisor.js +52 -27
- package/dist/effect-port.d.ts +4 -4
- package/dist/effect-port.js +4 -4
- package/dist/env.d.ts +0 -13
- package/dist/env.js +1 -44
- package/dist/environment/apt.d.ts +4 -0
- package/dist/environment/apt.js +32 -0
- package/dist/environment/declare.d.ts +59 -0
- package/dist/environment/declare.js +210 -0
- package/dist/environment/mise.d.ts +51 -0
- package/dist/environment/mise.js +272 -0
- package/dist/feishu.d.ts +2 -2
- package/dist/feishu.js +2 -2
- package/dist/git.d.ts +13 -0
- package/dist/git.js +55 -0
- package/dist/harnesses/models/catalog.d.ts +20 -0
- package/dist/harnesses/models/catalog.js +254 -0
- package/dist/{engines/pi/auth.d.ts → harnesses/models/credentials.d.ts} +3 -3
- package/dist/{engines/pi/auth.js → harnesses/models/credentials.js} +3 -3
- package/dist/harnesses/models/environment.d.ts +48 -0
- package/dist/harnesses/models/environment.js +88 -0
- package/dist/harnesses/models/host.d.ts +30 -0
- package/dist/harnesses/models/host.js +97 -0
- package/dist/{engines/pi → harnesses/models}/login.d.ts +66 -70
- package/dist/harnesses/models/login.js +439 -0
- package/dist/harnesses/models/models.d.ts +84 -0
- package/dist/harnesses/models/models.js +197 -0
- package/dist/harnesses/pi-durable/agent.d.ts +42 -0
- package/dist/harnesses/pi-durable/agent.js +581 -0
- package/dist/harnesses/pi-durable/defaults.d.ts +28 -0
- package/dist/harnesses/pi-durable/defaults.js +26 -0
- package/dist/harnesses/pi-durable/define.d.ts +77 -0
- package/dist/harnesses/pi-durable/define.js +28 -0
- package/dist/harnesses/pi-durable/entries.d.ts +32 -0
- package/dist/harnesses/pi-durable/entries.js +126 -0
- package/dist/harnesses/pi-durable/events.d.ts +25 -0
- package/dist/harnesses/pi-durable/events.js +238 -0
- package/dist/harnesses/pi-durable/ids.d.ts +16 -0
- package/dist/harnesses/pi-durable/ids.js +55 -0
- package/dist/harnesses/pi-durable/messages.d.ts +41 -0
- package/dist/harnesses/pi-durable/messages.js +116 -0
- package/dist/harnesses/pi-durable/open.d.ts +95 -0
- package/dist/harnesses/pi-durable/open.js +330 -0
- package/dist/harnesses/pi-durable/reads.d.ts +30 -0
- package/dist/harnesses/pi-durable/reads.js +94 -0
- package/dist/harnesses/pi-durable/registry.d.ts +18 -0
- package/dist/harnesses/pi-durable/registry.js +56 -0
- package/dist/harnesses/pi-durable/release.d.ts +13 -0
- package/dist/harnesses/pi-durable/release.js +40 -0
- package/dist/harnesses/pi-durable/serve.d.ts +90 -0
- package/dist/harnesses/pi-durable/serve.js +186 -0
- package/dist/harnesses/pi-durable/sessions.d.ts +27 -0
- package/dist/harnesses/pi-durable/sessions.js +47 -0
- package/dist/harnesses/pi-durable/storage.d.ts +4 -0
- package/dist/harnesses/pi-durable/storage.js +49 -0
- package/dist/harnesses/pi-durable/stream.d.ts +20 -0
- package/dist/harnesses/pi-durable/stream.js +221 -0
- package/dist/harnesses/pi-durable/text.d.ts +30 -0
- package/dist/harnesses/pi-durable/text.js +292 -0
- package/dist/harnesses/pi-durable/wake.d.ts +11 -0
- package/dist/harnesses/pi-durable/wake.js +90 -0
- package/dist/http/client.d.ts +6 -0
- package/dist/http/client.js +256 -0
- package/dist/http/contract.d.ts +541 -0
- package/dist/http/contract.js +179 -0
- package/dist/http/server.d.ts +34 -0
- package/dist/http/server.js +194 -0
- package/dist/index.d.ts +19 -4
- package/dist/index.js +13 -5
- package/dist/lark.d.ts +2 -2
- package/dist/lark.js +2 -2
- package/dist/locked-file.d.ts +17 -0
- package/dist/{engines/pi/locked-file.js → locked-file.js} +16 -10
- package/dist/once.d.ts +6 -0
- package/dist/once.js +23 -0
- package/dist/paths.d.ts +36 -52
- package/dist/paths.js +66 -182
- package/dist/runtime.d.ts +25 -2
- package/dist/runtime.js +27 -0
- package/dist/scaffold/add-channel.d.ts +14 -27
- package/dist/scaffold/add-channel.js +82 -180
- package/dist/scaffold/init.d.ts +17 -18
- package/dist/scaffold/init.js +87 -99
- package/dist/scaffold/templates/SYSTEM.md +12 -0
- package/dist/scaffold/templates/env.example +4 -10
- package/dist/scaffold/templates/fastagent.config.ts +21 -33
- package/dist/scaffold/templates/gitignore +8 -1
- package/dist/scaffold/templates/skills/writing-great-skills/SKILL.md +1 -2
- package/dist/scaffold/templates.d.ts +9 -4
- package/dist/scaffold/templates.js +7 -5
- package/dist/scaffold/vendor-skill.d.ts +1 -4
- package/dist/scaffold/vendor-skill.js +5 -6
- package/dist/schedule/cron.d.ts +13 -0
- package/dist/schedule/cron.js +52 -0
- package/dist/schedule/eventbridge-cron.d.ts +17 -0
- package/dist/schedule/eventbridge-cron.js +88 -0
- package/dist/schedule/schedule.d.ts +23 -0
- package/dist/schedule/schedule.js +34 -0
- package/dist/schedule/scheduler.d.ts +34 -33
- package/dist/schedule/scheduler.js +251 -137
- package/dist/schedule/state.d.ts +4 -14
- package/dist/schedule/state.js +7 -7
- package/dist/schedule/wake-alarm.d.ts +22 -2
- package/dist/schedule/wake-alarm.js +66 -20
- package/dist/schedule/wakeups.d.ts +16 -15
- package/dist/schedule/wakeups.js +47 -45
- package/dist/service.d.ts +56 -169
- package/dist/service.js +91 -187
- package/dist/serving-command.d.ts +10 -0
- package/dist/serving-command.js +16 -0
- package/dist/sign-in-api.d.ts +147 -0
- package/dist/sign-in-api.js +9 -0
- package/dist/slack.d.ts +1 -1
- package/dist/slack.js +1 -1
- package/dist/{channels/kit/state.js → state-file.js} +6 -6
- package/dist/telegram.d.ts +1 -0
- package/dist/telegram.js +1 -0
- package/dist/tunnel.d.ts +3 -0
- package/dist/tunnel.js +14 -5
- package/dist/value-file.d.ts +40 -0
- package/dist/value-file.js +164 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.js +14 -1
- package/package.json +18 -28
- package/dist/agent.d.ts +0 -106
- package/dist/agent.js +0 -21
- package/dist/channels/control.d.ts +0 -31
- package/dist/channels/control.js +0 -329
- package/dist/channels/define-channel.d.ts +0 -39
- package/dist/channels/define-channel.js +0 -9
- package/dist/channels/feishu/context-buffer.d.ts +0 -35
- package/dist/channels/feishu/context-buffer.js +0 -65
- package/dist/channels/feishu/scaffold/channel.websocket.ts +0 -31
- package/dist/channels/http.d.ts +0 -23
- package/dist/channels/http.js +0 -57
- package/dist/channels/lark/scaffold/channel.websocket.ts +0 -31
- package/dist/channels/slack/context-buffer.d.ts +0 -23
- package/dist/channels/slack/context-buffer.js +0 -37
- package/dist/channels/sse.d.ts +0 -4
- package/dist/channels/sse.js +0 -66
- package/dist/cli/commands/chat.d.ts +0 -3
- package/dist/cli/commands/chat.js +0 -14
- package/dist/cli/commands/routine-run.d.ts +0 -6
- package/dist/cli/commands/routine-run.js +0 -46
- package/dist/cli/commands/routine.d.ts +0 -25
- package/dist/cli/commands/routine.js +0 -122
- package/dist/cli/commands/tool.d.ts +0 -1
- package/dist/cli/commands/tool.js +0 -57
- package/dist/collect.d.ts +0 -63
- package/dist/collect.js +0 -90
- package/dist/core.d.ts +0 -13
- package/dist/core.js +0 -15
- package/dist/engines/pi/agent-models.d.ts +0 -83
- package/dist/engines/pi/agent-models.js +0 -120
- package/dist/engines/pi/agent-session-factory.d.ts +0 -121
- package/dist/engines/pi/agent-session-factory.js +0 -535
- package/dist/engines/pi/chat.d.ts +0 -3
- package/dist/engines/pi/chat.js +0 -8
- package/dist/engines/pi/config.d.ts +0 -71
- package/dist/engines/pi/config.js +0 -199
- package/dist/engines/pi/create.d.ts +0 -170
- package/dist/engines/pi/create.js +0 -343
- package/dist/engines/pi/definition.d.ts +0 -74
- package/dist/engines/pi/definition.js +0 -236
- package/dist/engines/pi/entry-images.d.ts +0 -14
- package/dist/engines/pi/entry-images.js +0 -23
- package/dist/engines/pi/invoke-session.d.ts +0 -18
- package/dist/engines/pi/invoke-session.js +0 -403
- package/dist/engines/pi/locked-file.d.ts +0 -9
- package/dist/engines/pi/login.js +0 -331
- package/dist/engines/pi/machine.d.ts +0 -53
- package/dist/engines/pi/machine.js +0 -137
- package/dist/engines/pi/models.d.ts +0 -200
- package/dist/engines/pi/models.js +0 -533
- package/dist/engines/pi/open.d.ts +0 -180
- package/dist/engines/pi/open.js +0 -270
- package/dist/engines/pi/openai-account-models.d.ts +0 -35
- package/dist/engines/pi/openai-account-models.js +0 -116
- package/dist/engines/pi/report.d.ts +0 -18
- package/dist/engines/pi/report.js +0 -59
- package/dist/engines/pi/retry-event.d.ts +0 -6
- package/dist/engines/pi/retry-event.js +0 -15
- package/dist/engines/pi/service.d.ts +0 -9
- package/dist/engines/pi/service.js +0 -14
- package/dist/engines/pi/session-builder.d.ts +0 -13
- package/dist/engines/pi/session-builder.js +0 -117
- package/dist/engines/pi/session-control.d.ts +0 -77
- package/dist/engines/pi/session-control.js +0 -908
- package/dist/engines/pi/session-effects.d.ts +0 -14
- package/dist/engines/pi/session-effects.js +0 -30
- package/dist/engines/pi/session-inheritance.d.ts +0 -21
- package/dist/engines/pi/session-inheritance.js +0 -204
- package/dist/engines/pi/session-markers.d.ts +0 -49
- package/dist/engines/pi/session-markers.js +0 -60
- package/dist/engines/pi/session-settings.d.ts +0 -67
- package/dist/engines/pi/session-settings.js +0 -119
- package/dist/engines/pi/session-store.d.ts +0 -69
- package/dist/engines/pi/session-store.js +0 -430
- package/dist/engines/pi/tool-context.d.ts +0 -45
- package/dist/engines/pi/tool-context.js +0 -31
- package/dist/engines/pi/tool.d.ts +0 -99
- package/dist/engines/pi/tool.js +0 -118
- package/dist/engines/pi/turn-kit.d.ts +0 -92
- package/dist/engines/pi/turn-kit.js +0 -288
- package/dist/engines/pi/wake-tool.d.ts +0 -9
- package/dist/engines/pi/wake-tool.js +0 -92
- package/dist/loader.d.ts +0 -41
- package/dist/loader.js +0 -116
- package/dist/node.d.ts +0 -3
- package/dist/node.js +0 -4
- package/dist/observe.d.ts +0 -6
- package/dist/observe.js +0 -47
- package/dist/pi.d.ts +0 -25
- package/dist/pi.js +0 -15
- package/dist/scaffold/templates/APPEND_SYSTEM.md +0 -12
- package/dist/scaffold/templates/tools/fetch-url.ts +0 -25
- package/dist/schedule/discover.d.ts +0 -17
- package/dist/schedule/discover.js +0 -61
- package/dist/schedule/routine.d.ts +0 -43
- package/dist/schedule/routine.js +0 -32
- package/dist/schedule/run.d.ts +0 -55
- package/dist/schedule/run.js +0 -146
- package/dist/secrets-gate.d.ts +0 -32
- package/dist/secrets-gate.js +0 -33
- package/dist/session-remote.d.ts +0 -47
- package/dist/session-remote.js +0 -460
- package/dist/session.d.ts +0 -466
- package/dist/session.js +0 -57
- /package/dist/{channels/kit/state.d.ts → state-file.d.ts} +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Parse .env content into key → value (the dialect above; last occurrence of a key wins). */
|
|
2
|
+
export declare function parseEnvContent(content: string): Map<string, string>;
|
|
3
|
+
/**
|
|
4
|
+
* READ a value file without entering it: the values as data, never `process.env`. This is how code reasons about an
|
|
5
|
+
* environment OTHER than its own — `deploy` resolves configuration in the environment being deployed, which this
|
|
6
|
+
* file declares, and merging it into the running process would put the two environments in one bag. A missing file
|
|
7
|
+
* is no values, which is normal.
|
|
8
|
+
*/
|
|
9
|
+
export declare function loadEnvValues(file: string): Map<string, string>;
|
|
10
|
+
/** The agent's `.env` file: `<resolved secrets dir>/.env`. */
|
|
11
|
+
export declare function dotEnvPath(agentDir: string, env?: NodeJS.ProcessEnv): string;
|
|
12
|
+
/** The committable template: `<agentDir>/.secrets/.env.example`. */
|
|
13
|
+
export declare function envExamplePath(agentDir: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* What the agent's value file ({@link dotEnvPath}) adds to this process's environment, read and not entered: each
|
|
16
|
+
* variable the process does not hold, as entering the file would set it. An agent opened in a process that runs
|
|
17
|
+
* others too reads its own values through this; one that a command entered (`dev`, `start`) adds nothing here.
|
|
18
|
+
*/
|
|
19
|
+
export declare function agentValues(agentDir: string): Record<string, string>;
|
|
20
|
+
/** One variable to write: with a `value`, an active line; without one, a placeholder under its `hint`. */
|
|
21
|
+
export interface ValueEntry {
|
|
22
|
+
name: string;
|
|
23
|
+
value?: string;
|
|
24
|
+
hint?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ValueWriteResult {
|
|
27
|
+
/** Generated values written as active `NAME=value` lines. */
|
|
28
|
+
written: string[];
|
|
29
|
+
/** Vars already present with a non-empty active value; left untouched and omitted from next steps. */
|
|
30
|
+
alreadySet: string[];
|
|
31
|
+
/** Set when the secrets dir is an operator-chosen one (`FASTAGENT_SECRETS_DIR`) carrying no `.gitignore`. */
|
|
32
|
+
unprotectedSecretsDir?: string;
|
|
33
|
+
}
|
|
34
|
+
/** What a command says when it wrote a secret into a secrets directory fastagent does not own and git may track. */
|
|
35
|
+
export declare function unprotectedSecretsNote(dir: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Write `entries` into the selected environment's value file, under a `# --- <section> ---` line. A name with a
|
|
38
|
+
* non-empty active value is kept unless `overwrite` names it.
|
|
39
|
+
*/
|
|
40
|
+
export declare function writeValues(dir: string, section: string, entries: readonly ValueEntry[], overwrite?: readonly string[]): Promise<ValueWriteResult>;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The selected environment's value file (`.secrets/.env`, or `.secrets/production/.env` for a deployment), read and
|
|
3
|
+
* written; entering it into `process.env` is env.ts's. Read as data: what it declares, and what it adds to an agent's
|
|
4
|
+
* environment. Written: what a command generates (a channel's secret, the Agent API's key) goes in as an active
|
|
5
|
+
* `NAME=value` line, a value already set stays, and the secrets directory fastagent made carries its own `.gitignore`.
|
|
6
|
+
*/
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
8
|
+
import { appendFile, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
9
|
+
import { dirname, join } from "node:path";
|
|
10
|
+
import { SECRETS_DIRNAME, SECRET_FILE_MODE, exists, resolveSecretsDir } from "./paths.js";
|
|
11
|
+
import { baseTemplate } from "./scaffold/templates.js";
|
|
12
|
+
/** Parse .env content into key → value (the dialect above; last occurrence of a key wins). */
|
|
13
|
+
export function parseEnvContent(content) {
|
|
14
|
+
const parsed = new Map();
|
|
15
|
+
for (const raw of content.split("\n")) {
|
|
16
|
+
const line = raw.trim();
|
|
17
|
+
if (!line || line.startsWith("#"))
|
|
18
|
+
continue;
|
|
19
|
+
const eq = line.indexOf("=");
|
|
20
|
+
if (eq < 1)
|
|
21
|
+
continue; // no `=`, or an empty key
|
|
22
|
+
const key = line.slice(0, eq).trim();
|
|
23
|
+
let value = line.slice(eq + 1).trim();
|
|
24
|
+
const quote = value[0];
|
|
25
|
+
if ((quote === '"' || quote === "'") && value.at(-1) === quote)
|
|
26
|
+
value = value.slice(1, -1);
|
|
27
|
+
parsed.set(key, value); // in-file: last occurrence wins (Map overwrite)
|
|
28
|
+
}
|
|
29
|
+
return parsed;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* READ a value file without entering it: the values as data, never `process.env`. This is how code reasons about an
|
|
33
|
+
* environment OTHER than its own — `deploy` resolves configuration in the environment being deployed, which this
|
|
34
|
+
* file declares, and merging it into the running process would put the two environments in one bag. A missing file
|
|
35
|
+
* is no values, which is normal.
|
|
36
|
+
*/
|
|
37
|
+
export function loadEnvValues(file) {
|
|
38
|
+
try {
|
|
39
|
+
return parseEnvContent(readFileSync(file, "utf8"));
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (error.code === "ENOENT")
|
|
43
|
+
return new Map();
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** The agent's `.env` file: `<resolved secrets dir>/.env`. */
|
|
48
|
+
export function dotEnvPath(agentDir, env = process.env) {
|
|
49
|
+
return join(resolveSecretsDir(agentDir, env), ".env");
|
|
50
|
+
}
|
|
51
|
+
/** The committable template: `<agentDir>/.secrets/.env.example`. */
|
|
52
|
+
export function envExamplePath(agentDir) {
|
|
53
|
+
return join(agentDir, SECRETS_DIRNAME, ".env.example");
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* What the agent's value file ({@link dotEnvPath}) adds to this process's environment, read and not entered: each
|
|
57
|
+
* variable the process does not hold, as entering the file would set it. An agent opened in a process that runs
|
|
58
|
+
* others too reads its own values through this; one that a command entered (`dev`, `start`) adds nothing here.
|
|
59
|
+
*/
|
|
60
|
+
export function agentValues(agentDir) {
|
|
61
|
+
const values = {};
|
|
62
|
+
for (const [key, value] of loadEnvValues(dotEnvPath(agentDir)))
|
|
63
|
+
if (!(key in process.env))
|
|
64
|
+
values[key] = value;
|
|
65
|
+
return values;
|
|
66
|
+
}
|
|
67
|
+
/** What a command says when it wrote a secret into a secrets directory fastagent does not own and git may track. */
|
|
68
|
+
export function unprotectedSecretsNote(dir) {
|
|
69
|
+
return (`${dir} (FASTAGENT_SECRETS_DIR) now holds a secret and has no .gitignore — that directory is yours, so ` +
|
|
70
|
+
"fastagent will not write one into it. Make sure git does not track what is in there.");
|
|
71
|
+
}
|
|
72
|
+
/** Whether `.env` content carries a non-empty ACTIVE value for `name`. */
|
|
73
|
+
function hasActiveEnvValue(content, name) {
|
|
74
|
+
return (parseEnvContent(content).get(name)?.trim() ?? "") !== "";
|
|
75
|
+
}
|
|
76
|
+
function mentionsEnvName(content, name) {
|
|
77
|
+
return content.split("\n").some((line) => new RegExp(`^\\s*#?\\s*${name}\\s*=`).test(line));
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Write `entries` into the selected environment's value file, under a `# --- <section> ---` line. A name with a
|
|
81
|
+
* non-empty active value is kept unless `overwrite` names it.
|
|
82
|
+
*/
|
|
83
|
+
export async function writeValues(dir, section, entries, overwrite = []) {
|
|
84
|
+
const file = dotEnvPath(dir);
|
|
85
|
+
const secretsDir = dirname(file);
|
|
86
|
+
await mkdir(secretsDir, { recursive: true });
|
|
87
|
+
// THE one exception to "fastagent has no opinion about git": the directory it writes secrets into carries its own
|
|
88
|
+
// `.gitignore`.
|
|
89
|
+
const owned = secretsDir === join(dir, SECRETS_DIRNAME) || secretsDir === join(dir, SECRETS_DIRNAME, "production");
|
|
90
|
+
let unprotectedSecretsDir;
|
|
91
|
+
if (owned) {
|
|
92
|
+
// Only EEXIST is tolerable (already protected, or a concurrent writer).
|
|
93
|
+
await writeFile(join(secretsDir, ".gitignore"), baseTemplate("secrets.gitignore"), { flag: "wx" }).catch((e) => {
|
|
94
|
+
if (e.code !== "EEXIST")
|
|
95
|
+
throw e;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
else if (!(await exists(join(secretsDir, ".gitignore")))) {
|
|
99
|
+
unprotectedSecretsDir = secretsDir;
|
|
100
|
+
}
|
|
101
|
+
let current = "";
|
|
102
|
+
try {
|
|
103
|
+
current = await readFile(file, "utf8");
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
if (e.code !== "ENOENT")
|
|
107
|
+
throw e;
|
|
108
|
+
}
|
|
109
|
+
const alreadySet = entries
|
|
110
|
+
.filter((e) => !overwrite.includes(e.name) && hasActiveEnvValue(current, e.name))
|
|
111
|
+
.map((e) => e.name);
|
|
112
|
+
const lines = [];
|
|
113
|
+
const written = [];
|
|
114
|
+
const contentLines = current.split("\n");
|
|
115
|
+
let replacedInPlace = false;
|
|
116
|
+
for (const e of entries) {
|
|
117
|
+
if (alreadySet.includes(e.name))
|
|
118
|
+
continue;
|
|
119
|
+
if (e.value !== undefined) {
|
|
120
|
+
// An ACTIVE but EMPTY assignment already in the file (an uncommented, unfilled placeholder from `cp
|
|
121
|
+
// .env.example .env`) must be replaced IN PLACE.
|
|
122
|
+
let idx = -1;
|
|
123
|
+
for (let i = contentLines.length - 1; i >= 0; i--) {
|
|
124
|
+
if (parseEnvContent(contentLines[i]).has(e.name)) {
|
|
125
|
+
idx = i;
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (idx >= 0) {
|
|
130
|
+
contentLines[idx] = `${e.name}=${e.value}`;
|
|
131
|
+
replacedInPlace = true;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
lines.push(`${e.name}=${e.value}`);
|
|
135
|
+
}
|
|
136
|
+
written.push(e.name);
|
|
137
|
+
}
|
|
138
|
+
else if (!mentionsEnvName(current, e.name)) {
|
|
139
|
+
// Hint above, never inline after `=` (this IS the file loadDotEnv reads).
|
|
140
|
+
lines.push(...(e.hint === undefined ? [] : [`# ${e.hint}`]), `# ${e.name}=`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// 0600 on the file this call CREATES, and nothing at all about one it did not: a `.env` the operator made with
|
|
144
|
+
// `cp .secrets/.env.example .secrets/.env` carries the mode that command gave it, and re-deciding it would be
|
|
145
|
+
// fastagent changing the permissions of a file it does not own.
|
|
146
|
+
const secret = { mode: SECRET_FILE_MODE };
|
|
147
|
+
if (replacedInPlace) {
|
|
148
|
+
current = contentLines.join("\n");
|
|
149
|
+
await writeFile(file, current, secret);
|
|
150
|
+
}
|
|
151
|
+
if (lines.length > 0) {
|
|
152
|
+
const marker = `# --- ${section} ---`;
|
|
153
|
+
if (current.includes(marker)) {
|
|
154
|
+
// A marker already present (e.g. a .env copied from .env.example) — slot the new lines under it instead of
|
|
155
|
+
// orphaning them at the end of the file.
|
|
156
|
+
await writeFile(file, current.replace(marker, `${marker}\n${lines.join("\n")}`), secret);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
const prefix = current === "" ? "" : current.endsWith("\n") ? "\n" : "\n\n";
|
|
160
|
+
await appendFile(file, `${prefix}${marker}\n${lines.join("\n")}\n`, secret);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return { written, alreadySet, ...(unprotectedSecretsDir === undefined ? {} : { unprotectedSecretsDir }) };
|
|
164
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -3,3 +3,8 @@
|
|
|
3
3
|
* scaffolded dependency range (`^${version}`), so `init` must never fall back and scaffold an uninstallable `^0.0.0`.
|
|
4
4
|
*/
|
|
5
5
|
export declare function fastagentVersion(): Promise<string>;
|
|
6
|
+
/** This build's version, and the exact versions of the harness packages it runs, for a new agent to depend on. */
|
|
7
|
+
export declare function fastagentBuild(): Promise<{
|
|
8
|
+
version: string;
|
|
9
|
+
harness: Record<string, string>;
|
|
10
|
+
}>;
|
package/dist/version.js
CHANGED
|
@@ -5,9 +5,22 @@ import { fileURLToPath } from "node:url";
|
|
|
5
5
|
* scaffolded dependency range (`^${version}`), so `init` must never fall back and scaffold an uninstallable `^0.0.0`.
|
|
6
6
|
*/
|
|
7
7
|
export async function fastagentVersion() {
|
|
8
|
+
return (await fastagentBuild()).version;
|
|
9
|
+
}
|
|
10
|
+
/** The packages an agent's code imports besides fastagent: the harness its tools and providers are written for. */
|
|
11
|
+
const HARNESS_PACKAGES = ["@earendil-works/pi-durable", "@earendil-works/pi-ai"];
|
|
12
|
+
/** This build's version, and the exact versions of the harness packages it runs, for a new agent to depend on. */
|
|
13
|
+
export async function fastagentBuild() {
|
|
8
14
|
const pkgPath = fileURLToPath(new URL("../package.json", import.meta.url));
|
|
9
15
|
const pkg = JSON.parse(await readFile(pkgPath, "utf8"));
|
|
10
16
|
if (typeof pkg.version !== "string" || pkg.version === "")
|
|
11
17
|
throw new Error(`no version in ${pkgPath}`);
|
|
12
|
-
|
|
18
|
+
const harness = {};
|
|
19
|
+
for (const name of HARNESS_PACKAGES) {
|
|
20
|
+
const range = pkg.dependencies?.[name];
|
|
21
|
+
if (range === undefined)
|
|
22
|
+
throw new Error(`${pkgPath} does not depend on ${name}`);
|
|
23
|
+
harness[name] = range;
|
|
24
|
+
}
|
|
25
|
+
return { version: pkg.version, harness };
|
|
13
26
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastagent-sh/fastagent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "Vibe first. Then FastAgent: turn a local agent directory into a live service in your app, on Telegram, Slack, Feishu, or behind any channel.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"type": "module",
|
|
30
30
|
"sideEffects": false,
|
|
31
31
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
32
|
+
"node": ">=24.15.0"
|
|
33
33
|
},
|
|
34
34
|
"main": "./dist/index.js",
|
|
35
35
|
"types": "./dist/index.d.ts",
|
|
@@ -38,21 +38,9 @@
|
|
|
38
38
|
"types": "./dist/index.d.ts",
|
|
39
39
|
"default": "./dist/index.js"
|
|
40
40
|
},
|
|
41
|
-
"./
|
|
42
|
-
"types": "./dist/
|
|
43
|
-
"default": "./dist/
|
|
44
|
-
},
|
|
45
|
-
"./node": {
|
|
46
|
-
"types": "./dist/node.d.ts",
|
|
47
|
-
"default": "./dist/node.js"
|
|
48
|
-
},
|
|
49
|
-
"./session": {
|
|
50
|
-
"types": "./dist/session.d.ts",
|
|
51
|
-
"default": "./dist/session.js"
|
|
52
|
-
},
|
|
53
|
-
"./pi": {
|
|
54
|
-
"types": "./dist/pi.d.ts",
|
|
55
|
-
"default": "./dist/pi.js"
|
|
41
|
+
"./client": {
|
|
42
|
+
"types": "./dist/client.d.ts",
|
|
43
|
+
"default": "./dist/client.js"
|
|
56
44
|
},
|
|
57
45
|
"./telegram": {
|
|
58
46
|
"types": "./dist/telegram.d.ts",
|
|
@@ -101,31 +89,33 @@
|
|
|
101
89
|
},
|
|
102
90
|
"dependencies": {
|
|
103
91
|
"@clack/prompts": "^1.6.0",
|
|
104
|
-
"@earendil-works/
|
|
105
|
-
"@earendil-works/pi-ai": "
|
|
106
|
-
"@earendil-works/pi-
|
|
107
|
-
"@
|
|
92
|
+
"@earendil-works/chord": "1.3.0",
|
|
93
|
+
"@earendil-works/pi-ai": "1.3.0",
|
|
94
|
+
"@earendil-works/pi-durable": "1.3.0",
|
|
95
|
+
"@effect/platform-bun": "^4.0.7",
|
|
96
|
+
"@effect/platform-node": "^4.0.7",
|
|
108
97
|
"@larksuiteoapi/node-sdk": "^1.71.1",
|
|
109
98
|
"@smithy/signature-v4": "^5.7.4",
|
|
110
99
|
"chokidar": "^5.0.0",
|
|
111
100
|
"commander": "^15.0.0",
|
|
112
101
|
"croner": "^10.0.1",
|
|
113
|
-
"effect": "4.0.
|
|
102
|
+
"effect": "^4.0.7",
|
|
114
103
|
"giget": "^3.3.0",
|
|
115
|
-
"ignore": "^7.0.
|
|
104
|
+
"ignore": "^7.0.12",
|
|
116
105
|
"proper-lockfile": "^4.1.2",
|
|
117
106
|
"undici": "^8.6.0",
|
|
118
|
-
"
|
|
107
|
+
"yaml": "^2.9.0"
|
|
119
108
|
},
|
|
120
109
|
"devDependencies": {
|
|
121
|
-
"@biomejs/biome": "^2.5.
|
|
110
|
+
"@biomejs/biome": "^2.5.15",
|
|
111
|
+
"@earendil-works/pi-coding-agent": "1.3.0",
|
|
112
|
+
"@hono/node-server": "^2.1.4",
|
|
122
113
|
"@types/express": "^5.0.6",
|
|
123
114
|
"@types/proper-lockfile": "^4.1.4",
|
|
124
115
|
"express": "^5.2.1",
|
|
125
116
|
"fastify": "^5.12.5",
|
|
126
|
-
"knip": "^6.
|
|
117
|
+
"knip": "^6.41.0",
|
|
127
118
|
"typescript": "^7.0.2",
|
|
128
|
-
"vitest": "^5.0.
|
|
129
|
-
"yaml": "^2.9.0"
|
|
119
|
+
"vitest": "^5.0.3"
|
|
130
120
|
}
|
|
131
121
|
}
|
package/dist/agent.d.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent Handler protocol v0.1 — the engine-neutral contract (docs/SPEC.md). Pure types: importing an engine here is
|
|
3
|
-
* forbidden (`@earendil-works/pi-*` may only appear under engines/).
|
|
4
|
-
*/
|
|
5
|
-
export type Json = null | boolean | number | string | Json[] | {
|
|
6
|
-
[k: string]: Json;
|
|
7
|
-
};
|
|
8
|
-
/** Base64-encoded image reference. */
|
|
9
|
-
export interface ImageRef {
|
|
10
|
-
mimeType: string;
|
|
11
|
-
data: string;
|
|
12
|
-
}
|
|
13
|
-
export interface Prompt {
|
|
14
|
-
text: string;
|
|
15
|
-
images?: ImageRef[];
|
|
16
|
-
}
|
|
17
|
-
export interface Scope {
|
|
18
|
-
/** Opaque session anchor: turns of the same logical conversation MUST reuse the same value. */
|
|
19
|
-
session: string;
|
|
20
|
-
/**
|
|
21
|
-
* EXTENSION (SPEC §8): the session this one branched from — a channel sets it when the place it is invoking for was
|
|
22
|
-
* born out of another place (a thread opened in a room).
|
|
23
|
-
*/
|
|
24
|
-
parentSession?: string;
|
|
25
|
-
/**
|
|
26
|
-
* EXTENSION (SPEC §8): opaque markers that MAY locate the branch point inside `parentSession` — e.g. platform
|
|
27
|
-
* message ids its transcript embeds.
|
|
28
|
-
*/
|
|
29
|
-
branchHints?: string[];
|
|
30
|
-
}
|
|
31
|
-
export type AgentEvent = {
|
|
32
|
-
type: "text";
|
|
33
|
-
delta: string;
|
|
34
|
-
}
|
|
35
|
-
/** Model reasoning, streamed live. */
|
|
36
|
-
| {
|
|
37
|
-
type: "thinking";
|
|
38
|
-
delta: string;
|
|
39
|
-
} | {
|
|
40
|
-
type: "tool_started";
|
|
41
|
-
id: string;
|
|
42
|
-
name: string;
|
|
43
|
-
args: Json;
|
|
44
|
-
} | {
|
|
45
|
-
type: "tool_ended";
|
|
46
|
-
id: string;
|
|
47
|
-
isError: boolean;
|
|
48
|
-
content: Json;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Advisory, non-terminal (engines MAY emit it): the running tool `id`'s current status, one line, replacing the last.
|
|
52
|
-
* It may be a line of the tool's output so far (trust it like `tool_ended.content`), never the whole output;
|
|
53
|
-
* untruncated, so a consumer that shows it clips it.
|
|
54
|
-
*/
|
|
55
|
-
| {
|
|
56
|
-
type: "tool_progress";
|
|
57
|
-
id: string;
|
|
58
|
-
text: string;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Advisory, non-terminal (engines MAY emit it): a transient internal failure scheduled a retry with backoff — the
|
|
62
|
-
* turn is still alive.
|
|
63
|
-
*/
|
|
64
|
-
| {
|
|
65
|
-
type: "retrying";
|
|
66
|
-
attempt: number;
|
|
67
|
-
maxAttempts: number;
|
|
68
|
-
delayMs: number;
|
|
69
|
-
reason: string;
|
|
70
|
-
}
|
|
71
|
-
/** Terminal: success. */
|
|
72
|
-
| {
|
|
73
|
-
type: "completed";
|
|
74
|
-
data?: Json;
|
|
75
|
-
}
|
|
76
|
-
/** Terminal: failure. */
|
|
77
|
-
| {
|
|
78
|
-
type: "failed";
|
|
79
|
-
details: string;
|
|
80
|
-
retryable: boolean;
|
|
81
|
-
code?: string;
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* The `failed.code` (SPEC §8 failure subdivision) the reference engine sets when a turn is rejected because the
|
|
85
|
-
* session is BUSY.
|
|
86
|
-
*/
|
|
87
|
-
export declare const SESSION_BUSY_CODE = "session_busy";
|
|
88
|
-
/**
|
|
89
|
-
* The `failed.code` set when a run was DELIBERATELY stopped. A channel MAY render cancellation distinctly from an
|
|
90
|
-
* error, and MUST treat it as a settled outcome — durable turn-intent cleanup included — so a deliberate stop is
|
|
91
|
-
* never replayed as a fresh turn on restart.
|
|
92
|
-
*/
|
|
93
|
-
export declare const ABORTED_CODE = "aborted";
|
|
94
|
-
/**
|
|
95
|
-
* The `failed.code` set when a turn has no model to run on: its session records none of its own, and the agent sets
|
|
96
|
-
* no default. Not retryable as is: giving the session a model (session control's `update({ model })`) or the agent a
|
|
97
|
-
* default is what changes the answer.
|
|
98
|
-
*/
|
|
99
|
-
export declare const MISSING_MODEL_CODE = "missing_model";
|
|
100
|
-
/**
|
|
101
|
-
* One turn = one invoke, returning a single async event stream. The stream MUST terminate with exactly one of
|
|
102
|
-
* `completed` / `failed`, or be cancelled by the caller (no terminal event).
|
|
103
|
-
*/
|
|
104
|
-
export interface Agent {
|
|
105
|
-
invoke(scope: Scope, prompt: Prompt): AsyncIterable<AgentEvent>;
|
|
106
|
-
}
|
package/dist/agent.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent Handler protocol v0.1 — the engine-neutral contract (docs/SPEC.md). Pure types: importing an engine here is
|
|
3
|
-
* forbidden (`@earendil-works/pi-*` may only appear under engines/).
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* The `failed.code` (SPEC §8 failure subdivision) the reference engine sets when a turn is rejected because the
|
|
7
|
-
* session is BUSY.
|
|
8
|
-
*/
|
|
9
|
-
export const SESSION_BUSY_CODE = "session_busy";
|
|
10
|
-
/**
|
|
11
|
-
* The `failed.code` set when a run was DELIBERATELY stopped. A channel MAY render cancellation distinctly from an
|
|
12
|
-
* error, and MUST treat it as a settled outcome — durable turn-intent cleanup included — so a deliberate stop is
|
|
13
|
-
* never replayed as a fresh turn on restart.
|
|
14
|
-
*/
|
|
15
|
-
export const ABORTED_CODE = "aborted";
|
|
16
|
-
/**
|
|
17
|
-
* The `failed.code` set when a turn has no model to run on: its session records none of its own, and the agent sets
|
|
18
|
-
* no default. Not retryable as is: giving the session a model (session control's `update({ model })`) or the agent a
|
|
19
|
-
* default is what changes the answer.
|
|
20
|
-
*/
|
|
21
|
-
export const MISSING_MODEL_CODE = "missing_model";
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { type SessionControl, type SessionEvent } from "../session.ts";
|
|
2
|
-
import { type PrefixMount } from "./serve.ts";
|
|
3
|
-
/** The prefix this plane OWNS: everything under it is the plane's to answer. */
|
|
4
|
-
export declare const CONTROL_PREFIX = "/control";
|
|
5
|
-
/**
|
|
6
|
-
* A plane handler: the request, its URL (for query parameters), and the session id the path named (`""` where the
|
|
7
|
-
* path has none).
|
|
8
|
-
*/
|
|
9
|
-
type PlaneHandler = (req: Request, url: URL, session: string) => Response | Promise<Response>;
|
|
10
|
-
/**
|
|
11
|
-
* The plane's route table: `"<METHOD> <path>"` → handler, where at most one path segment is {@link SESSION_SEGMENT}.
|
|
12
|
-
*/
|
|
13
|
-
export type PlaneRoutes = Record<string, PlaneHandler>;
|
|
14
|
-
/** The SSE payload: one control-plane event in its transport envelope. */
|
|
15
|
-
export interface WireEvent {
|
|
16
|
-
sessionId: string;
|
|
17
|
-
/** Serving-process incarnation (per `createControlPlane` call). */
|
|
18
|
-
epoch: string;
|
|
19
|
-
/** Per-connection monotonic counter. */
|
|
20
|
-
seq: number;
|
|
21
|
-
event: SessionEvent;
|
|
22
|
-
}
|
|
23
|
-
/** Create the control plane as a mountable prefix owner. */
|
|
24
|
-
export declare function createControlPlane(control: SessionControl): PrefixMount;
|
|
25
|
-
/**
|
|
26
|
-
* Mount a plane route table as a {@link PrefixMount} — the plane owns a PREFIX, while a route table is a set of paths,
|
|
27
|
-
* at most one segment of which is a session id.
|
|
28
|
-
*/
|
|
29
|
-
export declare function mountControlPlane(routes: PlaneRoutes): PrefixMount;
|
|
30
|
-
export declare function controlPlaneRoutes(control: SessionControl): PlaneRoutes;
|
|
31
|
-
export {};
|