@fastagent-sh/fastagent 0.24.3 → 0.25.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 +53 -82
- package/dist/agent-api.d.ts +452 -0
- package/dist/agent-api.js +201 -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 +77 -0
- package/dist/authoring.js +238 -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 +115 -63
- package/dist/cli/auth-view.d.ts +10 -3
- package/dist/cli/auth-view.js +8 -6
- package/dist/cli/box-login.d.ts +17 -7
- package/dist/cli/box-login.js +46 -12
- package/dist/cli/commands/add.d.ts +15 -4
- package/dist/cli/commands/add.js +252 -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 +190 -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 +131 -16
- package/dist/cli/commands/login.d.ts +31 -2
- package/dist/cli/commands/login.js +413 -64
- 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 +3 -2
- package/dist/cli/login-relay.js +18 -6
- 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 +68 -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 +217 -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 +222 -201
- 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 +51 -26
- package/dist/effect-port.d.ts +4 -4
- package/dist/effect-port.js +4 -4
- 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 +50 -0
- package/dist/environment/mise.js +268 -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 +43 -0
- package/dist/harnesses/models/environment.js +82 -0
- package/dist/{engines/pi → harnesses/models}/login.d.ts +57 -26
- package/dist/{engines/pi → harnesses/models}/login.js +187 -79
- package/dist/harnesses/models/models.d.ts +83 -0
- package/dist/harnesses/models/models.js +158 -0
- package/dist/harnesses/pi-durable/agent.d.ts +42 -0
- package/dist/harnesses/pi-durable/agent.js +579 -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 +88 -0
- package/dist/harnesses/pi-durable/open.js +329 -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 +80 -0
- package/dist/harnesses/pi-durable/serve.js +156 -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 +4 -0
- package/dist/harnesses/pi-durable/wake.js +81 -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 +17 -4
- package/dist/index.js +10 -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/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 +12 -4
- package/dist/value-file.d.ts +21 -0
- package/dist/value-file.js +108 -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 -517
- 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/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 -83
- package/dist/engines/pi/turn-kit.js +0 -275
- 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
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
/** `fastagent destroy agentcore [
|
|
1
|
+
/** `fastagent destroy agentcore [agent]`: remove every AWS resource the deploy created. */
|
|
2
2
|
import { basename, resolve } from "node:path";
|
|
3
3
|
import { destroyAgentcoreDeployment } from "../../deploy/agentcore/destroy.js";
|
|
4
4
|
import { agentcoreName } from "../../deploy/agentcore/plan.js";
|
|
5
5
|
import { awsRunner } from "../../deploy/runner.js";
|
|
6
6
|
import { enterAgentEnv } from "../../env.js";
|
|
7
|
-
import {
|
|
7
|
+
import { selectAgentEnvironment } from "../../paths.js";
|
|
8
|
+
import { agentDirOrExit, failStartup, failUsage } from "../fail.js";
|
|
8
9
|
export async function runDestroy(host, dirArg, opts) {
|
|
9
10
|
// The host argument is DISPATCHED here, as in runLogs. In practice commander rejects anything else first
|
|
10
11
|
// (the spec declares `choices`), so what the operator reads is its message plus the spec's notes, which name
|
|
@@ -12,10 +13,11 @@ export async function runDestroy(host, dirArg, opts) {
|
|
|
12
13
|
// treated as agentcore.
|
|
13
14
|
if (host !== "agentcore")
|
|
14
15
|
failUsage(`destroy: unsupported host "${host}"`);
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
16
|
+
const agentDir = agentDirOrExit(resolve(dirArg));
|
|
17
|
+
selectAgentEnvironment("production");
|
|
18
|
+
enterAgentEnv(agentDir);
|
|
19
|
+
const name = agentcoreName(basename(agentDir));
|
|
20
|
+
const outcome = await destroyAgentcoreDeployment({ name, run: opts.run === true }, awsRunner(agentDir), (message) => console.error(`[fastagent] destroy: ${message}`));
|
|
19
21
|
if (!outcome.ok) {
|
|
20
22
|
// THE WHOLE PICTURE, before the gate: a half-finished teardown is exactly when an operator needs to know
|
|
21
23
|
// what is out there, what is already gone, and what the retry still has to reach.
|
|
@@ -5,8 +5,6 @@ export interface DevOptions {
|
|
|
5
5
|
/** false ⇔ `--no-watch`. */
|
|
6
6
|
watch?: boolean;
|
|
7
7
|
tunnel?: boolean;
|
|
8
|
-
/** false ⇔ `--no-invoke`: withhold `POST /invoke` for THIS run (`http.invoke` is the persistent form). */
|
|
9
|
-
invoke?: boolean;
|
|
10
8
|
/** false ⇔ `--no-input`. */
|
|
11
9
|
input?: boolean;
|
|
12
10
|
}
|
package/dist/cli/commands/dev.js
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
* `fastagent dev`: a SUPERVISOR that spawns a worker (this command with FASTAGENT_DEV_WORKER set) to assemble + serve,
|
|
3
3
|
* restarting it on agent edits.
|
|
4
4
|
*/
|
|
5
|
-
import { runDevSupervisor } from "../../dev-supervisor.js";
|
|
5
|
+
import { listenForRestart, runDevSupervisor } from "../../dev-supervisor.js";
|
|
6
6
|
import { setLogLevel } from "../../log.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { markDevServe } from "../../serving-command.js";
|
|
8
|
+
import { selectAgentEnvironment } from "../../paths.js";
|
|
9
|
+
import { openServing } from "../../harnesses/pi-durable/serve.js";
|
|
10
|
+
import { DEFAULT_HTTP_PORT, serveAgent } from "../../service.js";
|
|
10
11
|
import { failStartup } from "../fail.js";
|
|
11
|
-
import { assertTunnelBindable, cliMountOptions, serveService
|
|
12
|
+
import { assertTunnelBindable, cliMountOptions, serveService } from "../serve.js";
|
|
12
13
|
import { enterAgentCommand, parseBind, parsePort, reportAssembly } from "../shared.js";
|
|
13
14
|
/**
|
|
14
15
|
* `dev` binds loopback unless `--bind` says otherwise: a dev serve carries the agent's full tool authority and lands on
|
|
@@ -17,32 +18,32 @@ import { enterAgentCommand, parseBind, parsePort, reportAssembly } from "../shar
|
|
|
17
18
|
const DEV_BIND = "127.0.0.1";
|
|
18
19
|
export async function runDev(dirArg, opts) {
|
|
19
20
|
setLogLevel("debug"); // dev posture: verbose, includes the debug turn trace (content) — supervisor and worker both
|
|
21
|
+
selectAgentEnvironment("dev");
|
|
22
|
+
markDevServe(); // the worker inherits both selections
|
|
20
23
|
const isWorker = process.env.FASTAGENT_DEV_WORKER === "1";
|
|
24
|
+
// First, so a restart asked for while the worker is still assembling is heard: with nothing running it stops at once.
|
|
25
|
+
if (isWorker)
|
|
26
|
+
process.on("message", listenForRestart(() => process.kill(process.pid, "SIGTERM")));
|
|
21
27
|
// The model is picked ONCE, in the parent process (a TTY; watch and --no-watch both).
|
|
22
|
-
const
|
|
28
|
+
const { agentDir, modelSpec } = await enterAgentCommand(dirArg, { ...opts, input: isWorker ? false : opts.input });
|
|
23
29
|
if (isWorker || opts.watch === false) {
|
|
24
|
-
await serveOnce(
|
|
30
|
+
await serveOnce(agentDir, modelSpec, opts);
|
|
25
31
|
return;
|
|
26
32
|
}
|
|
27
33
|
parsePort(opts.port, "--port", "flag"); // flag-shape checks before spawning
|
|
28
34
|
// The --bind/--tunnel conflict is decidable from flags alone: refuse it HERE, before a worker and a tunnel exist.
|
|
29
35
|
assertTunnelBindable(parseBind(opts.bind), opts.tunnel ?? false);
|
|
30
|
-
await runDevSupervisor(
|
|
36
|
+
await runDevSupervisor(agentDir, { tunnel: opts.tunnel ?? false });
|
|
31
37
|
}
|
|
32
38
|
/** Assemble the agent and serve it once (the dev worker; also the --no-watch path). */
|
|
33
|
-
async function serveOnce(
|
|
39
|
+
async function serveOnce(agentDir, modelSpec, opts) {
|
|
34
40
|
const portFlag = parsePort(opts.port, "--port", "flag");
|
|
35
41
|
const host = parseBind(opts.bind) ?? DEV_BIND;
|
|
36
42
|
const tunnel = opts.tunnel ?? false;
|
|
37
43
|
assertTunnelBindable(host, tunnel);
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
await reportAssembly({ ...a, modelSpec: placement.modelSpec }, { beforeModel: [["config", a.configPath ?? "(none)"]] });
|
|
44
|
-
// The SAME assembly an embedder gets from `createAgentService` — channels, control plane, schedules, long
|
|
45
|
-
// connections.
|
|
46
|
-
const service = await mountAgentService(withRunOverrides(a, opts), cliMountOptions(logAgentLoop)).catch(failStartup);
|
|
47
|
-
serveService(service, { port: portFlag ?? a.config.http?.port ?? DEFAULT_HTTP_PORT, host }, { tunnel, agentDir: a.agentDir, stateRoot: a.stateRoot });
|
|
44
|
+
const opened = await openServing(agentDir, { model: modelSpec }).catch(failStartup);
|
|
45
|
+
await reportAssembly(opened, modelSpec);
|
|
46
|
+
const { config } = opened.definition;
|
|
47
|
+
const service = await serveAgent(opened, cliMountOptions(config)).catch(failStartup);
|
|
48
|
+
serveService(service, { port: portFlag ?? config.http?.port ?? DEFAULT_HTTP_PORT, host }, { tunnel, agentDir, stateRoot: opened.stateRoot, config });
|
|
48
49
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function runEnvAdd(args: string[]): Promise<void>;
|
|
2
|
+
export declare function runEnvRemove(args: string[]): Promise<void>;
|
|
3
|
+
export declare function runEnvList(opts?: {
|
|
4
|
+
json?: boolean;
|
|
5
|
+
}): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Install what context.json declares here, mise first when the agent has none (into its package.json): every package at
|
|
8
|
+
* the newest release its version allows, a newer one where one is out. Apt packages are the image's: one missing here
|
|
9
|
+
* is said, with how.
|
|
10
|
+
*/
|
|
11
|
+
export declare function runEnvInstall(): Promise<void>;
|
|
12
|
+
export declare function runEnvExec(command: string[]): Promise<void>;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `fastagent env add|remove|list|install|exec`: the agent's environment, declared under `environment` in context.json
|
|
3
|
+
* and installed by the agent's own mise (docs/design/agent-service.md §4), in the agent directory, the current one.
|
|
4
|
+
*/
|
|
5
|
+
import { spawn } from "node:child_process";
|
|
6
|
+
import { resolve } from "node:path";
|
|
7
|
+
import { loadEnvironment, readContextFile } from "../../content/file.js";
|
|
8
|
+
import { aptAdvice, missingAptPackages } from "../../environment/apt.js";
|
|
9
|
+
import { declareEnvironment, declaredVariables, parsePackageArgument, runtimeAdvice, } from "../../environment/declare.js";
|
|
10
|
+
import { checkPackages, ensureMise, enterEnvironment, installPackages, miseBinary } from "../../environment/mise.js";
|
|
11
|
+
import { writeEnvironment } from "../../authoring.js";
|
|
12
|
+
import { log } from "../../log.js";
|
|
13
|
+
import { agentDirOrExit, failStartup } from "../fail.js";
|
|
14
|
+
import { dotEnvPath, enterAgentEnv } from "../../env.js";
|
|
15
|
+
import { missingSecrets } from "../../declared-secrets.js";
|
|
16
|
+
const NONE = { packages: {}, aptPackages: [], variables: {} };
|
|
17
|
+
/**
|
|
18
|
+
* The agent directory, the current one, entered as every command that runs in it is: its `.env` in `process.env`, and
|
|
19
|
+
* the proxy that `.env` may declare. mise's downloads go through that proxy, and `env exec` runs its command with the
|
|
20
|
+
* same values the agent's own commands get.
|
|
21
|
+
*/
|
|
22
|
+
function enterAgentHere() {
|
|
23
|
+
const agentDir = agentDirOrExit(resolve("."));
|
|
24
|
+
enterAgentEnv(agentDir);
|
|
25
|
+
return agentDir;
|
|
26
|
+
}
|
|
27
|
+
export async function runEnvAdd(args) {
|
|
28
|
+
const agentDir = enterAgentHere();
|
|
29
|
+
const parsed = args.map(parsePackageArgument);
|
|
30
|
+
const apt = parsed.flatMap((one) => ("apt" in one ? [one.apt] : []));
|
|
31
|
+
await edit(agentDir, (current) => {
|
|
32
|
+
const packages = { ...current.packages };
|
|
33
|
+
const aptPackages = [...current.aptPackages];
|
|
34
|
+
for (const one of parsed) {
|
|
35
|
+
if ("apt" in one) {
|
|
36
|
+
if (!aptPackages.includes(one.apt))
|
|
37
|
+
aptPackages.push(one.apt);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
packages[one.name] = one.version;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return { ...current, packages, aptPackages };
|
|
44
|
+
}).catch(failStartup);
|
|
45
|
+
const missing = missingAptPackages(apt);
|
|
46
|
+
if (missing && missing.length > 0)
|
|
47
|
+
log.warn(`[fastagent] ${aptAdvice(missing)}`);
|
|
48
|
+
}
|
|
49
|
+
export async function runEnvRemove(args) {
|
|
50
|
+
const agentDir = enterAgentHere();
|
|
51
|
+
await edit(agentDir, (current) => {
|
|
52
|
+
const packages = { ...current.packages };
|
|
53
|
+
let aptPackages = [...current.aptPackages];
|
|
54
|
+
for (const arg of args) {
|
|
55
|
+
const apt = arg.startsWith("apt:") ? arg.slice("apt:".length) : undefined;
|
|
56
|
+
const declared = apt !== undefined ? aptPackages.includes(apt) : Object.hasOwn(packages, arg);
|
|
57
|
+
if (!declared)
|
|
58
|
+
throw noPackage(current, arg);
|
|
59
|
+
if (apt !== undefined)
|
|
60
|
+
aptPackages = aptPackages.filter((name) => name !== apt);
|
|
61
|
+
else
|
|
62
|
+
delete packages[arg];
|
|
63
|
+
}
|
|
64
|
+
return { ...current, packages, aptPackages };
|
|
65
|
+
}).catch(failStartup);
|
|
66
|
+
}
|
|
67
|
+
export async function runEnvList(opts = {}) {
|
|
68
|
+
const agentDir = enterAgentHere();
|
|
69
|
+
const declared = await Promise.resolve()
|
|
70
|
+
.then(() => loadEnvironment(agentDir) ?? NONE)
|
|
71
|
+
.catch(failStartup);
|
|
72
|
+
const variables = declaredVariables(declared);
|
|
73
|
+
if (opts.json) {
|
|
74
|
+
// Whether each variable has a value here, never the value.
|
|
75
|
+
const listed = {
|
|
76
|
+
packages: Object.entries(declared.packages).map(([name, version]) => ({ name, version })),
|
|
77
|
+
apt: declared.aptPackages,
|
|
78
|
+
variables: variables.map(({ name, description }) => ({ name, description, set: Boolean(process.env[name]) })),
|
|
79
|
+
};
|
|
80
|
+
console.log(JSON.stringify(listed, null, 2));
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
printEnvironment(declared, variables);
|
|
84
|
+
}
|
|
85
|
+
if (Object.keys(declared.packages).length > 0) {
|
|
86
|
+
const bin = miseBinary(agentDir);
|
|
87
|
+
if (!bin) {
|
|
88
|
+
log.warn(`[fastagent] the packages are not checked: the agent's mise is not installed here — run ` +
|
|
89
|
+
`\`fastagent env install\``);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const { refusals, runtime } = await checkPackages(agentDir, bin, declared.packages).catch(failStartup);
|
|
93
|
+
for (const refusal of refusals)
|
|
94
|
+
log.warn(`[fastagent] ${refusal}`);
|
|
95
|
+
if (runtime)
|
|
96
|
+
log.warn(`[fastagent] ${runtimeAdvice(runtime)}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const missing = missingAptPackages(declared.aptPackages);
|
|
100
|
+
if (missing && missing.length > 0)
|
|
101
|
+
log.warn(`[fastagent] ${aptAdvice(missing)}`);
|
|
102
|
+
const unset = missingSecrets(variables).map(({ name }) => name);
|
|
103
|
+
if (unset.length > 0) {
|
|
104
|
+
log.warn(`[fastagent] no value here for ${unset.join(", ")}: dev and start refuse to run until they have one — set ` +
|
|
105
|
+
`them in ${dotEnvPath(agentDir)}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function printEnvironment(declared, variables) {
|
|
109
|
+
const names = [
|
|
110
|
+
...Object.keys(declared.packages),
|
|
111
|
+
...declared.aptPackages.map((name) => `apt:${name}`),
|
|
112
|
+
...variables.map(({ name }) => name),
|
|
113
|
+
];
|
|
114
|
+
if (names.length === 0)
|
|
115
|
+
console.log("(none: the agent runs this machine's commands)");
|
|
116
|
+
const width = Math.max(0, ...names.map((name) => name.length));
|
|
117
|
+
for (const [name, version] of Object.entries(declared.packages)) {
|
|
118
|
+
console.log(`${name.padEnd(width)} ${version}`);
|
|
119
|
+
}
|
|
120
|
+
for (const name of declared.aptPackages)
|
|
121
|
+
console.log(`${`apt:${name}`.padEnd(width)} (installed by the image)`);
|
|
122
|
+
// Whether each has a value here, never the value.
|
|
123
|
+
for (const { name, description } of variables) {
|
|
124
|
+
console.log(`${name.padEnd(width)} ${(process.env[name] ? "set" : "not set").padEnd(8)} ${description}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Install what context.json declares here, mise first when the agent has none (into its package.json): every package at
|
|
129
|
+
* the newest release its version allows, a newer one where one is out. Apt packages are the image's: one missing here
|
|
130
|
+
* is said, with how.
|
|
131
|
+
*/
|
|
132
|
+
export async function runEnvInstall() {
|
|
133
|
+
const agentDir = enterAgentHere();
|
|
134
|
+
await Promise.resolve()
|
|
135
|
+
.then(async () => {
|
|
136
|
+
const declared = loadEnvironment(agentDir) ?? NONE;
|
|
137
|
+
if (Object.keys(declared.packages).length > 0) {
|
|
138
|
+
await installPackages(agentDir, await checkedMise(agentDir, declared.packages), declared.packages, "all");
|
|
139
|
+
// Nothing in the agent directory changes, so `dev` does not restart: its PATH names the releases it started on.
|
|
140
|
+
log.info("[fastagent] a running `fastagent dev` keeps the releases it started with until it restarts");
|
|
141
|
+
}
|
|
142
|
+
const missing = missingAptPackages(declared.aptPackages);
|
|
143
|
+
if (missing && missing.length > 0)
|
|
144
|
+
log.warn(`[fastagent] ${aptAdvice(missing)}`);
|
|
145
|
+
})
|
|
146
|
+
.catch(failStartup);
|
|
147
|
+
}
|
|
148
|
+
export async function runEnvExec(command) {
|
|
149
|
+
const agentDir = enterAgentHere();
|
|
150
|
+
await enterEnvironment(agentDir).catch(failStartup);
|
|
151
|
+
const [program, ...args] = command;
|
|
152
|
+
const code = await new Promise((done, fail) => {
|
|
153
|
+
const child = spawn(program, args, { stdio: "inherit" });
|
|
154
|
+
child.on("error", fail);
|
|
155
|
+
child.on("close", (exit, signal) => done(exit ?? (signal ? 1 : 0)));
|
|
156
|
+
}).catch((error) => failStartup(error.code === "ENOENT" ? new Error(`${program}: command not found in the environment`) : error));
|
|
157
|
+
process.exit(code);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Change the declaration with `change`, checked as a whole. A package it adds or declares at another version is checked
|
|
161
|
+
* and installed first at the newest release its version allows, whatever older one this machine has, so a declared
|
|
162
|
+
* package is one that installs; what else it declares is installed when nothing here matches it. The declaration is
|
|
163
|
+
* then written under context.json's lock, `change` applied to it as it is by then, so two edits at once keep both.
|
|
164
|
+
* `change` is therefore called twice, and computes alone.
|
|
165
|
+
*/
|
|
166
|
+
async function edit(agentDir, change) {
|
|
167
|
+
// Read whole, as the write that follows is: a refused content entry stops the edit before anything is installed.
|
|
168
|
+
const current = readContextFile(agentDir).environment ?? NONE;
|
|
169
|
+
const next = declareEnvironment(change(current)) ?? NONE;
|
|
170
|
+
const added = Object.keys(next.packages).filter((name) => current.packages[name] !== next.packages[name]);
|
|
171
|
+
if (added.length > 0) {
|
|
172
|
+
await installPackages(agentDir, await checkedMise(agentDir, next.packages), next.packages, added);
|
|
173
|
+
}
|
|
174
|
+
return writeEnvironment(agentDir, (now) => declareEnvironment(change(now ?? NONE)) ?? NONE);
|
|
175
|
+
}
|
|
176
|
+
/** The refusal for a package `environment` does not declare, with what it does. */
|
|
177
|
+
function noPackage(environment, name) {
|
|
178
|
+
const has = [...Object.keys(environment.packages), ...environment.aptPackages.map((apt) => `apt:${apt}`)];
|
|
179
|
+
return new Error(`the environment has no package "${name}" (it has: ${has.join(", ") || "none"})`);
|
|
180
|
+
}
|
|
181
|
+
/** The agent's mise (added when it has none), once `packages` pass: a refused one stops the command. */
|
|
182
|
+
async function checkedMise(agentDir, packages) {
|
|
183
|
+
const bin = await ensureMise(agentDir);
|
|
184
|
+
const { refusals, runtime } = await checkPackages(agentDir, bin, packages);
|
|
185
|
+
if (refusals.length > 0)
|
|
186
|
+
throw new Error(refusals.join("\n"));
|
|
187
|
+
if (runtime)
|
|
188
|
+
log.warn(`[fastagent] ${runtimeAdvice(runtime)}`);
|
|
189
|
+
return bin;
|
|
190
|
+
}
|
|
@@ -1,182 +1,121 @@
|
|
|
1
|
-
/** `fastagent info [
|
|
1
|
+
/** `fastagent info [agent] [--json]`: print what the directory builds into, WITHOUT opening or serving the agent. */
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
|
+
import { channelIngress } from "../../channels/discover.js";
|
|
4
|
+
import { loadContent, loadEnvironment } from "../../content/file.js";
|
|
5
|
+
import { contentAbsentHere, resolveContent } from "../../content/resolve.js";
|
|
6
|
+
import { describeSecrets, missingSecrets } from "../../declared-secrets.js";
|
|
3
7
|
import { enterAgentEnv } from "../../env.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { resolveSessionsDir, resolveStateRoot } from "../../paths.js";
|
|
9
|
-
import { CODING_TOOL_NAMES, resolveAgentTools } from "../../engines/pi/create.js";
|
|
10
|
-
import { loadAgentDefinition } from "../../engines/pi/definition.js";
|
|
11
|
-
import { describeIndirectTools, describePrompt, reportFindingsIfChanged, reportToolCollisions, } from "../../engines/pi/report.js";
|
|
12
|
-
import { allSecrets, describeSecrets, missingSecrets } from "../../declared-secrets.js";
|
|
13
|
-
import { log } from "../../log.js";
|
|
14
|
-
import { reportModuleLoadFailures } from "../../loader.js";
|
|
15
|
-
import { readMachine, withMachine } from "../../engines/pi/machine.js";
|
|
8
|
+
import { modelEnvironment } from "../../harnesses/models/environment.js";
|
|
9
|
+
import { buildDefinition, modelSpecFor, prepareDefinition, secretsManifest } from "../../harnesses/pi-durable/open.js";
|
|
10
|
+
import { readCommands } from "../../harnesses/pi-durable/text.js";
|
|
11
|
+
import { resolveStateRoot } from "../../paths.js";
|
|
16
12
|
import { nextRun } from "../../schedule/cron.js";
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
13
|
+
import { contentLines } from "../content-view.js";
|
|
14
|
+
import { agentDirOrExit, failStartup } from "../fail.js";
|
|
19
15
|
export async function runInfo(dirArg, opts) {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const { config
|
|
24
|
-
const modelSpec =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
16
|
+
const agentDir = agentDirOrExit(resolve(dirArg));
|
|
17
|
+
enterAgentEnv(agentDir); // code may read its secrets, and fetch, when it is built
|
|
18
|
+
const definition = await prepareDefinition(agentDir).catch(failStartup);
|
|
19
|
+
const { config } = definition;
|
|
20
|
+
const modelSpec = modelSpecFor(config, opts.model);
|
|
21
|
+
const manifest = secretsManifest(definition);
|
|
22
|
+
const declared = manifest.flatMap(({ name, optional, declaredIn }) => declaredIn.map((source) => ({ name, optional, source })));
|
|
23
|
+
const unsetSecrets = missingSecrets(declared);
|
|
24
|
+
// Built only when every required secret has a value: building is what reads them. A module that is not what its
|
|
25
|
+
// directory holds is said as the refusal `dev` and `start` would stop on.
|
|
26
|
+
const code = unsetSecrets.length === 0
|
|
27
|
+
? await Promise.resolve()
|
|
28
|
+
.then(() => buildDefinition(definition))
|
|
29
|
+
.catch(failStartup)
|
|
30
|
+
: undefined;
|
|
31
|
+
// Reported, not fatal: `info` is how an author finds out a content entry is missing, or the environment refused.
|
|
32
|
+
let content = [];
|
|
33
|
+
let contentAbsent = [];
|
|
34
|
+
let contentError;
|
|
35
|
+
try {
|
|
36
|
+
const declaration = loadContent(agentDir);
|
|
37
|
+
content = resolveContent(agentDir, declaration);
|
|
38
|
+
contentAbsent = contentAbsentHere(declaration);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
contentError = error.message;
|
|
42
|
+
}
|
|
43
|
+
// Read already, by the definition's secrets: a refused environment is a definition that does not open.
|
|
44
|
+
const environment = loadEnvironment(agentDir);
|
|
45
|
+
const models = await modelEnvironment(agentDir, {}, code?.providers ?? []);
|
|
46
|
+
const slash = modelSpec?.indexOf("/") ?? -1;
|
|
47
|
+
const modelError = modelSpec === undefined || models.models.getModel(modelSpec.slice(0, slash), modelSpec.slice(slash + 1))
|
|
48
|
+
? undefined
|
|
49
|
+
: `no provider "${modelSpec.slice(0, Math.max(slash, 0))}" offers "${modelSpec.slice(slash + 1)}"`;
|
|
50
|
+
const channels = [...(code?.channels ?? new Map())].map(([name, module]) => ({
|
|
51
|
+
name,
|
|
52
|
+
ingress: channelIngress(module),
|
|
50
53
|
}));
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const sched = await loadRoutines(agentDir).catch(failStartup);
|
|
57
|
-
// What the definition DECLARED it needs, and which of those have no value here. `info` reports
|
|
58
|
-
// (never asserts): it is the read-only view of the same list `dev`/`start` refuse to boot without
|
|
59
|
-
// and `deploy` requires a value for.
|
|
60
|
-
const declaredSecrets = [
|
|
61
|
-
...tools.secrets,
|
|
62
|
-
...allSecrets(sched.secrets),
|
|
63
|
-
...allSecrets(inspected.secrets),
|
|
64
|
-
];
|
|
65
|
-
const unsetSecrets = missingSecrets(declaredSecrets);
|
|
66
|
-
const routines = sched.routines.map((r) => ({
|
|
67
|
-
name: r.name,
|
|
68
|
-
cron: r.cron ?? null,
|
|
69
|
-
tz: r.tz ?? null,
|
|
70
|
-
// A routine with no cron has no next fire — it is reached by name (`POST /run`, `routine run`), which is a
|
|
71
|
-
// fact worth printing rather than a null to squint at.
|
|
72
|
-
next: r.cron === undefined ? null : (nextRun(r.cron, r.tz, new Date())?.toISOString() ?? null),
|
|
54
|
+
const schedules = (code?.schedules ?? []).map((s) => ({
|
|
55
|
+
name: s.name,
|
|
56
|
+
cron: s.cron,
|
|
57
|
+
tz: s.tz ?? null,
|
|
58
|
+
next: nextRun(s.cron, s.tz, new Date())?.toISOString() ?? null,
|
|
73
59
|
}));
|
|
74
|
-
|
|
75
|
-
// info must not).
|
|
60
|
+
const commands = readCommands(agentDir).map(({ name, description }) => ({ name, description: description ?? null }));
|
|
76
61
|
const stateRoot = resolveStateRoot(agentDir);
|
|
77
|
-
const
|
|
78
|
-
// Both layers: "what is this agent's state" is the question `info` answers, and a credential it runs on can live in
|
|
79
|
-
// a file the agent dir does not contain.
|
|
80
|
-
const models = agentModels(agentDir, {}, { cwd: workspace });
|
|
81
|
-
const { auth } = models;
|
|
82
|
-
// RESOLVE the spec, do not just echo it: a spec is only real once its provider/model exist in the agent's own
|
|
83
|
-
// surface (built-ins + its models.json), which is exactly what a custom endpoint changes.
|
|
84
|
-
const modelError = modelSpec
|
|
85
|
-
? await models
|
|
86
|
-
.runtime()
|
|
87
|
-
.then((runtime) => {
|
|
88
|
-
resolveModel(runtime, modelSpec);
|
|
89
|
-
return undefined;
|
|
90
|
-
})
|
|
91
|
-
.catch((error) => error.message)
|
|
92
|
-
: undefined;
|
|
93
|
-
// The machine's own endpoints, which this agent inherits unless its models.json declares the same provider.
|
|
94
|
-
const machine = await machineModels(agentDir).then((value) => ({ value, error: undefined }), (error) => ({ value: undefined, error: error.message }));
|
|
95
|
-
const modelFromMachine = modelSpec !== undefined && machine.value?.inherited.includes(providerOf(modelSpec)) === true;
|
|
62
|
+
const auth = models.auth;
|
|
96
63
|
if (opts.json) {
|
|
97
64
|
console.log(JSON.stringify({
|
|
98
65
|
agentDir,
|
|
99
|
-
|
|
100
|
-
|
|
66
|
+
name: definition.name,
|
|
67
|
+
content,
|
|
68
|
+
contentAbsent,
|
|
69
|
+
contentError: contentError ?? null,
|
|
70
|
+
environment: environment ?? null,
|
|
101
71
|
model: modelSpec ?? null,
|
|
102
72
|
modelError: modelError ?? null,
|
|
103
|
-
modelFromMachine,
|
|
104
|
-
machineModels: machine.value ?? null,
|
|
105
|
-
machineModelsError: machine.error ?? null,
|
|
106
73
|
thinkingLevel: config.thinkingLevel ?? null,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
indirectTools: tools.indirect,
|
|
115
|
-
toolError: tools.error ?? null,
|
|
116
|
-
channels,
|
|
117
|
-
routines,
|
|
118
|
-
routineFailures: sched.failures,
|
|
119
|
-
channelFailures: inspected.failures,
|
|
74
|
+
tools: code?.tools.map(({ name }) => name) ?? null,
|
|
75
|
+
extensions: code?.extensions.map(({ name }) => name) ?? null,
|
|
76
|
+
channels: code === undefined ? null : channels,
|
|
77
|
+
schedules: code === undefined ? null : schedules,
|
|
78
|
+
commands,
|
|
79
|
+
secrets: manifest,
|
|
80
|
+
unsetSecrets: unsetSecrets.map(({ name }) => name),
|
|
120
81
|
stateRoot,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
fallbackAuthPath: auth.fallback ?? null,
|
|
124
|
-
diagnostics: definition.diagnostics,
|
|
125
|
-
skillCollisions: definition.collisions,
|
|
126
|
-
shadowed: definition.shadowed,
|
|
127
|
-
ignored: definition.ignored,
|
|
128
|
-
toolCollisions: tools.collisions,
|
|
129
|
-
toolFailures: tools.failures,
|
|
130
|
-
declaredSecrets,
|
|
131
|
-
unsetSecrets,
|
|
82
|
+
authPath: auth?.path ?? null,
|
|
83
|
+
fallbackAuthPath: auth?.fallback ?? null,
|
|
132
84
|
}, null, 2));
|
|
133
85
|
return;
|
|
134
86
|
}
|
|
135
|
-
// One padded label writer, so labels stay aligned.
|
|
136
87
|
const line = (label, value) => console.log(`${`${label}:`.padEnd(13)} ${value}`);
|
|
137
88
|
/** A continuation under the previous line, aligned to the same column (no label, so no bare colon). */
|
|
138
89
|
const cont = (value) => console.log(`${"".padEnd(13)} ${value}`);
|
|
139
|
-
line("agent", agentDir);
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
90
|
+
line("agent", `${definition.name} — ${agentDir}`);
|
|
91
|
+
for (const [label, value] of contentLines(content, contentAbsent))
|
|
92
|
+
line(label, value);
|
|
93
|
+
if (contentError)
|
|
94
|
+
cont(`⚠ ${contentError}`);
|
|
95
|
+
line("environment", environment ? describeEnvironment(environment) : "(none: the machine's commands)");
|
|
96
|
+
line("model", modelSpec ?? "(not set — pass --model, set FASTAGENT_MODEL, or model in fastagent.config.ts)");
|
|
143
97
|
if (modelError)
|
|
144
98
|
cont(`⚠ does not resolve: ${modelError}`);
|
|
145
|
-
if (modelFromMachine)
|
|
146
|
-
cont(`endpoint from the machine's ${machine.value?.path} (does not ship with a deploy)`);
|
|
147
99
|
if (config.thinkingLevel)
|
|
148
100
|
line("thinking", config.thinkingLevel);
|
|
149
|
-
|
|
150
|
-
line("
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
line("
|
|
154
|
-
line("
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
"(none)");
|
|
160
|
-
line("secrets", declaredSecrets.length > 0 ? describeSecrets(declaredSecrets) : "(none declared)");
|
|
161
|
-
if (unsetSecrets.length > 0)
|
|
162
|
-
cont(`⚠ dev/start refuse to boot until set: ${unsetSecrets.map((s) => s.name).join(", ")}`);
|
|
163
|
-
line("state", stateRoot);
|
|
164
|
-
line("sessions", sessionsDir);
|
|
165
|
-
line("auth", auth.fallback === undefined ? auth.path : `${auth.path} (then ${auth.fallback})`);
|
|
166
|
-
if (machine.error)
|
|
167
|
-
line("endpoints", `⚠ ${machine.error}`);
|
|
168
|
-
else if (machine.value) {
|
|
169
|
-
const { path, inherited, overridden } = machine.value;
|
|
170
|
-
const parts = [inherited.join(", ") || "(none inherited)"];
|
|
171
|
-
if (overridden.length > 0)
|
|
172
|
-
parts.push(`overridden by the agent: ${overridden.join(", ")}`);
|
|
173
|
-
line("endpoints", `${path}: ${parts.join("; ")}`);
|
|
101
|
+
const unbuilt = "(not built: a required secret has no value)";
|
|
102
|
+
line("tools", code ? code.tools.map(({ name }) => name).join(", ") || "(none)" : unbuilt);
|
|
103
|
+
if (code && code.extensions.length > 0)
|
|
104
|
+
line("extensions", code.extensions.map(({ name }) => name).join(", "));
|
|
105
|
+
line("channels", code ? channels.map((c) => `${c.name} (${c.ingress})`).join(", ") || "(none)" : unbuilt);
|
|
106
|
+
line("schedules", code ? schedules.map((s) => `${s.name} (next ${s.next ?? "never"})`).join(", ") || "(none)" : unbuilt);
|
|
107
|
+
line("commands", commands.map(({ name }) => `/${name}`).join(", ") || "(none)");
|
|
108
|
+
line("secrets", declared.length > 0 ? describeSecrets(declared) : "(none declared)");
|
|
109
|
+
if (unsetSecrets.length > 0) {
|
|
110
|
+
cont(`⚠ dev, start and deployments refuse to boot until set: ${unsetSecrets.map((s) => s.name).join(", ")}`);
|
|
174
111
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
112
|
+
line("state", stateRoot);
|
|
113
|
+
if (auth)
|
|
114
|
+
line("auth", auth.fallback === undefined ? auth.path : `${auth.path} (then ${auth.fallback})`);
|
|
115
|
+
}
|
|
116
|
+
/** The packages and apt packages an environment declares, as one line. */
|
|
117
|
+
function describeEnvironment(environment) {
|
|
118
|
+
const packages = Object.entries(environment.packages).map(([name, version]) => `${name} ${version}`);
|
|
119
|
+
const apt = environment.aptPackages.map((name) => `apt:${name}`);
|
|
120
|
+
return [...packages, ...apt].join(", ") || "(none: the machine's commands)";
|
|
182
121
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface InitOptions {
|
|
2
2
|
/** false ⇔ `--no-install`. */
|
|
3
3
|
install: boolean;
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/** `--content` sources, each a directory the agent works on. */
|
|
5
|
+
content: string[];
|
|
6
6
|
}
|
|
7
7
|
export declare function runInit(dirArg: string, opts: InitOptions): Promise<void>;
|