@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
|
@@ -7,33 +7,26 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
7
7
|
return path;
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
10
|
-
* The config subsystem: schema (defineConfig), loading (loadConfig), and value interpretation
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* Red line: config describes deployment/runtime choices, never authored identity or expertise (those
|
|
14
|
-
* live in persona.md + skills, with AGENTS.md as project context). It has no say in PLACEMENT either —
|
|
15
|
-
* that rule lives in the neutral src/paths.ts — but its FILE is what marks a directory as an agent, so a
|
|
16
|
-
* served agent always has one (its contents may be `export default {}`; a model can still come from
|
|
17
|
-
* --model / FASTAGENT_MODEL). The loader below stays tolerant of a missing file because it is a loader:
|
|
18
|
-
* callers that have not resolved a placement (deploy inspection, tests) may point it anywhere.
|
|
10
|
+
* The config subsystem: schema (defineConfig), loading (loadConfig), and value interpretation (resolveModel,
|
|
11
|
+
* resolveModelSpec).
|
|
19
12
|
*/
|
|
20
13
|
import { existsSync, statSync } from "node:fs";
|
|
21
|
-
import {
|
|
14
|
+
import { join } from "node:path";
|
|
22
15
|
import { pathToFileURL } from "node:url";
|
|
23
16
|
import { THINKING_LEVELS } from "./session-settings.js";
|
|
24
|
-
import {
|
|
17
|
+
import { GLOBAL_AUTH_PATH } from "./auth.js";
|
|
18
|
+
import { readSecretDeclaration } from "../../declared-secrets.js";
|
|
19
|
+
import { assertCorsOrigins } from "../../channels/serve.js";
|
|
25
20
|
import { moduleLoadHint } from "../../loader.js";
|
|
26
|
-
import {
|
|
21
|
+
import { AGENT_CONFIG_FILE, resolveOverridePath, resolveSecretsDir } from "../../paths.js";
|
|
27
22
|
/** Identity function for typing and IDE completion (vite/next-style). */
|
|
28
23
|
export function defineConfig(config) {
|
|
29
24
|
return config;
|
|
30
25
|
}
|
|
31
|
-
/** A valid bindable port. */
|
|
32
26
|
export function isValidPort(n) {
|
|
33
27
|
return Number.isInteger(n) && n >= 0 && n <= 65535;
|
|
34
28
|
}
|
|
35
|
-
/** Validate an optional `string[]` config field where each entry must match `shape
|
|
36
|
-
* deploy.secrets (env-var names) and deploy.apt (package names); undefined is fine (field omitted). */
|
|
29
|
+
/** Validate an optional `string[]` config field where each entry must match `shape`. */
|
|
37
30
|
function validateStringList(value, key, shape, desc, path) {
|
|
38
31
|
if (value === undefined)
|
|
39
32
|
return;
|
|
@@ -45,25 +38,28 @@ function validateStringList(value, key, shape, desc, path) {
|
|
|
45
38
|
}
|
|
46
39
|
}
|
|
47
40
|
}
|
|
48
|
-
/**
|
|
41
|
+
/** Refuse a key `level` does not have, naming the keys it does (the ONE list both the check and the message read). */
|
|
42
|
+
function refuseUnknownKeys(level, valid, prefix, path) {
|
|
43
|
+
for (const key of Object.keys(level)) {
|
|
44
|
+
if (!valid.includes(key)) {
|
|
45
|
+
throw new Error(`${path}: unknown key "${prefix}${key}" (valid keys: ${valid.join(", ")})`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** Load `<dir>/fastagent.config.ts`. */
|
|
49
50
|
export async function loadConfig(dir) {
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
51
|
+
const path = join(dir, AGENT_CONFIG_FILE);
|
|
52
|
+
if (!existsSync(path))
|
|
52
53
|
return { config: {} };
|
|
53
|
-
if (found.length > 1) {
|
|
54
|
-
throw new Error(`${dir}: multiple fastagent config files found; keep exactly one (${found.map((p) => basename(p)).join(", ")})`);
|
|
55
|
-
}
|
|
56
|
-
// biome-ignore lint/style/noNonNullAssertion: length checked above — exactly one element here
|
|
57
|
-
const path = found[0];
|
|
58
54
|
let mod;
|
|
59
55
|
try {
|
|
60
|
-
// Cache-bust on file change: ESM `import()` caches by URL, so a config REWRITTEN in this process
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
//
|
|
56
|
+
// Cache-bust on file change: ESM `import()` caches by URL, so a config REWRITTEN in this process (the first-run
|
|
57
|
+
// picker's write-back) would otherwise read back stale. An INTEGER stamp (mtimeNs), because `mtimeMs` carries a
|
|
58
|
+
// fraction and a loader that decides how to transform a module by looking at the last dot in the URL reads
|
|
59
|
+
// `…config.ts?v=1789701227227.251` as extension `251` and parses the file as JavaScript — which the scaffold's
|
|
60
|
+
// `import type` + `satisfies` (what makes an editor complete these keys) does not survive.
|
|
65
61
|
const url = pathToFileURL(path);
|
|
66
|
-
url.searchParams.set("v", String(statSync(path).
|
|
62
|
+
url.searchParams.set("v", String(statSync(path, { bigint: true }).mtimeNs));
|
|
67
63
|
mod = (await import(__rewriteRelativeImportExtension(url.href)));
|
|
68
64
|
}
|
|
69
65
|
catch (error) {
|
|
@@ -74,19 +70,10 @@ export async function loadConfig(dir) {
|
|
|
74
70
|
throw new Error(`${path}: must default-export defineConfig({...})`);
|
|
75
71
|
}
|
|
76
72
|
const c = config;
|
|
77
|
-
// Unknown keys throw
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
key !== "thinkingLevel" &&
|
|
82
|
-
key !== "tools" &&
|
|
83
|
-
key !== "http" &&
|
|
84
|
-
key !== "deploy" &&
|
|
85
|
-
key !== "selfSchedule" &&
|
|
86
|
-
key !== "sessionControl") {
|
|
87
|
-
throw new Error(`${path}: unknown key "${key}" (valid keys: model, thinkingLevel, tools, http, deploy, selfSchedule, sessionControl)`);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
73
|
+
// Unknown keys throw. This is NOT redundant with `defineConfig`'s types: Node strips types without checking them,
|
|
74
|
+
// so `modle:` reaches here whatever the editor said, and silently degrading to defaults is the failure it would
|
|
75
|
+
// otherwise cause.
|
|
76
|
+
refuseUnknownKeys(c, ["model", "thinkingLevel", "tools", "http", "deploy", "sessionControl"], "", path);
|
|
90
77
|
if (c.model !== undefined && typeof c.model !== "string") {
|
|
91
78
|
throw new Error(`${path}: "model" must be a "provider/modelId" string`);
|
|
92
79
|
}
|
|
@@ -96,9 +83,6 @@ export async function loadConfig(dir) {
|
|
|
96
83
|
if (c.thinkingLevel !== undefined && !THINKING_LEVELS.has(c.thinkingLevel)) {
|
|
97
84
|
throw new Error(`${path}: "thinkingLevel" must be one of ${[...THINKING_LEVELS].join(", ")}`);
|
|
98
85
|
}
|
|
99
|
-
if (c.selfSchedule !== undefined && typeof c.selfSchedule !== "boolean") {
|
|
100
|
-
throw new Error(`${path}: "selfSchedule" must be a boolean`);
|
|
101
|
-
}
|
|
102
86
|
if (c.tools !== undefined && !Array.isArray(c.tools)) {
|
|
103
87
|
throw new Error(`${path}: "tools" must be an array of AgentTool`);
|
|
104
88
|
}
|
|
@@ -111,42 +95,49 @@ export async function loadConfig(dir) {
|
|
|
111
95
|
if (typeof candidate.name !== "string" || typeof candidate.execute !== "function") {
|
|
112
96
|
throw new Error(`${path}: "tools[${i}]" must have string "name" and function "execute"`);
|
|
113
97
|
}
|
|
98
|
+
// The declaration's SHAPE, checked with the same read the code-input loaders use. Here rather
|
|
99
|
+
// than at tool resolution because this is the author's own config file: a wrong shape in it is
|
|
100
|
+
// a config error like any other (it stops the command with one line naming the entry), while a
|
|
101
|
+
// wrong shape in `tools/x.ts` is that one file's load failure and the agent serves without it.
|
|
102
|
+
const declaration = readSecretDeclaration(candidate, `${path}: "tools[${i}]"`);
|
|
103
|
+
if (declaration.error !== undefined)
|
|
104
|
+
throw new Error(declaration.error);
|
|
114
105
|
}
|
|
115
106
|
}
|
|
116
107
|
if (c.http !== undefined && (typeof c.http !== "object" || c.http === null)) {
|
|
117
108
|
throw new Error(`${path}: "http" must be an object`);
|
|
118
109
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
110
|
+
refuseUnknownKeys(c.http ?? {}, ["port", "cors", "invoke", "run"], "http.", path);
|
|
111
|
+
if (c.http?.invoke !== undefined && typeof c.http.invoke !== "boolean") {
|
|
112
|
+
throw new Error(`${path}: "http.invoke" must be a boolean`);
|
|
123
113
|
}
|
|
114
|
+
if (c.http?.run !== undefined && typeof c.http.run !== "boolean") {
|
|
115
|
+
throw new Error(`${path}: "http.run" must be a boolean`);
|
|
116
|
+
}
|
|
117
|
+
if (c.http?.cors !== undefined)
|
|
118
|
+
assertCorsOrigins(c.http.cors, `${path}: "http.cors"`);
|
|
124
119
|
if (c.http?.port !== undefined && (typeof c.http.port !== "number" || !isValidPort(c.http.port))) {
|
|
125
120
|
throw new Error(`${path}: "http.port" must be an integer 0-65535`);
|
|
126
121
|
}
|
|
127
|
-
// Validated as strictly as http.port: an unbindable string ("banana") must fail HERE, not surface
|
|
128
|
-
// later as a topology diagnostic about "the interface you bound".
|
|
129
|
-
if (c.http?.host !== undefined && (typeof c.http.host !== "string" || !isBindAddress(c.http.host))) {
|
|
130
|
-
throw new Error(`${path}: "http.host" must be an IP address or "localhost" (e.g. "127.0.0.1", "0.0.0.0")`);
|
|
131
|
-
}
|
|
132
122
|
if (c.deploy !== undefined && (typeof c.deploy !== "object" || c.deploy === null)) {
|
|
133
123
|
throw new Error(`${path}: "deploy" must be an object`);
|
|
134
124
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
125
|
+
refuseUnknownKeys(c.deploy ?? {}, ["apt", "agentcore"], "deploy.", path);
|
|
126
|
+
if (c.deploy?.agentcore !== undefined && (typeof c.deploy.agentcore !== "object" || c.deploy.agentcore === null)) {
|
|
127
|
+
throw new Error(`${path}: "deploy.agentcore" must be an object`);
|
|
128
|
+
}
|
|
129
|
+
refuseUnknownKeys(c.deploy?.agentcore ?? {}, ["idleTimeoutSeconds"], "deploy.agentcore.", path);
|
|
130
|
+
// AWS's own bounds for idleRuntimeSessionTimeout: a value outside them is rejected by CloudFormation minutes into
|
|
131
|
+
// `deploy agentcore --run`, after the image build.
|
|
132
|
+
const idle = c.deploy?.agentcore?.idleTimeoutSeconds;
|
|
133
|
+
if (idle !== undefined && (!Number.isInteger(idle) || idle < 60 || idle > 1209600)) {
|
|
134
|
+
throw new Error(`${path}: "deploy.agentcore.idleTimeoutSeconds" must be an integer 60-1209600 (seconds)`);
|
|
139
135
|
}
|
|
140
|
-
//
|
|
141
|
-
// Debian package names. Both go into a shell/env context on the host, so shape-validate them — catches a
|
|
142
|
-
// typo and refuses an injection-shaped value from an otherwise-trusted config.
|
|
143
|
-
validateStringList(c.deploy?.secrets, "deploy.secrets", /^[A-Z_][A-Z0-9_]*$/, "an UPPER_SNAKE env-var name", path);
|
|
136
|
+
// apt entries are Debian package names.
|
|
144
137
|
validateStringList(c.deploy?.apt, "deploy.apt", /^[a-z0-9][a-z0-9.+-]*$/, "a Debian package name", path);
|
|
145
138
|
return { config: c, path };
|
|
146
139
|
}
|
|
147
|
-
/** The provider prefix of a "provider/modelId" spec.
|
|
148
|
-
* lookups then miss visibly (an unknown-provider error / a login-required hint), never a mangled id
|
|
149
|
-
* (`slice(0, indexOf("/"))` silently drops the last char when "/" is absent). */
|
|
140
|
+
/** The provider prefix of a "provider/modelId" spec. */
|
|
150
141
|
export function providerOf(spec) {
|
|
151
142
|
const slash = spec.indexOf("/");
|
|
152
143
|
return slash > 0 ? spec.slice(0, slash) : spec;
|
|
@@ -174,13 +165,7 @@ export function listModels(models) {
|
|
|
174
165
|
}
|
|
175
166
|
return specs.sort();
|
|
176
167
|
}
|
|
177
|
-
/**
|
|
178
|
-
* Rewrite the `model` in a config file's SOURCE TEXT to `spec`, for the first-run picker's write-back.
|
|
179
|
-
* Handles the scaffold's commented placeholder (`// model: "…"`) and an existing `model:` line; returns
|
|
180
|
-
* null when neither is present (no config file, or a hand-shaped one) so the caller falls back to a
|
|
181
|
-
* printed hint instead of guessing where to insert. Text-level (not AST) on purpose — it only ever
|
|
182
|
-
* touches a line it recognizes, never reformats the author's file.
|
|
183
|
-
*/
|
|
168
|
+
/** Rewrite the `model` in a config file's SOURCE TEXT to `spec`, for the first-run picker's write-back. */
|
|
184
169
|
export function rewriteConfigModel(src, spec) {
|
|
185
170
|
const line = ` model: ${JSON.stringify(spec)},`;
|
|
186
171
|
const commented = /^[ \t]*\/\/[ \t]*model:.*$/m;
|
|
@@ -190,32 +175,24 @@ export function rewriteConfigModel(src, spec) {
|
|
|
190
175
|
if (active.test(src))
|
|
191
176
|
return src.replace(active, line);
|
|
192
177
|
// No model line at all — the natural state after "picked once, then hand-deleted the line to reset".
|
|
193
|
-
// Re-INSERT at the top of the default-export object while the config still has the scaffold's block
|
|
194
|
-
// shape; anything else (a wrapper call, a one-liner, a computed export) is hand-shaped — leave it
|
|
195
|
-
// untouched (the caller prints the set-it-yourself hint).
|
|
196
178
|
const opener = /^export default[ \t]*\{[ \t]*$/m;
|
|
197
179
|
if (opener.test(src))
|
|
198
180
|
return src.replace(opener, (open) => `${open}\n${line}`);
|
|
199
181
|
return null;
|
|
200
182
|
}
|
|
201
|
-
/** Model selection precedence: CLI flag > FASTAGENT_MODEL env > config default. */
|
|
202
|
-
export function resolveModelSpec(flag, config, env = process.env) {
|
|
203
|
-
return flag ?? env.FASTAGENT_MODEL ?? config.model;
|
|
204
|
-
}
|
|
205
183
|
/**
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
184
|
+
* Model selection precedence: CLI flag > FASTAGENT_MODEL env > config default. An EMPTY `FASTAGENT_MODEL` is
|
|
185
|
+
* "unset", not "no model": `export FASTAGENT_MODEL=` in a shell or CI job, and an `environment:`/`env` entry that
|
|
186
|
+
* interpolates a missing variable, both arrive as `""` — and a set-but-empty value that shadowed `config.model`
|
|
187
|
+
* would refuse to start an agent whose config names a model.
|
|
209
188
|
*/
|
|
210
|
-
export function
|
|
211
|
-
return
|
|
189
|
+
export function resolveModelSpec(flag, config, env = process.env) {
|
|
190
|
+
return flag ?? (env.FASTAGENT_MODEL || config.model);
|
|
212
191
|
}
|
|
213
192
|
/**
|
|
214
|
-
* The auth-file override:
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
* + fail-visibly; see auth.ts); to share one account across projects, point this at the global
|
|
218
|
-
* `~/.fastagent/.secrets/auth.json` — sharing ONE file is safe under the store's cross-process refresh lock.
|
|
193
|
+
* The auth-file override: the SDK's `authPath` option > `FASTAGENT_AUTH_PATH` env > undefined (the opener then falls
|
|
194
|
+
* back to {@link defaultAuthPath} under the {@link resolveSecretsDir} dir). The CLI has no flag for it: a second
|
|
195
|
+
* spelling of one environment variable buys nothing, and the variable is what a deployed container reads anyway.
|
|
219
196
|
*/
|
|
220
197
|
function resolveAuthPathOverride(flag, env = process.env) {
|
|
221
198
|
return resolveOverridePath(flag ?? env.FASTAGENT_AUTH_PATH);
|
|
@@ -228,7 +205,21 @@ export function defaultAuthPath(secretsDir) {
|
|
|
228
205
|
export function resolveAuthPath(dir, flag, env = process.env) {
|
|
229
206
|
return resolveAuthPathOverride(flag, env) ?? defaultAuthPath(resolveSecretsDir(dir, env));
|
|
230
207
|
}
|
|
231
|
-
/** The
|
|
232
|
-
export function
|
|
233
|
-
|
|
208
|
+
/** The {@link AuthLayers} an agent directory reads: `authPath` option > `FASTAGENT_AUTH_PATH` > its own file. */
|
|
209
|
+
export function resolveAuthLayers(agentDir, authPath, env = process.env) {
|
|
210
|
+
const fallback = resolveAuthFallback(authPath, env);
|
|
211
|
+
return { path: resolveAuthPath(agentDir, authPath, env), ...(fallback !== undefined ? { fallback } : {}) };
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Where a credential the project does not have is read from instead: the user-global store, because a login is a
|
|
215
|
+
* PERSON on a machine and not a project — one `login -g` then serves every agent here. Undefined when an explicit
|
|
216
|
+
* path was named: "use this file" is an instruction, not a preference, so it gets no second layer.
|
|
217
|
+
*
|
|
218
|
+
* BOTH knobs {@link resolveAuthPath} reads count as that instruction, `FASTAGENT_SECRETS_DIR` included — it is what
|
|
219
|
+
* the Fly/Railway/AgentCore artifacts set, and a deployed container must read its mounted credentials and nothing
|
|
220
|
+
* else (the artifact is the truth).
|
|
221
|
+
*/
|
|
222
|
+
export function resolveAuthFallback(flag, env = process.env) {
|
|
223
|
+
const explicit = resolveAuthPathOverride(flag, env) ?? resolveOverridePath(env.FASTAGENT_SECRETS_DIR);
|
|
224
|
+
return explicit === undefined ? GLOBAL_AUTH_PATH : undefined;
|
|
234
225
|
}
|
|
@@ -2,65 +2,66 @@ import type { ExecutionEnv, Skill, ThinkingLevel } from "@earendil-works/pi-agen
|
|
|
2
2
|
import { type ModelRuntime } from "@earendil-works/pi-coding-agent";
|
|
3
3
|
import type { Provider } from "@earendil-works/pi-ai";
|
|
4
4
|
import type { Agent } from "../../agent.ts";
|
|
5
|
-
import { type FastagentConfig } from "./config.ts";
|
|
5
|
+
import { type AuthLayers, type FastagentConfig } from "./config.ts";
|
|
6
|
+
import type { FastagentAuthOptions } from "./auth.ts";
|
|
6
7
|
import { type LoadedDefinition } from "./definition.ts";
|
|
7
8
|
import type { ModuleLoadFailure } from "../../loader.ts";
|
|
8
9
|
import { type ToolCollision, type MountedTool } from "./tool.ts";
|
|
10
|
+
import { type DeclaredSecret } from "../../declared-secrets.ts";
|
|
9
11
|
import { type PiAgentSessionFactory } from "./invoke-session.ts";
|
|
10
12
|
import { type AnyModel } from "./models.ts";
|
|
11
13
|
import { type PiSessionRecordStore } from "./session-store.ts";
|
|
12
14
|
import { type Lease, type SessionObserver } from "./turn-kit.ts";
|
|
13
15
|
/**
|
|
14
|
-
* Every pi coding tool, in canonical order, rooted at the workspace it operates in.
|
|
15
|
-
*
|
|
16
|
-
* pi ships two overlapping groupings and neither is the whole set: `createCodingTools` is the four it
|
|
17
|
-
* ACTIVATES for a terminal (read/bash/edit/write, no searching), `createReadOnlyTools` is
|
|
18
|
-
* read/grep/find/ls. `read` is in both; a directory agent mounts their union.
|
|
16
|
+
* Every pi coding tool, in canonical order, rooted at the workspace it operates in. pi ships two overlapping groupings
|
|
17
|
+
* and neither is the whole set.
|
|
19
18
|
*/
|
|
20
19
|
export declare const CODING_TOOL_NAMES: readonly ["read", "grep", "find", "ls", "bash", "edit", "write"];
|
|
21
20
|
export declare function piAllCodingTools(cwd: string): MountedTool[];
|
|
22
21
|
/**
|
|
23
|
-
* The full directory-agent tool set: all pi coding tools + `config.tools` + discovered `tools/`
|
|
24
|
-
*
|
|
25
|
-
* dev/start openers AND `fastagent tool`, so they all mount exactly the same set.
|
|
22
|
+
* The full directory-agent tool set: all pi coding tools + `config.tools` + discovered `tools/` (deduped, existing
|
|
23
|
+
* win), plus the authored names and collisions to report.
|
|
26
24
|
*/
|
|
27
25
|
export declare function resolveAgentTools(config: FastagentConfig, agentDir: string, cwd: string): Promise<{
|
|
28
26
|
tools: MountedTool[];
|
|
29
27
|
toolNames: string[];
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
28
|
+
/**
|
|
29
|
+
* Tools registered but not initially active (defineTool `deferred: true`) — discovered/activated via the built-in
|
|
30
|
+
* `search_tools` loader.
|
|
31
|
+
*/
|
|
32
32
|
deferredToolNames: string[];
|
|
33
33
|
toolCollisions: ToolCollision[];
|
|
34
34
|
toolFailures: ModuleLoadFailure[];
|
|
35
|
+
/** Env vars the MOUNTED tools declared they need, BY TOOL NAME — a discovered tool shadowed by a
|
|
36
|
+
* coding tool or `config.tools` never executes, so its declaration is dropped here rather than
|
|
37
|
+
* gating a start. Per tool because a caller that runs exactly ONE of them (`fastagent tool`) must
|
|
38
|
+
* not be stopped by a sibling's credential; the serving paths flatten it (they mount all of
|
|
39
|
+
* them). DATA: `info` reports it and the deploy pre-flight carries it, while the serving opener
|
|
40
|
+
* asserts it (open.ts) — this function must stay reportable. */
|
|
41
|
+
toolSecrets: Map<string, DeclaredSecret[]>;
|
|
35
42
|
}>;
|
|
36
|
-
/**
|
|
37
|
-
* The pi engine's base prompt (segment ①), mirroring pi-coding-agent's default path with two
|
|
38
|
-
* deviations: the pi-TUI docs section is dropped (those paths don't exist in deployments), and the
|
|
39
|
-
* tool list is generated from the actually-mounted tools (base and toolset must agree). An authored
|
|
40
|
-
* `persona` (from persona.md) replaces the default identity line, keeping the tools list + guidelines.
|
|
41
|
-
*/
|
|
43
|
+
/** The pi engine's base prompt (segment ①), mirroring pi-coding-agent's default path with two deviations. */
|
|
42
44
|
export declare function piBasePrompt(options?: {
|
|
43
45
|
tools?: MountedTool[];
|
|
44
46
|
persona?: string;
|
|
45
47
|
}): string;
|
|
46
48
|
export interface AssembleSystemPromptOptions {
|
|
47
49
|
/**
|
|
48
|
-
* Base prompt (①), REQUIRED — no default: a defaulted piBasePrompt() would render
|
|
49
|
-
*
|
|
50
|
+
* Base prompt (①), REQUIRED — no default: a defaulted piBasePrompt() would render "Available tools: (none)" even
|
|
51
|
+
* when tools are mounted.
|
|
50
52
|
*/
|
|
51
53
|
base: string;
|
|
52
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* ② project-context files (AGENTS.md et al. from loadProjectContextFiles); each wrapped `<project_instructions
|
|
56
|
+
* path=…>`.
|
|
57
|
+
*/
|
|
53
58
|
contextFiles?: Array<{
|
|
54
59
|
path: string;
|
|
55
60
|
content: string;
|
|
56
61
|
}>;
|
|
57
62
|
}
|
|
58
63
|
export declare function assembleSystemPrompt(options: AssembleSystemPromptOptions): string;
|
|
59
|
-
/**
|
|
60
|
-
* The assembly, as a value: what every rung builds and what the agent runs on. The opener hands it to
|
|
61
|
-
* the control plane too — boundary mutations contend on the SAME lease and validate against the SAME
|
|
62
|
-
* registry the runs use, which is only true if there is one of each to hand over.
|
|
63
|
-
*/
|
|
64
|
+
/** The assembly, as a value: what every rung builds and what the agent runs on. */
|
|
64
65
|
export interface PiAssembly {
|
|
65
66
|
lease: Lease;
|
|
66
67
|
sessionFactory: PiAgentSessionFactory;
|
|
@@ -71,102 +72,86 @@ export interface PiAssembly {
|
|
|
71
72
|
}>;
|
|
72
73
|
/** The configured reasoning effort — the other half of the pair a session without overrides runs on. */
|
|
73
74
|
thinkingLevel: ThinkingLevel;
|
|
75
|
+
/** The extension entry points every session loads, discovered once with the assembly. */
|
|
76
|
+
extensionPaths: readonly string[];
|
|
74
77
|
}
|
|
75
78
|
/** The agent an assembly runs as: the L0 over its lease and session factory. */
|
|
76
79
|
export declare function agentOf(assembly: PiAssembly, observer?: SessionObserver): Agent;
|
|
77
|
-
/** L1 options.
|
|
80
|
+
/** L1 options. */
|
|
78
81
|
export interface CreatePiAgentOptions {
|
|
79
82
|
/** Model spec "provider/modelId" (e.g. "openai-codex/gpt-5.5"), resolved against {@link models}. */
|
|
80
83
|
model: string;
|
|
81
|
-
/** Reasoning effort (pi's scale).
|
|
84
|
+
/** Reasoning effort (pi's scale). */
|
|
82
85
|
thinkingLevel?: ThinkingLevel;
|
|
83
86
|
/**
|
|
84
|
-
* The system prompt itself — no engine base and no wrapping (unlike the directory path, which
|
|
85
|
-
*
|
|
86
|
-
* a factory evaluated once per invoke, never during construction. Pi appends the skills listing
|
|
87
|
-
* when read is active.
|
|
88
|
-
*
|
|
89
|
-
* Not byte-for-byte verbatim: pi appends its own `Current working directory:` line to whatever
|
|
90
|
-
* prompt it is given. What this rung guarantees is that no engine IDENTITY is imposed — a
|
|
91
|
-
* hand-built agent is not told it is a coding assistant.
|
|
87
|
+
* The system prompt itself — no engine base and no wrapping (unlike the directory path, which assembles the engine
|
|
88
|
+
* base + AGENTS.md as segment ② + persona.md as segment ①).
|
|
92
89
|
*/
|
|
93
90
|
instructions?: string | (() => string);
|
|
94
91
|
/** The tool set to mount: authored tools or pi's cwd-bound coding tools, both AgentTool. */
|
|
95
92
|
tools?: MountedTool[];
|
|
96
93
|
skills?: Skill[];
|
|
97
94
|
/**
|
|
98
|
-
* Extra providers registered on top of the built-ins — your own gateway / self-hosted endpoint /
|
|
99
|
-
*
|
|
100
|
-
* still come from the {@link authPath} credentials file (fastagent login) or env, not from here.
|
|
95
|
+
* Extra providers registered on top of the built-ins — your own gateway / self-hosted endpoint / test fake —
|
|
96
|
+
* selected by the `model` spec's provider id.
|
|
101
97
|
*/
|
|
102
98
|
providers?: Provider[];
|
|
103
|
-
/**
|
|
104
|
-
* Credentials file for stored OAuth/API-key auth. Defaults to `~/.fastagent/.secrets/auth.json`; the
|
|
105
|
-
* directory opener passes the project-level `<root>/.secrets/auth.json` instead. Env vars are still
|
|
106
|
-
* consulted when a provider is absent from the file (resolution order is upstream-owned).
|
|
107
|
-
*/
|
|
99
|
+
/** Credentials file for stored OAuth/API-key auth (default `GLOBAL_AUTH_PATH`). */
|
|
108
100
|
authPath?: string;
|
|
109
|
-
/** Session persistence. Defaults to in-memory; inject piSessionRecordStore for restart-surviving
|
|
110
|
-
* continuity. */
|
|
111
101
|
sessions?: PiSessionRecordStore;
|
|
112
|
-
/** Supplies the working directory at L1 (default: process.cwd()), which loads no definition.
|
|
113
|
-
* At L2 it also reads persona.md and skills/.
|
|
114
|
-
* Tools and project-context discovery use the local process directly; this is not a sandbox. */
|
|
102
|
+
/** Supplies the working directory at L1 (default: process.cwd()), which loads no definition. */
|
|
115
103
|
env?: ExecutionEnv;
|
|
116
|
-
/** Single-writer lease.
|
|
104
|
+
/** Single-writer lease. */
|
|
117
105
|
lease?: Lease;
|
|
118
|
-
/** Observation-plane tap (session control): every rich session event of every run.
|
|
119
|
-
* returned by `createPiSessionControl` to serve `state`/`entries`/`events` for this agent. */
|
|
106
|
+
/** Observation-plane tap (session control): every rich session event of every run. */
|
|
120
107
|
observer?: SessionObserver;
|
|
121
108
|
}
|
|
122
109
|
/** L1: assemble from typed parts. */
|
|
123
110
|
export declare function createPiAgent(options: CreatePiAgentOptions): Agent;
|
|
124
|
-
/**
|
|
125
|
-
* L2 options. `instructions`/`skills` are absent by design — they come from the definition directory
|
|
126
|
-
* (AGENTS.md + skills/), which is the whole point of L2.
|
|
127
|
-
*/
|
|
111
|
+
/** L2 options. */
|
|
128
112
|
export interface CreatePiAgentFromDefinitionOptions {
|
|
129
113
|
/** Model spec "provider/modelId", resolved against {@link models}. */
|
|
130
114
|
model: string;
|
|
131
|
-
/** Reasoning effort (pi's scale).
|
|
115
|
+
/** Reasoning effort (pi's scale). */
|
|
132
116
|
thinkingLevel?: ThinkingLevel;
|
|
133
|
-
/** Override the engine base prompt (segment ①).
|
|
134
|
-
* live-read persona.md; pass base to fully opt out of persona.md. */
|
|
117
|
+
/** Override the engine base prompt (segment ①). */
|
|
135
118
|
base?: string;
|
|
136
|
-
/** Override tools. Defaults to {@link piAllCodingTools} (lock down with a custom list). An authored
|
|
137
|
-
* `FastagentTool[]` (AgentTool plus the optional `deferred` marker) widens into {@link MountedTool}. */
|
|
138
119
|
tools?: MountedTool[];
|
|
139
120
|
/**
|
|
140
|
-
* The agent's working directory: where the coding tools operate AND whose ancestors are walked for
|
|
141
|
-
*
|
|
142
|
-
* whose definition lives in `dir` operates on — and reads the AGENTS.md of — that repo (core.md
|
|
143
|
-
* scenario grid); that is what the CLI's opener does with the workspace.
|
|
121
|
+
* The agent's working directory: where the coding tools operate AND whose ancestors are walked for ② project context
|
|
122
|
+
* (AGENTS.md).
|
|
144
123
|
*/
|
|
145
124
|
cwd?: string;
|
|
146
125
|
/** Extra providers registered on top of the built-ins (your own gateway / self-hosted endpoint). */
|
|
147
126
|
providers?: Provider[];
|
|
148
127
|
/**
|
|
149
|
-
* Credentials file
|
|
150
|
-
*
|
|
151
|
-
* dir) — unlike the dir-less {@link createPiAgent}/{@link createPiModels}, which default global.
|
|
128
|
+
* Credentials file. Unset reads the directory's own layers (`resolveAuthLayers`); a named file is an instruction and
|
|
129
|
+
* gets no second layer.
|
|
152
130
|
*/
|
|
153
131
|
authPath?: string;
|
|
154
132
|
sessions?: PiSessionRecordStore;
|
|
155
|
-
/** Filesystem/process environment; see {@link CreatePiAgentOptions.env}.
|
|
156
|
-
* persona.md and skills/. The seven coding tools, ② project context (pi's
|
|
157
|
-
* loadProjectContextFiles uses node fs directly), and author-written `tools/` stay outside it.
|
|
158
|
-
* Injecting an env narrows the blast radius rather than closing it. */
|
|
133
|
+
/** Filesystem/process environment; see {@link CreatePiAgentOptions.env}. */
|
|
159
134
|
env?: ExecutionEnv;
|
|
160
135
|
lease?: Lease;
|
|
161
136
|
/** Observation-plane tap; see {@link CreatePiAgentOptions.observer}. */
|
|
162
137
|
observer?: SessionObserver;
|
|
163
138
|
}
|
|
164
139
|
/**
|
|
165
|
-
*
|
|
166
|
-
* definition
|
|
167
|
-
*
|
|
140
|
+
* THE model registry an agent directory runs on: pi's built-ins, the directory's own `models.json` (custom endpoints
|
|
141
|
+
* are definition data and travel with the artifact) layered over the machine's `~/.fastagent/models.json` (environment,
|
|
142
|
+
* which does not travel), and any injected Provider instance, over the given credentials.
|
|
143
|
+
* The directory rung assembles from it and `availableModelsFromDir` lists from it, so a layer added here reaches both.
|
|
168
144
|
*/
|
|
169
|
-
export declare function
|
|
145
|
+
export declare function definitionModelRuntime(dir: string, options: FastagentAuthOptions & {
|
|
146
|
+
auth: AuthLayers;
|
|
147
|
+
providers?: Provider[];
|
|
148
|
+
}): Promise<ModelRuntime>;
|
|
149
|
+
/** L2, as the value: load the directory (base + AGENTS.md + skills + env) and assemble. */
|
|
150
|
+
export declare function assemblePiFromDefinition(dir: string,
|
|
151
|
+
/** `auth` is the opener's already-resolved layers, which take the place of `authPath`. */
|
|
152
|
+
options: Omit<CreatePiAgentFromDefinitionOptions, "observer"> & {
|
|
153
|
+
auth?: AuthLayers;
|
|
154
|
+
}): Promise<{
|
|
170
155
|
assembly: PiAssembly;
|
|
171
156
|
definition: LoadedDefinition;
|
|
172
157
|
}>;
|