@akagilnc/pi-workflow-roles 0.1.3673 → 0.1.3682
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/dist/acp-host/production-host.js +272 -159
- package/dist/diarist-contracts.js +4 -4
- package/dist/diarist-role.js +10 -4
- package/dist/diarist.js +121 -17
- package/dist/package-contracts/terminating-tools.js +1 -1
- package/dist/public-cli/inspector-run.js +3 -13
- package/dist/public-cli/instruction-seat-run.js +6 -31
- package/dist/public-cli/invocation.js +32 -0
- package/dist/public-cli/judge-run.js +1 -7
- package/dist/public-cli/main.js +721 -745
- package/dist/public-cli/run-lifecycle.js +0 -28
- package/dist/public-cli/seat-ticket-binding.js +15 -104
- package/dist/role-runtime.js +89 -10
- package/package.json +1 -1
- package/resources/diarist-collect.md +10 -0
- package/src/diarist-contracts.ts +21 -9
- package/src/diarist-role.ts +15 -4
- package/src/diarist.ts +192 -22
- package/src/package-contracts/terminating-tools.ts +1 -1
- package/src/public-cli/coder-run.ts +1 -7
- package/src/public-cli/countersign-run.ts +238 -86
- package/src/public-cli/diarist-run.ts +83 -28
- package/src/public-cli/fixer-run.ts +1 -7
- package/src/public-cli/inspector-run.ts +3 -17
- package/src/public-cli/instruction-seat-run.ts +6 -36
- package/src/public-cli/invocation.ts +52 -0
- package/src/public-cli/judge-run.ts +1 -7
- package/src/public-cli/run-lifecycle.ts +0 -31
- package/src/public-cli/seat-ticket-binding.ts +14 -138
- package/src/role-runtime.ts +107 -9
package/dist/public-cli/main.js
CHANGED
|
@@ -15055,7 +15055,7 @@ function validateRecordedDiaristOutput(value) {
|
|
|
15055
15055
|
} catch {
|
|
15056
15056
|
throw new Error("Diarist output has no execution discriminator");
|
|
15057
15057
|
}
|
|
15058
|
-
if (status === "completed") {
|
|
15058
|
+
if (status === "completed" || status === "escalate") {
|
|
15059
15059
|
return value;
|
|
15060
15060
|
}
|
|
15061
15061
|
throw new Error("Diarist output has no execution discriminator");
|
|
@@ -15068,7 +15068,7 @@ var init_diarist_contracts = __esm({
|
|
|
15068
15068
|
DIARIST_SOURCES_FLAG = {
|
|
15069
15069
|
name: "ak-diarist-sources",
|
|
15070
15070
|
definition: {
|
|
15071
|
-
description: "Frozen
|
|
15071
|
+
description: "Frozen source catalog the diarist selects from (may be unbound until LLM asserts ticketNumber)",
|
|
15072
15072
|
type: "string"
|
|
15073
15073
|
}
|
|
15074
15074
|
};
|
|
@@ -16762,7 +16762,7 @@ function validateAcceptedDetails(toolName, details) {
|
|
|
16762
16762
|
[GATEKEEPER_OUTPUT_TOOL_NAME]: ["dispatch", "pass"],
|
|
16763
16763
|
[NAVIGATOR_OUTPUT_TOOL_NAME]: ["advice"],
|
|
16764
16764
|
[AUDITOR_OUTPUT_TOOL_NAME]: ["pass", "bounce", "escalate"],
|
|
16765
|
-
[DIARIST_OUTPUT_TOOL_NAME]: ["completed"]
|
|
16765
|
+
[DIARIST_OUTPUT_TOOL_NAME]: ["completed", "escalate"]
|
|
16766
16766
|
};
|
|
16767
16767
|
const collectorDiscriminator = toolName === COLLECTOR_OUTPUT_TOOL && Array.isArray(candidate?.groups);
|
|
16768
16768
|
const baseDiscriminator = discriminator;
|
|
@@ -17816,27 +17816,6 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
17816
17816
|
}
|
|
17817
17817
|
return best;
|
|
17818
17818
|
}
|
|
17819
|
-
async function collectBookRunTicketNumbers(input) {
|
|
17820
|
-
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
17821
|
-
const runsDir = join11(
|
|
17822
|
-
activationBookDirectory(ledgerHome, input.bookKey),
|
|
17823
|
-
"runs"
|
|
17824
|
-
);
|
|
17825
|
-
let entries;
|
|
17826
|
-
try {
|
|
17827
|
-
entries = await readdir2(runsDir);
|
|
17828
|
-
} catch (error) {
|
|
17829
|
-
if (errorCodeOf2(error) === "ENOENT") return /* @__PURE__ */ new Set();
|
|
17830
|
-
throw error;
|
|
17831
|
-
}
|
|
17832
|
-
const known = /* @__PURE__ */ new Set();
|
|
17833
|
-
for (const entry of entries) {
|
|
17834
|
-
if (!entry.includes("@")) continue;
|
|
17835
|
-
const ticketNumber = await readRunTicketNumber(join11(runsDir, entry));
|
|
17836
|
-
if (ticketNumber !== void 0) known.add(ticketNumber);
|
|
17837
|
-
}
|
|
17838
|
-
return known;
|
|
17839
|
-
}
|
|
17840
17819
|
function parsePersistedTicketIdentity(record4) {
|
|
17841
17820
|
const correlationId = typeof record4.correlationId === "string" && record4.correlationId.trim() !== "" ? record4.correlationId : void 0;
|
|
17842
17821
|
const ticketNumber = typeof record4.ticketNumber === "number" && Number.isSafeInteger(record4.ticketNumber) && record4.ticketNumber >= 1 ? record4.ticketNumber : void 0;
|
|
@@ -21911,513 +21890,104 @@ var init_method_skill = __esm({
|
|
|
21911
21890
|
}
|
|
21912
21891
|
});
|
|
21913
21892
|
|
|
21914
|
-
// src/
|
|
21915
|
-
|
|
21916
|
-
|
|
21917
|
-
|
|
21918
|
-
function projectTicketProvenanceDiagnostic(value) {
|
|
21919
|
-
if (!isRecord10(value)) return void 0;
|
|
21920
|
-
if (value.recordClass !== TICKET_PROVENANCE_RECORD_CLASS_DIAGNOSTIC) {
|
|
21921
|
-
return void 0;
|
|
21922
|
-
}
|
|
21923
|
-
if (typeof value.diagnosticKind !== "string" || !DIAGNOSTIC_KINDS.has(value.diagnosticKind)) {
|
|
21924
|
-
return void 0;
|
|
21925
|
-
}
|
|
21926
|
-
if (typeof value.cause !== "string" || value.cause.length === 0) {
|
|
21927
|
-
return void 0;
|
|
21928
|
-
}
|
|
21929
|
-
if (typeof value.recordedAt !== "string" || value.recordedAt.length === 0) {
|
|
21930
|
-
return void 0;
|
|
21931
|
-
}
|
|
21932
|
-
return {
|
|
21933
|
-
recordClass: TICKET_PROVENANCE_RECORD_CLASS_DIAGNOSTIC,
|
|
21934
|
-
diagnosticKind: value.diagnosticKind,
|
|
21935
|
-
cause: value.cause,
|
|
21936
|
-
recordedAt: value.recordedAt,
|
|
21937
|
-
...typeof value.reason === "string" ? { reason: value.reason } : {}
|
|
21938
|
-
};
|
|
21939
|
-
}
|
|
21940
|
-
function projectTicketProvenanceEntry(value) {
|
|
21941
|
-
if (!isRecord10(value)) return void 0;
|
|
21942
|
-
if (value.recordClass === TICKET_PROVENANCE_RECORD_CLASS_DIAGNOSTIC) {
|
|
21943
|
-
return void 0;
|
|
21944
|
-
}
|
|
21945
|
-
if (!isRecord10(value.basis)) return void 0;
|
|
21946
|
-
if (typeof value.basis.method !== "string" || !BASIS_METHODS.has(value.basis.method)) {
|
|
21947
|
-
return void 0;
|
|
21948
|
-
}
|
|
21949
|
-
if (typeof value.sourceKind !== "string" || !SOURCE_KINDS.has(value.sourceKind)) {
|
|
21950
|
-
return void 0;
|
|
21951
|
-
}
|
|
21952
|
-
if (!isRecord10(value.sourceRef)) return void 0;
|
|
21953
|
-
if (typeof value.transcript !== "string" || value.transcript.length === 0) {
|
|
21954
|
-
return void 0;
|
|
21955
|
-
}
|
|
21956
|
-
if (typeof value.timestamp !== "string" || value.timestamp.length === 0) {
|
|
21957
|
-
return void 0;
|
|
21958
|
-
}
|
|
21959
|
-
const basis = {
|
|
21960
|
-
method: value.basis.method,
|
|
21961
|
-
...Array.isArray(value.basis.anchors) ? {
|
|
21962
|
-
anchors: value.basis.anchors.filter(
|
|
21963
|
-
(item) => typeof item === "string"
|
|
21964
|
-
)
|
|
21965
|
-
} : {},
|
|
21966
|
-
...typeof value.basis.note === "string" ? { note: value.basis.note } : {}
|
|
21967
|
-
};
|
|
21968
|
-
const sourceRef = {
|
|
21969
|
-
...typeof value.sourceRef.sessionFile === "string" ? { sessionFile: value.sourceRef.sessionFile } : {},
|
|
21970
|
-
...typeof value.sourceRef.entryId === "string" || typeof value.sourceRef.entryId === "number" ? { entryId: value.sourceRef.entryId } : {},
|
|
21971
|
-
...typeof value.sourceRef.path === "string" ? { path: value.sourceRef.path } : {},
|
|
21972
|
-
...typeof value.sourceRef.url === "string" ? { url: value.sourceRef.url } : {}
|
|
21973
|
-
};
|
|
21974
|
-
return {
|
|
21975
|
-
basis,
|
|
21976
|
-
sourceKind: value.sourceKind,
|
|
21977
|
-
sourceRef,
|
|
21978
|
-
transcript: value.transcript,
|
|
21979
|
-
timestamp: value.timestamp
|
|
21980
|
-
};
|
|
21893
|
+
// src/auditor-dossier-tool.ts
|
|
21894
|
+
import { dirname as dirname8, join as join15, resolve as resolve8 } from "node:path";
|
|
21895
|
+
function gateSubmissionCandidatePath(runDirectory) {
|
|
21896
|
+
return join15(runDirectory, "artifacts", GATE_SUBMISSION_CANDIDATE_FILE);
|
|
21981
21897
|
}
|
|
21982
|
-
var
|
|
21983
|
-
var
|
|
21984
|
-
"src/
|
|
21898
|
+
var GATE_SUBMISSION_CANDIDATE_FILE;
|
|
21899
|
+
var init_auditor_dossier_tool = __esm({
|
|
21900
|
+
"src/auditor-dossier-tool.ts"() {
|
|
21985
21901
|
"use strict";
|
|
21986
|
-
|
|
21987
|
-
|
|
21988
|
-
TICKET_PROVENANCE_OFFERED_WATERMARK = "offered-identities.jsonl";
|
|
21989
|
-
TICKET_PROVENANCE_RECORD_CLASS_DIAGNOSTIC = "diagnostic";
|
|
21990
|
-
SOURCE_KINDS = /* @__PURE__ */ new Set([
|
|
21991
|
-
"cc-session",
|
|
21992
|
-
"issue-body-comment",
|
|
21993
|
-
"adr-decision-key",
|
|
21994
|
-
"ticket-decree-block"
|
|
21995
|
-
]);
|
|
21996
|
-
BASIS_METHODS = /* @__PURE__ */ new Set(["llm-semantic"]);
|
|
21997
|
-
DIAGNOSTIC_KINDS = /* @__PURE__ */ new Set([
|
|
21998
|
-
"collector-failed",
|
|
21999
|
-
"issue-source-failed",
|
|
22000
|
-
"quote-verify-failed"
|
|
22001
|
-
]);
|
|
21902
|
+
init_build();
|
|
21903
|
+
GATE_SUBMISSION_CANDIDATE_FILE = "gate-submission-candidate.json";
|
|
22002
21904
|
}
|
|
22003
21905
|
});
|
|
22004
21906
|
|
|
22005
|
-
// src/
|
|
22006
|
-
|
|
22007
|
-
|
|
22008
|
-
|
|
22009
|
-
|
|
22010
|
-
|
|
22011
|
-
|
|
21907
|
+
// src/compliance-transport.ts
|
|
21908
|
+
var nonblank2, decisionGateSchema, complianceDecisionSchema, AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE, AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE;
|
|
21909
|
+
var init_compliance_transport = __esm({
|
|
21910
|
+
"src/compliance-transport.ts"() {
|
|
21911
|
+
"use strict";
|
|
21912
|
+
init_build();
|
|
21913
|
+
init_auditor_dossier_tool();
|
|
21914
|
+
nonblank2 = typebox_exports.String({ minLength: 1, pattern: "\\S" });
|
|
21915
|
+
decisionGateSchema = typebox_exports.Object({ question: nonblank2, options: typebox_exports.Array(nonblank2, { minItems: 1 }) }, { additionalProperties: false });
|
|
21916
|
+
complianceDecisionSchema = typebox_exports.Object({ status: typebox_exports.Unknown({ description: "pass | bounce | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), violations: typebox_exports.Array(nonblank2, { description: "\u89C2\u5BDF\u5230\u7684\u5408\u89C4\u8FDD\u89C4" }), conflicts: typebox_exports.Array(nonblank2, { description: "\u672A\u51B3\u6743\u5A01\u6216\u6267\u884C\u51B2\u7A81" }), decisionGate: typebox_exports.Union([decisionGateSchema, typebox_exports.Null()], { description: "\u5347\u7EA7\u95EE\u9898\u4E0E\u53EF\u9009\u9009\u9879" }) }, { additionalProperties: true, required: [] });
|
|
21917
|
+
AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE = "ak_auditor_parent_attempt_binding";
|
|
21918
|
+
AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE = "ak_auditor_compliance_failure";
|
|
22012
21919
|
}
|
|
22013
|
-
|
|
22014
|
-
|
|
22015
|
-
|
|
22016
|
-
|
|
22017
|
-
|
|
22018
|
-
|
|
22019
|
-
ref.entryId === void 0 ? "" : String(ref.entryId),
|
|
22020
|
-
ref.path ?? "",
|
|
22021
|
-
ref.url ?? ""
|
|
22022
|
-
].join("");
|
|
22023
|
-
const material = [
|
|
22024
|
-
String(input.ticketNumber),
|
|
22025
|
-
input.sourceKind,
|
|
22026
|
-
refKey,
|
|
22027
|
-
input.transcript
|
|
22028
|
-
].join("\0");
|
|
22029
|
-
return createHash5("sha256").update(material, "utf8").digest("hex");
|
|
22030
|
-
}
|
|
22031
|
-
function resolveTicketProvenanceVolume(ticketNumber, cwd, home) {
|
|
22032
|
-
const path = resolveSitianRecordPath({
|
|
22033
|
-
level: "event",
|
|
22034
|
-
kind: TICKET_PROVENANCE_KIND,
|
|
22035
|
-
subject: ticketProvenanceSubject(ticketNumber),
|
|
22036
|
-
cwd,
|
|
22037
|
-
...home === void 0 ? {} : { home }
|
|
22038
|
-
});
|
|
22039
|
-
return {
|
|
22040
|
-
recordFile: path.recordFile,
|
|
22041
|
-
volumeDir: path.sessionDir,
|
|
22042
|
-
humanViewFile: join15(path.sessionDir, TICKET_PROVENANCE_HUMAN_VIEW),
|
|
22043
|
-
offeredWatermarkFile: join15(path.sessionDir, TICKET_PROVENANCE_OFFERED_WATERMARK)
|
|
22044
|
-
};
|
|
21920
|
+
});
|
|
21921
|
+
|
|
21922
|
+
// src/ledger-session-read.ts
|
|
21923
|
+
import { readFile as readFile11 } from "node:fs/promises";
|
|
21924
|
+
function isRecord10(value) {
|
|
21925
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22045
21926
|
}
|
|
22046
|
-
function
|
|
22047
|
-
const
|
|
22048
|
-
if (!existsSync6(offeredWatermarkFile)) return /* @__PURE__ */ new Set();
|
|
22049
|
-
let text;
|
|
22050
|
-
try {
|
|
22051
|
-
text = readFileSync2(offeredWatermarkFile, "utf8");
|
|
22052
|
-
} catch (error) {
|
|
22053
|
-
throw new TicketProvenanceWatermarkError(
|
|
22054
|
-
"unreadable",
|
|
22055
|
-
`ticket-provenance offered watermark unreadable (${offeredWatermarkFile})`,
|
|
22056
|
-
{ cause: error }
|
|
22057
|
-
);
|
|
22058
|
-
}
|
|
22059
|
-
const seen = /* @__PURE__ */ new Set();
|
|
21927
|
+
async function readLedgerSessionJsonl(path) {
|
|
21928
|
+
const text = await readFile11(path, "utf8");
|
|
22060
21929
|
const lines = text.split("\n");
|
|
21930
|
+
const rows = [];
|
|
22061
21931
|
for (let index = 0; index < lines.length; index += 1) {
|
|
22062
|
-
const
|
|
22063
|
-
if (!
|
|
22064
|
-
let
|
|
21932
|
+
const line2 = lines[index];
|
|
21933
|
+
if (!line2.trim()) continue;
|
|
21934
|
+
let row;
|
|
22065
21935
|
try {
|
|
22066
|
-
|
|
21936
|
+
row = JSON.parse(line2);
|
|
22067
21937
|
} catch (error) {
|
|
22068
|
-
throw
|
|
22069
|
-
|
|
22070
|
-
|
|
22071
|
-
|
|
22072
|
-
|
|
21938
|
+
if (!(error instanceof SyntaxError)) throw error;
|
|
21939
|
+
const completedByTerminator = index < lines.length - 1;
|
|
21940
|
+
if (completedByTerminator) {
|
|
21941
|
+
throw new LedgerSessionJsonlError(
|
|
21942
|
+
`malformed JSONL record in ${path} at line ${index + 1}: ${error.message}`,
|
|
21943
|
+
{ path, line: index + 1, prefixRows: rows }
|
|
21944
|
+
);
|
|
21945
|
+
}
|
|
21946
|
+
break;
|
|
22073
21947
|
}
|
|
22074
|
-
if (
|
|
22075
|
-
|
|
22076
|
-
|
|
22077
|
-
`
|
|
21948
|
+
if (!isRecord10(row)) {
|
|
21949
|
+
const kind = row === null ? "null" : Array.isArray(row) ? "array" : typeof row;
|
|
21950
|
+
throw new LedgerSessionJsonlError(
|
|
21951
|
+
`complete non-object JSONL record in ${path} at line ${index + 1}: expected object, got ${kind}`,
|
|
21952
|
+
{ path, line: index + 1, prefixRows: rows }
|
|
22078
21953
|
);
|
|
22079
21954
|
}
|
|
22080
|
-
|
|
21955
|
+
rows.push(row);
|
|
22081
21956
|
}
|
|
22082
|
-
return
|
|
21957
|
+
return rows;
|
|
22083
21958
|
}
|
|
22084
|
-
|
|
22085
|
-
|
|
22086
|
-
|
|
22087
|
-
const
|
|
22088
|
-
|
|
22089
|
-
|
|
22090
|
-
|
|
22091
|
-
|
|
22092
|
-
|
|
22093
|
-
|
|
22094
|
-
}
|
|
22095
|
-
|
|
22096
|
-
|
|
22097
|
-
|
|
22098
|
-
|
|
21959
|
+
function extractSessionTimestampSpan(rows) {
|
|
21960
|
+
let startedAt;
|
|
21961
|
+
let endedAt;
|
|
21962
|
+
for (const row of rows) {
|
|
21963
|
+
if (typeof row.timestamp !== "string" || !row.timestamp) continue;
|
|
21964
|
+
if (startedAt === void 0) startedAt = row.timestamp;
|
|
21965
|
+
endedAt = row.timestamp;
|
|
21966
|
+
}
|
|
21967
|
+
return {
|
|
21968
|
+
...startedAt !== void 0 ? { startedAt } : {},
|
|
21969
|
+
...endedAt !== void 0 ? { endedAt } : {}
|
|
21970
|
+
};
|
|
21971
|
+
}
|
|
21972
|
+
function extractSessionModelSequence(rows) {
|
|
21973
|
+
const seen = /* @__PURE__ */ new Set();
|
|
21974
|
+
const ordered = [];
|
|
21975
|
+
const push = (raw) => {
|
|
21976
|
+
const model = raw.trim();
|
|
21977
|
+
if (model === "" || seen.has(model)) return;
|
|
21978
|
+
seen.add(model);
|
|
21979
|
+
ordered.push(model);
|
|
21980
|
+
};
|
|
21981
|
+
for (const row of rows) {
|
|
21982
|
+
if (row.type === "model_change" && typeof row.modelId === "string") {
|
|
21983
|
+
push(row.modelId);
|
|
22099
21984
|
}
|
|
22100
|
-
const
|
|
22101
|
-
if (
|
|
22102
|
-
|
|
22103
|
-
continue;
|
|
21985
|
+
const message = isRecord10(row.message) ? row.message : void 0;
|
|
21986
|
+
if (message?.role === "assistant" && typeof message.model === "string") {
|
|
21987
|
+
push(message.model);
|
|
22104
21988
|
}
|
|
22105
|
-
entries.push(entry);
|
|
22106
21989
|
}
|
|
22107
|
-
return
|
|
22108
|
-
}
|
|
22109
|
-
function markdownFenceFor(text) {
|
|
22110
|
-
let longest = 0;
|
|
22111
|
-
const runs = text.match(/`+/g);
|
|
22112
|
-
if (runs !== null) {
|
|
22113
|
-
for (const run of runs) {
|
|
22114
|
-
if (run.length > longest) longest = run.length;
|
|
22115
|
-
}
|
|
22116
|
-
}
|
|
22117
|
-
return "`".repeat(Math.max(3, longest + 1));
|
|
22118
|
-
}
|
|
22119
|
-
function renderTicketProvenanceMarkdown(input) {
|
|
22120
|
-
const lines = [
|
|
22121
|
-
`# \u8D77\u5C45\u5F55 \xB7 #${input.ticketNumber}`,
|
|
22122
|
-
"",
|
|
22123
|
-
`\u6761\u76EE\u6570\uFF1A${input.entries.length}`,
|
|
22124
|
-
""
|
|
22125
|
-
];
|
|
22126
|
-
let index = 0;
|
|
22127
|
-
for (const entry of input.entries) {
|
|
22128
|
-
index += 1;
|
|
22129
|
-
lines.push(`## ${index}. ${entry.sourceKind} \xB7 ${entry.timestamp}`);
|
|
22130
|
-
lines.push("");
|
|
22131
|
-
lines.push(`- basis.method: \`${entry.basis.method}\``);
|
|
22132
|
-
if (entry.basis.anchors !== void 0 && entry.basis.anchors.length > 0) {
|
|
22133
|
-
lines.push(`- anchors: ${entry.basis.anchors.map((a) => `\`${a}\``).join(", ")}`);
|
|
22134
|
-
}
|
|
22135
|
-
if (entry.basis.note !== void 0) {
|
|
22136
|
-
lines.push(`- note: ${entry.basis.note}`);
|
|
22137
|
-
}
|
|
22138
|
-
const refParts = [];
|
|
22139
|
-
if (entry.sourceRef.sessionFile !== void 0) {
|
|
22140
|
-
refParts.push(`sessionFile=${entry.sourceRef.sessionFile}`);
|
|
22141
|
-
}
|
|
22142
|
-
if (entry.sourceRef.entryId !== void 0) {
|
|
22143
|
-
refParts.push(`entryId=${String(entry.sourceRef.entryId)}`);
|
|
22144
|
-
}
|
|
22145
|
-
if (entry.sourceRef.path !== void 0) {
|
|
22146
|
-
refParts.push(`path=${entry.sourceRef.path}`);
|
|
22147
|
-
}
|
|
22148
|
-
if (entry.sourceRef.url !== void 0) {
|
|
22149
|
-
refParts.push(`url=${entry.sourceRef.url}`);
|
|
22150
|
-
}
|
|
22151
|
-
if (refParts.length > 0) {
|
|
22152
|
-
lines.push(`- sourceRef: ${refParts.join(" \xB7 ")}`);
|
|
22153
|
-
}
|
|
22154
|
-
lines.push("");
|
|
22155
|
-
const fence = markdownFenceFor(entry.transcript);
|
|
22156
|
-
lines.push(fence);
|
|
22157
|
-
lines.push(entry.transcript);
|
|
22158
|
-
lines.push(fence);
|
|
22159
|
-
lines.push("");
|
|
22160
|
-
}
|
|
22161
|
-
return lines.join("\n");
|
|
22162
|
-
}
|
|
22163
|
-
function ensureTicketProvenanceVolume(ticketNumber, cwd, home) {
|
|
22164
|
-
const volume = resolveTicketProvenanceVolume(ticketNumber, cwd, home);
|
|
22165
|
-
mkdirSync3(volume.volumeDir, { recursive: true });
|
|
22166
|
-
appendFileSync2(volume.recordFile, "", "utf8");
|
|
22167
|
-
return volume;
|
|
22168
|
-
}
|
|
22169
|
-
function appendTicketProvenanceDiagnostic(input) {
|
|
22170
|
-
const subject = ticketProvenanceSubject(input.ticketNumber);
|
|
22171
|
-
const identityParts = input.diagnostic.diagnosticKind === "quote-verify-failed" ? [
|
|
22172
|
-
subject,
|
|
22173
|
-
input.diagnostic.recordClass,
|
|
22174
|
-
input.diagnostic.diagnosticKind,
|
|
22175
|
-
input.diagnostic.cause,
|
|
22176
|
-
input.diagnostic.reason ?? ""
|
|
22177
|
-
] : [
|
|
22178
|
-
subject,
|
|
22179
|
-
input.diagnostic.recordClass,
|
|
22180
|
-
input.diagnostic.diagnosticKind,
|
|
22181
|
-
input.diagnostic.recordedAt,
|
|
22182
|
-
input.diagnostic.cause,
|
|
22183
|
-
input.diagnostic.reason ?? ""
|
|
22184
|
-
];
|
|
22185
|
-
const identity = createHash5("sha256").update(identityParts.join("\0"), "utf8").digest("hex");
|
|
22186
|
-
return sitianReport({
|
|
22187
|
-
level: "event",
|
|
22188
|
-
kind: TICKET_PROVENANCE_KIND,
|
|
22189
|
-
identity,
|
|
22190
|
-
subject,
|
|
22191
|
-
cwd: input.cwd,
|
|
22192
|
-
...input.home === void 0 ? {} : { home: input.home },
|
|
22193
|
-
host: input.host ?? "diarist",
|
|
22194
|
-
source: input.source ?? "diarist-diagnostic",
|
|
22195
|
-
payload: input.diagnostic
|
|
22196
|
-
});
|
|
22197
|
-
}
|
|
22198
|
-
function appendIssueSourceFailureDiagnostic(input) {
|
|
22199
|
-
const recordedAt = input.recordedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
22200
|
-
return appendTicketProvenanceDiagnostic({
|
|
22201
|
-
ticketNumber: input.ticketNumber,
|
|
22202
|
-
cwd: input.cwd,
|
|
22203
|
-
...input.home === void 0 ? {} : { home: input.home },
|
|
22204
|
-
source: "diarist-issue-source",
|
|
22205
|
-
diagnostic: {
|
|
22206
|
-
recordClass: TICKET_PROVENANCE_RECORD_CLASS_DIAGNOSTIC,
|
|
22207
|
-
diagnosticKind: "issue-source-failed",
|
|
22208
|
-
cause: input.cause,
|
|
22209
|
-
recordedAt,
|
|
22210
|
-
reason: input.reason
|
|
22211
|
-
}
|
|
22212
|
-
});
|
|
22213
|
-
}
|
|
22214
|
-
function writeTicketProvenanceHumanView(input) {
|
|
22215
|
-
const volume = ensureTicketProvenanceVolume(input.ticketNumber, input.cwd, input.home);
|
|
22216
|
-
const md = renderTicketProvenanceMarkdown({
|
|
22217
|
-
ticketNumber: input.ticketNumber,
|
|
22218
|
-
entries: input.entries
|
|
22219
|
-
});
|
|
22220
|
-
writeFileSync2(volume.humanViewFile, md, "utf8");
|
|
22221
|
-
return volume.humanViewFile;
|
|
22222
|
-
}
|
|
22223
|
-
var TicketProvenanceWatermarkError;
|
|
22224
|
-
var init_ticket_provenance = __esm({
|
|
22225
|
-
"src/ticket-provenance.ts"() {
|
|
22226
|
-
"use strict";
|
|
22227
|
-
init_sitian_facade();
|
|
22228
|
-
init_ticket_provenance_contracts();
|
|
22229
|
-
TicketProvenanceWatermarkError = class extends Error {
|
|
22230
|
-
code = "ticket-provenance-watermark";
|
|
22231
|
-
reason;
|
|
22232
|
-
constructor(reason, message, options) {
|
|
22233
|
-
super(message, options);
|
|
22234
|
-
this.name = "TicketProvenanceWatermarkError";
|
|
22235
|
-
this.reason = reason;
|
|
22236
|
-
}
|
|
22237
|
-
};
|
|
22238
|
-
}
|
|
22239
|
-
});
|
|
22240
|
-
|
|
22241
|
-
// src/public-cli/seat-ticket-binding.ts
|
|
22242
|
-
import { existsSync as existsSync7 } from "node:fs";
|
|
22243
|
-
function instructionTicketTokens(instruction) {
|
|
22244
|
-
const tokens = [];
|
|
22245
|
-
const seen = /* @__PURE__ */ new Set();
|
|
22246
|
-
for (const match of instruction.matchAll(/#([1-9]\d*)/g)) {
|
|
22247
|
-
const parsed = Number(match[1]);
|
|
22248
|
-
if (!Number.isSafeInteger(parsed)) continue;
|
|
22249
|
-
if (seen.has(parsed)) continue;
|
|
22250
|
-
seen.add(parsed);
|
|
22251
|
-
tokens.push(parsed);
|
|
22252
|
-
}
|
|
22253
|
-
return tokens;
|
|
22254
|
-
}
|
|
22255
|
-
async function resolveKnownTicketNumber(input) {
|
|
22256
|
-
const tokens = instructionTicketTokens(input.instruction);
|
|
22257
|
-
if (tokens.length === 0) return void 0;
|
|
22258
|
-
const target = tokens[0];
|
|
22259
|
-
const volume = resolveTicketProvenanceVolume(
|
|
22260
|
-
target,
|
|
22261
|
-
input.projectRoot,
|
|
22262
|
-
input.home
|
|
22263
|
-
);
|
|
22264
|
-
if (existsSync7(volume.volumeDir)) return target;
|
|
22265
|
-
const runTickets = await readBookRunTickets(input);
|
|
22266
|
-
return runTickets.has(target) ? target : void 0;
|
|
22267
|
-
}
|
|
22268
|
-
async function resolveDiaristSummonsTicketNumber(input) {
|
|
22269
|
-
const tokens = instructionTicketTokens(input.instruction);
|
|
22270
|
-
return tokens[0];
|
|
22271
|
-
}
|
|
22272
|
-
async function readBookRunTickets(input) {
|
|
22273
|
-
let bookKey;
|
|
22274
|
-
try {
|
|
22275
|
-
bookKey = input.bookKey ?? resolveBookKeyFromGit(input.projectRoot);
|
|
22276
|
-
} catch (error) {
|
|
22277
|
-
if (error instanceof ActivationGitRepositoryRequiredError) return /* @__PURE__ */ new Set();
|
|
22278
|
-
throw error;
|
|
22279
|
-
}
|
|
22280
|
-
return await collectBookRunTicketNumbers({ home: input.home, bookKey });
|
|
22281
|
-
}
|
|
22282
|
-
async function bindReusedTicketNumber(admitted, ticketNumber) {
|
|
22283
|
-
if (ticketNumber === void 0) return;
|
|
22284
|
-
if (admitted.ticketNumber !== void 0) return;
|
|
22285
|
-
await bindAdmittedTicketNumber(admitted, ticketNumber);
|
|
22286
|
-
}
|
|
22287
|
-
async function resolveSeatTicketBinding(admitted, env) {
|
|
22288
|
-
if (admitted.ticketNumber !== void 0) return admitted.ticketNumber;
|
|
22289
|
-
const ticketNumber = await resolveKnownTicketNumber({
|
|
22290
|
-
instruction: admitted.instruction,
|
|
22291
|
-
projectRoot: admitted.projectRoot,
|
|
22292
|
-
home: env.home,
|
|
22293
|
-
bookKey: admitted.bookKey
|
|
22294
|
-
});
|
|
22295
|
-
await bindReusedTicketNumber(admitted, ticketNumber);
|
|
22296
|
-
return ticketNumber;
|
|
22297
|
-
}
|
|
22298
|
-
async function tryResumeSameTicketSeatRun(input) {
|
|
22299
|
-
if (input.freshSummons === true) return void 0;
|
|
22300
|
-
if (input.parentRunPath === void 0 && input.ticketNumber === void 0) {
|
|
22301
|
-
return void 0;
|
|
22302
|
-
}
|
|
22303
|
-
const previousRunId = await findLatestRunIdForSeatTicket({
|
|
22304
|
-
home: input.home,
|
|
22305
|
-
bookKey: resolveBookKeyFromGit(input.projectRoot),
|
|
22306
|
-
role: input.role,
|
|
22307
|
-
...input.parentRunPath === void 0 ? {} : { parentRunPath: input.parentRunPath },
|
|
22308
|
-
...input.ticketNumber === void 0 ? {} : { ticketNumber: input.ticketNumber }
|
|
22309
|
-
});
|
|
22310
|
-
if (previousRunId === void 0) return void 0;
|
|
22311
|
-
return await input.resume(previousRunId, input.summons);
|
|
22312
|
-
}
|
|
22313
|
-
var init_seat_ticket_binding = __esm({
|
|
22314
|
-
"src/public-cli/seat-ticket-binding.ts"() {
|
|
22315
|
-
"use strict";
|
|
22316
|
-
init_activation_ledger_git();
|
|
22317
|
-
init_ticket_provenance();
|
|
22318
|
-
init_invocation();
|
|
22319
|
-
init_run_lifecycle();
|
|
22320
|
-
}
|
|
22321
|
-
});
|
|
22322
|
-
|
|
22323
|
-
// src/auditor-dossier-tool.ts
|
|
22324
|
-
import { dirname as dirname8, join as join16, resolve as resolve8 } from "node:path";
|
|
22325
|
-
function gateSubmissionCandidatePath(runDirectory) {
|
|
22326
|
-
return join16(runDirectory, "artifacts", GATE_SUBMISSION_CANDIDATE_FILE);
|
|
22327
|
-
}
|
|
22328
|
-
var GATE_SUBMISSION_CANDIDATE_FILE;
|
|
22329
|
-
var init_auditor_dossier_tool = __esm({
|
|
22330
|
-
"src/auditor-dossier-tool.ts"() {
|
|
22331
|
-
"use strict";
|
|
22332
|
-
init_build();
|
|
22333
|
-
GATE_SUBMISSION_CANDIDATE_FILE = "gate-submission-candidate.json";
|
|
22334
|
-
}
|
|
22335
|
-
});
|
|
22336
|
-
|
|
22337
|
-
// src/compliance-transport.ts
|
|
22338
|
-
var nonblank2, decisionGateSchema, complianceDecisionSchema, AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE, AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE;
|
|
22339
|
-
var init_compliance_transport = __esm({
|
|
22340
|
-
"src/compliance-transport.ts"() {
|
|
22341
|
-
"use strict";
|
|
22342
|
-
init_build();
|
|
22343
|
-
init_auditor_dossier_tool();
|
|
22344
|
-
nonblank2 = typebox_exports.String({ minLength: 1, pattern: "\\S" });
|
|
22345
|
-
decisionGateSchema = typebox_exports.Object({ question: nonblank2, options: typebox_exports.Array(nonblank2, { minItems: 1 }) }, { additionalProperties: false });
|
|
22346
|
-
complianceDecisionSchema = typebox_exports.Object({ status: typebox_exports.Unknown({ description: "pass | bounce | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), violations: typebox_exports.Array(nonblank2, { description: "\u89C2\u5BDF\u5230\u7684\u5408\u89C4\u8FDD\u89C4" }), conflicts: typebox_exports.Array(nonblank2, { description: "\u672A\u51B3\u6743\u5A01\u6216\u6267\u884C\u51B2\u7A81" }), decisionGate: typebox_exports.Union([decisionGateSchema, typebox_exports.Null()], { description: "\u5347\u7EA7\u95EE\u9898\u4E0E\u53EF\u9009\u9009\u9879" }) }, { additionalProperties: true, required: [] });
|
|
22347
|
-
AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE = "ak_auditor_parent_attempt_binding";
|
|
22348
|
-
AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE = "ak_auditor_compliance_failure";
|
|
22349
|
-
}
|
|
22350
|
-
});
|
|
22351
|
-
|
|
22352
|
-
// src/ledger-session-read.ts
|
|
22353
|
-
import { readFile as readFile11 } from "node:fs/promises";
|
|
22354
|
-
function isRecord11(value) {
|
|
22355
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22356
|
-
}
|
|
22357
|
-
async function readLedgerSessionJsonl(path) {
|
|
22358
|
-
const text = await readFile11(path, "utf8");
|
|
22359
|
-
const lines = text.split("\n");
|
|
22360
|
-
const rows = [];
|
|
22361
|
-
for (let index = 0; index < lines.length; index += 1) {
|
|
22362
|
-
const line2 = lines[index];
|
|
22363
|
-
if (!line2.trim()) continue;
|
|
22364
|
-
let row;
|
|
22365
|
-
try {
|
|
22366
|
-
row = JSON.parse(line2);
|
|
22367
|
-
} catch (error) {
|
|
22368
|
-
if (!(error instanceof SyntaxError)) throw error;
|
|
22369
|
-
const completedByTerminator = index < lines.length - 1;
|
|
22370
|
-
if (completedByTerminator) {
|
|
22371
|
-
throw new LedgerSessionJsonlError(
|
|
22372
|
-
`malformed JSONL record in ${path} at line ${index + 1}: ${error.message}`,
|
|
22373
|
-
{ path, line: index + 1, prefixRows: rows }
|
|
22374
|
-
);
|
|
22375
|
-
}
|
|
22376
|
-
break;
|
|
22377
|
-
}
|
|
22378
|
-
if (!isRecord11(row)) {
|
|
22379
|
-
const kind = row === null ? "null" : Array.isArray(row) ? "array" : typeof row;
|
|
22380
|
-
throw new LedgerSessionJsonlError(
|
|
22381
|
-
`complete non-object JSONL record in ${path} at line ${index + 1}: expected object, got ${kind}`,
|
|
22382
|
-
{ path, line: index + 1, prefixRows: rows }
|
|
22383
|
-
);
|
|
22384
|
-
}
|
|
22385
|
-
rows.push(row);
|
|
22386
|
-
}
|
|
22387
|
-
return rows;
|
|
22388
|
-
}
|
|
22389
|
-
function extractSessionTimestampSpan(rows) {
|
|
22390
|
-
let startedAt;
|
|
22391
|
-
let endedAt;
|
|
22392
|
-
for (const row of rows) {
|
|
22393
|
-
if (typeof row.timestamp !== "string" || !row.timestamp) continue;
|
|
22394
|
-
if (startedAt === void 0) startedAt = row.timestamp;
|
|
22395
|
-
endedAt = row.timestamp;
|
|
22396
|
-
}
|
|
22397
|
-
return {
|
|
22398
|
-
...startedAt !== void 0 ? { startedAt } : {},
|
|
22399
|
-
...endedAt !== void 0 ? { endedAt } : {}
|
|
22400
|
-
};
|
|
22401
|
-
}
|
|
22402
|
-
function extractSessionModelSequence(rows) {
|
|
22403
|
-
const seen = /* @__PURE__ */ new Set();
|
|
22404
|
-
const ordered = [];
|
|
22405
|
-
const push = (raw) => {
|
|
22406
|
-
const model = raw.trim();
|
|
22407
|
-
if (model === "" || seen.has(model)) return;
|
|
22408
|
-
seen.add(model);
|
|
22409
|
-
ordered.push(model);
|
|
22410
|
-
};
|
|
22411
|
-
for (const row of rows) {
|
|
22412
|
-
if (row.type === "model_change" && typeof row.modelId === "string") {
|
|
22413
|
-
push(row.modelId);
|
|
22414
|
-
}
|
|
22415
|
-
const message = isRecord11(row.message) ? row.message : void 0;
|
|
22416
|
-
if (message?.role === "assistant" && typeof message.model === "string") {
|
|
22417
|
-
push(message.model);
|
|
22418
|
-
}
|
|
22419
|
-
}
|
|
22420
|
-
return ordered;
|
|
21990
|
+
return ordered;
|
|
22421
21991
|
}
|
|
22422
21992
|
function bashCommandFirstLine(command) {
|
|
22423
21993
|
const match = /^[^\r\n]*/.exec(command);
|
|
@@ -22428,11 +21998,11 @@ function extractSessionToolIntervals(rows) {
|
|
|
22428
21998
|
const openById = /* @__PURE__ */ new Map();
|
|
22429
21999
|
for (const row of rows) {
|
|
22430
22000
|
const rowTimestamp = typeof row.timestamp === "string" ? row.timestamp : void 0;
|
|
22431
|
-
const message =
|
|
22001
|
+
const message = isRecord10(row.message) ? row.message : void 0;
|
|
22432
22002
|
if (message?.role === "assistant" && Array.isArray(message.content)) {
|
|
22433
22003
|
const callTimestamp = typeof message.timestamp === "string" && message.timestamp ? message.timestamp : rowTimestamp;
|
|
22434
22004
|
for (const part of message.content) {
|
|
22435
|
-
if (!
|
|
22005
|
+
if (!isRecord10(part) || part.type !== "toolCall") continue;
|
|
22436
22006
|
if (typeof part.id !== "string" || part.id.length === 0) {
|
|
22437
22007
|
throw new Error("toolCall frame missing string id");
|
|
22438
22008
|
}
|
|
@@ -22445,7 +22015,7 @@ function extractSessionToolIntervals(rows) {
|
|
|
22445
22015
|
if (openById.has(part.id)) {
|
|
22446
22016
|
throw new Error(`duplicate toolCall id ${part.id}`);
|
|
22447
22017
|
}
|
|
22448
|
-
const args =
|
|
22018
|
+
const args = isRecord10(part.arguments) ? part.arguments : void 0;
|
|
22449
22019
|
const command = part.name === "bash" && args !== void 0 && typeof args.command === "string" ? bashCommandFirstLine(args.command) : void 0;
|
|
22450
22020
|
const interval = {
|
|
22451
22021
|
toolCallId: part.id,
|
|
@@ -22530,8 +22100,8 @@ var init_ledger_session_read = __esm({
|
|
|
22530
22100
|
|
|
22531
22101
|
// src/analyst-gate-cycles-read.ts
|
|
22532
22102
|
import { readdir as readdir3 } from "node:fs/promises";
|
|
22533
|
-
import { join as
|
|
22534
|
-
function
|
|
22103
|
+
import { join as join16 } from "node:path";
|
|
22104
|
+
function isRecord11(value) {
|
|
22535
22105
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22536
22106
|
}
|
|
22537
22107
|
function isParentAttemptBindingRow(row) {
|
|
@@ -22562,7 +22132,7 @@ function isGateTerminatingToolName(toolName) {
|
|
|
22562
22132
|
function acceptedGateReceiptIds(rows) {
|
|
22563
22133
|
const accepted = /* @__PURE__ */ new Set();
|
|
22564
22134
|
for (const row of rows) {
|
|
22565
|
-
const message =
|
|
22135
|
+
const message = isRecord11(row.message) ? row.message : void 0;
|
|
22566
22136
|
if (message?.role !== "toolResult") continue;
|
|
22567
22137
|
if (typeof message.toolCallId !== "string" || message.toolCallId.length === 0) continue;
|
|
22568
22138
|
if (message.isError === false) accepted.add(message.toolCallId);
|
|
@@ -22601,7 +22171,7 @@ function nearestAttemptBindingBefore(rows, beforeIndex) {
|
|
|
22601
22171
|
for (let i = beforeIndex - 1; i >= 0; i -= 1) {
|
|
22602
22172
|
const row = rows[i];
|
|
22603
22173
|
if (!isParentAttemptBindingRow(row)) continue;
|
|
22604
|
-
if (!
|
|
22174
|
+
if (!isRecord11(row.data) || !isRecord11(row.data.parent)) continue;
|
|
22605
22175
|
const id = row.data.parent.attemptEntryId;
|
|
22606
22176
|
const sessionFile = row.data.parent.sessionFile;
|
|
22607
22177
|
return {
|
|
@@ -22616,10 +22186,10 @@ function extractAllAcceptedGateToolCalls(rows) {
|
|
|
22616
22186
|
const out = [];
|
|
22617
22187
|
for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
|
|
22618
22188
|
const row = rows[rowIndex];
|
|
22619
|
-
const message =
|
|
22189
|
+
const message = isRecord11(row.message) ? row.message : void 0;
|
|
22620
22190
|
if (message?.role !== "assistant" || !Array.isArray(message.content)) continue;
|
|
22621
22191
|
for (const part of message.content) {
|
|
22622
|
-
if (!
|
|
22192
|
+
if (!isRecord11(part) || part.type !== "toolCall") continue;
|
|
22623
22193
|
if (typeof part.id !== "string" || part.id.length === 0) continue;
|
|
22624
22194
|
if (typeof part.name !== "string" || part.name.length === 0) continue;
|
|
22625
22195
|
if (!isGateTerminatingToolName(part.name)) continue;
|
|
@@ -22627,7 +22197,7 @@ function extractAllAcceptedGateToolCalls(rows) {
|
|
|
22627
22197
|
const binding = nearestAttemptBindingBefore(rows, rowIndex);
|
|
22628
22198
|
out.push({
|
|
22629
22199
|
toolName: part.name,
|
|
22630
|
-
args:
|
|
22200
|
+
args: isRecord11(part.arguments) ? part.arguments : void 0,
|
|
22631
22201
|
accepted: true,
|
|
22632
22202
|
rowIndex,
|
|
22633
22203
|
...binding
|
|
@@ -22767,7 +22337,7 @@ async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
|
22767
22337
|
{ cause: error }
|
|
22768
22338
|
);
|
|
22769
22339
|
}
|
|
22770
|
-
if (!
|
|
22340
|
+
if (!isRecord11(raw) || raw.kind !== "direct-officer-run-pointer" || raw.version !== 1) {
|
|
22771
22341
|
throw new Error(`direct officer run pointer has unknown shape in ${pointerPath}`);
|
|
22772
22342
|
}
|
|
22773
22343
|
const sessionFile = raw.sessionFile;
|
|
@@ -22791,7 +22361,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
|
|
|
22791
22361
|
throw error;
|
|
22792
22362
|
}
|
|
22793
22363
|
for (const name of names) {
|
|
22794
|
-
const path =
|
|
22364
|
+
const path = join16(directory, name);
|
|
22795
22365
|
const sessionPath = name.endsWith(".pointer.json") ? await resolveOfficerSessionFromPointerFile(path) : path;
|
|
22796
22366
|
if (sessionPath === void 0) continue;
|
|
22797
22367
|
const classified = await classifyAuditorVolume(sessionPath);
|
|
@@ -22851,21 +22421,21 @@ var init_gatekeeper_role = __esm({
|
|
|
22851
22421
|
|
|
22852
22422
|
// src/run-terminal-artifacts.ts
|
|
22853
22423
|
import { readdir as readdir4, readFile as readFile12 } from "node:fs/promises";
|
|
22854
|
-
import { basename as basename6, dirname as dirname9, join as
|
|
22424
|
+
import { basename as basename6, dirname as dirname9, join as join17 } from "node:path";
|
|
22855
22425
|
function isMissingPathError2(error) {
|
|
22856
22426
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
22857
22427
|
}
|
|
22858
22428
|
function errorText2(error) {
|
|
22859
22429
|
return error instanceof Error ? error.message : String(error);
|
|
22860
22430
|
}
|
|
22861
|
-
function
|
|
22431
|
+
function isRecord12(value) {
|
|
22862
22432
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22863
22433
|
}
|
|
22864
22434
|
function readUsableTerminalArtifactBody(body) {
|
|
22865
22435
|
if (body === null) {
|
|
22866
22436
|
return { ok: false, reason: "terminal artifact JSON value is null" };
|
|
22867
22437
|
}
|
|
22868
|
-
if (!
|
|
22438
|
+
if (!isRecord12(body)) {
|
|
22869
22439
|
return {
|
|
22870
22440
|
ok: false,
|
|
22871
22441
|
reason: `terminal artifact JSON value is not a typed object (${Array.isArray(body) ? "array" : typeof body})`
|
|
@@ -22926,7 +22496,7 @@ async function listUniqueErrorFallbackPaths(directories) {
|
|
|
22926
22496
|
}
|
|
22927
22497
|
for (const name of names.sort((a, b) => a.localeCompare(b))) {
|
|
22928
22498
|
if (!UNIQUE_ERROR_FALLBACK_NAME.test(name)) continue;
|
|
22929
|
-
found.push(
|
|
22499
|
+
found.push(join17(dir, name));
|
|
22930
22500
|
}
|
|
22931
22501
|
}
|
|
22932
22502
|
return found;
|
|
@@ -22942,14 +22512,14 @@ function presentUniqueFallbackBoundToRun(body, expectedRunId) {
|
|
|
22942
22512
|
return typeof body.runId === "string" && body.runId === expectedRunId;
|
|
22943
22513
|
}
|
|
22944
22514
|
async function readRunTerminalArtifact(runDirectory) {
|
|
22945
|
-
const artifactsDir =
|
|
22515
|
+
const artifactsDir = join17(runDirectory, "artifacts");
|
|
22946
22516
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
22947
|
-
const path =
|
|
22517
|
+
const path = join17(artifactsDir, file);
|
|
22948
22518
|
const read3 = await readTerminalArtifactAtPath(path, file);
|
|
22949
22519
|
if (read3 !== void 0) return read3;
|
|
22950
22520
|
}
|
|
22951
22521
|
for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
22952
|
-
const path =
|
|
22522
|
+
const path = join17(runDirectory, relative3);
|
|
22953
22523
|
const read3 = await readTerminalArtifactAtPath(path, "error.json");
|
|
22954
22524
|
if (read3 !== void 0) return read3;
|
|
22955
22525
|
}
|
|
@@ -23088,14 +22658,14 @@ var init_submission_ledger = __esm({
|
|
|
23088
22658
|
});
|
|
23089
22659
|
|
|
23090
22660
|
// src/session-opening-materials.ts
|
|
23091
|
-
import { existsSync as
|
|
22661
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
23092
22662
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
23093
|
-
import { dirname as dirname10, join as
|
|
22663
|
+
import { dirname as dirname10, join as join18 } from "node:path";
|
|
23094
22664
|
import { fileURLToPath, pathToFileURL as pathToFileURL2 } from "node:url";
|
|
23095
22665
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
23096
22666
|
let dir = dirname10(fileURLToPath(moduleUrl));
|
|
23097
22667
|
for (let i = 0; i < 8; i += 1) {
|
|
23098
|
-
if (
|
|
22668
|
+
if (existsSync6(join18(dir, "package.json")) && existsSync6(join18(dir, "souls"))) {
|
|
23099
22669
|
return dir;
|
|
23100
22670
|
}
|
|
23101
22671
|
const parent = dirname10(dir);
|
|
@@ -23421,12 +22991,12 @@ var init_reviewer_dispatch = __esm({
|
|
|
23421
22991
|
|
|
23422
22992
|
// src/public-cli/reviewer-dispatch-rejection.ts
|
|
23423
22993
|
import { readFile as readFile14, unlink as unlink3 } from "node:fs/promises";
|
|
23424
|
-
import { join as
|
|
22994
|
+
import { join as join19 } from "node:path";
|
|
23425
22995
|
function isReviewerPreflightViolation(value) {
|
|
23426
22996
|
return typeof value === "string" && REVIEWER_PREFLIGHT_VIOLATIONS.includes(value);
|
|
23427
22997
|
}
|
|
23428
22998
|
function reviewerDispatchRejectionPath(runDirectory) {
|
|
23429
|
-
return
|
|
22999
|
+
return join19(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
|
|
23430
23000
|
}
|
|
23431
23001
|
async function clearReviewerDispatchRejection(runDirectory) {
|
|
23432
23002
|
try {
|
|
@@ -23487,7 +23057,7 @@ var init_collector_evidence = __esm({
|
|
|
23487
23057
|
|
|
23488
23058
|
// src/collector-github.ts
|
|
23489
23059
|
import { spawn as spawn2 } from "node:child_process";
|
|
23490
|
-
function
|
|
23060
|
+
function isRecord13(value) {
|
|
23491
23061
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23492
23062
|
}
|
|
23493
23063
|
function requireString(value, label) {
|
|
@@ -23528,25 +23098,25 @@ function commentFailureCause(error) {
|
|
|
23528
23098
|
};
|
|
23529
23099
|
}
|
|
23530
23100
|
function requireUserLogin(raw) {
|
|
23531
|
-
if (!
|
|
23101
|
+
if (!isRecord13(raw) || typeof raw["login"] !== "string") {
|
|
23532
23102
|
throw new Error("GitHub payload missing user.login");
|
|
23533
23103
|
}
|
|
23534
23104
|
return raw["login"];
|
|
23535
23105
|
}
|
|
23536
23106
|
function optionalUserLogin(raw) {
|
|
23537
23107
|
if (raw === null) return null;
|
|
23538
|
-
if (!
|
|
23108
|
+
if (!isRecord13(raw) || typeof raw["login"] !== "string") {
|
|
23539
23109
|
throw new Error("GitHub payload missing user.login");
|
|
23540
23110
|
}
|
|
23541
23111
|
return raw["login"];
|
|
23542
23112
|
}
|
|
23543
23113
|
function machineIdentity(raw) {
|
|
23544
23114
|
const user = raw["user"];
|
|
23545
|
-
if (!
|
|
23115
|
+
if (!isRecord13(user) || typeof user["type"] !== "string" || typeof user["id"] !== "number") {
|
|
23546
23116
|
return null;
|
|
23547
23117
|
}
|
|
23548
23118
|
const app = raw["performed_via_github_app"];
|
|
23549
|
-
const appId =
|
|
23119
|
+
const appId = isRecord13(app) && typeof app["id"] === "number" ? app["id"] : void 0;
|
|
23550
23120
|
return {
|
|
23551
23121
|
userType: user["type"],
|
|
23552
23122
|
userId: user["id"],
|
|
@@ -23554,9 +23124,9 @@ function machineIdentity(raw) {
|
|
|
23554
23124
|
};
|
|
23555
23125
|
}
|
|
23556
23126
|
function normalizePullRequest(raw) {
|
|
23557
|
-
if (!
|
|
23127
|
+
if (!isRecord13(raw)) throw new Error("GitHub pull request payload must be an object");
|
|
23558
23128
|
const head = raw["head"];
|
|
23559
|
-
if (!
|
|
23129
|
+
if (!isRecord13(head) || typeof head["sha"] !== "string" || head["sha"].length === 0) {
|
|
23560
23130
|
throw new Error("GitHub pull request payload missing head.sha");
|
|
23561
23131
|
}
|
|
23562
23132
|
const number = requireNumber(raw["number"], "number");
|
|
@@ -23572,7 +23142,7 @@ function normalizePullRequest(raw) {
|
|
|
23572
23142
|
};
|
|
23573
23143
|
}
|
|
23574
23144
|
function normalizePullRequestReaction(raw) {
|
|
23575
|
-
if (!
|
|
23145
|
+
if (!isRecord13(raw)) throw new Error("GitHub reaction payload must be an object");
|
|
23576
23146
|
return {
|
|
23577
23147
|
id: requireNumber(raw["id"], "reaction.id"),
|
|
23578
23148
|
userLogin: optionalUserLogin(raw["user"]),
|
|
@@ -23583,7 +23153,7 @@ function normalizePullRequestReaction(raw) {
|
|
|
23583
23153
|
};
|
|
23584
23154
|
}
|
|
23585
23155
|
function normalizeReview(raw) {
|
|
23586
|
-
if (!
|
|
23156
|
+
if (!isRecord13(raw)) throw new Error("GitHub review payload must be an object");
|
|
23587
23157
|
return {
|
|
23588
23158
|
id: requireNumber(raw["id"], "review.id"),
|
|
23589
23159
|
...typeof raw["node_id"] === "string" ? { nodeId: raw["node_id"] } : {},
|
|
@@ -23598,7 +23168,7 @@ function normalizeReview(raw) {
|
|
|
23598
23168
|
};
|
|
23599
23169
|
}
|
|
23600
23170
|
function normalizeIssueComment(raw) {
|
|
23601
|
-
if (!
|
|
23171
|
+
if (!isRecord13(raw)) throw new Error("GitHub issue comment payload must be an object");
|
|
23602
23172
|
return {
|
|
23603
23173
|
id: requireNumber(raw["id"], "comment.id"),
|
|
23604
23174
|
userLogin: optionalUserLogin(raw["user"]),
|
|
@@ -23611,7 +23181,7 @@ function normalizeIssueComment(raw) {
|
|
|
23611
23181
|
};
|
|
23612
23182
|
}
|
|
23613
23183
|
function normalizeReviewComment(raw) {
|
|
23614
|
-
if (!
|
|
23184
|
+
if (!isRecord13(raw)) throw new Error("GitHub review comment payload must be an object");
|
|
23615
23185
|
return {
|
|
23616
23186
|
id: requireNumber(raw["id"], "review_comment.id"),
|
|
23617
23187
|
pullRequestReviewId: typeof raw["pull_request_review_id"] === "number" ? raw["pull_request_review_id"] : null,
|
|
@@ -23920,11 +23490,11 @@ function createGhCollectorGitHubTransport(runner = createGhApiRunner()) {
|
|
|
23920
23490
|
if (input.signal?.aborted) {
|
|
23921
23491
|
throw error;
|
|
23922
23492
|
}
|
|
23923
|
-
if (
|
|
23493
|
+
if (isRecord13(error) && error["ambiguousGhFailure"] === true) {
|
|
23924
23494
|
const cause = commentFailureCause(error);
|
|
23925
23495
|
return { kind: "ambiguous_loss", diagnostics: cause.message, cause };
|
|
23926
23496
|
}
|
|
23927
|
-
if (
|
|
23497
|
+
if (isRecord13(error) && error["name"] === "AbortError") {
|
|
23928
23498
|
throw error;
|
|
23929
23499
|
}
|
|
23930
23500
|
throw error;
|
|
@@ -24100,11 +23670,11 @@ var init_navigator_invocation_identity = __esm({
|
|
|
24100
23670
|
});
|
|
24101
23671
|
|
|
24102
23672
|
// src/receipt-delivery-policy.ts
|
|
24103
|
-
function
|
|
23673
|
+
function isRecord14(value) {
|
|
24104
23674
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24105
23675
|
}
|
|
24106
23676
|
function parseNoReceiptLifecycleFacts(input) {
|
|
24107
|
-
if (!
|
|
23677
|
+
if (!isRecord14(input) || typeof input.terminalToolCalled !== "boolean" || input.deliveryTurns !== RECEIPT_DELIVERY_TURN_LIMIT || input.sessionCompletion !== "settled-without-accepted-receipt" || input.acceptedReceipt !== false || typeof input.runPointer !== "string" || input.runPointer.trim() === "" || typeof input.attemptPointer !== "string" || input.attemptPointer.trim() === "" || !Array.isArray(input.rejectedReceipts) || !input.rejectedReceipts.every((item) => isRecord14(item) && typeof item.reason === "string")) {
|
|
24108
23678
|
throw new TypeError("malformed no-receipt lifecycle facts");
|
|
24109
23679
|
}
|
|
24110
23680
|
return {
|
|
@@ -24290,7 +23860,7 @@ var init_terminal = __esm({
|
|
|
24290
23860
|
// src/public-cli/settlement.ts
|
|
24291
23861
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
24292
23862
|
import { appendFile as appendFile2, readFile as readFile15, readdir as readdir5, writeFile as writeFile5 } from "node:fs/promises";
|
|
24293
|
-
import { dirname as dirname11, join as
|
|
23863
|
+
import { dirname as dirname11, join as join20 } from "node:path";
|
|
24294
23864
|
function sealedLedgerHome(admitted) {
|
|
24295
23865
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
24296
23866
|
}
|
|
@@ -24670,7 +24240,7 @@ async function readSitianRetainedAuditorProviderStop(sessionFile) {
|
|
|
24670
24240
|
const { records: records2 } = await readSitianRecords(recordFile);
|
|
24671
24241
|
for (let i = records2.length - 1; i >= 0; i -= 1) {
|
|
24672
24242
|
const payload = records2[i]?.payload;
|
|
24673
|
-
if (!
|
|
24243
|
+
if (!isRecord15(payload) || !isRecord15(payload.response)) continue;
|
|
24674
24244
|
if (typeof payload.type === "string") continue;
|
|
24675
24245
|
const stop = sessionProviderStopFromAssistant(payload.response);
|
|
24676
24246
|
if (stop !== void 0) return stop;
|
|
@@ -24691,7 +24261,7 @@ async function readSessionProviderStop(sessionFile) {
|
|
|
24691
24261
|
}
|
|
24692
24262
|
}
|
|
24693
24263
|
async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
24694
|
-
const childDirectory =
|
|
24264
|
+
const childDirectory = join20(dirname11(sessionFile), "evidence-children");
|
|
24695
24265
|
let names;
|
|
24696
24266
|
try {
|
|
24697
24267
|
names = await readdir5(childDirectory);
|
|
@@ -24702,12 +24272,12 @@ async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
|
24702
24272
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
24703
24273
|
let entries;
|
|
24704
24274
|
try {
|
|
24705
|
-
entries = await readBoundSessionEntries(
|
|
24275
|
+
entries = await readBoundSessionEntries(join20(childDirectory, file));
|
|
24706
24276
|
} catch (error) {
|
|
24707
24277
|
throw sessionReadFailure(error, "failed to read discovered evidence-child session");
|
|
24708
24278
|
}
|
|
24709
24279
|
const header = entries.find((entry) => entry.type === "session");
|
|
24710
|
-
if (!
|
|
24280
|
+
if (!isRecord15(header) || header.parentSession !== sessionFile) continue;
|
|
24711
24281
|
const stop = extractSessionProviderStop(entries);
|
|
24712
24282
|
if (stop === void 0) continue;
|
|
24713
24283
|
const primary = knownFailureFromProviderStop(stop);
|
|
@@ -24739,12 +24309,12 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
24739
24309
|
return firstLine === RESUME_ENVELOPE;
|
|
24740
24310
|
};
|
|
24741
24311
|
const isResumeEnvelope = (msg) => {
|
|
24742
|
-
if (!
|
|
24312
|
+
if (!isRecord15(msg) || msg.role !== "user") return false;
|
|
24743
24313
|
const text = typeof msg.text === "string" ? msg.text : typeof msg.content === "string" ? msg.content : void 0;
|
|
24744
24314
|
if (isResumeEnvelopeBytes(text)) return true;
|
|
24745
24315
|
const content = msg.content;
|
|
24746
24316
|
if (Array.isArray(content)) {
|
|
24747
|
-
return content.some((p) =>
|
|
24317
|
+
return content.some((p) => isRecord15(p) && (isResumeEnvelopeBytes(p.text) || isResumeEnvelopeBytes(p.content)));
|
|
24748
24318
|
}
|
|
24749
24319
|
return false;
|
|
24750
24320
|
};
|
|
@@ -24756,7 +24326,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
24756
24326
|
latestParentUserIndex = i;
|
|
24757
24327
|
break;
|
|
24758
24328
|
}
|
|
24759
|
-
const childDirectories = [
|
|
24329
|
+
const childDirectories = [join20(dirname11(sessionFile), "auditor-roles")];
|
|
24760
24330
|
const valid = [];
|
|
24761
24331
|
let sawAnyDirectory = false;
|
|
24762
24332
|
for (const childDirectory of childDirectories) {
|
|
@@ -24771,12 +24341,12 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
24771
24341
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
24772
24342
|
let entries;
|
|
24773
24343
|
try {
|
|
24774
|
-
entries = await readBoundSessionEntries(
|
|
24344
|
+
entries = await readBoundSessionEntries(join20(childDirectory, file));
|
|
24775
24345
|
} catch (error) {
|
|
24776
24346
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
24777
24347
|
}
|
|
24778
24348
|
const header = entries.find((entry) => entry.type === "session");
|
|
24779
|
-
if (!
|
|
24349
|
+
if (!isRecord15(header)) continue;
|
|
24780
24350
|
const bindingIndexes = [];
|
|
24781
24351
|
for (let i = 0; i < entries.length; i += 1) {
|
|
24782
24352
|
const entry = entries[i];
|
|
@@ -24790,7 +24360,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
24790
24360
|
end: idx + 1 < bindingIndexes.length ? bindingIndexes[idx + 1] : entries.length
|
|
24791
24361
|
})) : [{ entry: void 0, start: 0, end: entries.length }];
|
|
24792
24362
|
for (const { entry: bindingEntry, start, end } of bindingPasses) {
|
|
24793
|
-
const bindingParent = bindingEntry !== void 0 &&
|
|
24363
|
+
const bindingParent = bindingEntry !== void 0 && isRecord15(bindingEntry.data) && isRecord15(bindingEntry.data.parent) ? bindingEntry.data.parent : void 0;
|
|
24794
24364
|
const attemptEntryId = typeof bindingParent?.attemptEntryId === "string" ? bindingParent.attemptEntryId : void 0;
|
|
24795
24365
|
const attemptEntryIndex = attemptEntryId === void 0 ? -1 : parentEntries.findIndex((entry) => entry.id === attemptEntryId);
|
|
24796
24366
|
const boundSessionFile = typeof bindingParent?.sessionFile === "string" ? bindingParent.sessionFile : typeof header.parentSession === "string" ? header.parentSession : void 0;
|
|
@@ -24817,11 +24387,11 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
24817
24387
|
if (stop === void 0) continue;
|
|
24818
24388
|
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
24819
24389
|
const entry = entries[i];
|
|
24820
|
-
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !
|
|
24821
|
-
const parent =
|
|
24822
|
-
const failure =
|
|
24390
|
+
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord15(entry.data)) continue;
|
|
24391
|
+
const parent = isRecord15(entry.data.parent) ? entry.data.parent : void 0;
|
|
24392
|
+
const failure = isRecord15(entry.data.failure) ? entry.data.failure : void 0;
|
|
24823
24393
|
if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId || failure?.cause !== "provider" && failure?.cause !== "unrecognized") continue;
|
|
24824
|
-
const identity =
|
|
24394
|
+
const identity = isRecord15(failure.identity) ? failure.identity : void 0;
|
|
24825
24395
|
return {
|
|
24826
24396
|
cause: failure.cause === "provider" ? "provider" : "unrecognized",
|
|
24827
24397
|
...identity === void 0 ? {} : { identity: {
|
|
@@ -24829,7 +24399,7 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
24829
24399
|
...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
|
|
24830
24400
|
} },
|
|
24831
24401
|
...typeof failure.diagnostic === "string" ? { diagnostic: failure.diagnostic } : {},
|
|
24832
|
-
...
|
|
24402
|
+
...isRecord15(failure.details) ? { details: failure.details } : {}
|
|
24833
24403
|
};
|
|
24834
24404
|
}
|
|
24835
24405
|
}
|
|
@@ -24876,9 +24446,9 @@ function typedFailedTerminatingToolKnownFailure(entries) {
|
|
|
24876
24446
|
if (classification.kind !== "infrastructure") continue;
|
|
24877
24447
|
if (typeof message.toolCallId !== "string" || typeof message.toolName !== "string") continue;
|
|
24878
24448
|
if (boundRoleToolCallForResult(attemptEntries, i, message, message.toolName) === void 0) continue;
|
|
24879
|
-
const textPart = Array.isArray(message.content) ? message.content.find((part) =>
|
|
24880
|
-
const diagnostic =
|
|
24881
|
-
const details =
|
|
24449
|
+
const textPart = Array.isArray(message.content) ? message.content.find((part) => isRecord15(part) && part.type === "text" && typeof part.text === "string") : void 0;
|
|
24450
|
+
const diagnostic = isRecord15(textPart) ? textPart.text : void 0;
|
|
24451
|
+
const details = isRecord15(message.details) ? message.details : classification.fact;
|
|
24882
24452
|
return {
|
|
24883
24453
|
cause: "activation",
|
|
24884
24454
|
identity: { name: message.toolName, code: message.toolCallId },
|
|
@@ -25036,7 +24606,7 @@ function controlledFailureInputFromResolution(resolution) {
|
|
|
25036
24606
|
} : {}
|
|
25037
24607
|
};
|
|
25038
24608
|
}
|
|
25039
|
-
function
|
|
24609
|
+
function isRecord15(value) {
|
|
25040
24610
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25041
24611
|
}
|
|
25042
24612
|
function safelyRead(object, key) {
|
|
@@ -25160,7 +24730,7 @@ function boundRoleToolCallForResult(entries, resultIndex, message, outputToolNam
|
|
|
25160
24730
|
const candidateMessage = entries[index]?.message;
|
|
25161
24731
|
if (candidateMessage?.role === "assistant" && Array.isArray(candidateMessage.content)) {
|
|
25162
24732
|
for (const part of candidateMessage.content) {
|
|
25163
|
-
if (!
|
|
24733
|
+
if (!isRecord15(part) || part.type !== "toolCall" || part.id !== callId) {
|
|
25164
24734
|
continue;
|
|
25165
24735
|
}
|
|
25166
24736
|
if (part.name !== outputToolName) return void 0;
|
|
@@ -25232,7 +24802,7 @@ function parseNavigatorAttendanceDetails(details) {
|
|
|
25232
24802
|
const advisoryDiagnostic = typeof details.routePlaybookReadFailure === "string" ? { advisoryDiagnostic: details.routePlaybookReadFailure } : {};
|
|
25233
24803
|
if (disposition === "recommendation") {
|
|
25234
24804
|
const next = details.next;
|
|
25235
|
-
if (!
|
|
24805
|
+
if (!isRecord15(next) || typeof next.role !== "string") {
|
|
25236
24806
|
return {
|
|
25237
24807
|
disposition: "unavailable",
|
|
25238
24808
|
source: "unknown",
|
|
@@ -25240,7 +24810,7 @@ function parseNavigatorAttendanceDetails(details) {
|
|
|
25240
24810
|
};
|
|
25241
24811
|
}
|
|
25242
24812
|
const reason = typeof details.reason === "string" ? details.reason : "";
|
|
25243
|
-
const route = Array.isArray(details.route) ? details.route.filter(
|
|
24813
|
+
const route = Array.isArray(details.route) ? details.route.filter(isRecord15).map((target) => ({
|
|
25244
24814
|
role: String(target.role),
|
|
25245
24815
|
phase: navigatorPhaseValue(target.phase)
|
|
25246
24816
|
})) : void 0;
|
|
@@ -25303,8 +24873,8 @@ function projectTerminalGateFact(rounds) {
|
|
|
25303
24873
|
};
|
|
25304
24874
|
}
|
|
25305
24875
|
async function extractGateFactFromSessionDirectory(sessionDirectory, options = {}) {
|
|
25306
|
-
const directories = [
|
|
25307
|
-
const parentSessionFile = options.parentSessionFile ??
|
|
24876
|
+
const directories = [join20(sessionDirectory, "auditor-roles")];
|
|
24877
|
+
const parentSessionFile = options.parentSessionFile ?? join20(sessionDirectory, "session.jsonl");
|
|
25308
24878
|
const rounds = await readAnalystGateCyclesFromAuditorRoles(directories, {
|
|
25309
24879
|
parentSessionFile
|
|
25310
24880
|
});
|
|
@@ -25312,7 +24882,7 @@ async function extractGateFactFromSessionDirectory(sessionDirectory, options = {
|
|
|
25312
24882
|
}
|
|
25313
24883
|
async function withOptionalGateProjection(base, sessionDirectory, gateContext = {}) {
|
|
25314
24884
|
const secondaryEvidence = base.roleOutcome.kind === "failure" ? base.roleOutcome.decisiveFacts.secondaryEvidence : void 0;
|
|
25315
|
-
if (
|
|
24885
|
+
if (isRecord15(secondaryEvidence) && secondaryEvidence.kind === "role_infrastructure_failure" && (secondaryEvidence.stage === "gatekeeper" || secondaryEvidence.stage === "inspector" || secondaryEvidence.stage === "notary")) return base;
|
|
25316
24886
|
const gate = await extractGateFactFromSessionDirectory(sessionDirectory, gateContext);
|
|
25317
24887
|
return gate === void 0 ? base : { ...base, gate };
|
|
25318
24888
|
}
|
|
@@ -25352,7 +24922,7 @@ function extractNavigatorFact(entries) {
|
|
|
25352
24922
|
const entry = entries[i];
|
|
25353
24923
|
if (entry?.type === "custom_message" && entry.customType === "ak-navigator-attendance") {
|
|
25354
24924
|
const details = entry.message?.details ?? entry.details;
|
|
25355
|
-
if (!
|
|
24925
|
+
if (!isRecord15(details)) {
|
|
25356
24926
|
return {
|
|
25357
24927
|
disposition: "unavailable",
|
|
25358
24928
|
source: "unknown",
|
|
@@ -25402,8 +24972,8 @@ async function extractNavigatorFactFromAdmittedSession(sessionFile) {
|
|
|
25402
24972
|
async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
|
|
25403
24973
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
25404
24974
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
25405
|
-
const reportPath =
|
|
25406
|
-
const evidencePath =
|
|
24975
|
+
const reportPath = join20(artifactsDir, "report.json");
|
|
24976
|
+
const evidencePath = join20(artifactsDir, "evidence.json");
|
|
25407
24977
|
await writeFile5(
|
|
25408
24978
|
reportPath,
|
|
25409
24979
|
`${JSON.stringify(
|
|
@@ -25447,8 +25017,8 @@ async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
|
|
|
25447
25017
|
async function publishCoderArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
25448
25018
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
25449
25019
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
25450
|
-
const reportPath =
|
|
25451
|
-
const evidencePath =
|
|
25020
|
+
const reportPath = join20(artifactsDir, "report.json");
|
|
25021
|
+
const evidencePath = join20(artifactsDir, "evidence.json");
|
|
25452
25022
|
await writeFile5(
|
|
25453
25023
|
reportPath,
|
|
25454
25024
|
`${JSON.stringify(
|
|
@@ -25599,8 +25169,8 @@ function extractFixerMethodInvocations(entries, options) {
|
|
|
25599
25169
|
async function publishFixerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
25600
25170
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
25601
25171
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
25602
|
-
const reportPath =
|
|
25603
|
-
const evidencePath =
|
|
25172
|
+
const reportPath = join20(artifactsDir, "report.json");
|
|
25173
|
+
const evidencePath = join20(artifactsDir, "evidence.json");
|
|
25604
25174
|
await writeFile5(
|
|
25605
25175
|
reportPath,
|
|
25606
25176
|
`${JSON.stringify(
|
|
@@ -25690,8 +25260,8 @@ async function settleLawfulFixerTerminalResult(admitted, authority, options) {
|
|
|
25690
25260
|
async function publishCollectorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
25691
25261
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
25692
25262
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
25693
|
-
const reportPath =
|
|
25694
|
-
const evidencePath =
|
|
25263
|
+
const reportPath = join20(artifactsDir, "report.json");
|
|
25264
|
+
const evidencePath = join20(artifactsDir, "evidence.json");
|
|
25695
25265
|
await writeFile5(
|
|
25696
25266
|
reportPath,
|
|
25697
25267
|
`${JSON.stringify(
|
|
@@ -25750,7 +25320,7 @@ async function settleLawfulCollectorTerminalResult(admitted, authority) {
|
|
|
25750
25320
|
const residual = boundErroredToolCandidate(entries, index, message, COLLECTOR_WAIT_TOOL);
|
|
25751
25321
|
if (residual === void 0) continue;
|
|
25752
25322
|
const candidate = residual.candidate;
|
|
25753
|
-
const duration =
|
|
25323
|
+
const duration = isRecord15(candidate) ? candidate.durationMs : void 0;
|
|
25754
25324
|
if (Number.isSafeInteger(duration) && duration >= 1 && duration <= 9e5) {
|
|
25755
25325
|
continue;
|
|
25756
25326
|
}
|
|
@@ -25798,8 +25368,8 @@ async function trySettleCollectorTerminalResult(admitted, authority) {
|
|
|
25798
25368
|
async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
25799
25369
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
25800
25370
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
25801
|
-
const reportPath =
|
|
25802
|
-
const evidencePath =
|
|
25371
|
+
const reportPath = join20(artifactsDir, "report.json");
|
|
25372
|
+
const evidencePath = join20(artifactsDir, "evidence.json");
|
|
25803
25373
|
await writeFile5(
|
|
25804
25374
|
reportPath,
|
|
25805
25375
|
`${JSON.stringify(
|
|
@@ -25940,7 +25510,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
25940
25510
|
spec.toolName
|
|
25941
25511
|
);
|
|
25942
25512
|
if (residual !== void 0) {
|
|
25943
|
-
const details =
|
|
25513
|
+
const details = isRecord15(residual.candidate) ? residual.candidate : { candidate: residual.candidate };
|
|
25944
25514
|
return settleFailureTerminalResult(admitted, {
|
|
25945
25515
|
cause: "output",
|
|
25946
25516
|
diagnostic: residual.diagnostic,
|
|
@@ -26059,8 +25629,8 @@ function extractReviewerMethodInvocations(entries, options) {
|
|
|
26059
25629
|
async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
26060
25630
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26061
25631
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26062
|
-
const reportPath =
|
|
26063
|
-
const evidencePath =
|
|
25632
|
+
const reportPath = join20(artifactsDir, "report.json");
|
|
25633
|
+
const evidencePath = join20(artifactsDir, "evidence.json");
|
|
26064
25634
|
await writeFile5(
|
|
26065
25635
|
reportPath,
|
|
26066
25636
|
`${JSON.stringify(
|
|
@@ -26174,8 +25744,8 @@ function extractMergerMethodInvocations(entries, options) {
|
|
|
26174
25744
|
async function publishMergerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
26175
25745
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26176
25746
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26177
|
-
const reportPath =
|
|
26178
|
-
const evidencePath =
|
|
25747
|
+
const reportPath = join20(artifactsDir, "report.json");
|
|
25748
|
+
const evidencePath = join20(artifactsDir, "evidence.json");
|
|
26179
25749
|
await writeFile5(
|
|
26180
25750
|
reportPath,
|
|
26181
25751
|
`${JSON.stringify(
|
|
@@ -26242,7 +25812,7 @@ async function settleLawfulMergerTerminalResult(admitted, authority, options) {
|
|
|
26242
25812
|
if (message?.role !== "toolResult") continue;
|
|
26243
25813
|
const residual = boundErroredToolCandidate(entries, index, message, MERGER_OUTPUT_TOOL_NAME);
|
|
26244
25814
|
if (residual === void 0) continue;
|
|
26245
|
-
const attemptId =
|
|
25815
|
+
const attemptId = isRecord15(residual.candidate) ? safelyRead(residual.candidate, "attemptId") : { readable: true, value: void 0 };
|
|
26246
25816
|
if (!attemptId.readable || attemptId.value !== admitted.runId) continue;
|
|
26247
25817
|
return {
|
|
26248
25818
|
roleOutcome: buildResidualIncompleteTerminalOutcome({
|
|
@@ -26320,7 +25890,7 @@ function uniqueFailureFallbackDirs(runDirectory, baseDir) {
|
|
|
26320
25890
|
return dirs;
|
|
26321
25891
|
}
|
|
26322
25892
|
async function resolveFailureArtifactsBase(runDirectory) {
|
|
26323
|
-
const artifactsDir =
|
|
25893
|
+
const artifactsDir = join20(runDirectory, "artifacts");
|
|
26324
25894
|
try {
|
|
26325
25895
|
await ensureRunArtifactsDir(runDirectory);
|
|
26326
25896
|
return { baseDir: artifactsDir };
|
|
@@ -26336,7 +25906,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
26336
25906
|
const candidates = [
|
|
26337
25907
|
...preferredCandidates,
|
|
26338
25908
|
// One unique name per fallback dir — collisions on fixed names cannot exhaust this.
|
|
26339
|
-
...uniqueFallbackDirs.map((dir) =>
|
|
25909
|
+
...uniqueFallbackDirs.map((dir) => join20(dir, `${stem}.${randomUUID3()}.json`))
|
|
26340
25910
|
];
|
|
26341
25911
|
for (let i = 0; i < candidates.length; i += 1) {
|
|
26342
25912
|
const path = candidates[i];
|
|
@@ -26381,26 +25951,26 @@ async function publishFailureArtifacts(admitted, failure, authority) {
|
|
|
26381
25951
|
} catch (error) {
|
|
26382
25952
|
priorIssues.push(publicationAttemptFromError(sessionFile, error));
|
|
26383
25953
|
}
|
|
26384
|
-
const underArtifacts = baseDir ===
|
|
25954
|
+
const underArtifacts = baseDir === join20(admitted.runDirectory, "artifacts");
|
|
26385
25955
|
const uniqueFallbackDirs = uniqueFailureFallbackDirs(
|
|
26386
25956
|
admitted.runDirectory,
|
|
26387
25957
|
baseDir
|
|
26388
25958
|
);
|
|
26389
25959
|
const errorCandidates = underArtifacts ? [
|
|
26390
|
-
|
|
26391
|
-
|
|
26392
|
-
|
|
25960
|
+
join20(baseDir, "error.json"),
|
|
25961
|
+
join20(baseDir, "error.settlement.json"),
|
|
25962
|
+
join20(admitted.runDirectory, "error.settlement.json")
|
|
26393
25963
|
] : [
|
|
26394
|
-
|
|
26395
|
-
|
|
25964
|
+
join20(baseDir, "error.settlement.json"),
|
|
25965
|
+
join20(baseDir, "error.json")
|
|
26396
25966
|
];
|
|
26397
25967
|
const evidenceCandidates = underArtifacts ? [
|
|
26398
|
-
|
|
26399
|
-
|
|
26400
|
-
|
|
25968
|
+
join20(baseDir, "evidence.json"),
|
|
25969
|
+
join20(baseDir, "evidence.settlement.json"),
|
|
25970
|
+
join20(admitted.runDirectory, "evidence.settlement.json")
|
|
26401
25971
|
] : [
|
|
26402
|
-
|
|
26403
|
-
|
|
25972
|
+
join20(baseDir, "evidence.settlement.json"),
|
|
25973
|
+
join20(baseDir, "evidence.json")
|
|
26404
25974
|
];
|
|
26405
25975
|
const errorPayloadBase = {
|
|
26406
25976
|
kind: "error",
|
|
@@ -26666,9 +26236,336 @@ function projectRoleTurnRequest(admitted, roleDetails, options) {
|
|
|
26666
26236
|
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
26667
26237
|
};
|
|
26668
26238
|
}
|
|
26669
|
-
var init_turn_request = __esm({
|
|
26670
|
-
"src/public-cli/turn-request.ts"() {
|
|
26239
|
+
var init_turn_request = __esm({
|
|
26240
|
+
"src/public-cli/turn-request.ts"() {
|
|
26241
|
+
"use strict";
|
|
26242
|
+
}
|
|
26243
|
+
});
|
|
26244
|
+
|
|
26245
|
+
// src/ticket-provenance-contracts.ts
|
|
26246
|
+
function isRecord16(value) {
|
|
26247
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26248
|
+
}
|
|
26249
|
+
function projectTicketProvenanceDiagnostic(value) {
|
|
26250
|
+
if (!isRecord16(value)) return void 0;
|
|
26251
|
+
if (value.recordClass !== TICKET_PROVENANCE_RECORD_CLASS_DIAGNOSTIC) {
|
|
26252
|
+
return void 0;
|
|
26253
|
+
}
|
|
26254
|
+
if (typeof value.diagnosticKind !== "string" || !DIAGNOSTIC_KINDS.has(value.diagnosticKind)) {
|
|
26255
|
+
return void 0;
|
|
26256
|
+
}
|
|
26257
|
+
if (typeof value.cause !== "string" || value.cause.length === 0) {
|
|
26258
|
+
return void 0;
|
|
26259
|
+
}
|
|
26260
|
+
if (typeof value.recordedAt !== "string" || value.recordedAt.length === 0) {
|
|
26261
|
+
return void 0;
|
|
26262
|
+
}
|
|
26263
|
+
return {
|
|
26264
|
+
recordClass: TICKET_PROVENANCE_RECORD_CLASS_DIAGNOSTIC,
|
|
26265
|
+
diagnosticKind: value.diagnosticKind,
|
|
26266
|
+
cause: value.cause,
|
|
26267
|
+
recordedAt: value.recordedAt,
|
|
26268
|
+
...typeof value.reason === "string" ? { reason: value.reason } : {}
|
|
26269
|
+
};
|
|
26270
|
+
}
|
|
26271
|
+
function projectTicketProvenanceEntry(value) {
|
|
26272
|
+
if (!isRecord16(value)) return void 0;
|
|
26273
|
+
if (value.recordClass === TICKET_PROVENANCE_RECORD_CLASS_DIAGNOSTIC) {
|
|
26274
|
+
return void 0;
|
|
26275
|
+
}
|
|
26276
|
+
if (!isRecord16(value.basis)) return void 0;
|
|
26277
|
+
if (typeof value.basis.method !== "string" || !BASIS_METHODS.has(value.basis.method)) {
|
|
26278
|
+
return void 0;
|
|
26279
|
+
}
|
|
26280
|
+
if (typeof value.sourceKind !== "string" || !SOURCE_KINDS.has(value.sourceKind)) {
|
|
26281
|
+
return void 0;
|
|
26282
|
+
}
|
|
26283
|
+
if (!isRecord16(value.sourceRef)) return void 0;
|
|
26284
|
+
if (typeof value.transcript !== "string" || value.transcript.length === 0) {
|
|
26285
|
+
return void 0;
|
|
26286
|
+
}
|
|
26287
|
+
if (typeof value.timestamp !== "string" || value.timestamp.length === 0) {
|
|
26288
|
+
return void 0;
|
|
26289
|
+
}
|
|
26290
|
+
const basis = {
|
|
26291
|
+
method: value.basis.method,
|
|
26292
|
+
...Array.isArray(value.basis.anchors) ? {
|
|
26293
|
+
anchors: value.basis.anchors.filter(
|
|
26294
|
+
(item) => typeof item === "string"
|
|
26295
|
+
)
|
|
26296
|
+
} : {},
|
|
26297
|
+
...typeof value.basis.note === "string" ? { note: value.basis.note } : {}
|
|
26298
|
+
};
|
|
26299
|
+
const sourceRef = {
|
|
26300
|
+
...typeof value.sourceRef.sessionFile === "string" ? { sessionFile: value.sourceRef.sessionFile } : {},
|
|
26301
|
+
...typeof value.sourceRef.entryId === "string" || typeof value.sourceRef.entryId === "number" ? { entryId: value.sourceRef.entryId } : {},
|
|
26302
|
+
...typeof value.sourceRef.path === "string" ? { path: value.sourceRef.path } : {},
|
|
26303
|
+
...typeof value.sourceRef.url === "string" ? { url: value.sourceRef.url } : {}
|
|
26304
|
+
};
|
|
26305
|
+
return {
|
|
26306
|
+
basis,
|
|
26307
|
+
sourceKind: value.sourceKind,
|
|
26308
|
+
sourceRef,
|
|
26309
|
+
transcript: value.transcript,
|
|
26310
|
+
timestamp: value.timestamp
|
|
26311
|
+
};
|
|
26312
|
+
}
|
|
26313
|
+
var TICKET_PROVENANCE_KIND, TICKET_PROVENANCE_HUMAN_VIEW, TICKET_PROVENANCE_OFFERED_WATERMARK, TICKET_PROVENANCE_RECORD_CLASS_DIAGNOSTIC, SOURCE_KINDS, BASIS_METHODS, DIAGNOSTIC_KINDS;
|
|
26314
|
+
var init_ticket_provenance_contracts = __esm({
|
|
26315
|
+
"src/ticket-provenance-contracts.ts"() {
|
|
26316
|
+
"use strict";
|
|
26317
|
+
TICKET_PROVENANCE_KIND = "ticket-provenance";
|
|
26318
|
+
TICKET_PROVENANCE_HUMAN_VIEW = "\u8D77\u5C45\u5F55.md";
|
|
26319
|
+
TICKET_PROVENANCE_OFFERED_WATERMARK = "offered-identities.jsonl";
|
|
26320
|
+
TICKET_PROVENANCE_RECORD_CLASS_DIAGNOSTIC = "diagnostic";
|
|
26321
|
+
SOURCE_KINDS = /* @__PURE__ */ new Set([
|
|
26322
|
+
"cc-session",
|
|
26323
|
+
"issue-body-comment",
|
|
26324
|
+
"adr-decision-key",
|
|
26325
|
+
"ticket-decree-block"
|
|
26326
|
+
]);
|
|
26327
|
+
BASIS_METHODS = /* @__PURE__ */ new Set(["llm-semantic"]);
|
|
26328
|
+
DIAGNOSTIC_KINDS = /* @__PURE__ */ new Set([
|
|
26329
|
+
"collector-failed",
|
|
26330
|
+
"issue-source-failed",
|
|
26331
|
+
"quote-verify-failed"
|
|
26332
|
+
]);
|
|
26333
|
+
}
|
|
26334
|
+
});
|
|
26335
|
+
|
|
26336
|
+
// src/ticket-provenance.ts
|
|
26337
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
26338
|
+
import { appendFileSync as appendFileSync2, existsSync as existsSync7, mkdirSync as mkdirSync3, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
26339
|
+
import { join as join21 } from "node:path";
|
|
26340
|
+
function ticketProvenanceSubject(ticketNumber) {
|
|
26341
|
+
if (!Number.isSafeInteger(ticketNumber) || ticketNumber < 1) {
|
|
26342
|
+
throw new Error(`ticket-provenance subject requires a positive ticket number, got ${String(ticketNumber)}`);
|
|
26343
|
+
}
|
|
26344
|
+
return String(ticketNumber);
|
|
26345
|
+
}
|
|
26346
|
+
function ticketProvenanceEntryIdentity(input) {
|
|
26347
|
+
const ref = input.sourceRef;
|
|
26348
|
+
const refKey = [
|
|
26349
|
+
ref.sessionFile ?? "",
|
|
26350
|
+
ref.entryId === void 0 ? "" : String(ref.entryId),
|
|
26351
|
+
ref.path ?? "",
|
|
26352
|
+
ref.url ?? ""
|
|
26353
|
+
].join("");
|
|
26354
|
+
const material = [
|
|
26355
|
+
String(input.ticketNumber),
|
|
26356
|
+
input.sourceKind,
|
|
26357
|
+
refKey,
|
|
26358
|
+
input.transcript
|
|
26359
|
+
].join("\0");
|
|
26360
|
+
return createHash5("sha256").update(material, "utf8").digest("hex");
|
|
26361
|
+
}
|
|
26362
|
+
function resolveTicketProvenanceVolume(ticketNumber, cwd, home) {
|
|
26363
|
+
const path = resolveSitianRecordPath({
|
|
26364
|
+
level: "event",
|
|
26365
|
+
kind: TICKET_PROVENANCE_KIND,
|
|
26366
|
+
subject: ticketProvenanceSubject(ticketNumber),
|
|
26367
|
+
cwd,
|
|
26368
|
+
...home === void 0 ? {} : { home }
|
|
26369
|
+
});
|
|
26370
|
+
return {
|
|
26371
|
+
recordFile: path.recordFile,
|
|
26372
|
+
volumeDir: path.sessionDir,
|
|
26373
|
+
humanViewFile: join21(path.sessionDir, TICKET_PROVENANCE_HUMAN_VIEW),
|
|
26374
|
+
offeredWatermarkFile: join21(path.sessionDir, TICKET_PROVENANCE_OFFERED_WATERMARK)
|
|
26375
|
+
};
|
|
26376
|
+
}
|
|
26377
|
+
function readOfferedIdentities(ticketNumber, cwd, home) {
|
|
26378
|
+
const { offeredWatermarkFile } = resolveTicketProvenanceVolume(ticketNumber, cwd, home);
|
|
26379
|
+
if (!existsSync7(offeredWatermarkFile)) return /* @__PURE__ */ new Set();
|
|
26380
|
+
let text;
|
|
26381
|
+
try {
|
|
26382
|
+
text = readFileSync2(offeredWatermarkFile, "utf8");
|
|
26383
|
+
} catch (error) {
|
|
26384
|
+
throw new TicketProvenanceWatermarkError(
|
|
26385
|
+
"unreadable",
|
|
26386
|
+
`ticket-provenance offered watermark unreadable (${offeredWatermarkFile})`,
|
|
26387
|
+
{ cause: error }
|
|
26388
|
+
);
|
|
26389
|
+
}
|
|
26390
|
+
const seen = /* @__PURE__ */ new Set();
|
|
26391
|
+
const lines = text.split("\n");
|
|
26392
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
26393
|
+
const trimmed = lines[index].trim();
|
|
26394
|
+
if (!trimmed) continue;
|
|
26395
|
+
let parsed;
|
|
26396
|
+
try {
|
|
26397
|
+
parsed = JSON.parse(trimmed);
|
|
26398
|
+
} catch (error) {
|
|
26399
|
+
throw new TicketProvenanceWatermarkError(
|
|
26400
|
+
"malformed-json",
|
|
26401
|
+
`ticket-provenance offered watermark malformed JSON at line ${index + 1} (${offeredWatermarkFile})`,
|
|
26402
|
+
{ cause: error }
|
|
26403
|
+
);
|
|
26404
|
+
}
|
|
26405
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed) || typeof parsed.identity !== "string" || parsed.identity.length === 0) {
|
|
26406
|
+
throw new TicketProvenanceWatermarkError(
|
|
26407
|
+
"bad-shape",
|
|
26408
|
+
`ticket-provenance offered watermark bad shape at line ${index + 1} (${offeredWatermarkFile})`
|
|
26409
|
+
);
|
|
26410
|
+
}
|
|
26411
|
+
seen.add(parsed.identity);
|
|
26412
|
+
}
|
|
26413
|
+
return seen;
|
|
26414
|
+
}
|
|
26415
|
+
async function readTicketProvenance(ticketNumber, cwd, home) {
|
|
26416
|
+
const { recordFile } = resolveTicketProvenanceVolume(ticketNumber, cwd, home);
|
|
26417
|
+
const { records: records2 } = await readSitianRecords(recordFile);
|
|
26418
|
+
const entries = [];
|
|
26419
|
+
const diagnostics = [];
|
|
26420
|
+
let skipped = 0;
|
|
26421
|
+
for (const record4 of records2) {
|
|
26422
|
+
if (record4.kind !== TICKET_PROVENANCE_KIND) {
|
|
26423
|
+
skipped += 1;
|
|
26424
|
+
continue;
|
|
26425
|
+
}
|
|
26426
|
+
const diagnostic = projectTicketProvenanceDiagnostic(record4.payload);
|
|
26427
|
+
if (diagnostic !== void 0) {
|
|
26428
|
+
diagnostics.push(diagnostic);
|
|
26429
|
+
continue;
|
|
26430
|
+
}
|
|
26431
|
+
const entry = projectTicketProvenanceEntry(record4.payload);
|
|
26432
|
+
if (entry === void 0) {
|
|
26433
|
+
skipped += 1;
|
|
26434
|
+
continue;
|
|
26435
|
+
}
|
|
26436
|
+
entries.push(entry);
|
|
26437
|
+
}
|
|
26438
|
+
return { entries, diagnostics, records: records2, recordFile, skipped };
|
|
26439
|
+
}
|
|
26440
|
+
function markdownFenceFor(text) {
|
|
26441
|
+
let longest = 0;
|
|
26442
|
+
const runs = text.match(/`+/g);
|
|
26443
|
+
if (runs !== null) {
|
|
26444
|
+
for (const run of runs) {
|
|
26445
|
+
if (run.length > longest) longest = run.length;
|
|
26446
|
+
}
|
|
26447
|
+
}
|
|
26448
|
+
return "`".repeat(Math.max(3, longest + 1));
|
|
26449
|
+
}
|
|
26450
|
+
function renderTicketProvenanceMarkdown(input) {
|
|
26451
|
+
const lines = [
|
|
26452
|
+
`# \u8D77\u5C45\u5F55 \xB7 #${input.ticketNumber}`,
|
|
26453
|
+
"",
|
|
26454
|
+
`\u6761\u76EE\u6570\uFF1A${input.entries.length}`,
|
|
26455
|
+
""
|
|
26456
|
+
];
|
|
26457
|
+
let index = 0;
|
|
26458
|
+
for (const entry of input.entries) {
|
|
26459
|
+
index += 1;
|
|
26460
|
+
lines.push(`## ${index}. ${entry.sourceKind} \xB7 ${entry.timestamp}`);
|
|
26461
|
+
lines.push("");
|
|
26462
|
+
lines.push(`- basis.method: \`${entry.basis.method}\``);
|
|
26463
|
+
if (entry.basis.anchors !== void 0 && entry.basis.anchors.length > 0) {
|
|
26464
|
+
lines.push(`- anchors: ${entry.basis.anchors.map((a) => `\`${a}\``).join(", ")}`);
|
|
26465
|
+
}
|
|
26466
|
+
if (entry.basis.note !== void 0) {
|
|
26467
|
+
lines.push(`- note: ${entry.basis.note}`);
|
|
26468
|
+
}
|
|
26469
|
+
const refParts = [];
|
|
26470
|
+
if (entry.sourceRef.sessionFile !== void 0) {
|
|
26471
|
+
refParts.push(`sessionFile=${entry.sourceRef.sessionFile}`);
|
|
26472
|
+
}
|
|
26473
|
+
if (entry.sourceRef.entryId !== void 0) {
|
|
26474
|
+
refParts.push(`entryId=${String(entry.sourceRef.entryId)}`);
|
|
26475
|
+
}
|
|
26476
|
+
if (entry.sourceRef.path !== void 0) {
|
|
26477
|
+
refParts.push(`path=${entry.sourceRef.path}`);
|
|
26478
|
+
}
|
|
26479
|
+
if (entry.sourceRef.url !== void 0) {
|
|
26480
|
+
refParts.push(`url=${entry.sourceRef.url}`);
|
|
26481
|
+
}
|
|
26482
|
+
if (refParts.length > 0) {
|
|
26483
|
+
lines.push(`- sourceRef: ${refParts.join(" \xB7 ")}`);
|
|
26484
|
+
}
|
|
26485
|
+
lines.push("");
|
|
26486
|
+
const fence = markdownFenceFor(entry.transcript);
|
|
26487
|
+
lines.push(fence);
|
|
26488
|
+
lines.push(entry.transcript);
|
|
26489
|
+
lines.push(fence);
|
|
26490
|
+
lines.push("");
|
|
26491
|
+
}
|
|
26492
|
+
return lines.join("\n");
|
|
26493
|
+
}
|
|
26494
|
+
function ensureTicketProvenanceVolume(ticketNumber, cwd, home) {
|
|
26495
|
+
const volume = resolveTicketProvenanceVolume(ticketNumber, cwd, home);
|
|
26496
|
+
mkdirSync3(volume.volumeDir, { recursive: true });
|
|
26497
|
+
appendFileSync2(volume.recordFile, "", "utf8");
|
|
26498
|
+
return volume;
|
|
26499
|
+
}
|
|
26500
|
+
function appendTicketProvenanceDiagnostic(input) {
|
|
26501
|
+
const subject = ticketProvenanceSubject(input.ticketNumber);
|
|
26502
|
+
const identityParts = input.diagnostic.diagnosticKind === "quote-verify-failed" ? [
|
|
26503
|
+
subject,
|
|
26504
|
+
input.diagnostic.recordClass,
|
|
26505
|
+
input.diagnostic.diagnosticKind,
|
|
26506
|
+
input.diagnostic.cause,
|
|
26507
|
+
input.diagnostic.reason ?? ""
|
|
26508
|
+
] : [
|
|
26509
|
+
subject,
|
|
26510
|
+
input.diagnostic.recordClass,
|
|
26511
|
+
input.diagnostic.diagnosticKind,
|
|
26512
|
+
input.diagnostic.recordedAt,
|
|
26513
|
+
input.diagnostic.cause,
|
|
26514
|
+
input.diagnostic.reason ?? ""
|
|
26515
|
+
];
|
|
26516
|
+
const identity = createHash5("sha256").update(identityParts.join("\0"), "utf8").digest("hex");
|
|
26517
|
+
return sitianReport({
|
|
26518
|
+
level: "event",
|
|
26519
|
+
kind: TICKET_PROVENANCE_KIND,
|
|
26520
|
+
identity,
|
|
26521
|
+
subject,
|
|
26522
|
+
cwd: input.cwd,
|
|
26523
|
+
...input.home === void 0 ? {} : { home: input.home },
|
|
26524
|
+
host: input.host ?? "diarist",
|
|
26525
|
+
source: input.source ?? "diarist-diagnostic",
|
|
26526
|
+
payload: input.diagnostic
|
|
26527
|
+
});
|
|
26528
|
+
}
|
|
26529
|
+
function appendIssueSourceFailureDiagnostic(input) {
|
|
26530
|
+
const recordedAt = input.recordedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
26531
|
+
return appendTicketProvenanceDiagnostic({
|
|
26532
|
+
ticketNumber: input.ticketNumber,
|
|
26533
|
+
cwd: input.cwd,
|
|
26534
|
+
...input.home === void 0 ? {} : { home: input.home },
|
|
26535
|
+
source: "diarist-issue-source",
|
|
26536
|
+
diagnostic: {
|
|
26537
|
+
recordClass: TICKET_PROVENANCE_RECORD_CLASS_DIAGNOSTIC,
|
|
26538
|
+
diagnosticKind: "issue-source-failed",
|
|
26539
|
+
cause: input.cause,
|
|
26540
|
+
recordedAt,
|
|
26541
|
+
reason: input.reason
|
|
26542
|
+
}
|
|
26543
|
+
});
|
|
26544
|
+
}
|
|
26545
|
+
function writeTicketProvenanceHumanView(input) {
|
|
26546
|
+
const volume = ensureTicketProvenanceVolume(input.ticketNumber, input.cwd, input.home);
|
|
26547
|
+
const md = renderTicketProvenanceMarkdown({
|
|
26548
|
+
ticketNumber: input.ticketNumber,
|
|
26549
|
+
entries: input.entries
|
|
26550
|
+
});
|
|
26551
|
+
writeFileSync2(volume.humanViewFile, md, "utf8");
|
|
26552
|
+
return volume.humanViewFile;
|
|
26553
|
+
}
|
|
26554
|
+
var TicketProvenanceWatermarkError;
|
|
26555
|
+
var init_ticket_provenance = __esm({
|
|
26556
|
+
"src/ticket-provenance.ts"() {
|
|
26671
26557
|
"use strict";
|
|
26558
|
+
init_sitian_facade();
|
|
26559
|
+
init_ticket_provenance_contracts();
|
|
26560
|
+
TicketProvenanceWatermarkError = class extends Error {
|
|
26561
|
+
code = "ticket-provenance-watermark";
|
|
26562
|
+
reason;
|
|
26563
|
+
constructor(reason, message, options) {
|
|
26564
|
+
super(message, options);
|
|
26565
|
+
this.name = "TicketProvenanceWatermarkError";
|
|
26566
|
+
this.reason = reason;
|
|
26567
|
+
}
|
|
26568
|
+
};
|
|
26672
26569
|
}
|
|
26673
26570
|
});
|
|
26674
26571
|
|
|
@@ -27854,12 +27751,7 @@ async function runPublicCoder(argv, env, io, parseCoderArgv2) {
|
|
|
27854
27751
|
})
|
|
27855
27752
|
}
|
|
27856
27753
|
}),
|
|
27857
|
-
adapters:
|
|
27858
|
-
...coderAdapters(methodProvenance),
|
|
27859
|
-
beforeDispatch: async (admittedSeat) => {
|
|
27860
|
-
await resolveSeatTicketBinding(admittedSeat, env);
|
|
27861
|
-
}
|
|
27862
|
-
},
|
|
27754
|
+
adapters: coderAdapters(methodProvenance),
|
|
27863
27755
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
27864
27756
|
});
|
|
27865
27757
|
}
|
|
@@ -27919,7 +27811,6 @@ var init_coder_run = __esm({
|
|
|
27919
27811
|
init_method_skill();
|
|
27920
27812
|
init_cli_errors();
|
|
27921
27813
|
init_invocation();
|
|
27922
|
-
init_seat_ticket_binding();
|
|
27923
27814
|
init_run_lifecycle();
|
|
27924
27815
|
init_settlement();
|
|
27925
27816
|
init_turn_request();
|
|
@@ -27927,6 +27818,30 @@ var init_coder_run = __esm({
|
|
|
27927
27818
|
}
|
|
27928
27819
|
});
|
|
27929
27820
|
|
|
27821
|
+
// src/public-cli/seat-ticket-binding.ts
|
|
27822
|
+
async function tryResumeSameTicketSeatRun(input) {
|
|
27823
|
+
if (input.freshSummons === true) return void 0;
|
|
27824
|
+
if (input.parentRunPath === void 0 && input.ticketNumber === void 0) {
|
|
27825
|
+
return void 0;
|
|
27826
|
+
}
|
|
27827
|
+
const previousRunId = await findLatestRunIdForSeatTicket({
|
|
27828
|
+
home: input.home,
|
|
27829
|
+
bookKey: resolveBookKeyFromGit(input.projectRoot),
|
|
27830
|
+
role: input.role,
|
|
27831
|
+
...input.parentRunPath === void 0 ? {} : { parentRunPath: input.parentRunPath },
|
|
27832
|
+
...input.ticketNumber === void 0 ? {} : { ticketNumber: input.ticketNumber }
|
|
27833
|
+
});
|
|
27834
|
+
if (previousRunId === void 0) return void 0;
|
|
27835
|
+
return await input.resume(previousRunId, input.summons);
|
|
27836
|
+
}
|
|
27837
|
+
var init_seat_ticket_binding = __esm({
|
|
27838
|
+
"src/public-cli/seat-ticket-binding.ts"() {
|
|
27839
|
+
"use strict";
|
|
27840
|
+
init_activation_ledger_git();
|
|
27841
|
+
init_run_lifecycle();
|
|
27842
|
+
}
|
|
27843
|
+
});
|
|
27844
|
+
|
|
27930
27845
|
// src/public-cli/instruction-seat-run.ts
|
|
27931
27846
|
function buildInstructionSeatTurnRequest(admitted, options) {
|
|
27932
27847
|
return projectRoleTurnRequest(
|
|
@@ -28048,7 +27963,6 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
28048
27963
|
let auditorSubject;
|
|
28049
27964
|
let auditorSourceRun;
|
|
28050
27965
|
let auditorSourceTicket;
|
|
28051
|
-
let reusedTicketNumber;
|
|
28052
27966
|
const projectRoot = parsed.project ?? env.cwd;
|
|
28053
27967
|
if (role === "auditor") {
|
|
28054
27968
|
if (parsed.subject !== "judge" && parsed.subject !== "doctor") {
|
|
@@ -28083,12 +27997,6 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
28083
27997
|
);
|
|
28084
27998
|
return { exitCode: 2 };
|
|
28085
27999
|
}
|
|
28086
|
-
} else {
|
|
28087
|
-
reusedTicketNumber = await resolveKnownTicketNumber({
|
|
28088
|
-
instruction: parsed.instruction,
|
|
28089
|
-
projectRoot,
|
|
28090
|
-
home: env.home
|
|
28091
|
-
});
|
|
28092
28000
|
}
|
|
28093
28001
|
const summons = {
|
|
28094
28002
|
instruction: parsed.instruction,
|
|
@@ -28114,21 +28022,6 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
28114
28022
|
})
|
|
28115
28023
|
});
|
|
28116
28024
|
if (resumed !== void 0) return resumed;
|
|
28117
|
-
} else if (reusedTicketNumber !== void 0) {
|
|
28118
|
-
const resumed = await tryResumeSameTicketSeatRun({
|
|
28119
|
-
home: env.home,
|
|
28120
|
-
projectRoot,
|
|
28121
|
-
role,
|
|
28122
|
-
ticketNumber: reusedTicketNumber,
|
|
28123
|
-
freshSummons: env.freshSummons,
|
|
28124
|
-
summons,
|
|
28125
|
-
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
28126
|
-
{ runId, ...materials === void 0 ? {} : { summons: materials } },
|
|
28127
|
-
env,
|
|
28128
|
-
io
|
|
28129
|
-
)
|
|
28130
|
-
});
|
|
28131
|
-
if (resumed !== void 0) return resumed;
|
|
28132
28025
|
}
|
|
28133
28026
|
let admitted;
|
|
28134
28027
|
try {
|
|
@@ -28186,8 +28079,6 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
28186
28079
|
beforeDispatch: async (admittedSeat) => {
|
|
28187
28080
|
if (auditorSourceTicket !== void 0) {
|
|
28188
28081
|
await bindAdmittedTicketNumber(admittedSeat, auditorSourceTicket);
|
|
28189
|
-
} else {
|
|
28190
|
-
await bindReusedTicketNumber(admittedSeat, reusedTicketNumber);
|
|
28191
28082
|
}
|
|
28192
28083
|
}
|
|
28193
28084
|
}),
|
|
@@ -28320,7 +28211,7 @@ var init_collector_run = __esm({
|
|
|
28320
28211
|
|
|
28321
28212
|
// src/diarist-mechanical.ts
|
|
28322
28213
|
import { createHash as createHash6 } from "node:crypto";
|
|
28323
|
-
import { existsSync as
|
|
28214
|
+
import { existsSync as existsSync8, readdirSync as readdirSync2, readFileSync as readFileSync3, realpathSync as realpathSync3, statSync as statSync2 } from "node:fs";
|
|
28324
28215
|
import { basename as basename7, join as join25, resolve as resolve10 } from "node:path";
|
|
28325
28216
|
import { homedir } from "node:os";
|
|
28326
28217
|
function extractCornerQuotes(text, minLength = DEFAULT_QUOTE_MIN) {
|
|
@@ -28402,7 +28293,7 @@ function isNotificationRow(type, text) {
|
|
|
28402
28293
|
}
|
|
28403
28294
|
function readCcSessionBlocks(options) {
|
|
28404
28295
|
const root = options.projectsRoot ?? join25(homedir(), ".claude", "projects");
|
|
28405
|
-
if (!
|
|
28296
|
+
if (!existsSync8(root)) return [];
|
|
28406
28297
|
const blocks = [];
|
|
28407
28298
|
const dirs = /* @__PURE__ */ new Set();
|
|
28408
28299
|
for (const cwd of options.cwds) {
|
|
@@ -28411,10 +28302,10 @@ function readCcSessionBlocks(options) {
|
|
|
28411
28302
|
for (const cwd of options.cwds) {
|
|
28412
28303
|
if (cwd.includes("projects")) continue;
|
|
28413
28304
|
const direct = join25(root, cwd);
|
|
28414
|
-
if (
|
|
28305
|
+
if (existsSync8(direct)) dirs.add(direct);
|
|
28415
28306
|
}
|
|
28416
28307
|
for (const dir of dirs) {
|
|
28417
|
-
if (!
|
|
28308
|
+
if (!existsSync8(dir)) continue;
|
|
28418
28309
|
let dirStat;
|
|
28419
28310
|
try {
|
|
28420
28311
|
dirStat = statSync2(dir);
|
|
@@ -28539,7 +28430,7 @@ function readAdrDecisionKeyBlocks(input) {
|
|
|
28539
28430
|
const adrRootAbs = resolve10(cwdAbs, DIARIST_ADR_ROOT_REL);
|
|
28540
28431
|
let adrRootReal;
|
|
28541
28432
|
try {
|
|
28542
|
-
adrRootReal =
|
|
28433
|
+
adrRootReal = existsSync8(adrRootAbs) ? realpathSync3(adrRootAbs) : resolve10(realpathSync3(cwdAbs), DIARIST_ADR_ROOT_REL);
|
|
28543
28434
|
} catch (error) {
|
|
28544
28435
|
throw new DiaristSourceReadError(
|
|
28545
28436
|
"adr-unreadable",
|
|
@@ -28565,7 +28456,7 @@ function readAdrDecisionKeyBlocks(input) {
|
|
|
28565
28456
|
`diarist referenced ADR escapes docs/adr (${rel})`
|
|
28566
28457
|
);
|
|
28567
28458
|
}
|
|
28568
|
-
if (!
|
|
28459
|
+
if (!existsSync8(abs)) {
|
|
28569
28460
|
throw new DiaristSourceReadError(
|
|
28570
28461
|
"adr-missing",
|
|
28571
28462
|
abs,
|
|
@@ -28797,22 +28688,28 @@ function loadSourceBlocks(input) {
|
|
|
28797
28688
|
return blocks;
|
|
28798
28689
|
}
|
|
28799
28690
|
async function prepareDiaristSourceCatalog(input) {
|
|
28800
|
-
|
|
28801
|
-
|
|
28802
|
-
|
|
28803
|
-
|
|
28804
|
-
|
|
28805
|
-
|
|
28806
|
-
|
|
28807
|
-
|
|
28691
|
+
const known = input.ticketNumber;
|
|
28692
|
+
if (known !== void 0) {
|
|
28693
|
+
ensureTicketProvenanceVolume(known, input.cwd, input.home);
|
|
28694
|
+
const volume = await readTicketProvenance(known, input.cwd, input.home);
|
|
28695
|
+
writeTicketProvenanceHumanView({
|
|
28696
|
+
ticketNumber: known,
|
|
28697
|
+
cwd: input.cwd,
|
|
28698
|
+
...input.home === void 0 ? {} : { home: input.home },
|
|
28699
|
+
entries: volume.entries
|
|
28700
|
+
});
|
|
28701
|
+
}
|
|
28808
28702
|
const rawBlocks = loadSourceBlocks(input);
|
|
28809
28703
|
const safeguarded = mechanicalSafeguardPipeline(rawBlocks);
|
|
28810
|
-
const seen = await loadSeenEntryIdentities(
|
|
28704
|
+
const seen = known === void 0 ? /* @__PURE__ */ new Set() : await loadSeenEntryIdentities(known, input.cwd, input.home);
|
|
28811
28705
|
const fresh = safeguarded.filter(
|
|
28812
|
-
(block) => !seen.has(blockEntryIdentity(
|
|
28706
|
+
(block) => known === void 0 || !seen.has(blockEntryIdentity(known, block))
|
|
28813
28707
|
);
|
|
28814
28708
|
return {
|
|
28815
|
-
ticketNumber:
|
|
28709
|
+
...known === void 0 ? {} : { ticketNumber: known },
|
|
28710
|
+
instruction: input.instruction,
|
|
28711
|
+
runDirectory: input.runDirectory,
|
|
28712
|
+
projectRoot: input.projectRoot,
|
|
28816
28713
|
cwd: input.cwd,
|
|
28817
28714
|
...input.home === void 0 ? {} : { home: input.home },
|
|
28818
28715
|
candidates: fresh.map((block, candidateIndex) => ({ ...block, candidateIndex }))
|
|
@@ -28850,7 +28747,7 @@ __export(diarist_run_exports, {
|
|
|
28850
28747
|
runPublicDiarist: () => runPublicDiarist,
|
|
28851
28748
|
runPublicDiaristResume: () => runPublicDiaristResume
|
|
28852
28749
|
});
|
|
28853
|
-
import { existsSync as
|
|
28750
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
28854
28751
|
import { writeFile as writeFile7 } from "node:fs/promises";
|
|
28855
28752
|
import { join as join26 } from "node:path";
|
|
28856
28753
|
function withDiaristCatalogPath(prompt, sourcesPath) {
|
|
@@ -28877,22 +28774,24 @@ function buildDiaristTurnRequest(admitted, options, sourcesPath) {
|
|
|
28877
28774
|
);
|
|
28878
28775
|
}
|
|
28879
28776
|
async function freezeDiaristSourceCatalog(admitted, env) {
|
|
28880
|
-
if (admitted.ticketNumber === void 0) return void 0;
|
|
28881
28777
|
const path = join26(admitted.runDirectory, DIARIST_SOURCE_CATALOG_FILE);
|
|
28882
|
-
if (
|
|
28778
|
+
if (existsSync9(path)) {
|
|
28883
28779
|
const identity = await readRoleRunIdentity(admitted.runDirectory);
|
|
28884
28780
|
if (identity !== void 0 && identity.state !== "terminal") return path;
|
|
28885
28781
|
}
|
|
28886
|
-
const issueFace = await loadDiaristIssueFace({
|
|
28782
|
+
const issueFace = admitted.ticketNumber === void 0 ? void 0 : await loadDiaristIssueFace({
|
|
28887
28783
|
ticketNumber: admitted.ticketNumber,
|
|
28888
28784
|
projectRoot: admitted.projectRoot,
|
|
28889
28785
|
home: env.home
|
|
28890
28786
|
});
|
|
28891
28787
|
const catalog = await prepareDiaristSourceCatalog({
|
|
28892
|
-
ticketNumber: admitted.ticketNumber,
|
|
28788
|
+
...admitted.ticketNumber === void 0 ? {} : { ticketNumber: admitted.ticketNumber },
|
|
28789
|
+
instruction: admitted.instruction,
|
|
28790
|
+
runDirectory: admitted.runDirectory,
|
|
28791
|
+
projectRoot: admitted.projectRoot,
|
|
28893
28792
|
cwd: admitted.projectRoot,
|
|
28894
28793
|
home: env.home,
|
|
28895
|
-
issueFace,
|
|
28794
|
+
...issueFace === void 0 ? {} : { issueFace },
|
|
28896
28795
|
sessionCwds: [admitted.projectRoot, env.cwd]
|
|
28897
28796
|
});
|
|
28898
28797
|
await writeFile7(path, serializeDiaristSourceCatalog(catalog), "utf8");
|
|
@@ -28917,12 +28816,8 @@ async function runPublicDiarist(argv, env, io, parseDiaristArgv2) {
|
|
|
28917
28816
|
throw error;
|
|
28918
28817
|
}
|
|
28919
28818
|
const projectRoot = parsed.project ?? env.cwd;
|
|
28920
|
-
const
|
|
28921
|
-
|
|
28922
|
-
projectRoot,
|
|
28923
|
-
home: env.home
|
|
28924
|
-
});
|
|
28925
|
-
if (reusedTicketNumber !== void 0) {
|
|
28819
|
+
const handoffTicket = env.boundTicketNumber;
|
|
28820
|
+
if (typeof handoffTicket === "number" && Number.isSafeInteger(handoffTicket) && handoffTicket >= 1) {
|
|
28926
28821
|
const summons = {
|
|
28927
28822
|
instruction: parsed.instruction,
|
|
28928
28823
|
instructionEmpty: parsed.instruction.trim() === "",
|
|
@@ -28932,7 +28827,7 @@ async function runPublicDiarist(argv, env, io, parseDiaristArgv2) {
|
|
|
28932
28827
|
home: env.home,
|
|
28933
28828
|
projectRoot,
|
|
28934
28829
|
role: "diarist",
|
|
28935
|
-
ticketNumber:
|
|
28830
|
+
ticketNumber: handoffTicket,
|
|
28936
28831
|
freshSummons: env.freshSummons,
|
|
28937
28832
|
summons,
|
|
28938
28833
|
resume: (runId, materials) => runPublicDiaristResume(
|
|
@@ -28964,6 +28859,9 @@ async function runPublicDiarist(argv, env, io, parseDiaristArgv2) {
|
|
|
28964
28859
|
throw error;
|
|
28965
28860
|
}
|
|
28966
28861
|
await markRunAdmitted(admitted, env.principalAuthority);
|
|
28862
|
+
if (typeof handoffTicket === "number" && Number.isSafeInteger(handoffTicket) && handoffTicket >= 1) {
|
|
28863
|
+
await bindAdmittedTicketNumber(admitted, handoffTicket);
|
|
28864
|
+
}
|
|
28967
28865
|
const turnProjection = {
|
|
28968
28866
|
packageRoot: env.packageRoot,
|
|
28969
28867
|
home: env.home,
|
|
@@ -28991,7 +28889,6 @@ async function runPublicDiarist(argv, env, io, parseDiaristArgv2) {
|
|
|
28991
28889
|
request: turnRequest,
|
|
28992
28890
|
adapters: diaristAdapters({
|
|
28993
28891
|
beforeDispatch: async (admittedSeat) => {
|
|
28994
|
-
await bindReusedTicketNumber(admittedSeat, reusedTicketNumber);
|
|
28995
28892
|
const sourcesPath = await freezeDiaristSourceCatalog(admittedSeat, env);
|
|
28996
28893
|
Object.assign(
|
|
28997
28894
|
turnRequest,
|
|
@@ -29000,6 +28897,21 @@ async function runPublicDiarist(argv, env, io, parseDiaristArgv2) {
|
|
|
29000
28897
|
}
|
|
29001
28898
|
}),
|
|
29002
28899
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
28900
|
+
}).then(async (result2) => {
|
|
28901
|
+
if (admitted.ticketNumber === void 0 && result2.admitted !== void 0) {
|
|
28902
|
+
const roleOutcome = result2.terminal?.roleOutcome;
|
|
28903
|
+
if (roleOutcome !== void 0 && roleOutcome.kind === "accepted" && roleOutcome.status !== "escalate") {
|
|
28904
|
+
const facts = roleOutcome.decisiveFacts;
|
|
28905
|
+
const raw = typeof facts.ticketNumber === "number" ? facts.ticketNumber : typeof facts.sitian?.ticketNumber === "number" ? facts.sitian.ticketNumber : void 0;
|
|
28906
|
+
if (typeof raw === "number" && Number.isSafeInteger(raw) && raw >= 1) {
|
|
28907
|
+
admitted.ticketNumber = raw;
|
|
28908
|
+
if (result2.admitted.ticketNumber === void 0) {
|
|
28909
|
+
result2.admitted.ticketNumber = raw;
|
|
28910
|
+
}
|
|
28911
|
+
}
|
|
28912
|
+
}
|
|
28913
|
+
}
|
|
28914
|
+
return result2;
|
|
29003
28915
|
});
|
|
29004
28916
|
}
|
|
29005
28917
|
async function runPublicDiaristResume(request, env, io) {
|
|
@@ -29037,9 +28949,9 @@ var init_diarist_run = __esm({
|
|
|
29037
28949
|
init_engine_material();
|
|
29038
28950
|
init_cli_errors();
|
|
29039
28951
|
init_invocation();
|
|
29040
|
-
init_seat_ticket_binding();
|
|
29041
28952
|
init_post_admission();
|
|
29042
28953
|
init_run_lifecycle();
|
|
28954
|
+
init_seat_ticket_binding();
|
|
29043
28955
|
init_settlement();
|
|
29044
28956
|
init_turn_request();
|
|
29045
28957
|
DIARIST_SOURCE_CATALOG_FILE = "diarist-sources.json";
|
|
@@ -29060,12 +28972,7 @@ function buildCountersignTurnRequest(admitted, options) {
|
|
|
29060
28972
|
options
|
|
29061
28973
|
);
|
|
29062
28974
|
}
|
|
29063
|
-
async function
|
|
29064
|
-
if (admitted.ticketNumber === void 0) return;
|
|
29065
|
-
if (env.runCourtDiaristStation !== void 0) {
|
|
29066
|
-
await env.runCourtDiaristStation(admitted);
|
|
29067
|
-
return;
|
|
29068
|
-
}
|
|
28975
|
+
async function invokeCourtDiarist(input, env, io) {
|
|
29069
28976
|
const quietIo = {
|
|
29070
28977
|
stdout() {
|
|
29071
28978
|
},
|
|
@@ -29075,11 +28982,7 @@ async function runCountersignCourtDiaristStation(admitted, env, io) {
|
|
|
29075
28982
|
};
|
|
29076
28983
|
const { runPublicDiarist: runPublicDiarist2 } = await Promise.resolve().then(() => (init_diarist_run(), diarist_run_exports));
|
|
29077
28984
|
const result2 = await runPublicDiarist2(
|
|
29078
|
-
[
|
|
29079
|
-
"--project",
|
|
29080
|
-
admitted.projectRoot,
|
|
29081
|
-
`\u6574\u7406 #${admitted.ticketNumber} \u7684\u672C\u6848\u4F9D\u636E\u3002`
|
|
29082
|
-
],
|
|
28985
|
+
["--project", input.projectRoot, input.instruction],
|
|
29083
28986
|
{
|
|
29084
28987
|
home: env.home,
|
|
29085
28988
|
agentDir: env.agentDir,
|
|
@@ -29094,17 +28997,60 @@ async function runCountersignCourtDiaristStation(admitted, env, io) {
|
|
|
29094
28997
|
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
|
|
29095
28998
|
...env.credentials === void 0 ? {} : { credentials: env.credentials },
|
|
29096
28999
|
...env.correlationId === void 0 ? {} : { correlationId: env.correlationId },
|
|
29097
|
-
...env.signal === void 0 ? {} : { signal: env.signal }
|
|
29000
|
+
...env.signal === void 0 ? {} : { signal: env.signal },
|
|
29001
|
+
// Typed handoff only — never derived from summons prose.
|
|
29002
|
+
...input.boundTicketNumber === void 0 ? {} : { boundTicketNumber: input.boundTicketNumber }
|
|
29098
29003
|
},
|
|
29099
29004
|
quietIo,
|
|
29100
29005
|
parseDiaristArgv
|
|
29101
29006
|
);
|
|
29007
|
+
const roleOutcome = result2.terminal?.roleOutcome;
|
|
29008
|
+
if (roleOutcome !== void 0 && roleOutcome.kind !== "failure") {
|
|
29009
|
+
if (roleOutcome.status === "escalate") {
|
|
29010
|
+
const reason = typeof roleOutcome.decisiveFacts.reason === "string" ? roleOutcome.decisiveFacts.reason : "diarist escalated without reason";
|
|
29011
|
+
return { identity: { kind: "escalate", reason } };
|
|
29012
|
+
}
|
|
29013
|
+
}
|
|
29102
29014
|
if (result2.exitCode !== 0) {
|
|
29103
|
-
const
|
|
29015
|
+
const diagnostic = roleOutcome?.kind === "failure" ? roleOutcome.diagnostic : `exit ${result2.exitCode}`;
|
|
29016
|
+
return {
|
|
29017
|
+
identity: { kind: "unbound" },
|
|
29018
|
+
failedWithoutEscalate: {
|
|
29019
|
+
diagnostic: `court diarist station failed for ${input.failureLabel}: ${diagnostic}`
|
|
29020
|
+
}
|
|
29021
|
+
};
|
|
29022
|
+
}
|
|
29023
|
+
const asserted = result2.admitted?.ticketNumber;
|
|
29024
|
+
if (typeof asserted === "number" && Number.isSafeInteger(asserted) && asserted >= 1) {
|
|
29025
|
+
return { identity: { kind: "ticket", ticketNumber: asserted } };
|
|
29026
|
+
}
|
|
29027
|
+
return { identity: { kind: "unbound" } };
|
|
29028
|
+
}
|
|
29029
|
+
async function runCountersignCourtDiaristStation(admitted, env, io) {
|
|
29030
|
+
if (env.runCourtDiaristStation !== void 0) {
|
|
29031
|
+
await env.runCourtDiaristStation(admitted);
|
|
29032
|
+
return;
|
|
29033
|
+
}
|
|
29034
|
+
if (admitted.ticketNumber === void 0) return;
|
|
29035
|
+
const outcome = await invokeCourtDiarist(
|
|
29036
|
+
{
|
|
29037
|
+
instruction: `\u6574\u7406 #${admitted.ticketNumber} \u7684\u672C\u6848\u4F9D\u636E\u3002`,
|
|
29038
|
+
projectRoot: admitted.projectRoot,
|
|
29039
|
+
failureLabel: `ticket #${admitted.ticketNumber}`,
|
|
29040
|
+
// Refresh holds a typed key — hand it off so freeze loads issue face.
|
|
29041
|
+
boundTicketNumber: admitted.ticketNumber
|
|
29042
|
+
},
|
|
29043
|
+
env,
|
|
29044
|
+
io
|
|
29045
|
+
);
|
|
29046
|
+
if (outcome.identity.kind === "escalate") {
|
|
29104
29047
|
throw new Error(
|
|
29105
|
-
`court diarist station
|
|
29048
|
+
`court diarist station escalated (cannot identify court target): ${outcome.identity.reason}`
|
|
29106
29049
|
);
|
|
29107
29050
|
}
|
|
29051
|
+
if (outcome.failedWithoutEscalate !== void 0) {
|
|
29052
|
+
throw new Error(outcome.failedWithoutEscalate.diagnostic);
|
|
29053
|
+
}
|
|
29108
29054
|
}
|
|
29109
29055
|
async function runPublicCountersign(argv, env, io, parseCountersignArgv2) {
|
|
29110
29056
|
let parsed;
|
|
@@ -29117,33 +29063,6 @@ async function runPublicCountersign(argv, env, io, parseCountersignArgv2) {
|
|
|
29117
29063
|
}
|
|
29118
29064
|
throw error;
|
|
29119
29065
|
}
|
|
29120
|
-
const projectRoot = parsed.project ?? env.cwd;
|
|
29121
|
-
const reusedTicketNumber = await resolveKnownTicketNumber({
|
|
29122
|
-
instruction: parsed.instruction,
|
|
29123
|
-
projectRoot,
|
|
29124
|
-
home: env.home
|
|
29125
|
-
});
|
|
29126
|
-
if (reusedTicketNumber !== void 0) {
|
|
29127
|
-
const summons = {
|
|
29128
|
-
instruction: parsed.instruction,
|
|
29129
|
-
instructionEmpty: parsed.instruction.trim() === "",
|
|
29130
|
-
attachmentPaths: parsed.attachmentPaths
|
|
29131
|
-
};
|
|
29132
|
-
const resumed = await tryResumeSameTicketSeatRun({
|
|
29133
|
-
home: env.home,
|
|
29134
|
-
projectRoot,
|
|
29135
|
-
role: "countersign",
|
|
29136
|
-
ticketNumber: reusedTicketNumber,
|
|
29137
|
-
freshSummons: env.freshSummons,
|
|
29138
|
-
summons,
|
|
29139
|
-
resume: (runId, materials) => runPublicCountersignResume(
|
|
29140
|
-
{ runId, ...materials === void 0 ? {} : { summons: materials } },
|
|
29141
|
-
env,
|
|
29142
|
-
io
|
|
29143
|
-
)
|
|
29144
|
-
});
|
|
29145
|
-
if (resumed !== void 0) return resumed;
|
|
29146
|
-
}
|
|
29147
29066
|
let admitted;
|
|
29148
29067
|
try {
|
|
29149
29068
|
admitted = await admitCountersignInvocation({
|
|
@@ -29165,6 +29084,80 @@ async function runPublicCountersign(argv, env, io, parseCountersignArgv2) {
|
|
|
29165
29084
|
throw error;
|
|
29166
29085
|
}
|
|
29167
29086
|
await markRunAdmitted(admitted, env.principalAuthority);
|
|
29087
|
+
let typedTicket;
|
|
29088
|
+
let identityDiaristRan = false;
|
|
29089
|
+
if (env.runCourtDiaristStation === void 0) {
|
|
29090
|
+
const outcome = await invokeCourtDiarist(
|
|
29091
|
+
{
|
|
29092
|
+
instruction: parsed.instruction,
|
|
29093
|
+
projectRoot: admitted.projectRoot,
|
|
29094
|
+
failureLabel: "unbound summons"
|
|
29095
|
+
},
|
|
29096
|
+
env,
|
|
29097
|
+
io
|
|
29098
|
+
);
|
|
29099
|
+
identityDiaristRan = true;
|
|
29100
|
+
if (outcome.identity.kind === "escalate") {
|
|
29101
|
+
return await presentControlledFailure2(
|
|
29102
|
+
admitted,
|
|
29103
|
+
{
|
|
29104
|
+
timedOut: false,
|
|
29105
|
+
code: null,
|
|
29106
|
+
stderr: "",
|
|
29107
|
+
thrown: new Error(
|
|
29108
|
+
`court diarist station escalated (cannot identify court target): ${outcome.identity.reason}`
|
|
29109
|
+
)
|
|
29110
|
+
},
|
|
29111
|
+
countersignAdapters(),
|
|
29112
|
+
env.principalAuthority,
|
|
29113
|
+
io
|
|
29114
|
+
);
|
|
29115
|
+
}
|
|
29116
|
+
if (outcome.failedWithoutEscalate !== void 0) {
|
|
29117
|
+
return await presentControlledFailure2(
|
|
29118
|
+
admitted,
|
|
29119
|
+
{
|
|
29120
|
+
timedOut: false,
|
|
29121
|
+
code: null,
|
|
29122
|
+
stderr: "",
|
|
29123
|
+
thrown: new Error(outcome.failedWithoutEscalate.diagnostic)
|
|
29124
|
+
},
|
|
29125
|
+
countersignAdapters(),
|
|
29126
|
+
env.principalAuthority,
|
|
29127
|
+
io
|
|
29128
|
+
);
|
|
29129
|
+
}
|
|
29130
|
+
if (outcome.identity.kind === "ticket") {
|
|
29131
|
+
typedTicket = outcome.identity.ticketNumber;
|
|
29132
|
+
const summons = {
|
|
29133
|
+
instruction: parsed.instruction,
|
|
29134
|
+
instructionEmpty: parsed.instruction.trim() === "",
|
|
29135
|
+
attachmentPaths: parsed.attachmentPaths
|
|
29136
|
+
};
|
|
29137
|
+
const resumed = await tryResumeSameTicketSeatRun({
|
|
29138
|
+
home: env.home,
|
|
29139
|
+
projectRoot: admitted.projectRoot,
|
|
29140
|
+
role: "countersign",
|
|
29141
|
+
ticketNumber: typedTicket,
|
|
29142
|
+
freshSummons: env.freshSummons,
|
|
29143
|
+
summons,
|
|
29144
|
+
resume: async (runId, materials) => {
|
|
29145
|
+
await markRunTerminal(admitted.runDirectory);
|
|
29146
|
+
return await runPublicCountersignResume(
|
|
29147
|
+
{
|
|
29148
|
+
runId,
|
|
29149
|
+
...materials === void 0 ? {} : { summons: materials }
|
|
29150
|
+
},
|
|
29151
|
+
env,
|
|
29152
|
+
io
|
|
29153
|
+
);
|
|
29154
|
+
}
|
|
29155
|
+
});
|
|
29156
|
+
if (resumed !== void 0) {
|
|
29157
|
+
return resumed;
|
|
29158
|
+
}
|
|
29159
|
+
}
|
|
29160
|
+
}
|
|
29168
29161
|
const turnProjection = {
|
|
29169
29162
|
packageRoot: env.packageRoot,
|
|
29170
29163
|
home: env.home,
|
|
@@ -29192,12 +29185,16 @@ async function runPublicCountersign(argv, env, io, parseCountersignArgv2) {
|
|
|
29192
29185
|
request: turnRequest,
|
|
29193
29186
|
adapters: countersignAdapters({
|
|
29194
29187
|
beforeDispatch: async (admittedSeat) => {
|
|
29195
|
-
|
|
29188
|
+
if (!identityDiaristRan) {
|
|
29189
|
+
await runCountersignCourtDiaristStation(admittedSeat, env, io);
|
|
29190
|
+
} else if (typedTicket !== void 0) {
|
|
29191
|
+
await bindAdmittedTicketNumber(admittedSeat, typedTicket);
|
|
29192
|
+
await runCountersignCourtDiaristStation(admittedSeat, env, io);
|
|
29193
|
+
}
|
|
29196
29194
|
Object.assign(
|
|
29197
29195
|
turnRequest,
|
|
29198
29196
|
buildCountersignTurnRequest(admittedSeat, turnProjection)
|
|
29199
29197
|
);
|
|
29200
|
-
await runCountersignCourtDiaristStation(admittedSeat, env, io);
|
|
29201
29198
|
}
|
|
29202
29199
|
}),
|
|
29203
29200
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
@@ -29250,9 +29247,9 @@ var init_countersign_run = __esm({
|
|
|
29250
29247
|
init_engine_material();
|
|
29251
29248
|
init_cli_errors();
|
|
29252
29249
|
init_invocation();
|
|
29253
|
-
init_seat_ticket_binding();
|
|
29254
29250
|
init_post_admission();
|
|
29255
29251
|
init_run_lifecycle();
|
|
29252
|
+
init_seat_ticket_binding();
|
|
29256
29253
|
init_settlement();
|
|
29257
29254
|
init_turn_request();
|
|
29258
29255
|
}
|
|
@@ -29570,12 +29567,7 @@ async function runPublicFixer(argv, env, io, parseFixerArgv2) {
|
|
|
29570
29567
|
})
|
|
29571
29568
|
}
|
|
29572
29569
|
}),
|
|
29573
|
-
adapters:
|
|
29574
|
-
...fixerAdapters(env.packageRoot, methodMaterial),
|
|
29575
|
-
beforeDispatch: async (admittedSeat) => {
|
|
29576
|
-
await resolveSeatTicketBinding(admittedSeat, env);
|
|
29577
|
-
}
|
|
29578
|
-
},
|
|
29570
|
+
adapters: fixerAdapters(env.packageRoot, methodMaterial),
|
|
29579
29571
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
29580
29572
|
});
|
|
29581
29573
|
}
|
|
@@ -29628,7 +29620,6 @@ var init_fixer_run = __esm({
|
|
|
29628
29620
|
init_method_skill();
|
|
29629
29621
|
init_cli_errors();
|
|
29630
29622
|
init_invocation();
|
|
29631
|
-
init_seat_ticket_binding();
|
|
29632
29623
|
init_run_lifecycle();
|
|
29633
29624
|
init_settlement();
|
|
29634
29625
|
init_turn_request();
|
|
@@ -29637,7 +29628,7 @@ var init_fixer_run = __esm({
|
|
|
29637
29628
|
});
|
|
29638
29629
|
|
|
29639
29630
|
// src/public-cli/notary-run.ts
|
|
29640
|
-
import { existsSync as
|
|
29631
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
29641
29632
|
function buildNotaryTurnRequest(admitted, options) {
|
|
29642
29633
|
return projectRoleTurnRequest(
|
|
29643
29634
|
admitted,
|
|
@@ -29786,7 +29777,7 @@ async function runPublicNotaryResume(request, env, io) {
|
|
|
29786
29777
|
env
|
|
29787
29778
|
);
|
|
29788
29779
|
const candidatePath = gateSubmissionCandidatePath(admitted.sourceRunPath);
|
|
29789
|
-
const prompt =
|
|
29780
|
+
const prompt = existsSync10(candidatePath) ? appendResumeMaterialReread(projection.continuation.prompt, candidatePath) : projection.continuation.prompt;
|
|
29790
29781
|
return buildNotaryTurnRequest(admitted, {
|
|
29791
29782
|
...projection,
|
|
29792
29783
|
continuation: { kind: "resume", prompt }
|
|
@@ -29836,11 +29827,6 @@ async function runPublicInspector(argv, env, io, parseInspectorArgv2) {
|
|
|
29836
29827
|
throw error;
|
|
29837
29828
|
}
|
|
29838
29829
|
const projectRoot = parsed.project ?? env.cwd;
|
|
29839
|
-
const reusedTicketNumber = await resolveKnownTicketNumber({
|
|
29840
|
-
instruction: parsed.instruction,
|
|
29841
|
-
projectRoot,
|
|
29842
|
-
home: env.home
|
|
29843
|
-
});
|
|
29844
29830
|
const parentRunPath = parentRunPathFromGatePointerInstruction(parsed.instruction);
|
|
29845
29831
|
if (parentRunPath !== void 0) {
|
|
29846
29832
|
const summons = {
|
|
@@ -29906,11 +29892,7 @@ async function runPublicInspector(argv, env, io, parseInspectorArgv2) {
|
|
|
29906
29892
|
env,
|
|
29907
29893
|
io,
|
|
29908
29894
|
request: turnRequest,
|
|
29909
|
-
adapters: inspectorAdapters(
|
|
29910
|
-
beforeDispatch: async (admittedSeat) => {
|
|
29911
|
-
await bindReusedTicketNumber(admittedSeat, reusedTicketNumber);
|
|
29912
|
-
}
|
|
29913
|
-
}),
|
|
29895
|
+
adapters: inspectorAdapters(),
|
|
29914
29896
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
29915
29897
|
});
|
|
29916
29898
|
}
|
|
@@ -30042,12 +30024,7 @@ async function runPublicJudge(argv, env, io, parseJudgeArgv2) {
|
|
|
30042
30024
|
})
|
|
30043
30025
|
}
|
|
30044
30026
|
}),
|
|
30045
|
-
adapters:
|
|
30046
|
-
...judgeAdapters(),
|
|
30047
|
-
beforeDispatch: async (admittedSeat) => {
|
|
30048
|
-
await resolveSeatTicketBinding(admittedSeat, env);
|
|
30049
|
-
}
|
|
30050
|
-
},
|
|
30027
|
+
adapters: judgeAdapters(),
|
|
30051
30028
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
30052
30029
|
});
|
|
30053
30030
|
}
|
|
@@ -30071,7 +30048,6 @@ var init_judge_run = __esm({
|
|
|
30071
30048
|
init_engine_material();
|
|
30072
30049
|
init_cli_errors();
|
|
30073
30050
|
init_invocation();
|
|
30074
|
-
init_seat_ticket_binding();
|
|
30075
30051
|
init_run_lifecycle();
|
|
30076
30052
|
init_settlement();
|
|
30077
30053
|
init_turn_request();
|
|
@@ -33761,7 +33737,7 @@ var init_cli = __esm({
|
|
|
33761
33737
|
});
|
|
33762
33738
|
|
|
33763
33739
|
// src/public-cli/main.ts
|
|
33764
|
-
import { existsSync as
|
|
33740
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
33765
33741
|
import { dirname as dirname16, join as join33 } from "node:path";
|
|
33766
33742
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
33767
33743
|
|
|
@@ -33852,7 +33828,7 @@ function linkPackage(packageRoot2, name, targetDir) {
|
|
|
33852
33828
|
var here = dirname16(fileURLToPath2(import.meta.url));
|
|
33853
33829
|
function resolvePackageRoot(binDir) {
|
|
33854
33830
|
const canonical = join33(binDir, "..", "..");
|
|
33855
|
-
if (
|
|
33831
|
+
if (existsSync11(join33(canonical, "package.json"))) {
|
|
33856
33832
|
return canonical;
|
|
33857
33833
|
}
|
|
33858
33834
|
return binDir;
|