@fastagent-sh/fastagent 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -12
- package/dist/agent.d.ts +24 -37
- package/dist/agent.js +7 -15
- package/dist/atomic-write.d.ts +13 -17
- package/dist/atomic-write.js +18 -29
- package/dist/bind.d.ts +12 -22
- package/dist/bind.js +18 -27
- package/dist/channel.d.ts +11 -33
- package/dist/channels/agentcore-limits.d.ts +2 -13
- package/dist/channels/agentcore-limits.js +2 -13
- package/dist/channels/agentcore-protocol.d.ts +67 -58
- package/dist/channels/agentcore-protocol.js +23 -15
- package/dist/channels/agentcore-service.d.ts +19 -33
- package/dist/channels/agentcore-service.js +176 -59
- package/dist/channels/agentcore.d.ts +39 -33
- package/dist/channels/agentcore.js +90 -224
- package/dist/channels/body.d.ts +15 -2
- package/dist/channels/body.js +24 -2
- package/dist/channels/busy.d.ts +1 -21
- package/dist/channels/busy.js +2 -39
- package/dist/channels/control.d.ts +17 -62
- package/dist/channels/control.js +74 -182
- package/dist/channels/define-channel.d.ts +39 -0
- package/dist/channels/define-channel.js +9 -0
- package/dist/channels/discover.d.ts +10 -31
- package/dist/channels/discover.js +37 -31
- package/dist/channels/feishu/bootstrap-token.d.ts +1 -8
- package/dist/channels/feishu/bootstrap-token.js +7 -23
- package/dist/channels/feishu/card.d.ts +14 -28
- package/dist/channels/feishu/card.js +16 -30
- package/dist/channels/feishu/cloud.d.ts +1 -5
- package/dist/channels/feishu/context-buffer.d.ts +4 -23
- package/dist/channels/feishu/context-buffer.js +8 -31
- package/dist/channels/feishu/crypto.d.ts +10 -5
- package/dist/channels/feishu/crypto.js +12 -19
- package/dist/channels/feishu/feishu-api.d.ts +2 -1
- package/dist/channels/feishu/feishu-api.js +5 -4
- package/dist/channels/feishu/feishu.d.ts +4 -10
- package/dist/channels/feishu/feishu.js +113 -227
- package/dist/channels/feishu/invoke-turn.d.ts +5 -4
- package/dist/channels/feishu/invoke-turn.js +36 -54
- package/dist/channels/feishu/model.d.ts +4 -21
- package/dist/channels/feishu/model.js +1 -8
- package/dist/channels/feishu/normalize.d.ts +2 -10
- package/dist/channels/feishu/normalize.js +7 -42
- package/dist/channels/feishu/parse.d.ts +9 -29
- package/dist/channels/feishu/parse.js +8 -26
- package/dist/channels/feishu/preview.d.ts +12 -14
- package/dist/channels/feishu/preview.js +108 -207
- package/dist/channels/feishu/register-app.d.ts +8 -23
- package/dist/channels/feishu/register-app.js +7 -20
- package/dist/channels/feishu/register-webhook.d.ts +2 -9
- package/dist/channels/feishu/register-webhook.js +9 -33
- package/dist/channels/feishu/scaffold/channel.ts +27 -19
- package/dist/channels/feishu/scaffold/channel.websocket.ts +31 -0
- package/dist/channels/feishu/setup-mode.d.ts +11 -36
- package/dist/channels/feishu/setup-mode.js +7 -26
- package/dist/channels/feishu/ws-ingress.d.ts +1 -2
- package/dist/channels/feishu/ws-ingress.js +6 -8
- package/dist/channels/http.d.ts +15 -15
- package/dist/channels/http.js +19 -9
- package/dist/channels/kit/attachment-path.d.ts +4 -5
- package/dist/channels/kit/attachment-path.js +10 -34
- package/dist/channels/kit/context-buffer.d.ts +14 -21
- package/dist/channels/kit/context-buffer.js +25 -38
- package/dist/channels/kit/delivery.d.ts +35 -0
- package/dist/channels/kit/delivery.js +129 -0
- package/dist/channels/kit/event-stream.d.ts +5 -0
- package/dist/channels/kit/event-stream.js +29 -0
- package/dist/channels/kit/invoke-turn-kit.d.ts +53 -26
- package/dist/channels/kit/invoke-turn-kit.js +89 -32
- package/dist/channels/kit/preview-kit.d.ts +18 -72
- package/dist/channels/kit/preview-kit.js +22 -88
- package/dist/channels/kit/signature.d.ts +3 -9
- package/dist/channels/kit/signature.js +3 -9
- package/dist/channels/kit/state.d.ts +1 -2
- package/dist/channels/kit/state.js +5 -14
- package/dist/channels/kit/stop-command.d.ts +1 -2
- package/dist/channels/kit/stop-command.js +6 -9
- package/dist/channels/kit/tasks.d.ts +1 -1
- package/dist/channels/kit/tasks.js +8 -21
- package/dist/channels/kit/text.d.ts +2 -16
- package/dist/channels/kit/text.js +23 -31
- package/dist/channels/kit/thread-participants.d.ts +4 -17
- package/dist/channels/kit/thread-participants.js +8 -55
- package/dist/channels/kit/transport.d.ts +26 -0
- package/dist/channels/kit/transport.js +20 -0
- package/dist/channels/kit/turn-queue.d.ts +7 -11
- package/dist/channels/kit/turn-queue.js +21 -39
- package/dist/channels/kit/turn-runner.d.ts +32 -18
- package/dist/channels/kit/turn-runner.js +98 -53
- package/dist/channels/kit/turn-store.d.ts +32 -32
- package/dist/channels/kit/turn-store.js +45 -88
- package/dist/channels/lark/lark.d.ts +1 -5
- package/dist/channels/lark/onboard.d.ts +3 -12
- package/dist/channels/lark/onboard.js +3 -13
- package/dist/channels/lark/scaffold/channel.ts +27 -19
- package/dist/channels/lark/scaffold/channel.websocket.ts +31 -0
- package/dist/channels/registration.d.ts +9 -35
- package/dist/channels/registration.js +6 -37
- package/dist/channels/secret.js +2 -5
- package/dist/channels/serve.d.ts +47 -44
- package/dist/channels/serve.js +165 -101
- package/dist/channels/slack/config-api.d.ts +4 -27
- package/dist/channels/slack/config-api.js +5 -34
- package/dist/channels/slack/context-buffer.d.ts +2 -3
- package/dist/channels/slack/context-buffer.js +5 -5
- package/dist/channels/slack/invoke-turn.d.ts +3 -1
- package/dist/channels/slack/invoke-turn.js +25 -34
- package/dist/channels/slack/manifest.js +1 -3
- package/dist/channels/slack/model.d.ts +1 -2
- package/dist/channels/slack/model.js +1 -1
- package/dist/channels/slack/onboard.d.ts +4 -3
- package/dist/channels/slack/onboard.js +8 -11
- package/dist/channels/slack/onboarding-state.d.ts +3 -5
- package/dist/channels/slack/onboarding-state.js +9 -6
- package/dist/channels/slack/parse.d.ts +4 -13
- package/dist/channels/slack/parse.js +7 -28
- package/dist/channels/slack/preview.d.ts +12 -2
- package/dist/channels/slack/preview.js +292 -269
- package/dist/channels/slack/reaction.d.ts +11 -3
- package/dist/channels/slack/reaction.js +19 -8
- package/dist/channels/slack/register-webhook.js +4 -7
- package/dist/channels/slack/scaffold/channel.ts +20 -13
- package/dist/channels/slack/scaffold/slack-send.ts +2 -2
- package/dist/channels/slack/setup-server.d.ts +1 -5
- package/dist/channels/slack/setup-server.js +1 -5
- package/dist/channels/slack/shared-api.d.ts +1 -4
- package/dist/channels/slack/shared-api.js +2 -13
- package/dist/channels/slack/slack-api.d.ts +2 -1
- package/dist/channels/slack/slack-api.js +6 -4
- package/dist/channels/slack/slack.d.ts +11 -14
- package/dist/channels/slack/slack.js +121 -122
- package/dist/channels/sse.d.ts +1 -1
- package/dist/channels/sse.js +1 -1
- package/dist/channels/telegram/context-buffer.d.ts +7 -22
- package/dist/channels/telegram/context-buffer.js +6 -23
- package/dist/channels/telegram/invoke-turn.d.ts +7 -7
- package/dist/channels/telegram/invoke-turn.js +24 -43
- package/dist/channels/telegram/parse.d.ts +24 -51
- package/dist/channels/telegram/parse.js +32 -84
- package/dist/channels/telegram/preview.d.ts +10 -1
- package/dist/channels/telegram/preview.js +79 -100
- package/dist/channels/telegram/register-webhook.js +5 -23
- package/dist/channels/telegram/scaffold/channel.ts +25 -18
- package/dist/channels/telegram/scaffold/telegram-send.ts +6 -4
- package/dist/channels/telegram/telegram-api.d.ts +4 -3
- package/dist/channels/telegram/telegram-api.js +9 -7
- package/dist/channels/telegram/telegram.d.ts +4 -18
- package/dist/channels/telegram/telegram.js +38 -94
- package/dist/channels/telegram/turn-store.d.ts +11 -14
- package/dist/channels/telegram/turn-store.js +8 -6
- package/dist/channels/wait-health.d.ts +4 -6
- package/dist/channels/wait-health.js +10 -14
- package/dist/cli/add-feishu.d.ts +2 -12
- package/dist/cli/add-feishu.js +24 -71
- package/dist/cli/add-slack.d.ts +5 -3
- package/dist/cli/add-slack.js +53 -76
- package/dist/cli/auth-view.d.ts +2 -16
- package/dist/cli/auth-view.js +2 -16
- package/dist/cli/commands/add.js +25 -43
- package/dist/cli/commands/chat.d.ts +0 -1
- package/dist/cli/commands/chat.js +5 -6
- package/dist/cli/commands/deploy/agentcore.js +60 -65
- package/dist/cli/commands/deploy/docker.js +50 -23
- package/dist/cli/commands/deploy/fly.js +23 -61
- package/dist/cli/commands/deploy/railway.js +23 -18
- package/dist/cli/commands/deploy/shared.d.ts +38 -57
- package/dist/cli/commands/deploy/shared.js +40 -59
- package/dist/cli/commands/deploy.d.ts +10 -27
- package/dist/cli/commands/deploy.js +38 -60
- package/dist/cli/commands/destroy.d.ts +4 -0
- package/dist/cli/commands/destroy.js +56 -0
- package/dist/cli/commands/dev.d.ts +2 -1
- package/dist/cli/commands/dev.js +20 -23
- package/dist/cli/commands/info.d.ts +0 -2
- package/dist/cli/commands/info.js +83 -49
- package/dist/cli/commands/init.d.ts +1 -2
- package/dist/cli/commands/init.js +16 -55
- package/dist/cli/commands/invoke.d.ts +0 -1
- package/dist/cli/commands/invoke.js +5 -7
- package/dist/cli/commands/login.d.ts +2 -1
- package/dist/cli/commands/login.js +33 -38
- package/dist/cli/commands/logs.js +3 -4
- package/dist/cli/commands/models.js +1 -5
- package/dist/cli/commands/routine-run.d.ts +6 -0
- package/dist/cli/commands/routine-run.js +47 -0
- package/dist/cli/commands/routine.d.ts +25 -0
- package/dist/cli/commands/routine.js +122 -0
- package/dist/cli/commands/start.d.ts +31 -3
- package/dist/cli/commands/start.js +131 -81
- package/dist/cli/commands/tool.js +26 -12
- package/dist/cli/fail.d.ts +13 -23
- package/dist/cli/fail.js +20 -23
- package/dist/cli/invoke-stream.d.ts +1 -8
- package/dist/cli/kernel.d.ts +6 -38
- package/dist/cli/kernel.js +14 -77
- package/dist/cli/models-view.d.ts +1 -9
- package/dist/cli/models-view.js +11 -22
- package/dist/cli/program.d.ts +5 -6
- package/dist/cli/program.js +120 -157
- package/dist/cli/serve.d.ts +57 -41
- package/dist/cli/serve.js +94 -121
- package/dist/cli/shared.d.ts +15 -61
- package/dist/cli/shared.js +55 -181
- package/dist/cli.js +1 -8
- package/dist/collect.d.ts +6 -0
- package/dist/collect.js +6 -0
- package/dist/core.d.ts +4 -1
- package/dist/core.js +9 -7
- package/dist/declared-secrets.d.ts +55 -0
- package/dist/declared-secrets.js +88 -0
- package/dist/deploy/agentcore/aws-cli.d.ts +91 -0
- package/dist/deploy/agentcore/aws-cli.js +64 -0
- package/dist/deploy/agentcore/destroy.d.ts +51 -0
- package/dist/deploy/agentcore/destroy.js +273 -0
- package/dist/deploy/agentcore/forwarder.js +28 -79
- package/dist/deploy/agentcore/logs.d.ts +2 -18
- package/dist/deploy/agentcore/logs.js +27 -51
- package/dist/deploy/agentcore/plan.d.ts +85 -105
- package/dist/deploy/agentcore/plan.js +152 -314
- package/dist/deploy/agentcore/run.d.ts +28 -28
- package/dist/deploy/agentcore/run.js +227 -306
- package/dist/deploy/agentcore/zip.d.ts +2 -15
- package/dist/deploy/agentcore/zip.js +3 -17
- package/dist/deploy/build-context.d.ts +21 -0
- package/dist/deploy/build-context.js +137 -0
- package/dist/deploy/channel-ingress.d.ts +26 -39
- package/dist/deploy/channel-ingress.js +57 -28
- package/dist/deploy/container.d.ts +20 -34
- package/dist/deploy/container.js +49 -100
- package/dist/deploy/docker/plan.d.ts +12 -11
- package/dist/deploy/docker/plan.js +43 -24
- package/dist/deploy/docker/run.d.ts +22 -25
- package/dist/deploy/docker/run.js +39 -37
- package/dist/deploy/fly/plan.d.ts +15 -44
- package/dist/deploy/fly/plan.js +41 -73
- package/dist/deploy/fly/run.d.ts +16 -51
- package/dist/deploy/fly/run.js +42 -95
- package/dist/deploy/hosts.d.ts +24 -3
- package/dist/deploy/hosts.js +24 -3
- package/dist/deploy/preflight.d.ts +47 -41
- package/dist/deploy/preflight.js +282 -383
- package/dist/deploy/railway/plan.d.ts +16 -42
- package/dist/deploy/railway/plan.js +42 -60
- package/dist/deploy/railway/run.d.ts +30 -68
- package/dist/deploy/railway/run.js +86 -100
- package/dist/deploy/registration-gate.d.ts +6 -13
- package/dist/deploy/residency.d.ts +37 -0
- package/dist/deploy/residency.js +24 -0
- package/dist/deploy/runner.d.ts +10 -9
- package/dist/deploy/runner.js +7 -18
- package/dist/deploy/secrets.d.ts +40 -41
- package/dist/deploy/secrets.js +117 -103
- package/dist/deploy/workspace.d.ts +50 -0
- package/dist/deploy/workspace.js +197 -0
- package/dist/dev-supervisor.d.ts +1 -9
- package/dist/dev-supervisor.js +21 -64
- package/dist/effect-port.d.ts +50 -0
- package/dist/effect-port.js +77 -0
- package/dist/engines/pi/agent-session-factory.d.ts +50 -69
- package/dist/engines/pi/agent-session-factory.js +249 -146
- package/dist/engines/pi/auth.d.ts +15 -11
- package/dist/engines/pi/auth.js +96 -99
- package/dist/engines/pi/chat.d.ts +1 -5
- package/dist/engines/pi/chat.js +2 -14
- package/dist/engines/pi/config.d.ts +53 -51
- package/dist/engines/pi/config.js +83 -92
- package/dist/engines/pi/create.d.ts +60 -75
- package/dist/engines/pi/create.js +108 -141
- package/dist/engines/pi/definition.d.ts +14 -58
- package/dist/engines/pi/definition.js +21 -85
- package/dist/engines/pi/invoke-session.d.ts +5 -25
- package/dist/engines/pi/invoke-session.js +209 -244
- package/dist/engines/pi/login.d.ts +95 -35
- package/dist/engines/pi/login.js +259 -107
- package/dist/engines/pi/machine.d.ts +31 -0
- package/dist/engines/pi/machine.js +106 -0
- package/dist/engines/pi/models.d.ts +70 -89
- package/dist/engines/pi/models.js +188 -81
- package/dist/engines/pi/open.d.ts +65 -53
- package/dist/engines/pi/open.js +129 -69
- package/dist/engines/pi/report.d.ts +3 -12
- package/dist/engines/pi/report.js +2 -16
- package/dist/engines/pi/search-tools.d.ts +1 -9
- package/dist/engines/pi/search-tools.js +26 -57
- package/dist/engines/pi/service.d.ts +2 -16
- package/dist/engines/pi/service.js +2 -16
- package/dist/engines/pi/session-builder.d.ts +5 -9
- package/dist/engines/pi/session-builder.js +44 -82
- package/dist/engines/pi/session-control.js +286 -269
- package/dist/engines/pi/session-effects.d.ts +14 -0
- package/dist/engines/pi/session-effects.js +30 -0
- package/dist/engines/pi/session-inheritance.d.ts +9 -18
- package/dist/engines/pi/session-inheritance.js +103 -160
- package/dist/engines/pi/session-markers.d.ts +31 -30
- package/dist/engines/pi/session-markers.js +26 -25
- package/dist/engines/pi/session-settings.d.ts +6 -22
- package/dist/engines/pi/session-settings.js +10 -21
- package/dist/engines/pi/session-store.d.ts +26 -92
- package/dist/engines/pi/session-store.js +96 -310
- package/dist/engines/pi/tool-context.d.ts +17 -45
- package/dist/engines/pi/tool-context.js +7 -26
- package/dist/engines/pi/tool.d.ts +45 -36
- package/dist/engines/pi/tool.js +43 -57
- package/dist/engines/pi/turn-kit.d.ts +14 -52
- package/dist/engines/pi/turn-kit.js +18 -67
- package/dist/engines/pi/wake-tool.d.ts +2 -10
- package/dist/engines/pi/wake-tool.js +7 -27
- package/dist/env.d.ts +27 -28
- package/dist/env.js +45 -50
- package/dist/index.js +0 -2
- package/dist/lark.d.ts +1 -2
- package/dist/lark.js +1 -2
- package/dist/loader.d.ts +14 -55
- package/dist/loader.js +24 -43
- package/dist/log.d.ts +2 -12
- package/dist/log.js +3 -24
- package/dist/node.d.ts +2 -15
- package/dist/node.js +2 -18
- package/dist/observe.d.ts +2 -8
- package/dist/open-url.d.ts +1 -1
- package/dist/open-url.js +1 -1
- package/dist/paths.d.ts +70 -134
- package/dist/paths.js +165 -232
- package/dist/pi.d.ts +4 -6
- package/dist/pi.js +3 -3
- package/dist/proxy.d.ts +16 -6
- package/dist/proxy.js +52 -16
- package/dist/runtime.d.ts +18 -12
- package/dist/runtime.js +18 -11
- package/dist/scaffold/add-channel.d.ts +14 -31
- package/dist/scaffold/add-channel.js +48 -112
- package/dist/scaffold/init.d.ts +9 -31
- package/dist/scaffold/init.js +45 -138
- package/dist/scaffold/templates/env.example +6 -4
- package/dist/scaffold/templates/fastagent.config.ts +36 -0
- package/dist/scaffold/templates.d.ts +3 -3
- package/dist/scaffold/templates.js +5 -8
- package/dist/scaffold/vendor-skill.d.ts +2 -5
- package/dist/scaffold/vendor-skill.js +19 -29
- package/dist/schedule/cron.d.ts +9 -5
- package/dist/schedule/cron.js +9 -11
- package/dist/schedule/discover.d.ts +12 -12
- package/dist/schedule/discover.js +43 -34
- package/dist/schedule/routine.d.ts +43 -0
- package/dist/schedule/routine.js +32 -0
- package/dist/schedule/run.d.ts +55 -0
- package/dist/schedule/run.js +146 -0
- package/dist/schedule/scheduler.d.ts +44 -55
- package/dist/schedule/scheduler.js +291 -265
- package/dist/schedule/state.d.ts +105 -10
- package/dist/schedule/state.js +293 -19
- package/dist/schedule/wake-alarm.d.ts +10 -23
- package/dist/schedule/wake-alarm.js +91 -121
- package/dist/schedule/wakeups.d.ts +23 -39
- package/dist/schedule/wakeups.js +33 -75
- package/dist/secrets-gate.d.ts +32 -0
- package/dist/secrets-gate.js +33 -0
- package/dist/service.d.ts +137 -98
- package/dist/service.js +250 -252
- package/dist/session-remote.d.ts +33 -44
- package/dist/session-remote.js +203 -192
- package/dist/session.d.ts +153 -228
- package/dist/session.js +33 -55
- package/dist/tunnel.d.ts +8 -36
- package/dist/tunnel.js +24 -65
- package/dist/version.d.ts +2 -2
- package/dist/version.js +2 -2
- package/package.json +10 -16
- package/dist/channels/agentcore-state.d.ts +0 -77
- package/dist/channels/agentcore-state.js +0 -276
- package/dist/channels/github/github.d.ts +0 -31
- package/dist/channels/github/github.js +0 -89
- package/dist/channels/github/scaffold/channel.ts +0 -25
- package/dist/cli/commands/attach.d.ts +0 -108
- package/dist/cli/commands/attach.js +0 -637
- package/dist/cli/commands/fire.d.ts +0 -7
- package/dist/cli/commands/fire.js +0 -38
- package/dist/cli/commands/schedule.d.ts +0 -12
- package/dist/cli/commands/schedule.js +0 -87
- package/dist/github.d.ts +0 -3
- package/dist/github.js +0 -2
- package/dist/scaffold/templates/fastagent.config.mjs +0 -23
- package/dist/schedule/audit.d.ts +0 -18
- package/dist/schedule/audit.js +0 -57
- package/dist/schedule/schedule.d.ts +0 -35
- package/dist/schedule/schedule.js +0 -23
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Definition domain: read an agent definition directory (AGENTS.md + skills/) into memory. Produces
|
|
3
|
-
* data; create.ts consumes it.
|
|
4
|
-
*
|
|
5
|
-
* IO policy: persona.md + skills load through ExecutionEnv (portable across local/sandbox/remote); the
|
|
6
|
-
* invoke path never touches disk. EXCEPTION — ② project context comes from pi's loadProjectContextFiles,
|
|
7
|
-
* which reads via node fs DIRECTLY (not the injected `env`) and, on failure, at best warns to stderr and
|
|
8
|
-
* at worst is fully silent (its `existsSync` probe swallows a permission error) — no structured signal. So under a
|
|
9
|
-
* non-local ExecutionEnv the ② files still resolve against THIS process's filesystem, not the target env
|
|
10
|
-
* — a known break in the portability contract, deferred with the sandbox work (core.md §6). config/auth/
|
|
11
|
-
* sessions and this module's Node helpers are composition-root code and may use node fs.
|
|
12
|
-
*
|
|
13
|
-
* Errors: a broken persona.md / unresolvable dir throws (fail loudly at startup); non-fatal findings
|
|
14
|
-
* (bad skill files, name collisions) are returned as data. An unreadable ② context file only warns (pi).
|
|
15
|
-
*/
|
|
1
|
+
/** Definition domain: read an agent definition directory (AGENTS.md + skills/) into memory. */
|
|
16
2
|
import { realpathSync } from "node:fs";
|
|
17
3
|
import { join, resolve } from "node:path";
|
|
18
4
|
import { BACKGROUND_CONTEXT, loadSkills, } from "@earendil-works/pi-agent-core";
|
|
@@ -20,10 +6,13 @@ import { NodeExecutionEnv } from "@earendil-works/pi-agent-core/node";
|
|
|
20
6
|
import { loadProjectContextFiles } from "@earendil-works/pi-coding-agent";
|
|
21
7
|
import { log } from "../../log.js";
|
|
22
8
|
import { assertInsideAgentDir } from "../../paths.js";
|
|
23
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Read an agent definition. persona.md/skills come from `agentDir`; ② context = pi's loadProjectContextFiles({ cwd,
|
|
11
|
+
* agentDir }).
|
|
12
|
+
*/
|
|
24
13
|
export async function loadAgentDefinition(agentDir, options = {}) {
|
|
25
|
-
// One resolved default for the working directory (env cwd AND the context-walk start), so they can
|
|
26
|
-
//
|
|
14
|
+
// One resolved default for the working directory (env cwd AND the context-walk start), so they can never diverge if
|
|
15
|
+
// a caller passes a relative agentDir.
|
|
27
16
|
const cwd = options.cwd ?? agentDir;
|
|
28
17
|
const e = options.env ?? new NodeExecutionEnv({ cwd });
|
|
29
18
|
const rootResult = await e.absolutePath(agentDir, BACKGROUND_CONTEXT);
|
|
@@ -31,12 +20,10 @@ export async function loadAgentDefinition(agentDir, options = {}) {
|
|
|
31
20
|
throw new Error(`cannot resolve agent dir "${agentDir}": ${rootResult.error.message}`);
|
|
32
21
|
}
|
|
33
22
|
const root = rootResult.value;
|
|
34
|
-
// ② project context, following pi: the agentDir's own AGENTS.md + every AGENTS.md walking cwd up to
|
|
35
|
-
//
|
|
36
|
-
// a deliberate, deferred deviation from this module's portable-IO policy (revisit with the sandbox; core.md §6).
|
|
23
|
+
// ② project context, following pi: the agentDir's own AGENTS.md + every AGENTS.md walking cwd up to root
|
|
24
|
+
// (loadProjectContextFiles).
|
|
37
25
|
const contextFiles = loadProjectContextFiles({ cwd, agentDir: root });
|
|
38
|
-
// persona.md → segment ① persona (overrides the identity line).
|
|
39
|
-
// only not_found means "absent"; any other read error surfaces rather than silently dropping the persona.
|
|
26
|
+
// persona.md → segment ① persona (overrides the identity line).
|
|
40
27
|
const personaPath = join(root, "persona.md");
|
|
41
28
|
const personaRead = await e.readTextFile(personaPath, BACKGROUND_CONTEXT);
|
|
42
29
|
if (!personaRead.ok && personaRead.error.code !== "not_found") {
|
|
@@ -46,43 +33,7 @@ export async function loadAgentDefinition(agentDir, options = {}) {
|
|
|
46
33
|
const { skills, diagnostics, collisions } = await readSkills(e, root);
|
|
47
34
|
return { contextFiles, persona, skills, diagnostics, collisions, dir: root };
|
|
48
35
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Extension entry-point FILES under `<agentDir>/extensions/`, empty when there are none.
|
|
51
|
-
*
|
|
52
|
-
* Paths, not loaded objects — unlike skills (data: content inline, serializable), an extension is
|
|
53
|
-
* CODE that pi loads with jiti and binds to its own eventBus/runtime, so loading it here would
|
|
54
|
-
* reimplement pi's loader. The engine binding hands these to pi as `additionalExtensionPaths`, which
|
|
55
|
-
* survives `noExtensions: true` — that flag suppresses MACHINE-GLOBAL discovery (`~/.pi`), and the
|
|
56
|
-
* definition's own extensions were only ever collateral to it. FILES, not the directory: pi's paths
|
|
57
|
-
* are module specifiers, and a directory fails as `Cannot find module` into a
|
|
58
|
-
* `LoadExtensionsResult.errors` entry nothing reads.
|
|
59
|
-
*
|
|
60
|
-
* SEPARATE from {@link loadAgentDefinition} on purpose. Prompt and skills are re-read every invoke
|
|
61
|
-
* ("the directory is the agent, LIVE"); scanning for extension entry points is not, since the set
|
|
62
|
-
* cannot change without a restart. Called once per assembly, like `tools/`.
|
|
63
|
-
*
|
|
64
|
-
* Discovery runs on BOTH paths; loading does not. `chat` hands these to pi and runs them fully.
|
|
65
|
-
* Serving only announces them — pi's extension runtime is shared across sessions, and serving has
|
|
66
|
-
* concurrent turns for unrelated conversations (see `PiAgentSessionFactoryOptions.extensionPaths`).
|
|
67
|
-
* The refusals below are therefore about what the ARTIFACT may contain, and hold for both.
|
|
68
|
-
*
|
|
69
|
-
* Discovery follows pi's own rules, so an extension that works in pi works here:
|
|
70
|
-
*
|
|
71
|
-
* 1. a direct `*.ts` / `*.js` file;
|
|
72
|
-
* 2. a subdirectory with `index.ts` / `index.js`.
|
|
73
|
-
*
|
|
74
|
-
* pi has a third rule — a subdirectory whose `package.json` declares a `pi` field — which is NOT
|
|
75
|
-
* implemented here. That shape is reported rather than skipped: a definition whose extension silently
|
|
76
|
-
* fails to load is the failure mode this whole path exists to remove.
|
|
77
|
-
*
|
|
78
|
-
* Containment matches skills/tools/channels/schedules (the fifth of five surfaces): a symlinked
|
|
79
|
-
* `extensions/` escaping the agent dir is refused, and — like `loadModuleDir`, whose `entry.isFile()`
|
|
80
|
-
* excludes them — a symlinked ENTRY is not loaded either. pi's own discovery does follow those, but
|
|
81
|
-
* an extension reached through a link out of the definition is code the artifact does not carry: it
|
|
82
|
-
* resolves on the authoring machine and is missing in the container. Refused loudly, never silently.
|
|
83
|
-
*
|
|
84
|
-
* Absent is normal and silent; a FILE at that path is not — that is an author who meant something.
|
|
85
|
-
*/
|
|
36
|
+
/** Extension entry-point FILES under `<agentDir>/extensions/`, empty when there are none. */
|
|
86
37
|
export async function loadExtensionPaths(agentDir, options = {}) {
|
|
87
38
|
const cwd = options.cwd ?? agentDir;
|
|
88
39
|
const e = options.env ?? new NodeExecutionEnv({ cwd });
|
|
@@ -101,12 +52,7 @@ export async function loadExtensionPaths(agentDir, options = {}) {
|
|
|
101
52
|
const paths = [];
|
|
102
53
|
for (const entry of listed.value) {
|
|
103
54
|
if (entry.kind === "symlink") {
|
|
104
|
-
// EVERY symlink here is announced, without guessing whether it meant to be an extension.
|
|
105
|
-
// two mistakes are not equal: a needless line about a symlinked README costs a glance, while
|
|
106
|
-
// staying quiet about a symlinked extension loses a feature silently and only shows up in the
|
|
107
|
-
// container. A name-based guess also cannot see through the link — `audit.ext -> some/dir` is
|
|
108
|
-
// a directory candidate to pi and a mystery here — so the warning says what it knows and
|
|
109
|
-
// tells the author when to ignore it.
|
|
55
|
+
// EVERY symlink here is announced, without guessing whether it meant to be an extension.
|
|
110
56
|
warnSymlinkRefused(entry.path);
|
|
111
57
|
continue;
|
|
112
58
|
}
|
|
@@ -122,19 +68,14 @@ export async function loadExtensionPaths(agentDir, options = {}) {
|
|
|
122
68
|
paths.push(index.path);
|
|
123
69
|
}
|
|
124
70
|
else if (!index.refused) {
|
|
125
|
-
// Silent when the index WAS found and refused for being a symlink
|
|
126
|
-
// the real problem, and "expected index.ts" on top of it describes a directory that has one.
|
|
71
|
+
// Silent when the index WAS found and refused for being a symlink.
|
|
127
72
|
log.warn(`[fastagent] ${entry.path} is not a loadable extension: expected index.ts or index.js ` +
|
|
128
73
|
`(pi's package.json "pi" manifest form is not supported here) — it will not be loaded`);
|
|
129
74
|
}
|
|
130
75
|
}
|
|
131
76
|
return paths.sort();
|
|
132
77
|
}
|
|
133
|
-
/**
|
|
134
|
-
* The first candidate that is a REAL file, and whether one was found but REFUSED as a symlink.
|
|
135
|
-
* `exists` would follow the link, which is how a subdirectory's `index.ts` could otherwise point
|
|
136
|
-
* outside the definition and slip past the rule the top-level entries already follow.
|
|
137
|
-
*/
|
|
78
|
+
/** The first candidate that is a REAL file, and whether one was found but REFUSED as a symlink. */
|
|
138
79
|
async function firstRealFile(e, candidates) {
|
|
139
80
|
let refused = false;
|
|
140
81
|
for (const candidate of candidates) {
|
|
@@ -158,11 +99,10 @@ function warnSymlinkRefused(path) {
|
|
|
158
99
|
`the definition so it travels with the artifact — move it in. (If it is not an extension, ` +
|
|
159
100
|
`keep it outside extensions/ to silence this.)`);
|
|
160
101
|
}
|
|
161
|
-
/** The skills half, shared by the full load and {@link loadAgentSkills}.
|
|
102
|
+
/** The skills half, shared by the full load and {@link loadAgentSkills}. */
|
|
162
103
|
async function readSkills(e, root) {
|
|
163
|
-
//
|
|
164
|
-
//
|
|
165
|
-
// that escapes the agent dir is refused rather than followed (the fourth of four surfaces).
|
|
104
|
+
// The definition's OWN skills/ — its half of the answer. The machine's half is machine.ts's, and `withMachine`
|
|
105
|
+
// decides a name collision in this half's favour.
|
|
166
106
|
await assertInsideAgentDir(root, "skills");
|
|
167
107
|
const { skills: raw, diagnostics } = await loadSkills(e, [join(root, "skills")], BACKGROUND_CONTEXT);
|
|
168
108
|
const byName = new Map();
|
|
@@ -179,10 +119,8 @@ async function readSkills(e, root) {
|
|
|
179
119
|
return { skills: [...byName.values()], diagnostics, collisions };
|
|
180
120
|
}
|
|
181
121
|
/**
|
|
182
|
-
* The definition's skills ALONE, resolved the same way `loadAgentDefinition` resolves them (same
|
|
183
|
-
*
|
|
184
|
-
* names and must not pay the full load's ② context walk (every AGENTS.md from cwd to root) for them.
|
|
185
|
-
* The control plane's `commands()` is that reader, called when a composer opens its completion list.
|
|
122
|
+
* The definition's skills ALONE, resolved the same way `loadAgentDefinition` resolves them (same loader, same
|
|
123
|
+
* containment guard, same first-wins collision rule).
|
|
186
124
|
*/
|
|
187
125
|
export async function loadAgentSkills(agentDir, options = {}) {
|
|
188
126
|
const cwd = options.cwd ?? agentDir;
|
|
@@ -190,12 +128,10 @@ export async function loadAgentSkills(agentDir, options = {}) {
|
|
|
190
128
|
const rootResult = await e.absolutePath(agentDir, BACKGROUND_CONTEXT);
|
|
191
129
|
if (!rootResult.ok)
|
|
192
130
|
throw new Error(`cannot resolve agent dir "${agentDir}": ${rootResult.error.message}`);
|
|
193
|
-
// `dir` is the RESOLVED root, like {@link LoadedDefinition.dir}
|
|
194
|
-
// (the findings memo) on it, and "./agent" vs an absolute path must not become two definitions.
|
|
131
|
+
// `dir` is the RESOLVED root, like {@link LoadedDefinition.dir}.
|
|
195
132
|
return { ...(await readSkills(e, rootResult.value)), dir: rootResult.value };
|
|
196
133
|
}
|
|
197
|
-
/** Resolve to a canonical (symlink-free) absolute path so comparisons match `process.cwd()`'s realpath.
|
|
198
|
-
* A non-existent path can't be realpath'd, so it stays as the plain absolute resolve. */
|
|
134
|
+
/** Resolve to a canonical (symlink-free) absolute path so comparisons match `process.cwd()`'s realpath. */
|
|
199
135
|
export function canonicalPath(p) {
|
|
200
136
|
const resolved = resolve(p);
|
|
201
137
|
try {
|
|
@@ -1,35 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* THE L0: pi's `AgentSession`, one per invoke, over the same durable record —
|
|
3
|
-
* [conformance-levels.md](../../../docs/design/conformance-levels.md) §2's `per-invoke` posture.
|
|
4
|
-
* Build a session, run one turn, dispose; continuity lives in the record, never in this process.
|
|
5
|
-
*
|
|
6
|
-
* Why this class: pi 0.84 replaced `AgentHarness` with an unimplemented lane-based skeleton, and pi
|
|
7
|
-
* does not consume that class itself — its TUI, RPC and SDK all run on `AgentSession`. Being the
|
|
8
|
-
* sole consumer of a surface nobody dogfoods is a position, not an architecture.
|
|
9
|
-
*
|
|
10
|
-
* Events are translated ONCE, into the rich `SessionEvent` vocabulary the observation plane speaks;
|
|
11
|
-
* the SPEC stream is a projection of that (`docs/design/session-control.md` §6 — one translation
|
|
12
|
-
* plus one projection, never two parallel ones).
|
|
13
|
-
*
|
|
14
|
-
* Two disciplines this file exists to hold:
|
|
15
|
-
* - the turn's outcome comes from the EVENT STREAM, never from an index into session state, which
|
|
16
|
-
* compaction and overflow recovery both rewrite mid-turn;
|
|
17
|
-
* - `run_started` is published BEFORE the session is bound, so a dispatch racing the build queues on
|
|
18
|
-
* the run's controls instead of finding no run.
|
|
19
|
-
*/
|
|
1
|
+
/** Pi's per-invoke binding over a durable session record. */
|
|
20
2
|
import type { AgentSession } from "@earendil-works/pi-coding-agent";
|
|
21
|
-
import type { SessionInheritance } from "./session-inheritance.ts";
|
|
22
3
|
import { type Agent } from "../../agent.ts";
|
|
4
|
+
import type { SessionInheritance } from "./session-inheritance.ts";
|
|
23
5
|
import { type Lease, type SessionObserver } from "./turn-kit.ts";
|
|
24
|
-
/** Open
|
|
25
|
-
* `inherit` reaches the CREATE path only — an existing session ignores it. */
|
|
6
|
+
/** Open or create a record and bind a session. */
|
|
26
7
|
export type PiAgentSessionFactory = (sessionId: string, inherit?: SessionInheritance) => Promise<AgentSession>;
|
|
27
8
|
export interface CreatePiAgentFromSessionOptions {
|
|
28
9
|
sessionFactory: PiAgentSessionFactory;
|
|
29
|
-
/**
|
|
10
|
+
/** Shared with control-plane writes; admission is synchronous and fail-fast. */
|
|
30
11
|
lease?: Lease;
|
|
31
|
-
/**
|
|
32
|
-
* on `run_started`. Optional; the SPEC stream is identical with or without it. */
|
|
12
|
+
/** Trusted observation tap; controls arrive with run_started, before session binding. */
|
|
33
13
|
observer?: SessionObserver;
|
|
34
14
|
}
|
|
35
15
|
export declare function createPiAgentFromSession(options: CreatePiAgentFromSessionOptions): Agent;
|