@akagilnc/pi-workflow-roles 0.1.4243 → 0.1.4274
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -23
- package/README.zh-CN.md +24 -21
- package/dist/acp-host/production-host.js +4607 -3524
- package/dist/engine-detour-tool.js +64 -5
- package/dist/engine-detour-usage.js +285 -0
- package/dist/headless-host/production-host.js +6057 -4974
- package/dist/navigator-attendance.js +0 -2
- package/dist/navigator-public-session.js +2 -4
- package/dist/navigator-session-contracts.js +6 -13
- package/dist/pi/role-turn-host.js +10 -0
- package/dist/public-cli/config.js +16 -20
- package/dist/public-cli/main.js +935 -613
- package/dist/public-cli/post-admission.js +72 -43
- package/dist/public-cli/registry.js +0 -57
- package/dist/public-cli/settlement.js +80 -24
- package/dist/public-cli/turn-request.js +3 -0
- package/dist/public-role-summons.js +121 -96
- package/package.json +1 -1
- package/src/engine-detour-tool.ts +106 -8
- package/src/engine-detour-usage.ts +373 -0
- package/src/host-contracts.ts +12 -1
- package/src/navigator-attendance.ts +0 -2
- package/src/navigator-public-session.ts +3 -3
- package/src/navigator-session-contracts.ts +8 -14
- package/src/pi/adapter.ts +6 -0
- package/src/pi/role-turn-host.ts +6 -0
- package/src/public-cli/cli.ts +115 -307
- package/src/public-cli/config.ts +35 -23
- package/src/public-cli/post-admission.ts +91 -49
- package/src/public-cli/registry.ts +2 -66
- package/src/public-cli/settlement.ts +148 -23
- package/src/public-cli/turn-request.ts +5 -0
- package/src/public-role-summons.ts +197 -125
- package/src/role-envelope.ts +2 -0
package/dist/public-cli/main.js
CHANGED
|
@@ -15177,9 +15177,6 @@ function seatModelOnly(seat) {
|
|
|
15177
15177
|
if (seat?.provider === void 0 || seat.model === void 0) return void 0;
|
|
15178
15178
|
return seat.thinking === void 0 ? { provider: seat.provider, model: seat.model } : { provider: seat.provider, model: seat.model, thinking: seat.thinking };
|
|
15179
15179
|
}
|
|
15180
|
-
function publicStartupCandidates(seat) {
|
|
15181
|
-
return STARTUP_CANDIDATES[seat];
|
|
15182
|
-
}
|
|
15183
15180
|
function listHelpCapabilities() {
|
|
15184
15181
|
const support = PUBLIC_CLI_SUPPORT_COMMANDS.map((name) => ({
|
|
15185
15182
|
kind: "support",
|
|
@@ -15212,7 +15209,7 @@ function isPublicConfigurableSeat(value) {
|
|
|
15212
15209
|
function isPublicCliSupportCommand(value) {
|
|
15213
15210
|
return PUBLIC_CLI_SUPPORT_COMMANDS.includes(value);
|
|
15214
15211
|
}
|
|
15215
|
-
var INTERNAL_ROLE_ENTRYPOINT_RELATIVE, PUBLIC_CALLABLE_ROLES, PUBLIC_CONFIGURABLE_SEATS, PUBLIC_CLI_SUPPORT_COMMANDS,
|
|
15212
|
+
var INTERNAL_ROLE_ENTRYPOINT_RELATIVE, PUBLIC_CALLABLE_ROLES, PUBLIC_CONFIGURABLE_SEATS, PUBLIC_CLI_SUPPORT_COMMANDS, PUBLIC_DETERMINISTIC_COMMANDS;
|
|
15216
15213
|
var init_registry2 = __esm({
|
|
15217
15214
|
"src/public-cli/registry.ts"() {
|
|
15218
15215
|
"use strict";
|
|
@@ -15231,59 +15228,6 @@ var init_registry2 = __esm({
|
|
|
15231
15228
|
"resume",
|
|
15232
15229
|
"new"
|
|
15233
15230
|
];
|
|
15234
|
-
STARTUP_CANDIDATES = {
|
|
15235
|
-
judge: [
|
|
15236
|
-
{ provider: "openai-codex", model: "gpt-5.6-sol", thinking: "high" },
|
|
15237
|
-
{ provider: "xai", model: "grok-4.5", thinking: "high" }
|
|
15238
|
-
],
|
|
15239
|
-
countersign: [
|
|
15240
|
-
{ provider: "openai-codex", model: "gpt-5.6-sol", thinking: "high" },
|
|
15241
|
-
{ provider: "xai", model: "grok-4.5", thinking: "high" }
|
|
15242
|
-
],
|
|
15243
|
-
"gleaner-left": [
|
|
15244
|
-
{ provider: "openai-codex", model: "gpt-5.6-sol", thinking: "medium" },
|
|
15245
|
-
{ provider: "xai", model: "grok-4.5", thinking: "high" }
|
|
15246
|
-
],
|
|
15247
|
-
reviewer: [
|
|
15248
|
-
{ provider: "openai-codex", model: "gpt-5.6-sol", thinking: "medium" },
|
|
15249
|
-
{ provider: "xai", model: "grok-4.5", thinking: "high" }
|
|
15250
|
-
],
|
|
15251
|
-
coder: [
|
|
15252
|
-
{ provider: "openai-codex", model: "gpt-5.6-luna", thinking: "high" },
|
|
15253
|
-
{ provider: "xai", model: "grok-4.5", thinking: "high" }
|
|
15254
|
-
],
|
|
15255
|
-
fixer: [
|
|
15256
|
-
{ provider: "openai-codex", model: "gpt-5.6-luna", thinking: "high" },
|
|
15257
|
-
{ provider: "xai", model: "grok-4.5", thinking: "high" }
|
|
15258
|
-
],
|
|
15259
|
-
collector: [
|
|
15260
|
-
{ provider: "openai-codex", model: "gpt-5.6-luna", thinking: "high" },
|
|
15261
|
-
{ provider: "xai", model: "grok-4.5", thinking: "high" }
|
|
15262
|
-
],
|
|
15263
|
-
doctor: [
|
|
15264
|
-
{ provider: "openai-codex", model: "gpt-5.6-luna", thinking: "high" },
|
|
15265
|
-
{ provider: "xai", model: "grok-4.5", thinking: "high" }
|
|
15266
|
-
],
|
|
15267
|
-
merger: [
|
|
15268
|
-
{ provider: "openai-codex", model: "gpt-5.6-luna", thinking: "high" },
|
|
15269
|
-
{ provider: "xai", model: "grok-4.5", thinking: "high" }
|
|
15270
|
-
],
|
|
15271
|
-
// #620: subordinate officers inherit gatekeeper; no package startup model.
|
|
15272
|
-
notary: [],
|
|
15273
|
-
// #453/#620/#639: gatekeeper callable but no package startup model — caller
|
|
15274
|
-
// configures it or inherits on the province path.
|
|
15275
|
-
gatekeeper: [],
|
|
15276
|
-
inspector: [],
|
|
15277
|
-
navigator: [
|
|
15278
|
-
{ provider: "openai-codex", model: "gpt-5.6-luna", thinking: "medium" },
|
|
15279
|
-
{ provider: "xai", model: "grok-4.5", thinking: "high" }
|
|
15280
|
-
],
|
|
15281
|
-
// #675: auditor public seat — no package startup; caller configures.
|
|
15282
|
-
auditor: [],
|
|
15283
|
-
// #708 `diarist-seat-default`: owner-set initial value; changed in the seat
|
|
15284
|
-
// table like any other seat. No engine axis, package-default host.
|
|
15285
|
-
diarist: [{ provider: "xai", model: "grok-4.5", thinking: "medium" }]
|
|
15286
|
-
};
|
|
15287
15231
|
PUBLIC_DETERMINISTIC_COMMANDS = ["analyst"];
|
|
15288
15232
|
}
|
|
15289
15233
|
});
|
|
@@ -15439,11 +15383,13 @@ __export(config_exports, {
|
|
|
15439
15383
|
loadCredentialProviders: () => loadCredentialProviders,
|
|
15440
15384
|
loadPublicCliConfig: () => loadPublicCliConfig,
|
|
15441
15385
|
missingPublicProviderCredential: () => missingPublicProviderCredential,
|
|
15386
|
+
missingResolvedSeatModelMessage: () => missingResolvedSeatModelMessage,
|
|
15442
15387
|
parseAutoResumeLimit: () => parseAutoResumeLimit,
|
|
15443
15388
|
parseModelSpec: () => parseModelSpec,
|
|
15444
15389
|
providerConfigured: () => providerConfigured,
|
|
15445
15390
|
publicCliConfigPath: () => publicCliConfigPath,
|
|
15446
15391
|
resolveEffectiveSeat: () => resolveEffectiveSeat,
|
|
15392
|
+
resolvedSeatWithModel: () => resolvedSeatWithModel,
|
|
15447
15393
|
savePublicCliConfig: () => savePublicCliConfig,
|
|
15448
15394
|
setAutoResumeLimit: () => setAutoResumeLimit,
|
|
15449
15395
|
setPersistentSeatConfig: () => setPersistentSeatConfig,
|
|
@@ -15794,13 +15740,16 @@ function missingPublicProviderCredential(provider, credentials) {
|
|
|
15794
15740
|
if (provider !== "openai-codex" && provider !== "xai") return false;
|
|
15795
15741
|
return !providerConfigured(credentials, provider);
|
|
15796
15742
|
}
|
|
15797
|
-
function
|
|
15798
|
-
|
|
15799
|
-
|
|
15800
|
-
|
|
15801
|
-
|
|
15743
|
+
function resolvedSeatWithModel(seat) {
|
|
15744
|
+
if (seat.selection === void 0) return void 0;
|
|
15745
|
+
return seat;
|
|
15746
|
+
}
|
|
15747
|
+
function missingResolvedSeatModelMessage(seat, remediation = "config") {
|
|
15748
|
+
const configSet = `ak-role config set ${seat} <provider/model[:thinking]>`;
|
|
15749
|
+
if (remediation === "invocation-or-config") {
|
|
15750
|
+
return `seat ${seat} has no model configured; set with --model <provider/model[:thinking]> or ${configSet}`;
|
|
15802
15751
|
}
|
|
15803
|
-
return
|
|
15752
|
+
return `seat ${seat} has no model configured; set with ${configSet}`;
|
|
15804
15753
|
}
|
|
15805
15754
|
function attachHostAxis(seat, config, invocation) {
|
|
15806
15755
|
if (invocation?.host !== void 0) return { ...seat, host: invocation.host, hostSource: "invocation" };
|
|
@@ -15843,7 +15792,7 @@ function attachEngineAxis(seat, config, invocation) {
|
|
|
15843
15792
|
engineSource: "unconfigured"
|
|
15844
15793
|
};
|
|
15845
15794
|
}
|
|
15846
|
-
function resolveBaseSeat(config, seat
|
|
15795
|
+
function resolveBaseSeat(config, seat) {
|
|
15847
15796
|
if (seat === "notary" || seat === "inspector") {
|
|
15848
15797
|
const resolved = resolveConfiguredProvinceOfficer(config, seat);
|
|
15849
15798
|
return {
|
|
@@ -15862,22 +15811,14 @@ function resolveBaseSeat(config, seat, credentials) {
|
|
|
15862
15811
|
engineSource: "unconfigured"
|
|
15863
15812
|
};
|
|
15864
15813
|
}
|
|
15865
|
-
const startup = pickStartupCandidate(seat, credentials);
|
|
15866
|
-
if (startup !== void 0) {
|
|
15867
|
-
return {
|
|
15868
|
-
seat,
|
|
15869
|
-
source: "startup",
|
|
15870
|
-
selection: startup,
|
|
15871
|
-
engineSource: "unconfigured"
|
|
15872
|
-
};
|
|
15873
|
-
}
|
|
15874
15814
|
return { seat, source: "unconfigured", engineSource: "unconfigured" };
|
|
15875
15815
|
}
|
|
15876
15816
|
function resolveEffectiveSeat(config, seat, credentials, invocation) {
|
|
15877
15817
|
const hasModelInvocation = invocation !== void 0 && (invocation.model !== void 0 || invocation.thinking !== void 0);
|
|
15818
|
+
void credentials;
|
|
15878
15819
|
let modelSeat;
|
|
15879
15820
|
if (!hasModelInvocation || invocation === void 0) {
|
|
15880
|
-
modelSeat = resolveBaseSeat(config, seat
|
|
15821
|
+
modelSeat = resolveBaseSeat(config, seat);
|
|
15881
15822
|
} else if (invocation.model !== void 0) {
|
|
15882
15823
|
const spec = invocation.model.includes(":") || invocation.thinking === void 0 ? invocation.model : `${invocation.model}:${invocation.thinking}`;
|
|
15883
15824
|
modelSeat = {
|
|
@@ -15887,7 +15828,7 @@ function resolveEffectiveSeat(config, seat, credentials, invocation) {
|
|
|
15887
15828
|
engineSource: "unconfigured"
|
|
15888
15829
|
};
|
|
15889
15830
|
} else {
|
|
15890
|
-
const base = resolveBaseSeat(config, seat
|
|
15831
|
+
const base = resolveBaseSeat(config, seat);
|
|
15891
15832
|
if (base.selection === void 0 || invocation.thinking === void 0) {
|
|
15892
15833
|
modelSeat = {
|
|
15893
15834
|
seat,
|
|
@@ -16131,6 +16072,10 @@ var init_host_providers = __esm({
|
|
|
16131
16072
|
});
|
|
16132
16073
|
|
|
16133
16074
|
// src/public-cli/cli-errors.ts
|
|
16075
|
+
var cli_errors_exports = {};
|
|
16076
|
+
__export(cli_errors_exports, {
|
|
16077
|
+
CliUsageError: () => CliUsageError
|
|
16078
|
+
});
|
|
16134
16079
|
var CliUsageError;
|
|
16135
16080
|
var init_cli_errors = __esm({
|
|
16136
16081
|
"src/public-cli/cli-errors.ts"() {
|
|
@@ -16849,6 +16794,10 @@ ${paths.join("\n")}`
|
|
|
16849
16794
|
};
|
|
16850
16795
|
if (request.courtAttemptId === void 0) delete env.AK_ROLE_COURT_ATTEMPT;
|
|
16851
16796
|
else env.AK_ROLE_COURT_ATTEMPT = request.courtAttemptId;
|
|
16797
|
+
if (request.invocationScopeId === void 0) delete env.AK_ROLE_INVOCATION_SCOPE;
|
|
16798
|
+
else env.AK_ROLE_INVOCATION_SCOPE = request.invocationScopeId;
|
|
16799
|
+
if (request.host === void 0 || request.host.trim() === "") delete env.AK_ROLE_HOST;
|
|
16800
|
+
else env.AK_ROLE_HOST = request.host.trim();
|
|
16852
16801
|
applyEngineChildEnv(env, request.engine);
|
|
16853
16802
|
if (typeof process.env.AK_ROLE_AUDITOR_SOURCE_RUN === "string" && process.env.AK_ROLE_AUDITOR_SOURCE_RUN.trim() !== "") {
|
|
16854
16803
|
env.AK_ROLE_AUDITOR_SOURCE_RUN = process.env.AK_ROLE_AUDITOR_SOURCE_RUN;
|
|
@@ -23719,10 +23668,10 @@ function pairGateRounds(volumes) {
|
|
|
23719
23668
|
return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
|
|
23720
23669
|
}
|
|
23721
23670
|
async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
23722
|
-
const { readFile:
|
|
23671
|
+
const { readFile: readFile24 } = await import("node:fs/promises");
|
|
23723
23672
|
let raw;
|
|
23724
23673
|
try {
|
|
23725
|
-
raw = JSON.parse(await
|
|
23674
|
+
raw = JSON.parse(await readFile24(pointerPath, "utf8"));
|
|
23726
23675
|
} catch (error) {
|
|
23727
23676
|
throw new Error(
|
|
23728
23677
|
`direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -24484,6 +24433,154 @@ var init_collector_ledger = __esm({
|
|
|
24484
24433
|
}
|
|
24485
24434
|
});
|
|
24486
24435
|
|
|
24436
|
+
// src/engine-detour-usage.ts
|
|
24437
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
24438
|
+
import { readFileSync as readFileSync3 } from "node:fs";
|
|
24439
|
+
import { dirname as dirname13, join as join25 } from "node:path";
|
|
24440
|
+
function isRecord8(value) {
|
|
24441
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24442
|
+
}
|
|
24443
|
+
function callFactFromSitianPayload(payload, pointer) {
|
|
24444
|
+
if (!isRecord8(payload)) return void 0;
|
|
24445
|
+
if (payload.tool !== ENGINE_DETOUR_TOOL_NAME) return void 0;
|
|
24446
|
+
if (typeof payload.toolCallId !== "string" || payload.toolCallId.length === 0) {
|
|
24447
|
+
return void 0;
|
|
24448
|
+
}
|
|
24449
|
+
if (typeof payload.durationMs !== "number" || !Number.isFinite(payload.durationMs)) {
|
|
24450
|
+
return void 0;
|
|
24451
|
+
}
|
|
24452
|
+
return {
|
|
24453
|
+
toolCallId: payload.toolCallId,
|
|
24454
|
+
durationMs: payload.durationMs,
|
|
24455
|
+
...typeof payload.code === "number" ? { code: payload.code } : {},
|
|
24456
|
+
...typeof payload.stdoutByteLength === "number" ? { stdoutByteLength: payload.stdoutByteLength } : {},
|
|
24457
|
+
recordPointer: pointer
|
|
24458
|
+
};
|
|
24459
|
+
}
|
|
24460
|
+
function invocationScopeIdOfRecord(record4) {
|
|
24461
|
+
if (isRecord8(record4.subject)) {
|
|
24462
|
+
const fromSubject = record4.subject.invocationScopeId;
|
|
24463
|
+
if (typeof fromSubject === "string" && fromSubject.length > 0) return fromSubject;
|
|
24464
|
+
}
|
|
24465
|
+
if (isRecord8(record4.payload)) {
|
|
24466
|
+
const fromPayload = record4.payload.invocationScopeId;
|
|
24467
|
+
if (typeof fromPayload === "string" && fromPayload.length > 0) return fromPayload;
|
|
24468
|
+
}
|
|
24469
|
+
return void 0;
|
|
24470
|
+
}
|
|
24471
|
+
async function readEngineDetourToolUsage(input) {
|
|
24472
|
+
if (!input.engineMounted) return void 0;
|
|
24473
|
+
const { recordFile } = resolveSitianRecordPath({
|
|
24474
|
+
level: "event",
|
|
24475
|
+
kind: ENGINE_DETOUR_CALL_KIND,
|
|
24476
|
+
sessionParent: input.sessionParent,
|
|
24477
|
+
...input.home === void 0 ? {} : { home: input.home },
|
|
24478
|
+
...input.cwd === void 0 ? {} : { cwd: input.cwd }
|
|
24479
|
+
});
|
|
24480
|
+
const { records } = await readSitianRecords(recordFile);
|
|
24481
|
+
const calls = [];
|
|
24482
|
+
for (const record4 of records) {
|
|
24483
|
+
if (record4.kind !== ENGINE_DETOUR_CALL_KIND) continue;
|
|
24484
|
+
const boundScope = invocationScopeIdOfRecord(record4);
|
|
24485
|
+
if (input.invocationScopeId !== void 0 && input.invocationScopeId.length > 0) {
|
|
24486
|
+
if (boundScope !== input.invocationScopeId) continue;
|
|
24487
|
+
} else if (boundScope !== void 0) {
|
|
24488
|
+
continue;
|
|
24489
|
+
}
|
|
24490
|
+
const pointer = {
|
|
24491
|
+
identity: record4.identity,
|
|
24492
|
+
recordFile,
|
|
24493
|
+
kind: record4.kind,
|
|
24494
|
+
level: record4.level
|
|
24495
|
+
};
|
|
24496
|
+
const fact = callFactFromSitianPayload(record4.payload, pointer);
|
|
24497
|
+
if (fact === void 0) continue;
|
|
24498
|
+
calls.push(fact);
|
|
24499
|
+
}
|
|
24500
|
+
return { callCount: calls.length, calls };
|
|
24501
|
+
}
|
|
24502
|
+
function projectEngineDetourToolUsageForPublicTerminal(usage, options) {
|
|
24503
|
+
if (options.discloseRecordFile) return usage;
|
|
24504
|
+
return {
|
|
24505
|
+
callCount: usage.callCount,
|
|
24506
|
+
calls: usage.calls.map((call) => ({
|
|
24507
|
+
toolCallId: call.toolCallId,
|
|
24508
|
+
durationMs: call.durationMs,
|
|
24509
|
+
...call.code === void 0 ? {} : { code: call.code },
|
|
24510
|
+
...call.stdoutByteLength === void 0 ? {} : { stdoutByteLength: call.stdoutByteLength },
|
|
24511
|
+
recordPointer: {
|
|
24512
|
+
identity: call.recordPointer.identity,
|
|
24513
|
+
kind: call.recordPointer.kind,
|
|
24514
|
+
level: call.recordPointer.level,
|
|
24515
|
+
recordFile: ENGINE_DETOUR_CALL_RECORD_FILE_RELATIVE
|
|
24516
|
+
}
|
|
24517
|
+
}))
|
|
24518
|
+
};
|
|
24519
|
+
}
|
|
24520
|
+
function readInvocationRecord(runDirectory) {
|
|
24521
|
+
try {
|
|
24522
|
+
const raw = JSON.parse(
|
|
24523
|
+
readFileSync3(join25(runDirectory, "invocation.json"), "utf8")
|
|
24524
|
+
);
|
|
24525
|
+
return isRecord8(raw) ? raw : void 0;
|
|
24526
|
+
} catch (error) {
|
|
24527
|
+
if (error?.code === "ENOENT") return void 0;
|
|
24528
|
+
throw error;
|
|
24529
|
+
}
|
|
24530
|
+
}
|
|
24531
|
+
async function readInvocationEngineMounted(runDirectory) {
|
|
24532
|
+
const raw = readInvocationRecord(runDirectory);
|
|
24533
|
+
if (raw === void 0) return false;
|
|
24534
|
+
return typeof raw.engine === "string" && raw.engine.trim() !== "";
|
|
24535
|
+
}
|
|
24536
|
+
function readInvocationSelectedHost(runDirectory) {
|
|
24537
|
+
const raw = readInvocationRecord(runDirectory);
|
|
24538
|
+
if (raw === void 0) return void 0;
|
|
24539
|
+
return typeof raw.host === "string" && raw.host.trim() !== "" ? raw.host.trim() : void 0;
|
|
24540
|
+
}
|
|
24541
|
+
function withEngineDetourToolUsageFact(outcome, usage) {
|
|
24542
|
+
if (usage === void 0) return outcome;
|
|
24543
|
+
const prior = isRecord8(outcome.decisiveFacts) ? outcome.decisiveFacts : {};
|
|
24544
|
+
return {
|
|
24545
|
+
...outcome,
|
|
24546
|
+
decisiveFacts: {
|
|
24547
|
+
...prior,
|
|
24548
|
+
[ENGINE_DETOUR_TOOL_USAGE_FACT_KEY]: usage
|
|
24549
|
+
}
|
|
24550
|
+
};
|
|
24551
|
+
}
|
|
24552
|
+
function runDirectoryFromSessionDirectory(sessionDirectory) {
|
|
24553
|
+
return dirname13(sessionDirectory);
|
|
24554
|
+
}
|
|
24555
|
+
function sessionFileFromSessionDirectory(sessionDirectory) {
|
|
24556
|
+
return join25(sessionDirectory, "session.jsonl");
|
|
24557
|
+
}
|
|
24558
|
+
function mintEngineDetourInvocationScope(input) {
|
|
24559
|
+
const engine = input.effectiveEngine?.trim();
|
|
24560
|
+
if (engine === void 0 || engine.length === 0) return void 0;
|
|
24561
|
+
return randomUUID4();
|
|
24562
|
+
}
|
|
24563
|
+
function withEngineDetourInvocationScope(request, invocationScopeId) {
|
|
24564
|
+
if (invocationScopeId === void 0 || invocationScopeId.length === 0) {
|
|
24565
|
+
return request;
|
|
24566
|
+
}
|
|
24567
|
+
if (typeof request.invocationScopeId === "string" && request.invocationScopeId.length > 0) {
|
|
24568
|
+
return request;
|
|
24569
|
+
}
|
|
24570
|
+
return { ...request, invocationScopeId };
|
|
24571
|
+
}
|
|
24572
|
+
var ENGINE_DETOUR_CALL_KIND, ENGINE_DETOUR_TOOL_USAGE_FACT_KEY, ENGINE_DETOUR_CALL_RECORD_FILE_RELATIVE;
|
|
24573
|
+
var init_engine_detour_usage = __esm({
|
|
24574
|
+
"src/engine-detour-usage.ts"() {
|
|
24575
|
+
"use strict";
|
|
24576
|
+
init_engine_detour();
|
|
24577
|
+
init_sitian_facade();
|
|
24578
|
+
ENGINE_DETOUR_CALL_KIND = "engine-detour-call";
|
|
24579
|
+
ENGINE_DETOUR_TOOL_USAGE_FACT_KEY = "engineDetourToolUsage";
|
|
24580
|
+
ENGINE_DETOUR_CALL_RECORD_FILE_RELATIVE = `session/${ENGINE_DETOUR_CALL_KIND}/records.jsonl`;
|
|
24581
|
+
}
|
|
24582
|
+
});
|
|
24583
|
+
|
|
24487
24584
|
// src/work-subject-identity.ts
|
|
24488
24585
|
var init_work_subject_identity = __esm({
|
|
24489
24586
|
"src/work-subject-identity.ts"() {
|
|
@@ -24591,11 +24688,11 @@ var init_navigator_invocation_identity = __esm({
|
|
|
24591
24688
|
});
|
|
24592
24689
|
|
|
24593
24690
|
// src/receipt-delivery-policy.ts
|
|
24594
|
-
function
|
|
24691
|
+
function isRecord9(value) {
|
|
24595
24692
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24596
24693
|
}
|
|
24597
24694
|
function parseNoReceiptLifecycleFacts(input) {
|
|
24598
|
-
if (!
|
|
24695
|
+
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")) {
|
|
24599
24696
|
throw new TypeError("malformed no-receipt lifecycle facts");
|
|
24600
24697
|
}
|
|
24601
24698
|
return {
|
|
@@ -24771,16 +24868,96 @@ var init_terminal = __esm({
|
|
|
24771
24868
|
});
|
|
24772
24869
|
|
|
24773
24870
|
// src/public-cli/settlement.ts
|
|
24774
|
-
|
|
24871
|
+
var settlement_exports = {};
|
|
24872
|
+
__export(settlement_exports, {
|
|
24873
|
+
ATTEMPT_HISTORY_ENTRY_TYPE: () => ATTEMPT_HISTORY_ENTRY_TYPE,
|
|
24874
|
+
NAVIGATOR_POST_ROLE_GRACE_MS: () => NAVIGATOR_POST_ROLE_GRACE_MS,
|
|
24875
|
+
appendRunAttemptHistory: () => appendRunAttemptHistory,
|
|
24876
|
+
attachRecordedSubmissions: () => attachRecordedSubmissions,
|
|
24877
|
+
attemptProducedFreshSubmission: () => attemptProducedFreshSubmission,
|
|
24878
|
+
classifyPostAdmissionFailure: () => classifyPostAdmissionFailure,
|
|
24879
|
+
conciseChildDiagnostic: () => conciseChildDiagnostic,
|
|
24880
|
+
controlledFailureInputFromResolution: () => controlledFailureInputFromResolution,
|
|
24881
|
+
exitCodeForTerminalOutcome: () => exitCodeForTerminalOutcome,
|
|
24882
|
+
explicitInternalKnownFailureClassificationInput: () => explicitInternalKnownFailureClassificationInput,
|
|
24883
|
+
extractCollectorInfrastructureFailure: () => extractCollectorInfrastructureFailure,
|
|
24884
|
+
extractEngineDetourInfrastructureFailure: () => extractEngineDetourInfrastructureFailure,
|
|
24885
|
+
extractFixerMethodInvocations: () => extractFixerMethodInvocations,
|
|
24886
|
+
extractGateFactFromSessionDirectory: () => extractGateFactFromSessionDirectory,
|
|
24887
|
+
extractMergerMethodInvocations: () => extractMergerMethodInvocations,
|
|
24888
|
+
extractNavigatorFact: () => extractNavigatorFact,
|
|
24889
|
+
extractReviewerMethodInvocations: () => extractReviewerMethodInvocations,
|
|
24890
|
+
extractSessionProviderStop: () => extractSessionProviderStop,
|
|
24891
|
+
formatCliDiagnostic: () => formatCliDiagnostic,
|
|
24892
|
+
formatErrorCauseDetail: () => formatErrorCauseDetail,
|
|
24893
|
+
formatFailureStderrDiagnostic: () => formatFailureStderrDiagnostic,
|
|
24894
|
+
formatTerminalResult: () => formatTerminalResult,
|
|
24895
|
+
inspectJudgeSession: () => inspectJudgeSession,
|
|
24896
|
+
isLawfulTypedTerminalOutcome: () => isLawfulTypedTerminalOutcome,
|
|
24897
|
+
presentControlledFailure: () => presentControlledFailure,
|
|
24898
|
+
presentFailureTerminal: () => presentFailureTerminal,
|
|
24899
|
+
presentStructuralRejection: () => presentStructuralRejection,
|
|
24900
|
+
projectTerminalGateFact: () => projectTerminalGateFact,
|
|
24901
|
+
projectThrownFailureLeaf: () => projectThrownFailureLeaf,
|
|
24902
|
+
publishCoderArtifacts: () => publishCoderArtifacts,
|
|
24903
|
+
publishCollectorArtifacts: () => publishCollectorArtifacts,
|
|
24904
|
+
publishDoctorArtifacts: () => publishDoctorArtifacts,
|
|
24905
|
+
publishFailureArtifacts: () => publishFailureArtifacts,
|
|
24906
|
+
publishFixerArtifacts: () => publishFixerArtifacts,
|
|
24907
|
+
publishJudgeArtifacts: () => publishJudgeArtifacts,
|
|
24908
|
+
publishMergerArtifacts: () => publishMergerArtifacts,
|
|
24909
|
+
publishReviewerArtifacts: () => publishReviewerArtifacts,
|
|
24910
|
+
raceNavigatorGrace: () => raceNavigatorGrace,
|
|
24911
|
+
readBoundAuditorKnownFailure: () => readBoundAuditorKnownFailure,
|
|
24912
|
+
readBoundEvidenceChildKnownFailure: () => readBoundEvidenceChildKnownFailure,
|
|
24913
|
+
readCollectorInfrastructureFailure: () => readCollectorInfrastructureFailure,
|
|
24914
|
+
readEngineDetourInfrastructureFailure: () => readEngineDetourInfrastructureFailure,
|
|
24915
|
+
readLawfulJudgeRoleOutcome: () => readLawfulJudgeRoleOutcome,
|
|
24916
|
+
readSessionProviderStop: () => readSessionProviderStop,
|
|
24917
|
+
recordedSubmissionPayloads: () => recordedSubmissionPayloads,
|
|
24918
|
+
resolveAuditedRunnerFailureResolution: () => resolveAuditedRunnerFailureResolution,
|
|
24919
|
+
resolveAuditedRunnerKnownFailure: () => resolveAuditedRunnerKnownFailure,
|
|
24920
|
+
resolveControlledFailureResumeObservation: () => resolveControlledFailureResumeObservation,
|
|
24921
|
+
settleCoderTerminalResult: () => settleCoderTerminalResult,
|
|
24922
|
+
settleCollectorTerminalResult: () => settleCollectorTerminalResult,
|
|
24923
|
+
settleCountersignTerminalResult: () => settleCountersignTerminalResult,
|
|
24924
|
+
settleDoctorTerminalResult: () => settleDoctorTerminalResult,
|
|
24925
|
+
settleFailureTerminalResult: () => settleFailureTerminalResult,
|
|
24926
|
+
settleFixerTerminalResult: () => settleFixerTerminalResult,
|
|
24927
|
+
settleGleanerLeftTerminalResult: () => settleGleanerLeftTerminalResult,
|
|
24928
|
+
settleHostEndedNoReceipt: () => settleHostEndedNoReceipt,
|
|
24929
|
+
settleJudgeFailureTerminalResult: () => settleJudgeFailureTerminalResult,
|
|
24930
|
+
settleJudgeTerminalResult: () => settleJudgeTerminalResult,
|
|
24931
|
+
settleMergerTerminalResult: () => settleMergerTerminalResult,
|
|
24932
|
+
settleNotaryTerminalResult: () => settleNotaryTerminalResult,
|
|
24933
|
+
settleReviewerTerminalResult: () => settleReviewerTerminalResult,
|
|
24934
|
+
trySettleAuditorTerminalResult: () => trySettleAuditorTerminalResult,
|
|
24935
|
+
trySettleCoderTerminalResult: () => trySettleCoderTerminalResult,
|
|
24936
|
+
trySettleCollectorTerminalResult: () => trySettleCollectorTerminalResult,
|
|
24937
|
+
trySettleCountersignTerminalResult: () => trySettleCountersignTerminalResult,
|
|
24938
|
+
trySettleDiaristTerminalResult: () => trySettleDiaristTerminalResult,
|
|
24939
|
+
trySettleDoctorTerminalResult: () => trySettleDoctorTerminalResult,
|
|
24940
|
+
trySettleFixerTerminalResult: () => trySettleFixerTerminalResult,
|
|
24941
|
+
trySettleGatekeeperTerminalResult: () => trySettleGatekeeperTerminalResult,
|
|
24942
|
+
trySettleGleanerLeftTerminalResult: () => trySettleGleanerLeftTerminalResult,
|
|
24943
|
+
trySettleInspectorTerminalResult: () => trySettleInspectorTerminalResult,
|
|
24944
|
+
trySettleJudgeTerminalResult: () => trySettleJudgeTerminalResult,
|
|
24945
|
+
trySettleMergerTerminalResult: () => trySettleMergerTerminalResult,
|
|
24946
|
+
trySettleNavigatorTerminalResult: () => trySettleNavigatorTerminalResult,
|
|
24947
|
+
trySettleNotaryTerminalResult: () => trySettleNotaryTerminalResult,
|
|
24948
|
+
trySettleReviewerTerminalResult: () => trySettleReviewerTerminalResult,
|
|
24949
|
+
withSubmissions: () => withSubmissions
|
|
24950
|
+
});
|
|
24951
|
+
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
24775
24952
|
import { appendFile as appendFile2, readFile as readFile17, readdir as readdir7, writeFile as writeFile7 } from "node:fs/promises";
|
|
24776
|
-
import { dirname as
|
|
24953
|
+
import { dirname as dirname14, join as join26 } from "node:path";
|
|
24777
24954
|
function sealedLedgerHome(admitted) {
|
|
24778
24955
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
24779
24956
|
}
|
|
24780
24957
|
function ledgerReadScope(admitted, scope) {
|
|
24781
24958
|
return {
|
|
24782
24959
|
home: sealedLedgerHome(admitted),
|
|
24783
|
-
sessionParent:
|
|
24960
|
+
sessionParent: join26(admitted.runDirectory, "session", "session.jsonl"),
|
|
24784
24961
|
...scope?.courtAttemptId === void 0 || scope.courtAttemptId.length === 0 ? {} : { attemptId: scope.courtAttemptId }
|
|
24785
24962
|
};
|
|
24786
24963
|
}
|
|
@@ -24843,7 +25020,7 @@ async function attachRecordedSubmissions(admitted, terminal, scope) {
|
|
|
24843
25020
|
await recordedSubmissionPayloads(admitted, void 0)
|
|
24844
25021
|
);
|
|
24845
25022
|
}
|
|
24846
|
-
async function settleHostEndedNoReceipt(admitted, authority) {
|
|
25023
|
+
async function settleHostEndedNoReceipt(admitted, authority, scope) {
|
|
24847
25024
|
const facts = noReceiptLifecycleFacts({
|
|
24848
25025
|
terminalToolCalled: false,
|
|
24849
25026
|
rejectedReceipts: [],
|
|
@@ -24865,7 +25042,8 @@ async function settleHostEndedNoReceipt(admitted, authority) {
|
|
|
24865
25042
|
artifacts: [],
|
|
24866
25043
|
runId: admitted.runId
|
|
24867
25044
|
},
|
|
24868
|
-
coordinates.sessionDirectory
|
|
25045
|
+
coordinates.sessionDirectory,
|
|
25046
|
+
detourGateContext(admitted, scope)
|
|
24869
25047
|
);
|
|
24870
25048
|
}
|
|
24871
25049
|
async function closedLedgerOutcome(admitted, role, scope) {
|
|
@@ -25208,12 +25386,12 @@ async function readSitianRetainedAuditorProviderStop(sessionFile) {
|
|
|
25208
25386
|
kind: "auditor",
|
|
25209
25387
|
sessionParent: sessionFile,
|
|
25210
25388
|
// Path is driven by sessionParent when under ledger home; cwd is a fallback only.
|
|
25211
|
-
cwd:
|
|
25389
|
+
cwd: dirname14(sessionFile)
|
|
25212
25390
|
});
|
|
25213
25391
|
const { records } = await readSitianRecords(recordFile);
|
|
25214
25392
|
for (let i = records.length - 1; i >= 0; i -= 1) {
|
|
25215
25393
|
const payload = records[i]?.payload;
|
|
25216
|
-
if (!
|
|
25394
|
+
if (!isRecord10(payload) || !isRecord10(payload.response)) continue;
|
|
25217
25395
|
if (typeof payload.type === "string") continue;
|
|
25218
25396
|
const stop = sessionProviderStopFromAssistant(payload.response);
|
|
25219
25397
|
if (stop !== void 0) return stop;
|
|
@@ -25234,7 +25412,7 @@ async function readSessionProviderStop(sessionFile) {
|
|
|
25234
25412
|
}
|
|
25235
25413
|
}
|
|
25236
25414
|
async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
25237
|
-
const childDirectory =
|
|
25415
|
+
const childDirectory = join26(dirname14(sessionFile), "evidence-children");
|
|
25238
25416
|
let names;
|
|
25239
25417
|
try {
|
|
25240
25418
|
names = await readdir7(childDirectory);
|
|
@@ -25245,12 +25423,12 @@ async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
|
25245
25423
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
25246
25424
|
let entries;
|
|
25247
25425
|
try {
|
|
25248
|
-
entries = await readBoundSessionEntries(
|
|
25426
|
+
entries = await readBoundSessionEntries(join26(childDirectory, file));
|
|
25249
25427
|
} catch (error) {
|
|
25250
25428
|
throw sessionReadFailure(error, "failed to read discovered evidence-child session");
|
|
25251
25429
|
}
|
|
25252
25430
|
const header = entries.find((entry) => entry.type === "session");
|
|
25253
|
-
if (!
|
|
25431
|
+
if (!isRecord10(header) || header.parentSession !== sessionFile) continue;
|
|
25254
25432
|
const stop = extractSessionProviderStop(entries);
|
|
25255
25433
|
if (stop === void 0) continue;
|
|
25256
25434
|
const primary = knownFailureFromProviderStop(stop);
|
|
@@ -25283,12 +25461,12 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
25283
25461
|
return body.startsWith("\u672C\u6B21\u914D\u7F6E\u7684\u52B3\u52A1\u5F15\u64CE\u53CA\u5176\u624B\u518C\uFF1A") || body.startsWith("- engine:");
|
|
25284
25462
|
};
|
|
25285
25463
|
const isResumeEnvelope = (msg) => {
|
|
25286
|
-
if (!
|
|
25464
|
+
if (!isRecord10(msg) || msg.role !== "user") return false;
|
|
25287
25465
|
const text = typeof msg.text === "string" ? msg.text : typeof msg.content === "string" ? msg.content : void 0;
|
|
25288
25466
|
if (isResumeEnvelopeBytes(text)) return true;
|
|
25289
25467
|
const content = msg.content;
|
|
25290
25468
|
if (Array.isArray(content)) {
|
|
25291
|
-
return content.some((p) =>
|
|
25469
|
+
return content.some((p) => isRecord10(p) && (isResumeEnvelopeBytes(p.text) || isResumeEnvelopeBytes(p.content)));
|
|
25292
25470
|
}
|
|
25293
25471
|
return false;
|
|
25294
25472
|
};
|
|
@@ -25300,7 +25478,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
25300
25478
|
latestParentUserIndex = i;
|
|
25301
25479
|
break;
|
|
25302
25480
|
}
|
|
25303
|
-
const childDirectories = [
|
|
25481
|
+
const childDirectories = [join26(dirname14(sessionFile), "auditor-roles")];
|
|
25304
25482
|
const valid = [];
|
|
25305
25483
|
let sawAnyDirectory = false;
|
|
25306
25484
|
for (const childDirectory of childDirectories) {
|
|
@@ -25315,12 +25493,12 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
25315
25493
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
25316
25494
|
let entries;
|
|
25317
25495
|
try {
|
|
25318
|
-
entries = await readBoundSessionEntries(
|
|
25496
|
+
entries = await readBoundSessionEntries(join26(childDirectory, file));
|
|
25319
25497
|
} catch (error) {
|
|
25320
25498
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
25321
25499
|
}
|
|
25322
25500
|
const header = entries.find((entry) => entry.type === "session");
|
|
25323
|
-
if (!
|
|
25501
|
+
if (!isRecord10(header)) continue;
|
|
25324
25502
|
const bindingIndexes = [];
|
|
25325
25503
|
for (let i = 0; i < entries.length; i += 1) {
|
|
25326
25504
|
const entry = entries[i];
|
|
@@ -25334,7 +25512,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
25334
25512
|
end: idx + 1 < bindingIndexes.length ? bindingIndexes[idx + 1] : entries.length
|
|
25335
25513
|
})) : [{ entry: void 0, start: 0, end: entries.length }];
|
|
25336
25514
|
for (const { entry: bindingEntry, start, end } of bindingPasses) {
|
|
25337
|
-
const bindingParent = bindingEntry !== void 0 &&
|
|
25515
|
+
const bindingParent = bindingEntry !== void 0 && isRecord10(bindingEntry.data) && isRecord10(bindingEntry.data.parent) ? bindingEntry.data.parent : void 0;
|
|
25338
25516
|
const attemptEntryId = typeof bindingParent?.attemptEntryId === "string" ? bindingParent.attemptEntryId : void 0;
|
|
25339
25517
|
const attemptEntryIndex = attemptEntryId === void 0 ? -1 : parentEntries.findIndex((entry) => entry.id === attemptEntryId);
|
|
25340
25518
|
const boundSessionFile = typeof bindingParent?.sessionFile === "string" ? bindingParent.sessionFile : typeof header.parentSession === "string" ? header.parentSession : void 0;
|
|
@@ -25361,12 +25539,12 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
25361
25539
|
if (stop === void 0) continue;
|
|
25362
25540
|
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
25363
25541
|
const entry = entries[i];
|
|
25364
|
-
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !
|
|
25365
|
-
const parent =
|
|
25366
|
-
const failure =
|
|
25542
|
+
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord10(entry.data)) continue;
|
|
25543
|
+
const parent = isRecord10(entry.data.parent) ? entry.data.parent : void 0;
|
|
25544
|
+
const failure = isRecord10(entry.data.failure) ? entry.data.failure : void 0;
|
|
25367
25545
|
if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId) continue;
|
|
25368
25546
|
if (failure === void 0) continue;
|
|
25369
|
-
const identity =
|
|
25547
|
+
const identity = isRecord10(failure.identity) ? failure.identity : void 0;
|
|
25370
25548
|
const typedCause = failure.cause === "provider" || failure.cause === "activation" || failure.cause === "session" || failure.cause === "output" || failure.cause === "timeout" ? failure.cause : void 0;
|
|
25371
25549
|
return {
|
|
25372
25550
|
...typedCause === void 0 ? {} : { cause: typedCause },
|
|
@@ -25375,7 +25553,7 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
25375
25553
|
...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
|
|
25376
25554
|
} },
|
|
25377
25555
|
...typeof failure.diagnostic === "string" ? { diagnostic: failure.diagnostic } : {},
|
|
25378
|
-
...
|
|
25556
|
+
...isRecord10(failure.details) ? { details: failure.details } : {}
|
|
25379
25557
|
};
|
|
25380
25558
|
}
|
|
25381
25559
|
}
|
|
@@ -25396,6 +25574,11 @@ function providerStopFallbackFromAuditorVolumes(volumes) {
|
|
|
25396
25574
|
}
|
|
25397
25575
|
return void 0;
|
|
25398
25576
|
}
|
|
25577
|
+
async function readBoundAuditorKnownFailure(sessionFile) {
|
|
25578
|
+
const volumes = await loadBoundAuditorVolumes(sessionFile);
|
|
25579
|
+
if (volumes === void 0) return void 0;
|
|
25580
|
+
return complianceFailureFromAuditorVolumes(volumes) ?? providerStopFallbackFromAuditorVolumes(volumes);
|
|
25581
|
+
}
|
|
25399
25582
|
async function readBoundAuditorComplianceFailure(sessionFile) {
|
|
25400
25583
|
const volumes = await loadBoundAuditorVolumes(sessionFile);
|
|
25401
25584
|
if (volumes === void 0) return void 0;
|
|
@@ -25422,9 +25605,9 @@ function typedFailedTerminatingToolKnownFailure(entries) {
|
|
|
25422
25605
|
if (classification.kind !== "infrastructure") continue;
|
|
25423
25606
|
if (typeof message.toolCallId !== "string" || typeof message.toolName !== "string") continue;
|
|
25424
25607
|
if (boundRoleToolCallForResult(attemptEntries, i, message, message.toolName) === void 0) continue;
|
|
25425
|
-
const textPart = Array.isArray(message.content) ? message.content.find((part) =>
|
|
25426
|
-
const diagnostic =
|
|
25427
|
-
const details =
|
|
25608
|
+
const textPart = Array.isArray(message.content) ? message.content.find((part) => isRecord10(part) && part.type === "text" && typeof part.text === "string") : void 0;
|
|
25609
|
+
const diagnostic = isRecord10(textPart) ? textPart.text : void 0;
|
|
25610
|
+
const details = isRecord10(message.details) ? message.details : classification.fact;
|
|
25428
25611
|
return {
|
|
25429
25612
|
cause: "activation",
|
|
25430
25613
|
identity: { name: message.toolName, code: message.toolCallId },
|
|
@@ -25549,6 +25732,9 @@ async function resolveAuditedRunnerFailureResolution(input) {
|
|
|
25549
25732
|
typedHttp
|
|
25550
25733
|
);
|
|
25551
25734
|
}
|
|
25735
|
+
async function resolveAuditedRunnerKnownFailure(input) {
|
|
25736
|
+
return (await resolveAuditedRunnerFailureResolution(input)).knownFailure;
|
|
25737
|
+
}
|
|
25552
25738
|
async function resolveControlledFailureResumeObservation(input) {
|
|
25553
25739
|
if (input.typedHttpObservationSettled === true) {
|
|
25554
25740
|
const observation = input.typedHttpObservation;
|
|
@@ -25582,7 +25768,7 @@ function controlledFailureInputFromResolution(resolution) {
|
|
|
25582
25768
|
} : {}
|
|
25583
25769
|
};
|
|
25584
25770
|
}
|
|
25585
|
-
function
|
|
25771
|
+
function isRecord10(value) {
|
|
25586
25772
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25587
25773
|
}
|
|
25588
25774
|
function toolResultText(message) {
|
|
@@ -25607,7 +25793,7 @@ function extractCollectorTargetBindRejection(entries) {
|
|
|
25607
25793
|
const diagnostic = toolResultText(message);
|
|
25608
25794
|
if (diagnostic.length === 0) return void 0;
|
|
25609
25795
|
const details = message.details;
|
|
25610
|
-
const code =
|
|
25796
|
+
const code = isRecord10(details) && typeof details.code === "string" && details.code.trim() !== "" ? details.code : void 0;
|
|
25611
25797
|
return code === void 0 ? { diagnostic } : { diagnostic, code };
|
|
25612
25798
|
}
|
|
25613
25799
|
return void 0;
|
|
@@ -25652,6 +25838,12 @@ async function readInfrastructureToolFailure(sessionFile, spec, options = {}) {
|
|
|
25652
25838
|
return void 0;
|
|
25653
25839
|
}
|
|
25654
25840
|
}
|
|
25841
|
+
function extractCollectorInfrastructureFailure(entries) {
|
|
25842
|
+
return extractInfrastructureToolFailure(
|
|
25843
|
+
entries,
|
|
25844
|
+
COLLECTOR_INFRASTRUCTURE_FAILURE_SPEC
|
|
25845
|
+
);
|
|
25846
|
+
}
|
|
25655
25847
|
async function readCollectorInfrastructureFailure(sessionFile) {
|
|
25656
25848
|
return readInfrastructureToolFailure(
|
|
25657
25849
|
sessionFile,
|
|
@@ -25661,6 +25853,12 @@ async function readCollectorInfrastructureFailure(sessionFile) {
|
|
|
25661
25853
|
{ currentAttemptOnly: true }
|
|
25662
25854
|
);
|
|
25663
25855
|
}
|
|
25856
|
+
function extractEngineDetourInfrastructureFailure(entries) {
|
|
25857
|
+
return extractInfrastructureToolFailure(
|
|
25858
|
+
entries,
|
|
25859
|
+
ENGINE_DETOUR_INFRASTRUCTURE_FAILURE_SPEC
|
|
25860
|
+
);
|
|
25861
|
+
}
|
|
25664
25862
|
async function readEngineDetourInfrastructureFailure(sessionFile) {
|
|
25665
25863
|
return readInfrastructureToolFailure(
|
|
25666
25864
|
sessionFile,
|
|
@@ -25677,7 +25875,7 @@ function boundRoleToolCallForResult(entries, resultIndex, message, outputToolNam
|
|
|
25677
25875
|
const candidateMessage = entries[index]?.message;
|
|
25678
25876
|
if (candidateMessage?.role === "assistant" && Array.isArray(candidateMessage.content)) {
|
|
25679
25877
|
for (const part of candidateMessage.content) {
|
|
25680
|
-
if (!
|
|
25878
|
+
if (!isRecord10(part) || part.type !== "toolCall" || part.id !== callId) {
|
|
25681
25879
|
continue;
|
|
25682
25880
|
}
|
|
25683
25881
|
if (part.name !== outputToolName) return void 0;
|
|
@@ -25714,7 +25912,7 @@ async function appendRunAttemptHistory(source, outcome) {
|
|
|
25714
25912
|
type: "custom",
|
|
25715
25913
|
customType: ATTEMPT_HISTORY_ENTRY_TYPE,
|
|
25716
25914
|
data: attemptData,
|
|
25717
|
-
id:
|
|
25915
|
+
id: randomUUID5(),
|
|
25718
25916
|
parentId,
|
|
25719
25917
|
timestamp: timestamp2
|
|
25720
25918
|
})}
|
|
@@ -25749,7 +25947,7 @@ function parseNavigatorAttendanceDetails(details) {
|
|
|
25749
25947
|
const advisoryDiagnostic = typeof details.routePlaybookReadFailure === "string" ? { advisoryDiagnostic: details.routePlaybookReadFailure } : {};
|
|
25750
25948
|
if (disposition === "recommendation") {
|
|
25751
25949
|
const next = details.next;
|
|
25752
|
-
if (!
|
|
25950
|
+
if (!isRecord10(next) || typeof next.role !== "string") {
|
|
25753
25951
|
return {
|
|
25754
25952
|
disposition: "unavailable",
|
|
25755
25953
|
source: "unknown",
|
|
@@ -25757,7 +25955,7 @@ function parseNavigatorAttendanceDetails(details) {
|
|
|
25757
25955
|
};
|
|
25758
25956
|
}
|
|
25759
25957
|
const reason = typeof details.reason === "string" ? details.reason : "";
|
|
25760
|
-
const route = Array.isArray(details.route) ? details.route.filter(
|
|
25958
|
+
const route = Array.isArray(details.route) ? details.route.filter(isRecord10).map((target) => ({
|
|
25761
25959
|
role: String(target.role),
|
|
25762
25960
|
phase: navigatorPhaseValue(target.phase)
|
|
25763
25961
|
})) : void 0;
|
|
@@ -25820,18 +26018,50 @@ function projectTerminalGateFact(rounds) {
|
|
|
25820
26018
|
};
|
|
25821
26019
|
}
|
|
25822
26020
|
async function extractGateFactFromSessionDirectory(sessionDirectory, options = {}) {
|
|
25823
|
-
const directories = [
|
|
25824
|
-
const parentSessionFile = options.parentSessionFile ??
|
|
26021
|
+
const directories = [join26(sessionDirectory, "auditor-roles")];
|
|
26022
|
+
const parentSessionFile = options.parentSessionFile ?? join26(sessionDirectory, "session.jsonl");
|
|
25825
26023
|
const rounds = await readAnalystGateCyclesFromAuditorRoles(directories, {
|
|
25826
26024
|
parentSessionFile
|
|
25827
26025
|
});
|
|
25828
26026
|
return projectTerminalGateFact(rounds);
|
|
25829
26027
|
}
|
|
26028
|
+
async function attachEngineDetourToolUsage(base, sessionDirectory, gateContext = {}) {
|
|
26029
|
+
const runDirectory = typeof gateContext.runDirectory === "string" && gateContext.runDirectory.length > 0 ? gateContext.runDirectory : runDirectoryFromSessionDirectory(sessionDirectory);
|
|
26030
|
+
const engineMounted = await readInvocationEngineMounted(runDirectory);
|
|
26031
|
+
if (!engineMounted) return base;
|
|
26032
|
+
const invocationScopeId = typeof gateContext.invocationScopeId === "string" && gateContext.invocationScopeId.length > 0 ? gateContext.invocationScopeId : void 0;
|
|
26033
|
+
const sessionFile = sessionFileFromSessionDirectory(sessionDirectory);
|
|
26034
|
+
const usage = await readEngineDetourToolUsage({
|
|
26035
|
+
sessionParent: sessionFile,
|
|
26036
|
+
engineMounted: true,
|
|
26037
|
+
...invocationScopeId === void 0 ? {} : { invocationScopeId },
|
|
26038
|
+
cwd: runDirectory
|
|
26039
|
+
});
|
|
26040
|
+
const projected = usage === void 0 ? void 0 : projectEngineDetourToolUsageForPublicTerminal(usage, {
|
|
26041
|
+
// Resumable Terminal: run ID only in resume.command — relative openable path.
|
|
26042
|
+
discloseRecordFile: base.resume === void 0
|
|
26043
|
+
});
|
|
26044
|
+
return {
|
|
26045
|
+
...base,
|
|
26046
|
+
roleOutcome: withEngineDetourToolUsageFact(base.roleOutcome, projected)
|
|
26047
|
+
};
|
|
26048
|
+
}
|
|
26049
|
+
function detourGateContext(admitted, scope) {
|
|
26050
|
+
return {
|
|
26051
|
+
runDirectory: admitted.runDirectory,
|
|
26052
|
+
...scope?.courtAttemptId === void 0 || scope.courtAttemptId.length === 0 ? {} : { courtAttemptId: scope.courtAttemptId },
|
|
26053
|
+
...scope?.invocationScopeId === void 0 || scope.invocationScopeId.length === 0 ? {} : { invocationScopeId: scope.invocationScopeId }
|
|
26054
|
+
};
|
|
26055
|
+
}
|
|
25830
26056
|
async function withOptionalGateProjection(base, sessionDirectory, gateContext = {}) {
|
|
25831
26057
|
const secondaryEvidence = base.roleOutcome.kind === "failure" ? base.roleOutcome.decisiveFacts.secondaryEvidence : void 0;
|
|
25832
|
-
|
|
25833
|
-
|
|
25834
|
-
|
|
26058
|
+
const skipGate = isRecord10(secondaryEvidence) && secondaryEvidence.kind === "role_infrastructure_failure" && (secondaryEvidence.stage === "gatekeeper" || secondaryEvidence.stage === "inspector" || secondaryEvidence.stage === "notary");
|
|
26059
|
+
let next = base;
|
|
26060
|
+
if (!skipGate) {
|
|
26061
|
+
const gate = await extractGateFactFromSessionDirectory(sessionDirectory, gateContext);
|
|
26062
|
+
if (gate !== void 0) next = { ...base, gate };
|
|
26063
|
+
}
|
|
26064
|
+
return attachEngineDetourToolUsage(next, sessionDirectory, gateContext);
|
|
25835
26065
|
}
|
|
25836
26066
|
function extractNavigatorFact(entries) {
|
|
25837
26067
|
const terminal = findLatestDurablePackagedRoleTerminal(entries);
|
|
@@ -25869,7 +26099,7 @@ function extractNavigatorFact(entries) {
|
|
|
25869
26099
|
const entry = entries[i];
|
|
25870
26100
|
if (entry?.type === "custom_message" && entry.customType === "ak-navigator-attendance") {
|
|
25871
26101
|
const details = entry.message?.details ?? entry.details;
|
|
25872
|
-
if (!
|
|
26102
|
+
if (!isRecord10(details)) {
|
|
25873
26103
|
return {
|
|
25874
26104
|
disposition: "unavailable",
|
|
25875
26105
|
source: "unknown",
|
|
@@ -25919,8 +26149,8 @@ async function extractNavigatorFactFromAdmittedSession(sessionFile) {
|
|
|
25919
26149
|
async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
|
|
25920
26150
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
25921
26151
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
25922
|
-
const reportPath =
|
|
25923
|
-
const evidencePath =
|
|
26152
|
+
const reportPath = join26(artifactsDir, "report.json");
|
|
26153
|
+
const evidencePath = join26(artifactsDir, "evidence.json");
|
|
25924
26154
|
await writeFile7(
|
|
25925
26155
|
reportPath,
|
|
25926
26156
|
`${JSON.stringify(
|
|
@@ -25964,8 +26194,8 @@ async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
|
|
|
25964
26194
|
async function publishCoderArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
25965
26195
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
25966
26196
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
25967
|
-
const reportPath =
|
|
25968
|
-
const evidencePath =
|
|
26197
|
+
const reportPath = join26(artifactsDir, "report.json");
|
|
26198
|
+
const evidencePath = join26(artifactsDir, "evidence.json");
|
|
25969
26199
|
await writeFile7(
|
|
25970
26200
|
reportPath,
|
|
25971
26201
|
`${JSON.stringify(
|
|
@@ -26040,9 +26270,19 @@ async function settleLawfulJudgeTerminalResult(admitted, authority, scope) {
|
|
|
26040
26270
|
artifacts,
|
|
26041
26271
|
runId: admitted.runId
|
|
26042
26272
|
},
|
|
26043
|
-
coordinates.sessionDirectory
|
|
26273
|
+
coordinates.sessionDirectory,
|
|
26274
|
+
detourGateContext(admitted, scope)
|
|
26044
26275
|
);
|
|
26045
26276
|
}
|
|
26277
|
+
async function settleJudgeTerminalResult(admitted, authority, scope) {
|
|
26278
|
+
const settled = await settleLawfulJudgeTerminalResult(admitted, authority, scope);
|
|
26279
|
+
if (settled === void 0) {
|
|
26280
|
+
throw new Error(
|
|
26281
|
+
"Judge Role run completed without a lawful typed terminal result"
|
|
26282
|
+
);
|
|
26283
|
+
}
|
|
26284
|
+
return settled;
|
|
26285
|
+
}
|
|
26046
26286
|
async function trySettleJudgeTerminalResult(admitted, authority, scope) {
|
|
26047
26287
|
return settleLawfulJudgeTerminalResult(admitted, authority, scope);
|
|
26048
26288
|
}
|
|
@@ -26068,9 +26308,19 @@ async function settleLawfulCoderTerminalResult(admitted, authority, options = {}
|
|
|
26068
26308
|
artifacts,
|
|
26069
26309
|
runId: admitted.runId
|
|
26070
26310
|
},
|
|
26071
|
-
coordinates.sessionDirectory
|
|
26311
|
+
coordinates.sessionDirectory,
|
|
26312
|
+
detourGateContext(admitted, scope)
|
|
26072
26313
|
);
|
|
26073
26314
|
}
|
|
26315
|
+
async function settleCoderTerminalResult(admitted, authority, options = {}, scope) {
|
|
26316
|
+
const settled = await settleLawfulCoderTerminalResult(admitted, authority, options, scope);
|
|
26317
|
+
if (settled === void 0) {
|
|
26318
|
+
throw new Error(
|
|
26319
|
+
"Coder Role run completed without a lawful typed terminal result"
|
|
26320
|
+
);
|
|
26321
|
+
}
|
|
26322
|
+
return settled;
|
|
26323
|
+
}
|
|
26074
26324
|
function sessionMessageText(message) {
|
|
26075
26325
|
if (message === void 0) return "";
|
|
26076
26326
|
if (typeof message.content === "string") return message.content;
|
|
@@ -26102,8 +26352,8 @@ function extractFixerMethodInvocations(entries, options) {
|
|
|
26102
26352
|
async function publishFixerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
26103
26353
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26104
26354
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26105
|
-
const reportPath =
|
|
26106
|
-
const evidencePath =
|
|
26355
|
+
const reportPath = join26(artifactsDir, "report.json");
|
|
26356
|
+
const evidencePath = join26(artifactsDir, "evidence.json");
|
|
26107
26357
|
await writeFile7(
|
|
26108
26358
|
reportPath,
|
|
26109
26359
|
`${JSON.stringify(
|
|
@@ -26184,14 +26434,24 @@ async function settleLawfulFixerTerminalResult(admitted, authority, options, sco
|
|
|
26184
26434
|
artifacts,
|
|
26185
26435
|
runId: admitted.runId
|
|
26186
26436
|
},
|
|
26187
|
-
sessionDirectory
|
|
26437
|
+
sessionDirectory,
|
|
26438
|
+
detourGateContext(admitted, scope)
|
|
26188
26439
|
);
|
|
26189
26440
|
}
|
|
26441
|
+
async function settleFixerTerminalResult(admitted, authority, options, scope) {
|
|
26442
|
+
const settled = await settleLawfulFixerTerminalResult(admitted, authority, options, scope);
|
|
26443
|
+
if (settled === void 0) {
|
|
26444
|
+
throw new Error(
|
|
26445
|
+
"Fixer Role run completed without a lawful typed terminal result"
|
|
26446
|
+
);
|
|
26447
|
+
}
|
|
26448
|
+
return settled;
|
|
26449
|
+
}
|
|
26190
26450
|
async function publishCollectorArtifacts(admitted, roleOutcome, coordinates) {
|
|
26191
26451
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26192
26452
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26193
|
-
const reportPath =
|
|
26194
|
-
const evidencePath =
|
|
26453
|
+
const reportPath = join26(artifactsDir, "report.json");
|
|
26454
|
+
const evidencePath = join26(artifactsDir, "evidence.json");
|
|
26195
26455
|
await writeFile7(
|
|
26196
26456
|
reportPath,
|
|
26197
26457
|
`${JSON.stringify(
|
|
@@ -26249,12 +26509,17 @@ async function settleLawfulCollectorTerminalResult(admitted, authority, scope) {
|
|
|
26249
26509
|
const residual = boundErroredToolCandidate(entries, index, message, COLLECTOR_WAIT_TOOL);
|
|
26250
26510
|
if (residual === void 0) continue;
|
|
26251
26511
|
const candidate = residual.candidate;
|
|
26252
|
-
const details =
|
|
26253
|
-
const failed = await settleFailureTerminalResult(
|
|
26254
|
-
|
|
26255
|
-
|
|
26256
|
-
|
|
26257
|
-
|
|
26512
|
+
const details = isRecord10(candidate) ? candidate : { candidate };
|
|
26513
|
+
const failed = await settleFailureTerminalResult(
|
|
26514
|
+
admitted,
|
|
26515
|
+
{
|
|
26516
|
+
cause: "output",
|
|
26517
|
+
diagnostic: residual.diagnostic,
|
|
26518
|
+
details
|
|
26519
|
+
},
|
|
26520
|
+
authority,
|
|
26521
|
+
scope ?? {}
|
|
26522
|
+
);
|
|
26258
26523
|
return attachRecordedSubmissions(admitted, failed, scope);
|
|
26259
26524
|
}
|
|
26260
26525
|
return void 0;
|
|
@@ -26275,11 +26540,21 @@ async function settleLawfulCollectorTerminalResult(admitted, authority, scope) {
|
|
|
26275
26540
|
artifacts,
|
|
26276
26541
|
runId: admitted.runId
|
|
26277
26542
|
},
|
|
26278
|
-
sessionDirectory
|
|
26543
|
+
sessionDirectory,
|
|
26544
|
+
detourGateContext(admitted, scope)
|
|
26279
26545
|
),
|
|
26280
26546
|
scope
|
|
26281
26547
|
);
|
|
26282
26548
|
}
|
|
26549
|
+
async function settleCollectorTerminalResult(admitted, authority, scope) {
|
|
26550
|
+
const settled = await settleLawfulCollectorTerminalResult(admitted, authority, scope);
|
|
26551
|
+
if (settled === void 0) {
|
|
26552
|
+
throw new Error(
|
|
26553
|
+
"Collector Role run completed without a lawful typed terminal result"
|
|
26554
|
+
);
|
|
26555
|
+
}
|
|
26556
|
+
return settled;
|
|
26557
|
+
}
|
|
26283
26558
|
async function trySettleCollectorTerminalResult(admitted, authority, scope) {
|
|
26284
26559
|
return settleLawfulCollectorTerminalResult(admitted, authority, scope);
|
|
26285
26560
|
}
|
|
@@ -26289,7 +26564,7 @@ function extractDoctorCandidateCostFact(entries) {
|
|
|
26289
26564
|
const entry = entries[i];
|
|
26290
26565
|
if (entry?.type === "custom" && entry.customType === DOCTOR_CANDIDATE_ENTRY_TYPE) {
|
|
26291
26566
|
const data = entry.data;
|
|
26292
|
-
return
|
|
26567
|
+
return isRecord10(data) ? data.cost : void 0;
|
|
26293
26568
|
}
|
|
26294
26569
|
}
|
|
26295
26570
|
return void 0;
|
|
@@ -26300,7 +26575,7 @@ function extractDoctorCandidateAuditNoReceiptFact(entries) {
|
|
|
26300
26575
|
const entry = entries[i];
|
|
26301
26576
|
if (entry?.type === "custom" && entry.customType === DOCTOR_CANDIDATE_ENTRY_TYPE) {
|
|
26302
26577
|
const data = entry.data;
|
|
26303
|
-
return
|
|
26578
|
+
return isRecord10(data) ? data.auditNoReceipt : void 0;
|
|
26304
26579
|
}
|
|
26305
26580
|
}
|
|
26306
26581
|
return void 0;
|
|
@@ -26308,8 +26583,8 @@ function extractDoctorCandidateAuditNoReceiptFact(entries) {
|
|
|
26308
26583
|
async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
26309
26584
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26310
26585
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26311
|
-
const reportPath =
|
|
26312
|
-
const evidencePath =
|
|
26586
|
+
const reportPath = join26(artifactsDir, "report.json");
|
|
26587
|
+
const evidencePath = join26(artifactsDir, "evidence.json");
|
|
26313
26588
|
await writeFile7(
|
|
26314
26589
|
reportPath,
|
|
26315
26590
|
`${JSON.stringify(
|
|
@@ -26371,7 +26646,8 @@ async function settleLawfulDoctorTerminalResult(admitted, authority, scope) {
|
|
|
26371
26646
|
artifacts: artifacts2,
|
|
26372
26647
|
runId: admitted.runId
|
|
26373
26648
|
},
|
|
26374
|
-
sessionDirectory
|
|
26649
|
+
sessionDirectory,
|
|
26650
|
+
detourGateContext(admitted, scope)
|
|
26375
26651
|
);
|
|
26376
26652
|
}
|
|
26377
26653
|
const roleOutcome = sealed;
|
|
@@ -26394,9 +26670,19 @@ async function settleLawfulDoctorTerminalResult(admitted, authority, scope) {
|
|
|
26394
26670
|
artifacts,
|
|
26395
26671
|
runId: admitted.runId
|
|
26396
26672
|
},
|
|
26397
|
-
sessionDirectory
|
|
26673
|
+
sessionDirectory,
|
|
26674
|
+
detourGateContext(admitted, scope)
|
|
26398
26675
|
);
|
|
26399
26676
|
}
|
|
26677
|
+
async function settleDoctorTerminalResult(admitted, authority, scope) {
|
|
26678
|
+
const settled = await settleLawfulDoctorTerminalResult(admitted, authority, scope);
|
|
26679
|
+
if (settled === void 0) {
|
|
26680
|
+
throw new Error(
|
|
26681
|
+
"Doctor Role run completed without a lawful typed terminal result"
|
|
26682
|
+
);
|
|
26683
|
+
}
|
|
26684
|
+
return settled;
|
|
26685
|
+
}
|
|
26400
26686
|
async function trySettleDoctorTerminalResult(admitted, authority, scope) {
|
|
26401
26687
|
return settleLawfulDoctorTerminalResult(admitted, authority, scope);
|
|
26402
26688
|
}
|
|
@@ -26425,12 +26711,17 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
26425
26711
|
spec.toolName
|
|
26426
26712
|
);
|
|
26427
26713
|
if (residual !== void 0) {
|
|
26428
|
-
const details =
|
|
26429
|
-
const failed = await settleFailureTerminalResult(
|
|
26430
|
-
|
|
26431
|
-
|
|
26432
|
-
|
|
26433
|
-
|
|
26714
|
+
const details = isRecord10(residual.candidate) ? residual.candidate : { candidate: residual.candidate };
|
|
26715
|
+
const failed = await settleFailureTerminalResult(
|
|
26716
|
+
admitted,
|
|
26717
|
+
{
|
|
26718
|
+
cause: "output",
|
|
26719
|
+
diagnostic: residual.diagnostic,
|
|
26720
|
+
details
|
|
26721
|
+
},
|
|
26722
|
+
authority,
|
|
26723
|
+
scope ?? {}
|
|
26724
|
+
);
|
|
26434
26725
|
return withSubmissions(failed, submissions);
|
|
26435
26726
|
}
|
|
26436
26727
|
}
|
|
@@ -26445,7 +26736,8 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
26445
26736
|
artifacts: [],
|
|
26446
26737
|
runId: admitted.runId
|
|
26447
26738
|
},
|
|
26448
|
-
sessionDirectory
|
|
26739
|
+
sessionDirectory,
|
|
26740
|
+
detourGateContext(admitted, scope)
|
|
26449
26741
|
),
|
|
26450
26742
|
submissions
|
|
26451
26743
|
);
|
|
@@ -26460,7 +26752,8 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
26460
26752
|
artifacts: [],
|
|
26461
26753
|
runId: admitted.runId
|
|
26462
26754
|
},
|
|
26463
|
-
sessionDirectory
|
|
26755
|
+
sessionDirectory,
|
|
26756
|
+
detourGateContext(admitted, scope)
|
|
26464
26757
|
),
|
|
26465
26758
|
submissions
|
|
26466
26759
|
);
|
|
@@ -26473,6 +26766,15 @@ async function settleLawfulNotaryTerminalResult(admitted, authority, scope) {
|
|
|
26473
26766
|
toolName: NOTARY_OUTPUT_TOOL_NAME
|
|
26474
26767
|
}, scope);
|
|
26475
26768
|
}
|
|
26769
|
+
async function settleNotaryTerminalResult(admitted, authority, scope) {
|
|
26770
|
+
const settled = await settleLawfulNotaryTerminalResult(admitted, authority, scope);
|
|
26771
|
+
if (settled === void 0) {
|
|
26772
|
+
throw new Error(
|
|
26773
|
+
"Notary Role run completed without a lawful typed terminal result"
|
|
26774
|
+
);
|
|
26775
|
+
}
|
|
26776
|
+
return settled;
|
|
26777
|
+
}
|
|
26476
26778
|
async function trySettleNotaryTerminalResult(admitted, authority, scope) {
|
|
26477
26779
|
return settleLawfulNotaryTerminalResult(admitted, authority, scope);
|
|
26478
26780
|
}
|
|
@@ -26482,6 +26784,15 @@ async function settleLawfulCountersignTerminalResult(admitted, authority, scope)
|
|
|
26482
26784
|
toolName: COUNTERSIGN_OUTPUT_TOOL_NAME
|
|
26483
26785
|
}, scope);
|
|
26484
26786
|
}
|
|
26787
|
+
async function settleCountersignTerminalResult(admitted, authority, scope) {
|
|
26788
|
+
const settled = await settleLawfulCountersignTerminalResult(admitted, authority, scope);
|
|
26789
|
+
if (settled === void 0) {
|
|
26790
|
+
throw new Error(
|
|
26791
|
+
"Countersign Role run completed without a lawful typed terminal result"
|
|
26792
|
+
);
|
|
26793
|
+
}
|
|
26794
|
+
return settled;
|
|
26795
|
+
}
|
|
26485
26796
|
async function trySettleCountersignTerminalResult(admitted, authority, scope) {
|
|
26486
26797
|
return settleLawfulCountersignTerminalResult(admitted, authority, scope);
|
|
26487
26798
|
}
|
|
@@ -26491,6 +26802,15 @@ async function settleLawfulGleanerLeftTerminalResult(admitted, authority, scope)
|
|
|
26491
26802
|
toolName: GLEANER_LEFT_OUTPUT_TOOL_NAME
|
|
26492
26803
|
}, scope);
|
|
26493
26804
|
}
|
|
26805
|
+
async function settleGleanerLeftTerminalResult(admitted, authority, scope) {
|
|
26806
|
+
const settled = await settleLawfulGleanerLeftTerminalResult(admitted, authority, scope);
|
|
26807
|
+
if (settled === void 0) {
|
|
26808
|
+
throw new Error(
|
|
26809
|
+
"Gleaner-Left Role run completed without a lawful typed terminal result"
|
|
26810
|
+
);
|
|
26811
|
+
}
|
|
26812
|
+
return settled;
|
|
26813
|
+
}
|
|
26494
26814
|
async function trySettleGleanerLeftTerminalResult(admitted, authority, scope) {
|
|
26495
26815
|
return settleLawfulGleanerLeftTerminalResult(admitted, authority, scope);
|
|
26496
26816
|
}
|
|
@@ -26564,8 +26884,8 @@ function extractReviewerMethodInvocations(entries, options) {
|
|
|
26564
26884
|
async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
26565
26885
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26566
26886
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26567
|
-
const reportPath =
|
|
26568
|
-
const evidencePath =
|
|
26887
|
+
const reportPath = join26(artifactsDir, "report.json");
|
|
26888
|
+
const evidencePath = join26(artifactsDir, "evidence.json");
|
|
26569
26889
|
await writeFile7(
|
|
26570
26890
|
reportPath,
|
|
26571
26891
|
`${JSON.stringify(
|
|
@@ -26644,9 +26964,19 @@ async function settleLawfulReviewerTerminalResult(admitted, authority, options,
|
|
|
26644
26964
|
artifacts,
|
|
26645
26965
|
runId: admitted.runId
|
|
26646
26966
|
},
|
|
26647
|
-
sessionDirectory
|
|
26967
|
+
sessionDirectory,
|
|
26968
|
+
detourGateContext(admitted, scope)
|
|
26648
26969
|
);
|
|
26649
26970
|
}
|
|
26971
|
+
async function settleReviewerTerminalResult(admitted, authority, options, scope) {
|
|
26972
|
+
const settled = await settleLawfulReviewerTerminalResult(admitted, authority, options, scope);
|
|
26973
|
+
if (settled === void 0) {
|
|
26974
|
+
throw new Error(
|
|
26975
|
+
"Reviewer Role run completed without a lawful typed terminal result"
|
|
26976
|
+
);
|
|
26977
|
+
}
|
|
26978
|
+
return settled;
|
|
26979
|
+
}
|
|
26650
26980
|
async function trySettleReviewerTerminalResult(admitted, authority, options, scope) {
|
|
26651
26981
|
return settleLawfulReviewerTerminalResult(admitted, authority, options, scope);
|
|
26652
26982
|
}
|
|
@@ -26669,8 +26999,8 @@ function extractMergerMethodInvocations(entries, options) {
|
|
|
26669
26999
|
async function publishMergerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
26670
27000
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
26671
27001
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
26672
|
-
const reportPath =
|
|
26673
|
-
const evidencePath =
|
|
27002
|
+
const reportPath = join26(artifactsDir, "report.json");
|
|
27003
|
+
const evidencePath = join26(artifactsDir, "evidence.json");
|
|
26674
27004
|
await writeFile7(
|
|
26675
27005
|
reportPath,
|
|
26676
27006
|
`${JSON.stringify(
|
|
@@ -26729,12 +27059,17 @@ async function settleLawfulMergerTerminalResult(admitted, authority, options, sc
|
|
|
26729
27059
|
const residual = boundErroredToolCandidate(entries, index, message, MERGER_OUTPUT_TOOL_NAME);
|
|
26730
27060
|
if (residual === void 0) continue;
|
|
26731
27061
|
const candidate = residual.candidate;
|
|
26732
|
-
const details =
|
|
26733
|
-
const failed = await settleFailureTerminalResult(
|
|
26734
|
-
|
|
26735
|
-
|
|
26736
|
-
|
|
26737
|
-
|
|
27062
|
+
const details = isRecord10(candidate) ? candidate : { candidate };
|
|
27063
|
+
const failed = await settleFailureTerminalResult(
|
|
27064
|
+
admitted,
|
|
27065
|
+
{
|
|
27066
|
+
cause: "output",
|
|
27067
|
+
diagnostic: residual.diagnostic,
|
|
27068
|
+
details
|
|
27069
|
+
},
|
|
27070
|
+
authority,
|
|
27071
|
+
scope ?? {}
|
|
27072
|
+
);
|
|
26738
27073
|
return attachRecordedSubmissions(admitted, failed, scope);
|
|
26739
27074
|
}
|
|
26740
27075
|
return void 0;
|
|
@@ -26762,11 +27097,21 @@ async function settleLawfulMergerTerminalResult(admitted, authority, options, sc
|
|
|
26762
27097
|
artifacts,
|
|
26763
27098
|
runId: admitted.runId
|
|
26764
27099
|
},
|
|
26765
|
-
sessionDirectory
|
|
27100
|
+
sessionDirectory,
|
|
27101
|
+
detourGateContext(admitted, scope)
|
|
26766
27102
|
),
|
|
26767
27103
|
scope
|
|
26768
27104
|
);
|
|
26769
27105
|
}
|
|
27106
|
+
async function settleMergerTerminalResult(admitted, authority, options, scope) {
|
|
27107
|
+
const settled = await settleLawfulMergerTerminalResult(admitted, authority, options, scope);
|
|
27108
|
+
if (settled === void 0) {
|
|
27109
|
+
throw new Error(
|
|
27110
|
+
"Merger Role run completed without a lawful typed terminal result"
|
|
27111
|
+
);
|
|
27112
|
+
}
|
|
27113
|
+
return settled;
|
|
27114
|
+
}
|
|
26770
27115
|
async function trySettleMergerTerminalResult(admitted, authority, options, scope) {
|
|
26771
27116
|
return settleLawfulMergerTerminalResult(admitted, authority, options, scope);
|
|
26772
27117
|
}
|
|
@@ -26789,7 +27134,7 @@ function publicationAttemptFromError(path, error) {
|
|
|
26789
27134
|
}
|
|
26790
27135
|
function uniqueFailureFallbackDirs(runDirectory, baseDir) {
|
|
26791
27136
|
const dirs = [];
|
|
26792
|
-
for (const dir of [baseDir, runDirectory,
|
|
27137
|
+
for (const dir of [baseDir, runDirectory, dirname14(runDirectory)]) {
|
|
26793
27138
|
if (!dirs.includes(dir)) dirs.push(dir);
|
|
26794
27139
|
}
|
|
26795
27140
|
return dirs;
|
|
@@ -26811,7 +27156,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
26811
27156
|
const candidates = [
|
|
26812
27157
|
...preferredCandidates,
|
|
26813
27158
|
// One unique name per fallback dir — collisions on fixed names cannot exhaust this.
|
|
26814
|
-
...uniqueFallbackDirs.map((dir) =>
|
|
27159
|
+
...uniqueFallbackDirs.map((dir) => join26(dir, `${stem}.${randomUUID5()}.json`))
|
|
26815
27160
|
];
|
|
26816
27161
|
for (let i = 0; i < candidates.length; i += 1) {
|
|
26817
27162
|
const path = candidates[i];
|
|
@@ -26862,20 +27207,20 @@ async function publishFailureArtifacts(admitted, failure, authority) {
|
|
|
26862
27207
|
baseDir
|
|
26863
27208
|
);
|
|
26864
27209
|
const errorCandidates = underArtifacts ? [
|
|
26865
|
-
|
|
26866
|
-
|
|
26867
|
-
|
|
27210
|
+
join26(baseDir, "error.json"),
|
|
27211
|
+
join26(baseDir, "error.settlement.json"),
|
|
27212
|
+
join26(admitted.runDirectory, "error.settlement.json")
|
|
26868
27213
|
] : [
|
|
26869
|
-
|
|
26870
|
-
|
|
27214
|
+
join26(baseDir, "error.settlement.json"),
|
|
27215
|
+
join26(baseDir, "error.json")
|
|
26871
27216
|
];
|
|
26872
27217
|
const evidenceCandidates = underArtifacts ? [
|
|
26873
|
-
|
|
26874
|
-
|
|
26875
|
-
|
|
27218
|
+
join26(baseDir, "evidence.json"),
|
|
27219
|
+
join26(baseDir, "evidence.settlement.json"),
|
|
27220
|
+
join26(admitted.runDirectory, "evidence.settlement.json")
|
|
26876
27221
|
] : [
|
|
26877
|
-
|
|
26878
|
-
|
|
27222
|
+
join26(baseDir, "evidence.settlement.json"),
|
|
27223
|
+
join26(baseDir, "evidence.json")
|
|
26879
27224
|
];
|
|
26880
27225
|
const errorPayloadBase = {
|
|
26881
27226
|
kind: "error",
|
|
@@ -26957,7 +27302,8 @@ async function settleFailureTerminalResult(admitted, failure, authority, options
|
|
|
26957
27302
|
artifacts: [],
|
|
26958
27303
|
runId: admitted.runId
|
|
26959
27304
|
},
|
|
26960
|
-
sessionDirectory
|
|
27305
|
+
sessionDirectory,
|
|
27306
|
+
detourGateContext(admitted, options)
|
|
26961
27307
|
);
|
|
26962
27308
|
}
|
|
26963
27309
|
} catch {
|
|
@@ -26995,7 +27341,8 @@ async function settleFailureTerminalResult(admitted, failure, authority, options
|
|
|
26995
27341
|
artifacts: [],
|
|
26996
27342
|
resume: options.resume
|
|
26997
27343
|
},
|
|
26998
|
-
sessionDirectory
|
|
27344
|
+
sessionDirectory,
|
|
27345
|
+
detourGateContext(admitted, options)
|
|
26999
27346
|
);
|
|
27000
27347
|
}
|
|
27001
27348
|
const roleOutcome = {
|
|
@@ -27012,9 +27359,13 @@ async function settleFailureTerminalResult(admitted, failure, authority, options
|
|
|
27012
27359
|
artifacts,
|
|
27013
27360
|
runId: admitted.runId
|
|
27014
27361
|
},
|
|
27015
|
-
sessionDirectory
|
|
27362
|
+
sessionDirectory,
|
|
27363
|
+
detourGateContext(admitted, options)
|
|
27016
27364
|
);
|
|
27017
27365
|
}
|
|
27366
|
+
async function settleJudgeFailureTerminalResult(admitted, failure, authority, options = {}) {
|
|
27367
|
+
return settleFailureTerminalResult(admitted, failure, authority, options);
|
|
27368
|
+
}
|
|
27018
27369
|
function presentFailureTerminal(terminal, io) {
|
|
27019
27370
|
if (terminal.roleOutcome.kind !== "failure" && terminal.roleOutcome.kind !== "no_receipt") {
|
|
27020
27371
|
throw new TypeError("presentFailureTerminal requires a failure or no-receipt role outcome");
|
|
@@ -27035,7 +27386,41 @@ function presentFailureTerminal(terminal, io) {
|
|
|
27035
27386
|
}));
|
|
27036
27387
|
}
|
|
27037
27388
|
}
|
|
27038
|
-
|
|
27389
|
+
function defaultNavigatorGraceSleep() {
|
|
27390
|
+
let timer;
|
|
27391
|
+
const sleep2 = ((ms) => new Promise((resolve10) => {
|
|
27392
|
+
timer = setTimeout(() => {
|
|
27393
|
+
timer = void 0;
|
|
27394
|
+
resolve10();
|
|
27395
|
+
}, ms);
|
|
27396
|
+
}));
|
|
27397
|
+
sleep2.cancel = () => {
|
|
27398
|
+
if (timer !== void 0) {
|
|
27399
|
+
clearTimeout(timer);
|
|
27400
|
+
timer = void 0;
|
|
27401
|
+
}
|
|
27402
|
+
};
|
|
27403
|
+
return sleep2;
|
|
27404
|
+
}
|
|
27405
|
+
function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2 = defaultNavigatorGraceSleep()) {
|
|
27406
|
+
return new Promise((resolve10, reject) => {
|
|
27407
|
+
let settled = false;
|
|
27408
|
+
const finish = (action) => {
|
|
27409
|
+
if (settled) return;
|
|
27410
|
+
settled = true;
|
|
27411
|
+
sleep2.cancel?.();
|
|
27412
|
+
action();
|
|
27413
|
+
};
|
|
27414
|
+
void work.then(
|
|
27415
|
+
(value) => finish(() => resolve10({ status: "done", value })),
|
|
27416
|
+
(error) => finish(() => reject(error))
|
|
27417
|
+
);
|
|
27418
|
+
void sleep2(graceMs).then(() => {
|
|
27419
|
+
finish(() => resolve10({ status: "timeout" }));
|
|
27420
|
+
});
|
|
27421
|
+
});
|
|
27422
|
+
}
|
|
27423
|
+
var NAVIGATOR_POST_ROLE_GRACE_MS, COLLECTOR_INFRASTRUCTURE_TOOLS, COLLECTOR_INFRASTRUCTURE_FAILURE_SPEC, ENGINE_DETOUR_INFRASTRUCTURE_FAILURE_SPEC, ATTEMPT_HISTORY_ENTRY_TYPE;
|
|
27039
27424
|
var init_settlement = __esm({
|
|
27040
27425
|
"src/public-cli/settlement.ts"() {
|
|
27041
27426
|
"use strict";
|
|
@@ -27052,6 +27437,7 @@ var init_settlement = __esm({
|
|
|
27052
27437
|
init_compliance_transport();
|
|
27053
27438
|
init_collector_ledger();
|
|
27054
27439
|
init_engine_detour();
|
|
27440
|
+
init_engine_detour_usage();
|
|
27055
27441
|
init_judge_output();
|
|
27056
27442
|
init_collector_output();
|
|
27057
27443
|
init_worker_output();
|
|
@@ -27073,6 +27459,7 @@ var init_settlement = __esm({
|
|
|
27073
27459
|
init_role_run_placement();
|
|
27074
27460
|
init_invocation();
|
|
27075
27461
|
init_terminal();
|
|
27462
|
+
NAVIGATOR_POST_ROLE_GRACE_MS = 1e4;
|
|
27076
27463
|
COLLECTOR_INFRASTRUCTURE_TOOLS = /* @__PURE__ */ new Set([
|
|
27077
27464
|
COLLECTOR_OBSERVE_TOOL,
|
|
27078
27465
|
COLLECTOR_READ_TOOL,
|
|
@@ -27115,6 +27502,7 @@ function projectRoleTurnRequest(admitted, roleDetails, options) {
|
|
|
27115
27502
|
...options.correlationId === void 0 || options.correlationId.trim() === "" ? {} : { correlationId: options.correlationId },
|
|
27116
27503
|
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs },
|
|
27117
27504
|
...options.courtAttemptId === void 0 || options.courtAttemptId.length === 0 ? {} : { courtAttemptId: options.courtAttemptId },
|
|
27505
|
+
...options.invocationScopeId === void 0 || options.invocationScopeId.length === 0 ? {} : { invocationScopeId: options.invocationScopeId },
|
|
27118
27506
|
...options.stationChild === void 0 ? {} : { stationChild: options.stationChild }
|
|
27119
27507
|
};
|
|
27120
27508
|
}
|
|
@@ -27127,9 +27515,9 @@ var init_turn_request = __esm({
|
|
|
27127
27515
|
|
|
27128
27516
|
// src/session-identity.ts
|
|
27129
27517
|
import { mkdir as mkdir3, readFile as readFile18, rename as rename3, writeFile as writeFile8 } from "node:fs/promises";
|
|
27130
|
-
import { dirname as
|
|
27518
|
+
import { dirname as dirname15, join as join27 } from "node:path";
|
|
27131
27519
|
function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
27132
|
-
const bindingPath = (principal) =>
|
|
27520
|
+
const bindingPath = (principal) => join27(authority.decode(principal).sessionDirectory, sessionBindingFile);
|
|
27133
27521
|
return {
|
|
27134
27522
|
resolveSessionFile(principal) {
|
|
27135
27523
|
return authority.decode(principal).sessionFile;
|
|
@@ -27148,7 +27536,7 @@ function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
|
27148
27536
|
},
|
|
27149
27537
|
async bind(principal, sessionId) {
|
|
27150
27538
|
const target = bindingPath(principal);
|
|
27151
|
-
await mkdir3(
|
|
27539
|
+
await mkdir3(dirname15(target), { recursive: true });
|
|
27152
27540
|
const temporary = `${target}.${process.pid}.tmp`;
|
|
27153
27541
|
await writeFile8(temporary, `${JSON.stringify({ sessionId })}
|
|
27154
27542
|
`, { encoding: "utf8", mode: 384 });
|
|
@@ -27218,7 +27606,7 @@ var init_ticket_provenance = __esm({
|
|
|
27218
27606
|
// src/public-cli/case-dossier-delivery.ts
|
|
27219
27607
|
import { mkdtemp, readFile as readFile19, rm as rm2, writeFile as writeFile9 } from "node:fs/promises";
|
|
27220
27608
|
import { tmpdir } from "node:os";
|
|
27221
|
-
import { join as
|
|
27609
|
+
import { join as join28 } from "node:path";
|
|
27222
27610
|
function describeDossierFile(path) {
|
|
27223
27611
|
return path;
|
|
27224
27612
|
}
|
|
@@ -27243,9 +27631,9 @@ async function deliverCaseDossierAsAttachment(input) {
|
|
|
27243
27631
|
home: input.home
|
|
27244
27632
|
});
|
|
27245
27633
|
if (section === void 0) return void 0;
|
|
27246
|
-
const stagingDir = await mkdtemp(
|
|
27634
|
+
const stagingDir = await mkdtemp(join28(tmpdir(), "ak-case-dossier-"));
|
|
27247
27635
|
try {
|
|
27248
|
-
const stagingPath =
|
|
27636
|
+
const stagingPath = join28(stagingDir, CASE_DOSSIER_ATTACH_FILE);
|
|
27249
27637
|
await writeFile9(stagingPath, `${section}
|
|
27250
27638
|
`, "utf8");
|
|
27251
27639
|
return await freezeAttachmentsIntoRun(
|
|
@@ -27271,7 +27659,7 @@ var init_case_dossier_delivery = __esm({
|
|
|
27271
27659
|
|
|
27272
27660
|
// src/host-transition-prior-native.ts
|
|
27273
27661
|
import { access as access3, readdir as readdir8 } from "node:fs/promises";
|
|
27274
|
-
import { dirname as
|
|
27662
|
+
import { dirname as dirname16, join as join29 } from "node:path";
|
|
27275
27663
|
function isEnoent3(error) {
|
|
27276
27664
|
return typeof error === "object" && error !== null && error.code === "ENOENT";
|
|
27277
27665
|
}
|
|
@@ -27285,7 +27673,7 @@ async function listPiNativeRecordPaths(sessionFile) {
|
|
|
27285
27673
|
}
|
|
27286
27674
|
}
|
|
27287
27675
|
async function listSitianRecordPaths(sessionParent) {
|
|
27288
|
-
const sessionRoot =
|
|
27676
|
+
const sessionRoot = dirname16(sessionParent);
|
|
27289
27677
|
let entries;
|
|
27290
27678
|
try {
|
|
27291
27679
|
entries = await readdir8(sessionRoot, { withFileTypes: true });
|
|
@@ -27296,7 +27684,7 @@ async function listSitianRecordPaths(sessionParent) {
|
|
|
27296
27684
|
const recordPaths = [];
|
|
27297
27685
|
for (const entry of entries) {
|
|
27298
27686
|
if (!entry.isDirectory()) continue;
|
|
27299
|
-
const recordFile =
|
|
27687
|
+
const recordFile = join29(sessionRoot, entry.name, "records.jsonl");
|
|
27300
27688
|
try {
|
|
27301
27689
|
await access3(recordFile);
|
|
27302
27690
|
recordPaths.push(recordFile);
|
|
@@ -27364,9 +27752,9 @@ var init_public_run_credentials = __esm({
|
|
|
27364
27752
|
|
|
27365
27753
|
// src/public-cli/auto-resume.ts
|
|
27366
27754
|
import { constants as fsConstants2 } from "node:fs";
|
|
27367
|
-
import { randomUUID as
|
|
27755
|
+
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
27368
27756
|
import { lstat as lstat6, mkdir as mkdir4, open as open2 } from "node:fs/promises";
|
|
27369
|
-
import { join as
|
|
27757
|
+
import { join as join30 } from "node:path";
|
|
27370
27758
|
async function persistReturnedRunState(admitted, authority, options) {
|
|
27371
27759
|
if (options?.lawful === true) {
|
|
27372
27760
|
await markRunTerminal(admitted.runDirectory);
|
|
@@ -27481,7 +27869,7 @@ function jsonSafeReplacer() {
|
|
|
27481
27869
|
};
|
|
27482
27870
|
}
|
|
27483
27871
|
async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
|
|
27484
|
-
const filePath =
|
|
27872
|
+
const filePath = join30(artifactsDir, `${namePrefix}-${randomUUID6()}.json`);
|
|
27485
27873
|
const body = `${JSON.stringify(payload, jsonSafeReplacer(), 2)}
|
|
27486
27874
|
`;
|
|
27487
27875
|
const noFollowFlag = typeof fsConstants2.O_NOFOLLOW === "number" ? fsConstants2.O_NOFOLLOW : 0;
|
|
@@ -27752,9 +28140,9 @@ var init_auto_resume = __esm({
|
|
|
27752
28140
|
});
|
|
27753
28141
|
|
|
27754
28142
|
// src/public-cli/post-admission.ts
|
|
27755
|
-
import { randomUUID as
|
|
27756
|
-
import {
|
|
27757
|
-
import { isAbsolute as isAbsolute8, join as
|
|
28143
|
+
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
28144
|
+
import { writeFile as writeFile10 } from "node:fs/promises";
|
|
28145
|
+
import { isAbsolute as isAbsolute8, join as join31, resolve as resolve8 } from "node:path";
|
|
27758
28146
|
function describeCaughtError(error) {
|
|
27759
28147
|
if (error instanceof Error) {
|
|
27760
28148
|
const code = error.code;
|
|
@@ -27799,7 +28187,7 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
27799
28187
|
try {
|
|
27800
28188
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
27801
28189
|
await writeFile10(
|
|
27802
|
-
|
|
28190
|
+
join31(artifactsDir, `post-admission-diagnostic-${randomUUID7()}.json`),
|
|
27803
28191
|
`${JSON.stringify({ version: 1, ...payload }, null, 2)}
|
|
27804
28192
|
`,
|
|
27805
28193
|
{ encoding: "utf8", flag: "wx" }
|
|
@@ -27813,15 +28201,6 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
27813
28201
|
}
|
|
27814
28202
|
}
|
|
27815
28203
|
}
|
|
27816
|
-
async function readInvocationHost(runDirectory) {
|
|
27817
|
-
try {
|
|
27818
|
-
const raw = JSON.parse(await readFile20(join30(runDirectory, "invocation.json"), "utf8"));
|
|
27819
|
-
return typeof raw.host === "string" && raw.host.trim() !== "" ? raw.host : void 0;
|
|
27820
|
-
} catch (error) {
|
|
27821
|
-
if (error.code === "ENOENT") return void 0;
|
|
27822
|
-
throw error;
|
|
27823
|
-
}
|
|
27824
|
-
}
|
|
27825
28204
|
async function resolveResumeMethodMaterialAdapters(input) {
|
|
27826
28205
|
if (input.shouldLoad === false) {
|
|
27827
28206
|
return { kind: "continue", adapters: input.emptyAdapters };
|
|
@@ -27885,7 +28264,10 @@ async function presentControlledFailure2(admitted, failureInput, adapters, autho
|
|
|
27885
28264
|
admitted,
|
|
27886
28265
|
failure,
|
|
27887
28266
|
authority,
|
|
27888
|
-
|
|
28267
|
+
{
|
|
28268
|
+
...resumable ? { resume: { command: renderResumeCommand(admitted.runId) } } : {},
|
|
28269
|
+
...failureInput.invocationScopeId === void 0 || failureInput.invocationScopeId.length === 0 ? {} : { invocationScopeId: failureInput.invocationScopeId }
|
|
28270
|
+
}
|
|
27889
28271
|
)
|
|
27890
28272
|
);
|
|
27891
28273
|
presentFailureTerminal(terminal, io);
|
|
@@ -27954,12 +28336,12 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
27954
28336
|
return {
|
|
27955
28337
|
...await presentControlledFailure2(
|
|
27956
28338
|
admitted,
|
|
27957
|
-
{
|
|
28339
|
+
withEngineDetourInvocationScope({
|
|
27958
28340
|
timedOut: false,
|
|
27959
28341
|
code: null,
|
|
27960
28342
|
stderr: "",
|
|
27961
28343
|
thrown: error
|
|
27962
|
-
},
|
|
28344
|
+
}, request.invocationScopeId),
|
|
27963
28345
|
adapters,
|
|
27964
28346
|
env.principalAuthority,
|
|
27965
28347
|
io,
|
|
@@ -27980,7 +28362,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
27980
28362
|
return {
|
|
27981
28363
|
...await presentControlledFailure2(
|
|
27982
28364
|
admitted,
|
|
27983
|
-
missingCredential,
|
|
28365
|
+
withEngineDetourInvocationScope(missingCredential, request.invocationScopeId),
|
|
27984
28366
|
adapters,
|
|
27985
28367
|
env.principalAuthority,
|
|
27986
28368
|
io,
|
|
@@ -27994,7 +28376,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
27994
28376
|
const principalCoordinates = admitted.principal === void 0 ? void 0 : env.principalAuthority.decode(admitted.principal);
|
|
27995
28377
|
let hostTransition;
|
|
27996
28378
|
try {
|
|
27997
|
-
previousHost =
|
|
28379
|
+
previousHost = readInvocationSelectedHost(admitted.runDirectory);
|
|
27998
28380
|
hostTransition = previousHost !== void 0 && liveHost !== void 0 && principalCoordinates !== void 0 ? await projectHostTransitionPriorNative({
|
|
27999
28381
|
previousHost,
|
|
28000
28382
|
liveHost,
|
|
@@ -28004,12 +28386,12 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28004
28386
|
return {
|
|
28005
28387
|
...await presentControlledFailure2(
|
|
28006
28388
|
admitted,
|
|
28007
|
-
{
|
|
28389
|
+
withEngineDetourInvocationScope({
|
|
28008
28390
|
timedOut: false,
|
|
28009
28391
|
code: null,
|
|
28010
28392
|
stderr: "",
|
|
28011
28393
|
thrown: error
|
|
28012
|
-
},
|
|
28394
|
+
}, request.invocationScopeId),
|
|
28013
28395
|
adapters,
|
|
28014
28396
|
env.principalAuthority,
|
|
28015
28397
|
io,
|
|
@@ -28026,12 +28408,12 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28026
28408
|
} catch (error) {
|
|
28027
28409
|
const settled2 = await presentControlledFailure2(
|
|
28028
28410
|
admitted,
|
|
28029
|
-
{
|
|
28411
|
+
withEngineDetourInvocationScope({
|
|
28030
28412
|
timedOut: false,
|
|
28031
28413
|
code: null,
|
|
28032
28414
|
stderr: "",
|
|
28033
28415
|
thrown: error
|
|
28034
|
-
},
|
|
28416
|
+
}, request.invocationScopeId),
|
|
28035
28417
|
adapters,
|
|
28036
28418
|
env.principalAuthority,
|
|
28037
28419
|
io,
|
|
@@ -28050,6 +28432,9 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28050
28432
|
if (hostTransition !== void 0) {
|
|
28051
28433
|
turnRequest = { ...turnRequest, hostTransition };
|
|
28052
28434
|
}
|
|
28435
|
+
if (typeof liveHost === "string" && liveHost.trim() !== "") {
|
|
28436
|
+
turnRequest = { ...turnRequest, host: liveHost.trim() };
|
|
28437
|
+
}
|
|
28053
28438
|
if (isStationChildOfficerDialogue(admitted.role, env)) {
|
|
28054
28439
|
await deliverCaseDossierAsAttachment({
|
|
28055
28440
|
ticketNumber: admitted.ticketNumber,
|
|
@@ -28086,12 +28471,12 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28086
28471
|
} catch (error) {
|
|
28087
28472
|
const settled2 = await settleAfterTurnStarted(
|
|
28088
28473
|
admitted,
|
|
28089
|
-
{
|
|
28474
|
+
withEngineDetourInvocationScope({
|
|
28090
28475
|
timedOut: false,
|
|
28091
28476
|
code: null,
|
|
28092
28477
|
stderr: "",
|
|
28093
28478
|
thrown: error
|
|
28094
|
-
},
|
|
28479
|
+
}, request.invocationScopeId),
|
|
28095
28480
|
adapters,
|
|
28096
28481
|
env.principalAuthority,
|
|
28097
28482
|
io,
|
|
@@ -28102,7 +28487,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28102
28487
|
let stderrLogWriteFailure;
|
|
28103
28488
|
try {
|
|
28104
28489
|
await writeFile10(
|
|
28105
|
-
|
|
28490
|
+
join31(admitted.runDirectory, "stderr.log"),
|
|
28106
28491
|
result2.stderr,
|
|
28107
28492
|
"utf8"
|
|
28108
28493
|
);
|
|
@@ -28115,7 +28500,10 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28115
28500
|
io
|
|
28116
28501
|
);
|
|
28117
28502
|
}
|
|
28118
|
-
const courtScope = request.courtAttemptId === void 0 || request.courtAttemptId.length === 0 ? void 0 : {
|
|
28503
|
+
const courtScope = (request.courtAttemptId === void 0 || request.courtAttemptId.length === 0) && (request.invocationScopeId === void 0 || request.invocationScopeId.length === 0) ? void 0 : {
|
|
28504
|
+
...request.courtAttemptId === void 0 || request.courtAttemptId.length === 0 ? {} : { courtAttemptId: request.courtAttemptId },
|
|
28505
|
+
...request.invocationScopeId === void 0 || request.invocationScopeId.length === 0 ? {} : { invocationScopeId: request.invocationScopeId }
|
|
28506
|
+
};
|
|
28119
28507
|
let settled;
|
|
28120
28508
|
let settledOutcome;
|
|
28121
28509
|
let hostSignalFailed = false;
|
|
@@ -28165,12 +28553,12 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28165
28553
|
} catch (error) {
|
|
28166
28554
|
const settledFailure = await settleAfterTurnStarted(
|
|
28167
28555
|
admitted,
|
|
28168
|
-
{
|
|
28556
|
+
withEngineDetourInvocationScope({
|
|
28169
28557
|
timedOut: false,
|
|
28170
28558
|
code: result2.code,
|
|
28171
28559
|
stderr: result2.stderr,
|
|
28172
28560
|
thrown: error
|
|
28173
|
-
},
|
|
28561
|
+
}, request.invocationScopeId),
|
|
28174
28562
|
adapters,
|
|
28175
28563
|
env.principalAuthority,
|
|
28176
28564
|
io,
|
|
@@ -28185,13 +28573,13 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28185
28573
|
} catch (error) {
|
|
28186
28574
|
const failed = await settleAfterTurnStarted(
|
|
28187
28575
|
admitted,
|
|
28188
|
-
{
|
|
28576
|
+
withEngineDetourInvocationScope({
|
|
28189
28577
|
timedOut: false,
|
|
28190
28578
|
code: null,
|
|
28191
28579
|
stderr: "",
|
|
28192
28580
|
thrown: error,
|
|
28193
28581
|
skipRunStateWrite: true
|
|
28194
|
-
},
|
|
28582
|
+
}, request.invocationScopeId),
|
|
28195
28583
|
adapters,
|
|
28196
28584
|
env.principalAuthority,
|
|
28197
28585
|
io,
|
|
@@ -28207,7 +28595,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28207
28595
|
const stderrLogWriteDetails = stderrLogWriteFailure === void 0 ? void 0 : { stderrLogWriteFailure: describeCaughtError(stderrLogWriteFailure) };
|
|
28208
28596
|
const failed = await settleAfterTurnStarted(
|
|
28209
28597
|
admitted,
|
|
28210
|
-
{
|
|
28598
|
+
withEngineDetourInvocationScope({
|
|
28211
28599
|
timedOut: result2.timedOut,
|
|
28212
28600
|
code: result2.code,
|
|
28213
28601
|
stderr: result2.stderr,
|
|
@@ -28221,7 +28609,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28221
28609
|
details: { ...resolutionInput.knownFailure.details ?? {}, ...stderrLogWriteDetails }
|
|
28222
28610
|
}
|
|
28223
28611
|
} : { knownDetails: stderrLogWriteDetails }
|
|
28224
|
-
},
|
|
28612
|
+
}, request.invocationScopeId),
|
|
28225
28613
|
adapters,
|
|
28226
28614
|
env.principalAuthority,
|
|
28227
28615
|
io,
|
|
@@ -28232,12 +28620,12 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28232
28620
|
if (stderrLogWriteFailure !== void 0) {
|
|
28233
28621
|
const failed = await settleAfterTurnStarted(
|
|
28234
28622
|
admitted,
|
|
28235
|
-
{
|
|
28623
|
+
withEngineDetourInvocationScope({
|
|
28236
28624
|
timedOut: false,
|
|
28237
28625
|
code: result2.code,
|
|
28238
28626
|
stderr: result2.stderr,
|
|
28239
28627
|
thrown: stderrLogWriteFailure
|
|
28240
|
-
},
|
|
28628
|
+
}, request.invocationScopeId),
|
|
28241
28629
|
adapters,
|
|
28242
28630
|
env.principalAuthority,
|
|
28243
28631
|
io,
|
|
@@ -28247,7 +28635,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28247
28635
|
}
|
|
28248
28636
|
const noReceipt = await attachRecordedSubmissions(
|
|
28249
28637
|
admitted,
|
|
28250
|
-
await settleHostEndedNoReceipt(admitted, env.principalAuthority),
|
|
28638
|
+
await settleHostEndedNoReceipt(admitted, env.principalAuthority, courtScope),
|
|
28251
28639
|
courtScope
|
|
28252
28640
|
);
|
|
28253
28641
|
if (persistRunState) {
|
|
@@ -28256,13 +28644,13 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
28256
28644
|
} catch (error) {
|
|
28257
28645
|
const failed = await settleAfterTurnStarted(
|
|
28258
28646
|
admitted,
|
|
28259
|
-
{
|
|
28647
|
+
withEngineDetourInvocationScope({
|
|
28260
28648
|
timedOut: false,
|
|
28261
28649
|
code: null,
|
|
28262
28650
|
stderr: "",
|
|
28263
28651
|
thrown: error,
|
|
28264
28652
|
skipRunStateWrite: true
|
|
28265
|
-
},
|
|
28653
|
+
}, request.invocationScopeId),
|
|
28266
28654
|
adapters,
|
|
28267
28655
|
env.principalAuthority,
|
|
28268
28656
|
io,
|
|
@@ -28331,7 +28719,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
28331
28719
|
kind: "resume",
|
|
28332
28720
|
prompt
|
|
28333
28721
|
},
|
|
28334
|
-
...request.message === void 0 ? {} : { courtAttemptId:
|
|
28722
|
+
...request.message === void 0 ? {} : { courtAttemptId: randomUUID7() },
|
|
28335
28723
|
...env.stationChild === void 0 ? {} : { stationChild: env.stationChild }
|
|
28336
28724
|
};
|
|
28337
28725
|
}
|
|
@@ -28349,7 +28737,7 @@ async function dispatchAfterWriterLease(input) {
|
|
|
28349
28737
|
}
|
|
28350
28738
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
28351
28739
|
const absolute = isAbsolute8(attachmentPath) ? attachmentPath : resolve8(attachmentPath);
|
|
28352
|
-
return pathContainedIn(
|
|
28740
|
+
return pathContainedIn(join31(runDirectory, "attachments"), absolute);
|
|
28353
28741
|
}
|
|
28354
28742
|
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
28355
28743
|
if (summons === void 0) return void 0;
|
|
@@ -28428,7 +28816,7 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
28428
28816
|
}
|
|
28429
28817
|
let turnRequest = await input.buildTurnRequest(admittedForBuild, request);
|
|
28430
28818
|
if (openCourtAttemptId !== void 0 || request.summons !== void 0 || request.message !== void 0) {
|
|
28431
|
-
const courtAttemptId = openCourtAttemptId ?? (turnRequest.courtAttemptId !== void 0 && turnRequest.courtAttemptId.length > 0 ? turnRequest.courtAttemptId :
|
|
28819
|
+
const courtAttemptId = openCourtAttemptId ?? (turnRequest.courtAttemptId !== void 0 && turnRequest.courtAttemptId.length > 0 ? turnRequest.courtAttemptId : randomUUID7());
|
|
28432
28820
|
turnRequest = { ...turnRequest, courtAttemptId };
|
|
28433
28821
|
if (openCourtAttemptId === void 0) {
|
|
28434
28822
|
const court = {
|
|
@@ -28444,6 +28832,9 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
28444
28832
|
if (input.env.stationChild === true) {
|
|
28445
28833
|
let firstTurn;
|
|
28446
28834
|
const stationAdapters = withOnceSuccessfulBeforeDispatch(adapters);
|
|
28835
|
+
const invocationScopeId = mintEngineDetourInvocationScope({
|
|
28836
|
+
...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine }
|
|
28837
|
+
});
|
|
28447
28838
|
return await runWithAutoResumeLoop({
|
|
28448
28839
|
admitted: loaded.admitted,
|
|
28449
28840
|
principalAuthority: input.env.principalAuthority,
|
|
@@ -28470,7 +28861,10 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
28470
28861
|
}
|
|
28471
28862
|
};
|
|
28472
28863
|
}
|
|
28473
|
-
const turnRequest =
|
|
28864
|
+
const turnRequest = withEngineDetourInvocationScope(
|
|
28865
|
+
await buildRequestAfterLease(),
|
|
28866
|
+
invocationScopeId
|
|
28867
|
+
);
|
|
28474
28868
|
firstTurn = turnRequest;
|
|
28475
28869
|
return turnRequest;
|
|
28476
28870
|
},
|
|
@@ -28541,6 +28935,11 @@ async function runPostAdmissionOneShot(input) {
|
|
|
28541
28935
|
async function runPostAdmissionResumable(input) {
|
|
28542
28936
|
const { admitted, env, io, buildInitialRequest, buildResumeRequest, effectiveEngine } = input;
|
|
28543
28937
|
const adapters = withOnceSuccessfulBeforeDispatch(input.adapters);
|
|
28938
|
+
const invocationScopeId = mintEngineDetourInvocationScope({
|
|
28939
|
+
...effectiveEngine === void 0 ? {} : { effectiveEngine }
|
|
28940
|
+
});
|
|
28941
|
+
const buildScopedInitial = () => withEngineDetourInvocationScope(buildInitialRequest(), invocationScopeId);
|
|
28942
|
+
const buildScopedResume = () => withEngineDetourInvocationScope(buildResumeRequest(), invocationScopeId);
|
|
28544
28943
|
return runWithAutoResumeLoop({
|
|
28545
28944
|
admitted,
|
|
28546
28945
|
principalAuthority: env.principalAuthority,
|
|
@@ -28548,8 +28947,8 @@ async function runPostAdmissionResumable(input) {
|
|
|
28548
28947
|
io,
|
|
28549
28948
|
sessionAppender: env.sessionAppender,
|
|
28550
28949
|
autoResumeLimit: env.autoResumeLimit,
|
|
28551
|
-
buildInitialPayload:
|
|
28552
|
-
buildResumePayload:
|
|
28950
|
+
buildInitialPayload: buildScopedInitial,
|
|
28951
|
+
buildResumePayload: buildScopedResume,
|
|
28553
28952
|
dispatch: async (request, lease, _isFirst, attemptIo) => {
|
|
28554
28953
|
const result2 = await dispatchPostAdmissionTurn({
|
|
28555
28954
|
admitted,
|
|
@@ -28597,6 +28996,9 @@ async function runPostAdmissionManualResume(input) {
|
|
|
28597
28996
|
}
|
|
28598
28997
|
throw error;
|
|
28599
28998
|
}
|
|
28999
|
+
const invocationScopeId = mintEngineDetourInvocationScope({
|
|
29000
|
+
...effectiveEngine === void 0 ? {} : { effectiveEngine }
|
|
29001
|
+
});
|
|
28600
29002
|
const result2 = await dispatchAfterWriterLease({
|
|
28601
29003
|
lease,
|
|
28602
29004
|
build: async () => {
|
|
@@ -28608,6 +29010,7 @@ async function runPostAdmissionManualResume(input) {
|
|
|
28608
29010
|
}
|
|
28609
29011
|
request = await buildRequestAfterLease();
|
|
28610
29012
|
}
|
|
29013
|
+
request = withEngineDetourInvocationScope(request, invocationScopeId);
|
|
28611
29014
|
return request;
|
|
28612
29015
|
},
|
|
28613
29016
|
dispatch: (turnRequest) => dispatchPostAdmissionTurn({
|
|
@@ -28647,6 +29050,7 @@ var init_post_admission = __esm({
|
|
|
28647
29050
|
init_session_identity();
|
|
28648
29051
|
init_host_contracts();
|
|
28649
29052
|
init_case_dossier_delivery();
|
|
29053
|
+
init_engine_detour_usage();
|
|
28650
29054
|
init_host_transition_prior_native();
|
|
28651
29055
|
init_public_run_credentials();
|
|
28652
29056
|
init_run_lifecycle();
|
|
@@ -29969,7 +30373,7 @@ __export(public_role_summons_exports, {
|
|
|
29969
30373
|
summonPublicRole: () => summonPublicRole
|
|
29970
30374
|
});
|
|
29971
30375
|
import { existsSync as existsSync10 } from "node:fs";
|
|
29972
|
-
import { join as
|
|
30376
|
+
import { join as join32 } from "node:path";
|
|
29973
30377
|
function createCapturingIo() {
|
|
29974
30378
|
const chunks = [];
|
|
29975
30379
|
return {
|
|
@@ -29992,7 +30396,7 @@ function parentDir(path) {
|
|
|
29992
30396
|
function walkPackageRoot(start) {
|
|
29993
30397
|
let dir = start;
|
|
29994
30398
|
for (let i = 0; i < 12; i += 1) {
|
|
29995
|
-
if (existsSync10(
|
|
30399
|
+
if (existsSync10(join32(dir, "package.json")) && existsSync10(join32(dir, "souls"))) {
|
|
29996
30400
|
return dir;
|
|
29997
30401
|
}
|
|
29998
30402
|
const parent = parentDir(dir);
|
|
@@ -30045,11 +30449,17 @@ function hostSelectionFailureFromUnknown(error) {
|
|
|
30045
30449
|
const failure = error.failure;
|
|
30046
30450
|
return failure;
|
|
30047
30451
|
}
|
|
30048
|
-
async function createSummonEnv(options) {
|
|
30049
|
-
const [
|
|
30452
|
+
async function createSummonEnv(options, afterHost) {
|
|
30453
|
+
const [
|
|
30454
|
+
{ piDurablePrincipalAuthority: piDurablePrincipalAuthority2 },
|
|
30455
|
+
{ appendPiSessionCustomEntry: appendPiSessionCustomEntry2 },
|
|
30456
|
+
{ resolveRoleTurnHost: resolveRoleTurnHost2 },
|
|
30457
|
+
{ missingResolvedSeatModelMessage: missingResolvedSeatModelMessage2, resolvedSeatWithModel: resolvedSeatWithModel2 }
|
|
30458
|
+
] = await Promise.all([
|
|
30050
30459
|
Promise.resolve().then(() => (init_durable_principal(), durable_principal_exports)),
|
|
30051
30460
|
Promise.resolve().then(() => (init_role_turn_host(), role_turn_host_exports)),
|
|
30052
|
-
Promise.resolve().then(() => (init_role_turn_host_resolution(), role_turn_host_resolution_exports))
|
|
30461
|
+
Promise.resolve().then(() => (init_role_turn_host_resolution(), role_turn_host_resolution_exports)),
|
|
30462
|
+
Promise.resolve().then(() => (init_config2(), config_exports))
|
|
30053
30463
|
]);
|
|
30054
30464
|
const principalAuthority = piDurablePrincipalAuthority2;
|
|
30055
30465
|
const roleTurnHost = resolveRoleTurnHost2(
|
|
@@ -30061,32 +30471,43 @@ async function createSummonEnv(options) {
|
|
|
30061
30471
|
},
|
|
30062
30472
|
{ role: options.role, seat: options.seat, principalAuthority }
|
|
30063
30473
|
);
|
|
30064
|
-
|
|
30474
|
+
afterHost?.();
|
|
30475
|
+
const seatWithModel = resolvedSeatWithModel2(options.seat);
|
|
30476
|
+
if (seatWithModel === void 0) {
|
|
30477
|
+
return {
|
|
30478
|
+
ok: false,
|
|
30479
|
+
missingModelMessage: missingResolvedSeatModelMessage2(options.role)
|
|
30480
|
+
};
|
|
30481
|
+
}
|
|
30482
|
+
const hostName = seatWithModel.host ?? "pi";
|
|
30065
30483
|
const { loadHostProvidersTable: loadHostProvidersTable2, projectHostFacingProvider: projectHostFacingProvider2 } = await Promise.resolve().then(() => (init_host_providers(), host_providers_exports));
|
|
30066
|
-
const hostFacingSelection =
|
|
30067
|
-
|
|
30484
|
+
const hostFacingSelection = projectHostFacingProvider2(
|
|
30485
|
+
seatWithModel.selection,
|
|
30068
30486
|
hostName,
|
|
30069
30487
|
loadHostProvidersTable2(options.home),
|
|
30070
30488
|
options.home
|
|
30071
30489
|
);
|
|
30072
30490
|
return {
|
|
30073
|
-
|
|
30074
|
-
|
|
30075
|
-
|
|
30076
|
-
|
|
30077
|
-
|
|
30078
|
-
|
|
30079
|
-
|
|
30080
|
-
|
|
30081
|
-
|
|
30082
|
-
|
|
30083
|
-
|
|
30491
|
+
ok: true,
|
|
30492
|
+
env: {
|
|
30493
|
+
home: options.home,
|
|
30494
|
+
principalAuthority,
|
|
30495
|
+
agentDir: options.agentDir,
|
|
30496
|
+
sessionAppender: appendPiSessionCustomEntry2,
|
|
30497
|
+
packageRoot: options.packageRoot,
|
|
30498
|
+
roleTurnHost,
|
|
30499
|
+
cwd: options.cwd,
|
|
30500
|
+
credentials: options.credentials,
|
|
30501
|
+
...hostFacingSelection === void 0 ? {} : { model: hostFacingSelection },
|
|
30502
|
+
...projectSeatEngine(seatWithModel),
|
|
30503
|
+
...projectSeatHost(seatWithModel)
|
|
30504
|
+
}
|
|
30084
30505
|
};
|
|
30085
30506
|
}
|
|
30086
30507
|
async function summonPublicRole(options) {
|
|
30087
30508
|
const packageRoot2 = resolveSummonsPackageRoot(options.packageRoot);
|
|
30088
30509
|
const home = await resolveSummonHome(options);
|
|
30089
|
-
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
30510
|
+
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join32(home, ".pi", "agent");
|
|
30090
30511
|
const {
|
|
30091
30512
|
loadCredentialProviders: loadCredentialProviders2,
|
|
30092
30513
|
loadPublicCliConfig: loadPublicCliConfig2,
|
|
@@ -30095,46 +30516,72 @@ async function summonPublicRole(options) {
|
|
|
30095
30516
|
const credentials = options.credentials ?? await loadCredentialProviders2(agentDir);
|
|
30096
30517
|
const config = await loadPublicCliConfig2(home);
|
|
30097
30518
|
const seat = resolveEffectiveSeat2(config, options.role, credentials);
|
|
30098
|
-
let summonEnv;
|
|
30099
|
-
try {
|
|
30100
|
-
summonEnv = await createSummonEnv({
|
|
30101
|
-
role: options.role,
|
|
30102
|
-
home,
|
|
30103
|
-
agentDir,
|
|
30104
|
-
cwd: options.cwd,
|
|
30105
|
-
packageRoot: packageRoot2,
|
|
30106
|
-
credentials,
|
|
30107
|
-
seat,
|
|
30108
|
-
...options.extraPiArgs === void 0 ? {} : { extraPiArgs: options.extraPiArgs },
|
|
30109
|
-
...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
|
|
30110
|
-
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters }
|
|
30111
|
-
});
|
|
30112
|
-
} catch (error) {
|
|
30113
|
-
const failure = hostSelectionFailureFromUnknown(error);
|
|
30114
|
-
if (failure !== void 0) {
|
|
30115
|
-
const { formatHostSelectionFailure: formatHostSelectionFailure2 } = await Promise.resolve().then(() => (init_role_turn_host_resolution(), role_turn_host_resolution_exports));
|
|
30116
|
-
return { exitCode: 1, stderr: formatHostSelectionFailure2(failure) };
|
|
30117
|
-
}
|
|
30118
|
-
throw error;
|
|
30119
|
-
}
|
|
30120
|
-
const env = {
|
|
30121
|
-
...summonEnv,
|
|
30122
|
-
// Station child role run (#840): omit automatic navigator attendance.
|
|
30123
|
-
stationChild: true,
|
|
30124
|
-
// Host config passthrough only — same face as public CLI (#422 / #675).
|
|
30125
|
-
...config.autoResumeLimit === void 0 ? {} : { autoResumeLimit: config.autoResumeLimit },
|
|
30126
|
-
// Parent cancellation reaches the nested activation's own turn dispatch.
|
|
30127
|
-
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
30128
|
-
// #753: reask rides the existing notary same-ticket resume summons.instruction.
|
|
30129
|
-
...options.reviewReask === void 0 ? {} : { reviewReask: options.reviewReask },
|
|
30130
|
-
// #879: verbatim submission body on officer dialogue content channel.
|
|
30131
|
-
...options.gateReviewInstruction === void 0 ? {} : { gateReviewInstruction: options.gateReviewInstruction },
|
|
30132
|
-
...options.boundTicketNumber === void 0 ? {} : { boundTicketNumber: options.boundTicketNumber },
|
|
30133
|
-
// createRunId is the only remaining env overlay — host is seat-selected above.
|
|
30134
|
-
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
|
|
30135
|
-
};
|
|
30136
30519
|
const captured = options.io === void 0 ? createCapturingIo() : void 0;
|
|
30137
30520
|
const io = options.io ?? captured.io;
|
|
30521
|
+
const summonEnvInput = {
|
|
30522
|
+
role: options.role,
|
|
30523
|
+
home,
|
|
30524
|
+
agentDir,
|
|
30525
|
+
cwd: options.cwd,
|
|
30526
|
+
packageRoot: packageRoot2,
|
|
30527
|
+
credentials,
|
|
30528
|
+
seat,
|
|
30529
|
+
...options.extraPiArgs === void 0 ? {} : { extraPiArgs: options.extraPiArgs },
|
|
30530
|
+
...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
|
|
30531
|
+
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters }
|
|
30532
|
+
};
|
|
30533
|
+
async function prepareSummonEnv(afterHost) {
|
|
30534
|
+
try {
|
|
30535
|
+
const built = await createSummonEnv(summonEnvInput, afterHost);
|
|
30536
|
+
if (!built.ok) {
|
|
30537
|
+
return { ok: false, exitCode: 1, stderr: built.missingModelMessage };
|
|
30538
|
+
}
|
|
30539
|
+
return {
|
|
30540
|
+
ok: true,
|
|
30541
|
+
env: {
|
|
30542
|
+
...built.env,
|
|
30543
|
+
stationChild: true,
|
|
30544
|
+
...config.autoResumeLimit === void 0 ? {} : { autoResumeLimit: config.autoResumeLimit },
|
|
30545
|
+
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
30546
|
+
...options.reviewReask === void 0 ? {} : { reviewReask: options.reviewReask },
|
|
30547
|
+
...options.gateReviewInstruction === void 0 ? {} : { gateReviewInstruction: options.gateReviewInstruction },
|
|
30548
|
+
...options.boundTicketNumber === void 0 ? {} : { boundTicketNumber: options.boundTicketNumber },
|
|
30549
|
+
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
|
|
30550
|
+
}
|
|
30551
|
+
};
|
|
30552
|
+
} catch (error) {
|
|
30553
|
+
const failure = hostSelectionFailureFromUnknown(error);
|
|
30554
|
+
if (failure !== void 0) {
|
|
30555
|
+
const { formatHostSelectionFailure: formatHostSelectionFailure2 } = await Promise.resolve().then(() => (init_role_turn_host_resolution(), role_turn_host_resolution_exports));
|
|
30556
|
+
return { ok: false, exitCode: 1, stderr: formatHostSelectionFailure2(failure) };
|
|
30557
|
+
}
|
|
30558
|
+
const { CliUsageError: CliUsageError2 } = await Promise.resolve().then(() => (init_cli_errors(), cli_errors_exports));
|
|
30559
|
+
if (error instanceof CliUsageError2) {
|
|
30560
|
+
const { presentStructuralRejection: presentStructuralRejection2 } = await Promise.resolve().then(() => (init_settlement(), settlement_exports));
|
|
30561
|
+
presentStructuralRejection2(error, io);
|
|
30562
|
+
return { ok: false, exitCode: 2 };
|
|
30563
|
+
}
|
|
30564
|
+
throw error;
|
|
30565
|
+
}
|
|
30566
|
+
}
|
|
30567
|
+
function projectPrepareFailure(prepared) {
|
|
30568
|
+
const parts = [prepared.stderr, captured?.stderrText()].filter(
|
|
30569
|
+
(s) => typeof s === "string" && s !== ""
|
|
30570
|
+
);
|
|
30571
|
+
const stderr2 = parts.length === 0 ? void 0 : parts.join("");
|
|
30572
|
+
return {
|
|
30573
|
+
exitCode: prepared.exitCode,
|
|
30574
|
+
...stderr2 === void 0 ? {} : { stderr: stderr2 }
|
|
30575
|
+
};
|
|
30576
|
+
}
|
|
30577
|
+
async function runPrepared(parse, run) {
|
|
30578
|
+
let parsedArgv;
|
|
30579
|
+
const prepared = await prepareSummonEnv(() => {
|
|
30580
|
+
parsedArgv = parse(options.argv);
|
|
30581
|
+
});
|
|
30582
|
+
if (!prepared.ok) return { fail: projectPrepareFailure(prepared) };
|
|
30583
|
+
return { ok: await run(prepared.env, () => parsedArgv) };
|
|
30584
|
+
}
|
|
30138
30585
|
let result2;
|
|
30139
30586
|
switch (options.role) {
|
|
30140
30587
|
case "notary": {
|
|
@@ -30142,7 +30589,9 @@ async function summonPublicRole(options) {
|
|
|
30142
30589
|
Promise.resolve().then(() => (init_notary_run(), notary_run_exports)),
|
|
30143
30590
|
Promise.resolve().then(() => (init_invocation(), invocation_exports))
|
|
30144
30591
|
]);
|
|
30145
|
-
|
|
30592
|
+
const stepped = await runPrepared(parseNotaryArgv2, (env, once) => runPublicNotary2(options.argv, env, io, once));
|
|
30593
|
+
if ("fail" in stepped) return stepped.fail;
|
|
30594
|
+
result2 = stepped.ok;
|
|
30146
30595
|
break;
|
|
30147
30596
|
}
|
|
30148
30597
|
case "inspector": {
|
|
@@ -30150,49 +30599,23 @@ async function summonPublicRole(options) {
|
|
|
30150
30599
|
Promise.resolve().then(() => (init_inspector_run(), inspector_run_exports)),
|
|
30151
30600
|
Promise.resolve().then(() => (init_invocation(), invocation_exports))
|
|
30152
30601
|
]);
|
|
30153
|
-
|
|
30154
|
-
|
|
30155
|
-
|
|
30156
|
-
case "auditor": {
|
|
30157
|
-
const [{ runPublicInstructionSeat: runPublicInstructionSeat2 }, { parseAuditorArgv: parseAuditorArgv2 }] = await Promise.all([
|
|
30158
|
-
Promise.resolve().then(() => (init_instruction_seat_run(), instruction_seat_run_exports)),
|
|
30159
|
-
Promise.resolve().then(() => (init_invocation(), invocation_exports))
|
|
30160
|
-
]);
|
|
30161
|
-
result2 = await runPublicInstructionSeat2(
|
|
30162
|
-
options.argv,
|
|
30163
|
-
env,
|
|
30164
|
-
io,
|
|
30165
|
-
"auditor",
|
|
30166
|
-
parseAuditorArgv2
|
|
30167
|
-
);
|
|
30168
|
-
break;
|
|
30169
|
-
}
|
|
30170
|
-
case "navigator": {
|
|
30171
|
-
const [{ runPublicInstructionSeat: runPublicInstructionSeat2 }, { parseNavigatorArgv: parseNavigatorArgv2 }] = await Promise.all([
|
|
30172
|
-
Promise.resolve().then(() => (init_instruction_seat_run(), instruction_seat_run_exports)),
|
|
30173
|
-
Promise.resolve().then(() => (init_invocation(), invocation_exports))
|
|
30174
|
-
]);
|
|
30175
|
-
result2 = await runPublicInstructionSeat2(
|
|
30176
|
-
options.argv,
|
|
30177
|
-
env,
|
|
30178
|
-
io,
|
|
30179
|
-
"navigator",
|
|
30180
|
-
parseNavigatorArgv2
|
|
30181
|
-
);
|
|
30602
|
+
const stepped = await runPrepared(parseInspectorArgv2, (env, once) => runPublicInspector2(options.argv, env, io, once));
|
|
30603
|
+
if ("fail" in stepped) return stepped.fail;
|
|
30604
|
+
result2 = stepped.ok;
|
|
30182
30605
|
break;
|
|
30183
30606
|
}
|
|
30607
|
+
case "auditor":
|
|
30608
|
+
case "navigator":
|
|
30184
30609
|
case "gatekeeper": {
|
|
30185
|
-
const
|
|
30610
|
+
const seat2 = options.role;
|
|
30611
|
+
const [{ runPublicInstructionSeat: runPublicInstructionSeat2 }, invocation] = await Promise.all([
|
|
30186
30612
|
Promise.resolve().then(() => (init_instruction_seat_run(), instruction_seat_run_exports)),
|
|
30187
30613
|
Promise.resolve().then(() => (init_invocation(), invocation_exports))
|
|
30188
30614
|
]);
|
|
30189
|
-
|
|
30190
|
-
|
|
30191
|
-
|
|
30192
|
-
|
|
30193
|
-
"gatekeeper",
|
|
30194
|
-
parseGatekeeperArgv2
|
|
30195
|
-
);
|
|
30615
|
+
const parse = seat2 === "auditor" ? invocation.parseAuditorArgv : seat2 === "navigator" ? invocation.parseNavigatorArgv : invocation.parseGatekeeperArgv;
|
|
30616
|
+
const stepped = await runPrepared(parse, (env, once) => runPublicInstructionSeat2(options.argv, env, io, seat2, once));
|
|
30617
|
+
if ("fail" in stepped) return stepped.fail;
|
|
30618
|
+
result2 = stepped.ok;
|
|
30196
30619
|
break;
|
|
30197
30620
|
}
|
|
30198
30621
|
case "judge": {
|
|
@@ -30200,7 +30623,9 @@ async function summonPublicRole(options) {
|
|
|
30200
30623
|
Promise.resolve().then(() => (init_judge_run(), judge_run_exports)),
|
|
30201
30624
|
Promise.resolve().then(() => (init_invocation(), invocation_exports))
|
|
30202
30625
|
]);
|
|
30203
|
-
|
|
30626
|
+
const stepped = await runPrepared(parseJudgeArgv2, (env, once) => runPublicJudge2(options.argv, env, io, once));
|
|
30627
|
+
if ("fail" in stepped) return stepped.fail;
|
|
30628
|
+
result2 = stepped.ok;
|
|
30204
30629
|
break;
|
|
30205
30630
|
}
|
|
30206
30631
|
case "doctor": {
|
|
@@ -30208,7 +30633,9 @@ async function summonPublicRole(options) {
|
|
|
30208
30633
|
Promise.resolve().then(() => (init_doctor_run(), doctor_run_exports)),
|
|
30209
30634
|
Promise.resolve().then(() => (init_invocation(), invocation_exports))
|
|
30210
30635
|
]);
|
|
30211
|
-
|
|
30636
|
+
const stepped = await runPrepared(parseDoctorArgv2, (env, once) => runPublicDoctor2(options.argv, env, io, once));
|
|
30637
|
+
if ("fail" in stepped) return stepped.fail;
|
|
30638
|
+
result2 = stepped.ok;
|
|
30212
30639
|
break;
|
|
30213
30640
|
}
|
|
30214
30641
|
case "diarist": {
|
|
@@ -30216,7 +30643,9 @@ async function summonPublicRole(options) {
|
|
|
30216
30643
|
Promise.resolve().then(() => (init_diarist_run(), diarist_run_exports)),
|
|
30217
30644
|
Promise.resolve().then(() => (init_invocation(), invocation_exports))
|
|
30218
30645
|
]);
|
|
30219
|
-
|
|
30646
|
+
const stepped = await runPrepared(parseDiaristArgv2, (env, once) => runPublicDiarist2(options.argv, env, io, once));
|
|
30647
|
+
if ("fail" in stepped) return stepped.fail;
|
|
30648
|
+
result2 = stepped.ok;
|
|
30220
30649
|
break;
|
|
30221
30650
|
}
|
|
30222
30651
|
}
|
|
@@ -31325,8 +31754,8 @@ var init_analyst_book_key = __esm({
|
|
|
31325
31754
|
});
|
|
31326
31755
|
|
|
31327
31756
|
// src/analyst-index.ts
|
|
31328
|
-
import { open as open3, readFile as
|
|
31329
|
-
import { dirname as
|
|
31757
|
+
import { open as open3, readFile as readFile20, unlink as unlink4 } from "node:fs/promises";
|
|
31758
|
+
import { dirname as dirname17, join as join33 } from "node:path";
|
|
31330
31759
|
function sleep(ms) {
|
|
31331
31760
|
return new Promise((resolve10) => {
|
|
31332
31761
|
setTimeout(resolve10, ms);
|
|
@@ -31334,8 +31763,8 @@ function sleep(ms) {
|
|
|
31334
31763
|
}
|
|
31335
31764
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
31336
31765
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
31337
|
-
ensureRealDirectoryTree(ledgerHome,
|
|
31338
|
-
const lockPath =
|
|
31766
|
+
ensureRealDirectoryTree(ledgerHome, dirname17(indexPath));
|
|
31767
|
+
const lockPath = join33(dirname17(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
31339
31768
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
31340
31769
|
const startedAt = Date.now();
|
|
31341
31770
|
while (true) {
|
|
@@ -31362,7 +31791,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
31362
31791
|
}
|
|
31363
31792
|
}
|
|
31364
31793
|
function analystLibraryIndexPath(ledgerHome) {
|
|
31365
|
-
return
|
|
31794
|
+
return join33(ledgerHome, "analyst", "library-index.json");
|
|
31366
31795
|
}
|
|
31367
31796
|
function rowFromIssueMetricsPage(page) {
|
|
31368
31797
|
return {
|
|
@@ -31453,7 +31882,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
|
|
|
31453
31882
|
const path = analystLibraryIndexPath(ledgerHome);
|
|
31454
31883
|
let raw;
|
|
31455
31884
|
try {
|
|
31456
|
-
raw = await
|
|
31885
|
+
raw = await readFile20(path, "utf8");
|
|
31457
31886
|
} catch (error) {
|
|
31458
31887
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
|
|
31459
31888
|
return void 0;
|
|
@@ -31471,7 +31900,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
|
|
|
31471
31900
|
}
|
|
31472
31901
|
async function writeAnalystLibraryIndexPage(ledgerHome, page) {
|
|
31473
31902
|
const path = analystLibraryIndexPath(ledgerHome);
|
|
31474
|
-
ensureRealDirectoryTree(ledgerHome,
|
|
31903
|
+
ensureRealDirectoryTree(ledgerHome, dirname17(path));
|
|
31475
31904
|
assertLedgerFileInsideHome(path, ledgerHome);
|
|
31476
31905
|
await writeFileAtomically(path, `${JSON.stringify(page, null, 2)}
|
|
31477
31906
|
`);
|
|
@@ -31657,23 +32086,23 @@ var init_analyst_cohort = __esm({
|
|
|
31657
32086
|
});
|
|
31658
32087
|
|
|
31659
32088
|
// src/analyst-ledger.ts
|
|
31660
|
-
import { readdir as readdir9, readFile as
|
|
31661
|
-
import { basename as basename8, join as
|
|
32089
|
+
import { readdir as readdir9, readFile as readFile21 } from "node:fs/promises";
|
|
32090
|
+
import { basename as basename8, join as join34 } from "node:path";
|
|
31662
32091
|
function isMissingPathError6(error) {
|
|
31663
32092
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
31664
32093
|
}
|
|
31665
32094
|
function errorText3(error) {
|
|
31666
32095
|
return error instanceof Error ? error.message : String(error);
|
|
31667
32096
|
}
|
|
31668
|
-
function
|
|
32097
|
+
function isRecord11(value) {
|
|
31669
32098
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31670
32099
|
}
|
|
31671
32100
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
31672
32101
|
try {
|
|
31673
32102
|
const raw = JSON.parse(
|
|
31674
|
-
await
|
|
32103
|
+
await readFile21(join34(runDirectory, "run-state.json"), "utf8")
|
|
31675
32104
|
);
|
|
31676
|
-
if (!
|
|
32105
|
+
if (!isRecord11(raw) || typeof raw.state !== "string") return void 0;
|
|
31677
32106
|
return raw.state;
|
|
31678
32107
|
} catch {
|
|
31679
32108
|
return void 0;
|
|
@@ -31703,13 +32132,13 @@ async function listLedgerBookNames(booksRoot) {
|
|
|
31703
32132
|
async function readInvocationScopeFields(runDirectory) {
|
|
31704
32133
|
let raw;
|
|
31705
32134
|
try {
|
|
31706
|
-
raw = await
|
|
32135
|
+
raw = await readFile21(join34(runDirectory, "invocation.json"), "utf8");
|
|
31707
32136
|
} catch (error) {
|
|
31708
32137
|
if (isMissingPathError6(error)) return void 0;
|
|
31709
32138
|
throw error;
|
|
31710
32139
|
}
|
|
31711
32140
|
const parsed = JSON.parse(raw);
|
|
31712
|
-
if (!
|
|
32141
|
+
if (!isRecord11(parsed)) return void 0;
|
|
31713
32142
|
if (typeof parsed.projectRoot !== "string" || parsed.projectRoot.trim() === "") {
|
|
31714
32143
|
return void 0;
|
|
31715
32144
|
}
|
|
@@ -31736,15 +32165,15 @@ function decideIssueScope(input) {
|
|
|
31736
32165
|
}
|
|
31737
32166
|
async function resolveSessionFile(runDirectory) {
|
|
31738
32167
|
try {
|
|
31739
|
-
const raw = await
|
|
32168
|
+
const raw = await readFile21(join34(runDirectory, "invocation.json"), "utf8");
|
|
31740
32169
|
const parsed = JSON.parse(raw);
|
|
31741
|
-
if (
|
|
32170
|
+
if (isRecord11(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
31742
32171
|
return parsed.sessionFile;
|
|
31743
32172
|
}
|
|
31744
32173
|
} catch (error) {
|
|
31745
32174
|
if (!isMissingPathError6(error)) throw error;
|
|
31746
32175
|
}
|
|
31747
|
-
return
|
|
32176
|
+
return join34(runDirectory, "session", "session.jsonl");
|
|
31748
32177
|
}
|
|
31749
32178
|
function attributeSessionRowsForRun(input) {
|
|
31750
32179
|
if (pathContainedIn(input.runDirectory, input.sessionFile)) {
|
|
@@ -31916,9 +32345,9 @@ async function classifyScopedRun(input) {
|
|
|
31916
32345
|
}
|
|
31917
32346
|
let gateCycles;
|
|
31918
32347
|
try {
|
|
31919
|
-
const parentSessionFile =
|
|
32348
|
+
const parentSessionFile = join34(input.runDirectory, "session", "session.jsonl");
|
|
31920
32349
|
gateCycles = await readAnalystGateCyclesFromAuditorRoles(
|
|
31921
|
-
|
|
32350
|
+
join34(input.runDirectory, "session", "auditor-roles"),
|
|
31922
32351
|
{ parentSessionFile }
|
|
31923
32352
|
);
|
|
31924
32353
|
} catch (error) {
|
|
@@ -31951,7 +32380,7 @@ async function classifyScopedRun(input) {
|
|
|
31951
32380
|
async function scanAnalystIssueRuns(input) {
|
|
31952
32381
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
31953
32382
|
const scopeTicketNumber = input.ticketNumber;
|
|
31954
|
-
const booksRoot =
|
|
32383
|
+
const booksRoot = join34(ledgerHome, "books");
|
|
31955
32384
|
let wholeBook = false;
|
|
31956
32385
|
let scopeRootIdentity;
|
|
31957
32386
|
let bookNames;
|
|
@@ -31983,7 +32412,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
31983
32412
|
const unreadable = [];
|
|
31984
32413
|
const scopeConflicts = [];
|
|
31985
32414
|
for (const book of bookNames) {
|
|
31986
|
-
const bookDir =
|
|
32415
|
+
const bookDir = join34(booksRoot, book);
|
|
31987
32416
|
let runDirectories;
|
|
31988
32417
|
try {
|
|
31989
32418
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
@@ -32044,7 +32473,7 @@ var init_analyst_ledger = __esm({
|
|
|
32044
32473
|
});
|
|
32045
32474
|
|
|
32046
32475
|
// src/analyst-metric-families/acceptance-success-rework.ts
|
|
32047
|
-
function
|
|
32476
|
+
function isRecord12(value) {
|
|
32048
32477
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
32049
32478
|
}
|
|
32050
32479
|
function wallMsFromSpan(span) {
|
|
@@ -32053,21 +32482,21 @@ function wallMsFromSpan(span) {
|
|
|
32053
32482
|
function findCollectorGroups(body) {
|
|
32054
32483
|
if (Array.isArray(body.groups)) return body.groups;
|
|
32055
32484
|
const receipt = body.receipt;
|
|
32056
|
-
if (
|
|
32485
|
+
if (isRecord12(receipt) && Array.isArray(receipt.groups)) return receipt.groups;
|
|
32057
32486
|
const outcome = body.outcome;
|
|
32058
|
-
if (
|
|
32487
|
+
if (isRecord12(outcome)) {
|
|
32059
32488
|
const facts = outcome.decisiveFacts;
|
|
32060
|
-
if (
|
|
32489
|
+
if (isRecord12(facts) && Array.isArray(facts.groups)) return facts.groups;
|
|
32061
32490
|
}
|
|
32062
32491
|
return void 0;
|
|
32063
32492
|
}
|
|
32064
32493
|
function extractStatus(body) {
|
|
32065
32494
|
const outcome = body.outcome;
|
|
32066
|
-
if (
|
|
32495
|
+
if (isRecord12(outcome) && typeof outcome.status === "string" && outcome.status.trim() !== "") {
|
|
32067
32496
|
return outcome.status;
|
|
32068
32497
|
}
|
|
32069
32498
|
const receipt = body.receipt;
|
|
32070
|
-
if (
|
|
32499
|
+
if (isRecord12(receipt) && typeof receipt.status === "string" && receipt.status.trim() !== "") {
|
|
32071
32500
|
return receipt.status;
|
|
32072
32501
|
}
|
|
32073
32502
|
if (typeof body.status === "string" && body.status.trim() !== "") {
|
|
@@ -32692,21 +33121,21 @@ var init_leg_wall_clock = __esm({
|
|
|
32692
33121
|
});
|
|
32693
33122
|
|
|
32694
33123
|
// src/analyst-metric-families/round-timeline.ts
|
|
32695
|
-
function
|
|
33124
|
+
function isRecord13(value) {
|
|
32696
33125
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
32697
33126
|
}
|
|
32698
33127
|
function wallMsFromSpan2(startedAt, endedAt) {
|
|
32699
33128
|
return Date.parse(endedAt) - Date.parse(startedAt);
|
|
32700
33129
|
}
|
|
32701
33130
|
function readOutcomeStatus(body) {
|
|
32702
|
-
if (!
|
|
33131
|
+
if (!isRecord13(body.outcome)) return void 0;
|
|
32703
33132
|
const status = body.outcome.status;
|
|
32704
33133
|
if (typeof status !== "string" || status.trim() === "") return void 0;
|
|
32705
33134
|
return status;
|
|
32706
33135
|
}
|
|
32707
33136
|
function readClassCount(body) {
|
|
32708
|
-
if (!
|
|
32709
|
-
if (!
|
|
33137
|
+
if (!isRecord13(body.outcome)) return void 0;
|
|
33138
|
+
if (!isRecord13(body.outcome.decisiveFacts)) return void 0;
|
|
32710
33139
|
const classCount = body.outcome.decisiveFacts.classCount;
|
|
32711
33140
|
if (typeof classCount !== "number" || !Number.isFinite(classCount)) {
|
|
32712
33141
|
return void 0;
|
|
@@ -32850,7 +33279,7 @@ var init_analyst_metric_family = __esm({
|
|
|
32850
33279
|
|
|
32851
33280
|
// src/analyst-page.ts
|
|
32852
33281
|
import { createHash as createHash5 } from "node:crypto";
|
|
32853
|
-
import { dirname as
|
|
33282
|
+
import { dirname as dirname18, join as join35 } from "node:path";
|
|
32854
33283
|
function analystIssuePageKey(address) {
|
|
32855
33284
|
const parts = ["book", address.bookKey];
|
|
32856
33285
|
if (address.issueNumber !== void 0) {
|
|
@@ -32861,7 +33290,7 @@ function analystIssuePageKey(address) {
|
|
|
32861
33290
|
return createHash5("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
32862
33291
|
}
|
|
32863
33292
|
function analystIssuePagePath(ledgerHome, address) {
|
|
32864
|
-
return
|
|
33293
|
+
return join35(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
32865
33294
|
}
|
|
32866
33295
|
function analystIssuePageAddressFromPage(page) {
|
|
32867
33296
|
return {
|
|
@@ -32980,7 +33409,7 @@ async function buildAnalystIssueMetricsPage(input) {
|
|
|
32980
33409
|
}
|
|
32981
33410
|
async function writeAnalystIssueMetricsPage(ledgerHome, page) {
|
|
32982
33411
|
const path = analystIssuePagePath(ledgerHome, analystIssuePageAddressFromPage(page));
|
|
32983
|
-
ensureRealDirectoryTree(ledgerHome,
|
|
33412
|
+
ensureRealDirectoryTree(ledgerHome, dirname18(path));
|
|
32984
33413
|
assertLedgerFileInsideHome(path, ledgerHome);
|
|
32985
33414
|
await writeFileAtomically(path, `${JSON.stringify(page, null, 2)}
|
|
32986
33415
|
`);
|
|
@@ -32997,7 +33426,7 @@ var init_analyst_page = __esm({
|
|
|
32997
33426
|
});
|
|
32998
33427
|
|
|
32999
33428
|
// src/analyst-entry.ts
|
|
33000
|
-
import { readFile as
|
|
33429
|
+
import { readFile as readFile22 } from "node:fs/promises";
|
|
33001
33430
|
function isMissingPathError7(error) {
|
|
33002
33431
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
33003
33432
|
}
|
|
@@ -33027,7 +33456,7 @@ async function readOrComputeAnalystIssuePage(input, options) {
|
|
|
33027
33456
|
...issueNumber === void 0 && input.bookKey === void 0 ? { scopeRootIdentity: projectRoot } : {}
|
|
33028
33457
|
});
|
|
33029
33458
|
try {
|
|
33030
|
-
const raw = await
|
|
33459
|
+
const raw = await readFile22(pagePath, "utf8");
|
|
33031
33460
|
const page = JSON.parse(raw);
|
|
33032
33461
|
if (cachedPageMatchesRequestedScope(page, { bookKey, ...input })) {
|
|
33033
33462
|
return { mode: "issue", page, pagePath };
|
|
@@ -33122,7 +33551,7 @@ async function runAnalystModelGroupsMode(input, home) {
|
|
|
33122
33551
|
scopeRootIdentity: projectRoot
|
|
33123
33552
|
});
|
|
33124
33553
|
try {
|
|
33125
|
-
const raw = await
|
|
33554
|
+
const raw = await readFile22(pagePath, "utf8");
|
|
33126
33555
|
JSON.parse(raw);
|
|
33127
33556
|
} catch (error) {
|
|
33128
33557
|
if (!isMissingPathError7(error)) {
|
|
@@ -33221,7 +33650,7 @@ var init_analyst_entry = __esm({
|
|
|
33221
33650
|
});
|
|
33222
33651
|
|
|
33223
33652
|
// src/public-cli/analyst-run.ts
|
|
33224
|
-
import { readFile as
|
|
33653
|
+
import { readFile as readFile23 } from "node:fs/promises";
|
|
33225
33654
|
import { isAbsolute as isAbsolute10, resolve as resolve9 } from "node:path";
|
|
33226
33655
|
function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
|
|
33227
33656
|
try {
|
|
@@ -33274,7 +33703,7 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
|
|
|
33274
33703
|
const absolute = isAbsolute10(sourcePath) ? sourcePath : resolve9(sourcePath);
|
|
33275
33704
|
let bytes;
|
|
33276
33705
|
try {
|
|
33277
|
-
bytes = await
|
|
33706
|
+
bytes = await readFile23(absolute);
|
|
33278
33707
|
} catch (error) {
|
|
33279
33708
|
throw new CliUsageError(
|
|
33280
33709
|
`analyst sweep attachment is not a readable regular file: ${sourcePath}`,
|
|
@@ -33394,7 +33823,7 @@ __export(cli_exports, {
|
|
|
33394
33823
|
runAkRole: () => runAkRole
|
|
33395
33824
|
});
|
|
33396
33825
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
33397
|
-
import { join as
|
|
33826
|
+
import { join as join36 } from "node:path";
|
|
33398
33827
|
function takePublicGlobalFlag(argv, index, options) {
|
|
33399
33828
|
const tokens = argv.slice(index);
|
|
33400
33829
|
const taken = options.takeDashed(tokens);
|
|
@@ -33426,7 +33855,7 @@ function takePublicGlobalFlag(argv, index, options) {
|
|
|
33426
33855
|
}
|
|
33427
33856
|
return void 0;
|
|
33428
33857
|
}
|
|
33429
|
-
function createRoleEnvironment(env, options) {
|
|
33858
|
+
function createRoleEnvironment(env, options, afterHost) {
|
|
33430
33859
|
const role = options.role;
|
|
33431
33860
|
const extraPiArgs = role === "coder" ? env.coderExtraPiArgs : role === "fixer" ? env.fixerExtraPiArgs : role === "reviewer" ? env.reviewerExtraPiArgs : role === "merger" ? env.mergerExtraPiArgs : role === "judge" ? env.judgeExtraPiArgs : role === "collector" ? env.collectorExtraPiArgs : role === "doctor" ? env.doctorExtraPiArgs : role === "notary" ? env.notaryExtraPiArgs : void 0;
|
|
33432
33861
|
const timeoutMs = role === "coder" ? env.coderTimeoutMs : role === "fixer" ? env.fixerTimeoutMs : role === "reviewer" ? env.reviewerTimeoutMs : role === "merger" ? env.mergerTimeoutMs : role === "judge" ? env.judgeTimeoutMs : role === "collector" ? env.collectorTimeoutMs : role === "doctor" ? env.doctorTimeoutMs : role === "notary" ? env.notaryTimeoutMs : void 0;
|
|
@@ -33444,9 +33873,16 @@ function createRoleEnvironment(env, options) {
|
|
|
33444
33873
|
role,
|
|
33445
33874
|
seat: options.seat
|
|
33446
33875
|
});
|
|
33447
|
-
|
|
33448
|
-
|
|
33449
|
-
|
|
33876
|
+
afterHost?.();
|
|
33877
|
+
const seatWithModel = resolvedSeatWithModel(options.seat);
|
|
33878
|
+
if (seatWithModel === void 0) {
|
|
33879
|
+
throw new CliUsageError(
|
|
33880
|
+
missingResolvedSeatModelMessage(options.seat.seat, "invocation-or-config")
|
|
33881
|
+
);
|
|
33882
|
+
}
|
|
33883
|
+
const hostFacingSelection = projectHostFacingProvider(
|
|
33884
|
+
seatWithModel.selection,
|
|
33885
|
+
seatWithModel.host,
|
|
33450
33886
|
loadHostProvidersTable(options.home),
|
|
33451
33887
|
options.home
|
|
33452
33888
|
);
|
|
@@ -33470,6 +33906,34 @@ function createRoleEnvironment(env, options) {
|
|
|
33470
33906
|
...env.freshSummons === true ? { freshSummons: true } : {}
|
|
33471
33907
|
};
|
|
33472
33908
|
}
|
|
33909
|
+
async function dispatchPublicRoleCommand(env, home, io, parsed, role, parse, run) {
|
|
33910
|
+
const agentDir = resolveAgentDir(env, home);
|
|
33911
|
+
const cwd = env.cwd ?? process.cwd();
|
|
33912
|
+
const config = await loadAndValidateConfig(home, env.packageRoot);
|
|
33913
|
+
const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
|
|
33914
|
+
const seat = resolveEffectiveSeat(
|
|
33915
|
+
config,
|
|
33916
|
+
role,
|
|
33917
|
+
credentials,
|
|
33918
|
+
invocationFromParsed(parsed)
|
|
33919
|
+
);
|
|
33920
|
+
let parsedRoleArgv;
|
|
33921
|
+
const result2 = await run(
|
|
33922
|
+
parsed.args,
|
|
33923
|
+
createRoleEnvironment(
|
|
33924
|
+
env,
|
|
33925
|
+
{ role, home, agentDir, cwd, credentials, seat, config },
|
|
33926
|
+
() => {
|
|
33927
|
+
parsedRoleArgv = parse(parsed.args);
|
|
33928
|
+
}
|
|
33929
|
+
),
|
|
33930
|
+
() => parsedRoleArgv
|
|
33931
|
+
);
|
|
33932
|
+
return {
|
|
33933
|
+
exitCode: result2.exitCode,
|
|
33934
|
+
...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
|
|
33935
|
+
};
|
|
33936
|
+
}
|
|
33473
33937
|
function cliResultFromRoleRun(result2) {
|
|
33474
33938
|
return {
|
|
33475
33939
|
exitCode: result2.exitCode,
|
|
@@ -33491,7 +33955,7 @@ function resolveHome(env) {
|
|
|
33491
33955
|
return env.home ?? packageMachineHome();
|
|
33492
33956
|
}
|
|
33493
33957
|
function resolveAgentDir(env, home) {
|
|
33494
|
-
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
33958
|
+
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join36(home, ".pi", "agent");
|
|
33495
33959
|
}
|
|
33496
33960
|
function parseThinking(value) {
|
|
33497
33961
|
return value;
|
|
@@ -33707,6 +34171,7 @@ function renderHelp() {
|
|
|
33707
34171
|
"Persistent engine (callable roles): ak-role config set-engine <seat> <name> [model] | unset-engine <seat> | set-engine-model <seat> <model> | unset-engine-model <seat>",
|
|
33708
34172
|
"Persistent host (callable roles): ak-role config set-host <seat> <name> | unset-host <seat>",
|
|
33709
34173
|
"Host providers: ~/.ak-roles/host-providers.json (owner-edited; table > unique host directory > fail)",
|
|
34174
|
+
"Model resolution: --model \u2192 persistent seat \u2192 officer inherit (#620); still none \u2192 error (#178)",
|
|
33710
34175
|
"Host resolution: --host \u2192 persistent seat host \u2192 pi (resume uses the same order; #617)",
|
|
33711
34176
|
"Resume flag position: --model/--thinking/--host/--engine go before <runId> (before `resume` or between `resume` and <runId>); the one argv after <runId> is always the opaque message, never a flag (#471)",
|
|
33712
34177
|
"Effective seats: ak-role roles"
|
|
@@ -34108,291 +34573,148 @@ async function runAkRole(argv, env) {
|
|
|
34108
34573
|
throw new CliUsageError(`unhandled support command: ${parsed.command}`);
|
|
34109
34574
|
}
|
|
34110
34575
|
if (parsed.command === "judge") {
|
|
34111
|
-
|
|
34112
|
-
|
|
34113
|
-
|
|
34114
|
-
const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
|
|
34115
|
-
const seat = resolveEffectiveSeat(
|
|
34116
|
-
config,
|
|
34117
|
-
"judge",
|
|
34118
|
-
credentials,
|
|
34119
|
-
invocationFromParsed(parsed)
|
|
34120
|
-
);
|
|
34121
|
-
const result2 = await runPublicJudge(
|
|
34122
|
-
parsed.args,
|
|
34123
|
-
createRoleEnvironment(env, { role: "judge", home, agentDir, cwd, credentials, seat, config }),
|
|
34576
|
+
return await dispatchPublicRoleCommand(
|
|
34577
|
+
env,
|
|
34578
|
+
home,
|
|
34124
34579
|
io,
|
|
34125
|
-
|
|
34580
|
+
parsed,
|
|
34581
|
+
"judge",
|
|
34582
|
+
PUBLIC_ROLE_ARGV.judge.parse,
|
|
34583
|
+
(args, roleEnv, once) => runPublicJudge(args, roleEnv, io, once)
|
|
34126
34584
|
);
|
|
34127
|
-
return {
|
|
34128
|
-
exitCode: result2.exitCode,
|
|
34129
|
-
...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
|
|
34130
|
-
};
|
|
34131
34585
|
}
|
|
34132
34586
|
if (parsed.command === "countersign") {
|
|
34133
|
-
|
|
34134
|
-
|
|
34135
|
-
|
|
34136
|
-
const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
|
|
34137
|
-
const seat = resolveEffectiveSeat(
|
|
34138
|
-
config,
|
|
34139
|
-
"countersign",
|
|
34140
|
-
credentials,
|
|
34141
|
-
invocationFromParsed(parsed)
|
|
34142
|
-
);
|
|
34143
|
-
const result2 = await runPublicCountersign(
|
|
34144
|
-
parsed.args,
|
|
34145
|
-
createRoleEnvironment(env, { role: "countersign", home, agentDir, cwd, credentials, seat, config }),
|
|
34587
|
+
return await dispatchPublicRoleCommand(
|
|
34588
|
+
env,
|
|
34589
|
+
home,
|
|
34146
34590
|
io,
|
|
34147
|
-
|
|
34591
|
+
parsed,
|
|
34592
|
+
"countersign",
|
|
34593
|
+
PUBLIC_ROLE_ARGV.countersign.parse,
|
|
34594
|
+
(args, roleEnv, once) => runPublicCountersign(args, roleEnv, io, once)
|
|
34148
34595
|
);
|
|
34149
|
-
return {
|
|
34150
|
-
exitCode: result2.exitCode,
|
|
34151
|
-
...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
|
|
34152
|
-
};
|
|
34153
34596
|
}
|
|
34154
34597
|
if (parsed.command === "gleaner-left") {
|
|
34155
|
-
|
|
34156
|
-
|
|
34157
|
-
|
|
34158
|
-
const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
|
|
34159
|
-
const seat = resolveEffectiveSeat(
|
|
34160
|
-
config,
|
|
34161
|
-
"gleaner-left",
|
|
34162
|
-
credentials,
|
|
34163
|
-
invocationFromParsed(parsed)
|
|
34164
|
-
);
|
|
34165
|
-
const result2 = await runPublicGleanerLeft(
|
|
34166
|
-
parsed.args,
|
|
34167
|
-
createRoleEnvironment(env, { role: "gleaner-left", home, agentDir, cwd, credentials, seat, config }),
|
|
34598
|
+
return await dispatchPublicRoleCommand(
|
|
34599
|
+
env,
|
|
34600
|
+
home,
|
|
34168
34601
|
io,
|
|
34169
|
-
|
|
34602
|
+
parsed,
|
|
34603
|
+
"gleaner-left",
|
|
34604
|
+
PUBLIC_ROLE_ARGV["gleaner-left"].parse,
|
|
34605
|
+
(args, roleEnv, once) => runPublicGleanerLeft(args, roleEnv, io, once)
|
|
34170
34606
|
);
|
|
34171
|
-
return {
|
|
34172
|
-
exitCode: result2.exitCode,
|
|
34173
|
-
...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
|
|
34174
|
-
};
|
|
34175
34607
|
}
|
|
34176
34608
|
if (parsed.command === "diarist") {
|
|
34177
|
-
|
|
34178
|
-
|
|
34179
|
-
|
|
34180
|
-
const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
|
|
34181
|
-
const seat = resolveEffectiveSeat(
|
|
34182
|
-
config,
|
|
34183
|
-
"diarist",
|
|
34184
|
-
credentials,
|
|
34185
|
-
invocationFromParsed(parsed)
|
|
34186
|
-
);
|
|
34187
|
-
const result2 = await runPublicDiarist(
|
|
34188
|
-
parsed.args,
|
|
34189
|
-
createRoleEnvironment(env, { role: "diarist", home, agentDir, cwd, credentials, seat, config }),
|
|
34609
|
+
return await dispatchPublicRoleCommand(
|
|
34610
|
+
env,
|
|
34611
|
+
home,
|
|
34190
34612
|
io,
|
|
34191
|
-
|
|
34613
|
+
parsed,
|
|
34614
|
+
"diarist",
|
|
34615
|
+
PUBLIC_ROLE_ARGV.diarist.parse,
|
|
34616
|
+
(args, roleEnv, once) => runPublicDiarist(args, roleEnv, io, once)
|
|
34192
34617
|
);
|
|
34193
|
-
return {
|
|
34194
|
-
exitCode: result2.exitCode,
|
|
34195
|
-
...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
|
|
34196
|
-
};
|
|
34197
34618
|
}
|
|
34198
34619
|
if (parsed.command === "coder") {
|
|
34199
|
-
|
|
34200
|
-
|
|
34201
|
-
|
|
34202
|
-
const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
|
|
34203
|
-
const seat = resolveEffectiveSeat(
|
|
34204
|
-
config,
|
|
34205
|
-
"coder",
|
|
34206
|
-
credentials,
|
|
34207
|
-
invocationFromParsed(parsed)
|
|
34208
|
-
);
|
|
34209
|
-
const result2 = await runPublicCoder(
|
|
34210
|
-
parsed.args,
|
|
34211
|
-
createRoleEnvironment(env, { role: "coder", home, agentDir, cwd, credentials, seat, config }),
|
|
34620
|
+
return await dispatchPublicRoleCommand(
|
|
34621
|
+
env,
|
|
34622
|
+
home,
|
|
34212
34623
|
io,
|
|
34213
|
-
|
|
34624
|
+
parsed,
|
|
34625
|
+
"coder",
|
|
34626
|
+
PUBLIC_ROLE_ARGV.coder.parse,
|
|
34627
|
+
(args, roleEnv, once) => runPublicCoder(args, roleEnv, io, once)
|
|
34214
34628
|
);
|
|
34215
|
-
return {
|
|
34216
|
-
exitCode: result2.exitCode,
|
|
34217
|
-
...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
|
|
34218
|
-
};
|
|
34219
34629
|
}
|
|
34220
34630
|
if (parsed.command === "fixer") {
|
|
34221
|
-
|
|
34222
|
-
|
|
34223
|
-
|
|
34224
|
-
const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
|
|
34225
|
-
const seat = resolveEffectiveSeat(
|
|
34226
|
-
config,
|
|
34227
|
-
"fixer",
|
|
34228
|
-
credentials,
|
|
34229
|
-
invocationFromParsed(parsed)
|
|
34230
|
-
);
|
|
34231
|
-
const result2 = await runPublicFixer(
|
|
34232
|
-
parsed.args,
|
|
34233
|
-
createRoleEnvironment(env, { role: "fixer", home, agentDir, cwd, credentials, seat, config }),
|
|
34631
|
+
return await dispatchPublicRoleCommand(
|
|
34632
|
+
env,
|
|
34633
|
+
home,
|
|
34234
34634
|
io,
|
|
34235
|
-
|
|
34635
|
+
parsed,
|
|
34636
|
+
"fixer",
|
|
34637
|
+
PUBLIC_ROLE_ARGV.fixer.parse,
|
|
34638
|
+
(args, roleEnv, once) => runPublicFixer(args, roleEnv, io, once)
|
|
34236
34639
|
);
|
|
34237
|
-
return {
|
|
34238
|
-
exitCode: result2.exitCode,
|
|
34239
|
-
...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
|
|
34240
|
-
};
|
|
34241
34640
|
}
|
|
34242
34641
|
if (parsed.command === "collector") {
|
|
34243
|
-
|
|
34244
|
-
|
|
34245
|
-
|
|
34246
|
-
const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
|
|
34247
|
-
const seat = resolveEffectiveSeat(
|
|
34248
|
-
config,
|
|
34249
|
-
"collector",
|
|
34250
|
-
credentials,
|
|
34251
|
-
invocationFromParsed(parsed)
|
|
34252
|
-
);
|
|
34253
|
-
const result2 = await runPublicCollector(
|
|
34254
|
-
parsed.args,
|
|
34255
|
-
createRoleEnvironment(env, { role: "collector", home, agentDir, cwd, credentials, seat, config }),
|
|
34642
|
+
return await dispatchPublicRoleCommand(
|
|
34643
|
+
env,
|
|
34644
|
+
home,
|
|
34256
34645
|
io,
|
|
34257
|
-
|
|
34646
|
+
parsed,
|
|
34647
|
+
"collector",
|
|
34648
|
+
PUBLIC_ROLE_ARGV.collector.parse,
|
|
34649
|
+
(args, roleEnv, once) => runPublicCollector(args, roleEnv, io, once)
|
|
34258
34650
|
);
|
|
34259
|
-
return {
|
|
34260
|
-
exitCode: result2.exitCode,
|
|
34261
|
-
...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
|
|
34262
|
-
};
|
|
34263
34651
|
}
|
|
34264
34652
|
if (parsed.command === "reviewer") {
|
|
34265
|
-
|
|
34266
|
-
|
|
34267
|
-
|
|
34268
|
-
const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
|
|
34269
|
-
const seat = resolveEffectiveSeat(
|
|
34270
|
-
config,
|
|
34271
|
-
"reviewer",
|
|
34272
|
-
credentials,
|
|
34273
|
-
invocationFromParsed(parsed)
|
|
34274
|
-
);
|
|
34275
|
-
const result2 = await runPublicReviewer(
|
|
34276
|
-
parsed.args,
|
|
34277
|
-
createRoleEnvironment(env, { role: "reviewer", home, agentDir, cwd, credentials, seat, config }),
|
|
34653
|
+
return await dispatchPublicRoleCommand(
|
|
34654
|
+
env,
|
|
34655
|
+
home,
|
|
34278
34656
|
io,
|
|
34279
|
-
|
|
34657
|
+
parsed,
|
|
34658
|
+
"reviewer",
|
|
34659
|
+
PUBLIC_ROLE_ARGV.reviewer.parse,
|
|
34660
|
+
(args, roleEnv, once) => runPublicReviewer(args, roleEnv, io, once)
|
|
34280
34661
|
);
|
|
34281
|
-
return {
|
|
34282
|
-
exitCode: result2.exitCode,
|
|
34283
|
-
...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
|
|
34284
|
-
};
|
|
34285
34662
|
}
|
|
34286
34663
|
if (parsed.command === "doctor") {
|
|
34287
|
-
|
|
34288
|
-
|
|
34289
|
-
|
|
34290
|
-
const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
|
|
34291
|
-
const seat = resolveEffectiveSeat(
|
|
34292
|
-
config,
|
|
34293
|
-
"doctor",
|
|
34294
|
-
credentials,
|
|
34295
|
-
invocationFromParsed(parsed)
|
|
34296
|
-
);
|
|
34297
|
-
const result2 = await runPublicDoctor(
|
|
34298
|
-
parsed.args,
|
|
34299
|
-
createRoleEnvironment(env, { role: "doctor", home, agentDir, cwd, credentials, seat, config }),
|
|
34664
|
+
return await dispatchPublicRoleCommand(
|
|
34665
|
+
env,
|
|
34666
|
+
home,
|
|
34300
34667
|
io,
|
|
34301
|
-
|
|
34668
|
+
parsed,
|
|
34669
|
+
"doctor",
|
|
34670
|
+
PUBLIC_ROLE_ARGV.doctor.parse,
|
|
34671
|
+
(args, roleEnv, once) => runPublicDoctor(args, roleEnv, io, once)
|
|
34302
34672
|
);
|
|
34303
|
-
return {
|
|
34304
|
-
exitCode: result2.exitCode,
|
|
34305
|
-
...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
|
|
34306
|
-
};
|
|
34307
34673
|
}
|
|
34308
34674
|
if (parsed.command === "notary") {
|
|
34309
|
-
|
|
34310
|
-
|
|
34311
|
-
|
|
34312
|
-
const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
|
|
34313
|
-
const seat = resolveEffectiveSeat(
|
|
34314
|
-
config,
|
|
34315
|
-
"notary",
|
|
34316
|
-
credentials,
|
|
34317
|
-
invocationFromParsed(parsed)
|
|
34318
|
-
);
|
|
34319
|
-
const result2 = await runPublicNotary(
|
|
34320
|
-
parsed.args,
|
|
34321
|
-
createRoleEnvironment(env, { role: "notary", home, agentDir, cwd, credentials, seat, config }),
|
|
34675
|
+
return await dispatchPublicRoleCommand(
|
|
34676
|
+
env,
|
|
34677
|
+
home,
|
|
34322
34678
|
io,
|
|
34323
|
-
|
|
34679
|
+
parsed,
|
|
34680
|
+
"notary",
|
|
34681
|
+
PUBLIC_ROLE_ARGV.notary.parse,
|
|
34682
|
+
(args, roleEnv, once) => runPublicNotary(args, roleEnv, io, once)
|
|
34324
34683
|
);
|
|
34325
|
-
return {
|
|
34326
|
-
exitCode: result2.exitCode,
|
|
34327
|
-
...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
|
|
34328
|
-
};
|
|
34329
34684
|
}
|
|
34330
34685
|
if (parsed.command === "inspector") {
|
|
34331
|
-
|
|
34332
|
-
|
|
34333
|
-
|
|
34334
|
-
const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
|
|
34335
|
-
const seat = resolveEffectiveSeat(
|
|
34336
|
-
config,
|
|
34337
|
-
"inspector",
|
|
34338
|
-
credentials,
|
|
34339
|
-
invocationFromParsed(parsed)
|
|
34340
|
-
);
|
|
34341
|
-
const result2 = await runPublicInspector(
|
|
34342
|
-
parsed.args,
|
|
34343
|
-
createRoleEnvironment(env, { role: "inspector", home, agentDir, cwd, credentials, seat, config }),
|
|
34686
|
+
return await dispatchPublicRoleCommand(
|
|
34687
|
+
env,
|
|
34688
|
+
home,
|
|
34344
34689
|
io,
|
|
34345
|
-
|
|
34690
|
+
parsed,
|
|
34691
|
+
"inspector",
|
|
34692
|
+
PUBLIC_ROLE_ARGV.inspector.parse,
|
|
34693
|
+
(args, roleEnv, once) => runPublicInspector(args, roleEnv, io, once)
|
|
34346
34694
|
);
|
|
34347
|
-
return {
|
|
34348
|
-
exitCode: result2.exitCode,
|
|
34349
|
-
...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
|
|
34350
|
-
};
|
|
34351
34695
|
}
|
|
34352
34696
|
if (parsed.command === "merger") {
|
|
34353
|
-
|
|
34354
|
-
|
|
34355
|
-
|
|
34356
|
-
const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
|
|
34357
|
-
const seat = resolveEffectiveSeat(
|
|
34358
|
-
config,
|
|
34359
|
-
"merger",
|
|
34360
|
-
credentials,
|
|
34361
|
-
invocationFromParsed(parsed)
|
|
34362
|
-
);
|
|
34363
|
-
const result2 = await runPublicMerger(
|
|
34364
|
-
parsed.args,
|
|
34365
|
-
createRoleEnvironment(env, { role: "merger", home, agentDir, cwd, credentials, seat, config }),
|
|
34697
|
+
return await dispatchPublicRoleCommand(
|
|
34698
|
+
env,
|
|
34699
|
+
home,
|
|
34366
34700
|
io,
|
|
34367
|
-
|
|
34701
|
+
parsed,
|
|
34702
|
+
"merger",
|
|
34703
|
+
PUBLIC_ROLE_ARGV.merger.parse,
|
|
34704
|
+
(args, roleEnv, once) => runPublicMerger(args, roleEnv, io, once)
|
|
34368
34705
|
);
|
|
34369
|
-
return {
|
|
34370
|
-
exitCode: result2.exitCode,
|
|
34371
|
-
...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
|
|
34372
|
-
};
|
|
34373
34706
|
}
|
|
34374
34707
|
if (parsed.command === "gatekeeper" || parsed.command === "navigator" || parsed.command === "auditor") {
|
|
34375
|
-
const
|
|
34376
|
-
|
|
34377
|
-
|
|
34378
|
-
|
|
34379
|
-
const seat = resolveEffectiveSeat(
|
|
34380
|
-
config,
|
|
34381
|
-
parsed.command,
|
|
34382
|
-
credentials,
|
|
34383
|
-
invocationFromParsed(parsed)
|
|
34384
|
-
);
|
|
34385
|
-
const result2 = await runPublicInstructionSeat(
|
|
34386
|
-
parsed.args,
|
|
34387
|
-
createRoleEnvironment(env, { role: parsed.command, home, agentDir, cwd, credentials, seat, config }),
|
|
34708
|
+
const seat = parsed.command;
|
|
34709
|
+
return await dispatchPublicRoleCommand(
|
|
34710
|
+
env,
|
|
34711
|
+
home,
|
|
34388
34712
|
io,
|
|
34389
|
-
parsed
|
|
34390
|
-
|
|
34713
|
+
parsed,
|
|
34714
|
+
seat,
|
|
34715
|
+
PUBLIC_ROLE_ARGV[seat].parse,
|
|
34716
|
+
(args, roleEnv, once) => runPublicInstructionSeat(args, roleEnv, io, seat, once)
|
|
34391
34717
|
);
|
|
34392
|
-
return {
|
|
34393
|
-
exitCode: result2.exitCode,
|
|
34394
|
-
...result2.terminal === void 0 ? {} : { terminal: result2.terminal }
|
|
34395
|
-
};
|
|
34396
34718
|
}
|
|
34397
34719
|
if (parsed.command === "analyst") {
|
|
34398
34720
|
const result2 = await runPublicAnalyst(
|
|
@@ -34506,7 +34828,7 @@ var init_cli = __esm({
|
|
|
34506
34828
|
|
|
34507
34829
|
// src/public-cli/main.ts
|
|
34508
34830
|
import { existsSync as existsSync11 } from "node:fs";
|
|
34509
|
-
import { dirname as
|
|
34831
|
+
import { dirname as dirname19, join as join37 } from "node:path";
|
|
34510
34832
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
34511
34833
|
|
|
34512
34834
|
// src/public-cli/host-pi-runtime.ts
|
|
@@ -34593,10 +34915,10 @@ function linkPackage(packageRoot2, name, targetDir) {
|
|
|
34593
34915
|
}
|
|
34594
34916
|
|
|
34595
34917
|
// src/public-cli/main.ts
|
|
34596
|
-
var here =
|
|
34918
|
+
var here = dirname19(fileURLToPath2(import.meta.url));
|
|
34597
34919
|
function resolvePackageRoot(binDir) {
|
|
34598
|
-
const canonical =
|
|
34599
|
-
if (existsSync11(
|
|
34920
|
+
const canonical = join37(binDir, "..", "..");
|
|
34921
|
+
if (existsSync11(join37(canonical, "package.json"))) {
|
|
34600
34922
|
return canonical;
|
|
34601
34923
|
}
|
|
34602
34924
|
return binDir;
|