@agentproto/runtime 2.11.0 → 3.1.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 +26 -0
- package/dist/catalog-models.d.ts +1 -1
- package/dist/catalog-models.mjs.map +1 -1
- package/dist/command-allowlist.d.ts +38 -1
- package/dist/command-allowlist.mjs +25 -1
- package/dist/command-allowlist.mjs.map +1 -1
- package/dist/config.d.ts +14 -1
- package/dist/config.mjs.map +1 -1
- package/dist/index.d.ts +454 -71
- package/dist/index.mjs +10866 -7792
- package/dist/index.mjs.map +1 -1
- package/dist/pr-provenance.d.ts +26 -1
- package/dist/pr-provenance.mjs +20 -3
- package/dist/pr-provenance.mjs.map +1 -1
- package/dist/providers-store.d.ts +1 -0
- package/dist/resume-strategies.mjs +38 -1
- package/dist/resume-strategies.mjs.map +1 -1
- package/dist/session-presence.mjs.map +1 -1
- package/dist/{spawn-defaults-DUnTfwVK.d.ts → spawn-defaults-D4W661ui.d.ts} +8 -0
- package/dist/tool-envelope.d.ts +1 -0
- package/dist/tool-envelope.mjs +3 -0
- package/dist/tool-envelope.mjs.map +1 -0
- package/package.json +42 -35
package/dist/index.d.ts
CHANGED
|
@@ -12,9 +12,9 @@ import { CostBudget, AuthProfile, CostBudgetScope } from '@agentproto/auth';
|
|
|
12
12
|
export { CostBudget, CostBudgetScope } from '@agentproto/auth';
|
|
13
13
|
import { R as ResolvedContextContinuityPolicy } from './context-continuity-ib9_bVYM.js';
|
|
14
14
|
import { SandboxMode } from '@agentproto/command-sandbox';
|
|
15
|
-
import { AdapterHandle, SetupField, AdapterResolver, AdapterLister, HarnessCapabilities, AdapterEntry } from '@agentproto/provider-kit';
|
|
16
|
-
import { R as ResolvedAuthSpec, D as DeclaredAdapterOption, A as AdapterAuthDescriptor } from './spawn-defaults-
|
|
17
|
-
export { a as AuthEcho, b as AuthResolutionError, C as CLAUDE_CODE_OAUTH_SOURCE, c as CredentialSource, d as DefaultsAdapterAuthConfig, e as DefaultsAdapterConfig, f as ResolveSubscriptionCredentialInput, g as ResolvedSpawnAuthMaterial, h as ResolvedSpawnDefaults, S as SpawnDefaultsConfig, i as SubscriptionCredentialResolution, j as SubscriptionSourceError, k as credentialFingerprint, n as normalizeSkillsOption, r as resolveAuthSpec, l as resolveSpawnDefaults, m as resolveSubscriptionCredential } from './spawn-defaults-
|
|
15
|
+
import { AdapterHandle, SetupField, AdapterResolver, AdapterLister, CredsStore, HarnessCapabilities, AdapterEntry } from '@agentproto/provider-kit';
|
|
16
|
+
import { R as ResolvedAuthSpec, D as DeclaredAdapterOption, A as AdapterAuthDescriptor } from './spawn-defaults-D4W661ui.js';
|
|
17
|
+
export { a as AuthEcho, b as AuthResolutionError, C as CLAUDE_CODE_OAUTH_SOURCE, c as CredentialSource, d as DefaultsAdapterAuthConfig, e as DefaultsAdapterConfig, f as ResolveSubscriptionCredentialInput, g as ResolvedSpawnAuthMaterial, h as ResolvedSpawnDefaults, S as SpawnDefaultsConfig, i as SubscriptionCredentialResolution, j as SubscriptionSourceError, k as credentialFingerprint, n as normalizeSkillsOption, r as resolveAuthSpec, l as resolveSpawnDefaults, m as resolveSubscriptionCredential } from './spawn-defaults-D4W661ui.js';
|
|
18
18
|
import { CatalogModelsQuery, CatalogModelsResponse } from './catalog-models.js';
|
|
19
19
|
export { CatalogAdapterInput, CatalogAdapterModelInput, CatalogPricing, CatalogProduct, CatalogRoute, CatalogRouteSummary, CatalogVendor, buildCatalogModels } from './catalog-models.js';
|
|
20
20
|
import { FooterSession } from './pr-provenance.js';
|
|
@@ -22,6 +22,9 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
22
22
|
import { SandboxProvider } from '@agentproto/sandbox';
|
|
23
23
|
import { BrainManager, ExportedSessionLike } from '@agentproto/workspace-brain';
|
|
24
24
|
export { BrainManager, BrainStats, IngestReport, IngestResult } from '@agentproto/workspace-brain';
|
|
25
|
+
import * as _agentproto_tool from '@agentproto/tool';
|
|
26
|
+
import { ToolContext } from '@agentproto/tool';
|
|
27
|
+
import { DriverHandle } from '@agentproto/driver';
|
|
25
28
|
export { UserPreset, UserPresetsFile, deleteUserPreset, getUserPreset, listUserPresets, loadUserPresets, saveUserPreset, userPresetsPath } from './user-presets.js';
|
|
26
29
|
import { ResolvedModel } from '@agentproto/model-catalog';
|
|
27
30
|
import { FrameSink, E2eFrameSink } from '@agentproto/acp/tunnel';
|
|
@@ -722,10 +725,18 @@ interface ActivityPolicySlice {
|
|
|
722
725
|
policyId: string;
|
|
723
726
|
/** Representative session id (fan-in group[0]). */
|
|
724
727
|
sessionId: string;
|
|
725
|
-
/**
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
728
|
+
/**
|
|
729
|
+
* The full fan-in group being watched. OPTIONAL because supervisor state
|
|
730
|
+
* persisted before fan-in (WP6) predates this field — legacy rows on disk
|
|
731
|
+
* carry only `sessionId`, and the type must not lie about that.
|
|
732
|
+
*/
|
|
733
|
+
sessionIds?: readonly string[];
|
|
734
|
+
/**
|
|
735
|
+
* Group members that have NOT yet finished their turn. OPTIONAL for the
|
|
736
|
+
* same reason as `sessionIds`: pre-fan-in persisted supervisor state omits
|
|
737
|
+
* it.
|
|
738
|
+
*/
|
|
739
|
+
pending?: readonly string[];
|
|
729
740
|
status: "watching" | "queued" | "gating" | "acting" | "nudging" | "awaiting-ack" | "done" | "blocked" | "cancelled";
|
|
730
741
|
startedAt: string;
|
|
731
742
|
endedAt?: string;
|
|
@@ -1684,7 +1695,7 @@ declare function createTaskLedger(opts: {
|
|
|
1684
1695
|
* and session_monitor MCP tool (long-poll multiplexed).
|
|
1685
1696
|
*/
|
|
1686
1697
|
|
|
1687
|
-
type SessionEventType = "session:turn-end" | "session:awaiting-input" | "session:awaiting-input-flagged" | "session:permission-request" | "session:permission-resolved" | "session:exited" | "session:reaped" | "session:stalled" | "session:stall-cleared" | "session:watcher-attached" | "session:watcher-detached" | "session:bg-tasks-parked" | "session:bg-tasks-cleared" | "session:resumed" | "session:spawned" | "session:command-done" | "session:model-changed" | "session:config-changed" | "session:renamed" | "session:pinned-changed" | "policy:passed" | "policy:failed" | "policy:commit-ready" | "policy:committed" | "cron:fired" | "cron:succeeded" | "cron:failed" | "activity:changed" | "task:changed";
|
|
1698
|
+
type SessionEventType = "session:turn-end" | "session:awaiting-input" | "session:awaiting-input-flagged" | "session:awaiting-question-answered" | "session:permission-request" | "session:permission-resolved" | "session:exited" | "session:reaped" | "session:stalled" | "session:stall-cleared" | "session:watcher-attached" | "session:watcher-detached" | "session:bg-tasks-parked" | "session:bg-tasks-cleared" | "session:resumed" | "session:spawned" | "session:command-done" | "session:model-changed" | "session:config-changed" | "session:renamed" | "session:pinned-changed" | "policy:passed" | "policy:failed" | "policy:commit-ready" | "policy:committed" | "cron:fired" | "cron:succeeded" | "cron:failed" | "activity:changed" | "task:changed" | "workflow:gate-report" | "workflow:suspended" | "workflow:suspend-resumed" | "session:harness-warning";
|
|
1688
1699
|
/**
|
|
1689
1700
|
* Fixed severity vocabulary for a judge-gate finding (WP-D). Deliberately
|
|
1690
1701
|
* small and fixed so `policy_status` output is comparable across different
|
|
@@ -1813,6 +1824,26 @@ interface SessionPermissionRequestEvent {
|
|
|
1813
1824
|
label?: string;
|
|
1814
1825
|
ts: string;
|
|
1815
1826
|
}
|
|
1827
|
+
/**
|
|
1828
|
+
* Emitted when a client's next prompt text matched one of a structured
|
|
1829
|
+
* `awaitingQuestion`'s `options` (case-insensitive, trimmed) and was
|
|
1830
|
+
* therefore treated as an answer instead of a normal turn — see
|
|
1831
|
+
* `sessions.ts`'s structured-question-answer dispatch. Distinct from
|
|
1832
|
+
* `session:awaiting-input-flagged`: that fires for an EXTERNAL manual
|
|
1833
|
+
* override of the flag; this fires when the session's own declared options
|
|
1834
|
+
* were used as intended, by whichever seam the prompt came through
|
|
1835
|
+
* (`agent_prompt`, the HTTP prompt route, or the CLI).
|
|
1836
|
+
*/
|
|
1837
|
+
interface SessionAwaitingQuestionAnsweredEvent {
|
|
1838
|
+
type: "session:awaiting-question-answered";
|
|
1839
|
+
sessionId: string;
|
|
1840
|
+
/** The matched option string, verbatim from `question.options`. */
|
|
1841
|
+
answer: string;
|
|
1842
|
+
/** The question that was answered. */
|
|
1843
|
+
question: SessionAwaitingQuestion;
|
|
1844
|
+
label?: string;
|
|
1845
|
+
ts: string;
|
|
1846
|
+
}
|
|
1816
1847
|
/**
|
|
1817
1848
|
* Emitted when a parked permission is resolved — by an inbox
|
|
1818
1849
|
* approve/deny, or auto-`cancelled` when the session is torn down while the
|
|
@@ -2272,7 +2303,97 @@ interface TaskChangedEvent {
|
|
|
2272
2303
|
sessionId?: string;
|
|
2273
2304
|
ts: string;
|
|
2274
2305
|
}
|
|
2275
|
-
|
|
2306
|
+
/**
|
|
2307
|
+
* Emitted by the workflow runner (`workflow-runner.ts`) for every `kind:
|
|
2308
|
+
* "gate"` step command attempt — not just the last — carrying that attempt's
|
|
2309
|
+
* pass/fail, exit code, and parsed report (AIP-15 P3). Rides the same bus
|
|
2310
|
+
* fan-out as every other lifecycle event (`session_events_poll`, the
|
|
2311
|
+
* webhook notifier, `session_monitor`), giving a live watcher visibility
|
|
2312
|
+
* into a retry-with-reprompt loop as it happens, not just its final state.
|
|
2313
|
+
*/
|
|
2314
|
+
interface WorkflowGateReportEvent {
|
|
2315
|
+
type: "workflow:gate-report";
|
|
2316
|
+
runId: string;
|
|
2317
|
+
stepId: string;
|
|
2318
|
+
ok: boolean;
|
|
2319
|
+
exitCode: number;
|
|
2320
|
+
report: unknown;
|
|
2321
|
+
attempt: number;
|
|
2322
|
+
ts: string;
|
|
2323
|
+
}
|
|
2324
|
+
/**
|
|
2325
|
+
* Emitted by the workflow runner (`workflow-runner.ts`) when a `kind:
|
|
2326
|
+
* "approval"` step parks its run awaiting a human decision — the run's
|
|
2327
|
+
* status flips to `awaiting-approval`, `workflow_status` carries
|
|
2328
|
+
* `awaitingApproval`, and `workflow_escalation_resolve` (approval form)
|
|
2329
|
+
* resolves it. Same bus distribution as every other lifecycle event.
|
|
2330
|
+
*/
|
|
2331
|
+
interface WorkflowApprovalRequestedEvent {
|
|
2332
|
+
type: "workflow:approval-requested";
|
|
2333
|
+
runId: string;
|
|
2334
|
+
approvalId: string;
|
|
2335
|
+
stepId: string;
|
|
2336
|
+
prompt: string;
|
|
2337
|
+
approvers: readonly string[];
|
|
2338
|
+
artifacts?: readonly string[];
|
|
2339
|
+
requestedAt: string;
|
|
2340
|
+
ts: string;
|
|
2341
|
+
}
|
|
2342
|
+
/**
|
|
2343
|
+
* Emitted by the workflow runner when a parked approval is resolved — by a
|
|
2344
|
+
* human (`workflow_escalation_resolve`), a timeout (`who: "timeout"`), or a
|
|
2345
|
+
* cancel. The run resumes (or unwinds) right after this fires.
|
|
2346
|
+
*/
|
|
2347
|
+
interface WorkflowApprovalResolvedEvent {
|
|
2348
|
+
type: "workflow:approval-resolved";
|
|
2349
|
+
runId: string;
|
|
2350
|
+
approvalId: string;
|
|
2351
|
+
stepId: string;
|
|
2352
|
+
approved: boolean;
|
|
2353
|
+
who: string;
|
|
2354
|
+
note?: string;
|
|
2355
|
+
ts: string;
|
|
2356
|
+
}
|
|
2357
|
+
/**
|
|
2358
|
+
* Emitted by the workflow runner (`workflow-runner.ts`) when a `kind:
|
|
2359
|
+
* "suspend"` step parks its run awaiting an external event — the run's
|
|
2360
|
+
* status flips to `awaiting-input` with a durable `awaitingSuspend` record
|
|
2361
|
+
* (AIP-15 conformance rule 7), and `workflow_escalation_resolve`'s suspend
|
|
2362
|
+
* form resumes it. Same bus distribution as every other lifecycle event.
|
|
2363
|
+
*/
|
|
2364
|
+
interface WorkflowSuspendedEvent {
|
|
2365
|
+
type: "workflow:suspended";
|
|
2366
|
+
runId: string;
|
|
2367
|
+
stepId: string;
|
|
2368
|
+
on: readonly string[];
|
|
2369
|
+
ts: string;
|
|
2370
|
+
}
|
|
2371
|
+
/**
|
|
2372
|
+
* Emitted by the workflow runner when a parked `kind: "suspend"` step is
|
|
2373
|
+
* resumed — live (the run continues) or after a daemon restart (the run's
|
|
2374
|
+
* execution could not resume and it is marked failed with a clear reason).
|
|
2375
|
+
*/
|
|
2376
|
+
interface WorkflowSuspendResumedEvent {
|
|
2377
|
+
type: "workflow:suspend-resumed";
|
|
2378
|
+
runId: string;
|
|
2379
|
+
stepId: string;
|
|
2380
|
+
ts: string;
|
|
2381
|
+
}
|
|
2382
|
+
/**
|
|
2383
|
+
* Emitted when a `kind: "agent"` step's `harness` block declared a field the
|
|
2384
|
+
* spawn couldn't honor (today: `harness.tools` — no adapter exposes a
|
|
2385
|
+
* generic per-spawn tool allowlist this runtime can drive; see
|
|
2386
|
+
* `AgentHarness.tools`'s doc) — the "never silently ignore" fallback AIP-15
|
|
2387
|
+
* P2 requires. Same bus distribution as every other lifecycle event.
|
|
2388
|
+
*/
|
|
2389
|
+
interface SessionHarnessWarningEvent {
|
|
2390
|
+
type: "session:harness-warning";
|
|
2391
|
+
sessionId: string;
|
|
2392
|
+
warnings: string[];
|
|
2393
|
+
label?: string;
|
|
2394
|
+
ts: string;
|
|
2395
|
+
}
|
|
2396
|
+
type SessionEvent = SessionTurnEndEvent | SessionAwaitingInputEvent | SessionAwaitingInputFlaggedEvent | SessionAwaitingQuestionAnsweredEvent | SessionPermissionRequestEvent | SessionPermissionResolvedEvent | SessionExitedEvent | SessionReapedEvent | SessionStalledEvent | SessionStallClearedEvent | SessionWatcherAttachedEvent | SessionWatcherDetachedEvent | SessionBgTasksParkedEvent | SessionBgTasksClearedEvent | SessionResumedEvent | SessionSpawnedEvent | SessionCommandDoneEvent | SessionModelChangedEvent | SessionConfigChangedEvent | SessionRenamedEvent | SessionPinnedEvent | PolicyPassedEvent | PolicyFailedEvent | PolicyCommitReadyEvent | PolicyCommittedEvent | CronFiredEvent | CronSucceededEvent | CronFailedEvent | ActivityChangedEvent | TaskChangedEvent | WorkflowGateReportEvent | WorkflowApprovalRequestedEvent | WorkflowApprovalResolvedEvent | WorkflowSuspendedEvent | WorkflowSuspendResumedEvent | SessionHarnessWarningEvent;
|
|
2276
2397
|
interface SessionEventBus {
|
|
2277
2398
|
emit(ev: SessionEvent): void;
|
|
2278
2399
|
/** Subscribe to a specific event type. Returns an unsubscribe fn. */
|
|
@@ -2283,6 +2404,45 @@ interface SessionEventBus {
|
|
|
2283
2404
|
onAny(handler: (ev: SessionEvent) => void): () => void;
|
|
2284
2405
|
}
|
|
2285
2406
|
|
|
2407
|
+
/**
|
|
2408
|
+
* Runtime-side glue for the per-workspace brain: a shared registry of
|
|
2409
|
+
* {@link BrainManager}s (one per workspace bucket) plus the two bridges that
|
|
2410
|
+
* connect the pure `@agentproto/workspace-brain` engine to this daemon's real
|
|
2411
|
+
* conversation stores:
|
|
2412
|
+
*
|
|
2413
|
+
* - `readSessionForBrain` — a session id → exported transcript, via the same
|
|
2414
|
+
* ladder as `conversation-read.ts`: the provider-native store first
|
|
2415
|
+
* (`CONVERSATION_STORES`), then the universal `events.jsonl` capture
|
|
2416
|
+
* (`exportDaemonEventsSession`). `null` when neither has anything.
|
|
2417
|
+
* - `resolveWorkspace` — a session id → the workspace bucket it was recorded
|
|
2418
|
+
* under (via the persisted `conversations.jsonl` index).
|
|
2419
|
+
*
|
|
2420
|
+
* The registry itself is keyed by bucket slug and creates each `BrainManager`
|
|
2421
|
+
* lazily, so a workspace that never produces a session pays nothing until its
|
|
2422
|
+
* first exit does.
|
|
2423
|
+
*
|
|
2424
|
+
* A workspace's knowledge backends are configured per-workspace by a
|
|
2425
|
+
* `knowledge.json` file at `<bucket>/knowledge.json` (see
|
|
2426
|
+
* {@link loadKnowledgeConfigForWorkspace}). No file → the brain's default
|
|
2427
|
+
* single `files` provider (identical to pre-config behavior); an invalid
|
|
2428
|
+
* file → warn + fall back to that default; never throws either way.
|
|
2429
|
+
*/
|
|
2430
|
+
|
|
2431
|
+
/** The shared registry handed to both the subscriber and the MCP tools. */
|
|
2432
|
+
interface WorkspaceBrains {
|
|
2433
|
+
/** Get (creating lazily) the brain manager for a workspace bucket slug. */
|
|
2434
|
+
getBrain(workspace: string): BrainManager;
|
|
2435
|
+
/** Map a session id to the workspace bucket it was recorded under. */
|
|
2436
|
+
resolveWorkspace(sessionId: string): Promise<string | undefined>;
|
|
2437
|
+
/** Resolve an explicit workspace slug (or caller slug) to a safe bucket
|
|
2438
|
+
* slug — "default" when unregistered/absent (membership rule). */
|
|
2439
|
+
resolveWorkspaceSlug(workspace?: string, callerSlug?: string): string;
|
|
2440
|
+
}
|
|
2441
|
+
/** Resolve a session id to its exported transcript, native first then daemon
|
|
2442
|
+
* events — `null` (never throws) when neither store has anything readable. */
|
|
2443
|
+
declare function readSessionForBrain(sessionId: string): Promise<ExportedSessionLike | null>;
|
|
2444
|
+
declare function createWorkspaceBrains(): WorkspaceBrains;
|
|
2445
|
+
|
|
2286
2446
|
/**
|
|
2287
2447
|
* Shared types for pluggable tunnel providers.
|
|
2288
2448
|
*
|
|
@@ -2674,6 +2834,23 @@ interface SandboxProviderHandle extends AdapterHandle {
|
|
|
2674
2834
|
readonly setupFields?: readonly SetupField[];
|
|
2675
2835
|
}
|
|
2676
2836
|
|
|
2837
|
+
/**
|
|
2838
|
+
* Slug-keyed sandbox provider registry — the sandbox family's counterpart to
|
|
2839
|
+
* `remote-providers/registry.ts`. `local` resolves in-process; everything
|
|
2840
|
+
* else is a dynamic import of `@agentproto/sandbox-<slug>` (e.g.
|
|
2841
|
+
* `@agentproto/sandbox-e2b`), wrapped with this registry's own capability/
|
|
2842
|
+
* setup metadata because those packages export a bare `@agentproto/sandbox`
|
|
2843
|
+
* `SandboxProvider` (just `boot()`) rather than a self-describing
|
|
2844
|
+
* adapter-kit handle the way the tunnel family's third-party packages do.
|
|
2845
|
+
*
|
|
2846
|
+
* `modal` and `daytona` are catalog placeholders — AIP-36 day-1 provider
|
|
2847
|
+
* ids with no published `@agentproto/sandbox-<slug>` package yet, so they
|
|
2848
|
+
* always resolve to `null` (status "supported") until one ships.
|
|
2849
|
+
*/
|
|
2850
|
+
|
|
2851
|
+
/** Per-slug credentials, as stored by the creds store / setup tool. */
|
|
2852
|
+
type SandboxCreds = Record<string, string>;
|
|
2853
|
+
|
|
2677
2854
|
/**
|
|
2678
2855
|
* Sandbox family on top of `@agentproto/provider-kit` — mirrors
|
|
2679
2856
|
* `tunnel-adapters.ts`. This module is the entire bridge between the
|
|
@@ -2717,6 +2894,21 @@ interface SandboxAdapterInfo {
|
|
|
2717
2894
|
type SandboxProviderResolver = AdapterResolver<SandboxProviderHandle>;
|
|
2718
2895
|
/** List every sandbox provider with its live status + capabilities. */
|
|
2719
2896
|
type SandboxProviderLister = AdapterLister<SandboxAdapterInfo>;
|
|
2897
|
+
/** Build the sandbox-family creds store (per-slug, 0600). */
|
|
2898
|
+
declare function makeSandboxCredsStore(home?: string): CredsStore<SandboxCreds>;
|
|
2899
|
+
/**
|
|
2900
|
+
* Resolve a catalog slug to a concrete handle via the provider registry —
|
|
2901
|
+
* `local` in-process, `e2b`/`modal`/`daytona` dynamic-imported. Reads
|
|
2902
|
+
* stored creds first so `e2b` (and any future catalog entry) resolves
|
|
2903
|
+
* configured when possible; unconfigured slugs resolve to a descriptor-only
|
|
2904
|
+
* handle (listing never calls `start()`/`check()`). Throws on an unknown
|
|
2905
|
+
* slug so the kit's resolver wraps it to `null` ("supported but not
|
|
2906
|
+
* installed").
|
|
2907
|
+
*/
|
|
2908
|
+
declare function makeSandboxResolver(credsStore: CredsStore<SandboxCreds>, opts?: {
|
|
2909
|
+
/** Injectable for tests — defaults to a real dynamic `import()`. */
|
|
2910
|
+
importPackage?: (packageName: string) => Promise<Record<string, unknown>>;
|
|
2911
|
+
}): SandboxProviderResolver;
|
|
2720
2912
|
|
|
2721
2913
|
/**
|
|
2722
2914
|
* Fire-and-forget webhook notifier for session lifecycle events.
|
|
@@ -3401,6 +3593,23 @@ declare function createActivityProjector(opts: {
|
|
|
3401
3593
|
*/
|
|
3402
3594
|
type AgentsMdMode = "inline" | "pointer" | "absent";
|
|
3403
3595
|
|
|
3596
|
+
/** What a served app records on the session descriptor and echoes in the
|
|
3597
|
+
* spawn result — non-secret, caller-visible. */
|
|
3598
|
+
interface SessionAppServeInfo {
|
|
3599
|
+
/** App id the box's `app_install` registered. */
|
|
3600
|
+
appId: string;
|
|
3601
|
+
/** The in-box app dir that was installed + served. */
|
|
3602
|
+
dir: string;
|
|
3603
|
+
/** Port the UI binds inside the box. */
|
|
3604
|
+
port: number;
|
|
3605
|
+
/** Provider-resolved public URL for the served UI. */
|
|
3606
|
+
url: string;
|
|
3607
|
+
/** True when a probe against `url` answered OK within the readiness
|
|
3608
|
+
* window. False means the URL is the right address but the server had
|
|
3609
|
+
* not answered yet — retry the fetch rather than re-spawning. */
|
|
3610
|
+
ready: boolean;
|
|
3611
|
+
}
|
|
3612
|
+
|
|
3404
3613
|
/**
|
|
3405
3614
|
* Policy layer for `agent_start.worktree` — the config-driven decision of
|
|
3406
3615
|
* WHETHER to isolate a spawn into its own git worktree, kept deliberately
|
|
@@ -3870,6 +4079,17 @@ type AgentAdapterResolver = (slug: string) => Promise<{
|
|
|
3870
4079
|
* no caller-facing `env` passthrough on `agent_start` today, so this is
|
|
3871
4080
|
* daemon-authored only, not a general escape hatch. */
|
|
3872
4081
|
env?: Record<string, string>;
|
|
4082
|
+
/** Absolute paths OUTSIDE the session cwd the adapter's workspace
|
|
4083
|
+
* toolset may READ (never write). Daemon-authored only — used for the
|
|
4084
|
+
* exact AGENTS.md file an inherited (pointer-mode) prompt names, so a
|
|
4085
|
+
* cwd below the repo root can actually read the contract file its
|
|
4086
|
+
* prompt points at instead of erroring
|
|
4087
|
+
* (`path … escapes the workspace`). NOT a general escape hatch: the
|
|
4088
|
+
* driver forwards these to its confinement layer as extra READ paths
|
|
4089
|
+
* and (for the mastra-agent adapter) to `makeWorkspaceTools` as a
|
|
4090
|
+
* read-only grant; writes and sibling reads stay denied. Adapters
|
|
4091
|
+
* that can't model the grant ignore it. */
|
|
4092
|
+
additionalReadPaths?: string[];
|
|
3873
4093
|
}): Promise<AgentSessionLike>;
|
|
3874
4094
|
/** Display label for the descriptor's `command` field. */
|
|
3875
4095
|
commandPreview?: string;
|
|
@@ -3973,6 +4193,11 @@ interface AdapterListEntry {
|
|
|
3973
4193
|
* cli`'s `AdapterInfo.routeSelection` without importing it.
|
|
3974
4194
|
*/
|
|
3975
4195
|
routeSelection?: "free" | "derived-from-model";
|
|
4196
|
+
/** Known-valid model identifiers for this adapter (`@agentproto/cli`'s
|
|
4197
|
+
* `AdapterInfo.models`, forwarded verbatim). Undefined when the lister
|
|
4198
|
+
* behind `AgentAdapterLister` doesn't populate it — `adapter_list`'s
|
|
4199
|
+
* `summary` projection depends on this being present. */
|
|
4200
|
+
models?: string[];
|
|
3976
4201
|
}
|
|
3977
4202
|
type AgentAdapterLister = () => Promise<AdapterListEntry[]>;
|
|
3978
4203
|
/**
|
|
@@ -4291,6 +4516,11 @@ interface AgentStreamEvent {
|
|
|
4291
4516
|
* @agentproto/acp's `StreamEvent`'s `agent-prompt` kind. Harness-shaped
|
|
4292
4517
|
* and untyped; don't assume a stable schema across adapters. */
|
|
4293
4518
|
rawInput?: unknown;
|
|
4519
|
+
/** "agent-prompt" `_meta` bag, e.g. an ACP `requestPermission`'s
|
|
4520
|
+
* `toolCall._meta` (mastra-agent's `mastra-agent/suspendPayload` carries a
|
|
4521
|
+
* submit_plan's plan text there) — see @agentproto/acp's `StreamEvent`'s
|
|
4522
|
+
* `agent-prompt` kind. Harness-shaped and untyped. */
|
|
4523
|
+
_meta?: unknown;
|
|
4294
4524
|
/** "plan" event title — see @agentproto/acp's `StreamEvent`'s `plan` kind. */
|
|
4295
4525
|
title?: string;
|
|
4296
4526
|
/** "plan" event entries — see @agentproto/acp's `StreamEvent`'s `plan` kind. */
|
|
@@ -4547,6 +4777,15 @@ interface SessionDescriptor {
|
|
|
4547
4777
|
* completed) turn. Reset when the next turn starts. Tool-call enrichment
|
|
4548
4778
|
* events sharing an id count only once. Ephemeral and never persisted. */
|
|
4549
4779
|
toolCallsThisTurn?: number;
|
|
4780
|
+
/** Absolute path of this session's durable structured transcript
|
|
4781
|
+
* (`events.jsonl`), resolved from the SAME base dir the transcript
|
|
4782
|
+
* writer actually writes to (`sessions.eventsDir` config > the
|
|
4783
|
+
* hardcoded `~/.agentproto/sessions`) — never re-derived by the
|
|
4784
|
+
* caller. Ephemeral, stamped at read time (list/get) and at spawn;
|
|
4785
|
+
* never persisted. Lets an external client (`agent_start`'s spawn
|
|
4786
|
+
* response, Claude desktop sandbox, wait loops) discover WHERE the
|
|
4787
|
+
* transcript lives without guessing. */
|
|
4788
|
+
eventsPath?: string;
|
|
4550
4789
|
/** Whether the underlying OS process is still alive. Computed via
|
|
4551
4790
|
* `process.kill(pid, 0)` at read time (list()/get()) — cheap,
|
|
4552
4791
|
* zero-overhead, standard POSIX check. Absent when `pid` is null
|
|
@@ -5207,6 +5446,16 @@ interface SessionDescriptor {
|
|
|
5207
5446
|
/** True when the session has been hard-stopped by the context-continuity
|
|
5208
5447
|
* policy — no new prompt may be admitted. */
|
|
5209
5448
|
contextContinuityHardStopped?: boolean;
|
|
5449
|
+
/** The context percentage at which the user last answered "keep-going" to
|
|
5450
|
+
* the `ask`-mode continue-fresh question. `evaluateContextContinuity`
|
|
5451
|
+
* won't re-raise the same question until `contextPct` climbs past this
|
|
5452
|
+
* value again — otherwise the very next turn-boundary check (context
|
|
5453
|
+
* hasn't moved) would immediately re-ask, since the `ask` state covers
|
|
5454
|
+
* the whole `[compactAtPct, hardStopAtPct)` band, not just the instant it
|
|
5455
|
+
* was crossed. The hard-stop threshold is never suppressed by this — it
|
|
5456
|
+
* is checked ahead of `ask` in `contextContinuityStateForPct` and fires
|
|
5457
|
+
* regardless of any acknowledgment. */
|
|
5458
|
+
contextContinuityAckedAtPct?: number;
|
|
5210
5459
|
/** Id of the most recent checkpoint created for this session. */
|
|
5211
5460
|
checkpointId?: string;
|
|
5212
5461
|
/** When this session was continued fresh, the source session id. */
|
|
@@ -5288,6 +5537,15 @@ interface SessionDescriptor {
|
|
|
5288
5537
|
* default, ephemeral) or `"pause"` (keeps `sandboxId` reconnectable via
|
|
5289
5538
|
* `agent_start.sandbox.reuse`). Only set when `remote` is true. */
|
|
5290
5539
|
sandboxTeardown?: "kill" | "pause";
|
|
5540
|
+
/** App ports exposed at boot time (`SandboxSpec.extraPorts`) — maps port
|
|
5541
|
+
* number to its public URL. Only present for sandbox sessions where the
|
|
5542
|
+
* provider resolved `extraPorts` into `BootedSandbox.ports`. */
|
|
5543
|
+
sandboxPorts?: Record<number, string>;
|
|
5544
|
+
/** WP3 — an app UI served from INSIDE this sandbox session's box
|
|
5545
|
+
* (`agent_start.appServe`): the box-installed appId, the in-box dir, the
|
|
5546
|
+
* serve port, and the provider-resolved public URL. See
|
|
5547
|
+
* `sandbox-app-serve.ts`. */
|
|
5548
|
+
appServe?: SessionAppServeInfo;
|
|
5291
5549
|
}
|
|
5292
5550
|
/**
|
|
5293
5551
|
* Lightweight panel projection of SessionDescriptor for the VS Code Sessions
|
|
@@ -5392,7 +5650,15 @@ interface SessionSummary {
|
|
|
5392
5650
|
remote?: boolean;
|
|
5393
5651
|
sandboxId?: string;
|
|
5394
5652
|
sandboxTeardown?: "kill" | "pause";
|
|
5653
|
+
sandboxPorts?: Record<number, string>;
|
|
5654
|
+
appServe?: SessionAppServeInfo;
|
|
5395
5655
|
}
|
|
5656
|
+
/** Bracketed-paste mode as last observed in a PTY's OUTPUT stream.
|
|
5657
|
+
* `"unknown"` means neither `\x1b[?2004h` nor `\x1b[?2004l` has been seen
|
|
5658
|
+
* yet for this session — callers must treat unknown the same as "off"
|
|
5659
|
+
* (i.e. never wrap) to avoid a regression for sessions/shells that don't
|
|
5660
|
+
* use bracketed paste at all. */
|
|
5661
|
+
type BracketedPasteMode = "on" | "off" | "unknown";
|
|
5396
5662
|
/**
|
|
5397
5663
|
* Thrown by the lazy resume path when a resumable session has already failed to
|
|
5398
5664
|
* resume `MAX_RESUME_ATTEMPTS` times in a row (`canResume` false on a row that
|
|
@@ -5515,15 +5781,27 @@ interface PendingPermission {
|
|
|
5515
5781
|
* schema across adapters.
|
|
5516
5782
|
*/
|
|
5517
5783
|
rawInput?: unknown;
|
|
5784
|
+
/**
|
|
5785
|
+
* The tool call's `_meta` (e.g. mastra-agent's `mastra-agent/suspendPayload`
|
|
5786
|
+
* carrying a submit_plan's plan text), carried through from the ACP
|
|
5787
|
+
* `agent-prompt` event's `_meta` field when the driver supplied one.
|
|
5788
|
+
* Harness-shaped and untyped — don't assume a stable schema across adapters.
|
|
5789
|
+
*/
|
|
5790
|
+
_meta?: unknown;
|
|
5518
5791
|
}
|
|
5519
5792
|
/** How a caller resolves a pending permission — an explicit `optionId` wins
|
|
5520
5793
|
* over the `decision`→option mapping (approve → an allow-flavored option,
|
|
5521
5794
|
* deny → a reject-flavored option). `scope: "always"` prefers an
|
|
5522
|
-
* allow-always option when the request offers one.
|
|
5795
|
+
* allow-always option when the request offers one. `feedback` is optional
|
|
5796
|
+
* free text (e.g. "reject, but do X instead") sent alongside the outcome —
|
|
5797
|
+
* the acp client forwards it on the ACP outcome's `_meta`
|
|
5798
|
+
* (`agentproto/feedback`) for adapters that consume it (mastra-agent folds
|
|
5799
|
+
* it into a suspension's resumeData). */
|
|
5523
5800
|
interface PermissionRespondInput {
|
|
5524
5801
|
decision: "approve" | "deny";
|
|
5525
5802
|
optionId?: string;
|
|
5526
5803
|
scope?: "once" | "always";
|
|
5804
|
+
feedback?: string;
|
|
5527
5805
|
}
|
|
5528
5806
|
type PermissionRespondResult = {
|
|
5529
5807
|
ok: true;
|
|
@@ -6031,6 +6309,11 @@ interface SessionsRegistry {
|
|
|
6031
6309
|
* Single-shot variant of attachPty().write — useful for MCP
|
|
6032
6310
|
* tools that drive a session through tool calls. */
|
|
6033
6311
|
writeTerminalInput(id: string, data: string): boolean;
|
|
6312
|
+
/** Last observed bracketed-paste mode for a PTY session, tracked from
|
|
6313
|
+
* the PTY's OUTPUT stream (see `scanBracketedPaste`). `"unknown"` for
|
|
6314
|
+
* a missing/non-PTY session or one that hasn't emitted either
|
|
6315
|
+
* `\x1b[?2004h`/`\x1b[?2004l` sequence yet. */
|
|
6316
|
+
getBracketedPasteMode(id: string): BracketedPasteMode;
|
|
6034
6317
|
/** Snapshot the recent PTY byte buffer as one Buffer. Newest
|
|
6035
6318
|
* bytes at the end; `lastBytes` caps the returned size from the
|
|
6036
6319
|
* tail. Returns null when the session is missing or not a PTY. */
|
|
@@ -6369,6 +6652,12 @@ interface SpawnAgentInput {
|
|
|
6369
6652
|
/** What session close does to the box, when `remote` is true — see
|
|
6370
6653
|
* `SessionDescriptor.sandboxTeardown`. */
|
|
6371
6654
|
sandboxTeardown?: "kill" | "pause";
|
|
6655
|
+
/** Port-to-URL map from the booted sandbox — see
|
|
6656
|
+
* `SessionDescriptor.sandboxPorts`. */
|
|
6657
|
+
sandboxPorts?: Record<number, string>;
|
|
6658
|
+
/** WP3 — in-box app-serve echo (`agent_start.appServe`), recorded verbatim
|
|
6659
|
+
* onto {@link SessionDescriptor.appServe}. See `sandbox-app-serve.ts`. */
|
|
6660
|
+
appServe?: SessionAppServeInfo;
|
|
6372
6661
|
/** True when the driver session was started in permission-hold mode
|
|
6373
6662
|
* (`AgentCliStartOptions.permissionHold`) — its `agent-prompt` events carry
|
|
6374
6663
|
* respondable permission requests. Gates whether the registry registers
|
|
@@ -6521,6 +6810,15 @@ interface RecordCommandInput {
|
|
|
6521
6810
|
/** Id of the session that invoked this one, when the caller genuinely
|
|
6522
6811
|
* knows it — see `SessionDescriptor.callerSessionId`. */
|
|
6523
6812
|
callerSessionId?: string;
|
|
6813
|
+
/** Parent attribution + depth — same semantics as `SpawnPtyInput` /
|
|
6814
|
+
* `SpawnAgentInput` (orchestrator WP4): set when the command ran
|
|
6815
|
+
* through a scoped sub-gateway so `session_tree` shows the command
|
|
6816
|
+
* session under its invoker. */
|
|
6817
|
+
parentSessionId?: string;
|
|
6818
|
+
/** Recursion depth in the session tree — always recorded (`?? 0` when
|
|
6819
|
+
* absent) so subtree/depth logic never has to special-case a missing
|
|
6820
|
+
* value. Same semantics as `SpawnAgentInput.depth`. */
|
|
6821
|
+
depth?: number;
|
|
6524
6822
|
}
|
|
6525
6823
|
/** A pull request that a session successfully opened through a code-host
|
|
6526
6824
|
* driver. `openedAt` is assigned by the registry so callers cannot claim a
|
|
@@ -6537,27 +6835,6 @@ interface RecordOpenedPrInput {
|
|
|
6537
6835
|
url: string;
|
|
6538
6836
|
}
|
|
6539
6837
|
|
|
6540
|
-
/**
|
|
6541
|
-
* MCP tools that expose browser service adapters (Camofox, Bureau, …) to
|
|
6542
|
-
* agents connected to the daemon. Lets a remote operator start, stop, and
|
|
6543
|
-
* inspect browser service sessions through the same MCP connection it uses
|
|
6544
|
-
* for fs/exec/agent-cli.
|
|
6545
|
-
*
|
|
6546
|
-
* Five tools:
|
|
6547
|
-
* browser_adapter_list discover available browser adapter ids + metadata
|
|
6548
|
-
* start_browser ensure a browser adapter is up, register as a session
|
|
6549
|
-
* stop_browser kill a running browser session
|
|
6550
|
-
* list_browsers browse alive/recent browser sessions
|
|
6551
|
-
* browser_status descriptor + live health probe for one session
|
|
6552
|
-
*
|
|
6553
|
-
* Auth: same as every other daemon tool — gated by the gateway's auth source.
|
|
6554
|
-
*
|
|
6555
|
-
* Injection pattern: `resolveBrowserAdapter` is passed in, not imported.
|
|
6556
|
-
* This keeps the runtime package free of a hard dep on @agentproto/adapter-browser.
|
|
6557
|
-
* The types below are minimal structural shapes — equivalent to `AgentSessionLike`
|
|
6558
|
-
* in sessions.ts.
|
|
6559
|
-
*/
|
|
6560
|
-
|
|
6561
6838
|
/**
|
|
6562
6839
|
* Minimal shape of a BrowserAdapterInstance — structurally compatible with
|
|
6563
6840
|
* @agentproto/adapter-browser's BrowserAdapterInstance. Kept local so the
|
|
@@ -6902,45 +7179,6 @@ interface InboundWatcher {
|
|
|
6902
7179
|
shutdown(): void;
|
|
6903
7180
|
}
|
|
6904
7181
|
|
|
6905
|
-
/**
|
|
6906
|
-
* Runtime-side glue for the per-workspace brain: a shared registry of
|
|
6907
|
-
* {@link BrainManager}s (one per workspace bucket) plus the two bridges that
|
|
6908
|
-
* connect the pure `@agentproto/workspace-brain` engine to this daemon's real
|
|
6909
|
-
* conversation stores:
|
|
6910
|
-
*
|
|
6911
|
-
* - `readSessionForBrain` — a session id → exported transcript, via the same
|
|
6912
|
-
* ladder as `conversation-read.ts`: the provider-native store first
|
|
6913
|
-
* (`CONVERSATION_STORES`), then the universal `events.jsonl` capture
|
|
6914
|
-
* (`exportDaemonEventsSession`). `null` when neither has anything.
|
|
6915
|
-
* - `resolveWorkspace` — a session id → the workspace bucket it was recorded
|
|
6916
|
-
* under (via the persisted `conversations.jsonl` index).
|
|
6917
|
-
*
|
|
6918
|
-
* The registry itself is keyed by bucket slug and creates each `BrainManager`
|
|
6919
|
-
* lazily, so a workspace that never produces a session pays nothing until its
|
|
6920
|
-
* first exit does.
|
|
6921
|
-
*
|
|
6922
|
-
* A workspace's knowledge backends are configured per-workspace by a
|
|
6923
|
-
* `knowledge.json` file at `<bucket>/knowledge.json` (see
|
|
6924
|
-
* {@link loadKnowledgeConfigForWorkspace}). No file → the brain's default
|
|
6925
|
-
* single `files` provider (identical to pre-config behavior); an invalid
|
|
6926
|
-
* file → warn + fall back to that default; never throws either way.
|
|
6927
|
-
*/
|
|
6928
|
-
|
|
6929
|
-
/** The shared registry handed to both the subscriber and the MCP tools. */
|
|
6930
|
-
interface WorkspaceBrains {
|
|
6931
|
-
/** Get (creating lazily) the brain manager for a workspace bucket slug. */
|
|
6932
|
-
getBrain(workspace: string): BrainManager;
|
|
6933
|
-
/** Map a session id to the workspace bucket it was recorded under. */
|
|
6934
|
-
resolveWorkspace(sessionId: string): Promise<string | undefined>;
|
|
6935
|
-
/** Resolve an explicit workspace slug (or caller slug) to a safe bucket
|
|
6936
|
-
* slug — "default" when unregistered/absent (membership rule). */
|
|
6937
|
-
resolveWorkspaceSlug(workspace?: string, callerSlug?: string): string;
|
|
6938
|
-
}
|
|
6939
|
-
/** Resolve a session id to its exported transcript, native first then daemon
|
|
6940
|
-
* events — `null` (never throws) when neither store has anything readable. */
|
|
6941
|
-
declare function readSessionForBrain(sessionId: string): Promise<ExportedSessionLike | null>;
|
|
6942
|
-
declare function createWorkspaceBrains(): WorkspaceBrains;
|
|
6943
|
-
|
|
6944
7182
|
/**
|
|
6945
7183
|
* MCP tools that expose the per-workspace brain to agents.
|
|
6946
7184
|
*
|
|
@@ -6969,6 +7207,69 @@ interface RegisterBrainToolsOptions {
|
|
|
6969
7207
|
}
|
|
6970
7208
|
declare function registerBrainTools(server: McpServer, opts: RegisterBrainToolsOptions): void;
|
|
6971
7209
|
|
|
7210
|
+
declare const webSearchInputSchema: z.ZodObject<{
|
|
7211
|
+
query: z.ZodString;
|
|
7212
|
+
count: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
7213
|
+
country: z.ZodOptional<z.ZodString>;
|
|
7214
|
+
language: z.ZodOptional<z.ZodString>;
|
|
7215
|
+
freshness: z.ZodOptional<z.ZodEnum<{
|
|
7216
|
+
pd: "pd";
|
|
7217
|
+
pw: "pw";
|
|
7218
|
+
pm: "pm";
|
|
7219
|
+
py: "py";
|
|
7220
|
+
}>>;
|
|
7221
|
+
safesearch: z.ZodOptional<z.ZodEnum<{
|
|
7222
|
+
off: "off";
|
|
7223
|
+
strict: "strict";
|
|
7224
|
+
moderate: "moderate";
|
|
7225
|
+
}>>;
|
|
7226
|
+
}, z.core.$strip>;
|
|
7227
|
+
type WebSearchInput = z.infer<typeof webSearchInputSchema>;
|
|
7228
|
+
declare const webSearchOutputSchema: z.ZodObject<{
|
|
7229
|
+
provider: z.ZodEnum<{
|
|
7230
|
+
brave: "brave";
|
|
7231
|
+
serper: "serper";
|
|
7232
|
+
}>;
|
|
7233
|
+
results: z.ZodArray<z.ZodObject<{
|
|
7234
|
+
title: z.ZodString;
|
|
7235
|
+
url: z.ZodString;
|
|
7236
|
+
snippet: z.ZodOptional<z.ZodString>;
|
|
7237
|
+
position: z.ZodNumber;
|
|
7238
|
+
}, z.core.$strip>>;
|
|
7239
|
+
}, z.core.$strip>;
|
|
7240
|
+
type WebSearchOutput = z.infer<typeof webSearchOutputSchema>;
|
|
7241
|
+
type WebSearchResult = WebSearchOutput["results"][number];
|
|
7242
|
+
declare const webSearchTool: _agentproto_tool.ToolHandle<{
|
|
7243
|
+
query: string;
|
|
7244
|
+
count: number;
|
|
7245
|
+
country?: string | undefined;
|
|
7246
|
+
language?: string | undefined;
|
|
7247
|
+
freshness?: "pd" | "pw" | "pm" | "py" | undefined;
|
|
7248
|
+
safesearch?: "off" | "strict" | "moderate" | undefined;
|
|
7249
|
+
}, {
|
|
7250
|
+
provider: "brave" | "serper";
|
|
7251
|
+
results: {
|
|
7252
|
+
title: string;
|
|
7253
|
+
url: string;
|
|
7254
|
+
position: number;
|
|
7255
|
+
snippet?: string | undefined;
|
|
7256
|
+
}[];
|
|
7257
|
+
}, ToolContext>;
|
|
7258
|
+
declare function defineBraveSearchHttpDriver(): DriverHandle;
|
|
7259
|
+
declare function defineSerperHttpDriver(): DriverHandle;
|
|
7260
|
+
interface RegisterWebSearchToolsOptions {
|
|
7261
|
+
/** Injectable env (tests); default `process.env`. */
|
|
7262
|
+
env?: NodeJS.ProcessEnv;
|
|
7263
|
+
/** Injectable fetch (tests / live e2e); default `globalThis.fetch`. */
|
|
7264
|
+
fetch?: typeof fetch;
|
|
7265
|
+
}
|
|
7266
|
+
/**
|
|
7267
|
+
* Register the `web.search` MCP tool (`web_search`) when at least one
|
|
7268
|
+
* provider key is configured. With NEITHER key present, nothing is
|
|
7269
|
+
* registered — no broken tool is advertised, silently.
|
|
7270
|
+
*/
|
|
7271
|
+
declare function registerWebSearchTools(server: McpServer, opts?: RegisterWebSearchToolsOptions): void;
|
|
7272
|
+
|
|
6972
7273
|
/**
|
|
6973
7274
|
* Workshop-brain subscriber — auto-ingest a workspace's conversations when its
|
|
6974
7275
|
* sessions exit.
|
|
@@ -7382,6 +7683,88 @@ interface RegisterSandboxAttachToolOptions {
|
|
|
7382
7683
|
/** Register the `sandbox_attach` MCP tool. */
|
|
7383
7684
|
declare function registerSandboxAttachTool(server: McpServer, opts?: RegisterSandboxAttachToolOptions): void;
|
|
7384
7685
|
|
|
7686
|
+
/**
|
|
7687
|
+
* The sandbox ledger — `~/.agentproto/sandboxes.json`.
|
|
7688
|
+
*
|
|
7689
|
+
* The daemon KNOWS when it boots, pauses, reconnects to, or stops a sandbox
|
|
7690
|
+
* box (AIP-36 boot-and-drive, `session-spawn.ts`'s `bootSandboxAgentSession`
|
|
7691
|
+
* and the lifecycle teardown inside `SandboxAgentSessionProxy.close()`), but
|
|
7692
|
+
* it writes none of it down: finding a still-live sandboxId meant grepping
|
|
7693
|
+
* session descriptors for a `remote: true` stamp. This module is the
|
|
7694
|
+
* navigation half — one durable record per sandboxId:
|
|
7695
|
+
*
|
|
7696
|
+
* { sandboxId, provider, label?, state, cwd?, originSessionId?,
|
|
7697
|
+
* createdAt, updatedAt, expiresAt? }
|
|
7698
|
+
*
|
|
7699
|
+
* State machine: "booted" (fresh boot) → "connected" (reuse/attach) →
|
|
7700
|
+
* "paused" (proxy close() chose the pause teardown) | "stopped" (kill or
|
|
7701
|
+
* expiry). `expiresAt` is stamped at boot when the spec's lifecycle policy
|
|
7702
|
+
* carries a known idle window (`lifecycle.pause_after_idle` →
|
|
7703
|
+
* `SandboxLifecyclePolicy.pauseAfterIdleMs`) — the one expiry the daemon
|
|
7704
|
+
* actually knows about at boot time; a provider-side TTL the daemon never
|
|
7705
|
+
* sees is deliberately NOT guessed at here.
|
|
7706
|
+
*
|
|
7707
|
+
* Writes are ALWAYS best-effort: every helper swallows its own failures and
|
|
7708
|
+
* returns without throwing. A ledger error must never fail a spawn, a
|
|
7709
|
+
* pause, or a teardown — the ledger is an index over reality, never a
|
|
7710
|
+
* participant in it.
|
|
7711
|
+
*
|
|
7712
|
+
* Persistence style matches the daemon's other JSON stores
|
|
7713
|
+
* (`workspace-buckets.ts`, `saveWorkspacesConfig`): serialize → write to a
|
|
7714
|
+
* per-process-unique tmp file → rename over the target. A concurrent reader
|
|
7715
|
+
* never sees half a JSON object, and two in-flight writers never share a
|
|
7716
|
+
* tmp path (the pid-only suffix is not unique within one process — see the
|
|
7717
|
+
* 2026-08-14 registry-wipe write-up in `workspace-buckets.ts`).
|
|
7718
|
+
*/
|
|
7719
|
+
/** Lifecycle states a ledger row can carry. */
|
|
7720
|
+
type SandboxLedgerState = "booted" | "paused" | "connected" | "stopped";
|
|
7721
|
+
interface SandboxLedgerEntry {
|
|
7722
|
+
sandboxId: string;
|
|
7723
|
+
provider: string;
|
|
7724
|
+
state: SandboxLedgerState;
|
|
7725
|
+
createdAt: string;
|
|
7726
|
+
updatedAt: string;
|
|
7727
|
+
label?: string;
|
|
7728
|
+
cwd?: string;
|
|
7729
|
+
/** The HOST session id that first booted / last reconnected to the box. */
|
|
7730
|
+
originSessionId?: string;
|
|
7731
|
+
/** ISO instant the box is expected to idle-expire — stamped only when the
|
|
7732
|
+
* boot knew a window (`lifecycle.pause_after_idle`). */
|
|
7733
|
+
expiresAt?: string;
|
|
7734
|
+
}
|
|
7735
|
+
/** `~/.agentproto/sandboxes.json`. `AGENTPROTO_SANDBOX_LEDGER` overrides
|
|
7736
|
+
* the path (tests, and a caller that wants a workspace-scoped ledger). */
|
|
7737
|
+
declare const sandboxLedgerPath: () => string;
|
|
7738
|
+
/** Rows currently on disk. `[]` for a missing/corrupt file — the same
|
|
7739
|
+
* "degrade to nothing rather than throw" contract as every other store
|
|
7740
|
+
* reader in this daemon. Never throws. */
|
|
7741
|
+
declare function readSandboxLedger(path?: string): SandboxLedgerEntry[];
|
|
7742
|
+
/** Remove a row by sandboxId. Returns whether a row was actually dropped
|
|
7743
|
+
* (read from the PRE-call disk state). Never throws. */
|
|
7744
|
+
declare function removeSandboxLedgerEntry(sandboxId: string, path?: string): boolean;
|
|
7745
|
+
type ReuseResolution = {
|
|
7746
|
+
kind: "resolved";
|
|
7747
|
+
sandboxId: string;
|
|
7748
|
+
entry: SandboxLedgerEntry;
|
|
7749
|
+
} | {
|
|
7750
|
+
kind: "ambiguous";
|
|
7751
|
+
candidates: SandboxLedgerEntry[];
|
|
7752
|
+
} | {
|
|
7753
|
+
kind: "unresolved";
|
|
7754
|
+
};
|
|
7755
|
+
/**
|
|
7756
|
+
* `reuse: "<label-or-id>"` resolution against the ledger (PLAN-D1 §3).
|
|
7757
|
+
*
|
|
7758
|
+
* A reuse token that exactly matches a row's `label`, or is a PREFIX of
|
|
7759
|
+
* exactly one row's `sandboxId`, resolves to that row's sandboxId. Several
|
|
7760
|
+
* matches → `ambiguous` (the caller must disambiguate — the error it
|
|
7761
|
+
* renders lists the candidates). No match at all → `unresolved`, and the
|
|
7762
|
+
* spawn path passes the token through unchanged so the provider's own
|
|
7763
|
+
* `connect()` failure surfaces exactly as it did before this module
|
|
7764
|
+
* existed.
|
|
7765
|
+
*/
|
|
7766
|
+
declare function resolveReuseFromLedger(reuse: string, entries: readonly SandboxLedgerEntry[]): ReuseResolution;
|
|
7767
|
+
|
|
7385
7768
|
/**
|
|
7386
7769
|
* Idle agent-session reaper (PR-6).
|
|
7387
7770
|
*
|
|
@@ -9059,4 +9442,4 @@ interface GatewayHandle {
|
|
|
9059
9442
|
*/
|
|
9060
9443
|
declare function createGateway(opts: CreateGatewayOptions): Promise<GatewayHandle>;
|
|
9061
9444
|
|
|
9062
|
-
export { type ActivityKind, type ActivityListFilter, type ActivityPolicyLister, type ActivityProjector, type ActivityProjectorRegistry, type ActivityProjectorSession, type ActivityRecord, type ActivitySource, type ActivityState, type ActivityWaitingOn, type ActivityWorkflowLister, AdapterAuthDescriptor, type AdapterCapabilitiesLister, type AdapterInstallResult, type AdapterListEntry, type AgentAdapterInstaller, type AgentAdapterLister, type AgentAdapterResolver, type AgentSessionLike, type AgentStreamEvent, type AnthropicReaderConfig, AnthropicRemainingQuotaReader, type AttachPolicyInput, type AttachSandboxOpts, type AttachSandboxResult, AuthMethod, BUCKETS_ROOT, type BrowserAdapterHandle, type BrowserAdapterInfo, type BrowserAdapterLister, type BrowserAdapterResolver, BuildHeartbeatAgent, CanonicalPosture, type CatalogModelsLister, CatalogModelsQuery, CatalogModelsResponse, type CatalogProviderModel, type CatalogProviderModelsQuery, type CatalogProviderModelsResponse, type CatalogProviderPricing, type ClaudeNativeRef, type CommitSpec, type CompletionPolicySupervisor, ContextProfile, type ConversationIndexRecord, type ConversationNativeRef, type CostBudgetDecision, type CrashDetectSummary, type CrashReaperRegistry, type CreateGatewayOptions, type CreateOfferInput, type CreatedOffer, DEFAULT_BUCKET, DEFAULT_ORCHESTRATOR_TOOLS, DEFAULT_WORKTREE_ISOLATION, DeclaredAdapterOption, type DeclaredAdapterPreset, type EagerResumeFailReason, type EagerResumeOutcome, type EagerResumeSkipReason, type EagerResumeSummary, EffortLevel, type GateSpec, type GatewayHandle, type HarnessPreset, type HarnessPresetValidationDeps, HarnessPresetValidationError, type HarnessPresetsFile, type HermesNativeRef, INBOUND_PROVIDERS, type IdleReapSummary, type IdleReaperRegistry, type InboundEndpoint, type InboundEndpointStore, type InboundEndpointStoreOptions, type InboundEnqueuePrompt, type InboundIsSessionAlive, type InboundMessage, type InboundProvider, type InboundRestartSession, type InboundRouteMode, type InboundRouterDeps, type InboundRouterLog, type InboundSpawnForContact, type InboundWatcher, type JudgeGateSpec, LEGACY_SESSIONS_FILE, type LocatedConversation, type LocatedConversationByPath, type McpCredentialDeps, type MigrationMarker, type NormalizeInboundResult, type OnFailSpec, type OpenPrResolver, type OrchestratorGatewayDeps, type OrchestratorInjection, type OrchestratorInjector, type OrchestratorInjectorDeps, type OrchestratorMcpServerFactory, type OrchestratorScope, type OrphanReaperRegistry, PAIRINGS_VERSION, POSTURE_NATIVE_ALIASES, POSTURE_PREAMBLES, type PairingChannelContext, type PairingChannelHandle, type PairingChannelMode, type PairingRecord, type PairingRegistry, type PairingRegistryDeps, type PendingPermission, type PermissionRespondInput, type PermissionRespondResult, type PolicyRunState, type PolicyRunStatus, Posture, type PostureResolution, type PrResolvedState, type PrStateResolver, type PresetInfo, type PricingResolver, type QuotaReadableProfile, type QuotaStoreFile, type QuotaStoreOptions, type ReconnectLogGate, type RegisterBrainToolsOptions, type RegisterBrowserInput, type RegisterPairingToolsOptions, type RegisterSessionInput, type RemainingQuota, type RemainingQuotaReader, type ResolveNativeLinkInput, ResolvedAuthSpec, ResumeDisabledError, type RouteAwareLaunchConfig, type RouteAwareLaunchConfigInput, RouteSpec, type RuntimeMeta, SESSION_ID_ENV, type SandboxAdapterInfo, type SandboxConnectionDescriptor, type SandboxProviderCapabilities, type SandboxProviderHandle, type SandboxProviderLister, type SandboxProviderResolver, type ScopeTokenRegistry, SessionConfig, type SessionCurrentPhase, type SessionDescriptor, type SessionKind, type SessionObserver, type SessionSnapshots, type SessionStatus, type SessionUsage, type SessionWaitEvent, type SessionWaitResult, type SessionsRegistry, type ShellGateSpec, type SpawnAgentInput, type SpawnSessionInput, type StallWatchdogRegistry, type StallWatchdogSummary, type StoredProfileQuota, TASK_STATUSES, type TaskCaller, type TaskChangedEvent, type TaskClaimInput, type TaskCreateInput, type TaskGateOutcome, type TaskGateRunner, type TaskLedger, type TaskLedgerRegistry, type TaskLedgerSessionSlice, type TaskListFilter, type TaskRecord, type TaskStatus, type TaskUpdateInput, type TaskVerification, type TaskVerifySupervisor, type TaskWriteResult, type TokenPricing, type TransmitterBinding, type TransmitterBindingStore, type TunnelDescriptor, type TunnelProvider, type TunnelStatus, type UsageBucket, type UsageComputeInput, type UsageRollup, type UsageSnapshotRecord, type UsageSource, WORKSPACE_SLUG_ENV, WORKTREE_ISOLATION_ENV, type WatcherDescriptor, type WatcherStartInput, type WorkspaceBrainSubscriber, type WorkspaceBrainSubscriberOptions, type WorkspaceBrains, WorkspaceFs, type WorktreeAutoReclaimer, type WorktreeDecision, type WorktreeField, type WorktreeGcClass, type WorktreeGcOutcomeView, type WorktreeGcPlanEntryView, type WorktreeGcReclaimReason, type WorktreeGcResult, type WorktreeGcRunInput, type WorktreeGcRunner, WorktreeIsolationMode, type WorktreeProvisionOutcome, type WorktreeProvisionRequest, type WorktreeProvisioner, type WorktreeRequest, type WorktreeStatusLister, type WorktreeStatusView, activityCounts, addHarnessPreset, appendConversationRecord, attachSandbox, bucketDir, bucketSessionsFile, bucketTranscriptDir, buildCatalogProviderModels, buildMcpConfigSnippet, buildRouteAwareLaunchConfig, canonicalForModeId, claudeProjectSlug, composeSessionObservers, conversationIndexPath, createActivityProjector, createFileStepCache, createGateway, createInboundEndpointStore, createOrchestratorInjector, createOrchestratorMcpServerFactory, createPairingRegistry, createPrProvenanceReconciler, createReconnectLogGate, createScopeTokenRegistry, createSupervisorTaskGateRunner, createTaskLedger, createWorkspaceBrainSubscriber, createWorkspaceBrains, daemonRegistryDir, decideWorktreeIsolation, declaredPresetToProviderPreset, deriveSessionUsage, enrichRollupWithProviderQuota, enrichWithRemainingQuota, evaluateCostBudget, filterActivities, findConversationRecord, findNativeMode, formatToolCall, formatToolResult, getDefaultHarnessPreset, getHarnessPreset, getMcpCredentialDeps, harnessPresetsPath, isAgentCliAuthConfigured, isClosedTaskStatus, isSafeBucketSlug, isTerminalActivityState, listBuckets, listHarnessPresets, listPresets, loadHarnessPresets, loadQuotaStore, loadWorktreeIsolation, locateConversationByNativePath, locateConversationBySessionId, makeBrowserAdapterLister, migrateLegacySessionsFile, migrationMarkerPath, monitorPolicyWait, monitorSessionWait, narrowOrchestratorTools, normalizeInbound, normalizeModeId, normalizeWorktreeField, parseAnthropicRateLimitHeaders, parseTaskStatus, parseWindow, parseWorktreeIsolationMode, policyToActivities, policyWatchesSession, prToActivities, projectSessionUsage, readConversationIndex, readDaemonRegistry, readProfileQuota, readRegisteredSlugs, readRuntimeMeta, readSessionForBrain, readUsageSnapshots, reapOrphanedDescendants, recordProfileQuota, registerBrainTools, registerBuiltinRoutes, registerPairingTools, registerSandboxAttachTool, removeHarnessPreset, resolveBucketSlug, resolveNativeLink, resolvePosture, rollupUsage, runCrashDetectPass, runEagerResumePass, runIdleReapPass, runStallWatchdogPass, setDefaultPreset, setMcpCredentialDeps, sweepStaleDaemonRegistry, sweepStaleRuntimeMetas, toWorktreeStatusView, turnToActivities, unlinkDaemonRegistryEntry, unlinkRuntimeMeta, updateHarnessPreset, verifyInboundSignature, workflowToActivities, writeDaemonRegistryEntry };
|
|
9445
|
+
export { type ActivityKind, type ActivityListFilter, type ActivityPolicyLister, type ActivityProjector, type ActivityProjectorRegistry, type ActivityProjectorSession, type ActivityRecord, type ActivitySource, type ActivityState, type ActivityWaitingOn, type ActivityWorkflowLister, AdapterAuthDescriptor, type AdapterCapabilitiesLister, type AdapterInstallResult, type AdapterListEntry, type AgentAdapterInstaller, type AgentAdapterLister, type AgentAdapterResolver, type AgentSessionLike, type AgentStreamEvent, type AnthropicReaderConfig, AnthropicRemainingQuotaReader, type AttachPolicyInput, type AttachSandboxOpts, type AttachSandboxResult, AuthMethod, BUCKETS_ROOT, type BrowserAdapterHandle, type BrowserAdapterInfo, type BrowserAdapterLister, type BrowserAdapterResolver, BuildHeartbeatAgent, CanonicalPosture, type CatalogModelsLister, CatalogModelsQuery, CatalogModelsResponse, type CatalogProviderModel, type CatalogProviderModelsQuery, type CatalogProviderModelsResponse, type CatalogProviderPricing, type ClaudeNativeRef, type CommitSpec, type CompletionPolicySupervisor, ContextProfile, type ConversationIndexRecord, type ConversationNativeRef, type CostBudgetDecision, type CrashDetectSummary, type CrashReaperRegistry, type CreateGatewayOptions, type CreateOfferInput, type CreatedOffer, DEFAULT_BUCKET, DEFAULT_ORCHESTRATOR_TOOLS, DEFAULT_WORKTREE_ISOLATION, DeclaredAdapterOption, type DeclaredAdapterPreset, type EagerResumeFailReason, type EagerResumeOutcome, type EagerResumeSkipReason, type EagerResumeSummary, EffortLevel, type GateSpec, type GatewayHandle, type HarnessPreset, type HarnessPresetValidationDeps, HarnessPresetValidationError, type HarnessPresetsFile, type HermesNativeRef, INBOUND_PROVIDERS, type IdleReapSummary, type IdleReaperRegistry, type InboundEndpoint, type InboundEndpointStore, type InboundEndpointStoreOptions, type InboundEnqueuePrompt, type InboundIsSessionAlive, type InboundMessage, type InboundProvider, type InboundRestartSession, type InboundRouteMode, type InboundRouterDeps, type InboundRouterLog, type InboundSpawnForContact, type InboundWatcher, type JudgeGateSpec, LEGACY_SESSIONS_FILE, type LocatedConversation, type LocatedConversationByPath, type McpCredentialDeps, type MigrationMarker, type NormalizeInboundResult, type OnFailSpec, type OpenPrResolver, type OrchestratorGatewayDeps, type OrchestratorInjection, type OrchestratorInjector, type OrchestratorInjectorDeps, type OrchestratorMcpServerFactory, type OrchestratorScope, type OrphanReaperRegistry, PAIRINGS_VERSION, POSTURE_NATIVE_ALIASES, POSTURE_PREAMBLES, type PairingChannelContext, type PairingChannelHandle, type PairingChannelMode, type PairingRecord, type PairingRegistry, type PairingRegistryDeps, type PendingPermission, type PermissionRespondInput, type PermissionRespondResult, type PolicyRunState, type PolicyRunStatus, Posture, type PostureResolution, type PrResolvedState, type PrStateResolver, type PresetInfo, type PricingResolver, type QuotaReadableProfile, type QuotaStoreFile, type QuotaStoreOptions, type ReconnectLogGate, type RegisterBrainToolsOptions, type RegisterBrowserInput, type RegisterPairingToolsOptions, type RegisterSessionInput, type RegisterWebSearchToolsOptions, type RemainingQuota, type RemainingQuotaReader, type ResolveNativeLinkInput, ResolvedAuthSpec, ResumeDisabledError, type ReuseResolution, type RouteAwareLaunchConfig, type RouteAwareLaunchConfigInput, RouteSpec, type RuntimeMeta, SESSION_ID_ENV, type SandboxAdapterInfo, type SandboxConnectionDescriptor, type SandboxLedgerEntry, type SandboxLedgerState, type SandboxProviderCapabilities, type SandboxProviderHandle, type SandboxProviderLister, type SandboxProviderResolver, type ScopeTokenRegistry, SessionConfig, type SessionCurrentPhase, type SessionDescriptor, type SessionKind, type SessionObserver, type SessionSnapshots, type SessionStatus, type SessionUsage, type SessionWaitEvent, type SessionWaitResult, type SessionsRegistry, type ShellGateSpec, type SpawnAgentInput, type SpawnSessionInput, type StallWatchdogRegistry, type StallWatchdogSummary, type StoredProfileQuota, TASK_STATUSES, type TaskCaller, type TaskChangedEvent, type TaskClaimInput, type TaskCreateInput, type TaskGateOutcome, type TaskGateRunner, type TaskLedger, type TaskLedgerRegistry, type TaskLedgerSessionSlice, type TaskListFilter, type TaskRecord, type TaskStatus, type TaskUpdateInput, type TaskVerification, type TaskVerifySupervisor, type TaskWriteResult, type TokenPricing, type TransmitterBinding, type TransmitterBindingStore, type TunnelDescriptor, type TunnelProvider, type TunnelStatus, type UsageBucket, type UsageComputeInput, type UsageRollup, type UsageSnapshotRecord, type UsageSource, WORKSPACE_SLUG_ENV, WORKTREE_ISOLATION_ENV, type WatcherDescriptor, type WatcherStartInput, type WebSearchInput, type WebSearchOutput, type WebSearchResult, type WorkspaceBrainSubscriber, type WorkspaceBrainSubscriberOptions, type WorkspaceBrains, WorkspaceFs, type WorktreeAutoReclaimer, type WorktreeDecision, type WorktreeField, type WorktreeGcClass, type WorktreeGcOutcomeView, type WorktreeGcPlanEntryView, type WorktreeGcReclaimReason, type WorktreeGcResult, type WorktreeGcRunInput, type WorktreeGcRunner, WorktreeIsolationMode, type WorktreeProvisionOutcome, type WorktreeProvisionRequest, type WorktreeProvisioner, type WorktreeRequest, type WorktreeStatusLister, type WorktreeStatusView, activityCounts, addHarnessPreset, appendConversationRecord, attachSandbox, bucketDir, bucketSessionsFile, bucketTranscriptDir, buildCatalogProviderModels, buildMcpConfigSnippet, buildRouteAwareLaunchConfig, canonicalForModeId, claudeProjectSlug, composeSessionObservers, conversationIndexPath, createActivityProjector, createFileStepCache, createGateway, createInboundEndpointStore, createOrchestratorInjector, createOrchestratorMcpServerFactory, createPairingRegistry, createPrProvenanceReconciler, createReconnectLogGate, createScopeTokenRegistry, createSupervisorTaskGateRunner, createTaskLedger, createWorkspaceBrainSubscriber, createWorkspaceBrains, daemonRegistryDir, decideWorktreeIsolation, declaredPresetToProviderPreset, defineBraveSearchHttpDriver, defineSerperHttpDriver, deriveSessionUsage, enrichRollupWithProviderQuota, enrichWithRemainingQuota, evaluateCostBudget, filterActivities, findConversationRecord, findNativeMode, formatToolCall, formatToolResult, getDefaultHarnessPreset, getHarnessPreset, getMcpCredentialDeps, harnessPresetsPath, isAgentCliAuthConfigured, isClosedTaskStatus, isSafeBucketSlug, isTerminalActivityState, listBuckets, listHarnessPresets, listPresets, loadHarnessPresets, loadQuotaStore, loadWorktreeIsolation, locateConversationByNativePath, locateConversationBySessionId, makeBrowserAdapterLister, makeSandboxCredsStore, makeSandboxResolver, migrateLegacySessionsFile, migrationMarkerPath, monitorPolicyWait, monitorSessionWait, narrowOrchestratorTools, normalizeInbound, normalizeModeId, normalizeWorktreeField, parseAnthropicRateLimitHeaders, parseTaskStatus, parseWindow, parseWorktreeIsolationMode, policyToActivities, policyWatchesSession, prToActivities, projectSessionUsage, readConversationIndex, readDaemonRegistry, readProfileQuota, readRegisteredSlugs, readRuntimeMeta, readSandboxLedger, readSessionForBrain, readUsageSnapshots, reapOrphanedDescendants, recordProfileQuota, registerBrainTools, registerBuiltinRoutes, registerPairingTools, registerSandboxAttachTool, registerWebSearchTools, removeHarnessPreset, removeSandboxLedgerEntry, resolveBucketSlug, resolveNativeLink, resolvePosture, resolveReuseFromLedger, rollupUsage, runCrashDetectPass, runEagerResumePass, runIdleReapPass, runStallWatchdogPass, sandboxLedgerPath, setDefaultPreset, setMcpCredentialDeps, sweepStaleDaemonRegistry, sweepStaleRuntimeMetas, toWorktreeStatusView, turnToActivities, unlinkDaemonRegistryEntry, unlinkRuntimeMeta, updateHarnessPreset, verifyInboundSignature, webSearchTool, workflowToActivities, writeDaemonRegistryEntry };
|