@sema-agent/core 7.58.0 → 7.59.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/CHANGELOG.md +776 -0
- package/README.md +6 -4
- package/dist/agents/cc-peer-directory.js +8 -8
- package/dist/agents/child-model-seat.d.ts +4 -2
- package/dist/agents/child-model-seat.js +5 -3
- package/dist/agents/peer-directory.d.ts +9 -0
- package/dist/agents/peer-directory.js +6 -2
- package/dist/agents/send-message-tool.js +21 -12
- package/dist/agents/subagent.js +33 -34
- package/dist/brain/anthropic.js +161 -45
- package/dist/brain/errors.d.ts +9 -3
- package/dist/brain/errors.js +7 -1
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +3 -3
- package/dist/brain/openai.js +103 -53
- package/dist/brain/provider-dialect.d.ts +11 -0
- package/dist/brain/provider-dialect.js +5 -2
- package/dist/brain/reasoning-request.js +5 -4
- package/dist/brain/reasoning.d.ts +19 -0
- package/dist/brain/reasoning.js +17 -2
- package/dist/brain/request-route.d.ts +4 -1
- package/dist/brain/request-route.js +4 -1
- package/dist/brain/route-adjudicator.d.ts +84 -18
- package/dist/brain/route-adjudicator.js +87 -21
- package/dist/brain/route-conformance.js +1 -1
- package/dist/brain/stream-engine.js +84 -49
- package/dist/brain/stream-shared.d.ts +30 -0
- package/dist/brain/stream-shared.js +34 -1
- package/dist/brain/timeout.d.ts +62 -5
- package/dist/brain/timeout.js +93 -6
- package/dist/core/account-row.d.ts +61 -0
- package/dist/core/account-row.js +51 -0
- package/dist/core/advisor-verdict.d.ts +2 -1
- package/dist/core/advisor-verdict.js +1 -1
- package/dist/core/allow-entry.d.ts +18 -6
- package/dist/core/allow-entry.js +16 -8
- package/dist/core/approval-object.d.ts +29 -15
- package/dist/core/approval-object.js +47 -19
- package/dist/core/auto-compaction.js +1 -1
- package/dist/core/background-agent-store.d.ts +16 -3
- package/dist/core/checkpoint-requirements.d.ts +13 -1
- package/dist/core/checkpoint-requirements.js +3 -1
- package/dist/core/checkpoint-store.d.ts +58 -12
- package/dist/core/checkpoint-store.js +18 -6
- package/dist/core/child-clamp-seats.d.ts +29 -0
- package/dist/core/child-clamp-seats.js +56 -1
- package/dist/core/compliance.d.ts +2 -2
- package/dist/core/compliance.js +1 -1
- package/dist/core/effective-path-target.d.ts +8 -2
- package/dist/core/effective-path-target.js +8 -3
- package/dist/core/engine-notice.d.ts +98 -8
- package/dist/core/engine-notice.js +19 -5
- package/dist/core/gate-fold.js +1 -1
- package/dist/core/gate-lanes.js +8 -4
- package/dist/core/gate-outcome.d.ts +32 -3
- package/dist/core/gate-outcome.js +19 -1
- package/dist/core/governance-codes.d.ts +9 -1
- package/dist/core/governance-codes.js +13 -0
- package/dist/core/hooks.d.ts +31 -3
- package/dist/core/hooks.js +5 -6
- package/dist/core/image-admission.d.ts +6 -5
- package/dist/core/image-admission.js +18 -14
- package/dist/core/locked-config.d.ts +5 -2
- package/dist/core/locked-config.js +2 -1
- package/dist/core/mailbox-store.d.ts +45 -1
- package/dist/core/mailbox-store.js +53 -9
- package/dist/core/mcp-failure.d.ts +114 -18
- package/dist/core/mcp-failure.js +63 -5
- package/dist/core/mcp-server-link.d.ts +22 -1
- package/dist/core/mcp-server-link.js +25 -1
- package/dist/core/mcp.d.ts +12 -8
- package/dist/core/mcp.js +42 -25
- package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
- package/dist/core/memory-engine/consolidation-driver.js +3 -3
- package/dist/core/memory-engine/consolidation.d.ts +4 -0
- package/dist/core/memory-engine/consolidation.js +1 -0
- package/dist/core/memory-engine/delegation-settlement.js +5 -12
- package/dist/core/memory-engine/distiller.js +2 -2
- package/dist/core/memory-engine/dual-root.d.ts +50 -1
- package/dist/core/memory-engine/dual-root.js +44 -1
- package/dist/core/memory-engine/engine.d.ts +67 -14
- package/dist/core/memory-engine/engine.js +384 -212
- package/dist/core/memory-engine/export-bundle.d.ts +23 -0
- package/dist/core/memory-engine/export-bundle.js +23 -4
- package/dist/core/memory-engine/file-backend.d.ts +128 -55
- package/dist/core/memory-engine/file-backend.js +290 -117
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/layout.d.ts +59 -11
- package/dist/core/memory-engine/layout.js +190 -40
- package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
- package/dist/core/memory-engine/memory-backend-contract.js +39 -2
- package/dist/core/memory-engine/sync-client.d.ts +9 -1
- package/dist/core/memory-engine/sync-client.js +31 -8
- package/dist/core/memory-engine/sync.d.ts +5 -0
- package/dist/core/memory-engine/types.d.ts +6 -0
- package/dist/core/mods/classic-events.d.ts +5 -1
- package/dist/core/mods/kernel/dispatch.js +2 -1
- package/dist/core/mods/kernel/events.d.ts +2 -1
- package/dist/core/mods/kernel/events.js +2 -2
- package/dist/core/mods/kernel/registration.d.ts +4 -0
- package/dist/core/mods/kernel/registration.js +3 -0
- package/dist/core/mods/stations.d.ts +31 -10
- package/dist/core/mods/stations.js +44 -10
- package/dist/core/mods/tool-call.js +1 -1
- package/dist/core/parent-spec-seat.d.ts +8 -3
- package/dist/core/parent-spec-seat.js +2 -0
- package/dist/core/park-selfcheck.js +6 -0
- package/dist/core/peer-seat.d.ts +70 -8
- package/dist/core/peer-seat.js +143 -11
- package/dist/core/permission-rule-consent.js +10 -4
- package/dist/core/permission-rule-model.d.ts +16 -0
- package/dist/core/permission-rule-model.js +1 -1
- package/dist/core/present-plan-tool.d.ts +11 -3
- package/dist/core/present-plan-tool.js +2 -2
- package/dist/core/resume-startup-cause.js +1 -0
- package/dist/core/rewrite-rejudge.d.ts +1 -0
- package/dist/core/rewrite-rejudge.js +2 -2
- package/dist/core/roles.d.ts +34 -2
- package/dist/core/roles.js +43 -4
- package/dist/core/runner/announce-once-ledger.d.ts +5 -4
- package/dist/core/runner/announce-once-ledger.js +4 -2
- package/dist/core/runner/call-hook-stations.js +2 -2
- package/dist/core/runner/contracts.d.ts +20 -16
- package/dist/core/runner/credential-origin-seat.js +4 -3
- package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
- package/dist/core/runner/cwd-alignment-probe.js +21 -0
- package/dist/core/runner/decide-continuation.d.ts +2 -2
- package/dist/core/runner/gate-exit.d.ts +12 -4
- package/dist/core/runner/gate-exit.js +10 -7
- package/dist/core/runner/image-removed-seat.d.ts +12 -0
- package/dist/core/runner/image-removed-seat.js +19 -0
- package/dist/core/runner/inline-image.js +1 -1
- package/dist/core/runner/memory-consolidation-driver.js +3 -3
- package/dist/core/runner/park-commit.d.ts +1 -1
- package/dist/core/runner/park-commit.js +3 -0
- package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
- package/dist/core/runner/prepare-ask-lane.js +2 -1
- package/dist/core/runner/prepare-boundary-parks.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +3 -5
- package/dist/core/runner/prepare-caps-and-workflow.js +2 -0
- package/dist/core/runner/prepare-config-doors.js +2 -0
- package/dist/core/runner/prepare-context-lane.js +2 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +4 -0
- package/dist/core/runner/prepare-delegation-surface.js +1 -0
- package/dist/core/runner/prepare-hands-readface.d.ts +4 -0
- package/dist/core/runner/prepare-hands-readface.js +5 -0
- package/dist/core/runner/prepare-inherited-gate.d.ts +1 -3
- package/dist/core/runner/prepare-inherited-gate.js +14 -27
- package/dist/core/runner/prepare-memory.js +10 -17
- package/dist/core/runner/prepare-park-ask.d.ts +1 -1
- package/dist/core/runner/prepare-park-ask.js +2 -1
- package/dist/core/runner/prepare-policy-chain.d.ts +3 -3
- package/dist/core/runner/prepare-policy-chain.js +16 -13
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-project-context.js +2 -2
- package/dist/core/runner/prepare-prompt-inputs.d.ts +1 -1
- package/dist/core/runner/prepare-prompt-inputs.js +8 -19
- package/dist/core/runner/prepare-protocol-tools.js +9 -1
- package/dist/core/runner/prepare-run-refs.d.ts +2 -3
- package/dist/core/runner/prepare-run-refs.js +4 -1
- package/dist/core/runner/prepare-task.js +4 -2
- package/dist/core/runner/prepare-wiring-manifest.d.ts +1 -1
- package/dist/core/runner/prepare-wiring-manifest.js +2 -1
- package/dist/core/runner/reply-pricing.d.ts +30 -0
- package/dist/core/runner/reply-pricing.js +19 -0
- package/dist/core/runner/resume-admission.js +4 -2
- package/dist/core/runner/resume-apply.js +6 -1
- package/dist/core/runner/resume-policy-outcome.js +5 -5
- package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
- package/dist/core/runner/role-seat-defaulted.js +40 -0
- package/dist/core/runner/run-brain-sinks.js +2 -0
- package/dist/core/runner/run-identity-wiring.d.ts +2 -5
- package/dist/core/runner/run-identity-wiring.js +5 -4
- package/dist/core/runner/run-leg.d.ts +2 -0
- package/dist/core/runner/run-leg.js +37 -28
- package/dist/core/runner/run-stop-and-final-verify.js +2 -2
- package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
- package/dist/core/runner/run-terminal-adoption.js +9 -3
- package/dist/core/runner/run-turn-boundary.js +77 -70
- package/dist/core/runner/runtask.d.ts +1 -1
- package/dist/core/runner/runtask.js +2 -2
- package/dist/core/runner/side-call-account.d.ts +1 -1
- package/dist/core/runner/side-call-account.js +3 -18
- package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
- package/dist/core/runner/sub-agent-deny-lists.js +10 -0
- package/dist/core/runner/tool-end-body.js +2 -2
- package/dist/core/runner/tool-occurrence.d.ts +1 -1
- package/dist/core/runner/tool-occurrence.js +2 -2
- package/dist/core/runner/turn-attachments.d.ts +26 -22
- package/dist/core/runner/turn-attachments.js +24 -26
- package/dist/core/runner-deps.d.ts +1 -1
- package/dist/core/secret-env.d.ts +32 -2
- package/dist/core/secret-env.js +65 -3
- package/dist/core/sensitive-path-policy.js +3 -3
- package/dist/core/session-policy-store.d.ts +3 -1
- package/dist/core/session-policy-store.js +13 -9
- package/dist/core/session-store.d.ts +2 -5
- package/dist/core/side-query.d.ts +11 -1
- package/dist/core/side-query.js +9 -0
- package/dist/core/skill-grant-binding.d.ts +31 -2
- package/dist/core/skill-grant-binding.js +31 -1
- package/dist/core/skill-grant.d.ts +8 -5
- package/dist/core/skill-grant.js +6 -6
- package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +3 -2
- package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
- package/dist/core/synthetic-read-verdict.js +2 -1
- package/dist/core/task-event.d.ts +32 -8
- package/dist/core/task-notification.js +16 -10
- package/dist/core/task-registry-agent.js +1 -0
- package/dist/core/task-registry-shared.d.ts +5 -0
- package/dist/core/task-spec.d.ts +12 -1
- package/dist/core/terminal-cause.d.ts +10 -0
- package/dist/core/tool-check-reading.d.ts +1 -0
- package/dist/core/tool-check-reading.js +3 -3
- package/dist/core/tool-policy.d.ts +16 -0
- package/dist/core/tool-roster.d.ts +112 -5
- package/dist/core/tool-roster.js +42 -1
- package/dist/core/tool-spec.d.ts +3 -1
- package/dist/core/types.d.ts +2 -2
- package/dist/core/types.js +1 -1
- package/dist/core/user-attachment.js +1 -1
- package/dist/core/wiring-manifest.d.ts +6 -3
- package/dist/engine/compaction/compaction.js +29 -3
- package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
- package/dist/engine/execution-env/node-execution-env.js +9 -12
- package/dist/engine/harness/agent-harness.d.ts +25 -2
- package/dist/engine/harness/agent-harness.js +41 -12
- package/dist/engine/harness/messages.d.ts +3 -1
- package/dist/engine/harness/messages.js +3 -2
- package/dist/engine/harness/types.d.ts +8 -0
- package/dist/engine/llm/rejected-images.d.ts +46 -0
- package/dist/engine/llm/rejected-images.js +54 -0
- package/dist/engine/llm/tool-turns.d.ts +2 -1
- package/dist/engine/llm/types.d.ts +18 -7
- package/dist/engine/loop/agent-loop.d.ts +8 -0
- package/dist/engine/loop/agent-loop.js +52 -15
- package/dist/engine/loop/types.d.ts +3 -1
- package/dist/engine/session/path-to-root.d.ts +38 -0
- package/dist/engine/session/path-to-root.js +39 -0
- package/dist/engine/session/storage-base.js +4 -21
- package/dist/index.d.ts +16 -10
- package/dist/index.js +11 -7
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +1 -0
- package/dist/internal/llm.d.ts +1 -0
- package/dist/orchestration/workflow-observe.d.ts +17 -1
- package/dist/orchestration/workflow-observe.js +20 -0
- package/dist/orchestration/workflow-types.d.ts +32 -7
- package/dist/orchestration/workflow.js +739 -489
- package/dist/shell/counting-pass.d.ts +50 -0
- package/dist/shell/counting-pass.js +502 -0
- package/dist/shell/lex.d.ts +4 -2
- package/dist/shell/lex.js +93 -34
- package/dist/shell/shell-words.d.ts +1 -1
- package/dist/shell/shell-words.js +7 -6
- package/dist/stores/file/mailbox-store.js +6 -10
- package/dist/tools/fs/fs-bash.d.ts +6 -0
- package/dist/tools/fs/fs-bash.js +6 -3
- package/dist/tools/fs/index.js +6 -2
- package/dist/tools/fs/program-read-model.d.ts +13 -0
- package/dist/tools/fs/program-read-model.js +15 -0
- package/dist/tools/fs/program-read-model.rows.js +1 -1
- package/dist/tools/fs/read-deny.d.ts +13 -10
- package/dist/tools/fs/read-deny.js +25 -5
- package/dist/tools/fs/read-floor.d.ts +19 -0
- package/dist/tools/fs/read-floor.js +23 -0
- package/dist/tools/fs/shell-read-check.d.ts +1 -1
- package/dist/tools/fs/shell-read-check.js +2 -1
- package/dist/tools/fs/shell-read-judge.d.ts +16 -8
- package/dist/tools/fs/shell-read-judge.js +10 -6
- package/dist/tools/fs/shell-read-plan.d.ts +6 -1
- package/dist/tools/fs/shell-read-plan.js +22 -15
- package/dist/tools/fs/shell-read-start.js +1 -0
- package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
- package/dist/tools/fs/shell-reentry-text.js +25 -3
- package/dist/tools/monitor.d.ts +4 -0
- package/dist/tools/monitor.js +2 -0
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +87 -1
- package/wire-changes/core-stores-sql@7.59.0.json +29 -0
- package/wire-changes/core@7.59.0.json +2459 -0
- package/wire-changes/mods-kernel@7.59.0.json +29 -0
- package/wire-changes/primitives@7.59.0.json +29 -0
|
@@ -584,7 +584,8 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
584
584
|
if (caught !== undefined && "answer" in caught) {
|
|
585
585
|
if (failure.cause !== "violation" && failure.cause !== "reentry")
|
|
586
586
|
report(new Error(`${name}: ${event}: ${failure.reason}; its .catch answered`));
|
|
587
|
-
producers.
|
|
587
|
+
if (!(typeof caught.answer === "object" && caught.answer !== null && producers.has(caught.answer)))
|
|
588
|
+
producers.set(caught.answer, name);
|
|
588
589
|
traceOf(sink, i, name, h.reg.tier, "caught", ms);
|
|
589
590
|
return caught.answer;
|
|
590
591
|
}
|
|
@@ -25,8 +25,9 @@
|
|
|
25
25
|
* changed pinned key is), `tool.call` takes one member more than its own — `requestMeta`, a record of strings, judged there —
|
|
26
26
|
* and an admission record carries the registration's `provenance` as the host gave it and lists in `observe` only the patterns
|
|
27
27
|
* on which every handler it hung watches.
|
|
28
|
+
* 5: `classic.SubagentStart` has a station (a delegated leg's opening event).
|
|
28
29
|
*/
|
|
29
|
-
export declare const KERNEL_CONTRACT_VERSION =
|
|
30
|
+
export declare const KERNEL_CONTRACT_VERSION = 5;
|
|
30
31
|
/** The five tiers in run order (CC names). `builtin` and `core` are the engine's own. */
|
|
31
32
|
export declare const MOD_TIERS: readonly ["prepend", "user", "append", "builtin", "core"];
|
|
32
33
|
export type ModTier = (typeof MOD_TIERS)[number];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const KERNEL_CONTRACT_VERSION =
|
|
1
|
+
export const KERNEL_CONTRACT_VERSION = 5;
|
|
2
2
|
export const MOD_TIERS = Object.freeze(["prepend", "user", "append", "builtin", "core"]);
|
|
3
3
|
export const MOD_SEATS = Object.freeze(["deployment", "task"]);
|
|
4
4
|
export const MOD_EVENT_SIDES = Object.freeze(["engine", "surface", "both"]);
|
|
@@ -55,7 +55,7 @@ export const MOD_EVENT_TABLE = Object.freeze({
|
|
|
55
55
|
"classic.SessionEnd": engine(),
|
|
56
56
|
"classic.Stop": engine(station("skip", "immediate")),
|
|
57
57
|
"classic.StopFailure": engine(station("skip", "grace")),
|
|
58
|
-
"classic.SubagentStart": engine(),
|
|
58
|
+
"classic.SubagentStart": engine(station("skip", "immediate", ["agentId", "agentType"])),
|
|
59
59
|
"classic.SubagentStop": engine(station("skip", "immediate")),
|
|
60
60
|
"classic.PreCompact": engine(station("skip", "grace")),
|
|
61
61
|
"classic.PostCompact": engine(station("skip", "grace")),
|
|
@@ -23,6 +23,10 @@ export interface ModOrigin {
|
|
|
23
23
|
}
|
|
24
24
|
/** The engine's own origin; its `plugin` word is reserved (no registration may take it). */
|
|
25
25
|
export declare const ENGINE_ORIGIN: ModOrigin;
|
|
26
|
+
/** The extension a refusal names: the registration's own name — never the engine's origin word (a raise the engine could not run
|
|
27
|
+
* names no extension), never an absent one. The one reading of "who refused" for every station that refuses a call at the hook
|
|
28
|
+
* layer (`GateDisposition.extension`). Module-level: not part of the kernel's entry. */
|
|
29
|
+
export declare function namedRegistration(registration: string | undefined): string | undefined;
|
|
26
30
|
/** The facts `$.plugin` carries. */
|
|
27
31
|
export interface ModPluginFacts {
|
|
28
32
|
readonly name: string;
|
|
@@ -3,6 +3,9 @@ import { resolveModBudgetMs } from "./budget.js";
|
|
|
3
3
|
export const MODS_INVALID_CODE = "config.mods_invalid";
|
|
4
4
|
export const MODS_REGISTRATION_REFUSED_CODE = "mods.registration_refused";
|
|
5
5
|
export const ENGINE_ORIGIN = Object.freeze({ plugin: "engine", tier: "core" });
|
|
6
|
+
export function namedRegistration(registration) {
|
|
7
|
+
return registration === undefined || registration === ENGINE_ORIGIN.plugin ? undefined : registration;
|
|
8
|
+
}
|
|
6
9
|
export const MOD_TRACE_OUTCOMES = Object.freeze(["returned", "passed", "rejected", "caught", "expired", "kept", "skipped", "bypassed"]);
|
|
7
10
|
export function modsInvalid(message) {
|
|
8
11
|
return Object.assign(new Error(message), { code: MODS_INVALID_CODE });
|
|
@@ -2,7 +2,7 @@ import type { ExecutionEnv } from "../../internal/harness-types.js";
|
|
|
2
2
|
import type { AssistantMessage, Message, Model, Usage } from "../../internal/llm.js";
|
|
3
3
|
import type { CwdRef } from "../../tools/fs/fs-shared.js";
|
|
4
4
|
import { type PermissionResult, type ToolCallRequest } from "../tool-policy.js";
|
|
5
|
-
import type { ClassicEventBase, HookInvocationIdentity, PermissionDeniedPayload, UserPromptSubmitEvent } from "../hooks.js";
|
|
5
|
+
import type { ClassicEventBase, HookInvocationIdentity, PermissionDeniedPayload, SubagentStartResult, UserPromptSubmitEvent } from "../hooks.js";
|
|
6
6
|
import type { ClassicEventMap, ClassicEventName } from "./classic-events.js";
|
|
7
7
|
import type { PermissionMode } from "../ask-origin.js";
|
|
8
8
|
import type { RunnerDeps } from "../runner-deps.js";
|
|
@@ -29,12 +29,23 @@ export type LegModBus = Pick<ModBus, "hasHandlers" | "dispatch">;
|
|
|
29
29
|
* and its parent's fleet row use). A top-level leg carries none.
|
|
30
30
|
*/
|
|
31
31
|
export declare function agentIdOf(identity: HookInvocationIdentity | undefined): string | undefined;
|
|
32
|
+
export interface LegEvents {
|
|
33
|
+
/** The person's-prompt screen its objective passes — present when a person wrote the objective. */
|
|
34
|
+
readonly screen?: "classic.UserPromptSubmit";
|
|
35
|
+
/** The event it opens on — present on a delegated leg. */
|
|
36
|
+
readonly start?: "classic.SubagentStart";
|
|
37
|
+
/** The event it raises when it would otherwise end. */
|
|
38
|
+
readonly stop: "classic.Stop" | "classic.SubagentStop";
|
|
39
|
+
}
|
|
32
40
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* leg's
|
|
41
|
+
* Both ends of a leg. The delegation fact alone picks the lifecycle (a child resumed from its checkpoint keeps it): a
|
|
42
|
+
* delegated leg opens on `classic.SubagentStart` and ends on `classic.SubagentStop`, any other on nothing and
|
|
43
|
+
* `classic.Stop`. Who wrote the objective picks the screen: a top-level leg's objective is a person's prompt, and so is
|
|
44
|
+
* a delegated leg's that carries an operator's words (`operatorObjective`, the trusted resume fact) — both pass
|
|
45
|
+
* `classic.UserPromptSubmit`; any other delegated objective is its delegator's (a parent model, a workflow script, a
|
|
46
|
+
* peer) and is judged at the delegator's gate. Not the leg kind: a resumed leg's kind reads `"resume"` whoever it runs as.
|
|
36
47
|
*/
|
|
37
|
-
export declare function
|
|
48
|
+
export declare function legEventsOf(identity: Pick<HookInvocationIdentity, "isDelegatedChild"> | undefined, operatorObjective?: boolean): LegEvents;
|
|
38
49
|
/**
|
|
39
50
|
* The args as a judging handler receives them: the gate pass's own immutable value ({@link ownArgs} — the value itself when
|
|
40
51
|
* the gate already took it, which is every call the gate raises an event over), so the bytes a handler judges are the bytes
|
|
@@ -66,10 +77,13 @@ export declare function sameModChain(a: readonly ModChainLink[], b: readonly Mod
|
|
|
66
77
|
* screening constraint, and what a child's own gate stands in for when it mounted the same.
|
|
67
78
|
*/
|
|
68
79
|
export declare function chainJudges(bus: LegModBus): boolean;
|
|
69
|
-
/**
|
|
70
|
-
export declare function
|
|
71
|
-
/** The
|
|
72
|
-
|
|
80
|
+
/** Give a minted screening `policy` its installation — own, fixed and not enumerable, the object held in a closure no clone can re-point, so a copy or a wrapper of the policy carries none. Written only by the constraint mint (`createPreToolUseConstraintPolicy`). */
|
|
81
|
+
export declare function withInstallation<P extends object>(policy: P, bus: LegModBus): P;
|
|
82
|
+
/** The installation an inherited entry carries (its policy's own member, read off the descriptor: no getter or trap runs, and a
|
|
83
|
+
* member minted on another object is not this one's), or `undefined` when the mint did not make the entry's policy. */
|
|
84
|
+
export declare function installationOf(pc: {
|
|
85
|
+
readonly policy: object;
|
|
86
|
+
}): LegModBus | undefined;
|
|
73
87
|
/** How an inherited installation's question is settled: under the context its installation froze (its approver, its durable
|
|
74
88
|
* mandates, its classifier — the settlement its `classic.PreToolUse` ask takes in the fold), never at this leg's approver. An
|
|
75
89
|
* allow carrying `updatedInput` is a person's approval of an edit; an ask is one the settlement floated (the call is marked for
|
|
@@ -108,7 +122,7 @@ export interface LegInstallation {
|
|
|
108
122
|
}
|
|
109
123
|
/**
|
|
110
124
|
* Whether an inherited entry IS a leg's installation — the ONE installation identity. The chain is read off the entry's own
|
|
111
|
-
* bus (
|
|
125
|
+
* bus ({@link installationOf}, as that bus's admission recorded it), never off a list the entry carries: an entry
|
|
112
126
|
* whose policy the mint did not make, or whose bus no engine admission mounted, is no leg's installation. The rest is the
|
|
113
127
|
* context its questions are settled in: the same approver ({@link askApproverIdentity}), the same two durable mandates, the
|
|
114
128
|
* same environment, the same classifier instance. Readers: chain assembly (a leg already on the chain is not appended again)
|
|
@@ -211,6 +225,13 @@ export type PromptScreen = {
|
|
|
211
225
|
* a cancelled screen ends `aborted` at once. A dispatch the engine itself could not run is `failed` too.
|
|
212
226
|
*/
|
|
213
227
|
export declare function screenUserPrompt(bus: LegModBus, e: UserPromptSubmitEvent, signal: AbortSignal | undefined): Promise<PromptScreen | undefined>;
|
|
228
|
+
/**
|
|
229
|
+
* Raise `classic.SubagentStart` as a delegated leg opens on its objective (undefined when no handler hangs on it): the
|
|
230
|
+
* context the chain answers. It never keeps the child from starting — a handler that fails is skipped and reported by
|
|
231
|
+
* the bus, a cancel ends the wait at once (the leg's own cancel then ends the child), and a dispatch the engine itself
|
|
232
|
+
* could not run is no answer.
|
|
233
|
+
*/
|
|
234
|
+
export declare function openSubagent(bus: LegModBus, identity: HookInvocationIdentity, permissionMode: PermissionMode | undefined, signal: AbortSignal | undefined): Promise<SubagentStartResult | undefined>;
|
|
214
235
|
/** The three words a `tool.check` verdict speaks. */
|
|
215
236
|
export declare const TOOL_CHECK_DECISIONS: readonly ["allow", "ask", "deny"];
|
|
216
237
|
export type ToolCheckDecision = (typeof TOOL_CHECK_DECISIONS)[number];
|
|
@@ -20,8 +20,13 @@ export function engineCore() {
|
|
|
20
20
|
export function agentIdOf(identity) {
|
|
21
21
|
return identity?.isDelegatedChild === true ? identity.taskId : undefined;
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const PERSON_LEG = Object.freeze({ screen: "classic.UserPromptSubmit", stop: "classic.Stop" });
|
|
24
|
+
const DELEGATED_LEG = Object.freeze({ start: "classic.SubagentStart", stop: "classic.SubagentStop" });
|
|
25
|
+
const OPERATOR_RESUMED_LEG = Object.freeze({ screen: "classic.UserPromptSubmit", start: "classic.SubagentStart", stop: "classic.SubagentStop" });
|
|
26
|
+
export function legEventsOf(identity, operatorObjective = false) {
|
|
27
|
+
if (identity?.isDelegatedChild !== true)
|
|
28
|
+
return PERSON_LEG;
|
|
29
|
+
return operatorObjective ? OPERATOR_RESUMED_LEG : DELEGATED_LEG;
|
|
25
30
|
}
|
|
26
31
|
export function judgedInputOf(args) {
|
|
27
32
|
const owned = ownArgs(args);
|
|
@@ -69,15 +74,19 @@ const judgesCall = (p) => !p.observe;
|
|
|
69
74
|
export function chainJudges(bus) {
|
|
70
75
|
return bus.hasHandlers("classic.PreToolUse", judgesCall) || bus.hasHandlers("tool.check", judgesCall);
|
|
71
76
|
}
|
|
72
|
-
const
|
|
73
|
-
export function
|
|
74
|
-
|
|
77
|
+
const INSTALLATION = Symbol("installation");
|
|
78
|
+
export function withInstallation(policy, bus) {
|
|
79
|
+
return Object.defineProperty(policy, INSTALLATION, { value: Object.freeze({ bus, mintedAs: (o) => o === policy }) });
|
|
75
80
|
}
|
|
76
|
-
export function
|
|
77
|
-
|
|
81
|
+
export function installationOf(pc) {
|
|
82
|
+
const p = pc.policy;
|
|
83
|
+
if (p === null || p === undefined || types.isProxy(p))
|
|
84
|
+
return undefined;
|
|
85
|
+
const minted = Object.getOwnPropertyDescriptor(p, INSTALLATION)?.value;
|
|
86
|
+
return minted !== undefined && minted.mintedAs(p) ? minted.bus : undefined;
|
|
78
87
|
}
|
|
79
88
|
export function sameInstallation(pc, leg) {
|
|
80
|
-
const bus =
|
|
89
|
+
const bus = installationOf(pc);
|
|
81
90
|
const chain = bus !== undefined ? chainOfBus(bus) : undefined;
|
|
82
91
|
return (chain !== undefined &&
|
|
83
92
|
sameModChain(chain, leg.chain) &&
|
|
@@ -96,7 +105,7 @@ const judgesToolCheck = (h) => {
|
|
|
96
105
|
};
|
|
97
106
|
export function screeningInstallationsOf(entries) {
|
|
98
107
|
return entries.flatMap((pc) => {
|
|
99
|
-
const bus =
|
|
108
|
+
const bus = installationOf(pc);
|
|
100
109
|
return bus !== undefined || pc.mods !== undefined ? [{ bus, chain: pc.mods }] : [];
|
|
101
110
|
});
|
|
102
111
|
}
|
|
@@ -111,7 +120,7 @@ export function inheritedToolChecks(entries, standsIn, settleOf) {
|
|
|
111
120
|
throw modsInvalid(unraisable);
|
|
112
121
|
const checks = [];
|
|
113
122
|
for (const pc of entries) {
|
|
114
|
-
const bus =
|
|
123
|
+
const bus = installationOf(pc);
|
|
115
124
|
if (bus === undefined || standsIn(pc) || !bus.hasHandlers("tool.check", judges))
|
|
116
125
|
continue;
|
|
117
126
|
checks.push(Object.freeze({ bus, judges, settle: settleOf(pc) }));
|
|
@@ -218,6 +227,31 @@ export async function screenUserPrompt(bus, e, signal) {
|
|
|
218
227
|
return outcome;
|
|
219
228
|
return { kind: "answered", ...stringMembersOf(outcome.answer, ["block", "additionalContext"]) };
|
|
220
229
|
}
|
|
230
|
+
const subagentStartMembers = stringMembersAnswer("classic.SubagentStart", ["additionalContext"]);
|
|
231
|
+
function subagentStartAnswer(answer) {
|
|
232
|
+
const refused = subagentStartMembers(answer);
|
|
233
|
+
if (refused !== undefined)
|
|
234
|
+
return refused;
|
|
235
|
+
if (typeof answer === "object" && answer !== null && Reflect.get(answer, "block") !== undefined) {
|
|
236
|
+
return `answered "block"; classic.SubagentStart cannot keep a subagent from starting (it starts all the same) — a deployment refuses the delegating call at classic.PreToolUse`;
|
|
237
|
+
}
|
|
238
|
+
return undefined;
|
|
239
|
+
}
|
|
240
|
+
export async function openSubagent(bus, identity, permissionMode, signal) {
|
|
241
|
+
const e = {
|
|
242
|
+
...classicEventBase(identity, permissionMode),
|
|
243
|
+
agentId: identity.taskId,
|
|
244
|
+
...(identity.agentType !== undefined ? { agentType: identity.agentType } : {}),
|
|
245
|
+
};
|
|
246
|
+
let outcome;
|
|
247
|
+
try {
|
|
248
|
+
outcome = await dispatchClassic(bus, "classic.SubagentStart", e, { ...(signal !== undefined ? { signal } : {}), checkAnswer: subagentStartAnswer });
|
|
249
|
+
}
|
|
250
|
+
catch {
|
|
251
|
+
return undefined;
|
|
252
|
+
}
|
|
253
|
+
return outcome?.kind === "answered" ? stringMembersOf(outcome.answer, ["additionalContext"]) : undefined;
|
|
254
|
+
}
|
|
221
255
|
export const TOOL_CHECK_DECISIONS = Object.freeze(["allow", "ask", "deny"]);
|
|
222
256
|
const isToolCheckDecision = (v) => TOOL_CHECK_DECISIONS.some((d) => d === v);
|
|
223
257
|
const TOOL_CHECK_RANKS = Object.freeze({
|
|
@@ -51,7 +51,7 @@ export function createToolCallStation(input) {
|
|
|
51
51
|
return undefined;
|
|
52
52
|
const refusal = (call, by, text) => {
|
|
53
53
|
if (input.occurrences.get(call.toolCallId) !== undefined) {
|
|
54
|
-
input.occurrences.refuse(call.toolCallId, "hook");
|
|
54
|
+
input.occurrences.refuse(call.toolCallId, "hook", by);
|
|
55
55
|
input.occurrences.answeredInPlace(call.toolCallId, by);
|
|
56
56
|
}
|
|
57
57
|
input.blockedToolCalls.add(call.toolCallId);
|
|
@@ -14,7 +14,7 @@ import type { EngineDollar } from "./mods/dollar.js";
|
|
|
14
14
|
import type { ToolExecuteContext } from "./tool-spec.js";
|
|
15
15
|
import type { TaskSpec } from "./types.js";
|
|
16
16
|
/** The fields of a spec the seat carries — one `Pick`, shared by the mint's input and the apply's target. */
|
|
17
|
-
export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "oneShot" | "clientContext" | "onQuestion" | "mods" | "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "memoryPersistenceCapable" | "memory" | "compaction" | "skillListingBudgetFraction" | "skillListingMaxDescChars" | "fileHistory" | "projectMemory" | "promptForm" | "promptBinding" | "advisorModel" | "attachments">;
|
|
17
|
+
export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "oneShot" | "clientContext" | "onQuestion" | "mods" | "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "memoryPersistenceCapable" | "classifyAllShell" | "memory" | "compaction" | "skillListingBudgetFraction" | "skillListingMaxDescChars" | "fileHistory" | "projectMemory" | "promptForm" | "promptBinding" | "advisorModel" | "attachments">;
|
|
18
18
|
/**
|
|
19
19
|
* The seat a run hands its children. Every member is the parent's own value, frozen at mint (arrays copied and
|
|
20
20
|
* frozen; the facts object copied). Members present iff the parent carries them — an absent member is "nothing to
|
|
@@ -35,6 +35,9 @@ export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "oneShot" | "cli
|
|
|
35
35
|
* · `envFacts` — the sandbox facts (profile / egress / scratchpad).
|
|
36
36
|
* · `memoryPersistenceCapable` — the deployment's DECLARED persistence statement: `false` is a REMOVAL (floor),
|
|
37
37
|
* `true` a default a child's own declaration may narrow.
|
|
38
|
+
* · `classifyAllShell` — the request's "no shell allow entry clears a call in `auto`" declaration: only `true` travels and
|
|
39
|
+
* it is a REMOVAL (the child's shell allow entries stand down in `auto` as the parent's did; a child's own `false` cannot
|
|
40
|
+
* lift it).
|
|
38
41
|
* · `memory` — the request-level "memory is off" FACT, `{ enabled: false }` and nothing else of the declaration (the clamp
|
|
39
42
|
* table's `memory.enabled` row; present only when the parent stated `enabled: false`): a REMOVAL (floor) that
|
|
40
43
|
* REWRITES the one member on the child's own memory declaration — its scopes and knobs are the child's.
|
|
@@ -75,6 +78,7 @@ export interface ParentSpecSeat {
|
|
|
75
78
|
readonly additionalReadDirectories?: readonly string[];
|
|
76
79
|
readonly envFacts?: TaskSpec["envFacts"];
|
|
77
80
|
readonly memoryPersistenceCapable?: boolean;
|
|
81
|
+
readonly classifyAllShell?: true;
|
|
78
82
|
readonly memory?: {
|
|
79
83
|
readonly enabled: false;
|
|
80
84
|
};
|
|
@@ -96,8 +100,9 @@ export declare function assertParentSpecSeatCurrent(seat: object | undefined): v
|
|
|
96
100
|
export declare function parentSpecSeatOf(spec: Omit<ParentSpecSeatFields, "onQuestion">, frozenOnQuestion: OnQuestion | undefined): ParentSpecSeat;
|
|
97
101
|
/**
|
|
98
102
|
* Apply the seat to a child spec — ONE law for every member, both lanes:
|
|
99
|
-
* a value the child spec already carries WINS; the seat FILLS an unset one; the
|
|
100
|
-
* (`oneShot: true`, `memoryPersistenceCapable: false`, `memory: { enabled: false }`) land
|
|
103
|
+
* a value the child spec already carries WINS; the seat FILLS an unset one; the four REMOVAL values
|
|
104
|
+
* (`oneShot: true`, `memoryPersistenceCapable: false`, `classifyAllShell: true`, `memory: { enabled: false }`) land
|
|
105
|
+
* UNCONDITIONALLY.
|
|
101
106
|
* "Already carries" is the child's own authorship — a deployment baseline, a trusted script, an agent definition's
|
|
102
107
|
* fold (the Task lane folds the definition's `memoryPersistenceCapable` before applying; the workflow lane applies at
|
|
103
108
|
* the launch site AFTER the agentType fold) — so a definition may narrow a parent `true` to `false`, a baseline-pinned
|
|
@@ -18,6 +18,7 @@ export function parentSpecSeatOf(spec, frozenOnQuestion) {
|
|
|
18
18
|
...(spec.additionalReadDirectories !== undefined ? { additionalReadDirectories: Object.freeze([...spec.additionalReadDirectories]) } : {}),
|
|
19
19
|
...(spec.envFacts !== undefined ? { envFacts: Object.freeze({ ...spec.envFacts }) } : {}),
|
|
20
20
|
...(spec.memoryPersistenceCapable !== undefined ? { memoryPersistenceCapable: spec.memoryPersistenceCapable } : {}),
|
|
21
|
+
...(spec.classifyAllShell === true ? { classifyAllShell: true } : {}),
|
|
21
22
|
...(spec.compaction !== undefined ? { compaction: Object.freeze({ ...spec.compaction }) } : {}),
|
|
22
23
|
...(spec.skillListingBudgetFraction !== undefined ? { skillListingBudgetFraction: spec.skillListingBudgetFraction } : {}),
|
|
23
24
|
...(spec.skillListingMaxDescChars !== undefined ? { skillListingMaxDescChars: spec.skillListingMaxDescChars } : {}),
|
|
@@ -54,6 +55,7 @@ export function applyParentSpecSeat(child, seat) {
|
|
|
54
55
|
...fill("advisorModel", seat.advisorModel),
|
|
55
56
|
...fill("attachments", (seat.attachments !== undefined ? { ...seat.attachments } : undefined)),
|
|
56
57
|
...(seat.oneShot === true ? { oneShot: true } : {}),
|
|
58
|
+
...(seat.classifyAllShell === true ? { classifyAllShell: true } : {}),
|
|
57
59
|
...(seat.memoryPersistenceCapable === false ? { memoryPersistenceCapable: false } : fill("memoryPersistenceCapable", seat.memoryPersistenceCapable)),
|
|
58
60
|
};
|
|
59
61
|
return applyClampSeats(landed, clampFieldSeatsOf(seat));
|
|
@@ -81,6 +81,12 @@ function syntheticCheckpoint(scope, fidelity) {
|
|
|
81
81
|
askClass: "denial_limit_fallback",
|
|
82
82
|
classes: ["denial_limit_fallback"],
|
|
83
83
|
engineMounted: true,
|
|
84
|
+
capabilityId: "0123456789abcdef",
|
|
85
|
+
contractId: "core.selfcheck@1",
|
|
86
|
+
shapeDigest: "fedcba9876543210",
|
|
87
|
+
implementationRevision: "1",
|
|
88
|
+
family: "other",
|
|
89
|
+
declarationDigest: "d".repeat(64),
|
|
84
90
|
targets: { protective: "/park-selfcheck/target", declared: null },
|
|
85
91
|
targetReads: { ["0".repeat(64)]: "f".repeat(64) },
|
|
86
92
|
batchToolCallIds: [`${scope}:call`],
|
package/dist/core/peer-seat.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { StreamableHTTPError } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
1
2
|
import { type CredentialRef } from "@sema-agent/primitives";
|
|
2
3
|
import type { McpServerSpec } from "./mcp-server-spec.js";
|
|
3
4
|
import type { ProtocolId } from "./protocol-table.js";
|
|
@@ -64,11 +65,31 @@ export declare const PEER_ANSWER_LANES: Readonly<{
|
|
|
64
65
|
export type PeerLane = keyof typeof PEER_ANSWER_LANES;
|
|
65
66
|
/** How long one ask may take before the send goes without it (`credential_unavailable`). */
|
|
66
67
|
export declare const PEER_SEAT_WAIT_MS = 30000;
|
|
68
|
+
/** The longest URL an authorization record keeps (the seat's `authorizeUrl`, the endpoint's `resource_metadata`). */
|
|
69
|
+
export declare const AUTHORIZATION_URL_MAX = 2048;
|
|
70
|
+
/**
|
|
71
|
+
* The one URL law of the authorization record (`McpAuthorization`, mcp-failure.ts): an absolute http(s) URL with no user-info, within
|
|
72
|
+
* {@link AUTHORIZATION_URL_MAX} code units, as the URL parser serializes it with every markup-significant character after the host
|
|
73
|
+
* (brackets, parentheses, angle brackets, quotes, backtick, braces, pipe, caret, backslash) percent-encoded — so the text a model or a
|
|
74
|
+
* host renders is one plain link — else
|
|
75
|
+
* `undefined`. A string carrying a control character is refused before parsing (the parser would silently drop a tab or a line break
|
|
76
|
+
* and keep the rest).
|
|
77
|
+
*/
|
|
78
|
+
export declare function authorizationUrlOf(raw: unknown): string | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* The `Bearer` challenge's auth-params in a `WWW-Authenticate` value (RFC 7235 §4.1: a comma-separated list of challenges, each a
|
|
81
|
+
* scheme and its `name=value` params, a value a token or a quoted string) — names lower-cased, the first of a repeated name kept — or
|
|
82
|
+
* `undefined` when no Bearer challenge is there. A param belongs to the challenge it follows, so `not_error=…`, an `error=` inside a
|
|
83
|
+
* quoted description and another scheme's params are never the Bearer `error`. A malformed character is stepped over.
|
|
84
|
+
*/
|
|
85
|
+
export declare function bearerChallengeParams(header: string | null): ReadonlyMap<string, string> | undefined;
|
|
67
86
|
/** Why a send went without its pieces. */
|
|
68
87
|
export type PeerSeatFailureReason = "threw" | "timed_out" | "answer_invalid" | "unauthorized";
|
|
69
88
|
/**
|
|
70
89
|
* A send the seat did not furnish: nothing was sent. The text names the peer and the reason, never a value and never the seat's own
|
|
71
|
-
* error text (deployment code may put a credential in it); `authorizeUrl` is the seat's own, when it answered `unauthorized
|
|
90
|
+
* error text (deployment code may put a credential in it); `authorizeUrl` is the seat's own, when it answered `unauthorized` (read by
|
|
91
|
+
* {@link authorizationUrlOf}). An MCP failure reads `reason: "unauthorized"` as `unauthorized` (reason `none`), every other reason as
|
|
92
|
+
* `credential_unavailable` (mcp-failure.ts).
|
|
72
93
|
*/
|
|
73
94
|
export declare class PeerSeatFailure extends Error {
|
|
74
95
|
readonly reason: PeerSeatFailureReason;
|
|
@@ -81,6 +102,37 @@ export declare class PeerSeatFailure extends Error {
|
|
|
81
102
|
code?: string;
|
|
82
103
|
});
|
|
83
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* An MCP HTTP request the endpoint refused for its authorization — a 401, or a 403 whose Bearer challenge says `insufficient_scope`
|
|
107
|
+
* (RFC 6750 §3.1) — raised by the one fetch ({@link peerFetch}) in place of the SDK's status error, which keeps no header. It IS the
|
|
108
|
+
* SDK's status error (same class, same `code`), so every structural reader of a status reads it unchanged; it adds what the response
|
|
109
|
+
* said and what the re-ask after a 401 answered:
|
|
110
|
+
* · `reason` — `rejected` (401) or `scope` (403);
|
|
111
|
+
* · `resourceMetadataUrl` — the Bearer challenge's `resource_metadata` ({@link bearerChallengeParams}), the REMOTE's claim, read by
|
|
112
|
+
* {@link authorizationUrlOf};
|
|
113
|
+
* · `authorizeUrl` — the seat's, when it answered the re-ask after a 401 `unauthorized`;
|
|
114
|
+
* · `renewed` — the re-ask after a 401 answered pieces other than the refused send's: a credential this server has not refused yet
|
|
115
|
+
* exists, and a new send carries it (the call layer sends a repeat-safe call again on it). It is NOT "the user owes nothing": a seat
|
|
116
|
+
* that mints a fresh assertion on every ask renews every time, so only a refusal of the credential it renewed to says more.
|
|
117
|
+
* The text is the engine's sentence followed by the response body as the SDK's own error would have carried it (bounded to
|
|
118
|
+
* {@link REFUSAL_BODY_MAX} characters) — REMOTE text, read by every face through the one remote-words reading like any status body.
|
|
119
|
+
*/
|
|
120
|
+
export declare class PeerAuthorizationRefused extends StreamableHTTPError {
|
|
121
|
+
readonly reason: "rejected" | "scope";
|
|
122
|
+
readonly resourceMetadataUrl: string | undefined;
|
|
123
|
+
readonly authorizeUrl: string | undefined;
|
|
124
|
+
readonly renewed: boolean;
|
|
125
|
+
constructor(reason: "rejected" | "scope", facts: {
|
|
126
|
+
resourceMetadataUrl?: string;
|
|
127
|
+
authorizeUrl?: string;
|
|
128
|
+
renewed?: boolean;
|
|
129
|
+
body?: string;
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/** How much of a refusal's response body its text keeps. */
|
|
133
|
+
export declare const REFUSAL_BODY_MAX = 4096;
|
|
134
|
+
/** Whether a failure is an authorization refusal after which the deployment furnished a fresh credential ({@link PeerAuthorizationRefused.renewed}). */
|
|
135
|
+
export declare function refusedThenRenewed(err: unknown): boolean;
|
|
84
136
|
/** What one send carries, as the engine took it from an answer, and its digest (whether a re-ask changed anything). */
|
|
85
137
|
export interface CarriedPieces {
|
|
86
138
|
readonly headers?: Readonly<Record<string, string>>;
|
|
@@ -98,6 +150,11 @@ export declare function readPeerAnswer(raw: unknown, lane: PeerLane): {
|
|
|
98
150
|
} | {
|
|
99
151
|
readonly problem: string;
|
|
100
152
|
};
|
|
153
|
+
/** What the re-ask after a 401 said: whether it answered other pieces than the refused send carried, and the seat's `authorizeUrl` when it answered `unauthorized`. */
|
|
154
|
+
export interface PeerReask {
|
|
155
|
+
readonly renewed: boolean;
|
|
156
|
+
readonly authorizeUrl?: string;
|
|
157
|
+
}
|
|
101
158
|
/**
|
|
102
159
|
* One connection's (or one A2A peer's) asks of the seat. `next` answers each send: a 401's re-ask answer when one is waiting (carried
|
|
103
160
|
* once), else the seat's answer to this send. `rejected` is the one re-ask after a 401 (concurrent rejections share it); `renewed` says
|
|
@@ -124,8 +181,10 @@ export declare class PeerCarrier {
|
|
|
124
181
|
/** The pieces the latest send carried (`undefined` before the first). */
|
|
125
182
|
last: CarriedPieces | undefined;
|
|
126
183
|
/** A send that carried `carried` was answered 401: ask once more (`rejected`); the next send carries that answer. Never throws —
|
|
127
|
-
* a re-ask that fails leaves `renewed` false, so the 401 is the call's answer, and the next send asks afresh.
|
|
128
|
-
|
|
184
|
+
* a re-ask that fails leaves `renewed` false, so the 401 is the call's answer, and the next send asks afresh. Resolves to what the
|
|
185
|
+
* re-ask said (concurrent rejections share one flight and its answer): whether it renewed, and the seat's `authorizeUrl` when it
|
|
186
|
+
* answered `unauthorized`. */
|
|
187
|
+
rejected(carried: CarriedPieces, signal?: AbortSignal, destination?: string): Promise<PeerReask>;
|
|
129
188
|
/** Whether the pieces a stdio child was started with have stopped being good. */
|
|
130
189
|
expired(now?: number): boolean;
|
|
131
190
|
private ask;
|
|
@@ -140,7 +199,9 @@ export declare function carriedHttpHeaders(protocol: ProtocolId, carrier: PeerCa
|
|
|
140
199
|
/**
|
|
141
200
|
* The MCP HTTP transport's `fetch` under the seat: every request the transport makes (the POST, the SSE GET, the DELETE) asks the
|
|
142
201
|
* carrier first, carries what it answered, goes only to the endpoint the declaration named (no redirect is followed — a 3xx is the
|
|
143
|
-
* answer) and, answered 401, has the carrier ask once more for the next send.
|
|
202
|
+
* answer) and, answered 401, has the carrier ask once more for the next send. A refusal of the authorization — 401, or 403 whose
|
|
203
|
+
* challenge says `insufficient_scope` — is raised here as {@link PeerAuthorizationRefused} carrying the challenge, the re-ask's answer
|
|
204
|
+
* and the bounded body (the SDK would raise its status error from the same response with no header kept).
|
|
144
205
|
*/
|
|
145
206
|
export declare function peerFetch(carrier: PeerCarrier, principalHeader: string | undefined, principal: string | undefined): typeof fetch;
|
|
146
207
|
/** The member of a declaration that would carry a value (retired: values come from the seat). */
|
|
@@ -175,11 +236,12 @@ export declare class Reauthorized {
|
|
|
175
236
|
constructor(error: unknown);
|
|
176
237
|
}
|
|
177
238
|
/**
|
|
178
|
-
* The call layer's one re-send after a 401: `attempt` once; when it answers {@link Reauthorized} and `mayResend`
|
|
179
|
-
* (the revocation probe and `reach`, asked again) holds, once more, carrying what the re-ask answered
|
|
180
|
-
*
|
|
239
|
+
* The call layer's one re-send after a 401: `attempt(false)` once; when it answers {@link Reauthorized} and `mayResend`
|
|
240
|
+
* (the revocation probe and `reach`, asked again) holds, `attempt(true)` once more, carrying what the re-ask answered — the flag says
|
|
241
|
+
* whether this is the last attempt (its refusal is the call's answer). A re-send the seat could not furnish ends with the first
|
|
242
|
+
* attempt's failure, whose delivery verdict stands for the call (one of its attempts was sent).
|
|
181
243
|
*/
|
|
182
|
-
export declare function sentOnceMore<R>(attempt: () => Promise<R | Reauthorized>, mayResend: () => boolean): Promise<R>;
|
|
244
|
+
export declare function sentOnceMore<R>(attempt: (last: boolean) => Promise<R | Reauthorized>, mayResend: () => boolean): Promise<R>;
|
|
183
245
|
export declare function inFlight<T>(client: object, run: () => Promise<T>): Promise<T>;
|
|
184
246
|
export declare function settledInFlight(client: object): Promise<void>;
|
|
185
247
|
export declare function recordCarrier(client: object, carrier: PeerCarrier): void;
|