@sema-agent/core 7.6.3 → 7.8.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.
Files changed (164) hide show
  1. package/CHANGELOG.md +70 -10
  2. package/dist/agents/agent-transcript-tool.js +2 -2
  3. package/dist/agents/list-agents-tool.js +2 -3
  4. package/dist/agents/observer.js +2 -2
  5. package/dist/agents/peer-admission.d.ts +1 -1
  6. package/dist/agents/send-message-tool.js +2 -1
  7. package/dist/agents/subagent-steps.js +5 -4
  8. package/dist/agents/subagent.js +2 -3
  9. package/dist/brain/anthropic.js +8 -2
  10. package/dist/brain/open-responses.js +5 -3
  11. package/dist/brain/openai.js +31 -8
  12. package/dist/brain/reasoning.d.ts +32 -0
  13. package/dist/brain/reasoning.js +18 -0
  14. package/dist/core/ask-question.js +2 -2
  15. package/dist/core/auto-mode-defaults.d.ts +16 -0
  16. package/dist/core/auto-mode-defaults.js +1 -0
  17. package/dist/core/auto-mode.d.ts +19 -0
  18. package/dist/core/auto-mode.js +74 -56
  19. package/dist/core/checkpoint-execution-record.d.ts +110 -0
  20. package/dist/core/checkpoint-execution-record.js +49 -0
  21. package/dist/core/checkpoint-store.d.ts +114 -2
  22. package/dist/core/checkpoint-store.js +35 -2
  23. package/dist/core/context-edit.d.ts +0 -22
  24. package/dist/core/context-edit.js +2 -11
  25. package/dist/core/engine-notice.d.ts +17 -0
  26. package/dist/core/fs-write-gate-policy.d.ts +7 -1
  27. package/dist/core/fs-write-gate-policy.js +7 -7
  28. package/dist/core/gate-fold.js +2 -2
  29. package/dist/core/gate-lanes.js +4 -3
  30. package/dist/core/governance-codes.d.ts +1 -1
  31. package/dist/core/governance-codes.js +8 -0
  32. package/dist/core/hooks.d.ts +8 -2
  33. package/dist/core/hooks.js +1 -1
  34. package/dist/core/lsp.js +2 -2
  35. package/dist/core/mcp-server-spec.d.ts +17 -0
  36. package/dist/core/mcp.js +3 -1
  37. package/dist/core/memory-engine/tools.js +4 -12
  38. package/dist/core/permission-rules.d.ts +32 -2
  39. package/dist/core/permission-rules.js +43 -37
  40. package/dist/core/present-plan-tool.js +3 -4
  41. package/dist/core/runner/active-skill-scope.js +7 -4
  42. package/dist/core/runner/clock-and-limits.d.ts +117 -0
  43. package/dist/core/runner/clock-and-limits.js +118 -0
  44. package/dist/core/runner/compaction-call-options.d.ts +1 -1
  45. package/dist/core/runner/contracts.d.ts +37 -3
  46. package/dist/core/runner/decide-continuation.d.ts +98 -0
  47. package/dist/core/runner/decide-continuation.js +133 -0
  48. package/dist/core/runner/execution-record.d.ts +26 -0
  49. package/dist/core/runner/execution-record.js +19 -0
  50. package/dist/core/runner/git-leg-delivery.d.ts +28 -0
  51. package/dist/core/runner/git-leg-delivery.js +94 -0
  52. package/dist/core/runner/initial-run-state.d.ts +14 -0
  53. package/dist/core/runner/initial-run-state.js +11 -0
  54. package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
  55. package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -4
  56. package/dist/core/runner/prepare-caps-and-workflow.js +33 -11
  57. package/dist/core/runner/prepare-defer-classify.d.ts +5 -26
  58. package/dist/core/runner/prepare-defer-classify.js +10 -10
  59. package/dist/core/runner/prepare-delegation-surface.d.ts +5 -4
  60. package/dist/core/runner/prepare-delegation-surface.js +15 -17
  61. package/dist/core/runner/prepare-gate-stations.d.ts +4 -1
  62. package/dist/core/runner/prepare-gate-stations.js +3 -1
  63. package/dist/core/runner/prepare-hands-readface.d.ts +3 -2
  64. package/dist/core/runner/prepare-hands-readface.js +3 -2
  65. package/dist/core/runner/prepare-inherited-gate.d.ts +1 -1
  66. package/dist/core/runner/prepare-inherited-gate.js +1 -0
  67. package/dist/core/runner/prepare-lsp.d.ts +4 -3
  68. package/dist/core/runner/prepare-lsp.js +3 -2
  69. package/dist/core/runner/prepare-memory-engine-session.d.ts +4 -4
  70. package/dist/core/runner/prepare-memory-engine-session.js +4 -2
  71. package/dist/core/runner/prepare-offload-wrappers.js +7 -5
  72. package/dist/core/runner/prepare-park-ask.d.ts +4 -0
  73. package/dist/core/runner/prepare-park-ask.js +4 -1
  74. package/dist/core/runner/prepare-project-context.d.ts +5 -23
  75. package/dist/core/runner/prepare-project-context.js +7 -5
  76. package/dist/core/runner/prepare-prompt-assembly.d.ts +1 -1
  77. package/dist/core/runner/prepare-protocol-tools.d.ts +5 -1
  78. package/dist/core/runner/prepare-protocol-tools.js +38 -21
  79. package/dist/core/runner/prepare-question-face.d.ts +4 -3
  80. package/dist/core/runner/prepare-question-face.js +5 -3
  81. package/dist/core/runner/prepare-safety-scan.js +42 -2
  82. package/dist/core/runner/prepare-task.js +37 -19
  83. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +5 -2
  84. package/dist/core/runner/prepare-tool-disclosure-mount.js +3 -1
  85. package/dist/core/runner/prepare-wiring-manifest.d.ts +4 -0
  86. package/dist/core/runner/prepare-wiring-manifest.js +3 -8
  87. package/dist/core/runner/run-harness-handlers.d.ts +46 -0
  88. package/dist/core/runner/run-harness-handlers.js +345 -0
  89. package/dist/core/runner/run-turn-boundary.d.ts +69 -0
  90. package/dist/core/runner/run-turn-boundary.js +694 -0
  91. package/dist/core/runner/runtask.d.ts +0 -68
  92. package/dist/core/runner/runtask.js +66 -1486
  93. package/dist/core/runner/session-rule-policy.js +9 -4
  94. package/dist/core/runner/steer-admission.d.ts +17 -0
  95. package/dist/core/runner/steer-admission.js +17 -0
  96. package/dist/core/runner/synthetic-tools.js +5 -8
  97. package/dist/core/runner/tool-disclosure.d.ts +4 -0
  98. package/dist/core/runner/tool-disclosure.js +9 -5
  99. package/dist/core/runner/tool-end-body.d.ts +71 -0
  100. package/dist/core/runner/tool-end-body.js +75 -0
  101. package/dist/core/runner/tool-face-overlay.d.ts +40 -0
  102. package/dist/core/runner/tool-face-overlay.js +125 -0
  103. package/dist/core/runner/tool-output-projection.d.ts +10 -0
  104. package/dist/core/runner/tool-output-projection.js +33 -10
  105. package/dist/core/sensitive-path-policy.d.ts +3 -0
  106. package/dist/core/sensitive-path-policy.js +6 -5
  107. package/dist/core/shared-memory/tools.js +3 -6
  108. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +4 -0
  109. package/dist/core/store-contracts/checkpoint-store-contract.js +108 -0
  110. package/dist/core/task-event.d.ts +10 -0
  111. package/dist/core/task-registry.js +4 -5
  112. package/dist/core/task-spec.d.ts +8 -0
  113. package/dist/core/tool-catalog-entries.d.ts +48 -0
  114. package/dist/core/tool-catalog-entries.js +174 -0
  115. package/dist/core/tool-conformance.d.ts +22 -0
  116. package/dist/core/tool-conformance.js +37 -0
  117. package/dist/core/tool-face.d.ts +171 -0
  118. package/dist/core/tool-face.js +25 -0
  119. package/dist/core/tool-policy.d.ts +24 -0
  120. package/dist/core/tool-policy.js +4 -2
  121. package/dist/core/tool-registry.d.ts +114 -0
  122. package/dist/core/tool-registry.js +114 -0
  123. package/dist/core/tool-result-budget.d.ts +0 -3
  124. package/dist/core/tool-result-budget.js +4 -3
  125. package/dist/core/tool-result-store.d.ts +0 -18
  126. package/dist/core/tool-result-store.js +2 -18
  127. package/dist/core/tool-roster.d.ts +450 -0
  128. package/dist/core/tool-roster.js +497 -0
  129. package/dist/core/tool-spec.d.ts +54 -3
  130. package/dist/core/tools.js +7 -0
  131. package/dist/core/trace.d.ts +24 -0
  132. package/dist/core/wiring-manifest.d.ts +13 -0
  133. package/dist/core/wiring-manifest.js +2 -1
  134. package/dist/core/write-protect.d.ts +2 -1
  135. package/dist/core/write-protect.js +5 -4
  136. package/dist/engine/compaction/utils.d.ts +6 -0
  137. package/dist/engine/compaction/utils.js +19 -19
  138. package/dist/engine/loop/types.d.ts +6 -0
  139. package/dist/index.d.ts +20 -8
  140. package/dist/index.js +19 -7
  141. package/dist/orchestration/goal.js +2 -1
  142. package/dist/orchestration/run-spec.js +3 -5
  143. package/dist/orchestration/run-workflow-tool.js +2 -2
  144. package/dist/prompt-assembly/event-registry.js +3 -3
  145. package/dist/prompt-assembly/tool-catalog.d.ts +2 -2
  146. package/dist/stores/file/checkpoint-store.d.ts +7 -0
  147. package/dist/stores/file/checkpoint-store.js +20 -1
  148. package/dist/tools/fs/fs-bash.d.ts +1 -1
  149. package/dist/tools/fs/fs-bash.js +7 -11
  150. package/dist/tools/fs/fs-read.js +2 -2
  151. package/dist/tools/fs/fs-search-tools.d.ts +0 -7
  152. package/dist/tools/fs/fs-search-tools.js +3 -16
  153. package/dist/tools/fs/fs-write.js +4 -6
  154. package/dist/tools/fs/repo-map.js +2 -2
  155. package/dist/tools/fs/safety.d.ts +2 -1
  156. package/dist/tools/fs/safety.js +6 -5
  157. package/dist/tools/monitor.js +2 -2
  158. package/dist/tools/scheduler-tools.js +5 -8
  159. package/dist/tools/task-list.js +5 -8
  160. package/dist/tools/todo.js +2 -2
  161. package/dist/tools/web.js +3 -6
  162. package/dist/tools/worktree.js +3 -4
  163. package/package.json +4 -1
  164. package/test/export-surface.snapshot.json +183 -7
@@ -0,0 +1,450 @@
1
+ import { Type, type Static, type TSchema } from "typebox";
2
+ import type { AgentTool } from "../internal/harness-types.js";
3
+ import { type ToolFamily, type ToolMountTag, type ToolPathTarget, type ToolRenderHints, type ToolRuleFace } from "./tool-face.js";
4
+ import type { ToolContentOrigin, ToolEffect } from "./tool-spec.js";
5
+ export declare const ROSTER_SOURCES: readonly ["builtin", "caller", "host", "mcp", "a2a", "external", "synthetic"];
6
+ export type RosterSource = (typeof ROSTER_SOURCES)[number];
7
+ export declare const ToolRosterRenderHints: Type.TObject<{
8
+ userFacingName: Type.TOptional<Type.TString>;
9
+ activity: Type.TOptional<Type.TString>;
10
+ summaryParams: Type.TOptional<Type.TArray<Type.TString>>;
11
+ resultCards: Type.TOptional<Type.TArray<Type.TString>>;
12
+ approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">]>>;
13
+ }>;
14
+ export declare const ToolRosterEntry: Type.TObject<{
15
+ name: Type.TString;
16
+ /** Always present (empty when the tool answers to no other name). */
17
+ aliases: Type.TArray<Type.TString>;
18
+ source: Type.TUnion<[Type.TLiteral<"builtin">, Type.TLiteral<"caller">, Type.TLiteral<"host">, Type.TLiteral<"mcp">, Type.TLiteral<"a2a">, Type.TLiteral<"external">, Type.TLiteral<"synthetic">]>;
19
+ /** Present iff `source` ∈ {mcp, a2a, external} (run-time validated at the mint). */
20
+ origin: Type.TOptional<Type.TObject<{
21
+ peer: Type.TString;
22
+ declaredBy: Type.TOptional<Type.TUnion<[Type.TLiteral<"center">, Type.TLiteral<"file">, Type.TLiteral<"request">]>>;
23
+ }>>;
24
+ /** Undeclared ⇒ `legacy:<shapeDigest>` / `unversioned`. */
25
+ contract: Type.TObject<{
26
+ contractId: Type.TString;
27
+ implementationRevision: Type.TString;
28
+ }>;
29
+ shapeDigest: Type.TString;
30
+ wireSchemaDigest: Type.TString;
31
+ /** `builtin:<name>` | `caller:<contractId>` | `mcp:<peer>/<tool>` | `a2a:<peer>/<skill>` | `external:<contractId>`. */
32
+ cardId: Type.TString;
33
+ /** ENGINE-minted: sha256 prefix over the canonical tuple {source, peer, name, contractId}; unique per leg. */
34
+ capabilityId: Type.TString;
35
+ /** The materialized schema's top-level properties (name + coarse type). */
36
+ inputKeys: Type.TArray<Type.TObject<{
37
+ name: Type.TString;
38
+ type: Type.TUnion<[Type.TLiteral<"string">, Type.TLiteral<"number">, Type.TLiteral<"integer">, Type.TLiteral<"boolean">, Type.TLiteral<"object">, Type.TLiteral<"array">, Type.TLiteral<"null">, Type.TLiteral<"mixed">]>;
39
+ }>>;
40
+ effect: Type.TUnion<[Type.TLiteral<"read">, Type.TLiteral<"write">, Type.TLiteral<"idempotent">]>;
41
+ effectProvenance: Type.TUnion<[Type.TLiteral<"declared">, Type.TLiteral<"caller">, Type.TLiteral<"synthetic">, Type.TLiteral<"default">]>;
42
+ offload: Type.TBoolean;
43
+ offloadThresholdChars: Type.TOptional<Type.TInteger>;
44
+ compactable: Type.TBoolean;
45
+ budgetExempt: Type.TBoolean;
46
+ egress: Type.TBoolean;
47
+ egressProvenance: Type.TUnion<[Type.TLiteral<"declared">, Type.TLiteral<"caller">, Type.TLiteral<"default">]>;
48
+ irreversibility: Type.TOptional<Type.TUnion<[Type.TLiteral<"never">, Type.TLiteral<"maybe">, Type.TLiteral<"always">]>>;
49
+ reversibilityProbe: Type.TBoolean;
50
+ contentOrigin: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"execution">, Type.TLiteral<"external">]>;
51
+ contentOriginProvenance: Type.TUnion<[Type.TLiteral<"declared">, Type.TLiteral<"server">, Type.TLiteral<"exempted">, Type.TLiteral<"default">]>;
52
+ family: Type.TUnion<[Type.TLiteral<"shell">, Type.TLiteral<"file-read">, Type.TLiteral<"file-write">, Type.TLiteral<"search">, Type.TLiteral<"web">, Type.TLiteral<"delegate">, Type.TLiteral<"plan">, Type.TLiteral<"scaffold">, Type.TLiteral<"memory">, Type.TLiteral<"protocol">, Type.TLiteral<"other">]>;
53
+ pathTarget: Type.TOptional<Type.TObject<{
54
+ param: Type.TString;
55
+ aliases: Type.TArray<Type.TString>;
56
+ access: Type.TUnion<[Type.TLiteral<"read">, Type.TLiteral<"create">, Type.TLiteral<"edit">]>;
57
+ skillScopeEligible: Type.TBoolean;
58
+ }>>;
59
+ ruleFace: Type.TObject<{
60
+ primaryParams: Type.TArray<Type.TString>;
61
+ params: Type.TArray<Type.TString>;
62
+ }>;
63
+ approvalPreview: Type.TBoolean;
64
+ validateInput: Type.TBoolean;
65
+ deferred: Type.TBoolean;
66
+ alwaysLoad: Type.TBoolean;
67
+ /** Present iff the definition carries a model-gate class and survived the gate. */
68
+ modelGate: Type.TOptional<Type.TString>;
69
+ renderHints: Type.TOptional<Type.TObject<{
70
+ userFacingName: Type.TOptional<Type.TString>;
71
+ activity: Type.TOptional<Type.TString>;
72
+ summaryParams: Type.TOptional<Type.TArray<Type.TString>>;
73
+ resultCards: Type.TOptional<Type.TArray<Type.TString>>;
74
+ approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">]>>;
75
+ }>>;
76
+ /** The ONE mount condition that fired for this instance. */
77
+ mountedBy: Type.TUnion<[Type.TLiteral<"hands">, Type.TLiteral<"backgroundTasks">, Type.TLiteral<"workflow">, Type.TLiteral<"delegation">, Type.TLiteral<"hostInternals">, Type.TLiteral<"peerLane">, Type.TLiteral<"scheduler">, Type.TLiteral<"memory">, Type.TLiteral<"scenario">, Type.TLiteral<"always">, Type.TLiteral<"optional">]>;
78
+ }>;
79
+ export type ToolRosterEntry = Static<typeof ToolRosterEntry>;
80
+ export declare const ToolRoster: Type.TObject<{
81
+ schemaVersion: Type.TLiteral<1>;
82
+ /** Run-time asserted equal to `entries.length`. */
83
+ count: Type.TInteger;
84
+ /** Declaration order = the model's `tools[]` order; names unique (run-time asserted). */
85
+ entries: Type.TArray<Type.TObject<{
86
+ name: Type.TString;
87
+ /** Always present (empty when the tool answers to no other name). */
88
+ aliases: Type.TArray<Type.TString>;
89
+ source: Type.TUnion<[Type.TLiteral<"builtin">, Type.TLiteral<"caller">, Type.TLiteral<"host">, Type.TLiteral<"mcp">, Type.TLiteral<"a2a">, Type.TLiteral<"external">, Type.TLiteral<"synthetic">]>;
90
+ /** Present iff `source` ∈ {mcp, a2a, external} (run-time validated at the mint). */
91
+ origin: Type.TOptional<Type.TObject<{
92
+ peer: Type.TString;
93
+ declaredBy: Type.TOptional<Type.TUnion<[Type.TLiteral<"center">, Type.TLiteral<"file">, Type.TLiteral<"request">]>>;
94
+ }>>;
95
+ /** Undeclared ⇒ `legacy:<shapeDigest>` / `unversioned`. */
96
+ contract: Type.TObject<{
97
+ contractId: Type.TString;
98
+ implementationRevision: Type.TString;
99
+ }>;
100
+ shapeDigest: Type.TString;
101
+ wireSchemaDigest: Type.TString;
102
+ /** `builtin:<name>` | `caller:<contractId>` | `mcp:<peer>/<tool>` | `a2a:<peer>/<skill>` | `external:<contractId>`. */
103
+ cardId: Type.TString;
104
+ /** ENGINE-minted: sha256 prefix over the canonical tuple {source, peer, name, contractId}; unique per leg. */
105
+ capabilityId: Type.TString;
106
+ /** The materialized schema's top-level properties (name + coarse type). */
107
+ inputKeys: Type.TArray<Type.TObject<{
108
+ name: Type.TString;
109
+ type: Type.TUnion<[Type.TLiteral<"string">, Type.TLiteral<"number">, Type.TLiteral<"integer">, Type.TLiteral<"boolean">, Type.TLiteral<"object">, Type.TLiteral<"array">, Type.TLiteral<"null">, Type.TLiteral<"mixed">]>;
110
+ }>>;
111
+ effect: Type.TUnion<[Type.TLiteral<"read">, Type.TLiteral<"write">, Type.TLiteral<"idempotent">]>;
112
+ effectProvenance: Type.TUnion<[Type.TLiteral<"declared">, Type.TLiteral<"caller">, Type.TLiteral<"synthetic">, Type.TLiteral<"default">]>;
113
+ offload: Type.TBoolean;
114
+ offloadThresholdChars: Type.TOptional<Type.TInteger>;
115
+ compactable: Type.TBoolean;
116
+ budgetExempt: Type.TBoolean;
117
+ egress: Type.TBoolean;
118
+ egressProvenance: Type.TUnion<[Type.TLiteral<"declared">, Type.TLiteral<"caller">, Type.TLiteral<"default">]>;
119
+ irreversibility: Type.TOptional<Type.TUnion<[Type.TLiteral<"never">, Type.TLiteral<"maybe">, Type.TLiteral<"always">]>>;
120
+ reversibilityProbe: Type.TBoolean;
121
+ contentOrigin: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"execution">, Type.TLiteral<"external">]>;
122
+ contentOriginProvenance: Type.TUnion<[Type.TLiteral<"declared">, Type.TLiteral<"server">, Type.TLiteral<"exempted">, Type.TLiteral<"default">]>;
123
+ family: Type.TUnion<[Type.TLiteral<"shell">, Type.TLiteral<"file-read">, Type.TLiteral<"file-write">, Type.TLiteral<"search">, Type.TLiteral<"web">, Type.TLiteral<"delegate">, Type.TLiteral<"plan">, Type.TLiteral<"scaffold">, Type.TLiteral<"memory">, Type.TLiteral<"protocol">, Type.TLiteral<"other">]>;
124
+ pathTarget: Type.TOptional<Type.TObject<{
125
+ param: Type.TString;
126
+ aliases: Type.TArray<Type.TString>;
127
+ access: Type.TUnion<[Type.TLiteral<"read">, Type.TLiteral<"create">, Type.TLiteral<"edit">]>;
128
+ skillScopeEligible: Type.TBoolean;
129
+ }>>;
130
+ ruleFace: Type.TObject<{
131
+ primaryParams: Type.TArray<Type.TString>;
132
+ params: Type.TArray<Type.TString>;
133
+ }>;
134
+ approvalPreview: Type.TBoolean;
135
+ validateInput: Type.TBoolean;
136
+ deferred: Type.TBoolean;
137
+ alwaysLoad: Type.TBoolean;
138
+ /** Present iff the definition carries a model-gate class and survived the gate. */
139
+ modelGate: Type.TOptional<Type.TString>;
140
+ renderHints: Type.TOptional<Type.TObject<{
141
+ userFacingName: Type.TOptional<Type.TString>;
142
+ activity: Type.TOptional<Type.TString>;
143
+ summaryParams: Type.TOptional<Type.TArray<Type.TString>>;
144
+ resultCards: Type.TOptional<Type.TArray<Type.TString>>;
145
+ approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">]>>;
146
+ }>>;
147
+ /** The ONE mount condition that fired for this instance. */
148
+ mountedBy: Type.TUnion<[Type.TLiteral<"hands">, Type.TLiteral<"backgroundTasks">, Type.TLiteral<"workflow">, Type.TLiteral<"delegation">, Type.TLiteral<"hostInternals">, Type.TLiteral<"peerLane">, Type.TLiteral<"scheduler">, Type.TLiteral<"memory">, Type.TLiteral<"scenario">, Type.TLiteral<"always">, Type.TLiteral<"optional">]>;
149
+ }>>;
150
+ /** sha256 prefix over the canonical COMPLETE rows — any axis / hint / contract / alias change moves it. */
151
+ digest: Type.TString;
152
+ }>;
153
+ export type ToolRoster = Static<typeof ToolRoster>;
154
+ export declare const ToolRosterDelta: Type.TObject<{
155
+ /** The digest the consumer is expected to hold. A mismatch is NOT a rejection: the carried `roster` is the
156
+ * new state regardless, only `summary` becomes unusable (the consumer records a skew and re-syncs). */
157
+ fromDigest: Type.TString;
158
+ /** The whole post-change roster; positions come from it, never from the summary. */
159
+ roster: Type.TObject<{
160
+ schemaVersion: Type.TLiteral<1>;
161
+ /** Run-time asserted equal to `entries.length`. */
162
+ count: Type.TInteger;
163
+ /** Declaration order = the model's `tools[]` order; names unique (run-time asserted). */
164
+ entries: Type.TArray<Type.TObject<{
165
+ name: Type.TString;
166
+ /** Always present (empty when the tool answers to no other name). */
167
+ aliases: Type.TArray<Type.TString>;
168
+ source: Type.TUnion<[Type.TLiteral<"builtin">, Type.TLiteral<"caller">, Type.TLiteral<"host">, Type.TLiteral<"mcp">, Type.TLiteral<"a2a">, Type.TLiteral<"external">, Type.TLiteral<"synthetic">]>;
169
+ /** Present iff `source` ∈ {mcp, a2a, external} (run-time validated at the mint). */
170
+ origin: Type.TOptional<Type.TObject<{
171
+ peer: Type.TString;
172
+ declaredBy: Type.TOptional<Type.TUnion<[Type.TLiteral<"center">, Type.TLiteral<"file">, Type.TLiteral<"request">]>>;
173
+ }>>;
174
+ /** Undeclared ⇒ `legacy:<shapeDigest>` / `unversioned`. */
175
+ contract: Type.TObject<{
176
+ contractId: Type.TString;
177
+ implementationRevision: Type.TString;
178
+ }>;
179
+ shapeDigest: Type.TString;
180
+ wireSchemaDigest: Type.TString;
181
+ /** `builtin:<name>` | `caller:<contractId>` | `mcp:<peer>/<tool>` | `a2a:<peer>/<skill>` | `external:<contractId>`. */
182
+ cardId: Type.TString;
183
+ /** ENGINE-minted: sha256 prefix over the canonical tuple {source, peer, name, contractId}; unique per leg. */
184
+ capabilityId: Type.TString;
185
+ /** The materialized schema's top-level properties (name + coarse type). */
186
+ inputKeys: Type.TArray<Type.TObject<{
187
+ name: Type.TString;
188
+ type: Type.TUnion<[Type.TLiteral<"string">, Type.TLiteral<"number">, Type.TLiteral<"integer">, Type.TLiteral<"boolean">, Type.TLiteral<"object">, Type.TLiteral<"array">, Type.TLiteral<"null">, Type.TLiteral<"mixed">]>;
189
+ }>>;
190
+ effect: Type.TUnion<[Type.TLiteral<"read">, Type.TLiteral<"write">, Type.TLiteral<"idempotent">]>;
191
+ effectProvenance: Type.TUnion<[Type.TLiteral<"declared">, Type.TLiteral<"caller">, Type.TLiteral<"synthetic">, Type.TLiteral<"default">]>;
192
+ offload: Type.TBoolean;
193
+ offloadThresholdChars: Type.TOptional<Type.TInteger>;
194
+ compactable: Type.TBoolean;
195
+ budgetExempt: Type.TBoolean;
196
+ egress: Type.TBoolean;
197
+ egressProvenance: Type.TUnion<[Type.TLiteral<"declared">, Type.TLiteral<"caller">, Type.TLiteral<"default">]>;
198
+ irreversibility: Type.TOptional<Type.TUnion<[Type.TLiteral<"never">, Type.TLiteral<"maybe">, Type.TLiteral<"always">]>>;
199
+ reversibilityProbe: Type.TBoolean;
200
+ contentOrigin: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"execution">, Type.TLiteral<"external">]>;
201
+ contentOriginProvenance: Type.TUnion<[Type.TLiteral<"declared">, Type.TLiteral<"server">, Type.TLiteral<"exempted">, Type.TLiteral<"default">]>;
202
+ family: Type.TUnion<[Type.TLiteral<"shell">, Type.TLiteral<"file-read">, Type.TLiteral<"file-write">, Type.TLiteral<"search">, Type.TLiteral<"web">, Type.TLiteral<"delegate">, Type.TLiteral<"plan">, Type.TLiteral<"scaffold">, Type.TLiteral<"memory">, Type.TLiteral<"protocol">, Type.TLiteral<"other">]>;
203
+ pathTarget: Type.TOptional<Type.TObject<{
204
+ param: Type.TString;
205
+ aliases: Type.TArray<Type.TString>;
206
+ access: Type.TUnion<[Type.TLiteral<"read">, Type.TLiteral<"create">, Type.TLiteral<"edit">]>;
207
+ skillScopeEligible: Type.TBoolean;
208
+ }>>;
209
+ ruleFace: Type.TObject<{
210
+ primaryParams: Type.TArray<Type.TString>;
211
+ params: Type.TArray<Type.TString>;
212
+ }>;
213
+ approvalPreview: Type.TBoolean;
214
+ validateInput: Type.TBoolean;
215
+ deferred: Type.TBoolean;
216
+ alwaysLoad: Type.TBoolean;
217
+ /** Present iff the definition carries a model-gate class and survived the gate. */
218
+ modelGate: Type.TOptional<Type.TString>;
219
+ renderHints: Type.TOptional<Type.TObject<{
220
+ userFacingName: Type.TOptional<Type.TString>;
221
+ activity: Type.TOptional<Type.TString>;
222
+ summaryParams: Type.TOptional<Type.TArray<Type.TString>>;
223
+ resultCards: Type.TOptional<Type.TArray<Type.TString>>;
224
+ approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">]>>;
225
+ }>>;
226
+ /** The ONE mount condition that fired for this instance. */
227
+ mountedBy: Type.TUnion<[Type.TLiteral<"hands">, Type.TLiteral<"backgroundTasks">, Type.TLiteral<"workflow">, Type.TLiteral<"delegation">, Type.TLiteral<"hostInternals">, Type.TLiteral<"peerLane">, Type.TLiteral<"scheduler">, Type.TLiteral<"memory">, Type.TLiteral<"scenario">, Type.TLiteral<"always">, Type.TLiteral<"optional">]>;
228
+ }>>;
229
+ /** sha256 prefix over the canonical COMPLETE rows — any axis / hint / contract / alias change moves it. */
230
+ digest: Type.TString;
231
+ }>;
232
+ /** Three pairwise-disjoint name lists; a `changed` name's new row is in `roster`. */
233
+ summary: Type.TObject<{
234
+ added: Type.TArray<Type.TString>;
235
+ removed: Type.TArray<Type.TString>;
236
+ changed: Type.TArray<Type.TString>;
237
+ }>;
238
+ }>;
239
+ export type ToolRosterDelta = Static<typeof ToolRosterDelta>;
240
+ /** The ONE name→row resolution every per-call reader shares (the call face, the park identity): the wire name first,
241
+ * then an alias — the same order the dispatcher resolves a model's call. */
242
+ export declare function rosterEntryNamed(roster: ToolRoster, toolName: string): ToolRosterEntry | undefined;
243
+ /** design/388 B6 — the per-call face a gated request carries, read off a roster snapshot by name (aliases resolve). */
244
+ export declare function toolCallFaceOf(roster: ToolRoster | undefined, toolName: string): import("./tool-policy.js").ToolCallFace | undefined;
245
+ /** design/388 B18 — the identity members a park row carries, read off a roster snapshot by name; an empty object when
246
+ * the name is not on the snapshot (the row then reads pre-identity and the resume takes the name-only path). */
247
+ export declare function parkedToolIdentity(roster: ToolRoster | undefined, toolName: string): {
248
+ capabilityId?: string;
249
+ contractId?: string;
250
+ shapeDigest?: string;
251
+ implementationRevision?: string;
252
+ rosterDigest?: string;
253
+ };
254
+ /** design/388 B6 × B18 (merge-seam adversarial round H1) — the FACE members a park row carries beside its identity:
255
+ * the display family and the declared path target the parked call was judged under. A recheck that runs before
256
+ * the leg's roster exists (the pre-CAS resume-edit re-adjudication) rebuilds the call face from the row through
257
+ * {@link parkedCallFaceOf}, so it judges the same object the live gate judged. An empty object when the name is
258
+ * not on the snapshot (the row then reads pre-face and the recheck falls to the catalog for the name). */
259
+ export declare function parkedToolFace(roster: ToolRoster | undefined, toolName: string): {
260
+ family?: ToolFamily;
261
+ pathTarget?: ToolRosterEntry["pathTarget"];
262
+ };
263
+ /** The call face a park row carries — present iff the row was minted with BOTH its face members and its four
264
+ * identity members (one mint writes all of them; a row missing any is pre-388 and yields undefined, never a
265
+ * partial face). This is the face every recheck of the row judges under, roster or no roster. */
266
+ export declare function parkedCallFaceOf(pending: {
267
+ family?: ToolFamily;
268
+ pathTarget?: ToolRosterEntry["pathTarget"];
269
+ capabilityId?: string;
270
+ contractId?: string;
271
+ shapeDigest?: string;
272
+ implementationRevision?: string;
273
+ }): import("./tool-policy.js").ToolCallFace | undefined;
274
+ /** The optional `face` seat of a ToolCallRequest: present iff a face was read (a bare request carries no key). */
275
+ export declare function callFaceSeat(face: import("./tool-policy.js").ToolCallFace | undefined): {
276
+ face?: import("./tool-policy.js").ToolCallFace;
277
+ };
278
+ /** The four-tuple that decides "still the same tool" across a park (design/388 §2.5 boundary ②). */
279
+ export interface ToolIdentity {
280
+ capabilityId: string;
281
+ contractId: string;
282
+ shapeDigest: string;
283
+ implementationRevision: string;
284
+ }
285
+ export declare function toolIdentityOf(entry: ToolRosterEntry): ToolIdentity;
286
+ /** The engine-minted capability identity: a STRUCTURED tuple (never a joined string — `a:b`+`c` and `a`+`b:c`
287
+ * must not collide). Stable across legs for the same source/peer/name/contract. */
288
+ export declare function mintCapabilityId(t: {
289
+ source: RosterSource;
290
+ peer: string | null;
291
+ name: string;
292
+ contractId: string;
293
+ }): string;
294
+ export declare function rosterDigestOf(entries: readonly ToolRosterEntry[]): string;
295
+ /** The materialized schema's top-level properties, in declaration order. */
296
+ export declare function inputKeysOf(schema: TSchema | undefined): {
297
+ keys: ToolRosterEntry["inputKeys"];
298
+ scalar: Set<string>;
299
+ };
300
+ /** The roster's KEY bounds over a schema (design/388 B20): a problem sentence, or undefined when every top-level key fits.
301
+ * Shared by the caller declaration door (typed refusal) and the MCP intake (disclosed drop) — a key is never truncated. */
302
+ export declare function schemaKeyBoundProblem(schema: TSchema | undefined): string | undefined;
303
+ /**
304
+ * The rule vocabulary of ONE mounted instance (design/388 §2.2 ③ / D-3): DERIVED = the scalar top-level
305
+ * keys ∪ the path target's `param` + aliases; a declared `params` list can only NARROW it (a declared
306
+ * name outside the derived set is dropped — the L6 gate names it for a built-in); `primaryParams` =
307
+ * declared, else the path target's `param` + aliases.
308
+ */
309
+ export declare function ruleFaceOfInstance(schema: TSchema | undefined, declared: ToolRuleFace | undefined, pathTarget: ToolPathTarget | undefined): {
310
+ primaryParams: string[];
311
+ params: string[];
312
+ };
313
+ /** What a mount site knows that the instance does not: where the tool came from and which condition fired. */
314
+ export interface RosterMountMeta {
315
+ source: RosterSource;
316
+ mountedBy: ToolMountTag;
317
+ /** Required for `mcp` / `a2a` / `external`; refused otherwise. */
318
+ origin?: {
319
+ peer: string;
320
+ declaredBy?: "center" | "file" | "request";
321
+ };
322
+ }
323
+ /** The face a mounted instance carries (forwarded by `defineTool`; read here by the same untyped-carry convention
324
+ * every other axis reader in the runner uses). */
325
+ export interface MountedToolFace {
326
+ effect?: ToolEffect;
327
+ egress?: true;
328
+ irreversibility?: "never" | "maybe" | "always";
329
+ reversibilityProbe?: unknown;
330
+ contentOrigin?: ToolContentOrigin;
331
+ offload?: boolean;
332
+ offloadThresholdChars?: number;
333
+ defer?: boolean;
334
+ alwaysLoad?: boolean;
335
+ mcpAlwaysLoad?: boolean;
336
+ family?: ToolFamily;
337
+ pathTarget?: ToolPathTarget;
338
+ ruleFace?: ToolRuleFace;
339
+ renderHints?: ToolRenderHints;
340
+ compactable?: true;
341
+ budgetExempt?: true;
342
+ modelGate?: string;
343
+ }
344
+ export declare const faceOf: (t: AgentTool) => MountedToolFace;
345
+ /** The leg facts the snapshot reads beside the instances — the safety scan's folds and the per-task knobs. */
346
+ export interface RosterSnapshotFacts {
347
+ /** The leg's by-name effect map (the builder is its mount-time writer; the protocol folds also write it). */
348
+ effects: ReadonlyMap<string, ToolEffect>;
349
+ egress: ReadonlySet<string>;
350
+ irreversibilityTier: ReadonlyMap<string, "never" | "maybe" | "always">;
351
+ reversibilityProbes: ReadonlyMap<string, unknown>;
352
+ /** Names the defer classification ships as placeholders. */
353
+ deferred: ReadonlySet<string>;
354
+ /** `TaskSpec.memory.trustedTools` — the exemption channel for an undeclared content class. */
355
+ trustedTools: ReadonlySet<string>;
356
+ }
357
+ export declare class RosterBuilder {
358
+ #private;
359
+ constructor(effects: Map<string, ToolEffect>);
360
+ /** The mount array as a READ face. The order is the wire order. */
361
+ get tools(): readonly AgentTool[];
362
+ get length(): number;
363
+ metaOf(tool: AgentTool): RosterMountMeta | undefined;
364
+ /** Mount one instance at the tail. An instance that DECLARES an effect writes it into the leg's effect map —
365
+ * the later mount under a name is the one the harness dispatches to (`snapshot`'s yield rule), so its
366
+ * declaration is the map's truth for that name; a pre-mount registration (the hand band, the plan pair, an
367
+ * MCP axis) stands only for names no mounted instance declares. ONE lane is different by construction: the
368
+ * `scenario` lane's declarations were latched by the safety scan BEFORE any mount, on the synchronous
369
+ * doors+scan stretch (a microtask cannot flip them) — so a scenario mount never re-reads its instance's
370
+ * effect over a registered name; an engine lane's mount under that name still displaces it. */
371
+ mount(tool: AgentTool, meta: RosterMountMeta): void;
372
+ /** An ENGINE-INJECTED instance the harness list carries outside the mount array (the ToolSearch lane): a roster
373
+ * row — the model can call it — never a mount-array element (the disclosure lane owns that list and appends the
374
+ * instance itself). Its row follows the mount array's rows in the snapshot; the same admission rules apply. */
375
+ mountEngineLane(tool: AgentTool, meta: RosterMountMeta): void;
376
+ mountAll(tools: readonly AgentTool[], meta: RosterMountMeta): void;
377
+ /** Remove every instance the predicate selects; returns them in mount order. */
378
+ unmountWhere(pred: (tool: AgentTool, index: number) => boolean): AgentTool[];
379
+ /** Swap the instance at `index` for another object standing for the SAME mount (a presentation re-render, a
380
+ * wrapper): the mount meta carries over. */
381
+ replaceAt(index: number, tool: AgentTool): void;
382
+ /**
383
+ * Re-insert a NAME-PREFIX domain in place (the RefreshMcpTools seam): every instance whose name starts with
384
+ * `prefix` is removed and `fresh` is spliced in at the domain's lowest former index (the wire prefix a
385
+ * provider cache reads stays put); a domain that was not mounted appends at the tail.
386
+ */
387
+ replaceDomain(prefix: string, fresh: readonly AgentTool[], meta: RosterMountMeta): {
388
+ anchor: number;
389
+ };
390
+ /** Mint the roster: one row per mounted NAME, in order. Two mounted instances under one name follow the
391
+ * harness's own yield (the LATER mount is the one the model dispatches to — design/141 Q4, the
392
+ * `auditToolCollisions` "yield" record): the roster carries the surviving instance's row at the
393
+ * yielded instance's position and never a row per object. */
394
+ snapshot(facts: RosterSnapshotFacts): ToolRoster;
395
+ }
396
+ /** Which source a `TaskSpec.tools` entry mounts as: a definition carrying a CORE contract is a built-in the host chose
397
+ * to mount; anything else is the caller's own tool. Identity follows the object, never the name. */
398
+ export declare function callerMountSource(tool: AgentTool): RosterSource;
399
+ /** One row (design/388 §2.5). Every axis is read off the instance or the leg facts; nothing off a name table. */
400
+ export declare function mintRosterEntry(tool: AgentTool, meta: RosterMountMeta, facts: RosterSnapshotFacts): ToolRosterEntry;
401
+ /**
402
+ * The run-time delta seat: armed with the leg's minted roster and a re-snapshot closure at prepare, it
403
+ * re-mints the roster after every run-time roster change (the RefreshMcpTools seam), diffs it against the
404
+ * last published one and hands the delta to the stream (`tool_roster_delta`). Deltas published before a
405
+ * sink subscribes are buffered (bounded) and flushed at subscription, so the first consumer sees them.
406
+ */
407
+ export declare class ToolRosterDeltaSeat {
408
+ #private;
409
+ arm(current: ToolRoster, snapshot: () => ToolRoster): void;
410
+ /** The last minted roster (the prepared one until a run-time change re-mints it). */
411
+ get current(): ToolRoster | undefined;
412
+ /** Re-mint after a run-time change; publishes and returns the delta (undefined before arming). A
413
+ * byte-identical re-mint still publishes: the consumer's summary is empty and its digest unchanged. */
414
+ republish(): ToolRosterDelta | undefined;
415
+ /** Install the stream sink; anything published before is flushed in order. */
416
+ subscribe(sink: (delta: ToolRosterDelta) => void): void;
417
+ /** Take the buffered deltas (a consumer that polls instead of subscribing). */
418
+ drain(): ToolRosterDelta[];
419
+ }
420
+ /**
421
+ * design/388 B15 — the rule-face resolver a leg hands the rule compiler: every roster row answers with its
422
+ * derived vocabulary, the carried-but-non-scalar keys (so `Edit(edits:x)` reads `param_non_scalar`, not
423
+ * `param_unknown`) and whether it names a path target; a name off the roster answers undefined.
424
+ */
425
+ export declare function ruleFacesFromRoster(roster: ToolRoster): (toolName: string) => {
426
+ primaryParams: readonly string[];
427
+ params: readonly string[];
428
+ nonScalar: readonly string[];
429
+ pathTargeting: boolean;
430
+ } | undefined;
431
+ /** The delta between two snapshots (design/388 §2.5): the whole `next` roster plus the name summary. */
432
+ export declare function diffToolRoster(prev: ToolRoster, next: ToolRoster): ToolRosterDelta;
433
+ /**
434
+ * The resume-side identity judgement (design/388 §2.5 boundary ②, B18/B19): a parked action carrying the
435
+ * four identity members is redeemed only against a same-name row whose four members ALL match; a row
436
+ * whose contract / shape / revision / source-peer moved is a replacement wearing the name, and the
437
+ * resume refuses it (`resume.tool_contract_mismatch`, same family and disposition as
438
+ * `resume.tool_unavailable`). A parked action minted BEFORE the identity members existed (all four absent)
439
+ * follows the name-only path and is never widened by their absence.
440
+ */
441
+ export declare function judgeParkedToolIdentity(pending: {
442
+ capabilityId?: string;
443
+ contractId?: string;
444
+ shapeDigest?: string;
445
+ implementationRevision?: string;
446
+ }, row: ToolRosterEntry | undefined): "match" | "mismatch" | "name_only" | "absent";
447
+ /** The card-namespace check a CALLER declaration must pass at prepare (design/388 §2.2 ④): a `resultCards`
448
+ * entry must live under the tool's own `cardId`; naming an engine card (`builtin:*`, or a bare engine card
449
+ * type) is refused. Returns the offending entry, or undefined. */
450
+ export declare function offendingResultCard(hints: ToolRenderHints | undefined, cardId: string, engineCards: ReadonlySet<string>): string | undefined;