@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
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import type { Agent } from "../../agent.ts";
|
|
2
|
-
import { type FastagentConfig } from "./config.ts";
|
|
3
|
-
import type { AgentCommand, ModelDescriptor, SessionControl } from "../../session.ts";
|
|
4
|
-
import { type IndirectTool, type PiAssembly } from "./create.ts";
|
|
5
|
-
import type { SessionObserver } from "./turn-kit.ts";
|
|
6
|
-
import { type LoadedDefinition } from "./definition.ts";
|
|
7
|
-
import type { ModelRuntime } from "@earendil-works/pi-coding-agent";
|
|
8
|
-
import type { CredentialStore } from "@earendil-works/pi-ai";
|
|
9
|
-
import type { CredentialSourceOptions, FastagentAuthOptions } from "./auth.ts";
|
|
10
|
-
import { type AgentModels } from "./agent-models.ts";
|
|
11
|
-
import { type PiSessionRecordStore } from "./session-store.ts";
|
|
12
|
-
import type { ToolCollision, MountedTool } from "./tool.ts";
|
|
13
|
-
import type { DeclaredSecret } from "../../declared-secrets.ts";
|
|
14
|
-
import type { HttpSurface } from "../../service.ts";
|
|
15
|
-
/**
|
|
16
|
-
* The names a `/` composer completes: this agent's skills and prompt templates — the definition's, plus the ones its
|
|
17
|
-
* machine lends (machine.ts) — and the commands its `extensions/` register.
|
|
18
|
-
*
|
|
19
|
-
* `source` says how a name is INVOKED, which is the one thing a client needs from it: a `skill` is sent as
|
|
20
|
-
* `/skill:<name>`, an `extension` command and a `prompt` as `/<name>` (docs/design/session-control.md §5.1.1).
|
|
21
|
-
*
|
|
22
|
-
* The definition is read live, like every turn reads it; the machine is the process's one read, the same snapshot a
|
|
23
|
-
* bound session runs on, so the menu cannot offer a name the next prompt would not expand. The same holds for
|
|
24
|
-
* extensions: `served` is what sessions load — the assembly's entry points, discovered once, and the runtime turns run
|
|
25
|
-
* on (asked only when there are extensions) — never a fresh scan of `extensions/`.
|
|
26
|
-
*/
|
|
27
|
-
export declare function agentCommands(agentDir: string, workspace: string, served: {
|
|
28
|
-
extensionPaths: readonly string[];
|
|
29
|
-
modelRuntime: () => Promise<ModelRuntime>;
|
|
30
|
-
}): Promise<AgentCommand[]>;
|
|
31
|
-
export interface CreatePiAgentFromDirOptions {
|
|
32
|
-
/** Model spec override (e.g. the CLI --model flag). */
|
|
33
|
-
model?: string;
|
|
34
|
-
/**
|
|
35
|
-
* Where conversations are stored, for an EMBEDDER that puts them somewhere the state root does not cover. There is
|
|
36
|
-
* no env or flag spelling of it: sessions are machine state, and the one knob that moves machine state is
|
|
37
|
-
* `FASTAGENT_STATE_DIR` (see {@link resolveSessionsDir}).
|
|
38
|
-
*/
|
|
39
|
-
sessionsDir?: string;
|
|
40
|
-
/** Credentials file override. */
|
|
41
|
-
authPath?: string;
|
|
42
|
-
/** The caller's own credential store, in place of any file ({@link CredentialSourceOptions}). */
|
|
43
|
-
credentialStore?: CredentialStore;
|
|
44
|
-
/**
|
|
45
|
-
* This is a long-running SERVE (`dev`/`start`), where the scheduler poller runs — so a self-scheduled wake-up is
|
|
46
|
-
* actually honored.
|
|
47
|
-
*/
|
|
48
|
-
serving?: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Wire the control plane's BOUNDARY (model changes, fork, delete) and publish it. A serve always gets the hub
|
|
51
|
-
* itself — stopping the running turn is a chat command, not a management endpoint — so this is the answer to
|
|
52
|
-
* "may a remote caller steer and rewrite this deployment", nothing else. Defaults to `config.sessionControl`.
|
|
53
|
-
*/
|
|
54
|
-
sessionControl?: boolean;
|
|
55
|
-
/** Additional raw tap with the FULL vocabulary. */
|
|
56
|
-
observer?: SessionObserver;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* The agent assembly FRONT HALF — everything that is independent of how pi consumes the definition (a per-invoke
|
|
60
|
-
* session for serving vs a resident one for chat).
|
|
61
|
-
*/
|
|
62
|
-
export interface AgentAssembly {
|
|
63
|
-
config: FastagentConfig;
|
|
64
|
-
configPath?: string;
|
|
65
|
-
/**
|
|
66
|
-
* The default "provider/modelId" spec (`--model` > `FASTAGENT_MODEL` > config), or undefined when the agent sets none:
|
|
67
|
-
* it still opens, a session that records its model runs on it, and one that records none is refused with
|
|
68
|
-
* `missing_model` at invoke.
|
|
69
|
-
*/
|
|
70
|
-
modelSpec?: string;
|
|
71
|
-
/** Absolute agent dir — definition + config + machinery live here (resolvePlacement().agentDir). */
|
|
72
|
-
agentDir: string;
|
|
73
|
-
/** Absolute workspace — the agent's cwd and the start of the ②-context walk. */
|
|
74
|
-
workspace: string;
|
|
75
|
-
/** Absolute state root (FASTAGENT_STATE_DIR > <agentDir>/.state). */
|
|
76
|
-
stateRoot: string;
|
|
77
|
-
/** The credential store and model registry every turn and every report reads ({@link agentModels}). */
|
|
78
|
-
models: AgentModels;
|
|
79
|
-
/** The full mounted tool surface (all coding tools + config.tools + discovered tools/). */
|
|
80
|
-
tools: MountedTool[];
|
|
81
|
-
toolNames: string[];
|
|
82
|
-
indirectTools: IndirectTool[];
|
|
83
|
-
toolCollisions: ToolCollision[];
|
|
84
|
-
/** Env vars the mounted tools declared, by tool name — already asserted present by this function. */
|
|
85
|
-
toolSecrets: Map<string, DeclaredSecret[]>;
|
|
86
|
-
}
|
|
87
|
-
export declare function resolveAgentAssembly(dir: string, options?: {
|
|
88
|
-
model?: string;
|
|
89
|
-
} & CredentialSourceOptions): Promise<AgentAssembly>;
|
|
90
|
-
/**
|
|
91
|
-
* L2 over a resolved front half: the ONE mapping from what the directory resolved to what the assembly runs on, for
|
|
92
|
-
* both session shapes (the served agent and `chat`'s resident one). Two copies of it drifted once (#566, chat ran at
|
|
93
|
-
* the wrong reasoning effort). `models` is the front's own, so the assembly runs on what the report describes.
|
|
94
|
-
*/
|
|
95
|
-
export declare function assembleFront(front: AgentAssembly, extra?: {
|
|
96
|
-
tools?: MountedTool[];
|
|
97
|
-
sessions?: PiSessionRecordStore;
|
|
98
|
-
}): Promise<{
|
|
99
|
-
assembly: PiAssembly;
|
|
100
|
-
definition: LoadedDefinition;
|
|
101
|
-
}>;
|
|
102
|
-
/**
|
|
103
|
-
* The models `createPiAgentFromDir(dir, { authPath })` could run now, as a picker shows them (spec, name, the thinking
|
|
104
|
-
* levels a session on it accepts, context window), sorted by spec: the agent's registry (pi's built-ins, its
|
|
105
|
-
* `models.json`, and what its `extensions/` declare) filtered to the providers whose credentials are configured. The
|
|
106
|
-
* directory needs no model set, and the same placement and credential layers as the opener apply, so a listed spec
|
|
107
|
-
* authenticates there. Configuration is checked, not validity: no OAuth token is refreshed and no provider is called.
|
|
108
|
-
* A Sign in with ChatGPT on `openai` lists the account's own models (openai-account-models.ts), not pi's built-ins.
|
|
109
|
-
*
|
|
110
|
-
* `warn` reaches the credential store. An unreadable or corrupt credentials file otherwise reads as "nothing
|
|
111
|
-
* configured", so a client that must not show that as an empty list passes a sink that throws. A ChatGPT sign-in that
|
|
112
|
-
* carries no catalog is a normal, recoverable state (signed in before the catalog was read), not that: it is logged,
|
|
113
|
-
* never sent to `warn`, so a throwing sink does not fail the whole listing for it.
|
|
114
|
-
*/
|
|
115
|
-
export declare function availableModelsFromDir(dir: string, options?: FastagentAuthOptions & CredentialSourceOptions): Promise<ModelDescriptor[]>;
|
|
116
|
-
/**
|
|
117
|
-
* Refresh the agent's model catalog (`<agent dir>/models-store.json`) with the credentials
|
|
118
|
-
* `createPiAgentFromDir(dir, { authPath })` would use, so a model released after the installed pi appears in
|
|
119
|
-
* {@link availableModelsFromDir} and runs. Only providers those credentials authenticate are fetched (pi asks pi.dev
|
|
120
|
-
* for no other). Nothing refreshes it on its own. The file is part of the definition: commit it, and it ships with a
|
|
121
|
-
* deploy, so the deployed agent knows the same models without a network call.
|
|
122
|
-
*
|
|
123
|
-
* Rejects, naming each provider that failed, when the refresh fails, outlasts 15 seconds or `PI_OFFLINE` is set, and
|
|
124
|
-
* when the credentials authenticate no provider at all.
|
|
125
|
-
*/
|
|
126
|
-
export declare function refreshModelCatalog(dir: string, options?: FastagentAuthOptions & CredentialSourceOptions & {
|
|
127
|
-
signal?: AbortSignal;
|
|
128
|
-
}): Promise<void>;
|
|
129
|
-
/** {@link refreshModelCatalog} against another catalog server. Not public: a test seam. */
|
|
130
|
-
export declare function refreshModelCatalogOver(dir: string, options: FastagentAuthOptions & CredentialSourceOptions & {
|
|
131
|
-
signal?: AbortSignal;
|
|
132
|
-
}, catalogBaseUrl?: string): Promise<void>;
|
|
133
|
-
/**
|
|
134
|
-
* Refresh the MACHINE's model catalog (`~/.fastagent/models-store.json`), which every agent here reads under its own,
|
|
135
|
-
* so one refresh serves them all and no file is written into any agent. Credentials resolve as for
|
|
136
|
-
* {@link refreshModelCatalog} without a directory: `credentialStore`, else `authPath`, else the global credentials file;
|
|
137
|
-
* the environment applies either way. Rejects for the same reasons. The file never ships with a deploy.
|
|
138
|
-
*/
|
|
139
|
-
export declare function refreshMachineModelCatalog(options?: FastagentAuthOptions & CredentialSourceOptions & {
|
|
140
|
-
signal?: AbortSignal;
|
|
141
|
-
}): Promise<void>;
|
|
142
|
-
/** {@link refreshMachineModelCatalog} against another catalog server. Not public: a test seam. */
|
|
143
|
-
export declare function refreshMachineModelCatalogOver(options: FastagentAuthOptions & CredentialSourceOptions & {
|
|
144
|
-
signal?: AbortSignal;
|
|
145
|
-
}, catalogBaseUrl?: string): Promise<void>;
|
|
146
|
-
/**
|
|
147
|
-
* "Point at a directory → agent": resolve the placement (`dir` may be either end — the workspace or the agent dir
|
|
148
|
-
* itself), load the config, resolve model and tools, then L2.
|
|
149
|
-
*/
|
|
150
|
-
export declare function createPiAgentFromDir(dir: string, options?: CreatePiAgentFromDirOptions): Promise<{
|
|
151
|
-
agent: Agent;
|
|
152
|
-
definition: LoadedDefinition;
|
|
153
|
-
config: FastagentConfig;
|
|
154
|
-
configPath?: string;
|
|
155
|
-
/** The default "provider/modelId" spec, or undefined when the agent sets none ({@link AgentAssembly.modelSpec}). */
|
|
156
|
-
modelSpec?: string;
|
|
157
|
-
/** Absolute agent dir in use — channels/tools/prompt come from here. */
|
|
158
|
-
agentDir: string;
|
|
159
|
-
/** Absolute workspace in use — the agent's cwd: ALWAYS the directory that was pointed at. */
|
|
160
|
-
workspace: string;
|
|
161
|
-
/** Absolute state root in use (FASTAGENT_STATE_DIR > <agentDir>/.state) — the ChannelContext's stateRoot. */
|
|
162
|
-
stateRoot: string;
|
|
163
|
-
/** Absolute session store directory in use (for the startup report). */
|
|
164
|
-
sessionsDir: string;
|
|
165
|
-
/** The credential store and registry the agent runs on — what the startup report describes. */
|
|
166
|
-
models: AgentModels;
|
|
167
|
-
sessions: PiSessionRecordStore;
|
|
168
|
-
/** The observation plane over this agent's sessions; present on every serve (a channel's stop command reaches the
|
|
169
|
-
* live run through it). Its boundary is wired only when {@link publishControl}. */
|
|
170
|
-
sessionControl?: SessionControl;
|
|
171
|
-
/** Whether that plane is also served as `/control/*` — `config.sessionControl`. */
|
|
172
|
-
publishControl: boolean;
|
|
173
|
-
/** What the serve publishes — `config.http`, handed to the assembly as-is (MountableAgent). */
|
|
174
|
-
http?: HttpSurface;
|
|
175
|
-
/** Non-default, active-by-default tool names in effect: config.tools + discovered tools/. */
|
|
176
|
-
toolNames: string[];
|
|
177
|
-
/** Mounted authored tools the model is not given up front, with how each is reached. */
|
|
178
|
-
indirectTools: IndirectTool[];
|
|
179
|
-
toolCollisions: ToolCollision[];
|
|
180
|
-
}>;
|
package/dist/engines/pi/open.js
DELETED
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Open a definition directory into an agent — the single agent opener BOTH `fastagent dev` and `fastagent start`
|
|
3
|
-
* drive.
|
|
4
|
-
*/
|
|
5
|
-
import { mkdir } from "node:fs/promises";
|
|
6
|
-
import { join } from "node:path";
|
|
7
|
-
import { loadConfig, resolveModelSpec } from "./config.js";
|
|
8
|
-
import { AGENT_MODEL_CATALOG_FILE, resolveSessionsDir, resolveStateRoot, resolvePlacement } from "../../paths.js";
|
|
9
|
-
import { describeModels } from "./session-settings.js";
|
|
10
|
-
import { agentOf, assemblePiFromDefinition, resolveAgentTools } from "./create.js";
|
|
11
|
-
import { createPiSessionControl } from "./session-control.js";
|
|
12
|
-
import { withWakeTool } from "./wake-tool.js";
|
|
13
|
-
import { refuseBrokenDeclarations } from "../../loader.js";
|
|
14
|
-
import { loadAgentDefinition } from "./definition.js";
|
|
15
|
-
import { servedExtensionCommands } from "./agent-session-factory.js";
|
|
16
|
-
import { reportFindingsIfChanged } from "./report.js";
|
|
17
|
-
import { readMachine, withMachine } from "./machine.js";
|
|
18
|
-
import { createPiModelRuntime, globalCatalogPath, machineModelRuntime, refreshCatalog } from "./models.js";
|
|
19
|
-
import { agentModels } from "./agent-models.js";
|
|
20
|
-
import { OPENAI_PROVIDER, missingAccountModels } from "./openai-account-models.js";
|
|
21
|
-
import { log } from "../../log.js";
|
|
22
|
-
import { piSessionRecordStore } from "./session-store.js";
|
|
23
|
-
import { gateSecrets } from "../../secrets-gate.js";
|
|
24
|
-
/**
|
|
25
|
-
* The names a `/` composer completes: this agent's skills and prompt templates — the definition's, plus the ones its
|
|
26
|
-
* machine lends (machine.ts) — and the commands its `extensions/` register.
|
|
27
|
-
*
|
|
28
|
-
* `source` says how a name is INVOKED, which is the one thing a client needs from it: a `skill` is sent as
|
|
29
|
-
* `/skill:<name>`, an `extension` command and a `prompt` as `/<name>` (docs/design/session-control.md §5.1.1).
|
|
30
|
-
*
|
|
31
|
-
* The definition is read live, like every turn reads it; the machine is the process's one read, the same snapshot a
|
|
32
|
-
* bound session runs on, so the menu cannot offer a name the next prompt would not expand. The same holds for
|
|
33
|
-
* extensions: `served` is what sessions load — the assembly's entry points, discovered once, and the runtime turns run
|
|
34
|
-
* on (asked only when there are extensions) — never a fresh scan of `extensions/`.
|
|
35
|
-
*/
|
|
36
|
-
export async function agentCommands(agentDir, workspace, served) {
|
|
37
|
-
// The whole definition, read the way a turn reads it: a skill whose frontmatter broke simply is not in `skills`, and
|
|
38
|
-
// would vanish from the composer with no signal. The SAME findings a turn reports, so the per-directory memo sees
|
|
39
|
-
// one set from both readers instead of warning again after every menu request.
|
|
40
|
-
const own = await loadAgentDefinition(agentDir, { cwd: workspace });
|
|
41
|
-
reportFindingsIfChanged(own.dir, own);
|
|
42
|
-
const machine = await readMachine(workspace);
|
|
43
|
-
const prompts = withMachine(own.prompts, machine.prompts);
|
|
44
|
-
const { extensionPaths } = served;
|
|
45
|
-
const extensionCommands = await servedExtensionCommands({
|
|
46
|
-
cwd: workspace,
|
|
47
|
-
modelRuntime: await served.modelRuntime(),
|
|
48
|
-
extensionPaths,
|
|
49
|
-
});
|
|
50
|
-
// pi dispatches an extension command before it expands a template, so a template it shadows never runs.
|
|
51
|
-
const shadowed = new Set(extensionCommands.map((command) => command.invocationName));
|
|
52
|
-
return [
|
|
53
|
-
...withMachine(own.skills, machine.skills).map((skill) => ({
|
|
54
|
-
name: skill.name,
|
|
55
|
-
description: skill.description,
|
|
56
|
-
source: "skill",
|
|
57
|
-
})),
|
|
58
|
-
...extensionCommands.map((command) => ({
|
|
59
|
-
name: command.invocationName,
|
|
60
|
-
...(command.description ? { description: command.description } : {}),
|
|
61
|
-
source: "extension",
|
|
62
|
-
})),
|
|
63
|
-
...prompts
|
|
64
|
-
.filter((prompt) => !shadowed.has(prompt.name))
|
|
65
|
-
.map((prompt) => ({
|
|
66
|
-
name: prompt.name,
|
|
67
|
-
...(prompt.description ? { description: prompt.description } : {}),
|
|
68
|
-
source: "prompt",
|
|
69
|
-
})),
|
|
70
|
-
];
|
|
71
|
-
}
|
|
72
|
-
export async function resolveAgentAssembly(dir, options = {}) {
|
|
73
|
-
// Placement is structural (resolvePlacement): the AGENT DIR carries definition + config + machinery; its parent.
|
|
74
|
-
const { agentDir, workspace } = resolvePlacement(dir);
|
|
75
|
-
const { config, path: configPath } = await loadConfig(agentDir);
|
|
76
|
-
const modelSpec = resolveModelSpec(options.model, config);
|
|
77
|
-
const { tools, toolNames, indirectTools, toolCollisions, toolFailures, toolSecrets } = await resolveAgentTools(config, agentDir, workspace);
|
|
78
|
-
// THE serving-path gate for tool declarations, in the order that costs the fewest round trips. A file that could
|
|
79
|
-
// not be imported declares nothing, so its `secrets:` are missing from `toolSecrets` — gating secrets first would
|
|
80
|
-
// report an incomplete set, and fixing the file could then reveal more missing values. Refuse the broken file
|
|
81
|
-
// first and one pass reports every secret the definition actually wants.
|
|
82
|
-
refuseBrokenDeclarations(toolFailures);
|
|
83
|
-
// Both gates live here rather than inside resolveAgentTools, which `info` and `fastagent tool` call to REPORT on a
|
|
84
|
-
// definition and must survive both faults; every path through this function is about to run ALL of the tools, so
|
|
85
|
-
// no `owner`.
|
|
86
|
-
//
|
|
87
|
-
// DEFERRED tools gate too, deliberately: native discovery can activate one mid-turn, so "registered"
|
|
88
|
-
// means "may run in this process" — letting it start would put the empty-credential failure back
|
|
89
|
-
// inside a turn. An author who does not want that opts out per tool by not declaring.
|
|
90
|
-
gateSecrets({ declared: toolSecrets, failures: [] });
|
|
91
|
-
// The state root: sessions/channel state/schedule state derive from it (FASTAGENT_STATE_DIR moves it in one knob —
|
|
92
|
-
// a container points it at its volume).
|
|
93
|
-
const stateRoot = resolveStateRoot(agentDir);
|
|
94
|
-
return {
|
|
95
|
-
config,
|
|
96
|
-
configPath,
|
|
97
|
-
...(modelSpec ? { modelSpec } : {}),
|
|
98
|
-
agentDir,
|
|
99
|
-
workspace,
|
|
100
|
-
stateRoot,
|
|
101
|
-
// Project-level by default (under `<agentDir>/.secrets`), with the global file behind it per provider.
|
|
102
|
-
models: agentModels(agentDir, options, { cwd: workspace }),
|
|
103
|
-
tools,
|
|
104
|
-
toolNames,
|
|
105
|
-
indirectTools,
|
|
106
|
-
toolCollisions,
|
|
107
|
-
toolSecrets,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* L2 over a resolved front half: the ONE mapping from what the directory resolved to what the assembly runs on, for
|
|
112
|
-
* both session shapes (the served agent and `chat`'s resident one). Two copies of it drifted once (#566, chat ran at
|
|
113
|
-
* the wrong reasoning effort). `models` is the front's own, so the assembly runs on what the report describes.
|
|
114
|
-
*/
|
|
115
|
-
export function assembleFront(front, extra = {}) {
|
|
116
|
-
return assemblePiFromDefinition(front.agentDir, {
|
|
117
|
-
...(front.modelSpec ? { model: front.modelSpec } : {}),
|
|
118
|
-
thinkingLevel: front.config.thinkingLevel,
|
|
119
|
-
cwd: front.workspace,
|
|
120
|
-
tools: extra.tools ?? front.tools,
|
|
121
|
-
models: front.models,
|
|
122
|
-
...(extra.sessions ? { sessions: extra.sessions } : {}),
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* The models `createPiAgentFromDir(dir, { authPath })` could run now, as a picker shows them (spec, name, the thinking
|
|
127
|
-
* levels a session on it accepts, context window), sorted by spec: the agent's registry (pi's built-ins, its
|
|
128
|
-
* `models.json`, and what its `extensions/` declare) filtered to the providers whose credentials are configured. The
|
|
129
|
-
* directory needs no model set, and the same placement and credential layers as the opener apply, so a listed spec
|
|
130
|
-
* authenticates there. Configuration is checked, not validity: no OAuth token is refreshed and no provider is called.
|
|
131
|
-
* A Sign in with ChatGPT on `openai` lists the account's own models (openai-account-models.ts), not pi's built-ins.
|
|
132
|
-
*
|
|
133
|
-
* `warn` reaches the credential store. An unreadable or corrupt credentials file otherwise reads as "nothing
|
|
134
|
-
* configured", so a client that must not show that as an empty list passes a sink that throws. A ChatGPT sign-in that
|
|
135
|
-
* carries no catalog is a normal, recoverable state (signed in before the catalog was read), not that: it is logged,
|
|
136
|
-
* never sent to `warn`, so a throwing sink does not fail the whole listing for it.
|
|
137
|
-
*/
|
|
138
|
-
export async function availableModelsFromDir(dir, options = {}) {
|
|
139
|
-
const { agentDir, workspace } = resolvePlacement(dir);
|
|
140
|
-
const environment = agentModels(agentDir, options, { cwd: workspace });
|
|
141
|
-
const available = await (await environment.runtime()).getAvailable();
|
|
142
|
-
const missing = missingAccountModels(await environment.credentials.read(OPENAI_PROVIDER));
|
|
143
|
-
if (missing)
|
|
144
|
-
log.warn(missing);
|
|
145
|
-
return describeModels(available);
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Refresh the agent's model catalog (`<agent dir>/models-store.json`) with the credentials
|
|
149
|
-
* `createPiAgentFromDir(dir, { authPath })` would use, so a model released after the installed pi appears in
|
|
150
|
-
* {@link availableModelsFromDir} and runs. Only providers those credentials authenticate are fetched (pi asks pi.dev
|
|
151
|
-
* for no other). Nothing refreshes it on its own. The file is part of the definition: commit it, and it ships with a
|
|
152
|
-
* deploy, so the deployed agent knows the same models without a network call.
|
|
153
|
-
*
|
|
154
|
-
* Rejects, naming each provider that failed, when the refresh fails, outlasts 15 seconds or `PI_OFFLINE` is set, and
|
|
155
|
-
* when the credentials authenticate no provider at all.
|
|
156
|
-
*/
|
|
157
|
-
export function refreshModelCatalog(dir, options = {}) {
|
|
158
|
-
return refreshModelCatalogOver(dir, options);
|
|
159
|
-
}
|
|
160
|
-
/** {@link refreshModelCatalog} against another catalog server. Not public: a test seam. */
|
|
161
|
-
export async function refreshModelCatalogOver(dir, options, catalogBaseUrl) {
|
|
162
|
-
const { agentDir } = resolvePlacement(dir);
|
|
163
|
-
const { credentials } = agentModels(agentDir, options);
|
|
164
|
-
await refreshCatalog(join(agentDir, AGENT_MODEL_CATALOG_FILE), (catalogFile) => createPiModelRuntime({
|
|
165
|
-
agentDir,
|
|
166
|
-
credentials,
|
|
167
|
-
catalogFile,
|
|
168
|
-
...(catalogBaseUrl ? { catalogBaseUrl } : {}),
|
|
169
|
-
}), options.signal ? { signal: options.signal } : {});
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Refresh the MACHINE's model catalog (`~/.fastagent/models-store.json`), which every agent here reads under its own,
|
|
173
|
-
* so one refresh serves them all and no file is written into any agent. Credentials resolve as for
|
|
174
|
-
* {@link refreshModelCatalog} without a directory: `credentialStore`, else `authPath`, else the global credentials file;
|
|
175
|
-
* the environment applies either way. Rejects for the same reasons. The file never ships with a deploy.
|
|
176
|
-
*/
|
|
177
|
-
export function refreshMachineModelCatalog(options = {}) {
|
|
178
|
-
return refreshMachineModelCatalogOver(options);
|
|
179
|
-
}
|
|
180
|
-
/** {@link refreshMachineModelCatalog} against another catalog server. Not public: a test seam. */
|
|
181
|
-
export async function refreshMachineModelCatalogOver(options, catalogBaseUrl) {
|
|
182
|
-
const { credentials } = agentModels(undefined, options);
|
|
183
|
-
await refreshCatalog(globalCatalogPath(), (catalogFile) => machineModelRuntime({
|
|
184
|
-
credentials,
|
|
185
|
-
catalogFile,
|
|
186
|
-
...(catalogBaseUrl ? { catalogBaseUrl } : {}),
|
|
187
|
-
}), options.signal ? { signal: options.signal } : {});
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* "Point at a directory → agent": resolve the placement (`dir` may be either end — the workspace or the agent dir
|
|
191
|
-
* itself), load the config, resolve model and tools, then L2.
|
|
192
|
-
*/
|
|
193
|
-
export async function createPiAgentFromDir(dir, options = {}) {
|
|
194
|
-
const front = await resolveAgentAssembly(dir, options);
|
|
195
|
-
const { config, configPath, modelSpec, agentDir, workspace, stateRoot, models, tools, toolNames, indirectTools, toolCollisions, } = front;
|
|
196
|
-
// Every serve mounts the built-in `wake` tool: the agent's own follow-up work is a default capability, and a serve
|
|
197
|
-
// is where the poller that honors it runs. A one-shot `invoke` has no poller, so nothing there would fire it.
|
|
198
|
-
const mountedTools = withWakeTool(tools, stateRoot, !!options.serving);
|
|
199
|
-
// An explicit value is used as given (the store resolves a relative one against the WORKSPACE); without one, the
|
|
200
|
-
// resolution every reader shares (config.ts), so a serve and an `info` never report on different directories.
|
|
201
|
-
const sessionsDir = options.sessionsDir ?? resolveSessionsDir(agentDir);
|
|
202
|
-
await mkdir(sessionsDir, { recursive: true });
|
|
203
|
-
const sessions = piSessionRecordStore({ dir: sessionsDir, cwd: workspace });
|
|
204
|
-
// Skills are definition-only (the agent is its directory), so dev mirrors deployment exactly.
|
|
205
|
-
const { assembly, definition } = await assembleFront(front, { tools: mountedTools, sessions });
|
|
206
|
-
// The hub is wired HERE because the store is created here (an external `createPiSessionControl` cannot exist before
|
|
207
|
-
// the store does).
|
|
208
|
-
const caller = options.observer;
|
|
209
|
-
// TWO decisions, not one. The hub is in-process bookkeeping over the run observer: a serve gets it unconditionally,
|
|
210
|
-
// because `/stop` in a chat is an ordinary thing to ask for and reaching the live run is the only way to answer it.
|
|
211
|
-
// Publishing `/control/*` — steer, rewrite, delete, unauthenticated at whatever URL this serves on — is the
|
|
212
|
-
// separate decision `config.sessionControl` makes, and it is the only one that also wires the boundary.
|
|
213
|
-
const publish = options.sessionControl ?? config.sessionControl === true;
|
|
214
|
-
const wantControl = publish || options.serving === true;
|
|
215
|
-
let hub;
|
|
216
|
-
if (wantControl) {
|
|
217
|
-
// The hub's surface is synchronous (`capabilities()` lists the allowed models), while building the registry reads
|
|
218
|
-
// credentials and is not. Resolved only when the boundary is wired, so an ordinary serve does not pay for it.
|
|
219
|
-
const boundary = publish
|
|
220
|
-
? await assembly.engine().then(({ modelRuntime, model }) => ({
|
|
221
|
-
lease: assembly.lease,
|
|
222
|
-
models: modelRuntime,
|
|
223
|
-
sessionFactory: assembly.sessionFactory,
|
|
224
|
-
defaults: { ...(model ? { model } : {}), thinkingLevel: assembly.thinkingLevel },
|
|
225
|
-
}))
|
|
226
|
-
: undefined;
|
|
227
|
-
hub = createPiSessionControl({
|
|
228
|
-
sessions,
|
|
229
|
-
boundary,
|
|
230
|
-
// What a client offers is what a turn WOULD run, which since this agent inherits its machine is not the
|
|
231
|
-
// definition alone. Built through the same resource posture the turn uses, so the menu cannot list a name
|
|
232
|
-
// the prompt would not expand — a second reading of "which skills exist" is how those two come to disagree.
|
|
233
|
-
commands: () => agentCommands(agentDir, workspace, {
|
|
234
|
-
extensionPaths: assembly.extensionPaths,
|
|
235
|
-
modelRuntime: assembly.createModelRuntime,
|
|
236
|
-
}),
|
|
237
|
-
// The caller tap's boundary-event half: state_changed/compaction_* originate in the hub and never cross the
|
|
238
|
-
// data plane's observer seam.
|
|
239
|
-
tap: caller ? (session, event) => caller(session, event) : undefined,
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
const observer = hub
|
|
243
|
-
? caller
|
|
244
|
-
? (session, event, run) => {
|
|
245
|
-
hub.observer(session, event, run);
|
|
246
|
-
caller(session, event, run);
|
|
247
|
-
}
|
|
248
|
-
: hub.observer
|
|
249
|
-
: caller;
|
|
250
|
-
const agent = agentOf(assembly, observer);
|
|
251
|
-
return {
|
|
252
|
-
agent,
|
|
253
|
-
definition,
|
|
254
|
-
sessions,
|
|
255
|
-
sessionControl: hub?.control,
|
|
256
|
-
publishControl: publish,
|
|
257
|
-
http: config.http,
|
|
258
|
-
agentDir,
|
|
259
|
-
workspace,
|
|
260
|
-
config,
|
|
261
|
-
configPath,
|
|
262
|
-
...(modelSpec ? { modelSpec } : {}),
|
|
263
|
-
stateRoot,
|
|
264
|
-
sessionsDir,
|
|
265
|
-
models,
|
|
266
|
-
toolNames,
|
|
267
|
-
indirectTools,
|
|
268
|
-
toolCollisions,
|
|
269
|
-
};
|
|
270
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The models a Sign in with ChatGPT can run on the `openai` provider: the ACCOUNT's catalog, which OpenAI publishes at
|
|
3
|
-
* `GET /v1/models` for the same access token, not pi's built-in list (most of which such an account is refused).
|
|
4
|
-
*
|
|
5
|
-
* pi lists a provider's models through `filterModels`, which is synchronous, so the catalog is read when there is a
|
|
6
|
-
* token to read it with (login and every token refresh) and kept on the credential, like the account it belongs to:
|
|
7
|
-
* a new account brings its own list, and nothing per-account lands in the definition's model catalog. pi's `openai`
|
|
8
|
-
* provider does not do this itself (checked against pi 0.99.2), so {@link withAccountModels} wraps it. An API key on the same
|
|
9
|
-
* provider keeps the built-in list.
|
|
10
|
-
*/
|
|
11
|
-
import type { Credential, Provider } from "@earendil-works/pi-ai";
|
|
12
|
-
import type { ModelRuntime } from "@earendil-works/pi-coding-agent";
|
|
13
|
-
export declare const OPENAI_PROVIDER = "openai";
|
|
14
|
-
/**
|
|
15
|
-
* Why the stored `openai` credential lists no models, when that is because its sign-in carries no catalog: the one
|
|
16
|
-
* wording a listing reports instead of falling back to every built-in model.
|
|
17
|
-
*/
|
|
18
|
-
export declare function missingAccountModels(credential: Credential | undefined): string | undefined;
|
|
19
|
-
/**
|
|
20
|
-
* `provider` with the account catalog: read at login and at each token refresh, and the only models a ChatGPT
|
|
21
|
-
* sign-in lists. Anything without OAuth is returned as is.
|
|
22
|
-
*/
|
|
23
|
-
export declare function withAccountModels(provider: Provider): Provider;
|
|
24
|
-
/**
|
|
25
|
-
* Put {@link withAccountModels} on a runtime's `openai`, over the provider the runtime composed (pi's remote catalog,
|
|
26
|
-
* the agent's models.json, and an extension's `registerProvider("openai", …)` included), so none of them is lost. pi
|
|
27
|
-
* composes a native provider with models.json once more; that second pass is idempotent today, and
|
|
28
|
-
* openai-account-models.test.ts holds it to that. Call it inside `withModelRegistration`, and again after extensions
|
|
29
|
-
* load: pi's `registerProvider` drops a native provider, and a refresh without the wrapper would store a credential
|
|
30
|
-
* without its catalog. Repeating it is harmless.
|
|
31
|
-
*
|
|
32
|
-
* Known ceiling: an extension that registers `openai` later than its load (from an event handler) drops the wrapper
|
|
33
|
-
* for that runtime.
|
|
34
|
-
*/
|
|
35
|
-
export declare function registerAccountModels(runtime: ModelRuntime): void;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { log } from "../../log.js";
|
|
2
|
-
export const OPENAI_PROVIDER = "openai";
|
|
3
|
-
const ACCOUNT_MODELS_URL = "https://api.openai.com/v1/models";
|
|
4
|
-
/** Where the catalog is kept on the stored credential: the model ids the account lists, in OpenAI's order. */
|
|
5
|
-
const ACCOUNT_MODELS_FIELD = "accountModels";
|
|
6
|
-
/** A token refresh is bounded at 15s by pi; the catalog read must leave it room to finish and be stored. */
|
|
7
|
-
const CATALOG_TIMEOUT_MS = 5_000;
|
|
8
|
-
/** The slugs the account lists for a picker (`visibility: "list"`), in the server's order. */
|
|
9
|
-
async function fetchAccountModels(access, signal) {
|
|
10
|
-
const timeout = AbortSignal.timeout(CATALOG_TIMEOUT_MS);
|
|
11
|
-
const response = await fetch(ACCOUNT_MODELS_URL, {
|
|
12
|
-
headers: { accept: "application/json", authorization: `Bearer ${access}` },
|
|
13
|
-
signal: signal ? AbortSignal.any([signal, timeout]) : timeout,
|
|
14
|
-
});
|
|
15
|
-
if (!response.ok) {
|
|
16
|
-
const body = await response.text().catch(() => "");
|
|
17
|
-
throw new Error(`GET ${ACCOUNT_MODELS_URL} answered ${response.status}: ${body || response.statusText}`);
|
|
18
|
-
}
|
|
19
|
-
const models = (await response.json())?.models;
|
|
20
|
-
if (!Array.isArray(models))
|
|
21
|
-
throw new Error(`GET ${ACCOUNT_MODELS_URL} answered without a "models" array`);
|
|
22
|
-
return models.flatMap((entry) => entry?.visibility === "list" && typeof entry.slug === "string" ? [entry.slug] : []);
|
|
23
|
-
}
|
|
24
|
-
/** The catalog a ChatGPT sign-in carries, or undefined when it carries none (signed in before it was read). */
|
|
25
|
-
function accountModels(credential) {
|
|
26
|
-
const ids = credential[ACCOUNT_MODELS_FIELD];
|
|
27
|
-
return Array.isArray(ids) && ids.every((id) => typeof id === "string") ? ids : undefined;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Why the stored `openai` credential lists no models, when that is because its sign-in carries no catalog: the one
|
|
31
|
-
* wording a listing reports instead of falling back to every built-in model.
|
|
32
|
-
*/
|
|
33
|
-
export function missingAccountModels(credential) {
|
|
34
|
-
if (credential?.type !== "oauth" || accountModels(credential))
|
|
35
|
-
return undefined;
|
|
36
|
-
return ("[fastagent] the ChatGPT sign-in for openai carries no model catalog, so it lists no models: it is read at " +
|
|
37
|
-
"login and on each token refresh. Run `fastagent login` to read it now");
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* `provider` with the account catalog: read at login and at each token refresh, and the only models a ChatGPT
|
|
41
|
-
* sign-in lists. Anything without OAuth is returned as is.
|
|
42
|
-
*/
|
|
43
|
-
export function withAccountModels(provider) {
|
|
44
|
-
const oauth = provider.auth.oauth;
|
|
45
|
-
if (!oauth)
|
|
46
|
-
return provider;
|
|
47
|
-
const wrapped = {
|
|
48
|
-
...oauth,
|
|
49
|
-
async login(interaction, options) {
|
|
50
|
-
const credential = await oauth.login(interaction, options);
|
|
51
|
-
try {
|
|
52
|
-
return {
|
|
53
|
-
...credential,
|
|
54
|
-
[ACCOUNT_MODELS_FIELD]: await fetchAccountModels(credential.access, interaction.signal),
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
// The sign-in itself worked and inference needs nothing more: keep it, and say the list is empty until the
|
|
59
|
-
// next token refresh reads the catalog.
|
|
60
|
-
interaction.notify({
|
|
61
|
-
type: "info",
|
|
62
|
-
message: `could not read this ChatGPT account's model catalog (${error.message}); it lists no models until the next token refresh or login`,
|
|
63
|
-
});
|
|
64
|
-
return credential;
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
async refresh(credential, signal) {
|
|
68
|
-
const next = await oauth.refresh(credential, signal);
|
|
69
|
-
try {
|
|
70
|
-
return { ...next, [ACCOUNT_MODELS_FIELD]: await fetchAccountModels(next.access, signal) };
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
// NEVER fail here: the refresh token was just rotated, and a throw would leave the new one unstored and the
|
|
74
|
-
// old one spent. The previous catalog stands.
|
|
75
|
-
log.warn(`[fastagent] could not refresh the ChatGPT account's model catalog: ${error.message}`);
|
|
76
|
-
const previous = accountModels(credential);
|
|
77
|
-
return previous ? { ...next, [ACCOUNT_MODELS_FIELD]: previous } : next;
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
return {
|
|
82
|
-
...provider,
|
|
83
|
-
auth: { ...provider.auth, oauth: wrapped },
|
|
84
|
-
filterModels: (models, credential) => {
|
|
85
|
-
const base = provider.filterModels?.(models, credential) ?? models;
|
|
86
|
-
if (credential?.type !== "oauth")
|
|
87
|
-
return base;
|
|
88
|
-
const listed = new Set(accountModels(credential) ?? []);
|
|
89
|
-
return base.filter((model) => listed.has(model.id));
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
/** Providers this module built, so a second registration leaves them as they are instead of wrapping them again. */
|
|
94
|
-
const wrappedProviders = new WeakSet();
|
|
95
|
-
/**
|
|
96
|
-
* Put {@link withAccountModels} on a runtime's `openai`, over the provider the runtime composed (pi's remote catalog,
|
|
97
|
-
* the agent's models.json, and an extension's `registerProvider("openai", …)` included), so none of them is lost. pi
|
|
98
|
-
* composes a native provider with models.json once more; that second pass is idempotent today, and
|
|
99
|
-
* openai-account-models.test.ts holds it to that. Call it inside `withModelRegistration`, and again after extensions
|
|
100
|
-
* load: pi's `registerProvider` drops a native provider, and a refresh without the wrapper would store a credential
|
|
101
|
-
* without its catalog. Repeating it is harmless.
|
|
102
|
-
*
|
|
103
|
-
* Known ceiling: an extension that registers `openai` later than its load (from an event handler) drops the wrapper
|
|
104
|
-
* for that runtime.
|
|
105
|
-
*/
|
|
106
|
-
export function registerAccountModels(runtime) {
|
|
107
|
-
const registered = runtime.getRegisteredNativeProvider(OPENAI_PROVIDER);
|
|
108
|
-
if (registered && wrappedProviders.has(registered))
|
|
109
|
-
return;
|
|
110
|
-
const provider = runtime.getProvider(OPENAI_PROVIDER);
|
|
111
|
-
if (!provider)
|
|
112
|
-
return;
|
|
113
|
-
const wrapped = withAccountModels(provider);
|
|
114
|
-
wrappedProviders.add(wrapped);
|
|
115
|
-
runtime.registerNativeProvider(wrapped);
|
|
116
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { DefinitionDiagnostic, DefinitionShadow, LoadedDefinition, SkillCollision } from "./definition.ts";
|
|
2
|
-
import type { ToolCollision } from "./tool.ts";
|
|
3
|
-
import type { IndirectTool } from "./create.ts";
|
|
4
|
-
type Findings = {
|
|
5
|
-
collisions: SkillCollision[];
|
|
6
|
-
diagnostics: DefinitionDiagnostic[];
|
|
7
|
-
shadowed?: DefinitionShadow[];
|
|
8
|
-
ignored?: LoadedDefinition["ignored"];
|
|
9
|
-
};
|
|
10
|
-
/** THE door for definition findings: warns only when this dir's set CHANGED since the last report. */
|
|
11
|
-
export declare function reportFindingsIfChanged(dir: string, def: Findings): void;
|
|
12
|
-
export declare function reportDefinitionWarnings(def: Findings): void;
|
|
13
|
-
/** What the agent's system prompt is made of, as a report line: pi's default or `SYSTEM.md`, plus an addendum. */
|
|
14
|
-
export declare function describePrompt(def: Pick<LoadedDefinition, "dir" | "systemPrompt" | "appendSystemPrompt">): string;
|
|
15
|
-
/** The report line for the mounted tools the model is not given up front: each name with its way in. */
|
|
16
|
-
export declare function describeIndirectTools(tools: readonly IndirectTool[]): string;
|
|
17
|
-
export declare function reportToolCollisions(collisions: ToolCollision[]): void;
|
|
18
|
-
export {};
|