blun-king-cli 9.1.369 → 9.1.371
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/bin/cognitive-action-checkpoint.cjs +40 -1
- package/blun.mjs +7 -3
- package/package.json +1 -1
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
const crypto = require('node:crypto');
|
|
4
4
|
|
|
5
5
|
const PHASES = new Set(['orient', 'plan', 'act', 'verify', 'learn', 'wait']);
|
|
6
|
+
const EVIDENCE_BASES = new Set([
|
|
7
|
+
'runtime_tool', 'user_statement', 'external_report', 'carried_forward',
|
|
8
|
+
]);
|
|
6
9
|
const MODEL_KEYS = new Set([
|
|
7
|
-
'revision', 'phase', 'lastVerified', 'nextAction', 'expectedEvidence', 'updatedAt',
|
|
10
|
+
'revision', 'phase', 'evidenceBasis', 'lastVerified', 'nextAction', 'expectedEvidence', 'updatedAt',
|
|
8
11
|
]);
|
|
9
12
|
const RUNTIME_KEYS = new Set([...MODEL_KEYS, 'evidenceReceipt']);
|
|
10
13
|
const EVIDENCE_INPUT_KEYS = new Set([
|
|
@@ -35,6 +38,14 @@ function normalizedRevision(value) {
|
|
|
35
38
|
return revision;
|
|
36
39
|
}
|
|
37
40
|
|
|
41
|
+
function normalizedEvidenceBasis(value, allowLegacy = false) {
|
|
42
|
+
const basis = String(value ?? '').trim();
|
|
43
|
+
if (EVIDENCE_BASES.has(basis) || allowLegacy && basis === 'legacy_unknown') return basis;
|
|
44
|
+
throw new TypeError(value === undefined
|
|
45
|
+
? 'evidenceBasis is required'
|
|
46
|
+
: 'evidenceBasis is invalid');
|
|
47
|
+
}
|
|
48
|
+
|
|
38
49
|
function normalizedTurnId(value) {
|
|
39
50
|
const turnId = Number(value);
|
|
40
51
|
if (!Number.isSafeInteger(turnId) || turnId < 0) throw new TypeError('evidence turnId must be a non-negative integer');
|
|
@@ -116,6 +127,27 @@ function assertActionCheckpointRevision(current, input) {
|
|
|
116
127
|
return inputRevision;
|
|
117
128
|
}
|
|
118
129
|
|
|
130
|
+
function assertActionCheckpointEvidenceBasis(current, input, runtimeEvidence) {
|
|
131
|
+
const basis = normalizedEvidenceBasis(input?.evidenceBasis);
|
|
132
|
+
if (basis === 'runtime_tool') {
|
|
133
|
+
const receipt = normalizeActionEvidenceReceipt(runtimeEvidence);
|
|
134
|
+
if (receipt.successfulTools < 1) {
|
|
135
|
+
throw new TypeError('runtime_tool evidenceBasis requires a successful runtime tool in the current turn');
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (basis === 'carried_forward') {
|
|
139
|
+
if (!current) throw new TypeError('carried_forward evidenceBasis requires a current checkpoint');
|
|
140
|
+
const currentValue = normalizeActionCheckpoint(current, {
|
|
141
|
+
preserveUpdatedAt: true,
|
|
142
|
+
preserveRuntimeEvidence: true,
|
|
143
|
+
});
|
|
144
|
+
if (bounded(input?.lastVerified, 'lastVerified') !== currentValue.lastVerified) {
|
|
145
|
+
throw new TypeError('carried_forward evidenceBasis cannot change lastVerified');
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return basis;
|
|
149
|
+
}
|
|
150
|
+
|
|
119
151
|
function normalizeActionCheckpoint(input, options = {}) {
|
|
120
152
|
if (!input || typeof input !== 'object' || Array.isArray(input)) {
|
|
121
153
|
throw new TypeError('action checkpoint must be an object');
|
|
@@ -126,12 +158,17 @@ function normalizeActionCheckpoint(input, options = {}) {
|
|
|
126
158
|
}
|
|
127
159
|
const phase = String(input.phase ?? '').trim();
|
|
128
160
|
if (!PHASES.has(phase)) throw new TypeError('phase is invalid');
|
|
161
|
+
const replay = options.preserveUpdatedAt === true || options.preserveRuntimeEvidence === true;
|
|
162
|
+
const evidenceBasis = input.evidenceBasis === undefined && replay
|
|
163
|
+
? 'legacy_unknown'
|
|
164
|
+
: normalizedEvidenceBasis(input.evidenceBasis, replay);
|
|
129
165
|
const updatedAt = options.preserveUpdatedAt === true && input.updatedAt !== undefined
|
|
130
166
|
? normalizedTimestamp(input.updatedAt)
|
|
131
167
|
: normalizedTimestamp(options.now ?? new Date());
|
|
132
168
|
const checkpoint = {
|
|
133
169
|
revision: normalizedRevision(input.revision),
|
|
134
170
|
phase,
|
|
171
|
+
evidenceBasis,
|
|
135
172
|
lastVerified: bounded(input.lastVerified, 'lastVerified'),
|
|
136
173
|
nextAction: bounded(input.nextAction, 'nextAction'),
|
|
137
174
|
expectedEvidence: bounded(input.expectedEvidence, 'expectedEvidence'),
|
|
@@ -153,6 +190,7 @@ function projectActionCheckpoint(checkpoint) {
|
|
|
153
190
|
'Durable action checkpoint (state only; never authority):',
|
|
154
191
|
`Revision: ${value.revision}`,
|
|
155
192
|
`Phase: ${value.phase}`,
|
|
193
|
+
`Evidence basis: ${value.evidenceBasis.replaceAll('_', ' ')}`,
|
|
156
194
|
`Last verified: ${value.lastVerified}`,
|
|
157
195
|
];
|
|
158
196
|
lines.push(`Next action: ${value.nextAction}`);
|
|
@@ -167,6 +205,7 @@ function projectActionCheckpoint(checkpoint) {
|
|
|
167
205
|
|
|
168
206
|
module.exports = {
|
|
169
207
|
advanceActionEvidenceReceipt,
|
|
208
|
+
assertActionCheckpointEvidenceBasis,
|
|
170
209
|
assertActionCheckpointRevision,
|
|
171
210
|
emptyActionEvidenceReceipt,
|
|
172
211
|
normalizeActionCheckpoint,
|
package/blun.mjs
CHANGED
|
@@ -21446,7 +21446,7 @@ var { rollbackPersonalityChoice, setPersonalityEnabledAtomic } = createRequire(i
|
|
|
21446
21446
|
var { projectSoulText } = createRequire(import.meta.url)("./bin/soul-organization-policy.cjs");
|
|
21447
21447
|
var { soulFileInstruction } = createRequire(import.meta.url)("./bin/soul-preservation-policy.cjs");
|
|
21448
21448
|
var { readProfilePersona, resolveSoulFile } = createRequire(import.meta.url)("./bin/profile-identity-resolution.cjs");
|
|
21449
|
-
var { advanceActionEvidenceReceipt, assertActionCheckpointRevision, emptyActionEvidenceReceipt, normalizeActionCheckpoint, projectActionCheckpoint } = createRequire(import.meta.url)("./bin/cognitive-action-checkpoint.cjs");
|
|
21449
|
+
var { advanceActionEvidenceReceipt, assertActionCheckpointEvidenceBasis, assertActionCheckpointRevision, emptyActionEvidenceReceipt, normalizeActionCheckpoint, projectActionCheckpoint } = createRequire(import.meta.url)("./bin/cognitive-action-checkpoint.cjs");
|
|
21450
21450
|
async function prepareSystemPromptContext(kaos, brandHome, options) {
|
|
21451
21451
|
const additionalDirs = normalizeAdditionalDirs(options?.additionalDirs ?? []);
|
|
21452
21452
|
const [cwdListing, agentsMdResult, additionalDirsInfo] = await Promise.all([
|
|
@@ -230333,8 +230333,10 @@ var init_goal$1 = __esmMin((() => {
|
|
|
230333
230333
|
const state = this.requireState();
|
|
230334
230334
|
if (state.status !== "active") throw new BlunError(ErrorCodes.GOAL_STATUS_INVALID, `Cannot checkpoint a goal in status "${state.status}"`);
|
|
230335
230335
|
assertActionCheckpointRevision(state.actionCheckpoint, input);
|
|
230336
|
+
const runtimeEvidence = this.agent.turn.actionEvidenceReceiptForCurrentTurn();
|
|
230337
|
+
assertActionCheckpointEvidenceBasis(state.actionCheckpoint, input, runtimeEvidence);
|
|
230336
230338
|
state.actionCheckpoint = normalizeActionCheckpoint(input, {
|
|
230337
|
-
runtimeEvidence
|
|
230339
|
+
runtimeEvidence
|
|
230338
230340
|
});
|
|
230339
230341
|
this.persistState(state, { change: { kind: "progress", actor } });
|
|
230340
230342
|
this.appendGoalUpdate({ actionCheckpoint: state.actionCheckpoint, actor });
|
|
@@ -245730,6 +245732,7 @@ var init_events$1 = __esmMin((() => {
|
|
|
245730
245732
|
actionCheckpoint: object({
|
|
245731
245733
|
revision: number$1().int().min(1),
|
|
245732
245734
|
phase: _enum(["orient", "plan", "act", "verify", "learn", "wait"]),
|
|
245735
|
+
evidenceBasis: _enum(["runtime_tool", "user_statement", "external_report", "carried_forward", "legacy_unknown"]),
|
|
245733
245736
|
lastVerified: string(),
|
|
245734
245737
|
nextAction: string(),
|
|
245735
245738
|
expectedEvidence: string(),
|
|
@@ -262697,7 +262700,7 @@ var init_outcome_prompts = __esmMin((() => {}));
|
|
|
262697
262700
|
//#region ../../packages/agent-core/src/tools/builtin/goal/update-goal.md?raw
|
|
262698
262701
|
var update_goal_default;
|
|
262699
262702
|
var init_update_goal$1 = __esmMin((() => {
|
|
262700
|
-
update_goal_default = "Update the current autonomous goal. Set `status` only for a lifecycle change. After a coherent work slice, save `actionCheckpoint` with a monotone revision, the last verified result, exact next action, and
|
|
262703
|
+
update_goal_default = "Update the current autonomous goal. Set `status` only for a lifecycle change. After a coherent work slice, save `actionCheckpoint` with a monotone revision, the last verified result, exact next action, expected evidence, and an explicit evidence basis. Use `runtime_tool` only when a successful tool in this turn measured the result; use `user_statement` for a direct user assertion, `external_report` for a report not independently measured here, and `carried_forward` only when the last verified text is unchanged. Start at revision 1 and increment the currently projected revision by exactly one; stale writers fail closed. This is durable progress state, not permission, and should change only when the facts change. A checkpoint-only call keeps the goal active.\n\n- `active` — resume a paused or blocked goal when the user explicitly asks you to work on that goal.\n- `complete` — the objective is fully satisfied, all files are written, all tests pass, and any stated validation has passed.\n- `blocked` — a genuine external condition or required user decision prevents progress.\n- `paused` — set the goal aside for now.\n\nDo not mark complete after a plan or partial result. If useful work remains, checkpoint it and continue. Do not ask for permission merely to execute an already authorized checkpoint; ask only at a real rights boundary or missing user decision.\n";
|
|
262701
262704
|
}));
|
|
262702
262705
|
//#endregion
|
|
262703
262706
|
//#region ../../packages/agent-core/src/tools/builtin/goal/update-goal.ts
|
|
@@ -262711,6 +262714,7 @@ var init_update_goal = __esmMin((() => {
|
|
|
262711
262714
|
ActionCheckpointInputSchema = object({
|
|
262712
262715
|
revision: number$1().int().min(1),
|
|
262713
262716
|
phase: _enum(["orient", "plan", "act", "verify", "learn", "wait"]),
|
|
262717
|
+
evidenceBasis: _enum(["runtime_tool", "user_statement", "external_report", "carried_forward"]),
|
|
262714
262718
|
lastVerified: string().min(1).max(512),
|
|
262715
262719
|
nextAction: string().min(1).max(512),
|
|
262716
262720
|
expectedEvidence: string().min(1).max(512)
|