@akagilnc/pi-workflow-roles 0.1.5207 → 0.1.5216
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/README.md +1 -1
- package/dist/acp-host/production-host.js +163 -709
- package/dist/headless-host/production-host.js +139 -685
- package/dist/migrate-book-topology.js +0 -1
- package/dist/public-cli/main.js +0 -2
- package/dist/sitian-appender.js +0 -1
- package/dist/submission-ledger.js +8 -29
- package/dist/ticket-provenance-contracts.js +4 -42
- package/dist/ticket-provenance.js +27 -456
- package/package.json +2 -3
- package/scripts/build-package.mjs +1 -3
- package/src/diarist.ts +5 -5
- package/src/host-contracts.ts +0 -100
- package/src/role-runtime.ts +4 -57
- package/src/sitian-appender.ts +0 -1
- package/src/sitian-contracts.ts +0 -3
- package/src/submission-ledger.ts +10 -31
- package/src/ticket-provenance-contracts.ts +10 -48
- package/src/ticket-provenance.ts +33 -499
- package/dist/pi/in-process-session.js +0 -660
- package/dist/stream-idle-guard.js +0 -67
- package/schemas/tool-execution-observation.schema.json +0 -107
- package/scripts/generate-tool-execution-observation-schema.ts +0 -7
- package/src/in-process-session.ts +0 -1
- package/src/pi/in-process-session.ts +0 -861
- package/src/stream-idle-guard.ts +0 -98
- package/src/tool-execution-observation.ts +0 -168
|
@@ -15038,7 +15038,6 @@ var init_sitian_facade = __esm({
|
|
|
15038
15038
|
var init_ticket_provenance = __esm({
|
|
15039
15039
|
"src/ticket-provenance.ts"() {
|
|
15040
15040
|
"use strict";
|
|
15041
|
-
init_activation_ledger_git();
|
|
15042
15041
|
init_activation_ledger_topology();
|
|
15043
15042
|
init_ledger_session_read();
|
|
15044
15043
|
init_run_ticket_number();
|
package/dist/public-cli/main.js
CHANGED
|
@@ -18101,7 +18101,6 @@ function appendSitianRecord(input) {
|
|
|
18101
18101
|
identity,
|
|
18102
18102
|
...input.subject === void 0 ? {} : { subject: input.subject },
|
|
18103
18103
|
...input.sessionParent === void 0 ? {} : { sessionParent: input.sessionParent },
|
|
18104
|
-
...input.priorEventId === void 0 ? {} : { priorEventId: input.priorEventId },
|
|
18105
18104
|
timestamp: timestamp2,
|
|
18106
18105
|
host,
|
|
18107
18106
|
...input.source === void 0 ? {} : { source: input.source },
|
|
@@ -19273,7 +19272,6 @@ async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, ho
|
|
|
19273
19272
|
var init_ticket_provenance = __esm({
|
|
19274
19273
|
"src/ticket-provenance.ts"() {
|
|
19275
19274
|
"use strict";
|
|
19276
|
-
init_activation_ledger_git();
|
|
19277
19275
|
init_activation_ledger_topology();
|
|
19278
19276
|
init_ledger_session_read();
|
|
19279
19277
|
init_run_ticket_number();
|
package/dist/sitian-appender.js
CHANGED
|
@@ -240,7 +240,6 @@ function appendSitianRecord(input) {
|
|
|
240
240
|
identity,
|
|
241
241
|
...input.subject === void 0 ? {} : { subject: input.subject },
|
|
242
242
|
...input.sessionParent === void 0 ? {} : { sessionParent: input.sessionParent },
|
|
243
|
-
...input.priorEventId === void 0 ? {} : { priorEventId: input.priorEventId },
|
|
244
243
|
timestamp,
|
|
245
244
|
host,
|
|
246
245
|
...input.source === void 0 ? {} : { source: input.source },
|
|
@@ -312,26 +312,14 @@ export async function readLatestSubmissionOutcome(cwd, runId, homeOrScope) {
|
|
|
312
312
|
}
|
|
313
313
|
async function restoreState(cwd, runId, scope) {
|
|
314
314
|
const located = await readOwnedSubmissionRecords(cwd, runId, scope);
|
|
315
|
-
// Unknown-run empty set: no prior chain. Owned rows without a file are an internal bug.
|
|
316
315
|
if (located.file === undefined) {
|
|
317
316
|
if (located.owned.length !== 0) {
|
|
318
317
|
throw new Error(`submission ledger invariant: owned rows present without recordFile for run ${runId}`);
|
|
319
318
|
}
|
|
320
319
|
return { sequence: 0 };
|
|
321
320
|
}
|
|
322
|
-
const {
|
|
323
|
-
const last = owned.at(-1);
|
|
321
|
+
const { owned } = located;
|
|
324
322
|
return {
|
|
325
|
-
...(last === undefined
|
|
326
|
-
? {}
|
|
327
|
-
: {
|
|
328
|
-
prior: {
|
|
329
|
-
identity: last.identity,
|
|
330
|
-
recordFile: file,
|
|
331
|
-
kind: last.kind,
|
|
332
|
-
level: last.level,
|
|
333
|
-
},
|
|
334
|
-
}),
|
|
335
323
|
sequence: owned.reduce((maximum, record) => {
|
|
336
324
|
const payload = record.payload;
|
|
337
325
|
return payload?.type === "candidate" && typeof payload.sequence === "number"
|
|
@@ -362,7 +350,7 @@ function homeFromHostContext(context, home) {
|
|
|
362
350
|
}
|
|
363
351
|
/**
|
|
364
352
|
* #959: seal one accepted submission without a model tool call.
|
|
365
|
-
* Same ledger row shape
|
|
353
|
+
* Same ledger row shape as the terminating-tool wrap.
|
|
366
354
|
* Used when a prose-exit seat (navigator) harvests the final assistant text.
|
|
367
355
|
*/
|
|
368
356
|
export async function sealAcceptedSubmission(options) {
|
|
@@ -370,15 +358,10 @@ export async function sealAcceptedSubmission(options) {
|
|
|
370
358
|
const attemptId = attemptIdentity(options.context, runId);
|
|
371
359
|
const sessionParent = sessionParentFromHostContext(options.context);
|
|
372
360
|
const home = homeFromHostContext(options.context, options.home);
|
|
373
|
-
|
|
374
|
-
...(home === undefined ? {} : { home }),
|
|
375
|
-
...(sessionParent === undefined ? {} : { sessionParent }),
|
|
376
|
-
});
|
|
377
|
-
const pointer = sitianReport({
|
|
361
|
+
sitianReport({
|
|
378
362
|
level: "event",
|
|
379
363
|
kind: "sealed",
|
|
380
364
|
subject: { runId, attemptId },
|
|
381
|
-
...(state.prior === undefined ? {} : { priorEventId: state.prior.identity }),
|
|
382
365
|
payload: {
|
|
383
366
|
type: "sealed",
|
|
384
367
|
attemptId,
|
|
@@ -391,7 +374,6 @@ export async function sealAcceptedSubmission(options) {
|
|
|
391
374
|
...(home !== undefined ? { home } : {}),
|
|
392
375
|
...(sessionParent === undefined ? {} : { sessionParent }),
|
|
393
376
|
});
|
|
394
|
-
state.prior = pointer;
|
|
395
377
|
}
|
|
396
378
|
/**
|
|
397
379
|
* Submission ledger host — record only (#836).
|
|
@@ -412,31 +394,28 @@ export function createSubmissionLedgerHost(host, outputTools, failInfrastructure
|
|
|
412
394
|
states.set(runId, pending);
|
|
413
395
|
return pending;
|
|
414
396
|
})();
|
|
415
|
-
const appendFor = (
|
|
397
|
+
const appendFor = (context, runId, attemptId, event) => {
|
|
416
398
|
const home = resolveHomeFromContext(context);
|
|
417
399
|
const sessionParent = sessionParentFromHostContext(context);
|
|
418
|
-
|
|
400
|
+
return sitianReport({
|
|
419
401
|
level: "event",
|
|
420
402
|
kind: event.type,
|
|
421
403
|
subject: { runId, attemptId },
|
|
422
|
-
...(state.prior === undefined ? {} : { priorEventId: state.prior.identity }),
|
|
423
404
|
payload: event,
|
|
424
405
|
source: "role-runtime",
|
|
425
406
|
cwd: context.cwd,
|
|
426
407
|
...(home !== undefined ? { home } : {}),
|
|
427
408
|
...(sessionParent === undefined ? {} : { sessionParent }),
|
|
428
409
|
});
|
|
429
|
-
state.prior = pointer;
|
|
430
|
-
return pointer;
|
|
431
410
|
};
|
|
432
411
|
host.on("turn_end", async (event, context) => {
|
|
433
412
|
try {
|
|
434
413
|
const runId = runIdentity(context);
|
|
435
414
|
const attemptId = attemptIdentity(context, runId);
|
|
436
|
-
const state = await stateFor(context, runId);
|
|
437
415
|
const calls = event.calls.map(({ toolCallId: id, toolName: name }) => ({ id, name }));
|
|
438
416
|
if (calls.length > 0) {
|
|
439
|
-
|
|
417
|
+
await stateFor(context, runId);
|
|
418
|
+
appendFor(context, runId, attemptId, { type: "roundContext", attemptId, calls });
|
|
440
419
|
}
|
|
441
420
|
}
|
|
442
421
|
catch (error) {
|
|
@@ -465,7 +444,7 @@ export function createSubmissionLedgerHost(host, outputTools, failInfrastructure
|
|
|
465
444
|
const runId = runIdentity(context);
|
|
466
445
|
const attemptId = attemptIdentity(context, runId);
|
|
467
446
|
const state = await stateFor(context, runId);
|
|
468
|
-
const append = (event) => appendFor(
|
|
447
|
+
const append = (event) => appendFor(context, runId, attemptId, event);
|
|
469
448
|
// #541 / #575: shared infra-declaration fail lives on the ledger seam.
|
|
470
449
|
// #641 chain②: seats may bounce a misdeclared infrastructure failure
|
|
471
450
|
// as correctable (2.1/2.2/2.3 keep paths).
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 起居录(ticket-provenance)typed 形状 —— ADR 0075
|
|
2
|
+
* 起居录(ticket-provenance)typed 形状 —— ADR 0075 / ADR 0081 / #1090。
|
|
3
3
|
*
|
|
4
|
-
* 一册=一个追加式 records.jsonl
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* 交卷 `sessions` 输入语义仍是「本轮对话边界」;累计并集是机械合并,不是角色交什么。
|
|
4
|
+
* 一册=一个追加式 records.jsonl。每轮交卷的 `sessions`=本轮对话边界;
|
|
5
|
+
* 成录接缝按该边界从宿主卷投影并追加,不回读已成录历史去重或折叠。
|
|
6
|
+
* 既有「首行册子头+裸对话行」snapshot 仍可读;后续提交不回写旧行。
|
|
8
7
|
*/
|
|
9
8
|
/** Sitian kind for per-ticket court diary volumes. */
|
|
10
9
|
export const TICKET_PROVENANCE_KIND = "ticket-provenance";
|
|
@@ -21,19 +20,6 @@ function positiveInteger(value) {
|
|
|
21
20
|
}
|
|
22
21
|
return undefined;
|
|
23
22
|
}
|
|
24
|
-
function nonNegativeInteger(value) {
|
|
25
|
-
if (typeof value === "number" && Number.isSafeInteger(value) && value >= 0)
|
|
26
|
-
return value;
|
|
27
|
-
if (typeof value === "string" && /^(0|[1-9][0-9]*)$/.test(value)) {
|
|
28
|
-
const parsed = Number(value);
|
|
29
|
-
if (Number.isSafeInteger(parsed))
|
|
30
|
-
return parsed;
|
|
31
|
-
}
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
function projectSpeaker(value) {
|
|
35
|
-
return value === "owner" || value === "runner" ? value : undefined;
|
|
36
|
-
}
|
|
37
23
|
function projectBound(value) {
|
|
38
24
|
if (!isRecord(value))
|
|
39
25
|
return undefined;
|
|
@@ -102,27 +88,3 @@ export function projectTicketProvenanceHeader(value) {
|
|
|
102
88
|
sessions,
|
|
103
89
|
};
|
|
104
90
|
}
|
|
105
|
-
/** 读回一条对话行。 */
|
|
106
|
-
export function projectTicketProvenanceLine(value) {
|
|
107
|
-
if (!isRecord(value))
|
|
108
|
-
return undefined;
|
|
109
|
-
const speaker = projectSpeaker(value.speaker);
|
|
110
|
-
const s = nonNegativeInteger(value.s);
|
|
111
|
-
if (speaker === undefined || s === undefined)
|
|
112
|
-
return undefined;
|
|
113
|
-
if (typeof value.text !== "string")
|
|
114
|
-
return undefined;
|
|
115
|
-
const sourcePosition = nonNegativeInteger(value.sourcePosition);
|
|
116
|
-
const sourceIdentity = typeof value.sourceIdentity === "string" && value.sourceIdentity !== ""
|
|
117
|
-
? value.sourceIdentity
|
|
118
|
-
: undefined;
|
|
119
|
-
const id = typeof value.id === "string" && value.id !== "" ? value.id : undefined;
|
|
120
|
-
return {
|
|
121
|
-
speaker,
|
|
122
|
-
s,
|
|
123
|
-
...(sourcePosition === undefined ? {} : { sourcePosition }),
|
|
124
|
-
...(sourceIdentity === undefined ? {} : { sourceIdentity }),
|
|
125
|
-
...(id === undefined ? {} : { id }),
|
|
126
|
-
text: value.text,
|
|
127
|
-
};
|
|
128
|
-
}
|