@agentproto/runtime 2.10.1 → 2.12.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/dist/index.d.ts CHANGED
@@ -13,8 +13,8 @@ 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
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-DUnTfwVK.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-DUnTfwVK.js';
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';
@@ -557,15 +557,16 @@ interface ToolCallRecord {
557
557
  *
558
558
  * Deliberately dependency-free — a `SessionState`, two pure summarisers, one
559
559
  * regenerate/guard helper — so it can be BOTH:
560
- * - reused verbatim by `summarize_session` (agents-overview-app.ts re-exports
561
- * `summarizeLines` / `deriveSessionState` from here), and
560
+ * - reused verbatim by `summarize_session` (summarize-session-tool.ts
561
+ * imports `summarizeLines` / `deriveSessionState` from here), and
562
562
  * - imported by the session store (sessions.ts) to stamp `activitySummary`
563
563
  * onto the descriptor on turn-end, WITHOUT dragging the overview panel's
564
- * HTML bundle or the MCP-app wiring into the hot session path.
564
+ * HTML bundle (now @agentproto/apps/agents-overview) or the MCP-app
565
+ * wiring into the hot session path.
565
566
  *
566
- * HEURISTIC, no LLM: `@agentproto/runtime` has no inference client (see the
567
- * agents-overview-app.ts header for why a `ModelLike.complete` call is too
568
- * heavy today). `regenerateActivitySummary` is the documented swap point —
567
+ * HEURISTIC, no LLM: `@agentproto/runtime` has no inference client (see
568
+ * summarize-session-tool.ts's header for why a `ModelLike.complete` call is
569
+ * too heavy today). `regenerateActivitySummary` is the documented swap point —
569
570
  * replace its `summarizeLines`/`deriveSessionState` body with a
570
571
  * `ModelLike.complete({ system, prompt })` call to upgrade the line to a
571
572
  * semantic one; the trigger + `renamedByUser` guard contract and the
@@ -1683,7 +1684,7 @@ declare function createTaskLedger(opts: {
1683
1684
  * and session_monitor MCP tool (long-poll multiplexed).
1684
1685
  */
1685
1686
 
1686
- 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";
1687
+ 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" | "session:harness-warning";
1687
1688
  /**
1688
1689
  * Fixed severity vocabulary for a judge-gate finding (WP-D). Deliberately
1689
1690
  * small and fixed so `policy_status` output is comparable across different
@@ -1812,6 +1813,26 @@ interface SessionPermissionRequestEvent {
1812
1813
  label?: string;
1813
1814
  ts: string;
1814
1815
  }
1816
+ /**
1817
+ * Emitted when a client's next prompt text matched one of a structured
1818
+ * `awaitingQuestion`'s `options` (case-insensitive, trimmed) and was
1819
+ * therefore treated as an answer instead of a normal turn — see
1820
+ * `sessions.ts`'s structured-question-answer dispatch. Distinct from
1821
+ * `session:awaiting-input-flagged`: that fires for an EXTERNAL manual
1822
+ * override of the flag; this fires when the session's own declared options
1823
+ * were used as intended, by whichever seam the prompt came through
1824
+ * (`agent_prompt`, the HTTP prompt route, or the CLI).
1825
+ */
1826
+ interface SessionAwaitingQuestionAnsweredEvent {
1827
+ type: "session:awaiting-question-answered";
1828
+ sessionId: string;
1829
+ /** The matched option string, verbatim from `question.options`. */
1830
+ answer: string;
1831
+ /** The question that was answered. */
1832
+ question: SessionAwaitingQuestion;
1833
+ label?: string;
1834
+ ts: string;
1835
+ }
1815
1836
  /**
1816
1837
  * Emitted when a parked permission is resolved — by an inbox
1817
1838
  * approve/deny, or auto-`cancelled` when the session is torn down while the
@@ -2271,7 +2292,72 @@ interface TaskChangedEvent {
2271
2292
  sessionId?: string;
2272
2293
  ts: string;
2273
2294
  }
2274
- type SessionEvent = SessionTurnEndEvent | SessionAwaitingInputEvent | SessionAwaitingInputFlaggedEvent | 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;
2295
+ /**
2296
+ * Emitted by the workflow runner (`workflow-runner.ts`) for every `kind:
2297
+ * "gate"` step command attempt — not just the last — carrying that attempt's
2298
+ * pass/fail, exit code, and parsed report (AIP-15 P3). Rides the same bus
2299
+ * fan-out as every other lifecycle event (`session_events_poll`, the
2300
+ * webhook notifier, `session_monitor`), giving a live watcher visibility
2301
+ * into a retry-with-reprompt loop as it happens, not just its final state.
2302
+ */
2303
+ interface WorkflowGateReportEvent {
2304
+ type: "workflow:gate-report";
2305
+ runId: string;
2306
+ stepId: string;
2307
+ ok: boolean;
2308
+ exitCode: number;
2309
+ report: unknown;
2310
+ attempt: number;
2311
+ ts: string;
2312
+ }
2313
+ /**
2314
+ * Emitted by the workflow runner (`workflow-runner.ts`) when a `kind:
2315
+ * "approval"` step parks its run awaiting a human decision — the run's
2316
+ * status flips to `awaiting-approval`, `workflow_status` carries
2317
+ * `awaitingApproval`, and `workflow_escalation_resolve` (approval form)
2318
+ * resolves it. Same bus distribution as every other lifecycle event.
2319
+ */
2320
+ interface WorkflowApprovalRequestedEvent {
2321
+ type: "workflow:approval-requested";
2322
+ runId: string;
2323
+ approvalId: string;
2324
+ stepId: string;
2325
+ prompt: string;
2326
+ approvers: readonly string[];
2327
+ artifacts?: readonly string[];
2328
+ requestedAt: string;
2329
+ ts: string;
2330
+ }
2331
+ /**
2332
+ * Emitted by the workflow runner when a parked approval is resolved — by a
2333
+ * human (`workflow_escalation_resolve`), a timeout (`who: "timeout"`), or a
2334
+ * cancel. The run resumes (or unwinds) right after this fires.
2335
+ */
2336
+ interface WorkflowApprovalResolvedEvent {
2337
+ type: "workflow:approval-resolved";
2338
+ runId: string;
2339
+ approvalId: string;
2340
+ stepId: string;
2341
+ approved: boolean;
2342
+ who: string;
2343
+ note?: string;
2344
+ ts: string;
2345
+ }
2346
+ /**
2347
+ * Emitted when a `kind: "agent"` step's `harness` block declared a field the
2348
+ * spawn couldn't honor (today: `harness.tools` — no adapter exposes a
2349
+ * generic per-spawn tool allowlist this runtime can drive; see
2350
+ * `AgentHarness.tools`'s doc) — the "never silently ignore" fallback AIP-15
2351
+ * P2 requires. Same bus distribution as every other lifecycle event.
2352
+ */
2353
+ interface SessionHarnessWarningEvent {
2354
+ type: "session:harness-warning";
2355
+ sessionId: string;
2356
+ warnings: string[];
2357
+ label?: string;
2358
+ ts: string;
2359
+ }
2360
+ 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 | SessionHarnessWarningEvent;
2275
2361
  interface SessionEventBus {
2276
2362
  emit(ev: SessionEvent): void;
2277
2363
  /** Subscribe to a specific event type. Returns an unsubscribe fn. */
@@ -3400,6 +3486,23 @@ declare function createActivityProjector(opts: {
3400
3486
  */
3401
3487
  type AgentsMdMode = "inline" | "pointer" | "absent";
3402
3488
 
3489
+ /** What a served app records on the session descriptor and echoes in the
3490
+ * spawn result — non-secret, caller-visible. */
3491
+ interface SessionAppServeInfo {
3492
+ /** App id the box's `app_install` registered. */
3493
+ appId: string;
3494
+ /** The in-box app dir that was installed + served. */
3495
+ dir: string;
3496
+ /** Port the UI binds inside the box. */
3497
+ port: number;
3498
+ /** Provider-resolved public URL for the served UI. */
3499
+ url: string;
3500
+ /** True when a probe against `url` answered OK within the readiness
3501
+ * window. False means the URL is the right address but the server had
3502
+ * not answered yet — retry the fetch rather than re-spawning. */
3503
+ ready: boolean;
3504
+ }
3505
+
3403
3506
  /**
3404
3507
  * Policy layer for `agent_start.worktree` — the config-driven decision of
3405
3508
  * WHETHER to isolate a spawn into its own git worktree, kept deliberately
@@ -3869,6 +3972,17 @@ type AgentAdapterResolver = (slug: string) => Promise<{
3869
3972
  * no caller-facing `env` passthrough on `agent_start` today, so this is
3870
3973
  * daemon-authored only, not a general escape hatch. */
3871
3974
  env?: Record<string, string>;
3975
+ /** Absolute paths OUTSIDE the session cwd the adapter's workspace
3976
+ * toolset may READ (never write). Daemon-authored only — used for the
3977
+ * exact AGENTS.md file an inherited (pointer-mode) prompt names, so a
3978
+ * cwd below the repo root can actually read the contract file its
3979
+ * prompt points at instead of erroring
3980
+ * (`path … escapes the workspace`). NOT a general escape hatch: the
3981
+ * driver forwards these to its confinement layer as extra READ paths
3982
+ * and (for the mastra-agent adapter) to `makeWorkspaceTools` as a
3983
+ * read-only grant; writes and sibling reads stay denied. Adapters
3984
+ * that can't model the grant ignore it. */
3985
+ additionalReadPaths?: string[];
3872
3986
  }): Promise<AgentSessionLike>;
3873
3987
  /** Display label for the descriptor's `command` field. */
3874
3988
  commandPreview?: string;
@@ -3972,6 +4086,11 @@ interface AdapterListEntry {
3972
4086
  * cli`'s `AdapterInfo.routeSelection` without importing it.
3973
4087
  */
3974
4088
  routeSelection?: "free" | "derived-from-model";
4089
+ /** Known-valid model identifiers for this adapter (`@agentproto/cli`'s
4090
+ * `AdapterInfo.models`, forwarded verbatim). Undefined when the lister
4091
+ * behind `AgentAdapterLister` doesn't populate it — `adapter_list`'s
4092
+ * `summary` projection depends on this being present. */
4093
+ models?: string[];
3975
4094
  }
3976
4095
  type AgentAdapterLister = () => Promise<AdapterListEntry[]>;
3977
4096
  /**
@@ -4290,6 +4409,11 @@ interface AgentStreamEvent {
4290
4409
  * @agentproto/acp's `StreamEvent`'s `agent-prompt` kind. Harness-shaped
4291
4410
  * and untyped; don't assume a stable schema across adapters. */
4292
4411
  rawInput?: unknown;
4412
+ /** "agent-prompt" `_meta` bag, e.g. an ACP `requestPermission`'s
4413
+ * `toolCall._meta` (mastra-agent's `mastra-agent/suspendPayload` carries a
4414
+ * submit_plan's plan text there) — see @agentproto/acp's `StreamEvent`'s
4415
+ * `agent-prompt` kind. Harness-shaped and untyped. */
4416
+ _meta?: unknown;
4293
4417
  /** "plan" event title — see @agentproto/acp's `StreamEvent`'s `plan` kind. */
4294
4418
  title?: string;
4295
4419
  /** "plan" event entries — see @agentproto/acp's `StreamEvent`'s `plan` kind. */
@@ -5206,6 +5330,16 @@ interface SessionDescriptor {
5206
5330
  /** True when the session has been hard-stopped by the context-continuity
5207
5331
  * policy — no new prompt may be admitted. */
5208
5332
  contextContinuityHardStopped?: boolean;
5333
+ /** The context percentage at which the user last answered "keep-going" to
5334
+ * the `ask`-mode continue-fresh question. `evaluateContextContinuity`
5335
+ * won't re-raise the same question until `contextPct` climbs past this
5336
+ * value again — otherwise the very next turn-boundary check (context
5337
+ * hasn't moved) would immediately re-ask, since the `ask` state covers
5338
+ * the whole `[compactAtPct, hardStopAtPct)` band, not just the instant it
5339
+ * was crossed. The hard-stop threshold is never suppressed by this — it
5340
+ * is checked ahead of `ask` in `contextContinuityStateForPct` and fires
5341
+ * regardless of any acknowledgment. */
5342
+ contextContinuityAckedAtPct?: number;
5209
5343
  /** Id of the most recent checkpoint created for this session. */
5210
5344
  checkpointId?: string;
5211
5345
  /** When this session was continued fresh, the source session id. */
@@ -5287,6 +5421,15 @@ interface SessionDescriptor {
5287
5421
  * default, ephemeral) or `"pause"` (keeps `sandboxId` reconnectable via
5288
5422
  * `agent_start.sandbox.reuse`). Only set when `remote` is true. */
5289
5423
  sandboxTeardown?: "kill" | "pause";
5424
+ /** App ports exposed at boot time (`SandboxSpec.extraPorts`) — maps port
5425
+ * number to its public URL. Only present for sandbox sessions where the
5426
+ * provider resolved `extraPorts` into `BootedSandbox.ports`. */
5427
+ sandboxPorts?: Record<number, string>;
5428
+ /** WP3 — an app UI served from INSIDE this sandbox session's box
5429
+ * (`agent_start.appServe`): the box-installed appId, the in-box dir, the
5430
+ * serve port, and the provider-resolved public URL. See
5431
+ * `sandbox-app-serve.ts`. */
5432
+ appServe?: SessionAppServeInfo;
5290
5433
  }
5291
5434
  /**
5292
5435
  * Lightweight panel projection of SessionDescriptor for the VS Code Sessions
@@ -5391,6 +5534,8 @@ interface SessionSummary {
5391
5534
  remote?: boolean;
5392
5535
  sandboxId?: string;
5393
5536
  sandboxTeardown?: "kill" | "pause";
5537
+ sandboxPorts?: Record<number, string>;
5538
+ appServe?: SessionAppServeInfo;
5394
5539
  }
5395
5540
  /**
5396
5541
  * Thrown by the lazy resume path when a resumable session has already failed to
@@ -5514,15 +5659,27 @@ interface PendingPermission {
5514
5659
  * schema across adapters.
5515
5660
  */
5516
5661
  rawInput?: unknown;
5662
+ /**
5663
+ * The tool call's `_meta` (e.g. mastra-agent's `mastra-agent/suspendPayload`
5664
+ * carrying a submit_plan's plan text), carried through from the ACP
5665
+ * `agent-prompt` event's `_meta` field when the driver supplied one.
5666
+ * Harness-shaped and untyped — don't assume a stable schema across adapters.
5667
+ */
5668
+ _meta?: unknown;
5517
5669
  }
5518
5670
  /** How a caller resolves a pending permission — an explicit `optionId` wins
5519
5671
  * over the `decision`→option mapping (approve → an allow-flavored option,
5520
5672
  * deny → a reject-flavored option). `scope: "always"` prefers an
5521
- * allow-always option when the request offers one. */
5673
+ * allow-always option when the request offers one. `feedback` is optional
5674
+ * free text (e.g. "reject, but do X instead") sent alongside the outcome —
5675
+ * the acp client forwards it on the ACP outcome's `_meta`
5676
+ * (`agentproto/feedback`) for adapters that consume it (mastra-agent folds
5677
+ * it into a suspension's resumeData). */
5522
5678
  interface PermissionRespondInput {
5523
5679
  decision: "approve" | "deny";
5524
5680
  optionId?: string;
5525
5681
  scope?: "once" | "always";
5682
+ feedback?: string;
5526
5683
  }
5527
5684
  type PermissionRespondResult = {
5528
5685
  ok: true;
@@ -6351,6 +6508,7 @@ interface SpawnAgentInput {
6351
6508
  * reads its state.db keyed by the adapter session id). Omit for adapters
6352
6509
  * with no usage source. */
6353
6510
  readUsage?: () => Promise<{
6511
+ model?: string;
6354
6512
  costUsd?: number;
6355
6513
  tokensIn?: number;
6356
6514
  tokensOut?: number;
@@ -6367,6 +6525,12 @@ interface SpawnAgentInput {
6367
6525
  /** What session close does to the box, when `remote` is true — see
6368
6526
  * `SessionDescriptor.sandboxTeardown`. */
6369
6527
  sandboxTeardown?: "kill" | "pause";
6528
+ /** Port-to-URL map from the booted sandbox — see
6529
+ * `SessionDescriptor.sandboxPorts`. */
6530
+ sandboxPorts?: Record<number, string>;
6531
+ /** WP3 — in-box app-serve echo (`agent_start.appServe`), recorded verbatim
6532
+ * onto {@link SessionDescriptor.appServe}. See `sandbox-app-serve.ts`. */
6533
+ appServe?: SessionAppServeInfo;
6370
6534
  /** True when the driver session was started in permission-hold mode
6371
6535
  * (`AgentCliStartOptions.permissionHold`) — its `agent-prompt` events carry
6372
6536
  * respondable permission requests. Gates whether the registry registers
@@ -6400,6 +6564,7 @@ type PendingAgentOutcome = {
6400
6564
  resumable?: boolean;
6401
6565
  nativeTerminalResume?: boolean;
6402
6566
  readUsage?: () => Promise<{
6567
+ model?: string;
6403
6568
  costUsd?: number;
6404
6569
  tokensIn?: number;
6405
6570
  tokensOut?: number;
@@ -6781,6 +6946,7 @@ interface ReconcilerSession extends FooterSession {
6781
6946
  worktreePath?: string;
6782
6947
  openedPrs?: readonly {
6783
6948
  url: string;
6949
+ number?: number;
6784
6950
  }[];
6785
6951
  }
6786
6952
  /** The registry slice the reconciler needs — structurally satisfied by the full