@ouro.bot/cli 0.1.0-alpha.695 → 0.1.0-alpha.697
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.json +15 -0
- package/dist/arc/flight-recorder.js +139 -21
- package/dist/arc/obligations.js +28 -6
- package/dist/arc/packets.js +48 -0
- package/dist/heart/autonomy-budget.js +434 -0
- package/dist/heart/core.js +11 -0
- package/dist/heart/daemon/cadence.js +110 -0
- package/dist/heart/daemon/cli-exec.js +20 -0
- package/dist/heart/daemon/cli-help.js +74 -0
- package/dist/heart/daemon/cli-parse.js +466 -0
- package/dist/heart/daemon/daemon.js +24 -3
- package/dist/heart/daemon/doctor.js +151 -0
- package/dist/heart/daemon/stale-bundle-prune.js +23 -6
- package/dist/heart/habits/habit-parser.js +4 -1
- package/dist/heart/habits/habit-scheduler.js +46 -38
- package/dist/heart/habits/habit-session.js +2 -3
- package/dist/heart/run-ledger.js +247 -0
- package/dist/heart/runtime-credentials.js +12 -3
- package/dist/heart/work-card.js +1 -11
- package/dist/mind/prompt-budget.js +380 -0
- package/dist/repertoire/tools-base.js +2 -0
- package/dist/repertoire/tools-obligations.js +39 -0
- package/dist/repertoire/tools-rsvp.js +139 -0
- package/dist/rsvp/aisleplanner-client.js +354 -0
- package/dist/rsvp/cli.js +679 -0
- package/dist/rsvp/config.js +327 -0
- package/dist/rsvp/cutover.js +431 -0
- package/dist/rsvp/diagnostics.js +222 -0
- package/dist/rsvp/diff-renderer.js +159 -0
- package/dist/rsvp/habit-policy.js +85 -0
- package/dist/rsvp/habit-stage.js +93 -0
- package/dist/rsvp/incident-bundle.js +97 -0
- package/dist/rsvp/migration.js +204 -0
- package/dist/rsvp/outbound-state.js +254 -0
- package/dist/rsvp/query.js +118 -0
- package/dist/rsvp/replay.js +233 -0
- package/dist/rsvp/snapshot.js +232 -0
- package/dist/senses/bluebubbles/client.js +13 -7
- package/dist/senses/bluebubbles/index.js +227 -22
- package/dist/senses/bluebubbles/outbound-state.js +304 -0
- package/dist/senses/bluebubbles/replay.js +147 -0
- package/dist/senses/context-packet-ledger.js +245 -0
- package/dist/senses/context-packets.js +154 -0
- package/dist/senses/pipeline.js +92 -12
- package/dist/senses/private-runtime-worker.js +170 -31
- package/dist/senses/private-runtime.js +13 -1
- package/dist/senses/voice/twilio-phone.js +9 -5
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
|
|
3
3
|
"versions": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.1.0-alpha.697",
|
|
6
|
+
"changes": [
|
|
7
|
+
"Add BlueBubbles same-thread context, native RSVP habit, autonomy budgets, run ledger attribution, diagnostics, cutover, and verification guardrails.",
|
|
8
|
+
"Harden Twilio phone agent-root resolution so test and runtime callers use explicit bundle roots without falling back to the host AgentBundles tree.",
|
|
9
|
+
"Gate native RSVP live sends on a current passing legacy cutover check so refreshes and smoke tests cannot compete with the old RSVP sender.",
|
|
10
|
+
"Align RSVP doctor cutover preflight with the native config's legacy root so triage reports the same sender state enforced by live sends."
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"version": "0.1.0-alpha.696",
|
|
15
|
+
"changes": [
|
|
16
|
+
"Prevent completed return-work packets from re-entering active Arc state."
|
|
17
|
+
]
|
|
18
|
+
},
|
|
4
19
|
{
|
|
5
20
|
"version": "0.1.0-alpha.695",
|
|
6
21
|
"changes": [
|
|
@@ -51,6 +51,7 @@ const crypto_1 = require("crypto");
|
|
|
51
51
|
const session_events_1 = require("../heart/session-events");
|
|
52
52
|
const runtime_1 = require("../nerves/runtime");
|
|
53
53
|
const obligations_1 = require("./obligations");
|
|
54
|
+
const packets_1 = require("./packets");
|
|
54
55
|
function isHabitRunTrigger(value) {
|
|
55
56
|
return value === "cron"
|
|
56
57
|
|| value === "launchd"
|
|
@@ -235,10 +236,16 @@ function remainingArcWorkDescriptions(resume) {
|
|
|
235
236
|
...resume.openEvolutionCaseIds.map((id) => `evolution case ${id}`),
|
|
236
237
|
];
|
|
237
238
|
}
|
|
238
|
-
function nextSafeActionAfterObligationReconcile(resume, activeObligations, staleActiveObligationIds, unverifiableActiveObligationIds) {
|
|
239
|
+
function nextSafeActionAfterObligationReconcile(resume, activeObligations, staleActiveObligationIds, unverifiableActiveObligationIds, staleActiveReturnObligationIds, unverifiableActiveReturnObligationIds, staleActivePacketIds, unverifiableActivePacketIds) {
|
|
239
240
|
if (unverifiableActiveObligationIds.length > 0) {
|
|
240
241
|
return (0, session_events_1.capStructuredRecordString)(`inspect unverifiable active obligations before acting: ${unverifiableActiveObligationIds.join(", ")}`);
|
|
241
242
|
}
|
|
243
|
+
if (unverifiableActiveReturnObligationIds.length > 0) {
|
|
244
|
+
return (0, session_events_1.capStructuredRecordString)(`inspect unverifiable active return obligations before acting: ${unverifiableActiveReturnObligationIds.join(", ")}`);
|
|
245
|
+
}
|
|
246
|
+
if (unverifiableActivePacketIds.length > 0) {
|
|
247
|
+
return (0, session_events_1.capStructuredRecordString)(`inspect unverifiable active packets before acting: ${unverifiableActivePacketIds.join(", ")}`);
|
|
248
|
+
}
|
|
242
249
|
const firstActive = activeObligations[0];
|
|
243
250
|
if (firstActive) {
|
|
244
251
|
const detail = firstActive.nextAction?.trim() || firstActive.content;
|
|
@@ -248,11 +255,56 @@ function nextSafeActionAfterObligationReconcile(resume, activeObligations, stale
|
|
|
248
255
|
if (remainingWork.length > 0) {
|
|
249
256
|
return (0, session_events_1.capStructuredRecordString)(`continue remaining Arc work: ${remainingWork.slice(0, 5).join(", ")}`);
|
|
250
257
|
}
|
|
251
|
-
|
|
258
|
+
if (staleActiveObligationIds.length > 0) {
|
|
259
|
+
return (0, session_events_1.capStructuredRecordString)(`wait for new input; reconciled completed or missing obligations: ${staleActiveObligationIds.join(", ")}`);
|
|
260
|
+
}
|
|
261
|
+
if (staleActiveReturnObligationIds.length > 0) {
|
|
262
|
+
return (0, session_events_1.capStructuredRecordString)(`wait for new input; reconciled completed or missing return obligations: ${staleActiveReturnObligationIds.join(", ")}`);
|
|
263
|
+
}
|
|
264
|
+
return (0, session_events_1.capStructuredRecordString)(`wait for new input; reconciled completed or missing packets: ${staleActivePacketIds.join(", ")}`);
|
|
265
|
+
}
|
|
266
|
+
function reconcileActiveReturnObligationIds(resume, returnObligations, activeReturnObligations) {
|
|
267
|
+
const canonicalIdSet = new Set(returnObligations.map((obligation) => obligation.id));
|
|
268
|
+
const activeIdSet = new Set(activeReturnObligations.map((obligation) => obligation.id));
|
|
269
|
+
const resumeIdSet = new Set(resume.activeReturnObligationIds);
|
|
270
|
+
const staleActiveReturnObligationIds = resume.activeReturnObligationIds.filter((id) => canonicalIdSet.has(id) && !activeIdSet.has(id));
|
|
271
|
+
const unverifiableActiveReturnObligationIds = resume.activeReturnObligationIds.filter((id) => !canonicalIdSet.has(id));
|
|
272
|
+
const missingActiveReturnObligationIds = activeReturnObligations
|
|
273
|
+
.map((obligation) => obligation.id)
|
|
274
|
+
.filter((id) => !resumeIdSet.has(id));
|
|
275
|
+
const activeReturnObligationIds = uniqueStrings([
|
|
276
|
+
...resume.activeReturnObligationIds.filter((id) => !staleActiveReturnObligationIds.includes(id)),
|
|
277
|
+
...missingActiveReturnObligationIds,
|
|
278
|
+
]);
|
|
279
|
+
return {
|
|
280
|
+
activeReturnObligationIds,
|
|
281
|
+
staleActiveReturnObligationIds,
|
|
282
|
+
missingActiveReturnObligationIds,
|
|
283
|
+
unverifiableActiveReturnObligationIds,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function reconcileActivePacketIds(resume, packets, activePackets) {
|
|
287
|
+
const canonicalIdSet = new Set(packets.map((packet) => packet.id));
|
|
288
|
+
const activeIdSet = new Set(activePackets.map((packet) => packet.id));
|
|
289
|
+
const resumeIdSet = new Set(resume.activePacketIds);
|
|
290
|
+
const staleActivePacketIds = resume.activePacketIds.filter((id) => canonicalIdSet.has(id) && !activeIdSet.has(id));
|
|
291
|
+
const unverifiableActivePacketIds = resume.activePacketIds.filter((id) => !canonicalIdSet.has(id));
|
|
292
|
+
const missingActivePacketIds = activePackets
|
|
293
|
+
.map((packet) => packet.id)
|
|
294
|
+
.filter((id) => !resumeIdSet.has(id));
|
|
295
|
+
const activePacketIds = uniqueStrings([
|
|
296
|
+
...resume.activePacketIds.filter((id) => !staleActivePacketIds.includes(id)),
|
|
297
|
+
...missingActivePacketIds,
|
|
298
|
+
]);
|
|
299
|
+
return { activePacketIds, staleActivePacketIds, missingActivePacketIds, unverifiableActivePacketIds };
|
|
252
300
|
}
|
|
253
301
|
function reconcileActiveObligations(agentRoot, resume) {
|
|
254
302
|
const obligations = (0, obligations_1.readVerifiedObligations)(agentRoot);
|
|
255
303
|
const activeObligations = (0, obligations_1.readVerifiedPendingObligations)(agentRoot);
|
|
304
|
+
const returnObligations = (0, obligations_1.listReturnObligationsForRoot)(agentRoot);
|
|
305
|
+
const activeReturnObligations = (0, obligations_1.listActiveReturnObligationsForRoot)(agentRoot);
|
|
306
|
+
const packets = (0, packets_1.listPonderPackets)(agentRoot);
|
|
307
|
+
const activePackets = (0, packets_1.listActivePonderPackets)(agentRoot);
|
|
256
308
|
const canonicalIdSet = new Set(obligations.map((obligation) => obligation.id));
|
|
257
309
|
const openIdSet = new Set(activeObligations.map((obligation) => obligation.id));
|
|
258
310
|
const resumeIdSet = new Set(resume.activeObligationIds);
|
|
@@ -261,33 +313,66 @@ function reconcileActiveObligations(agentRoot, resume) {
|
|
|
261
313
|
const missingActiveObligationIds = activeObligations
|
|
262
314
|
.map((obligation) => obligation.id)
|
|
263
315
|
.filter((id) => !resumeIdSet.has(id));
|
|
316
|
+
const { activeReturnObligationIds, staleActiveReturnObligationIds, missingActiveReturnObligationIds, unverifiableActiveReturnObligationIds, } = reconcileActiveReturnObligationIds(resume, returnObligations, activeReturnObligations);
|
|
317
|
+
const { activePacketIds, staleActivePacketIds, missingActivePacketIds, unverifiableActivePacketIds, } = reconcileActivePacketIds(resume, packets, activePackets);
|
|
264
318
|
if (staleActiveObligationIds.length === 0
|
|
265
319
|
&& missingActiveObligationIds.length === 0
|
|
266
|
-
&& unverifiableActiveObligationIds.length === 0
|
|
267
|
-
|
|
320
|
+
&& unverifiableActiveObligationIds.length === 0
|
|
321
|
+
&& staleActiveReturnObligationIds.length === 0
|
|
322
|
+
&& missingActiveReturnObligationIds.length === 0
|
|
323
|
+
&& unverifiableActiveReturnObligationIds.length === 0
|
|
324
|
+
&& staleActivePacketIds.length === 0
|
|
325
|
+
&& missingActivePacketIds.length === 0
|
|
326
|
+
&& unverifiableActivePacketIds.length === 0) {
|
|
327
|
+
return {
|
|
328
|
+
resume,
|
|
329
|
+
staleActiveObligationIds,
|
|
330
|
+
missingActiveObligationIds,
|
|
331
|
+
unverifiableActiveObligationIds,
|
|
332
|
+
staleActiveReturnObligationIds,
|
|
333
|
+
missingActiveReturnObligationIds,
|
|
334
|
+
unverifiableActiveReturnObligationIds,
|
|
335
|
+
staleActivePacketIds,
|
|
336
|
+
missingActivePacketIds,
|
|
337
|
+
unverifiableActivePacketIds,
|
|
338
|
+
};
|
|
268
339
|
}
|
|
269
340
|
const activeObligationIds = uniqueStrings([
|
|
270
341
|
...resume.activeObligationIds.filter((id) => !staleActiveObligationIds.includes(id)),
|
|
271
342
|
...missingActiveObligationIds,
|
|
272
343
|
]);
|
|
273
344
|
const hasActiveArcContinuation = activeObligationIds.length > 0
|
|
274
|
-
||
|
|
275
|
-
||
|
|
345
|
+
|| activeReturnObligationIds.length > 0
|
|
346
|
+
|| activePacketIds.length > 0
|
|
276
347
|
|| resume.openEvolutionCaseIds.length > 0;
|
|
277
|
-
const isTerminalWait = staleActiveObligationIds.length > 0
|
|
348
|
+
const isTerminalWait = (staleActiveObligationIds.length > 0
|
|
349
|
+
|| staleActiveReturnObligationIds.length > 0
|
|
350
|
+
|| staleActivePacketIds.length > 0) && !hasActiveArcContinuation;
|
|
278
351
|
const mustSynthesizeAction = staleActiveObligationIds.length > 0
|
|
279
352
|
|| unverifiableActiveObligationIds.length > 0
|
|
353
|
+
|| staleActiveReturnObligationIds.length > 0
|
|
354
|
+
|| unverifiableActiveReturnObligationIds.length > 0
|
|
355
|
+
|| staleActivePacketIds.length > 0
|
|
356
|
+
|| unverifiableActivePacketIds.length > 0
|
|
280
357
|
|| !nonEmpty(resume.nextSafeAction.value);
|
|
281
358
|
const nextSafeActionValue = mustSynthesizeAction
|
|
282
|
-
? nextSafeActionAfterObligationReconcile(resume, activeObligations, staleActiveObligationIds, unverifiableActiveObligationIds)
|
|
359
|
+
? nextSafeActionAfterObligationReconcile({ ...resume, activeObligationIds, activeReturnObligationIds, activePacketIds }, activeObligations, staleActiveObligationIds, unverifiableActiveObligationIds, staleActiveReturnObligationIds, unverifiableActiveReturnObligationIds, staleActivePacketIds, unverifiableActivePacketIds)
|
|
283
360
|
: resume.nextSafeAction.value;
|
|
284
|
-
const
|
|
361
|
+
const unverifiableIssues = [
|
|
362
|
+
...(unverifiableActiveObligationIds.length > 0
|
|
363
|
+
? [`active obligation ids could not be verified in arc/obligations: ${unverifiableActiveObligationIds.join(", ")}`]
|
|
364
|
+
: []),
|
|
365
|
+
...(unverifiableActiveReturnObligationIds.length > 0
|
|
366
|
+
? [`active return obligation ids could not be verified in arc/obligations/inner: ${unverifiableActiveReturnObligationIds.join(", ")}`]
|
|
367
|
+
: []),
|
|
368
|
+
...(unverifiableActivePacketIds.length > 0
|
|
369
|
+
? [`active packet ids could not be verified in arc/packets: ${unverifiableActivePacketIds.join(", ")}`]
|
|
370
|
+
: []),
|
|
371
|
+
];
|
|
372
|
+
const recorderHealth = unverifiableIssues.length > 0
|
|
285
373
|
? {
|
|
286
374
|
status: resume.recorderHealth.status === "unavailable" ? "unavailable" : "degraded",
|
|
287
|
-
issues: uniqueStrings([
|
|
288
|
-
...resume.recorderHealth.issues,
|
|
289
|
-
`active obligation ids could not be verified in arc/obligations: ${unverifiableActiveObligationIds.join(", ")}`,
|
|
290
|
-
]),
|
|
375
|
+
issues: uniqueStrings([...resume.recorderHealth.issues, ...unverifiableIssues]),
|
|
291
376
|
}
|
|
292
377
|
: resume.recorderHealth;
|
|
293
378
|
const canContinue = nonEmpty(resume.currentAsk.value)
|
|
@@ -302,6 +387,8 @@ function reconcileActiveObligations(agentRoot, resume) {
|
|
|
302
387
|
canContinue,
|
|
303
388
|
recorderHealth,
|
|
304
389
|
activeObligationIds,
|
|
390
|
+
activeReturnObligationIds,
|
|
391
|
+
activePacketIds,
|
|
305
392
|
nextSafeAction: {
|
|
306
393
|
...resume.nextSafeAction,
|
|
307
394
|
value: nextSafeActionValue,
|
|
@@ -309,22 +396,41 @@ function reconcileActiveObligations(agentRoot, resume) {
|
|
|
309
396
|
? [FLIGHT_RECORDER_RECONCILE_SOURCE_ID]
|
|
310
397
|
: resume.nextSafeAction.sourceEventIds,
|
|
311
398
|
stopBefore: unverifiableActiveObligationIds.length > 0
|
|
312
|
-
|
|
399
|
+
|| unverifiableActiveReturnObligationIds.length > 0
|
|
400
|
+
|| unverifiableActivePacketIds.length > 0
|
|
401
|
+
? uniqueStrings([
|
|
402
|
+
...resume.nextSafeAction.stopBefore,
|
|
403
|
+
...(unverifiableActiveObligationIds.length > 0 ? ["acting on unverifiable obligation state"] : []),
|
|
404
|
+
...(unverifiableActiveReturnObligationIds.length > 0 ? ["acting on unverifiable return obligation state"] : []),
|
|
405
|
+
...(unverifiableActivePacketIds.length > 0 ? ["acting on unverifiable packet state"] : []),
|
|
406
|
+
])
|
|
313
407
|
: resume.nextSafeAction.stopBefore,
|
|
314
408
|
},
|
|
315
409
|
}),
|
|
316
410
|
staleActiveObligationIds,
|
|
317
411
|
missingActiveObligationIds,
|
|
318
412
|
unverifiableActiveObligationIds,
|
|
413
|
+
staleActiveReturnObligationIds,
|
|
414
|
+
missingActiveReturnObligationIds,
|
|
415
|
+
unverifiableActiveReturnObligationIds,
|
|
416
|
+
staleActivePacketIds,
|
|
417
|
+
missingActivePacketIds,
|
|
418
|
+
unverifiableActivePacketIds,
|
|
319
419
|
};
|
|
320
420
|
}
|
|
321
421
|
function normalizeResumeForAgentRoot(agentRoot, resume) {
|
|
322
422
|
return reconcileActiveObligations(agentRoot, normalizeResumeInvariants(resume));
|
|
323
423
|
}
|
|
324
|
-
function emitFlightRecorderReconciled(agentRoot, staleActiveObligationIds, missingActiveObligationIds, unverifiableActiveObligationIds) {
|
|
424
|
+
function emitFlightRecorderReconciled(agentRoot, staleActiveObligationIds, missingActiveObligationIds, unverifiableActiveObligationIds, staleActiveReturnObligationIds, missingActiveReturnObligationIds, unverifiableActiveReturnObligationIds, staleActivePacketIds, missingActivePacketIds, unverifiableActivePacketIds) {
|
|
325
425
|
if (staleActiveObligationIds.length === 0
|
|
326
426
|
&& missingActiveObligationIds.length === 0
|
|
327
|
-
&& unverifiableActiveObligationIds.length === 0
|
|
427
|
+
&& unverifiableActiveObligationIds.length === 0
|
|
428
|
+
&& staleActiveReturnObligationIds.length === 0
|
|
429
|
+
&& missingActiveReturnObligationIds.length === 0
|
|
430
|
+
&& unverifiableActiveReturnObligationIds.length === 0
|
|
431
|
+
&& staleActivePacketIds.length === 0
|
|
432
|
+
&& missingActivePacketIds.length === 0
|
|
433
|
+
&& unverifiableActivePacketIds.length === 0)
|
|
328
434
|
return;
|
|
329
435
|
(0, runtime_1.emitNervesEvent)({
|
|
330
436
|
component: "mind",
|
|
@@ -335,6 +441,12 @@ function emitFlightRecorderReconciled(agentRoot, staleActiveObligationIds, missi
|
|
|
335
441
|
staleActiveObligationIds,
|
|
336
442
|
missingActiveObligationIds,
|
|
337
443
|
unverifiableActiveObligationIds,
|
|
444
|
+
staleActiveReturnObligationIds,
|
|
445
|
+
missingActiveReturnObligationIds,
|
|
446
|
+
unverifiableActiveReturnObligationIds,
|
|
447
|
+
staleActivePacketIds,
|
|
448
|
+
missingActivePacketIds,
|
|
449
|
+
unverifiableActivePacketIds,
|
|
338
450
|
},
|
|
339
451
|
});
|
|
340
452
|
}
|
|
@@ -390,11 +502,17 @@ function readFlightRecorderResume(agentRoot) {
|
|
|
390
502
|
if (!isFlightRecorderResume(parsed)) {
|
|
391
503
|
throw new Error("latest.json has invalid flight-recorder resume shape");
|
|
392
504
|
}
|
|
393
|
-
const { resume, staleActiveObligationIds, missingActiveObligationIds, unverifiableActiveObligationIds, } = normalizeResumeForAgentRoot(agentRoot, parsed);
|
|
505
|
+
const { resume, staleActiveObligationIds, missingActiveObligationIds, unverifiableActiveObligationIds, staleActiveReturnObligationIds, missingActiveReturnObligationIds, unverifiableActiveReturnObligationIds, staleActivePacketIds, missingActivePacketIds, unverifiableActivePacketIds, } = normalizeResumeForAgentRoot(agentRoot, parsed);
|
|
394
506
|
if (staleActiveObligationIds.length > 0
|
|
395
507
|
|| missingActiveObligationIds.length > 0
|
|
396
|
-
|| unverifiableActiveObligationIds.length > 0
|
|
397
|
-
|
|
508
|
+
|| unverifiableActiveObligationIds.length > 0
|
|
509
|
+
|| staleActiveReturnObligationIds.length > 0
|
|
510
|
+
|| missingActiveReturnObligationIds.length > 0
|
|
511
|
+
|| unverifiableActiveReturnObligationIds.length > 0
|
|
512
|
+
|| staleActivePacketIds.length > 0
|
|
513
|
+
|| missingActivePacketIds.length > 0
|
|
514
|
+
|| unverifiableActivePacketIds.length > 0) {
|
|
515
|
+
emitFlightRecorderReconciled(agentRoot, staleActiveObligationIds, missingActiveObligationIds, unverifiableActiveObligationIds, staleActiveReturnObligationIds, missingActiveReturnObligationIds, unverifiableActiveReturnObligationIds, staleActivePacketIds, missingActivePacketIds, unverifiableActivePacketIds);
|
|
398
516
|
}
|
|
399
517
|
(0, runtime_1.emitNervesEvent)({
|
|
400
518
|
component: "mind",
|
|
@@ -418,9 +536,9 @@ function readFlightRecorderResume(agentRoot) {
|
|
|
418
536
|
}
|
|
419
537
|
}
|
|
420
538
|
function writeFlightRecorderResume(agentRoot, resume) {
|
|
421
|
-
const { resume: safeResume, staleActiveObligationIds, missingActiveObligationIds, unverifiableActiveObligationIds, } = normalizeResumeForAgentRoot(agentRoot, resume);
|
|
539
|
+
const { resume: safeResume, staleActiveObligationIds, missingActiveObligationIds, unverifiableActiveObligationIds, staleActiveReturnObligationIds, missingActiveReturnObligationIds, unverifiableActiveReturnObligationIds, staleActivePacketIds, missingActivePacketIds, unverifiableActivePacketIds, } = normalizeResumeForAgentRoot(agentRoot, resume);
|
|
422
540
|
atomicWriteJson(flightRecorderLatestPath(agentRoot), safeResume);
|
|
423
|
-
emitFlightRecorderReconciled(agentRoot, staleActiveObligationIds, missingActiveObligationIds, unverifiableActiveObligationIds);
|
|
541
|
+
emitFlightRecorderReconciled(agentRoot, staleActiveObligationIds, missingActiveObligationIds, unverifiableActiveObligationIds, staleActiveReturnObligationIds, missingActiveReturnObligationIds, unverifiableActiveReturnObligationIds, staleActivePacketIds, missingActivePacketIds, unverifiableActivePacketIds);
|
|
424
542
|
(0, runtime_1.emitNervesEvent)({
|
|
425
543
|
component: "mind",
|
|
426
544
|
event: "mind.flight_recorder_resume_written",
|
package/dist/arc/obligations.js
CHANGED
|
@@ -33,6 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.readObligation = readObligation;
|
|
36
37
|
exports.isOpenObligationStatus = isOpenObligationStatus;
|
|
37
38
|
exports.isOpenObligation = isOpenObligation;
|
|
38
39
|
exports.createObligation = createObligation;
|
|
@@ -49,7 +50,11 @@ exports.getReturnObligationsDir = getReturnObligationsDir;
|
|
|
49
50
|
exports.getReturnObligationsDirForRoot = getReturnObligationsDirForRoot;
|
|
50
51
|
exports.createReturnObligation = createReturnObligation;
|
|
51
52
|
exports.readReturnObligation = readReturnObligation;
|
|
53
|
+
exports.readReturnObligationForRoot = readReturnObligationForRoot;
|
|
52
54
|
exports.advanceReturnObligation = advanceReturnObligation;
|
|
55
|
+
exports.isActiveReturnObligationStatus = isActiveReturnObligationStatus;
|
|
56
|
+
exports.listReturnObligationsForRoot = listReturnObligationsForRoot;
|
|
57
|
+
exports.isActiveReturnObligationRecord = isActiveReturnObligationRecord;
|
|
53
58
|
exports.listActiveReturnObligations = listActiveReturnObligations;
|
|
54
59
|
exports.listActiveReturnObligationsForRoot = listActiveReturnObligationsForRoot;
|
|
55
60
|
const path = __importStar(require("path"));
|
|
@@ -60,6 +65,9 @@ const json_store_1 = require("./json-store");
|
|
|
60
65
|
function obligationsDir(agentRoot) {
|
|
61
66
|
return path.join(agentRoot, "arc", "obligations");
|
|
62
67
|
}
|
|
68
|
+
function readObligation(agentRoot, obligationId) {
|
|
69
|
+
return (0, json_store_1.readJsonFile)(obligationsDir(agentRoot), obligationId);
|
|
70
|
+
}
|
|
63
71
|
function isOpenObligationStatus(status) {
|
|
64
72
|
return status !== "fulfilled";
|
|
65
73
|
}
|
|
@@ -256,6 +264,9 @@ function createReturnObligation(agentName, obligation) {
|
|
|
256
264
|
function readReturnObligation(agentName, obligationId) {
|
|
257
265
|
return (0, json_store_1.readJsonFile)(getReturnObligationsDir(agentName), obligationId);
|
|
258
266
|
}
|
|
267
|
+
function readReturnObligationForRoot(agentRoot, obligationId) {
|
|
268
|
+
return (0, json_store_1.readJsonFile)(getReturnObligationsDirForRoot(agentRoot), obligationId);
|
|
269
|
+
}
|
|
259
270
|
function advanceReturnObligation(agentName, obligationId, update) {
|
|
260
271
|
const existing = readReturnObligation(agentName, obligationId);
|
|
261
272
|
if (!existing)
|
|
@@ -295,6 +306,9 @@ const RETURN_OBLIGATION_INJECTION_MAX_AGE_MS = 14 * 24 * 60 * 60 * 1000;
|
|
|
295
306
|
// surface-tool boundary) is treated as terminal — i.e., we do not re-inject
|
|
296
307
|
// it. This is a read-time defense; the underlying file is left as-is.
|
|
297
308
|
const ACTIVE_RETURN_OBLIGATION_STATUSES = new Set(["queued", "running"]);
|
|
309
|
+
function isActiveReturnObligationStatus(status) {
|
|
310
|
+
return ACTIVE_RETURN_OBLIGATION_STATUSES.has(status);
|
|
311
|
+
}
|
|
298
312
|
function isSelfInnerReturnObligation(obligation) {
|
|
299
313
|
return obligation.origin?.friendId === "self" && obligation.origin.channel === "inner";
|
|
300
314
|
}
|
|
@@ -311,16 +325,24 @@ function isReturnObligationRecord(value) {
|
|
|
311
325
|
&& typeof candidate.origin.channel === "string"
|
|
312
326
|
&& typeof candidate.origin.key === "string";
|
|
313
327
|
}
|
|
328
|
+
function listReturnObligationsForRoot(agentRoot) {
|
|
329
|
+
return (0, json_store_1.readJsonDir)(getReturnObligationsDirForRoot(agentRoot))
|
|
330
|
+
.filter(isReturnObligationRecord);
|
|
331
|
+
}
|
|
332
|
+
function isActiveReturnObligationRecord(value, options = {}) {
|
|
333
|
+
if (!isReturnObligationRecord(value))
|
|
334
|
+
return false;
|
|
335
|
+
const nowMs = (options.now ?? Date.now)();
|
|
336
|
+
return isActiveReturnObligationStatus(value.status)
|
|
337
|
+
&& !isSelfInnerReturnObligation(value)
|
|
338
|
+
&& nowMs - value.createdAt <= RETURN_OBLIGATION_INJECTION_MAX_AGE_MS;
|
|
339
|
+
}
|
|
314
340
|
function listActiveReturnObligations(agentName, options = {}) {
|
|
315
341
|
return listActiveReturnObligationsForRoot((0, identity_1.getAgentRoot)(agentName), options);
|
|
316
342
|
}
|
|
317
343
|
function listActiveReturnObligationsForRoot(agentRoot, options = {}) {
|
|
318
|
-
const all = (0, json_store_1.readJsonDir)(getReturnObligationsDirForRoot(agentRoot));
|
|
319
344
|
const nowMs = (options.now ?? Date.now)();
|
|
320
|
-
return
|
|
321
|
-
.filter(
|
|
322
|
-
.filter((parsed) => ACTIVE_RETURN_OBLIGATION_STATUSES.has(parsed.status))
|
|
323
|
-
.filter((parsed) => !isSelfInnerReturnObligation(parsed))
|
|
324
|
-
.filter((parsed) => nowMs - parsed.createdAt <= RETURN_OBLIGATION_INJECTION_MAX_AGE_MS)
|
|
345
|
+
return listReturnObligationsForRoot(agentRoot)
|
|
346
|
+
.filter((parsed) => isActiveReturnObligationRecord(parsed, { now: () => nowMs }))
|
|
325
347
|
.sort((a, b) => a.createdAt - b.createdAt);
|
|
326
348
|
}
|
package/dist/arc/packets.js
CHANGED
|
@@ -33,9 +33,16 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ACTIVE_PONDER_PACKET_STATUSES = void 0;
|
|
36
37
|
exports.getPonderPacketArtifactsDir = getPonderPacketArtifactsDir;
|
|
38
|
+
exports.isActivePonderPacketStatus = isActivePonderPacketStatus;
|
|
39
|
+
exports.isActivePonderPacket = isActivePonderPacket;
|
|
37
40
|
exports.listPonderPackets = listPonderPackets;
|
|
41
|
+
exports.listActivePonderPackets = listActivePonderPackets;
|
|
38
42
|
exports.readPonderPacket = readPonderPacket;
|
|
43
|
+
exports.findPonderPacketByRelatedReturnObligationId = findPonderPacketByRelatedReturnObligationId;
|
|
44
|
+
exports.listPonderPacketsByRelatedReturnObligationId = listPonderPacketsByRelatedReturnObligationId;
|
|
45
|
+
exports.listPonderPacketsByRelatedObligationId = listPonderPacketsByRelatedObligationId;
|
|
39
46
|
exports.createPonderPacket = createPonderPacket;
|
|
40
47
|
exports.revisePonderPacket = revisePonderPacket;
|
|
41
48
|
exports.advancePonderPacket = advancePonderPacket;
|
|
@@ -46,6 +53,7 @@ const session_events_1 = require("../heart/session-events");
|
|
|
46
53
|
const runtime_1 = require("../nerves/runtime");
|
|
47
54
|
const task_lifecycle_1 = require("./task-lifecycle");
|
|
48
55
|
const json_store_1 = require("./json-store");
|
|
56
|
+
const obligations_1 = require("./obligations");
|
|
49
57
|
const evolution_1 = require("./evolution");
|
|
50
58
|
function packetsDir(agentRoot) {
|
|
51
59
|
return path.join(agentRoot, "arc", "packets");
|
|
@@ -82,6 +90,34 @@ function isPonderPacket(value) {
|
|
|
82
90
|
&& typeof packet.createdAt === "number"
|
|
83
91
|
&& typeof packet.updatedAt === "number";
|
|
84
92
|
}
|
|
93
|
+
exports.ACTIVE_PONDER_PACKET_STATUSES = new Set([
|
|
94
|
+
"drafting",
|
|
95
|
+
"processing",
|
|
96
|
+
"validating",
|
|
97
|
+
"collaborating",
|
|
98
|
+
"paused",
|
|
99
|
+
"blocked",
|
|
100
|
+
]);
|
|
101
|
+
function isActivePonderPacketStatus(status) {
|
|
102
|
+
return exports.ACTIVE_PONDER_PACKET_STATUSES.has(status);
|
|
103
|
+
}
|
|
104
|
+
function hasInactiveLinkedReturnObligation(agentRoot, packet, options = {}) {
|
|
105
|
+
if (!packet.relatedReturnObligationId)
|
|
106
|
+
return false;
|
|
107
|
+
const obligation = (0, obligations_1.readReturnObligationForRoot)(agentRoot, packet.relatedReturnObligationId);
|
|
108
|
+
return !(0, obligations_1.isActiveReturnObligationRecord)(obligation, options);
|
|
109
|
+
}
|
|
110
|
+
function hasFulfilledLinkedObligation(agentRoot, packet) {
|
|
111
|
+
if (!packet.relatedObligationId)
|
|
112
|
+
return false;
|
|
113
|
+
const obligation = (0, obligations_1.readObligation)(agentRoot, packet.relatedObligationId);
|
|
114
|
+
return obligation?.status === "fulfilled";
|
|
115
|
+
}
|
|
116
|
+
function isActivePonderPacket(agentRoot, packet, options = {}) {
|
|
117
|
+
return isActivePonderPacketStatus(packet.status)
|
|
118
|
+
&& !hasInactiveLinkedReturnObligation(agentRoot, packet, options)
|
|
119
|
+
&& !hasFulfilledLinkedObligation(agentRoot, packet);
|
|
120
|
+
}
|
|
85
121
|
function payloadString(payload, key) {
|
|
86
122
|
const value = payload[key];
|
|
87
123
|
return typeof value === "string" && value.trim().length > 0 ? value : null;
|
|
@@ -156,10 +192,22 @@ function listPonderPackets(agentRoot) {
|
|
|
156
192
|
.filter(isPonderPacket)
|
|
157
193
|
.sort((left, right) => left.createdAt - right.createdAt);
|
|
158
194
|
}
|
|
195
|
+
function listActivePonderPackets(agentRoot, options = {}) {
|
|
196
|
+
return listPonderPackets(agentRoot).filter((packet) => isActivePonderPacket(agentRoot, packet, options));
|
|
197
|
+
}
|
|
159
198
|
function readPonderPacket(agentRoot, packetId) {
|
|
160
199
|
const packet = (0, json_store_1.readJsonFile)(packetsDir(agentRoot), packetId);
|
|
161
200
|
return isPonderPacket(packet) ? packet : null;
|
|
162
201
|
}
|
|
202
|
+
function findPonderPacketByRelatedReturnObligationId(agentRoot, relatedReturnObligationId) {
|
|
203
|
+
return listPonderPacketsByRelatedReturnObligationId(agentRoot, relatedReturnObligationId)[0] ?? null;
|
|
204
|
+
}
|
|
205
|
+
function listPonderPacketsByRelatedReturnObligationId(agentRoot, relatedReturnObligationId) {
|
|
206
|
+
return listPonderPackets(agentRoot).filter((packet) => packet.relatedReturnObligationId === relatedReturnObligationId);
|
|
207
|
+
}
|
|
208
|
+
function listPonderPacketsByRelatedObligationId(agentRoot, relatedObligationId) {
|
|
209
|
+
return listPonderPackets(agentRoot).filter((packet) => packet.relatedObligationId === relatedObligationId);
|
|
210
|
+
}
|
|
163
211
|
function createPonderPacket(agentRoot, input) {
|
|
164
212
|
const now = Date.now();
|
|
165
213
|
const packet = bindHarnessFrictionEvolutionCase(agentRoot, {
|