@sema-agent/core 5.12.0 → 5.14.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 +320 -0
- package/dist/agents/send-message-tool.js +1 -0
- package/dist/agents/subagent.d.ts +4 -0
- package/dist/agents/subagent.js +137 -43
- package/dist/brain/anthropic.js +33 -10
- package/dist/brain/context-overflow.d.ts +20 -0
- package/dist/brain/context-overflow.js +58 -0
- package/dist/brain/open-responses.js +24 -10
- package/dist/brain/openai.js +29 -11
- package/dist/brain/request-params.d.ts +2 -0
- package/dist/brain/request-params.js +16 -0
- package/dist/brain/stream-engine.d.ts +9 -1
- package/dist/brain/stream-engine.js +256 -27
- package/dist/brain/timeout.d.ts +1 -0
- package/dist/brain/timeout.js +1 -0
- package/dist/core/a2a.d.ts +2 -2
- package/dist/core/a2a.js +3 -3
- package/dist/core/ask-question.d.ts +47 -2
- package/dist/core/ask-question.js +209 -28
- package/dist/core/background-agent-store.d.ts +2 -0
- package/dist/core/checkpoint-store.d.ts +49 -18
- package/dist/core/checkpoint-store.js +117 -4
- package/dist/core/compliance.d.ts +11 -0
- package/dist/core/compliance.js +34 -0
- package/dist/core/governance-codes.d.ts +12 -0
- package/dist/core/governance-codes.js +24 -0
- package/dist/core/hooks.d.ts +24 -2
- package/dist/core/hooks.js +97 -10
- package/dist/core/human-input-projection.d.ts +12 -0
- package/dist/core/human-input-projection.js +27 -0
- package/dist/core/locked-config.d.ts +27 -0
- package/dist/core/locked-config.js +42 -0
- package/dist/core/mcp.d.ts +7 -2
- package/dist/core/mcp.js +7 -7
- package/dist/core/memory-admission.d.ts +51 -0
- package/dist/core/memory-admission.js +159 -0
- package/dist/core/memory.d.ts +2 -0
- package/dist/core/memory.js +3 -2
- package/dist/core/retention.d.ts +36 -0
- package/dist/core/retention.js +31 -0
- package/dist/core/runner/assemble-result.d.ts +1 -0
- package/dist/core/runner/assemble-result.js +2 -2
- package/dist/core/runner/prepare-memory.d.ts +9 -0
- package/dist/core/runner/prepare-memory.js +28 -2
- package/dist/core/runner/prepare-task.d.ts +18 -6
- package/dist/core/runner/prepare-task.js +428 -38
- package/dist/core/runner/runtask.d.ts +3 -6
- package/dist/core/runner/runtask.js +258 -77
- package/dist/core/runner/tool-output-projection.js +1 -0
- package/dist/core/session-store.d.ts +4 -0
- package/dist/core/session-store.js +5 -0
- package/dist/core/session.d.ts +1 -0
- package/dist/core/store-contracts/background-agent-store-contract.js +19 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +62 -3
- package/dist/core/task-notification.d.ts +2 -0
- package/dist/core/task-notification.js +5 -3
- package/dist/core/task-registry-agent.d.ts +1 -0
- package/dist/core/task-registry-agent.js +6 -0
- package/dist/core/task-registry.d.ts +1 -0
- package/dist/core/task-registry.js +4 -1
- package/dist/core/tool-policy.d.ts +5 -0
- package/dist/core/tool-policy.js +2 -1
- package/dist/core/tool-result-store.d.ts +2 -0
- package/dist/core/tool-result-store.js +1 -0
- package/dist/core/types.d.ts +38 -2
- package/dist/core/wiring-manifest.d.ts +97 -0
- package/dist/core/wiring-manifest.js +186 -0
- package/dist/engine/compaction/compaction.js +2 -2
- package/dist/engine/harness/agent-harness.d.ts +2 -1
- package/dist/engine/harness/agent-harness.js +19 -2
- package/dist/engine/harness/types.d.ts +3 -1
- package/dist/engine/llm/types.d.ts +7 -0
- package/dist/engine/llm/types.js +8 -1
- package/dist/engine/llm/validation.js +11 -1
- package/dist/engine/session/import-validate.d.ts +6 -1
- package/dist/engine/session/import-validate.js +29 -6
- package/dist/engine/session/memory-repo.d.ts +3 -1
- package/dist/engine/session/memory-repo.js +2 -2
- package/dist/index.d.ts +12 -4
- package/dist/index.js +12 -4
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/llm.d.ts +2 -2
- package/dist/internal/llm.js +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +4 -0
- package/dist/orchestration/run-workflow-tool.js +3 -0
- package/dist/orchestration/workflow-types.d.ts +8 -0
- package/dist/orchestration/workflow-types.js +14 -0
- package/dist/orchestration/workflow.d.ts +4 -0
- package/dist/orchestration/workflow.js +134 -5
- package/dist/prompts/default.js +1 -1
- package/dist/stores/file/checkpoint-store.d.ts +3 -5
- package/dist/stores/file/checkpoint-store.js +31 -2
- package/dist/stores/file/index.js +1 -1
- package/dist/stores/file/session-store.d.ts +3 -1
- package/dist/stores/file/session-store.js +2 -2
- package/dist/stores/file/shared-ledger.js +8 -1
- package/dist/tools/fs/bash-readonly-classifier.d.ts +3 -0
- package/dist/tools/fs/bash-readonly-classifier.js +94 -0
- package/dist/tools/fs/fs-bash.js +31 -12
- package/dist/tools/fs/safety.js +34 -10
- package/package.json +1 -1
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { canonicalize } from "./canonical-json.js";
|
|
3
|
+
import { resolveCheckpointStore } from "./checkpoint-store.js";
|
|
4
|
+
import { isLiveQuestionFace } from "./ask-question.js";
|
|
5
|
+
export function resolveDeclaredDurability(store, storeName) {
|
|
6
|
+
const declared = store?.durability;
|
|
7
|
+
if (declared === undefined)
|
|
8
|
+
return "process-local";
|
|
9
|
+
if (declared === "durable" || declared === "process-local")
|
|
10
|
+
return declared;
|
|
11
|
+
const e = new Error(`${storeName}.durability declares ${JSON.stringify(declared)} — not a recognized StoreDurability ` +
|
|
12
|
+
`("durable" | "process-local"). Fix the declaration; an unparseable durability cannot be folded to either arm.`);
|
|
13
|
+
e.code = "config.store_durability_invalid";
|
|
14
|
+
throw e;
|
|
15
|
+
}
|
|
16
|
+
const manifestDurabilityOf = (d) => (d === "durable" ? "declared_durable" : "process_local");
|
|
17
|
+
export function deriveAskEffective(form, parkEffective) {
|
|
18
|
+
switch (form) {
|
|
19
|
+
case "callback":
|
|
20
|
+
return "human_reachable";
|
|
21
|
+
case "allow":
|
|
22
|
+
return "auto_allow";
|
|
23
|
+
case "deny":
|
|
24
|
+
return "auto_deny";
|
|
25
|
+
case "absent":
|
|
26
|
+
return parkEffective === true ? "park_only" : parkEffective === "unresolved" ? "unresolved" : "auto_deny";
|
|
27
|
+
default: {
|
|
28
|
+
const _exhaustive = form;
|
|
29
|
+
void _exhaustive;
|
|
30
|
+
throw new Error(`unreachable ask form ${String(form)}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function deriveParkLane(facts) {
|
|
35
|
+
if (!facts.parkCapable) {
|
|
36
|
+
return { capable: false, effective: false, reasons: ["no_checkpoint_store"] };
|
|
37
|
+
}
|
|
38
|
+
const durability = facts.checkpointDurability !== undefined ? { checkpointDurability: manifestDurabilityOf(facts.checkpointDurability) } : {};
|
|
39
|
+
if (facts.parkDurableApprovalOptIn || facts.parkForceDurableGate === true || facts.parkSafetyVocabularyArmed === true) {
|
|
40
|
+
return { capable: true, effective: true, reasons: [], ...durability };
|
|
41
|
+
}
|
|
42
|
+
const reasons = ["no_durable_approval_opt_in"];
|
|
43
|
+
const unresolved = facts.parkForceDurableGate === undefined || facts.parkSafetyVocabularyArmed === undefined;
|
|
44
|
+
if (facts.parkForceDurableGate === undefined)
|
|
45
|
+
reasons.push("await_runtime_caps");
|
|
46
|
+
else
|
|
47
|
+
reasons.push("no_force_durable_gate");
|
|
48
|
+
if (facts.parkSafetyVocabularyArmed === undefined)
|
|
49
|
+
reasons.push("await_tool_vocabulary");
|
|
50
|
+
else
|
|
51
|
+
reasons.push("no_armed_safety_vocabulary");
|
|
52
|
+
return { capable: true, effective: unresolved ? "unresolved" : false, reasons, ...durability };
|
|
53
|
+
}
|
|
54
|
+
export function deriveWiringManifest(facts) {
|
|
55
|
+
if (facts.half === "static" && facts.leg !== undefined) {
|
|
56
|
+
throw new Error("a static wiring manifest has no leg — leg identity is an effective-half fact");
|
|
57
|
+
}
|
|
58
|
+
if (facts.half === "effective" && facts.leg === undefined) {
|
|
59
|
+
throw new Error("an effective wiring manifest requires its leg kind");
|
|
60
|
+
}
|
|
61
|
+
if (facts.half === "effective" && (facts.parkForceDurableGate === undefined || facts.parkSafetyVocabularyArmed === undefined)) {
|
|
62
|
+
throw new Error("an effective wiring manifest requires the resolved park atoms (parkForceDurableGate, parkSafetyVocabularyArmed) — " +
|
|
63
|
+
"`unresolved` is a static-half fact; report the static half instead, or resolve the atoms first.");
|
|
64
|
+
}
|
|
65
|
+
const parkLane = deriveParkLane(facts);
|
|
66
|
+
const questionChannel = facts.questionWired
|
|
67
|
+
? "wired"
|
|
68
|
+
: facts.half === "effective" && facts.questionStrippedByEngine === true
|
|
69
|
+
? "stripped_bg_lane"
|
|
70
|
+
: "absent";
|
|
71
|
+
const manifest = {
|
|
72
|
+
schemaVersion: 1,
|
|
73
|
+
...(facts.leg !== undefined ? { leg: { kind: facts.leg } } : {}),
|
|
74
|
+
ask: {
|
|
75
|
+
form: facts.askForm,
|
|
76
|
+
...(facts.askProvenance !== undefined ? { provenance: facts.askProvenance } : {}),
|
|
77
|
+
...(facts.half === "effective" ? { effective: deriveAskEffective(facts.askForm, parkLane.effective) } : {}),
|
|
78
|
+
},
|
|
79
|
+
question: {
|
|
80
|
+
wired: questionChannel,
|
|
81
|
+
...(questionChannel === "wired" && facts.questionProvenance !== undefined ? { provenance: facts.questionProvenance } : {}),
|
|
82
|
+
...(facts.interactiveToolsWithoutDeliveryFace === true ? { interactiveToolsWithoutDeliveryFace: true } : {}),
|
|
83
|
+
},
|
|
84
|
+
interaction: { posture: facts.interactionPosture ?? "absent" },
|
|
85
|
+
elicit: { seamWired: facts.elicitSeamWired, serversOptedIn: facts.elicitServersOptedIn },
|
|
86
|
+
parkLane,
|
|
87
|
+
session: { store: manifestDurabilityOf(facts.sessionDurability) },
|
|
88
|
+
fleet: { backgroundAgentStore: facts.backgroundAgentStoreWired, hostChildEventSink: facts.hostChildEventSinkWired },
|
|
89
|
+
governance: {
|
|
90
|
+
audience: "operator",
|
|
91
|
+
lockedConfig: facts.lockedConfigWired,
|
|
92
|
+
compliance: facts.complianceWired,
|
|
93
|
+
memoryAdmission: facts.memoryAdmissionWired,
|
|
94
|
+
retention: facts.retentionPolicyWired,
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
if (facts.half === "effective") {
|
|
98
|
+
const { leg: _leg, ...assembly } = manifest;
|
|
99
|
+
const { provenance: _askSeat, ...askForHash } = assembly.ask;
|
|
100
|
+
const { provenance: _questionSeat, ...questionForHash } = assembly.question;
|
|
101
|
+
manifest.configFingerprint = createHash("sha256")
|
|
102
|
+
.update(canonicalize({ ...assembly, ask: askForHash, question: questionForHash }))
|
|
103
|
+
.digest("hex")
|
|
104
|
+
.slice(0, 16);
|
|
105
|
+
}
|
|
106
|
+
return manifest;
|
|
107
|
+
}
|
|
108
|
+
export function resolveAskSeamForm(spec, deps) {
|
|
109
|
+
const seat = spec.onAsk !== undefined ? { value: spec.onAsk, provenance: "spec" } : deps.onAsk !== undefined ? { value: deps.onAsk, provenance: "deps" } : undefined;
|
|
110
|
+
if (seat === undefined)
|
|
111
|
+
return { form: "absent" };
|
|
112
|
+
const v = seat.value;
|
|
113
|
+
const form = typeof v === "function" ? "callback" : v === "allow" ? "allow" : v === "deny" ? "deny" : undefined;
|
|
114
|
+
if (form === undefined) {
|
|
115
|
+
const e = new Error(`the resolved onAsk seat (${seat.provenance}) holds ${JSON.stringify(v)} — not an OnAsk ` +
|
|
116
|
+
`("allow" | "deny" | approver function); refusing to classify it.`);
|
|
117
|
+
e.code = "config.interaction_wiring";
|
|
118
|
+
throw e;
|
|
119
|
+
}
|
|
120
|
+
return { form, provenance: seat.provenance };
|
|
121
|
+
}
|
|
122
|
+
export function resolveQuestionSeam(spec, deps) {
|
|
123
|
+
const seat = spec.onQuestion !== undefined ? { value: spec.onQuestion, provenance: "spec" } : deps.onQuestion !== undefined ? { value: deps.onQuestion, provenance: "deps" } : undefined;
|
|
124
|
+
if (seat === undefined)
|
|
125
|
+
return { wired: false };
|
|
126
|
+
if (typeof seat.value !== "function") {
|
|
127
|
+
const e = new Error(`the resolved onQuestion seat (${seat.provenance}) holds ${seat.value === null ? "null" : typeof seat.value} — not an OnQuestion ` +
|
|
128
|
+
`callback; refusing to report it as a wired question channel (omit the key, or wire a function).`);
|
|
129
|
+
e.code = "config.interaction_wiring";
|
|
130
|
+
throw e;
|
|
131
|
+
}
|
|
132
|
+
if (!isLiveQuestionFace(seat.value))
|
|
133
|
+
return { wired: false };
|
|
134
|
+
return { wired: true, provenance: seat.provenance };
|
|
135
|
+
}
|
|
136
|
+
export function countElicitOptIns(spec) {
|
|
137
|
+
return (spec.mcp ?? []).filter((s) => s.elicitation === true).length;
|
|
138
|
+
}
|
|
139
|
+
export function resolveElicitSeam(deps) {
|
|
140
|
+
if (deps.onElicit === undefined)
|
|
141
|
+
return false;
|
|
142
|
+
if (typeof deps.onElicit !== "function") {
|
|
143
|
+
const e = new Error(`RunnerDeps.onElicit holds ${deps.onElicit === null ? "null" : typeof deps.onElicit} — not an OnElicit ` +
|
|
144
|
+
`callback; refusing to report it as a wired elicitation seam (omit the key, or wire a function).`);
|
|
145
|
+
e.code = "config.interaction_wiring";
|
|
146
|
+
throw e;
|
|
147
|
+
}
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
export function describeStaticWiring(deps, spec = {}) {
|
|
151
|
+
const ask = resolveAskSeamForm(spec, deps);
|
|
152
|
+
const question = resolveQuestionSeam(spec, deps);
|
|
153
|
+
const checkpointStore = resolveCheckpointStore(spec, deps);
|
|
154
|
+
const capable = checkpointStore !== undefined;
|
|
155
|
+
return deriveWiringManifest({
|
|
156
|
+
half: "static",
|
|
157
|
+
askForm: ask.form,
|
|
158
|
+
...(ask.provenance !== undefined ? { askProvenance: ask.provenance } : {}),
|
|
159
|
+
questionWired: question.wired,
|
|
160
|
+
...(question.provenance !== undefined ? { questionProvenance: question.provenance } : {}),
|
|
161
|
+
...(() => {
|
|
162
|
+
const posture = spec.interactionPosture ?? deps.interactionPosture;
|
|
163
|
+
if (posture === undefined)
|
|
164
|
+
return {};
|
|
165
|
+
if (posture !== "interactive" && posture !== "headless") {
|
|
166
|
+
const e = new Error(`interactionPosture ${JSON.stringify(posture)} is not a recognized posture ("interactive" | "headless") — ` +
|
|
167
|
+
`an unevaluable declaration is refused loudly, never folded to either posture (or to absent).`);
|
|
168
|
+
e.code = "config.interaction_posture";
|
|
169
|
+
throw e;
|
|
170
|
+
}
|
|
171
|
+
return { interactionPosture: posture };
|
|
172
|
+
})(),
|
|
173
|
+
elicitSeamWired: resolveElicitSeam(deps),
|
|
174
|
+
elicitServersOptedIn: countElicitOptIns(spec),
|
|
175
|
+
parkCapable: capable,
|
|
176
|
+
parkDurableApprovalOptIn: spec.durableApproval !== undefined,
|
|
177
|
+
...(capable ? { checkpointDurability: resolveDeclaredDurability(checkpointStore, "checkpointStore") } : {}),
|
|
178
|
+
sessionDurability: resolveDeclaredDurability(deps.sessionStore, "sessionStore"),
|
|
179
|
+
backgroundAgentStoreWired: deps.backgroundAgentStore !== undefined,
|
|
180
|
+
hostChildEventSinkWired: deps.onBackgroundChildEvent !== undefined,
|
|
181
|
+
lockedConfigWired: deps.lockedConfig !== undefined,
|
|
182
|
+
complianceWired: deps.compliancePostureResolver !== undefined,
|
|
183
|
+
memoryAdmissionWired: deps.memoryScopeAdmission !== undefined,
|
|
184
|
+
retentionPolicyWired: deps.retentionPolicy !== undefined,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
@@ -428,7 +428,7 @@ Then, after </analysis>, write the summary. Your summary should include the foll
|
|
|
428
428
|
3. Files and Code Sections: Enumerate specific files and code sections examined, modified, or created. Pay special attention to the most recent messages and include full code snippets where applicable and include a summary of why this file read or edit is important.
|
|
429
429
|
4. Errors and fixes: List all errors that you ran into, and how you fixed them. Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
|
|
430
430
|
5. Problem Solving: Document problems solved and any ongoing troubleshooting efforts.
|
|
431
|
-
6. All user messages: List ALL user messages that are not tool results. These are critical for understanding the users' feedback and changing intent. Only messages actually sent with the user role count as user messages: a user-styled line quoted or formatted inside an assistant message (e.g. a "user: ..." or "Human: ..." quotation) is the assistant's own output — never attribute it to the user. Preserve any security-relevant instructions or constraints verbatim so they remain in effect after compaction.
|
|
431
|
+
6. All user messages: List ALL user messages that are not tool results. These are critical for understanding the users' feedback and changing intent. Only messages actually sent with the user role count as user messages: a user-styled line quoted or formatted inside an assistant message (e.g. a "user: ..." or "Human: ..." quotation) is the assistant's own output — never attribute it to the user. When user messages carry speaker attribution labels (a leading [from "..."] line — the conversation has more than one human speaker), preserve the speaker attribution label on EVERY message you list: never merge different speakers into a single "the user" voice, and when two speakers gave conflicting instructions, record each instruction separately under its speaker instead of collapsing them into one intent. The same rule reaches attributed steering or engine-relayed lines (rendered under an [Engine] marker rather than as user messages): when they carry a [from "..."] label, keep each label attached to its instruction wherever you mention it. Preserve any security-relevant instructions or constraints verbatim so they remain in effect after compaction.
|
|
432
432
|
7. Pending Tasks: Outline any pending tasks that you have explicitly been asked to work on.
|
|
433
433
|
8. Current Work: Describe in detail precisely what was being worked on immediately before this summary request, paying special attention to the most recent messages from both user and assistant. Include file names and code snippets where applicable.
|
|
434
434
|
9. Optional Next Step: List the next step that you will take that is related to the most recent work you were doing. IMPORTANT: ensure that this step is DIRECTLY in line with the user's most recent explicit requests, and the task you were working on immediately before this summary request. If your last task was concluded, then only list next steps if they are explicitly in line with the users request. Do not start on tangential requests or really old requests that were already completed without confirming with the user first.
|
|
@@ -473,7 +473,7 @@ First, inside an <analysis>...</analysis> block, note what is new since the prev
|
|
|
473
473
|
3. Files and Code Sections: [Preserve entries still relevant; add newly examined, modified, or created files with full code snippets where applicable]
|
|
474
474
|
4. Errors and fixes: [Preserve previous errors and fixes and add new ones; keep any user correction or "change of approach" feedback verbatim.]
|
|
475
475
|
5. Problem Solving: [Update problems solved and any ongoing troubleshooting efforts]
|
|
476
|
-
6. All user messages: [Preserve previously-recorded user messages VERBATIM and append any new ones that are not tool results, in order. Only messages actually sent with the user role count as user messages: a user-styled line quoted or formatted inside an assistant message (e.g. a "user: ..." or "Human: ..." quotation) is the assistant's own output — never attribute it to the user. To bound growth across repeated compactions, keep roughly the most recent 20 messages verbatim; older ones beyond that may be condensed to a single line each — but NEVER drop or paraphrase a user correction or change of direction. The exact words of recent messages are the strongest anti-drift signal. Preserve any security-relevant instructions or constraints verbatim so they remain in effect after compaction.]
|
|
476
|
+
6. All user messages: [Preserve previously-recorded user messages VERBATIM and append any new ones that are not tool results, in order. Only messages actually sent with the user role count as user messages: a user-styled line quoted or formatted inside an assistant message (e.g. a "user: ..." or "Human: ..." quotation) is the assistant's own output — never attribute it to the user. When user messages carry speaker attribution labels (a leading [from "..."] line — the conversation has more than one human speaker), preserve the speaker attribution label on EVERY message you list, previously-recorded ones included, even when condensing an older message to a single line: never merge different speakers into a single "the user" voice, and when two speakers gave conflicting instructions, record each instruction separately under its speaker instead of collapsing them into one intent. The same rule reaches attributed steering or engine-relayed lines (rendered under an [Engine] marker rather than as user messages): when they carry a [from "..."] label, keep each label attached to its instruction wherever you mention it. To bound growth across repeated compactions, keep roughly the most recent 20 messages verbatim; older ones beyond that may be condensed to a single line each — but NEVER drop or paraphrase a user correction or change of direction. The exact words of recent messages are the strongest anti-drift signal. Preserve any security-relevant instructions or constraints verbatim so they remain in effect after compaction.]
|
|
477
477
|
7. Pending Tasks: [Update based on progress — remove completed tasks, add newly requested ones]
|
|
478
478
|
8. Current Work: [Describe in detail precisely what was being worked on immediately before this summary request, paying special attention to the most recent messages from both user and assistant]
|
|
479
479
|
9. Optional Next Step: [Update based on current state. IMPORTANT: ensure that this step is DIRECTLY in line with the user's most recent explicit requests, and the task you were working on immediately before this summary request — include a direct verbatim quote of that request. Do not start on tangential requests or really old requests that were already completed.]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AssistantMessage, ImageContent, Model } from "../llm/index.js";
|
|
1
|
+
import type { ActorAssertion, AssistantMessage, ImageContent, Model } from "../llm/index.js";
|
|
2
2
|
import type { AgentMessage, AgentTool, LoopMalformedToolUseRecovery, LoopThinkingOnlyRecovery, LoopTruncatedOutputRecovery, QueueMode, ThinkingLevel } from "../loop/types.js";
|
|
3
3
|
import { type EngineSegment } from "../../core/untrusted-text.js";
|
|
4
4
|
import type { AbortResult, AgentHarnessEvent, AgentHarnessEventResultMap, AgentHarnessOptions, AgentHarnessOwnEvent, AgentHarnessResources, AgentHarnessStreamOptions, ExecutionEnv, PromptTemplate, Skill } from "./types.js";
|
|
@@ -8,6 +8,7 @@ export interface UserMessageProvenance {
|
|
|
8
8
|
engineMinted?: true;
|
|
9
9
|
provenance?: "engine-note";
|
|
10
10
|
enginePayload?: unknown;
|
|
11
|
+
actor?: ActorAssertion;
|
|
11
12
|
}
|
|
12
13
|
export interface HarnessLoopRecovery {
|
|
13
14
|
truncatedOutput?: LoopTruncatedOutputRecovery;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { snapshotActorAssertion, stripEngineMetadata } from "../llm/index.js";
|
|
1
2
|
import { runAgentLoop } from "../loop/agent-loop.js";
|
|
2
3
|
import { resolveAgentCoreStreamFn } from "../loop/runtime-deps.js";
|
|
3
4
|
import { normalizeEngineSegments } from "../../core/untrusted-text.js";
|
|
@@ -24,9 +25,16 @@ function createUserMessage(text, images, provenance) {
|
|
|
24
25
|
: {}),
|
|
25
26
|
...(provenance?.engineMinted === true && !engineNote ? { engineMinted: true } : {}),
|
|
26
27
|
...(engineNote ? { provenance: "engine-note" } : {}),
|
|
28
|
+
...(provenance?.actor !== undefined &&
|
|
29
|
+
typeof provenance.actor.id === "string" &&
|
|
30
|
+
provenance.actor.id.length > 0 &&
|
|
31
|
+
typeof provenance.actor.hostAsserted === "boolean"
|
|
32
|
+
? { actor: snapshotActorAssertion(provenance.actor) }
|
|
33
|
+
: {}),
|
|
27
34
|
};
|
|
28
35
|
}
|
|
29
36
|
const engineNotePayloads = new WeakMap();
|
|
37
|
+
const ENGINE_NOTE_STEER_BACKLOG_CAP = 50;
|
|
30
38
|
function createFailureMessage(model, error, aborted) {
|
|
31
39
|
return {
|
|
32
40
|
role: "assistant",
|
|
@@ -418,7 +426,13 @@ export class AgentHarness {
|
|
|
418
426
|
};
|
|
419
427
|
}
|
|
420
428
|
async drainQueuedMessages(queue, mode) {
|
|
421
|
-
|
|
429
|
+
let count = mode === "all" ? queue.length : 1;
|
|
430
|
+
if (mode !== "all" && queue.length > 1 && engineNotePayloads.has(queue[0])) {
|
|
431
|
+
count = 1;
|
|
432
|
+
while (count < queue.length && engineNotePayloads.has(queue[count]))
|
|
433
|
+
count++;
|
|
434
|
+
}
|
|
435
|
+
const messages = queue.splice(0, count);
|
|
422
436
|
if (messages.length === 0) {
|
|
423
437
|
return messages;
|
|
424
438
|
}
|
|
@@ -448,7 +462,7 @@ export class AgentHarness {
|
|
|
448
462
|
...(this.streamingToolExecution === true && (this.getHandlers("tool_call")?.size ?? 0) === 0
|
|
449
463
|
? { streamingToolExecution: true }
|
|
450
464
|
: {}),
|
|
451
|
-
convertToLlm,
|
|
465
|
+
convertToLlm: (messages) => stripEngineMetadata(convertToLlm(messages)),
|
|
452
466
|
shouldStopAfterTurn: () => this._stopAfterTurn,
|
|
453
467
|
transformContext: async (messages) => {
|
|
454
468
|
const result = await this.emitHook({ type: "context", messages: [...messages] });
|
|
@@ -713,6 +727,9 @@ export class AgentHarness {
|
|
|
713
727
|
async enqueueInjection(queue, text, options) {
|
|
714
728
|
if (AgentHarness.emptyInjection(text, options))
|
|
715
729
|
return;
|
|
730
|
+
if (options?.enginePayload !== undefined && queue.filter((q) => engineNotePayloads.has(q)).length >= ENGINE_NOTE_STEER_BACKLOG_CAP) {
|
|
731
|
+
throw new AgentHarnessError("invalid_state", `engine-note backlog at cap (${ENGINE_NOTE_STEER_BACKLOG_CAP}) — park the payload for the session's next run`);
|
|
732
|
+
}
|
|
716
733
|
const m = createUserMessage(text, options?.images, options);
|
|
717
734
|
if (options?.enginePayload !== undefined)
|
|
718
735
|
engineNotePayloads.set(m, options.enginePayload);
|
|
@@ -336,7 +336,9 @@ export interface SessionRepo<TMetadata extends SessionMetadata = SessionMetadata
|
|
|
336
336
|
delete(metadata: TMetadata): Promise<void>;
|
|
337
337
|
fork(source: TMetadata, options: SessionForkOptions & TCreateOptions): Promise<Session<TMetadata>>;
|
|
338
338
|
exportEntries?(sessionId: string): Promise<SessionTreeEntry[]>;
|
|
339
|
-
importEntries?(sessionId: string, owner: string | undefined, entries: SessionTreeEntry[]
|
|
339
|
+
importEntries?(sessionId: string, owner: string | undefined, entries: SessionTreeEntry[], options?: {
|
|
340
|
+
preserveActorAssertions?: boolean;
|
|
341
|
+
}): Promise<void>;
|
|
340
342
|
}
|
|
341
343
|
export interface JsonlSessionCreateOptions extends SessionCreateOptions {
|
|
342
344
|
cwd: string;
|
|
@@ -110,6 +110,12 @@ export interface Usage {
|
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
112
|
export type StopReason = "stop" | "length" | "toolUse" | "error" | "aborted";
|
|
113
|
+
export interface ActorAssertion {
|
|
114
|
+
id: string;
|
|
115
|
+
hostAsserted: boolean;
|
|
116
|
+
issuer?: string;
|
|
117
|
+
}
|
|
118
|
+
export declare function snapshotActorAssertion(actor: ActorAssertion): ActorAssertion;
|
|
113
119
|
export interface UserMessage {
|
|
114
120
|
role: "user";
|
|
115
121
|
content: string | (TextContent | ImageContent)[];
|
|
@@ -121,6 +127,7 @@ export interface UserMessage {
|
|
|
121
127
|
}>;
|
|
122
128
|
engineMinted?: true;
|
|
123
129
|
provenance?: "engine-note";
|
|
130
|
+
actor?: ActorAssertion;
|
|
124
131
|
}
|
|
125
132
|
export interface AssistantMessage {
|
|
126
133
|
role: "assistant";
|
package/dist/engine/llm/types.js
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
export function snapshotActorAssertion(actor) {
|
|
2
|
+
return {
|
|
3
|
+
id: actor.id,
|
|
4
|
+
hostAsserted: actor.hostAsserted,
|
|
5
|
+
...(actor.issuer !== undefined ? { issuer: actor.issuer } : {}),
|
|
6
|
+
};
|
|
7
|
+
}
|
|
1
8
|
export function stripEngineMetadata(messages) {
|
|
2
9
|
return messages.map((m) => {
|
|
3
10
|
if (m.role !== "user")
|
|
4
11
|
return m;
|
|
5
|
-
const { enginePrefixChars: _a, engineSegments: _b, engineMinted: _c, provenance: _d, ...rest } = m;
|
|
12
|
+
const { enginePrefixChars: _a, engineSegments: _b, engineMinted: _c, provenance: _d, actor: _e, ...rest } = m;
|
|
6
13
|
return rest;
|
|
7
14
|
});
|
|
8
15
|
}
|
|
@@ -288,5 +288,15 @@ export function validateToolArguments(tool, toolCall) {
|
|
|
288
288
|
.Errors(args)
|
|
289
289
|
.map((error) => ` - ${formatValidationPath(error)}: ${error.message}`)
|
|
290
290
|
.join("\n") || "Unknown validation error";
|
|
291
|
-
|
|
291
|
+
const schemaJson = (() => {
|
|
292
|
+
try {
|
|
293
|
+
const s = JSON.stringify(tool.parameters);
|
|
294
|
+
return s.length > VALIDATION_ERROR_SCHEMA_MAX_CHARS ? `${s.slice(0, VALIDATION_ERROR_SCHEMA_MAX_CHARS)}… (schema truncated)` : s;
|
|
295
|
+
}
|
|
296
|
+
catch {
|
|
297
|
+
return "(schema not serializable)";
|
|
298
|
+
}
|
|
299
|
+
})();
|
|
300
|
+
throw new Error(`Validation failed for tool "${toolCall.name}":\n${errors}\n\nReceived arguments:\n${JSON.stringify(toolCall.arguments, null, 2)}\n\nExpected parameter schema:\n${schemaJson}`);
|
|
292
301
|
}
|
|
302
|
+
const VALIDATION_ERROR_SCHEMA_MAX_CHARS = 4_000;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { type SessionTreeEntry } from "../harness/types.js";
|
|
2
|
+
export interface ImportValidatorOptions {
|
|
3
|
+
preserveActorAssertions?: boolean;
|
|
4
|
+
}
|
|
2
5
|
export declare class StreamingImportValidator {
|
|
3
6
|
private readonly seen;
|
|
4
7
|
private readonly parentOf;
|
|
5
8
|
private rootCount;
|
|
6
9
|
private runningLeaf;
|
|
7
10
|
private done;
|
|
11
|
+
private readonly preserveActorAssertions;
|
|
12
|
+
constructor(options?: ImportValidatorOptions);
|
|
8
13
|
step(entry: SessionTreeEntry): void;
|
|
9
14
|
finish(): {
|
|
10
15
|
leafId: string | null;
|
|
11
16
|
};
|
|
12
17
|
}
|
|
13
|
-
export declare function validateEntriesForImport(entries: SessionTreeEntry[]): SessionTreeEntry[];
|
|
18
|
+
export declare function validateEntriesForImport(entries: SessionTreeEntry[], options?: ImportValidatorOptions): SessionTreeEntry[];
|
|
@@ -17,6 +17,10 @@ export class StreamingImportValidator {
|
|
|
17
17
|
rootCount = 0;
|
|
18
18
|
runningLeaf = null;
|
|
19
19
|
done = false;
|
|
20
|
+
preserveActorAssertions;
|
|
21
|
+
constructor(options) {
|
|
22
|
+
this.preserveActorAssertions = options?.preserveActorAssertions === true;
|
|
23
|
+
}
|
|
20
24
|
step(entry) {
|
|
21
25
|
if (this.done) {
|
|
22
26
|
throw new SessionError("invalid_session", "StreamingImportValidator.step() called after finish()");
|
|
@@ -55,7 +59,7 @@ export class StreamingImportValidator {
|
|
|
55
59
|
}
|
|
56
60
|
if (e.type === "message") {
|
|
57
61
|
validateMessageContentShape(e.message, `Entry "${e.id}"`);
|
|
58
|
-
normalizeEngineProvenanceStamp(e.message);
|
|
62
|
+
normalizeEngineProvenanceStamp(e.message, this.preserveActorAssertions);
|
|
59
63
|
}
|
|
60
64
|
else if (e.type === "custom_message") {
|
|
61
65
|
validateContentShape(e.content, CUSTOM_CONTENT_BLOCK_TYPES, true, `Entry "${e.id}".content`);
|
|
@@ -208,12 +212,15 @@ export class StreamingImportValidator {
|
|
|
208
212
|
return { leafId: this.runningLeaf };
|
|
209
213
|
}
|
|
210
214
|
}
|
|
211
|
-
export function validateEntriesForImport(entries) {
|
|
212
|
-
const
|
|
213
|
-
|
|
215
|
+
export function validateEntriesForImport(entries, options) {
|
|
216
|
+
const protectedEntries = entries.map((e) => e.type === "message" && typeof e.message === "object" && e.message !== null && !Array.isArray(e.message)
|
|
217
|
+
? { ...e, message: { ...e.message } }
|
|
218
|
+
: e);
|
|
219
|
+
const v = new StreamingImportValidator(options);
|
|
220
|
+
for (const e of protectedEntries)
|
|
214
221
|
v.step(e);
|
|
215
222
|
v.finish();
|
|
216
|
-
return
|
|
223
|
+
return protectedEntries;
|
|
217
224
|
}
|
|
218
225
|
const TEXT_IMAGE_BLOCK_TYPES = new Set(["text", "image"]);
|
|
219
226
|
const CUSTOM_CONTENT_BLOCK_TYPES = TEXT_IMAGE_BLOCK_TYPES;
|
|
@@ -235,12 +242,28 @@ function describeShape(value) {
|
|
|
235
242
|
}
|
|
236
243
|
return `a ${typeof value}`;
|
|
237
244
|
}
|
|
238
|
-
function normalizeEngineProvenanceStamp(message) {
|
|
245
|
+
function normalizeEngineProvenanceStamp(message, preserveActorAssertions = false) {
|
|
239
246
|
if (message === null || typeof message !== "object")
|
|
240
247
|
return;
|
|
241
248
|
const m = message;
|
|
242
249
|
if (m.role !== "user")
|
|
243
250
|
return;
|
|
251
|
+
if (m.actor !== undefined) {
|
|
252
|
+
const a = m.actor;
|
|
253
|
+
const wellFormed = preserveActorAssertions &&
|
|
254
|
+
a !== null &&
|
|
255
|
+
typeof a === "object" &&
|
|
256
|
+
typeof a.id === "string" &&
|
|
257
|
+
a.id.length > 0 &&
|
|
258
|
+
typeof a.hostAsserted === "boolean" &&
|
|
259
|
+
(a.issuer === undefined || (typeof a.issuer === "string" && a.issuer.length > 0));
|
|
260
|
+
if (wellFormed) {
|
|
261
|
+
m.actor = { id: a.id, hostAsserted: a.hostAsserted, ...(a.issuer !== undefined ? { issuer: a.issuer } : {}) };
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
delete m.actor;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
244
267
|
if (m.engineMinted !== undefined && m.engineMinted !== true)
|
|
245
268
|
delete m.engineMinted;
|
|
246
269
|
if (m.provenance !== undefined && m.provenance !== "engine-note")
|
|
@@ -11,5 +11,7 @@ export declare class InMemorySessionRepo implements SessionRepo<SessionMetadata,
|
|
|
11
11
|
delete(metadata: SessionMetadata): Promise<void>;
|
|
12
12
|
fork(sourceMetadata: SessionMetadata, options: SessionForkOptions): Promise<Session>;
|
|
13
13
|
exportEntries(sessionId: string): Promise<SessionTreeEntry[]>;
|
|
14
|
-
importEntries(sessionId: string, owner: string | undefined, entries: SessionTreeEntry[]
|
|
14
|
+
importEntries(sessionId: string, owner: string | undefined, entries: SessionTreeEntry[], options?: {
|
|
15
|
+
preserveActorAssertions?: boolean;
|
|
16
|
+
}): Promise<void>;
|
|
15
17
|
}
|
|
@@ -49,9 +49,9 @@ export class InMemorySessionRepo {
|
|
|
49
49
|
const session = await this.open({ id: sessionId, createdAt: "" });
|
|
50
50
|
return session.getStorage().getEntries();
|
|
51
51
|
}
|
|
52
|
-
async importEntries(sessionId, owner, entries) {
|
|
52
|
+
async importEntries(sessionId, owner, entries, options) {
|
|
53
53
|
void owner;
|
|
54
|
-
const validated = validateEntriesForImport(entries);
|
|
54
|
+
const validated = validateEntriesForImport(entries, options);
|
|
55
55
|
const metadata = { id: sessionId, createdAt: createTimestamp() };
|
|
56
56
|
this.sessions.set(sessionId, toSession(new InMemorySessionStorage({ metadata, entries: validated })));
|
|
57
57
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export { createTaskListTools, createMemoryTaskListStore, assertJsonMetadata, typ
|
|
|
15
15
|
export { assembleCodeTools, type CodeToolsConfig, CODE_ROLE } from "./scenarios/full-body.js";
|
|
16
16
|
export { capAggregateToolResults, AGGREGATE_TOOL_RESULT_BUDGET_CHARS, DEFAULT_BUDGET_EXEMPT_TOOLS, type AggregateBudgetOptions, } from "./core/tool-result-budget.js";
|
|
17
17
|
export { capAggregateMediaBytes, AGGREGATE_MEDIA_BUDGET_BYTES, type MediaStripInfo } from "./core/media-byte-cap.js";
|
|
18
|
-
export { createAskUserQuestionTool, createDurableQuestionPolicy, QUESTION_AWAITS_RESUME, type OnQuestion, type AskQuestion, type AskQuestionOption, type AskQuestionRequest, type QuestionAnswer, type QuestionAnswerItem, } from "./core/ask-question.js";
|
|
18
|
+
export { createAskUserQuestionTool, createDurableQuestionPolicy, QUESTION_AWAITS_RESUME, isQuestionUnavailable, type OnQuestionOutcome, type QuestionUnavailable, type OnQuestion, type AskQuestion, type AskQuestionOption, type AskQuestionRequest, type QuestionAnswer, type QuestionAnswerItem, type AskQuestionCardDetails, type AskUserQuestionToolOptions, type AskAnswerContinuationSource, type SyntheticContinuationReason, } from "./core/ask-question.js";
|
|
19
19
|
export { createLspTool, gitCheckIgnoreFilter, LSP_OPERATIONS, LSP_FAILURE_BRAND, brandLspFailure, lspFailureOf, SharedAbortScope, settleOnAbort, type LspNoneReason, type LspOperation, type LspServerManager, type LspSession, type LspResult, type LspLocation, type LspSymbolInfo, type LspRequestParams, type LspToolOptions, type LspTransport, type LspReadText, } from "./core/lsp.js";
|
|
20
20
|
export { buildRequest, parseResult, callHierarchyMethod, pathToUri } from "./core/lsp-protocol.js";
|
|
21
21
|
export { TransportLspSession, type SessionWarmup } from "./core/lsp-session.js";
|
|
@@ -48,6 +48,11 @@ export { InMemorySessionPolicyStore, SessionPolicyError, loosenReasons, normaliz
|
|
|
48
48
|
export { SAFETY_MERGE_CONFORMANCE_CORPUS, type SafetyMergeVector } from "./core/safety-merge-corpus.js";
|
|
49
49
|
export { SAFETY_AXIS_VOCABULARY } from "./core/safety-axis-vocab.js";
|
|
50
50
|
export { createSessionRulePolicy } from "./core/runner/session-rule-policy.js";
|
|
51
|
+
export { LOCKED_KEY_REGISTRY, resolveLockedKeys, type LockedKey, type LockedConfig } from "./core/locked-config.js";
|
|
52
|
+
export { BUILTIN_COMPLIANCE_DENIES, COMPLIANCE_CAPABILITIES, WEB_FETCH_TOOL_NAME, complianceCallDenial, resolveComplianceDenies, type ComplianceCapability, type CompliancePosture, type ComplianceProfile, } from "./core/compliance.js";
|
|
53
|
+
export { admitMemoryScopes, foldAdmissionFreeze, type OwnOrgAdmissionVerdict, type MemoryAdmissionInput, type MemoryAdmissionOutcome, type MemoryAdmissionVerdict, type MemoryScopeAdmission, type MemoryScopeOrigin, type MemoryScopeRequest, } from "./core/memory-admission.js";
|
|
54
|
+
export { assertRetentionCapability, type ManagedRetentionCapability, type RetentionDeclaration, type RetentionDeclaring, type RetentionPolicy, type RetentionReceipt, } from "./core/retention.js";
|
|
55
|
+
export { GOVERNANCE_CODES, governanceRetryClass, type GovernanceCode, type GovernanceRetryClass } from "./core/governance-codes.js";
|
|
51
56
|
export { TtlSessionStore, type TtlSessionStoreOptions, type EvictPolicy } from "./core/session-store.js";
|
|
52
57
|
export { reconcileInterruptedSession, findOrphanToolCalls, type OrphanToolCall, type ReconcileReport, } from "./core/session-reconcile.js";
|
|
53
58
|
export { StoredSession, InMemorySessionRepo, InMemorySessionStorage, BaseSessionStorage, leafIdAfterEntry, validateEntriesForImport, StreamingImportValidator, boundedTail, SessionError, isSessionConflict, hasSessionFork, uuidv7, type Session, type SessionStore, type AcquiredSession, type SessionStoreSummary, type SessionStorage, type SessionRepo, type SessionMetadata, type SessionTreeEntry, type SessionWriteOptions, } from "./core/session.js";
|
|
@@ -77,7 +82,7 @@ export { HAND_TOOL_EFFECTS, bashReversibilityProbe, BASH_READONLY_DEFAULT_ALLOW,
|
|
|
77
82
|
export { classifyCompoundReadonlyDetailed, formatOutOfRootReadApprovalOption, type BashReadonlyRootBoundary, type CompoundReadonlyVerdict, } from "./tools/fs/index.js";
|
|
78
83
|
export { resolveBashTimeoutCaps } from "./tools/fs/index.js";
|
|
79
84
|
export { InMemoryToolResultStore, OFFLOAD_TOOL_NAME, DEFAULT_TOOL_RESULT_THRESHOLD_CHARS, assertSafeToolResultRef, type ToolResultStore, type ToolResultSlice, } from "./core/tool-result-store.js";
|
|
80
|
-
export { InMemoryCheckpointStore, CheckpointError, mintCheckpointToken, checkpointVersionOf, CURRENT_CHECKPOINT_VERSION, MAX_SUPPORTED_CHECKPOINT_VERSION, RESOURCE_CHECKPOINT_VERSION, TOKEN_CHECKPOINT_VERSION, debitLedger, remainingBudgetMicroUsd, remainingTokens, winnerFromOutcome, validatePendingSteer, riskSeverity, buildRiskDescriptor, summarizeCheckpoint, type RiskDescriptor, type CheckpointStore, type CheckpointSummary, type Checkpoint, type CheckpointToken, type CheckpointGate, type CheckpointState, type SerializedCheckpointState, type CheckpointFaultMode, type PendingAction, type ResumeOutcome, type ResolvedOutcome, type ReopenReason, type ResolveExpectation, type SafetyAxis, type ResourceLedger, type ResourceLimitReason, type PlatformLimitReason, } from "./core/checkpoint-store.js";
|
|
85
|
+
export { InMemoryCheckpointStore, CheckpointError, mintCheckpointToken, checkpointVersionOf, CURRENT_CHECKPOINT_VERSION, MAX_SUPPORTED_CHECKPOINT_VERSION, ORG_ADMISSION_CHECKPOINT_VERSION, RESOURCE_CHECKPOINT_VERSION, TOKEN_CHECKPOINT_VERSION, debitLedger, remainingBudgetMicroUsd, remainingTokens, winnerFromOutcome, validatePendingSteer, readPendingSteerQueue, appendPendingSteer, MAX_PENDING_STEER_CHARS, MAX_PENDING_STEER_ENTRIES, PENDING_STEER_QUEUE_BYTE_BUDGET_BYTES, PENDING_STEER_FROZEN_FIELDS, ACTOR_ASSERTION_FROZEN_FIELDS, MAX_ACTOR_FIELD_CHARS, MAX_STEER_INPUT_ID_CHARS, LEGACY_PENDING_STEER_INPUT_ID, type ActorAssertion, type PendingSteerEntry, type PendingSteerInput, riskSeverity, buildRiskDescriptor, summarizeCheckpoint, type RiskDescriptor, type CheckpointStore, type CheckpointSummary, type Checkpoint, type CheckpointToken, type CheckpointGate, type CheckpointState, type SerializedCheckpointState, type CheckpointFaultMode, type PendingAction, type ResumeOutcome, type ResolvedOutcome, type ReopenReason, type ResolveExpectation, type SafetyAxis, type ResourceLedger, type ResourceLimitReason, type PlatformLimitReason, } from "./core/checkpoint-store.js";
|
|
81
86
|
export { InMemoryUsageWindowStore, GLOBAL_USAGE_KEY, EMPTY_USAGE_WINDOW_RECORD, chargeUsageRecord, readUsageRecord, usageRetryAfterMs, resolveUsageWindows, type UsageWindow, type UsageWindowStore, type UsageWindowReading, type UsageWindowRecord, type UsageSlot, type UsageBucketRow, } from "./core/usage-window-store.js";
|
|
82
87
|
export { FileUsageWindowStore } from "./stores/file/usage-window-store.js";
|
|
83
88
|
export { ENV_LIFETIME_SUSPEND_MARGIN_MS, USAGE_WINDOW_REAP_MARGIN_MS } from "./core/runner/prepare-task.js";
|
|
@@ -92,7 +97,10 @@ export { createSensitivePathPolicy, RECOMMENDED_SENSITIVE_PATTERNS } from "./cor
|
|
|
92
97
|
export { createFsWriteGatePolicy, type FsWriteGatePolicyOptions } from "./core/fs-write-gate-policy.js";
|
|
93
98
|
export { RETIRED_TOOL_NAMES } from "./core/tool-name-aliases.js";
|
|
94
99
|
export { DEFAULT_SUBAGENT_TOOL_NAME } from "./agents/subagent.js";
|
|
95
|
-
export { renderTaskNotificationXml, taskNotificationDedupKey, SystemInjectionQueue, type TaskNotificationPayload, type TaskNotificationStatus, type ExternalNotificationInput, type SystemInjection, type SystemInjectionPriority, } from "./core/task-notification.js";
|
|
100
|
+
export { renderTaskNotificationXml, taskNotificationDedupKey, isDelegatedAgentTerminal, SystemInjectionQueue, type TaskNotificationPayload, type TaskNotificationStatus, type ExternalNotificationInput, type SystemInjection, type SystemInjectionPriority, } from "./core/task-notification.js";
|
|
101
|
+
export { describeStaticWiring, deriveWiringManifest, deriveAskEffective, resolveDeclaredDurability, resolveAskSeamForm, resolveQuestionSeam, countElicitOptIns, type WiringManifest, type WiringFacts, type WiringLegKind, type AskSeamForm, type AskEffective, type QuestionChannelState, type SeamProvenance, type ParkLaneReason, type ManifestDurability, type StaticWiringDeps, type StaticWiringSpec, } from "./core/wiring-manifest.js";
|
|
102
|
+
export { type StoreDurability } from "./core/checkpoint-store.js";
|
|
103
|
+
export { projectHumanInput, buildHumanInputEvent, type HumanInputSource, type HumanInputFrame, type HumanInputEvent, type HumanInputDelivery, } from "./core/human-input-projection.js";
|
|
96
104
|
export { TaskRegistry, defaultTaskRegistry, createTaskOutputTool, createTaskStopTool, type SemaTaskType, type SemaTaskStatus, type SemaTaskHandle, type ParkedClaimTicket, type TaskAccess, type UnifiedTaskOutput, type TaskRetrievalStatus, type StopSource, type RegisterMonitorInput, type MonitorTimers, MONITOR_BATCH_WINDOW_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_MAX_TIMEOUT_MS, MONITOR_MAX_BATCHES_PER_MINUTE, canAccessWorkflowRun, DURABLE_AGENT_HANDLE_RE, } from "./core/task-registry.js";
|
|
97
105
|
export { InMemoryMailboxStore, type MailboxStore, type MailboxMessage, type MailboxLease } from "./core/mailbox-store.js";
|
|
98
106
|
export { FileMailboxStore, type FileMailboxStoreOptions } from "./stores/file/mailbox-store.js";
|
|
@@ -118,7 +126,7 @@ export { parseAutoModeResponse, createAutoModeDecider, type AutoModeVerdict, typ
|
|
|
118
126
|
export { buildAutoModePrompt, renderAutoModeWindow, renderAutoModeAction, AUTO_MODE_DEFAULTS_SENTINEL, type AutoModeRules, type BuildAutoModePromptOptions, type AutoModeWindowOptions, } from "./core/auto-mode-prompt.js";
|
|
119
127
|
export { AUTO_MODE_BASE_PROMPT, AUTO_MODE_PERMISSIONS_EXTERNAL } from "./core/auto-mode-prompt-assets.js";
|
|
120
128
|
export { createPermissionRulePolicy, validatePermissionRules, parsePermissionRule, wildcardMatch, type PermissionRule, type ParsedPermissionRule, type PermissionRuleIssue, type PermissionRuleCaps, type PermissionRulePolicyOptions, } from "./core/permission-rules.js";
|
|
121
|
-
export { formatHookFeedback, runToolGate, type Hooks, type HookToolContext, type HookToolOutput, type PreToolUseResult, type PostToolUseResult, type UserPromptSubmitResult, type HookToolFailure, type PostToolUseFailureResult, type PostToolBatchCall, type PostToolBatchResult, type PreCompactContext, type PreCompactResult, type PostCompactContext, type StopFailureContext, type PermissionDeniedPayload, type PermissionDeniedSource, } from "./core/hooks.js";
|
|
129
|
+
export { formatHookFeedback, runToolGate, createHookEnvCapabilities, type Hooks, type HookToolContext, type HookEnvCapabilities, type HookToolOutput, type PreToolUseResult, type PostToolUseResult, type UserPromptSubmitResult, type HookToolFailure, type PostToolUseFailureResult, type PostToolBatchCall, type PostToolBatchResult, type PreCompactContext, type PreCompactResult, type PostCompactContext, type StopFailureContext, type PermissionDeniedPayload, type PermissionDeniedSource, } from "./core/hooks.js";
|
|
122
130
|
export { InMemoryMemoryStore, composeMemoryBlock, composeLayeredMemoryBlock, normalizeMemorySpec, type NormalizedMemorySpec, type MemorySpecInput, supportsConsolidation, supportsPeriodicConsolidation, firstSentence, expandLexicalTerms, lexicalSearchMatch, type Embedder, classifyPromotable, enforcePromotableWriteGate, guardedMemoryStore, MemoryGateError, detectSecret, enforceSecretWriteGate, enforceStructuredNoteSecretGate, type UtilityGate, type MemoryStore, type MemoryVectorMode, type ScoredMemory, type MemoryNoteHeader, type MemoryNoteRecord, type MemoryNoteType, type StructuredNoteInput, } from "./core/memory.js";
|
|
123
131
|
export { MemoryEngine, FileMemoryEngineBackend, memoryBackendContract, assertMemoryBackendSearchEquivalence, type MemoryBackendContractHooks, buildMemoryInstruction, truncateIndex, scanEntryFiles, deriveRepoKey, deriveRepoMemoryDir, deriveControlPlaneDir, deriveRepoControlPlaneDir, resolveMemoryEngineRoot, scopeDirName, ControlPlaneCorruptError, parseEntryFile, serializeEntryFile, computeEntryRev, entryFromFile, MEMORY_INSTRUCTION_TEMPLATE, MEMORY_INDEX_FILENAME, MEMORY_INDEX_MAX_LINES, MEMORY_INDEX_MAX_BYTES, STUB_ARCHIVED_LINE, DEFAULT_MAX_MEMORY_FILES, DEFAULT_MAX_ENTRY_DEPTH, DEFAULT_HARVEST_DEADLINE_MS, DEFAULT_HARVEST_FILE_BUDGET, MASS_DELETION_FUSE_RATIO, scanMemoryWrite, scanMemoryFileName, scanRemediation, MEMORY_FILENAME_SEGMENT_RE, renderAnnouncements, enqueueMemoryAnnouncement, drainMemoryAnnouncements, peekMemoryAnnouncements, bumpScanFuse, scanFuseCount, clearScanFuse, ANNOUNCEMENTS_FILE, MEMORY_ANNOUNCEMENTS_MAX, SCAN_FUSE_FILE, SCAN_FUSE_THRESHOLD, type MemoryAnnouncement, type ScanFinding, type MemoryEngineOptions, type MemoryInjection, type MemoryBackend, type MemoryEntry, type MemoryEntryFrontmatter, type MemoryEntryHeader, type ScoredMemoryEntry, type NotePatch, type PatchReport, type MaterializedFile, type MemorySessionHandle, type HarvestReport, type HarvestRejection, type HarvestRejectionCode, type ParsedEntryFile, type ScannedEntryFile, SCOPE_SEGMENT_MAX_ENCODED, PROJECT_MARKER_PATH, encodeScopeSegment, decodeScopeSegment, parseScopeKey, formatUserScope, formatOrgScope, formatProjScope, formatUserProjScope, isPersonalScope, assertScopeContractPlacement, formatProjectMarker, parseProjectMarker, resolveProjectId, PROJECT_ID_REGEX, type ParsedScopeKey, migrateScope, type MigrateScopeReport, materializeEntriesToFiles, harvestFilesToPatches, projectionsToWriteBack, screenInboundEntries, REMOTE_HARVEST_PER_FILE_BYTES, REMOTE_MASS_DELETION_FUSE_RATIO, type RemoteMemoryFile, type RemoteMemoryBaseline, type RemoteMaterialization, type RemoteHarvestResult, type InboundEntryFinding, deriveProjectMemoryDir, deriveProjectControlDir, recordProjectIdHint, lookupProjectIdHint, PROJECT_ID_HINTS_FILE, reconcileMemoryEntries, nextSyncBaseline, mergeRecallHits, type MemorySyncCursor, type MemorySyncConflict, type MemorySyncPlan, type RecallSource, syncMemoryScope, type MemorySyncTransport, type MemorySyncRequestBody, type MemorySyncResponseBody, type MemorySyncClientConflict, type SyncMemoryScopeOptions, type MemorySyncClientResult, } from "./core/memory-engine/index.js";
|
|
124
132
|
export { termSet, jaccardDistance, cosineDistance } from "./core/memory-vector.js";
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ export { createTaskListTools, createMemoryTaskListStore, assertJsonMetadata } fr
|
|
|
12
12
|
export { assembleCodeTools, CODE_ROLE } from "./scenarios/full-body.js";
|
|
13
13
|
export { capAggregateToolResults, AGGREGATE_TOOL_RESULT_BUDGET_CHARS, DEFAULT_BUDGET_EXEMPT_TOOLS, } from "./core/tool-result-budget.js";
|
|
14
14
|
export { capAggregateMediaBytes, AGGREGATE_MEDIA_BUDGET_BYTES } from "./core/media-byte-cap.js";
|
|
15
|
-
export { createAskUserQuestionTool, createDurableQuestionPolicy, QUESTION_AWAITS_RESUME, } from "./core/ask-question.js";
|
|
15
|
+
export { createAskUserQuestionTool, createDurableQuestionPolicy, QUESTION_AWAITS_RESUME, isQuestionUnavailable, } from "./core/ask-question.js";
|
|
16
16
|
export { createLspTool, gitCheckIgnoreFilter, LSP_OPERATIONS, LSP_FAILURE_BRAND, brandLspFailure, lspFailureOf, SharedAbortScope, settleOnAbort, } from "./core/lsp.js";
|
|
17
17
|
export { buildRequest, parseResult, callHierarchyMethod, pathToUri } from "./core/lsp-protocol.js";
|
|
18
18
|
export { TransportLspSession } from "./core/lsp-session.js";
|
|
@@ -44,6 +44,11 @@ export { InMemorySessionPolicyStore, SessionPolicyError, loosenReasons, normaliz
|
|
|
44
44
|
export { SAFETY_MERGE_CONFORMANCE_CORPUS } from "./core/safety-merge-corpus.js";
|
|
45
45
|
export { SAFETY_AXIS_VOCABULARY } from "./core/safety-axis-vocab.js";
|
|
46
46
|
export { createSessionRulePolicy } from "./core/runner/session-rule-policy.js";
|
|
47
|
+
export { LOCKED_KEY_REGISTRY, resolveLockedKeys } from "./core/locked-config.js";
|
|
48
|
+
export { BUILTIN_COMPLIANCE_DENIES, COMPLIANCE_CAPABILITIES, WEB_FETCH_TOOL_NAME, complianceCallDenial, resolveComplianceDenies, } from "./core/compliance.js";
|
|
49
|
+
export { admitMemoryScopes, foldAdmissionFreeze, } from "./core/memory-admission.js";
|
|
50
|
+
export { assertRetentionCapability, } from "./core/retention.js";
|
|
51
|
+
export { GOVERNANCE_CODES, governanceRetryClass } from "./core/governance-codes.js";
|
|
47
52
|
export { TtlSessionStore } from "./core/session-store.js";
|
|
48
53
|
export { reconcileInterruptedSession, findOrphanToolCalls, } from "./core/session-reconcile.js";
|
|
49
54
|
export { StoredSession, InMemorySessionRepo, InMemorySessionStorage, BaseSessionStorage, leafIdAfterEntry, validateEntriesForImport, StreamingImportValidator, boundedTail, SessionError, isSessionConflict, hasSessionFork, uuidv7, } from "./core/session.js";
|
|
@@ -65,7 +70,7 @@ export { HAND_TOOL_EFFECTS, bashReversibilityProbe, BASH_READONLY_DEFAULT_ALLOW,
|
|
|
65
70
|
export { classifyCompoundReadonlyDetailed, formatOutOfRootReadApprovalOption, } from "./tools/fs/index.js";
|
|
66
71
|
export { resolveBashTimeoutCaps } from "./tools/fs/index.js";
|
|
67
72
|
export { InMemoryToolResultStore, OFFLOAD_TOOL_NAME, DEFAULT_TOOL_RESULT_THRESHOLD_CHARS, assertSafeToolResultRef, } from "./core/tool-result-store.js";
|
|
68
|
-
export { InMemoryCheckpointStore, CheckpointError, mintCheckpointToken, checkpointVersionOf, CURRENT_CHECKPOINT_VERSION, MAX_SUPPORTED_CHECKPOINT_VERSION, RESOURCE_CHECKPOINT_VERSION, TOKEN_CHECKPOINT_VERSION, debitLedger, remainingBudgetMicroUsd, remainingTokens, winnerFromOutcome, validatePendingSteer, riskSeverity, buildRiskDescriptor, summarizeCheckpoint, } from "./core/checkpoint-store.js";
|
|
73
|
+
export { InMemoryCheckpointStore, CheckpointError, mintCheckpointToken, checkpointVersionOf, CURRENT_CHECKPOINT_VERSION, MAX_SUPPORTED_CHECKPOINT_VERSION, ORG_ADMISSION_CHECKPOINT_VERSION, RESOURCE_CHECKPOINT_VERSION, TOKEN_CHECKPOINT_VERSION, debitLedger, remainingBudgetMicroUsd, remainingTokens, winnerFromOutcome, validatePendingSteer, readPendingSteerQueue, appendPendingSteer, MAX_PENDING_STEER_CHARS, MAX_PENDING_STEER_ENTRIES, PENDING_STEER_QUEUE_BYTE_BUDGET_BYTES, PENDING_STEER_FROZEN_FIELDS, ACTOR_ASSERTION_FROZEN_FIELDS, MAX_ACTOR_FIELD_CHARS, MAX_STEER_INPUT_ID_CHARS, LEGACY_PENDING_STEER_INPUT_ID, riskSeverity, buildRiskDescriptor, summarizeCheckpoint, } from "./core/checkpoint-store.js";
|
|
69
74
|
export { InMemoryUsageWindowStore, GLOBAL_USAGE_KEY, EMPTY_USAGE_WINDOW_RECORD, chargeUsageRecord, readUsageRecord, usageRetryAfterMs, resolveUsageWindows, } from "./core/usage-window-store.js";
|
|
70
75
|
export { FileUsageWindowStore } from "./stores/file/usage-window-store.js";
|
|
71
76
|
export { ENV_LIFETIME_SUSPEND_MARGIN_MS, USAGE_WINDOW_REAP_MARGIN_MS } from "./core/runner/prepare-task.js";
|
|
@@ -79,7 +84,10 @@ export { createSensitivePathPolicy, RECOMMENDED_SENSITIVE_PATTERNS } from "./cor
|
|
|
79
84
|
export { createFsWriteGatePolicy } from "./core/fs-write-gate-policy.js";
|
|
80
85
|
export { RETIRED_TOOL_NAMES } from "./core/tool-name-aliases.js";
|
|
81
86
|
export { DEFAULT_SUBAGENT_TOOL_NAME } from "./agents/subagent.js";
|
|
82
|
-
export { renderTaskNotificationXml, taskNotificationDedupKey, SystemInjectionQueue, } from "./core/task-notification.js";
|
|
87
|
+
export { renderTaskNotificationXml, taskNotificationDedupKey, isDelegatedAgentTerminal, SystemInjectionQueue, } from "./core/task-notification.js";
|
|
88
|
+
export { describeStaticWiring, deriveWiringManifest, deriveAskEffective, resolveDeclaredDurability, resolveAskSeamForm, resolveQuestionSeam, countElicitOptIns, } from "./core/wiring-manifest.js";
|
|
89
|
+
export {} from "./core/checkpoint-store.js";
|
|
90
|
+
export { projectHumanInput, buildHumanInputEvent, } from "./core/human-input-projection.js";
|
|
83
91
|
export { TaskRegistry, defaultTaskRegistry, createTaskOutputTool, createTaskStopTool, MONITOR_BATCH_WINDOW_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_MAX_TIMEOUT_MS, MONITOR_MAX_BATCHES_PER_MINUTE, canAccessWorkflowRun, DURABLE_AGENT_HANDLE_RE, } from "./core/task-registry.js";
|
|
84
92
|
export { InMemoryMailboxStore } from "./core/mailbox-store.js";
|
|
85
93
|
export { FileMailboxStore } from "./stores/file/mailbox-store.js";
|
|
@@ -103,7 +111,7 @@ export { parseAutoModeResponse, createAutoModeDecider, } from "./core/auto-mode.
|
|
|
103
111
|
export { buildAutoModePrompt, renderAutoModeWindow, renderAutoModeAction, AUTO_MODE_DEFAULTS_SENTINEL, } from "./core/auto-mode-prompt.js";
|
|
104
112
|
export { AUTO_MODE_BASE_PROMPT, AUTO_MODE_PERMISSIONS_EXTERNAL } from "./core/auto-mode-prompt-assets.js";
|
|
105
113
|
export { createPermissionRulePolicy, validatePermissionRules, parsePermissionRule, wildcardMatch, } from "./core/permission-rules.js";
|
|
106
|
-
export { formatHookFeedback, runToolGate, } from "./core/hooks.js";
|
|
114
|
+
export { formatHookFeedback, runToolGate, createHookEnvCapabilities, } from "./core/hooks.js";
|
|
107
115
|
export { InMemoryMemoryStore, composeMemoryBlock, composeLayeredMemoryBlock, normalizeMemorySpec, supportsConsolidation, supportsPeriodicConsolidation, firstSentence, expandLexicalTerms, lexicalSearchMatch, classifyPromotable, enforcePromotableWriteGate, guardedMemoryStore, MemoryGateError, detectSecret, enforceSecretWriteGate, enforceStructuredNoteSecretGate, } from "./core/memory.js";
|
|
108
116
|
export { MemoryEngine, FileMemoryEngineBackend, memoryBackendContract, assertMemoryBackendSearchEquivalence, buildMemoryInstruction, truncateIndex, scanEntryFiles, deriveRepoKey, deriveRepoMemoryDir, deriveControlPlaneDir, deriveRepoControlPlaneDir, resolveMemoryEngineRoot, scopeDirName, ControlPlaneCorruptError, parseEntryFile, serializeEntryFile, computeEntryRev, entryFromFile, MEMORY_INSTRUCTION_TEMPLATE, MEMORY_INDEX_FILENAME, MEMORY_INDEX_MAX_LINES, MEMORY_INDEX_MAX_BYTES, STUB_ARCHIVED_LINE, DEFAULT_MAX_MEMORY_FILES, DEFAULT_MAX_ENTRY_DEPTH, DEFAULT_HARVEST_DEADLINE_MS, DEFAULT_HARVEST_FILE_BUDGET, MASS_DELETION_FUSE_RATIO, scanMemoryWrite, scanMemoryFileName, scanRemediation, MEMORY_FILENAME_SEGMENT_RE, renderAnnouncements, enqueueMemoryAnnouncement, drainMemoryAnnouncements, peekMemoryAnnouncements, bumpScanFuse, scanFuseCount, clearScanFuse, ANNOUNCEMENTS_FILE, MEMORY_ANNOUNCEMENTS_MAX, SCAN_FUSE_FILE, SCAN_FUSE_THRESHOLD, SCOPE_SEGMENT_MAX_ENCODED, PROJECT_MARKER_PATH, encodeScopeSegment, decodeScopeSegment, parseScopeKey, formatUserScope, formatOrgScope, formatProjScope, formatUserProjScope, isPersonalScope, assertScopeContractPlacement, formatProjectMarker, parseProjectMarker, resolveProjectId, PROJECT_ID_REGEX, migrateScope, materializeEntriesToFiles, harvestFilesToPatches, projectionsToWriteBack, screenInboundEntries, REMOTE_HARVEST_PER_FILE_BYTES, REMOTE_MASS_DELETION_FUSE_RATIO, deriveProjectMemoryDir, deriveProjectControlDir, recordProjectIdHint, lookupProjectIdHint, PROJECT_ID_HINTS_FILE, reconcileMemoryEntries, nextSyncBaseline, mergeRecallHits, syncMemoryScope, } from "./core/memory-engine/index.js";
|
|
109
117
|
export { termSet, jaccardDistance, cosineDistance } from "./core/memory-vector.js";
|
|
@@ -2,7 +2,7 @@ export type { CompactionPreparation, SummarizationClampDryRun } from "../engine/
|
|
|
2
2
|
export type { InvokedSkillRetention } from "../engine/compaction/utils.js";
|
|
3
3
|
export type { AgentCoreRuntimeDeps } from "../engine/loop/runtime-deps.js";
|
|
4
4
|
export type { AgentMessage, AgentTool, AgentToolResult, AgentToolUpdateCallback, ThinkingLevel, ToolExecutionMode, } from "../engine/loop/types.js";
|
|
5
|
-
export type { AgentHarnessEvent, CompactionSettings, ExecutionEnv, ExecutionErrorCode, FileErrorCode, FileInfo, Result, Session, SessionMetadata, SessionRepo, SessionStorage, SessionTreeEntry, Skill, } from "../engine/harness/types.js";
|
|
5
|
+
export type { AgentHarnessEvent, CompactionSettings, ExecutionEnv, ExecutionErrorCode, FileError, FileErrorCode, FileInfo, Result, Session, SessionMetadata, SessionRepo, SessionStorage, SessionTreeEntry, Skill, } from "../engine/harness/types.js";
|
|
6
6
|
export type { ExecutionEnvExecOptions, ExecResult } from "../engine/harness/types.js";
|
|
7
7
|
export type { SessionWriteOptions, CompactionEntry } from "../engine/harness/types.js";
|
|
8
8
|
export type { ActiveWorktreeSession, WorkspaceState } from "../engine/harness/types.js";
|
package/dist/internal/llm.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { createAssistantMessageEventStream, stripEngineMetadata } from "../engine/llm/index.js";
|
|
2
|
-
export type { AnthropicMessagesCompat, OpenAICompletionsCompat, OpenAIResponsesCompat, AssistantMessage, AssistantMessageDiagnostic, AssistantMessageEvent, CompleteSimpleFn, Context, DocumentContent, ImageContent, Message, Model, ResilienceOptions, SimpleStreamOptions, StallTimeouts, StopReason, StreamFn, TextContent, ThinkingContent, Tool, ToolCall, ToolResultMessage, Usage, UserMessage, } from "../engine/llm/index.js";
|
|
1
|
+
export { createAssistantMessageEventStream, snapshotActorAssertion, stripEngineMetadata } from "../engine/llm/index.js";
|
|
2
|
+
export type { ActorAssertion, AnthropicMessagesCompat, OpenAICompletionsCompat, OpenAIResponsesCompat, AssistantMessage, AssistantMessageDiagnostic, AssistantMessageEvent, CompleteSimpleFn, Context, DocumentContent, ImageContent, Message, Model, ResilienceOptions, SimpleStreamOptions, StallTimeouts, StopReason, StreamFn, TextContent, ThinkingContent, Tool, ToolCall, ToolResultMessage, Usage, UserMessage, } from "../engine/llm/index.js";
|
package/dist/internal/llm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createAssistantMessageEventStream, stripEngineMetadata } from "../engine/llm/index.js";
|
|
1
|
+
export { createAssistantMessageEventStream, snapshotActorAssertion, stripEngineMetadata } from "../engine/llm/index.js";
|