@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,14 +0,0 @@
|
|
|
1
|
-
/** Scoped acquisition of the two things a pi turn or control write owns: the session lease and the
|
|
2
|
-
* bound session. The Promise crossing itself is `src/effect-port.ts`. */
|
|
3
|
-
import * as Effect from "effect/Effect";
|
|
4
|
-
import type { PiAgentSessionFactory } from "./invoke-session.ts";
|
|
5
|
-
import type { SessionInheritance } from "./session-inheritance.ts";
|
|
6
|
-
import type { Lease } from "./turn-kit.ts";
|
|
7
|
-
/** Admission was refused: another turn (or another write) holds this session. Its own tag because it
|
|
8
|
-
* is CONTROL FLOW — a caller answers it with `session_busy` and a retry — not a port failure. */
|
|
9
|
-
export declare class SessionBusy extends Error {
|
|
10
|
-
readonly _tag = "SessionBusy";
|
|
11
|
-
constructor();
|
|
12
|
-
}
|
|
13
|
-
export declare function acquireSessionLease(lease: Lease, session: string): Effect.Effect<import("./turn-kit.ts").Release, SessionBusy, import("effect/Scope").Scope>;
|
|
14
|
-
export declare function acquireSession(factory: PiAgentSessionFactory, session: string, inherit?: SessionInheritance): Effect.Effect<import("@earendil-works/pi-coding-agent").AgentSession, import("../../effect-port.ts").PortFailure, import("effect/Scope").Scope>;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/** Scoped acquisition of the two things a pi turn or control write owns: the session lease and the
|
|
2
|
-
* bound session. The Promise crossing itself is `src/effect-port.ts`. */
|
|
3
|
-
import * as Effect from "effect/Effect";
|
|
4
|
-
import { port, portCleanup } from "../../effect-port.js";
|
|
5
|
-
/** Admission was refused: another turn (or another write) holds this session. Its own tag because it
|
|
6
|
-
* is CONTROL FLOW — a caller answers it with `session_busy` and a retry — not a port failure. */
|
|
7
|
-
export class SessionBusy extends Error {
|
|
8
|
-
_tag = "SessionBusy";
|
|
9
|
-
constructor() {
|
|
10
|
-
super("session busy: a turn or another write is already in flight");
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export function acquireSessionLease(lease, session) {
|
|
14
|
-
return Effect.acquireRelease(Effect.suspend(() => {
|
|
15
|
-
const release = lease.tryAcquire(session);
|
|
16
|
-
return release ? Effect.succeed(release) : Effect.fail(new SessionBusy());
|
|
17
|
-
}), (release) => portCleanup("lease release", release));
|
|
18
|
-
}
|
|
19
|
-
export function acquireSession(factory, session, inherit) {
|
|
20
|
-
// Acquisition stays uninterruptible: a late factory may still publish durable state under the lease.
|
|
21
|
-
// The extension instances are this session's alone, so their end is its end: pi's `dispose()` does not tell them.
|
|
22
|
-
return Effect.acquireRelease(port(() => factory(session, inherit)), (bound) => portCleanup("dispose", async () => {
|
|
23
|
-
try {
|
|
24
|
-
await bound.extensionRunner.emit({ type: "session_shutdown", reason: "quit" });
|
|
25
|
-
}
|
|
26
|
-
finally {
|
|
27
|
-
bound.dispose();
|
|
28
|
-
}
|
|
29
|
-
}));
|
|
30
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type SessionManager } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
/** What a Caller names when a new session should start from an existing one. */
|
|
3
|
-
export interface SessionInheritance {
|
|
4
|
-
parentSession: string;
|
|
5
|
-
/**
|
|
6
|
-
* Opaque markers that MAY locate the branch point on the parent's active path (searched in message content, first
|
|
7
|
-
* hit wins, most recent occurrence).
|
|
8
|
-
*/
|
|
9
|
-
branchHints?: string[];
|
|
10
|
-
}
|
|
11
|
-
/** The branch point this inheritance should copy up to, and the parent's path. */
|
|
12
|
-
export declare function inheritanceCut(parent: SessionManager, branchHints?: string[]): {
|
|
13
|
-
at: string;
|
|
14
|
-
} | undefined;
|
|
15
|
-
/**
|
|
16
|
-
* Copy the parent's path up to `at` into `child`, entry by entry — what a backend with no FILE to fork has to do
|
|
17
|
-
* instead.
|
|
18
|
-
*/
|
|
19
|
-
export declare function copyBranchInto(parent: SessionManager, child: SessionManager, at: string): void;
|
|
20
|
-
/** {@link copyBranchInto} plus the inheritance window — what a new THREAD gets and a fork does not. */
|
|
21
|
-
export declare function copyBranchForInheritance(parent: SessionManager, child: SessionManager, at: string): void;
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import { estimateTokens } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { log } from "../../log.js";
|
|
3
|
-
import { isConversationMessage, isPlaneMarker } from "./session-markers.js";
|
|
4
|
-
/** Inheritance window: at most this many exchanges of the parent reach the child's model context. */
|
|
5
|
-
const INHERIT_MAX_EXCHANGES = 50;
|
|
6
|
-
/** …and at most roughly this many tokens (~1/4 of a 200K context: generous, not everything). */
|
|
7
|
-
const INHERIT_MAX_TOKENS = 50_000;
|
|
8
|
-
/**
|
|
9
|
-
* Branch hints are IDS, not payloads: each one costs a scan over the parent's serialized path, and the wire accepts
|
|
10
|
-
* arbitrary arrays.
|
|
11
|
-
*/
|
|
12
|
-
const MAX_BRANCH_HINTS = 16;
|
|
13
|
-
const MAX_BRANCH_HINT_CHARS = 128;
|
|
14
|
-
function isUserMessage(entry) {
|
|
15
|
-
return entry?.type === "message" && entry.message?.role === "user";
|
|
16
|
-
}
|
|
17
|
-
/** Find the fork target on the parent's active path. */
|
|
18
|
-
function locateBranchPoint(path, hints) {
|
|
19
|
-
const usable = hints
|
|
20
|
-
.filter((hint) => hint.length > 0 && hint.length <= MAX_BRANCH_HINT_CHARS)
|
|
21
|
-
.slice(0, MAX_BRANCH_HINTS);
|
|
22
|
-
if (usable.length < hints.length) {
|
|
23
|
-
log.warn(`[fastagent] ignored ${hints.length - usable.length} branch hint(s) (over ${MAX_BRANCH_HINTS} hints or ${MAX_BRANCH_HINT_CHARS} chars each) — hints are message ids, not payloads`);
|
|
24
|
-
}
|
|
25
|
-
if (usable.length === 0)
|
|
26
|
-
return undefined;
|
|
27
|
-
// Serialize each conversation message ONCE — the scan is hints × entries, and stringify must not sit in the inner
|
|
28
|
-
// loop. A hint is something a participant said, so the engine's own system entries are not searched: see
|
|
29
|
-
// `isConversationMessage` for what a hint landing in the assembled prompt would otherwise do here.
|
|
30
|
-
const serialized = path.map((entry) => (isConversationMessage(entry) ? JSON.stringify(entry.message) : ""));
|
|
31
|
-
for (const hint of usable) {
|
|
32
|
-
for (let i = path.length - 1; i >= 0; i--) {
|
|
33
|
-
if (!serialized[i]?.includes(hint))
|
|
34
|
-
continue;
|
|
35
|
-
let j = i + 1;
|
|
36
|
-
while (j < path.length && !isUserMessage(path[j]))
|
|
37
|
-
j++;
|
|
38
|
-
return path[j - 1]?.id;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Bound what the child's MODEL CONTEXT starts with. Measured on pi's projection, what the model will actually see:
|
|
45
|
-
* a `context_edit` omission (an abandoned retry or overflow attempt) costs nothing, and the engine's own `system`
|
|
46
|
-
* entries are not history. The newest copied compaction (its summary, then the tail it retained) reaches the model
|
|
47
|
-
* only while no window is cut: pi reads the NEWEST compaction alone, so a mark placed after it drops that tail. Its
|
|
48
|
-
* summary, a few hundred tokens covering everything older, is carried into the mark instead.
|
|
49
|
-
*/
|
|
50
|
-
function markInheritanceWindow(child) {
|
|
51
|
-
const path = child.getBranch();
|
|
52
|
-
const position = new Map(path.map((entry, i) => [entry.id, i]));
|
|
53
|
-
const latest = path.map((entry) => entry.type).lastIndexOf("compaction");
|
|
54
|
-
const previous = latest >= 0 ? path[latest] : undefined;
|
|
55
|
-
let summaryTokens = 0;
|
|
56
|
-
let tailTokens = 0;
|
|
57
|
-
let tailExchanges = 0;
|
|
58
|
-
const scanned = [];
|
|
59
|
-
for (const { sourceEntry, messages } of child.buildSessionProjection().entries) {
|
|
60
|
-
const tokens = messages.reduce((sum, message) => (message.role === "system" ? sum : sum + estimateTokens(message)), 0);
|
|
61
|
-
const startsExchange = sourceEntry.type === "message" && sourceEntry.message.role === "user" && messages.length > 0;
|
|
62
|
-
if (sourceEntry.id === previous?.id)
|
|
63
|
-
summaryTokens += tokens;
|
|
64
|
-
else if ((position.get(sourceEntry.id) ?? -1) < latest) {
|
|
65
|
-
// The retained tail: journal entries BEFORE the compaction that pi still projects.
|
|
66
|
-
tailTokens += tokens;
|
|
67
|
-
if (startsExchange)
|
|
68
|
-
tailExchanges++;
|
|
69
|
-
}
|
|
70
|
-
else
|
|
71
|
-
scanned.push({ id: sourceEntry.id, tokens, startsExchange });
|
|
72
|
-
}
|
|
73
|
-
const starts = [];
|
|
74
|
-
scanned.forEach((entry, i) => {
|
|
75
|
-
if (entry.startsExchange)
|
|
76
|
-
starts.push(i);
|
|
77
|
-
});
|
|
78
|
-
if (starts.length === 0)
|
|
79
|
-
return; // no exchange after the compaction to place a mark at
|
|
80
|
-
const suffixTokens = new Array(scanned.length + 1).fill(0);
|
|
81
|
-
for (let i = scanned.length - 1; i >= 0; i--) {
|
|
82
|
-
suffixTokens[i] = (suffixTokens[i + 1] ?? 0) + (scanned[i]?.tokens ?? 0);
|
|
83
|
-
}
|
|
84
|
-
const fits = (exchanges, tokens) => exchanges <= INHERIT_MAX_EXCHANGES && tokens <= INHERIT_MAX_TOKENS;
|
|
85
|
-
const everything = summaryTokens + tailTokens + (suffixTokens[0] ?? 0);
|
|
86
|
-
if (fits(tailExchanges + starts.length, everything))
|
|
87
|
-
return; // the whole visible history fits the window
|
|
88
|
-
// Cut: the tail goes, the summary stays (carried below). The newest exchange is the floor.
|
|
89
|
-
let chosen = starts.length - 1;
|
|
90
|
-
for (let k = starts.length - 2; k >= 0; k--) {
|
|
91
|
-
if (!fits(starts.length - k, summaryTokens + (suffixTokens[starts[k] ?? 0] ?? 0)))
|
|
92
|
-
break;
|
|
93
|
-
chosen = k;
|
|
94
|
-
}
|
|
95
|
-
// Without a compaction, a mark at the first exchange would hide nothing that costs tokens.
|
|
96
|
-
if (!previous && chosen === 0)
|
|
97
|
-
return;
|
|
98
|
-
const boundary = scanned[starts[chosen] ?? 0];
|
|
99
|
-
if (boundary === undefined)
|
|
100
|
-
return;
|
|
101
|
-
const hidden = tailExchanges + chosen;
|
|
102
|
-
const note = hidden > 0
|
|
103
|
-
? `Inherited from the parent conversation; ${hidden} earlier exchange(s) are not shown.`
|
|
104
|
-
: "Inherited from the parent conversation; earlier messages are not shown.";
|
|
105
|
-
child.appendCompaction(previous ? `${previous.summary}\n\n${note}` : note, boundary.id, everything);
|
|
106
|
-
}
|
|
107
|
-
/** The branch point this inheritance should copy up to, and the parent's path. */
|
|
108
|
-
export function inheritanceCut(parent, branchHints) {
|
|
109
|
-
const path = parent.getBranch();
|
|
110
|
-
const leaf = path[path.length - 1];
|
|
111
|
-
if (!leaf)
|
|
112
|
-
return undefined; // an empty parent has nothing to inherit
|
|
113
|
-
const hints = branchHints ?? [];
|
|
114
|
-
const at = locateBranchPoint(path, hints);
|
|
115
|
-
if (at === undefined && hints.length > 0) {
|
|
116
|
-
log.warn("[fastagent] no branch hint matched in the parent session — inheriting from its present");
|
|
117
|
-
}
|
|
118
|
-
return { at: at ?? leaf.id };
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Copy the parent's path up to `at` into `child`, entry by entry — what a backend with no FILE to fork has to do
|
|
122
|
-
* instead.
|
|
123
|
-
*/
|
|
124
|
-
export function copyBranchInto(parent, child, at) {
|
|
125
|
-
/**
|
|
126
|
-
* Parent entry id → the child's id for that entry: the copy mints its own, and a compaction points BACK into the
|
|
127
|
-
* path it was appended to.
|
|
128
|
-
*/
|
|
129
|
-
const copied = new Map();
|
|
130
|
-
/** Ids of entries this copy did NOT append. */
|
|
131
|
-
let unanchored = [];
|
|
132
|
-
const record = (parentId, childId) => {
|
|
133
|
-
for (const id of unanchored)
|
|
134
|
-
copied.set(id, childId);
|
|
135
|
-
unanchored = [];
|
|
136
|
-
copied.set(parentId, childId);
|
|
137
|
-
};
|
|
138
|
-
// Typed by pi's own union, and exhaustive: a pi release that adds an entry type fails typecheck here instead of
|
|
139
|
-
// being dropped from every copied branch without a word.
|
|
140
|
-
for (const entry of parent.getBranch(at)) {
|
|
141
|
-
let childId;
|
|
142
|
-
switch (entry.type) {
|
|
143
|
-
case "message":
|
|
144
|
-
// Every message, INCLUDING the engine's system entries: the child starts from the prompt the parent was
|
|
145
|
-
// running under, and pi diffs its own sections against it, so the thread's first request carries that
|
|
146
|
-
// prompt once rather than twice.
|
|
147
|
-
childId = child.appendMessage(entry.message);
|
|
148
|
-
break;
|
|
149
|
-
case "custom_message":
|
|
150
|
-
// Model-visible history, unlike the `custom` entries below it: an extension injected it INTO the
|
|
151
|
-
// conversation, and the assistant messages answering it are being copied.
|
|
152
|
-
childId = child.appendCustomMessageEntry(entry.customType, entry.content, entry.display, entry.details);
|
|
153
|
-
break;
|
|
154
|
-
case "compaction":
|
|
155
|
-
// `firstKeptEntryId` is where the RETAINED TAIL starts — the entries pi did not summarize, which still reach
|
|
156
|
-
// the model.
|
|
157
|
-
childId = child.appendCompaction(entry.summary, copied.get(entry.firstKeptEntryId) ?? "", entry.tokensBefore, entry.details);
|
|
158
|
-
break;
|
|
159
|
-
case "context_edit": {
|
|
160
|
-
// pi omits an abandoned retry/overflow attempt from the model's context this way; dropping the edit would
|
|
161
|
-
// hand that attempt back to the copy. Its target is a message, which the copy always anchors.
|
|
162
|
-
const target = copied.get(entry.targetId);
|
|
163
|
-
if (target)
|
|
164
|
-
childId = child.appendContextEdit(target, entry.replacement);
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
case "model_change":
|
|
168
|
-
childId = child.appendModelChange(entry.provider, entry.modelId);
|
|
169
|
-
break;
|
|
170
|
-
case "thinking_level_change":
|
|
171
|
-
childId = child.appendThinkingLevelChange(entry.thinkingLevel);
|
|
172
|
-
break;
|
|
173
|
-
case "custom":
|
|
174
|
-
// The plane's markers describe the parent's RECORD, not the thread's history.
|
|
175
|
-
if (!isPlaneMarker(entry))
|
|
176
|
-
childId = child.appendCustomEntry(entry.customType, entry.data);
|
|
177
|
-
break;
|
|
178
|
-
case "label":
|
|
179
|
-
case "session_info":
|
|
180
|
-
case "branch_summary":
|
|
181
|
-
case "usage":
|
|
182
|
-
break; // the parent's facts, not the thread's history
|
|
183
|
-
default: {
|
|
184
|
-
// Unreachable by type; a record written by a newer pi can still carry one, and refusing to start the thread
|
|
185
|
-
// over it would be worse than naming it.
|
|
186
|
-
const unhandled = entry;
|
|
187
|
-
log.warn(`[fastagent] inheritance skipped a session entry of unknown type "${unhandled.type}"`);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (childId === undefined)
|
|
191
|
-
unanchored.push(entry.id);
|
|
192
|
-
else
|
|
193
|
-
record(entry.id, childId);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
/** {@link copyBranchInto} plus the inheritance window — what a new THREAD gets and a fork does not. */
|
|
197
|
-
export function copyBranchForInheritance(parent, child, at) {
|
|
198
|
-
copyBranchInto(parent, child, at);
|
|
199
|
-
markInheritanceWindow(child);
|
|
200
|
-
}
|
|
201
|
-
// There is deliberately NO file-level fork here. pi can copy a path into a new file (`createBranchedSession` +
|
|
202
|
-
// `forkFrom`), but that pair writes the intermediate only when the copied path contains an ASSISTANT message — so
|
|
203
|
-
// forking at a user entry hands `forkFrom` a path that does not exist, and the failure reads as retryable for a
|
|
204
|
-
// condition no retry can change.
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Which journal entries are POSITIONS, which are the control plane's own bookkeeping, and which are turns in the
|
|
3
|
-
* CONVERSATION. pi's journal has one shape for everything, so the plane writes what it needs to remember into the
|
|
4
|
-
* same log the conversation lives in (what fork a record is, and the anchor that makes a leaf move survive a
|
|
5
|
-
* reopen) — and since 0.86 the ENGINE writes its own bookkeeping there too, as the `system` entries carrying the
|
|
6
|
-
* assembled prompt. Three questions, one file: a reader of the journal answers them here or it answers them alone,
|
|
7
|
-
* which is how one reader came to count the prompt as history.
|
|
8
|
-
*/
|
|
9
|
-
import type { SessionManager } from "@earendil-works/pi-coding-agent";
|
|
10
|
-
/** What pins a leaf move to disk. pi's `branch()` writes nothing. */
|
|
11
|
-
export declare const LEAF_ANCHOR = "fastagent.leaf";
|
|
12
|
-
/**
|
|
13
|
-
* The CONTROL PLANE's bookkeeping — not a place in a conversation, so never published, never navigable, and never
|
|
14
|
-
* copied by a fork.
|
|
15
|
-
*/
|
|
16
|
-
export declare function isPlaneMarker(entry: {
|
|
17
|
-
type?: string;
|
|
18
|
-
customType?: string;
|
|
19
|
-
}): boolean;
|
|
20
|
-
/**
|
|
21
|
-
* An entry that is a TURN IN THE CONVERSATION — what a reader counting, previewing or searching the history means
|
|
22
|
-
* by "a message".
|
|
23
|
-
*
|
|
24
|
-
* The line it draws is the ENGINE's prompt state. Since pi 0.86 pi writes `system` messages into the same log the
|
|
25
|
-
* conversation lives in, carrying the assembled prompt (system prompt, project context, skill and tool descriptions)
|
|
26
|
-
* plus one more per prompt or tool-set change. They are bookkeeping, not something anyone said, and every reader
|
|
27
|
-
* of the journal has to decide about them. Deciding once, here, is the point: the first reader that forgot cut
|
|
28
|
-
* inheritance above every exchange and handed a new thread an empty history, with no diagnostic.
|
|
29
|
-
*/
|
|
30
|
-
export declare function isConversationMessage(entry: {
|
|
31
|
-
type?: string;
|
|
32
|
-
message?: {
|
|
33
|
-
role?: string;
|
|
34
|
-
};
|
|
35
|
-
}): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Every position a client may move the branch head to, and everything `entries()` publishes — ONE predicate, so
|
|
38
|
-
* "anything published is navigable" holds by construction.
|
|
39
|
-
*/
|
|
40
|
-
export declare function isNavigable(entry: {
|
|
41
|
-
type?: string;
|
|
42
|
-
customType?: string;
|
|
43
|
-
}): boolean;
|
|
44
|
-
/** The head a client SEES: the last publishable entry on the active path. */
|
|
45
|
-
export declare function publishedLeaf(record: SessionManager): string | undefined;
|
|
46
|
-
/** Stamp a fresh fork with where it came from. */
|
|
47
|
-
export declare function stampProvenance(record: SessionManager, provenance: string): void;
|
|
48
|
-
/** What fork this record IS, or undefined for a record that was not forked. */
|
|
49
|
-
export declare function forkProvenance(record: SessionManager): string | undefined;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* "This record is a fork of X at Y." Its own entry rather than pi's header `parentSession`, which pi fills from its
|
|
3
|
-
* own fork path and names a FILE, not the branch point idempotency needs.
|
|
4
|
-
*/
|
|
5
|
-
const FORK_PROVENANCE = "fastagent.fork";
|
|
6
|
-
/** What pins a leaf move to disk. pi's `branch()` writes nothing. */
|
|
7
|
-
export const LEAF_ANCHOR = "fastagent.leaf";
|
|
8
|
-
/**
|
|
9
|
-
* The CONTROL PLANE's bookkeeping — not a place in a conversation, so never published, never navigable, and never
|
|
10
|
-
* copied by a fork.
|
|
11
|
-
*/
|
|
12
|
-
export function isPlaneMarker(entry) {
|
|
13
|
-
return entry.type === "custom" && (entry.customType === FORK_PROVENANCE || entry.customType === LEAF_ANCHOR);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* An entry that is a TURN IN THE CONVERSATION — what a reader counting, previewing or searching the history means
|
|
17
|
-
* by "a message".
|
|
18
|
-
*
|
|
19
|
-
* The line it draws is the ENGINE's prompt state. Since pi 0.86 pi writes `system` messages into the same log the
|
|
20
|
-
* conversation lives in, carrying the assembled prompt (system prompt, project context, skill and tool descriptions)
|
|
21
|
-
* plus one more per prompt or tool-set change. They are bookkeeping, not something anyone said, and every reader
|
|
22
|
-
* of the journal has to decide about them. Deciding once, here, is the point: the first reader that forgot cut
|
|
23
|
-
* inheritance above every exchange and handed a new thread an empty history, with no diagnostic.
|
|
24
|
-
*/
|
|
25
|
-
export function isConversationMessage(entry) {
|
|
26
|
-
return entry.type === "message" && entry.message?.role !== "system";
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Every position a client may move the branch head to, and everything `entries()` publishes — ONE predicate, so
|
|
30
|
-
* "anything published is navigable" holds by construction.
|
|
31
|
-
*/
|
|
32
|
-
export function isNavigable(entry) {
|
|
33
|
-
return entry.type !== "label" && !isPlaneMarker(entry);
|
|
34
|
-
}
|
|
35
|
-
/** The head a client SEES: the last publishable entry on the active path. */
|
|
36
|
-
export function publishedLeaf(record) {
|
|
37
|
-
const path = record.getBranch();
|
|
38
|
-
for (let i = path.length - 1; i >= 0; i--) {
|
|
39
|
-
const entry = path[i];
|
|
40
|
-
if (entry && isNavigable(entry))
|
|
41
|
-
return entry.id;
|
|
42
|
-
}
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
/** Stamp a fresh fork with where it came from. */
|
|
46
|
-
export function stampProvenance(record, provenance) {
|
|
47
|
-
record.appendCustomEntry(FORK_PROVENANCE, { provenance });
|
|
48
|
-
}
|
|
49
|
-
/** What fork this record IS, or undefined for a record that was not forked. */
|
|
50
|
-
export function forkProvenance(record) {
|
|
51
|
-
let found;
|
|
52
|
-
for (const raw of record.getEntries()) {
|
|
53
|
-
if (raw.type !== "custom" || raw.customType !== FORK_PROVENANCE)
|
|
54
|
-
continue;
|
|
55
|
-
const value = raw.data?.provenance;
|
|
56
|
-
if (typeof value === "string")
|
|
57
|
-
found = value;
|
|
58
|
-
}
|
|
59
|
-
return found;
|
|
60
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/** What a session is SET TO, and what it may be set to. */
|
|
2
|
-
import type { ThinkingLevel } from "@earendil-works/pi-agent-core";
|
|
3
|
-
import { type Models } from "@earendil-works/pi-ai";
|
|
4
|
-
import type { SessionManager } from "@earendil-works/pi-coding-agent";
|
|
5
|
-
import type { ModelDescriptor } from "../../session.ts";
|
|
6
|
-
import type { AnyModel } from "./models.ts";
|
|
7
|
-
export declare const THINKING_LEVELS: ReadonlySet<ThinkingLevel>;
|
|
8
|
-
/**
|
|
9
|
-
* Models as a client's picker shows them, ordered by spec: the ONE description both listings give
|
|
10
|
-
* (`capabilities().allowedModels` and `availableModelsFromDir`). Its levels come from the function
|
|
11
|
-
* `resolveSessionSettings` reads, so a picker offers what `state()` will then report. A model that declares no name or
|
|
12
|
-
* context window (an extension's virtual model may not: pi reads the window as 0) leaves the field out rather than
|
|
13
|
-
* inventing one.
|
|
14
|
-
*/
|
|
15
|
-
export declare function describeModels(models: readonly AnyModel[]): ModelDescriptor[];
|
|
16
|
-
/** The shape both override consumers walk — a session entry, structurally. */
|
|
17
|
-
export interface OverrideEntryLike {
|
|
18
|
-
type: string;
|
|
19
|
-
provider?: string;
|
|
20
|
-
modelId?: string;
|
|
21
|
-
thinkingLevel?: string;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* The last entry of each kind wins, and a malformed one reads as ABSENT rather than falling through to an earlier
|
|
25
|
-
* record.
|
|
26
|
-
*/
|
|
27
|
-
export declare function lastOverrideEntries(entries: OverrideEntryLike[]): {
|
|
28
|
-
model?: {
|
|
29
|
-
provider: string;
|
|
30
|
-
modelId: string;
|
|
31
|
-
};
|
|
32
|
-
thinkingLevel?: string;
|
|
33
|
-
};
|
|
34
|
-
export interface SessionSettings {
|
|
35
|
-
model: AnyModel;
|
|
36
|
-
/** Already clamped to what {@link model} supports. */
|
|
37
|
-
thinkingLevel: ThinkingLevel;
|
|
38
|
-
/** What `update({ thinkingLevel })` accepts for this session. */
|
|
39
|
-
availableThinkingLevels: string[];
|
|
40
|
-
/** Recorded overrides that could not be applied. */
|
|
41
|
-
dropped?: {
|
|
42
|
-
model?: string;
|
|
43
|
-
thinkingLevel?: {
|
|
44
|
-
recorded: string;
|
|
45
|
-
running: string;
|
|
46
|
-
known: boolean;
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* `defaults` is the assembly's configured pair — what a session with no overrides runs on. An agent may set no default
|
|
52
|
-
* model, so a session runs on the model it records, else the default, else none: undefined then, and the session
|
|
53
|
-
* cannot run until it is given one ({@link MissingModel}).
|
|
54
|
-
*/
|
|
55
|
-
export declare function resolveSessionSettings(entries: OverrideEntryLike[], models: Models, defaults: {
|
|
56
|
-
model?: AnyModel;
|
|
57
|
-
thinkingLevel: ThinkingLevel;
|
|
58
|
-
}): SessionSettings | undefined;
|
|
59
|
-
/**
|
|
60
|
-
* A turn has no model to run on: its session records none this registry knows, and the agent sets no default. Its own
|
|
61
|
-
* class so the invoke answers it with `missing_model` instead of a prose failure.
|
|
62
|
-
*/
|
|
63
|
-
export declare class MissingModel extends Error {
|
|
64
|
-
constructor(session: string, entries: OverrideEntryLike[]);
|
|
65
|
-
}
|
|
66
|
-
/** The entries on the session's ACTIVE path, root→leaf — what every last-wins settings read walks. */
|
|
67
|
-
export declare function activePath(record: SessionManager, from?: string): OverrideEntryLike[];
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { clampThinkingLevel, getSupportedThinkingLevels } from "@earendil-works/pi-ai";
|
|
2
|
-
/** Which strings are levels at all — the vocabulary. */
|
|
3
|
-
const ALL_THINKING_LEVELS = {
|
|
4
|
-
off: true,
|
|
5
|
-
minimal: true,
|
|
6
|
-
low: true,
|
|
7
|
-
medium: true,
|
|
8
|
-
high: true,
|
|
9
|
-
xhigh: true,
|
|
10
|
-
max: true,
|
|
11
|
-
};
|
|
12
|
-
export const THINKING_LEVELS = new Set(Object.keys(ALL_THINKING_LEVELS));
|
|
13
|
-
/**
|
|
14
|
-
* Models as a client's picker shows them, ordered by spec: the ONE description both listings give
|
|
15
|
-
* (`capabilities().allowedModels` and `availableModelsFromDir`). Its levels come from the function
|
|
16
|
-
* `resolveSessionSettings` reads, so a picker offers what `state()` will then report. A model that declares no name or
|
|
17
|
-
* context window (an extension's virtual model may not: pi reads the window as 0) leaves the field out rather than
|
|
18
|
-
* inventing one.
|
|
19
|
-
*/
|
|
20
|
-
export function describeModels(models) {
|
|
21
|
-
return models
|
|
22
|
-
.map((model) => ({
|
|
23
|
-
spec: `${model.provider}/${model.id}`,
|
|
24
|
-
...(model.name ? { name: model.name } : {}),
|
|
25
|
-
thinkingLevels: getSupportedThinkingLevels(model),
|
|
26
|
-
...(model.contextWindow > 0 ? { contextWindow: model.contextWindow } : {}),
|
|
27
|
-
}))
|
|
28
|
-
.sort((a, b) => (a.spec < b.spec ? -1 : a.spec > b.spec ? 1 : 0));
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* The last entry of each kind wins, and a malformed one reads as ABSENT rather than falling through to an earlier
|
|
32
|
-
* record.
|
|
33
|
-
*/
|
|
34
|
-
export function lastOverrideEntries(entries) {
|
|
35
|
-
let model;
|
|
36
|
-
let modelSeen = false;
|
|
37
|
-
let thinkingLevel;
|
|
38
|
-
let thinkingSeen = false;
|
|
39
|
-
for (let i = entries.length - 1; i >= 0 && !(modelSeen && thinkingSeen); i--) {
|
|
40
|
-
const e = entries[i];
|
|
41
|
-
if (!modelSeen && e?.type === "model_change") {
|
|
42
|
-
modelSeen = true;
|
|
43
|
-
if (e.provider !== undefined && e.modelId !== undefined)
|
|
44
|
-
model = { provider: e.provider, modelId: e.modelId };
|
|
45
|
-
}
|
|
46
|
-
if (!thinkingSeen && e?.type === "thinking_level_change") {
|
|
47
|
-
thinkingSeen = true;
|
|
48
|
-
if (e.thinkingLevel !== undefined)
|
|
49
|
-
thinkingLevel = e.thinkingLevel;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return { model, thinkingLevel };
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* `defaults` is the assembly's configured pair — what a session with no overrides runs on. An agent may set no default
|
|
56
|
-
* model, so a session runs on the model it records, else the default, else none: undefined then, and the session
|
|
57
|
-
* cannot run until it is given one ({@link MissingModel}).
|
|
58
|
-
*/
|
|
59
|
-
export function resolveSessionSettings(entries, models, defaults) {
|
|
60
|
-
const recorded = lastOverrideEntries(entries);
|
|
61
|
-
const dropped = {};
|
|
62
|
-
// A registry change across deploys must not brick the conversation.
|
|
63
|
-
let model = defaults.model;
|
|
64
|
-
if (recorded.model) {
|
|
65
|
-
const found = models.getModel(recorded.model.provider, recorded.model.modelId);
|
|
66
|
-
if (found)
|
|
67
|
-
model = found;
|
|
68
|
-
else
|
|
69
|
-
dropped.model = `${recorded.model.provider}/${recorded.model.modelId}`;
|
|
70
|
-
}
|
|
71
|
-
if (!model)
|
|
72
|
-
return undefined;
|
|
73
|
-
const availableThinkingLevels = getSupportedThinkingLevels(model);
|
|
74
|
-
let thinkingLevel = clampThinkingLevel(model, defaults.thinkingLevel);
|
|
75
|
-
if (recorded.thinkingLevel !== undefined) {
|
|
76
|
-
const level = recorded.thinkingLevel;
|
|
77
|
-
if (!THINKING_LEVELS.has(level)) {
|
|
78
|
-
dropped.thinkingLevel = { recorded: level, running: thinkingLevel, known: false };
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
// pi's clamp takes the lowest supported level AT OR ABOVE the recorded one, falling back downward only when
|
|
82
|
-
// nothing is above.
|
|
83
|
-
thinkingLevel = clampThinkingLevel(model, level);
|
|
84
|
-
if (thinkingLevel !== level) {
|
|
85
|
-
dropped.thinkingLevel = { recorded: level, running: thinkingLevel, known: true };
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
model,
|
|
91
|
-
thinkingLevel,
|
|
92
|
-
availableThinkingLevels,
|
|
93
|
-
...(dropped.model || dropped.thinkingLevel ? { dropped } : {}),
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* A turn has no model to run on: its session records none this registry knows, and the agent sets no default. Its own
|
|
98
|
-
* class so the invoke answers it with `missing_model` instead of a prose failure.
|
|
99
|
-
*/
|
|
100
|
-
export class MissingModel extends Error {
|
|
101
|
-
constructor(session, entries) {
|
|
102
|
-
const recorded = lastOverrideEntries(entries).model;
|
|
103
|
-
super(`session "${session}" has no model: ${recorded
|
|
104
|
-
? `the model it records, ${recorded.provider}/${recorded.modelId}, is not one this agent knows,`
|
|
105
|
-
: "it records none,"} and the agent sets no default — give the session one (session control's update({ model })), or the agent ` +
|
|
106
|
-
`a default ("model" in fastagent.config.ts, or FASTAGENT_MODEL)`);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
/** The entries on the session's ACTIVE path, root→leaf — what every last-wins settings read walks. */
|
|
110
|
-
export function activePath(record, from) {
|
|
111
|
-
// `from` asks a different question: the path a leaf move is ABOUT to make active, which a caller validating a patch
|
|
112
|
-
// needs before the move exists.
|
|
113
|
-
const path = record.getBranch(from);
|
|
114
|
-
const root = path[0];
|
|
115
|
-
if (root?.parentId != null) {
|
|
116
|
-
throw new Error(`session entry "${root.parentId}" is missing from the journal (parent of "${root.id}")`);
|
|
117
|
-
}
|
|
118
|
-
return path;
|
|
119
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { SessionManager } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import type { SessionSummary, SessionUpdateField } from "../../session.ts";
|
|
3
|
-
import { type OverrideEntryLike } from "./session-settings.ts";
|
|
4
|
-
import { type SessionInheritance } from "./session-inheritance.ts";
|
|
5
|
-
/** The session RECORDS, as operations rather than as pi handles. */
|
|
6
|
-
export interface PiSessionRecordStore {
|
|
7
|
-
openOrCreate(sessionId: string, inherit?: SessionInheritance): Promise<SessionManager>;
|
|
8
|
-
/**
|
|
9
|
-
* OPEN-EXISTING sibling: an unknown session answers undefined, never creates one. The reads and every write that
|
|
10
|
-
* needs history go through it; creating is `openOrCreate`'s.
|
|
11
|
-
*/
|
|
12
|
-
openIfExists(sessionId: string): Promise<SessionManager | undefined>;
|
|
13
|
-
/** Write session properties, in the order pi's leaf pointer requires, and report what LANDED. */
|
|
14
|
-
applyProperties(sessionId: string, writes: PropertyWrites): Promise<AppliedProperties | undefined>;
|
|
15
|
-
/** Every record this store holds, in CALLER ids. */
|
|
16
|
-
list(): Promise<SessionSummary[]>;
|
|
17
|
-
/**
|
|
18
|
-
* Copy `from`'s history up to entry `at` into a new record named `into`, stamped with `provenance` so a repeat of
|
|
19
|
-
* the SAME fork can be recognised as one ({@link forkProvenance}) instead of becoming a second record or an
|
|
20
|
-
* overwrite.
|
|
21
|
-
*/
|
|
22
|
-
fork(from: string, at: string, into: string, provenance: string): Promise<void>;
|
|
23
|
-
delete(sessionId: string): Promise<boolean>;
|
|
24
|
-
}
|
|
25
|
-
/** A validated property patch, in the shape a RECORD takes it. */
|
|
26
|
-
export interface PropertyWrites {
|
|
27
|
-
name?: string;
|
|
28
|
-
model?: {
|
|
29
|
-
provider: string;
|
|
30
|
-
id: string;
|
|
31
|
-
};
|
|
32
|
-
thinkingLevel?: string;
|
|
33
|
-
leafEntryId?: string;
|
|
34
|
-
}
|
|
35
|
-
/** What a property write actually did, and what the record holds after it. */
|
|
36
|
-
interface AppliedProperties {
|
|
37
|
-
/** In write order. */
|
|
38
|
-
landed: SessionUpdateField[];
|
|
39
|
-
/** Why the rest stopped, if anything did. */
|
|
40
|
-
failure?: unknown;
|
|
41
|
-
/**
|
|
42
|
-
* The record AFTER the writes — what the caller reports, rather than echoing the request. pi rewrites a name
|
|
43
|
-
* (newlines collapse, ends trim), so the request is not what was stored.
|
|
44
|
-
*/
|
|
45
|
-
name?: string;
|
|
46
|
-
leafEntryId?: string;
|
|
47
|
-
/**
|
|
48
|
-
* The active path after the writes, for a caller that resolves settings against a model registry this layer has no
|
|
49
|
-
* business knowing.
|
|
50
|
-
*/
|
|
51
|
-
path?: OverrideEntryLike[];
|
|
52
|
-
}
|
|
53
|
-
/** A Caller's session id, as a name pi will accept. */
|
|
54
|
-
export declare function piSessionId(sessionId: string): string;
|
|
55
|
-
/**
|
|
56
|
-
* {@link piSessionId} backwards — what `list()` needs, because a session id belongs to the CALLER and a record name is
|
|
57
|
-
* storage detail.
|
|
58
|
-
*/
|
|
59
|
-
export declare function callerSessionId(recordId: string): string | undefined;
|
|
60
|
-
/** Disk-backed store under `dir`: restart the process, conversations continue. */
|
|
61
|
-
export declare function piSessionRecordStore(options: {
|
|
62
|
-
dir: string;
|
|
63
|
-
cwd?: string;
|
|
64
|
-
}): PiSessionRecordStore;
|
|
65
|
-
/** In-process store: continuity lives and dies with the instance. */
|
|
66
|
-
export declare function piInMemorySessionRecordStore(options?: {
|
|
67
|
-
cwd?: string;
|
|
68
|
-
}): PiSessionRecordStore;
|
|
69
|
-
export {};
|