@akagilnc/pi-workflow-roles 0.1.3356 → 0.1.3377

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.
@@ -21702,9 +21702,199 @@ var init_method_skill = __esm({
21702
21702
  }
21703
21703
  });
21704
21704
 
21705
+ // src/auditor-dossier-tool.ts
21706
+ var init_auditor_dossier_tool = __esm({
21707
+ "src/auditor-dossier-tool.ts"() {
21708
+ "use strict";
21709
+ init_build();
21710
+ }
21711
+ });
21712
+
21713
+ // src/engine-detour-tool.ts
21714
+ var engineDetourArgsSchema;
21715
+ var init_engine_detour_tool = __esm({
21716
+ "src/engine-detour-tool.ts"() {
21717
+ "use strict";
21718
+ init_build();
21719
+ init_engine_detour();
21720
+ engineDetourArgsSchema = typebox_exports.Object(
21721
+ {
21722
+ argv: typebox_exports.Array(typebox_exports.String({ minLength: 1 }), {
21723
+ minItems: 1,
21724
+ description: "\u9996\u9879\u4E3A PATH \u4E2D\u7684\u53EF\u6267\u884C\u6587\u4EF6\uFF0C\u5176\u4F59\u9879\u4E3A\u53C2\u6570\u3002"
21725
+ })
21726
+ },
21727
+ { additionalProperties: false }
21728
+ );
21729
+ }
21730
+ });
21731
+
21732
+ // src/session-opening-materials.ts
21733
+ import { existsSync as existsSync6 } from "node:fs";
21734
+ import { dirname as dirname8, join as join16 } from "node:path";
21735
+ import { fileURLToPath, pathToFileURL as pathToFileURL2 } from "node:url";
21736
+ function resolvePackageRootDir(moduleUrl = import.meta.url) {
21737
+ let dir = dirname8(fileURLToPath(moduleUrl));
21738
+ for (let i = 0; i < 8; i += 1) {
21739
+ if (existsSync6(join16(dir, "package.json")) && existsSync6(join16(dir, "souls"))) {
21740
+ return dir;
21741
+ }
21742
+ const parent = dirname8(dir);
21743
+ if (parent === dir) break;
21744
+ dir = parent;
21745
+ }
21746
+ return fileURLToPath(new URL("..", moduleUrl));
21747
+ }
21748
+ var packageRootUrl, MAIN_ROLE_SESSION_MATERIALS, GATEKEEPER_SESSION_MATERIALS;
21749
+ var init_session_opening_materials = __esm({
21750
+ "src/session-opening-materials.ts"() {
21751
+ "use strict";
21752
+ init_packaged_role_registry();
21753
+ packageRootUrl = pathToFileURL2(resolvePackageRootDir() + "/").href;
21754
+ MAIN_ROLE_SESSION_MATERIALS = {
21755
+ ...Object.fromEntries(
21756
+ PUBLIC_ROLE_RECORDS.map((record4) => [record4.role, record4.sessionMaterials])
21757
+ )
21758
+ };
21759
+ GATEKEEPER_SESSION_MATERIALS = {
21760
+ // #639: single authority — the public gatekeeper record owns the province list.
21761
+ gatekeeper: PUBLIC_ROLE_RECORDS.find((entry) => entry.role === "gatekeeper").sessionMaterials,
21762
+ inspector: INSPECTOR_SESSION_MATERIALS,
21763
+ notary: NOTARY_SESSION_MATERIALS
21764
+ };
21765
+ }
21766
+ });
21767
+
21768
+ // src/navigator-session-contracts.ts
21769
+ var navigatorProviderFailureSchema;
21770
+ var init_navigator_session_contracts = __esm({
21771
+ "src/navigator-session-contracts.ts"() {
21772
+ "use strict";
21773
+ init_build();
21774
+ init_value2();
21775
+ init_auditor_dossier_tool();
21776
+ init_institutional_resolution();
21777
+ navigatorProviderFailureSchema = typebox_exports.Object({
21778
+ source: typebox_exports.Union([
21779
+ typebox_exports.Literal("context"),
21780
+ typebox_exports.Literal("session"),
21781
+ typebox_exports.Literal("model"),
21782
+ typebox_exports.Literal("thinking"),
21783
+ typebox_exports.Literal("auth"),
21784
+ typebox_exports.Literal("quota"),
21785
+ typebox_exports.Literal("transport"),
21786
+ typebox_exports.Literal("unknown")
21787
+ ]),
21788
+ cause: typebox_exports.Union([
21789
+ typebox_exports.Literal("context"),
21790
+ typebox_exports.Literal("session"),
21791
+ typebox_exports.Literal("model"),
21792
+ typebox_exports.Literal("thinking"),
21793
+ typebox_exports.Literal("auth"),
21794
+ typebox_exports.Literal("quota"),
21795
+ typebox_exports.Literal("transport"),
21796
+ typebox_exports.Literal("unknown")
21797
+ ])
21798
+ }, { additionalProperties: false });
21799
+ }
21800
+ });
21801
+
21802
+ // src/receipt-delivery-policy.ts
21803
+ function isRecord9(value) {
21804
+ return typeof value === "object" && value !== null && !Array.isArray(value);
21805
+ }
21806
+ function parseNoReceiptLifecycleFacts(input) {
21807
+ if (!isRecord9(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) => isRecord9(item) && typeof item.reason === "string")) {
21808
+ throw new TypeError("malformed no-receipt lifecycle facts");
21809
+ }
21810
+ return {
21811
+ terminalToolCalled: input.terminalToolCalled,
21812
+ rejectedReceipts: input.rejectedReceipts.map((item) => ({
21813
+ reason: item.reason,
21814
+ diagnosticAvailable: item.reason.trim() !== ""
21815
+ })),
21816
+ deliveryTurns: RECEIPT_DELIVERY_TURN_LIMIT,
21817
+ sessionCompletion: "settled-without-accepted-receipt",
21818
+ runPointer: input.runPointer,
21819
+ attemptPointer: input.attemptPointer,
21820
+ acceptedReceipt: false
21821
+ };
21822
+ }
21823
+ var RECEIPT_DELIVERY_TURN_LIMIT, NO_RECEIPT_LIFECYCLE_ENTRY_TYPE;
21824
+ var init_receipt_delivery_policy = __esm({
21825
+ "src/receipt-delivery-policy.ts"() {
21826
+ "use strict";
21827
+ RECEIPT_DELIVERY_TURN_LIMIT = 2;
21828
+ NO_RECEIPT_LIFECYCLE_ENTRY_TYPE = "ak-no-receipt-lifecycle";
21829
+ }
21830
+ });
21831
+
21832
+ // src/upstream-error-testimony.ts
21833
+ function isNonSuccessHttpStatus(status) {
21834
+ return typeof status === "number" && (status < 200 || status >= 300);
21835
+ }
21836
+ function hasUpstreamErrorTestimony(input) {
21837
+ if (isNonSuccessHttpStatus(input.httpStatus)) return true;
21838
+ return Array.isArray(input.diagnostics) && input.diagnostics.length > 0;
21839
+ }
21840
+ function projectConfirmedRemotePayload(input) {
21841
+ return {
21842
+ ...input.body === void 0 ? {} : { body: input.body },
21843
+ ...input.code === void 0 ? {} : { code: input.code },
21844
+ ...input.errno === void 0 ? {} : { errno: input.errno }
21845
+ };
21846
+ }
21847
+ var init_upstream_error_testimony = __esm({
21848
+ "src/upstream-error-testimony.ts"() {
21849
+ "use strict";
21850
+ }
21851
+ });
21852
+
21853
+ // src/evidence-child-executor.ts
21854
+ var init_evidence_child_executor = __esm({
21855
+ "src/evidence-child-executor.ts"() {
21856
+ "use strict";
21857
+ init_compliance_transport();
21858
+ init_auditor_dossier_tool();
21859
+ init_sitian_facade();
21860
+ init_engine_detour_tool();
21861
+ init_engine_detour();
21862
+ init_engine_material();
21863
+ init_session_opening_materials();
21864
+ init_config2();
21865
+ init_institutional_resolution();
21866
+ init_navigator_session_contracts();
21867
+ init_receipt_delivery_policy();
21868
+ init_typed_provider_http();
21869
+ init_upstream_error_testimony();
21870
+ }
21871
+ });
21872
+
21873
+ // src/compliance-transport.ts
21874
+ function createComplianceDecisionTool(name, description) {
21875
+ return { name, description, parameters: complianceDecisionSchema, async execute(_id, params) {
21876
+ return { content: [{ type: "text", text: "\u5BA1\u8BA1\u51B3\u8BAE\u5DF2\u6536" }], details: params, terminate: true };
21877
+ } };
21878
+ }
21879
+ var nonblank2, decisionGateSchema, complianceDecisionSchema, AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE, AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE;
21880
+ var init_compliance_transport = __esm({
21881
+ "src/compliance-transport.ts"() {
21882
+ "use strict";
21883
+ init_build();
21884
+ init_evidence_child_executor();
21885
+ init_auditor_dossier_tool();
21886
+ init_sitian_facade();
21887
+ nonblank2 = typebox_exports.String({ minLength: 1, pattern: "\\S" });
21888
+ decisionGateSchema = typebox_exports.Object({ question: nonblank2, options: typebox_exports.Array(nonblank2, { minItems: 1 }) }, { additionalProperties: false });
21889
+ complianceDecisionSchema = typebox_exports.Object({ status: typebox_exports.Unknown({ description: "pass | revise | 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: [] });
21890
+ AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE = "ak_auditor_parent_attempt_binding";
21891
+ AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE = "ak_auditor_compliance_failure";
21892
+ }
21893
+ });
21894
+
21705
21895
  // src/ledger-session-read.ts
21706
21896
  import { readFile as readFile11 } from "node:fs/promises";
21707
- function isRecord9(value) {
21897
+ function isRecord10(value) {
21708
21898
  return typeof value === "object" && value !== null && !Array.isArray(value);
21709
21899
  }
21710
21900
  async function readLedgerSessionJsonl(path) {
@@ -21728,7 +21918,7 @@ async function readLedgerSessionJsonl(path) {
21728
21918
  }
21729
21919
  break;
21730
21920
  }
21731
- if (!isRecord9(row)) {
21921
+ if (!isRecord10(row)) {
21732
21922
  const kind = row === null ? "null" : Array.isArray(row) ? "array" : typeof row;
21733
21923
  throw new LedgerSessionJsonlError(
21734
21924
  `complete non-object JSONL record in ${path} at line ${index + 1}: expected object, got ${kind}`,
@@ -21765,7 +21955,7 @@ function extractSessionModelSequence(rows) {
21765
21955
  if (row.type === "model_change" && typeof row.modelId === "string") {
21766
21956
  push(row.modelId);
21767
21957
  }
21768
- const message = isRecord9(row.message) ? row.message : void 0;
21958
+ const message = isRecord10(row.message) ? row.message : void 0;
21769
21959
  if (message?.role === "assistant" && typeof message.model === "string") {
21770
21960
  push(message.model);
21771
21961
  }
@@ -21781,11 +21971,11 @@ function extractSessionToolIntervals(rows) {
21781
21971
  const openById = /* @__PURE__ */ new Map();
21782
21972
  for (const row of rows) {
21783
21973
  const rowTimestamp = typeof row.timestamp === "string" ? row.timestamp : void 0;
21784
- const message = isRecord9(row.message) ? row.message : void 0;
21974
+ const message = isRecord10(row.message) ? row.message : void 0;
21785
21975
  if (message?.role === "assistant" && Array.isArray(message.content)) {
21786
21976
  const callTimestamp = typeof message.timestamp === "string" && message.timestamp ? message.timestamp : rowTimestamp;
21787
21977
  for (const part of message.content) {
21788
- if (!isRecord9(part) || part.type !== "toolCall") continue;
21978
+ if (!isRecord10(part) || part.type !== "toolCall") continue;
21789
21979
  if (typeof part.id !== "string" || part.id.length === 0) {
21790
21980
  throw new Error("toolCall frame missing string id");
21791
21981
  }
@@ -21798,7 +21988,7 @@ function extractSessionToolIntervals(rows) {
21798
21988
  if (openById.has(part.id)) {
21799
21989
  throw new Error(`duplicate toolCall id ${part.id}`);
21800
21990
  }
21801
- const args = isRecord9(part.arguments) ? part.arguments : void 0;
21991
+ const args = isRecord10(part.arguments) ? part.arguments : void 0;
21802
21992
  const command = part.name === "bash" && args !== void 0 && typeof args.command === "string" ? bashCommandFirstLine(args.command) : void 0;
21803
21993
  const interval = {
21804
21994
  toolCallId: part.id,
@@ -21866,10 +22056,19 @@ var init_ledger_session_read = __esm({
21866
22056
 
21867
22057
  // src/analyst-gate-cycles-read.ts
21868
22058
  import { readdir as readdir3 } from "node:fs/promises";
21869
- import { join as join16 } from "node:path";
21870
- function isRecord10(value) {
22059
+ import { join as join17 } from "node:path";
22060
+ function isRecord11(value) {
21871
22061
  return typeof value === "object" && value !== null && !Array.isArray(value);
21872
22062
  }
22063
+ function extractAttemptEntryId(rows) {
22064
+ for (const row of rows) {
22065
+ if (row.type !== "custom" || row.customType !== AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE) continue;
22066
+ if (!isRecord11(row.data) || !isRecord11(row.data.parent)) continue;
22067
+ const id = row.data.parent.attemptEntryId;
22068
+ if (typeof id === "string" && id.length > 0) return id;
22069
+ }
22070
+ return void 0;
22071
+ }
21873
22072
  function isMissingDirectoryError(error) {
21874
22073
  return error instanceof Error && "code" in error && error.code === "ENOENT";
21875
22074
  }
@@ -21892,32 +22091,38 @@ function isGateTerminatingToolName(toolName) {
21892
22091
  function acceptedGateReceiptIds(rows) {
21893
22092
  const accepted = /* @__PURE__ */ new Set();
21894
22093
  for (const row of rows) {
21895
- const message = isRecord10(row.message) ? row.message : void 0;
22094
+ const message = isRecord11(row.message) ? row.message : void 0;
21896
22095
  if (message?.role !== "toolResult") continue;
21897
22096
  if (typeof message.toolCallId !== "string" || message.toolCallId.length === 0) continue;
21898
22097
  if (message.isError === false) accepted.add(message.toolCallId);
21899
22098
  }
21900
22099
  return accepted;
21901
22100
  }
21902
- function extractLastAcceptedGateToolCall(rows) {
22101
+ function extractLastGateToolCall(rows) {
21903
22102
  const acceptedIds = acceptedGateReceiptIds(rows);
21904
- let last;
22103
+ let lastAccepted;
22104
+ let lastRejected;
21905
22105
  for (const row of rows) {
21906
- const message = isRecord10(row.message) ? row.message : void 0;
22106
+ const message = isRecord11(row.message) ? row.message : void 0;
21907
22107
  if (message?.role !== "assistant" || !Array.isArray(message.content)) continue;
21908
22108
  for (const part of message.content) {
21909
- if (!isRecord10(part) || part.type !== "toolCall") continue;
22109
+ if (!isRecord11(part) || part.type !== "toolCall") continue;
21910
22110
  if (typeof part.id !== "string" || part.id.length === 0) continue;
21911
- if (!acceptedIds.has(part.id)) continue;
21912
22111
  if (typeof part.name !== "string" || part.name.length === 0) continue;
21913
22112
  if (!isGateTerminatingToolName(part.name)) continue;
21914
- last = {
22113
+ const call = {
21915
22114
  toolName: part.name,
21916
- args: isRecord10(part.arguments) ? part.arguments : void 0
22115
+ args: isRecord11(part.arguments) ? part.arguments : void 0,
22116
+ accepted: acceptedIds.has(part.id)
21917
22117
  };
22118
+ if (call.accepted) {
22119
+ lastAccepted = call;
22120
+ } else if (lastAccepted === void 0) {
22121
+ lastRejected = call;
22122
+ }
21918
22123
  }
21919
22124
  }
21920
- return last;
22125
+ return lastAccepted ?? lastRejected;
21921
22126
  }
21922
22127
  function requireAcceptedGateStatus(args, filePath) {
21923
22128
  if (args === void 0 || typeof args.status !== "string" || args.status.trim() === "") {
@@ -21949,8 +22154,12 @@ function requireAcceptedGateSpan(rows, filePath) {
21949
22154
  }
21950
22155
  async function classifyAuditorVolume(filePath) {
21951
22156
  const rows = await readLedgerSessionJsonl(filePath);
21952
- const call = extractLastAcceptedGateToolCall(rows);
22157
+ const call = extractLastGateToolCall(rows);
21953
22158
  if (call === void 0) return void 0;
22159
+ const attemptEntryId = extractAttemptEntryId(rows);
22160
+ if (!call.accepted) {
22161
+ return void 0;
22162
+ }
21954
22163
  const span = requireAcceptedGateSpan(rows, filePath);
21955
22164
  const status = requireAcceptedGateStatus(call.args, filePath);
21956
22165
  const findings = asStringFindings(call.args?.findings);
@@ -21976,7 +22185,8 @@ async function classifyAuditorVolume(filePath) {
21976
22185
  startedAt: span.startedAt,
21977
22186
  officer: officer2,
21978
22187
  status,
21979
- ...reason === void 0 ? {} : { reason }
22188
+ ...reason === void 0 ? {} : { reason },
22189
+ ...attemptEntryId === void 0 ? {} : { attemptEntryId }
21980
22190
  };
21981
22191
  }
21982
22192
  const officer = OFFICER_TOOL_TO_FACE[call.toolName];
@@ -21993,7 +22203,8 @@ async function classifyAuditorVolume(filePath) {
21993
22203
  status,
21994
22204
  findings,
21995
22205
  findingsCount,
21996
- officerWallMs: span.wallMs
22206
+ officerWallMs: span.wallMs,
22207
+ ...attemptEntryId === void 0 ? {} : { attemptEntryId }
21997
22208
  };
21998
22209
  }
21999
22210
  function pairGateRounds(volumes) {
@@ -22013,6 +22224,9 @@ function pairGateRounds(volumes) {
22013
22224
  const candidate = ordered[j];
22014
22225
  if (candidate.kind !== "officer") continue;
22015
22226
  if (candidate.officer !== vol.officer) continue;
22227
+ if (vol.attemptEntryId === void 0 || candidate.attemptEntryId === void 0 || candidate.attemptEntryId !== vol.attemptEntryId) {
22228
+ continue;
22229
+ }
22016
22230
  match = { index: j, officer: candidate };
22017
22231
  break;
22018
22232
  }
@@ -22027,11 +22241,28 @@ function pairGateRounds(volumes) {
22027
22241
  officerEndedAt: match.officer.endedAt,
22028
22242
  findings: match.officer.findings,
22029
22243
  findingsCount: match.officer.findingsCount,
22030
- dispatchStatus: vol.status,
22031
- ...vol.reason === void 0 ? {} : { dispatchReason: vol.reason }
22244
+ origin: {
22245
+ kind: "historical_dispatch",
22246
+ ...vol.reason === void 0 ? {} : { reason: vol.reason }
22247
+ }
22032
22248
  });
22033
22249
  }
22034
- return rounds;
22250
+ for (let i = 0; i < ordered.length; i += 1) {
22251
+ const vol = ordered[i];
22252
+ if (vol.kind !== "officer" || usedOfficerIdx.has(i)) continue;
22253
+ rounds.push({
22254
+ roundIndex: 0,
22255
+ officer: vol.officer,
22256
+ status: vol.status,
22257
+ officerWallMs: vol.officerWallMs,
22258
+ officerStartedAt: vol.startedAt,
22259
+ officerEndedAt: vol.endedAt,
22260
+ findings: vol.findings,
22261
+ findingsCount: vol.findingsCount,
22262
+ origin: { kind: "direct" }
22263
+ });
22264
+ }
22265
+ return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
22035
22266
  }
22036
22267
  async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory) {
22037
22268
  let names;
@@ -22044,7 +22275,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory) {
22044
22275
  }
22045
22276
  const volumes = [];
22046
22277
  for (const name of names) {
22047
- const classified = await classifyAuditorVolume(join16(auditorRolesDirectory, name));
22278
+ const classified = await classifyAuditorVolume(join17(auditorRolesDirectory, name));
22048
22279
  if (classified !== void 0) volumes.push(classified);
22049
22280
  }
22050
22281
  return pairGateRounds(volumes);
@@ -22053,6 +22284,7 @@ var DISPATCH_TOOLS, OFFICER_TOOL_TO_FACE, OFFICER_ARG_ALIASES;
22053
22284
  var init_analyst_gate_cycles_read = __esm({
22054
22285
  "src/analyst-gate-cycles-read.ts"() {
22055
22286
  "use strict";
22287
+ init_compliance_transport();
22056
22288
  init_ledger_session_read();
22057
22289
  DISPATCH_TOOLS = /* @__PURE__ */ new Set(["ak_menxia_output", "ak_gatekeeper_output"]);
22058
22290
  OFFICER_TOOL_TO_FACE = {
@@ -22070,196 +22302,6 @@ var init_analyst_gate_cycles_read = __esm({
22070
22302
  }
22071
22303
  });
22072
22304
 
22073
- // src/auditor-dossier-tool.ts
22074
- var init_auditor_dossier_tool = __esm({
22075
- "src/auditor-dossier-tool.ts"() {
22076
- "use strict";
22077
- init_build();
22078
- }
22079
- });
22080
-
22081
- // src/compliance-transport.ts
22082
- function createComplianceDecisionTool(name, description) {
22083
- return { name, description, parameters: complianceDecisionSchema, async execute(_id, params) {
22084
- return { content: [{ type: "text", text: "\u5BA1\u8BA1\u51B3\u8BAE\u5DF2\u6536" }], details: params, terminate: true };
22085
- } };
22086
- }
22087
- var nonblank2, decisionGateSchema, complianceDecisionSchema, AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE, AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE;
22088
- var init_compliance_transport = __esm({
22089
- "src/compliance-transport.ts"() {
22090
- "use strict";
22091
- init_build();
22092
- init_evidence_child_executor();
22093
- init_auditor_dossier_tool();
22094
- init_sitian_facade();
22095
- nonblank2 = typebox_exports.String({ minLength: 1, pattern: "\\S" });
22096
- decisionGateSchema = typebox_exports.Object({ question: nonblank2, options: typebox_exports.Array(nonblank2, { minItems: 1 }) }, { additionalProperties: false });
22097
- complianceDecisionSchema = typebox_exports.Object({ status: typebox_exports.Unknown({ description: "pass | revise | 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: [] });
22098
- AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE = "ak_auditor_parent_attempt_binding";
22099
- AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE = "ak_auditor_compliance_failure";
22100
- }
22101
- });
22102
-
22103
- // src/engine-detour-tool.ts
22104
- var engineDetourArgsSchema;
22105
- var init_engine_detour_tool = __esm({
22106
- "src/engine-detour-tool.ts"() {
22107
- "use strict";
22108
- init_build();
22109
- init_engine_detour();
22110
- engineDetourArgsSchema = typebox_exports.Object(
22111
- {
22112
- argv: typebox_exports.Array(typebox_exports.String({ minLength: 1 }), {
22113
- minItems: 1,
22114
- description: "\u9996\u9879\u4E3A PATH \u4E2D\u7684\u53EF\u6267\u884C\u6587\u4EF6\uFF0C\u5176\u4F59\u9879\u4E3A\u53C2\u6570\u3002"
22115
- })
22116
- },
22117
- { additionalProperties: false }
22118
- );
22119
- }
22120
- });
22121
-
22122
- // src/session-opening-materials.ts
22123
- import { existsSync as existsSync6 } from "node:fs";
22124
- import { dirname as dirname8, join as join17 } from "node:path";
22125
- import { fileURLToPath, pathToFileURL as pathToFileURL2 } from "node:url";
22126
- function resolvePackageRootDir(moduleUrl = import.meta.url) {
22127
- let dir = dirname8(fileURLToPath(moduleUrl));
22128
- for (let i = 0; i < 8; i += 1) {
22129
- if (existsSync6(join17(dir, "package.json")) && existsSync6(join17(dir, "souls"))) {
22130
- return dir;
22131
- }
22132
- const parent = dirname8(dir);
22133
- if (parent === dir) break;
22134
- dir = parent;
22135
- }
22136
- return fileURLToPath(new URL("..", moduleUrl));
22137
- }
22138
- var packageRootUrl, MAIN_ROLE_SESSION_MATERIALS, GATEKEEPER_SESSION_MATERIALS;
22139
- var init_session_opening_materials = __esm({
22140
- "src/session-opening-materials.ts"() {
22141
- "use strict";
22142
- init_packaged_role_registry();
22143
- packageRootUrl = pathToFileURL2(resolvePackageRootDir() + "/").href;
22144
- MAIN_ROLE_SESSION_MATERIALS = {
22145
- ...Object.fromEntries(
22146
- PUBLIC_ROLE_RECORDS.map((record4) => [record4.role, record4.sessionMaterials])
22147
- )
22148
- };
22149
- GATEKEEPER_SESSION_MATERIALS = {
22150
- // #639: single authority — the public gatekeeper record owns the province list.
22151
- gatekeeper: PUBLIC_ROLE_RECORDS.find((entry) => entry.role === "gatekeeper").sessionMaterials,
22152
- inspector: INSPECTOR_SESSION_MATERIALS,
22153
- notary: NOTARY_SESSION_MATERIALS
22154
- };
22155
- }
22156
- });
22157
-
22158
- // src/navigator-session-contracts.ts
22159
- var navigatorProviderFailureSchema;
22160
- var init_navigator_session_contracts = __esm({
22161
- "src/navigator-session-contracts.ts"() {
22162
- "use strict";
22163
- init_build();
22164
- init_value2();
22165
- init_auditor_dossier_tool();
22166
- init_institutional_resolution();
22167
- navigatorProviderFailureSchema = typebox_exports.Object({
22168
- source: typebox_exports.Union([
22169
- typebox_exports.Literal("context"),
22170
- typebox_exports.Literal("session"),
22171
- typebox_exports.Literal("model"),
22172
- typebox_exports.Literal("thinking"),
22173
- typebox_exports.Literal("auth"),
22174
- typebox_exports.Literal("quota"),
22175
- typebox_exports.Literal("transport"),
22176
- typebox_exports.Literal("unknown")
22177
- ]),
22178
- cause: typebox_exports.Union([
22179
- typebox_exports.Literal("context"),
22180
- typebox_exports.Literal("session"),
22181
- typebox_exports.Literal("model"),
22182
- typebox_exports.Literal("thinking"),
22183
- typebox_exports.Literal("auth"),
22184
- typebox_exports.Literal("quota"),
22185
- typebox_exports.Literal("transport"),
22186
- typebox_exports.Literal("unknown")
22187
- ])
22188
- }, { additionalProperties: false });
22189
- }
22190
- });
22191
-
22192
- // src/receipt-delivery-policy.ts
22193
- function isRecord11(value) {
22194
- return typeof value === "object" && value !== null && !Array.isArray(value);
22195
- }
22196
- function parseNoReceiptLifecycleFacts(input) {
22197
- if (!isRecord11(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) => isRecord11(item) && typeof item.reason === "string")) {
22198
- throw new TypeError("malformed no-receipt lifecycle facts");
22199
- }
22200
- return {
22201
- terminalToolCalled: input.terminalToolCalled,
22202
- rejectedReceipts: input.rejectedReceipts.map((item) => ({
22203
- reason: item.reason,
22204
- diagnosticAvailable: item.reason.trim() !== ""
22205
- })),
22206
- deliveryTurns: RECEIPT_DELIVERY_TURN_LIMIT,
22207
- sessionCompletion: "settled-without-accepted-receipt",
22208
- runPointer: input.runPointer,
22209
- attemptPointer: input.attemptPointer,
22210
- acceptedReceipt: false
22211
- };
22212
- }
22213
- var RECEIPT_DELIVERY_TURN_LIMIT, NO_RECEIPT_LIFECYCLE_ENTRY_TYPE;
22214
- var init_receipt_delivery_policy = __esm({
22215
- "src/receipt-delivery-policy.ts"() {
22216
- "use strict";
22217
- RECEIPT_DELIVERY_TURN_LIMIT = 2;
22218
- NO_RECEIPT_LIFECYCLE_ENTRY_TYPE = "ak-no-receipt-lifecycle";
22219
- }
22220
- });
22221
-
22222
- // src/upstream-error-testimony.ts
22223
- function isNonSuccessHttpStatus(status) {
22224
- return typeof status === "number" && (status < 200 || status >= 300);
22225
- }
22226
- function hasUpstreamErrorTestimony(input) {
22227
- if (isNonSuccessHttpStatus(input.httpStatus)) return true;
22228
- return Array.isArray(input.diagnostics) && input.diagnostics.length > 0;
22229
- }
22230
- function projectConfirmedRemotePayload(input) {
22231
- return {
22232
- ...input.body === void 0 ? {} : { body: input.body },
22233
- ...input.code === void 0 ? {} : { code: input.code },
22234
- ...input.errno === void 0 ? {} : { errno: input.errno }
22235
- };
22236
- }
22237
- var init_upstream_error_testimony = __esm({
22238
- "src/upstream-error-testimony.ts"() {
22239
- "use strict";
22240
- }
22241
- });
22242
-
22243
- // src/evidence-child-executor.ts
22244
- var init_evidence_child_executor = __esm({
22245
- "src/evidence-child-executor.ts"() {
22246
- "use strict";
22247
- init_compliance_transport();
22248
- init_auditor_dossier_tool();
22249
- init_sitian_facade();
22250
- init_engine_detour_tool();
22251
- init_engine_detour();
22252
- init_engine_material();
22253
- init_session_opening_materials();
22254
- init_config2();
22255
- init_institutional_resolution();
22256
- init_navigator_session_contracts();
22257
- init_receipt_delivery_policy();
22258
- init_typed_provider_http();
22259
- init_upstream_error_testimony();
22260
- }
22261
- });
22262
-
22263
22305
  // src/gatekeeper-role.ts
22264
22306
  var officerDecisionSchema, MISSING_ARGUMENTS_SUBMISSION;
22265
22307
  var init_gatekeeper_role = __esm({
@@ -23545,9 +23587,9 @@ function formatTerminalResult(result2) {
23545
23587
  `gate ${encodeTerminalField(result2.gate.actualSeats.join(","))} ${result2.gate.rounds.length}`
23546
23588
  );
23547
23589
  for (const round of result2.gate.rounds) {
23548
- const reason = round.dispatch.reason === void 0 ? "" : encodeTerminalField(round.dispatch.reason);
23590
+ const reason = round.dispatch.kind === "historical_dispatch" && round.dispatch.reason !== void 0 ? encodeTerminalField(round.dispatch.reason) : "";
23549
23591
  lines.push(
23550
- `gate-round ${round.roundIndex} ${round.dispatch.status} ${round.dispatch.officer} ${reason} ${round.officer.seat} ${encodeTerminalField(round.officer.status)} ${encodeTerminalField(JSON.stringify(round.officer.findings))}`
23592
+ `gate-round ${round.roundIndex} ${round.dispatch.kind} ${round.dispatch.officer} ${reason} ${round.officer.seat} ${encodeTerminalField(round.officer.status)} ${encodeTerminalField(JSON.stringify(round.officer.findings))}`
23551
23593
  );
23552
23594
  }
23553
23595
  }
@@ -24692,8 +24734,10 @@ function parseNavigatorAttendanceDetails(details) {
24692
24734
  function projectTerminalGateFact(rounds) {
24693
24735
  if (rounds.length === 0) return void 0;
24694
24736
  const seen = /* @__PURE__ */ new Set();
24695
- seen.add("gatekeeper");
24696
- for (const round of rounds) seen.add(round.officer);
24737
+ for (const round of rounds) {
24738
+ if (round.origin.kind === "historical_dispatch") seen.add("gatekeeper");
24739
+ seen.add(round.officer);
24740
+ }
24697
24741
  const actualSeats = ["gatekeeper", "inspector", "notary"].filter(
24698
24742
  (seat) => seen.has(seat)
24699
24743
  );
@@ -24701,10 +24745,10 @@ function projectTerminalGateFact(rounds) {
24701
24745
  actualSeats,
24702
24746
  rounds: rounds.map((round) => ({
24703
24747
  roundIndex: round.roundIndex,
24704
- dispatch: {
24705
- status: round.dispatchStatus,
24748
+ dispatch: round.origin.kind === "direct" ? { kind: "direct", officer: round.officer } : {
24749
+ kind: "historical_dispatch",
24706
24750
  officer: round.officer,
24707
- ...round.dispatchReason === void 0 ? {} : { reason: round.dispatchReason }
24751
+ ...round.origin.reason === void 0 ? {} : { reason: round.origin.reason }
24708
24752
  },
24709
24753
  officer: {
24710
24754
  seat: round.officer,
@@ -31485,7 +31529,8 @@ function projectRound(round) {
31485
31529
  officer: round.officer,
31486
31530
  status: round.status,
31487
31531
  officerWallMs: round.officerWallMs,
31488
- findingsCount: round.findingsCount
31532
+ findingsCount: round.findingsCount,
31533
+ origin: round.origin
31489
31534
  };
31490
31535
  }
31491
31536
  function projectLeg(facts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akagilnc/pi-workflow-roles",
3
- "version": "0.1.3356",
3
+ "version": "0.1.3377",
4
4
  "description": "Soul-bound workflow roles for Pi",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",