@akagilnc/pi-workflow-roles 0.1.5216 → 0.1.5241
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/CLAUDE.md +3 -0
- package/README.md +1 -1
- package/dist/acp-host/production-host.js +658 -829
- package/dist/engine-detour-usage.js +4 -16
- package/dist/headless-host/production-host.js +777 -862
- package/dist/host-session-record.js +303 -0
- package/dist/pi/role-turn-host.js +1 -21
- package/dist/public-cli/main.js +200 -487
- package/dist/public-cli/post-admission.js +11 -60
- package/dist/sitian-appender.js +10 -155
- package/package.json +1 -1
- package/src/acp-host/role-turn-host.ts +36 -108
- package/src/engine-detour-usage.ts +4 -16
- package/src/external-host-turn-loop.ts +2 -18
- package/src/headless-host/role-turn-host.ts +67 -31
- package/src/host-contracts.ts +0 -15
- package/src/host-session-record.ts +325 -25
- package/src/notary-role.ts +0 -1
- package/src/pi/role-turn-host.ts +1 -25
- package/src/public-cli/countersign-run.ts +4 -3
- package/src/public-cli/post-admission.ts +10 -69
- package/src/public-role-summons.ts +1 -2
- package/src/role-envelope.ts +2 -2
- package/src/role-runtime.ts +0 -14
- package/src/sitian-appender.ts +16 -205
- package/dist/host-transition-prior-native.js +0 -78
- package/dist/public-cli/case-dossier-delivery.js +0 -109
- package/src/host-transition-prior-native.ts +0 -80
- package/src/pi/pi-normalization.ts +0 -291
- package/src/public-cli/case-dossier-delivery.ts +0 -147
|
@@ -4224,57 +4224,15 @@ var init_sitian_contracts = __esm({
|
|
|
4224
4224
|
});
|
|
4225
4225
|
|
|
4226
4226
|
// src/sitian-appender.ts
|
|
4227
|
-
import {
|
|
4228
|
-
import {
|
|
4229
|
-
appendFileSync,
|
|
4230
|
-
existsSync,
|
|
4231
|
-
readFileSync,
|
|
4232
|
-
unlinkSync,
|
|
4233
|
-
writeFileSync
|
|
4234
|
-
} from "node:fs";
|
|
4227
|
+
import { randomUUID } from "node:crypto";
|
|
4228
|
+
import { appendFileSync } from "node:fs";
|
|
4235
4229
|
import { dirname as dirname3, join as join4 } from "node:path";
|
|
4236
|
-
function isRecord3(value) {
|
|
4237
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4238
|
-
}
|
|
4239
|
-
function errorCodeOf(error) {
|
|
4240
|
-
return error.code;
|
|
4241
|
-
}
|
|
4242
|
-
function identityClaimPath(recordFile, identity) {
|
|
4243
|
-
const digest = createHash4("sha256").update(identity, "utf8").digest("hex");
|
|
4244
|
-
return `${recordFile}.id-${digest}`;
|
|
4245
|
-
}
|
|
4246
|
-
function createExclusiveFile(path, contents) {
|
|
4247
|
-
writeFileSync(path, contents, { encoding: "utf8", flag: "wx" });
|
|
4248
|
-
}
|
|
4249
|
-
function sealTornTail(recordFile) {
|
|
4250
|
-
if (!existsSync(recordFile)) return;
|
|
4251
|
-
const buffer = readFileSync(recordFile);
|
|
4252
|
-
if (buffer.length > 0 && buffer[buffer.length - 1] !== 10) {
|
|
4253
|
-
appendFileSync(recordFile, "\n", "utf8");
|
|
4254
|
-
}
|
|
4255
|
-
}
|
|
4256
4230
|
function appendSitianRecordBlock(input, block) {
|
|
4257
4231
|
if (block === "") return;
|
|
4258
4232
|
try {
|
|
4259
4233
|
const { sessionDir, recordFile, ledgerHome } = resolveSitianRecordPath(input);
|
|
4260
4234
|
ensureRealDirectoryTree(ledgerHome, sessionDir);
|
|
4261
|
-
appendFileSync(recordFile,
|
|
4262
|
-
sealTornTail(recordFile);
|
|
4263
|
-
const identityOf = (line2) => {
|
|
4264
|
-
try {
|
|
4265
|
-
const row = JSON.parse(line2);
|
|
4266
|
-
return isRecord3(row) && typeof row.identity === "string" ? row.identity : void 0;
|
|
4267
|
-
} catch {
|
|
4268
|
-
return void 0;
|
|
4269
|
-
}
|
|
4270
|
-
};
|
|
4271
|
-
const identities = new Set(readFileSync(recordFile, "utf8").split("\n").map(identityOf).filter((id) => id !== void 0));
|
|
4272
|
-
for (const line2 of block.match(/[^\n]*\n|[^\n]+$/g) ?? []) {
|
|
4273
|
-
const identity = identityOf(line2);
|
|
4274
|
-
if (identity !== void 0 && identities.has(identity)) continue;
|
|
4275
|
-
appendFileSync(recordFile, line2, "utf8");
|
|
4276
|
-
if (identity !== void 0) identities.add(identity);
|
|
4277
|
-
}
|
|
4235
|
+
appendFileSync(recordFile, block, "utf8");
|
|
4278
4236
|
} catch (error) {
|
|
4279
4237
|
if (error instanceof SitianInfrastructureError) throw error;
|
|
4280
4238
|
throw new SitianInfrastructureError(
|
|
@@ -4283,106 +4241,6 @@ function appendSitianRecordBlock(input, block) {
|
|
|
4283
4241
|
);
|
|
4284
4242
|
}
|
|
4285
4243
|
}
|
|
4286
|
-
function findIdentityPointer(recordFile, identity, kind, level) {
|
|
4287
|
-
if (!existsSync(recordFile)) return void 0;
|
|
4288
|
-
const text = readFileSync(recordFile, "utf8");
|
|
4289
|
-
for (const line2 of text.split("\n")) {
|
|
4290
|
-
const trimmed = line2.trim();
|
|
4291
|
-
if (!trimmed) continue;
|
|
4292
|
-
try {
|
|
4293
|
-
const parsed = JSON.parse(trimmed);
|
|
4294
|
-
if (isRecord3(parsed) && parsed.identity === identity) {
|
|
4295
|
-
return { identity, recordFile, kind, level };
|
|
4296
|
-
}
|
|
4297
|
-
} catch {
|
|
4298
|
-
}
|
|
4299
|
-
}
|
|
4300
|
-
return void 0;
|
|
4301
|
-
}
|
|
4302
|
-
function unlinkAbsentOk(path) {
|
|
4303
|
-
try {
|
|
4304
|
-
unlinkSync(path);
|
|
4305
|
-
return void 0;
|
|
4306
|
-
} catch (error) {
|
|
4307
|
-
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
4308
|
-
return error instanceof Error ? error : new Error(errorText(error));
|
|
4309
|
-
}
|
|
4310
|
-
}
|
|
4311
|
-
function appendWithIdentityClaim(recordFile, record4, row) {
|
|
4312
|
-
sealTornTail(recordFile);
|
|
4313
|
-
const claimPath = identityClaimPath(recordFile, record4.identity);
|
|
4314
|
-
const existing = findIdentityPointer(
|
|
4315
|
-
recordFile,
|
|
4316
|
-
record4.identity,
|
|
4317
|
-
record4.kind,
|
|
4318
|
-
record4.level
|
|
4319
|
-
);
|
|
4320
|
-
if (existing !== void 0) {
|
|
4321
|
-
unlinkAbsentOk(claimPath);
|
|
4322
|
-
return existing;
|
|
4323
|
-
}
|
|
4324
|
-
try {
|
|
4325
|
-
createExclusiveFile(claimPath, "");
|
|
4326
|
-
} catch (error) {
|
|
4327
|
-
if (errorCodeOf(error) !== "EEXIST") throw error;
|
|
4328
|
-
sealTornTail(recordFile);
|
|
4329
|
-
const published = findIdentityPointer(
|
|
4330
|
-
recordFile,
|
|
4331
|
-
record4.identity,
|
|
4332
|
-
record4.kind,
|
|
4333
|
-
record4.level
|
|
4334
|
-
);
|
|
4335
|
-
if (published !== void 0) {
|
|
4336
|
-
unlinkAbsentOk(claimPath);
|
|
4337
|
-
return published;
|
|
4338
|
-
}
|
|
4339
|
-
throw new SitianInfrastructureError(
|
|
4340
|
-
`Sitian identity claim at ${claimPath} already exists for identity ${record4.identity}`,
|
|
4341
|
-
{ cause: error }
|
|
4342
|
-
);
|
|
4343
|
-
}
|
|
4344
|
-
let primaryFailure;
|
|
4345
|
-
let result;
|
|
4346
|
-
let cleanupFailure;
|
|
4347
|
-
try {
|
|
4348
|
-
sealTornTail(recordFile);
|
|
4349
|
-
const raced = findIdentityPointer(
|
|
4350
|
-
recordFile,
|
|
4351
|
-
record4.identity,
|
|
4352
|
-
record4.kind,
|
|
4353
|
-
record4.level
|
|
4354
|
-
);
|
|
4355
|
-
if (raced !== void 0) {
|
|
4356
|
-
result = raced;
|
|
4357
|
-
} else {
|
|
4358
|
-
appendFileSync(recordFile, row, "utf8");
|
|
4359
|
-
result = {
|
|
4360
|
-
identity: record4.identity,
|
|
4361
|
-
recordFile,
|
|
4362
|
-
kind: record4.kind,
|
|
4363
|
-
level: record4.level
|
|
4364
|
-
};
|
|
4365
|
-
}
|
|
4366
|
-
} catch (error) {
|
|
4367
|
-
primaryFailure = error;
|
|
4368
|
-
} finally {
|
|
4369
|
-
cleanupFailure = unlinkAbsentOk(claimPath);
|
|
4370
|
-
}
|
|
4371
|
-
if (primaryFailure !== void 0) {
|
|
4372
|
-
if (primaryFailure instanceof SitianInfrastructureError) throw primaryFailure;
|
|
4373
|
-
throw new SitianInfrastructureError(
|
|
4374
|
-
`Sitian appender persistence failure: ${errorText(primaryFailure)}`,
|
|
4375
|
-
{ cause: primaryFailure }
|
|
4376
|
-
);
|
|
4377
|
-
}
|
|
4378
|
-
if (cleanupFailure !== void 0) {
|
|
4379
|
-
throw new SitianInfrastructureError(
|
|
4380
|
-
`Sitian identity claim at ${claimPath} could not be released after append for identity ${record4.identity}: ${errorText(cleanupFailure)}`,
|
|
4381
|
-
{ cause: cleanupFailure }
|
|
4382
|
-
);
|
|
4383
|
-
}
|
|
4384
|
-
return result;
|
|
4385
|
-
}
|
|
4386
4244
|
function resolveSitianVolumeCategory(kind) {
|
|
4387
4245
|
if (S4_SUBMISSION_LEDGER_KINDS.has(kind)) {
|
|
4388
4246
|
return "submission-ledger";
|
|
@@ -4421,14 +4279,6 @@ function resolveSitianRecordPathInLedger(input, ledgerHome) {
|
|
|
4421
4279
|
}
|
|
4422
4280
|
return { sessionDir, recordFile, ledgerHome };
|
|
4423
4281
|
}
|
|
4424
|
-
function projectTicketRecordsPathShape() {
|
|
4425
|
-
const { recordFile } = ticketProvenanceUnderBookPaths(
|
|
4426
|
-
join4("~", ".ak-roles"),
|
|
4427
|
-
"<\u7C3F>",
|
|
4428
|
-
"<\u7968\u53F7>"
|
|
4429
|
-
);
|
|
4430
|
-
return recordFile.replace(/\\/g, "/");
|
|
4431
|
-
}
|
|
4432
4282
|
function resolveSitianRecordPath(input) {
|
|
4433
4283
|
const ledgerHome = input.home !== void 0 && input.home.length > 0 ? resolveActivationLedgerHome(input.home) : resolveActivationLedgerHomeForPath(input.runDirectory ?? input.sessionParent);
|
|
4434
4284
|
return resolveSitianRecordPathInLedger(input, ledgerHome);
|
|
@@ -4455,7 +4305,13 @@ function appendSitianRecord(input) {
|
|
|
4455
4305
|
};
|
|
4456
4306
|
const row = `${JSON.stringify(record4)}
|
|
4457
4307
|
`;
|
|
4458
|
-
|
|
4308
|
+
appendFileSync(recordFile, row, "utf8");
|
|
4309
|
+
return {
|
|
4310
|
+
identity: record4.identity,
|
|
4311
|
+
recordFile,
|
|
4312
|
+
kind: record4.kind,
|
|
4313
|
+
level: record4.level
|
|
4314
|
+
};
|
|
4459
4315
|
} catch (error) {
|
|
4460
4316
|
if (error instanceof SitianInfrastructureError) throw error;
|
|
4461
4317
|
throw new SitianInfrastructureError(
|
|
@@ -4483,13 +4339,13 @@ var init_sitian_appender = __esm({
|
|
|
4483
4339
|
});
|
|
4484
4340
|
|
|
4485
4341
|
// src/sitian-reader.ts
|
|
4486
|
-
import { existsSync
|
|
4342
|
+
import { existsSync } from "node:fs";
|
|
4487
4343
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
4488
|
-
function
|
|
4344
|
+
function isRecord3(value) {
|
|
4489
4345
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4490
4346
|
}
|
|
4491
4347
|
async function readSitianRecords(recordFile) {
|
|
4492
|
-
if (!
|
|
4348
|
+
if (!existsSync(recordFile)) {
|
|
4493
4349
|
return { records: [], diagnostics: [] };
|
|
4494
4350
|
}
|
|
4495
4351
|
const text = await readFile3(recordFile, "utf8");
|
|
@@ -4501,7 +4357,7 @@ async function readSitianRecords(recordFile) {
|
|
|
4501
4357
|
if (!line2.trim()) continue;
|
|
4502
4358
|
try {
|
|
4503
4359
|
const parsed = JSON.parse(line2);
|
|
4504
|
-
if (
|
|
4360
|
+
if (isRecord3(parsed)) {
|
|
4505
4361
|
records.push(parsed);
|
|
4506
4362
|
} else {
|
|
4507
4363
|
const typeDesc = parsed === null ? "null" : Array.isArray(parsed) ? "array" : typeof parsed;
|
|
@@ -4642,14 +4498,14 @@ function isMissingPathError2(error) {
|
|
|
4642
4498
|
function errorText2(error) {
|
|
4643
4499
|
return error instanceof Error ? error.message : String(error);
|
|
4644
4500
|
}
|
|
4645
|
-
function
|
|
4501
|
+
function isRecord4(value) {
|
|
4646
4502
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4647
4503
|
}
|
|
4648
4504
|
function readUsableTerminalArtifactBody(body) {
|
|
4649
4505
|
if (body === null) {
|
|
4650
4506
|
return { ok: false, reason: "terminal artifact JSON value is null" };
|
|
4651
4507
|
}
|
|
4652
|
-
if (!
|
|
4508
|
+
if (!isRecord4(body)) {
|
|
4653
4509
|
return {
|
|
4654
4510
|
ok: false,
|
|
4655
4511
|
reason: `terminal artifact JSON value is not a typed object (${Array.isArray(body) ? "array" : typeof body})`
|
|
@@ -5247,10 +5103,10 @@ __export(session_assistant_usage_exports, {
|
|
|
5247
5103
|
});
|
|
5248
5104
|
import { join as join9 } from "node:path";
|
|
5249
5105
|
async function readAssistantUsageFromSessionFile(sessionFile) {
|
|
5250
|
-
const { readFile:
|
|
5106
|
+
const { readFile: readFile26 } = await import("node:fs/promises");
|
|
5251
5107
|
let text;
|
|
5252
5108
|
try {
|
|
5253
|
-
text = await
|
|
5109
|
+
text = await readFile26(sessionFile, "utf8");
|
|
5254
5110
|
} catch (error) {
|
|
5255
5111
|
if (error?.code === "ENOENT") return void 0;
|
|
5256
5112
|
throw error;
|
|
@@ -5340,7 +5196,7 @@ var init_session_assistant_usage = __esm({
|
|
|
5340
5196
|
});
|
|
5341
5197
|
|
|
5342
5198
|
// src/package-resources/engine-material.ts
|
|
5343
|
-
import { existsSync as
|
|
5199
|
+
import { existsSync as existsSync2, readdirSync } from "node:fs";
|
|
5344
5200
|
import { join as join10 } from "node:path";
|
|
5345
5201
|
function pickEngineAxis(source) {
|
|
5346
5202
|
return {
|
|
@@ -5383,7 +5239,7 @@ function engineSessionMaterialFromOptions(options) {
|
|
|
5383
5239
|
const model = options.engineModel === void 0 ? void 0 : assertLegalEngineModel(options.engineModel);
|
|
5384
5240
|
const materialPath = resolveEngineMaterialPath(options.packageRoot, name);
|
|
5385
5241
|
const modelField = model === void 0 ? {} : { model };
|
|
5386
|
-
if (
|
|
5242
|
+
if (existsSync2(materialPath)) {
|
|
5387
5243
|
return Object.freeze({ name, materialPath, ...modelField });
|
|
5388
5244
|
}
|
|
5389
5245
|
return Object.freeze({ name, ...modelField });
|
|
@@ -5750,19 +5606,7 @@ function createPiRoleTurnHost(config) {
|
|
|
5750
5606
|
});
|
|
5751
5607
|
return {
|
|
5752
5608
|
async executeTurn(request) {
|
|
5753
|
-
|
|
5754
|
-
const officerStationChild = request.stationChild === true && isOfficerReviewSeat(request.activation.role);
|
|
5755
|
-
const paths = !officerStationChild && request.hostTransition?.priorNativeKind === "sitian" ? request.hostTransition.priorNativePaths : void 0;
|
|
5756
|
-
if (request.continuation.kind === "resume" && paths !== void 0 && paths.length > 0) {
|
|
5757
|
-
turnRequest = {
|
|
5758
|
-
...request,
|
|
5759
|
-
continuation: {
|
|
5760
|
-
...request.continuation,
|
|
5761
|
-
prompt: `${request.continuation.prompt}
|
|
5762
|
-
${paths.join("\n")}`
|
|
5763
|
-
}
|
|
5764
|
-
};
|
|
5765
|
-
}
|
|
5609
|
+
const turnRequest = request;
|
|
5766
5610
|
const roleEntry = await realpath(resolveInternalRoleEntrypoint(config.packageRoot));
|
|
5767
5611
|
const extraArgs = buildPiTurnExtraArgs(
|
|
5768
5612
|
turnRequest,
|
|
@@ -5842,7 +5686,6 @@ var init_role_turn_host = __esm({
|
|
|
5842
5686
|
"src/pi/role-turn-host.ts"() {
|
|
5843
5687
|
"use strict";
|
|
5844
5688
|
init_host_contracts();
|
|
5845
|
-
init_packaged_role_registry();
|
|
5846
5689
|
init_engine_detour();
|
|
5847
5690
|
init_role_activation_flags();
|
|
5848
5691
|
init_user_dialogue_stdin();
|
|
@@ -5962,9 +5805,9 @@ var init_host_descriptions = __esm({
|
|
|
5962
5805
|
});
|
|
5963
5806
|
|
|
5964
5807
|
// src/sha256.ts
|
|
5965
|
-
import { createHash as
|
|
5808
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
5966
5809
|
function sha256Hex(bytes) {
|
|
5967
|
-
return
|
|
5810
|
+
return createHash4("sha256").update(bytes).digest("hex");
|
|
5968
5811
|
}
|
|
5969
5812
|
var init_sha256 = __esm({
|
|
5970
5813
|
"src/sha256.ts"() {
|
|
@@ -6464,7 +6307,7 @@ var init_merger_git_state = __esm({
|
|
|
6464
6307
|
|
|
6465
6308
|
// src/ledger-session-read.ts
|
|
6466
6309
|
import { readFile as readFile9 } from "node:fs/promises";
|
|
6467
|
-
function
|
|
6310
|
+
function isRecord5(value) {
|
|
6468
6311
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6469
6312
|
}
|
|
6470
6313
|
async function readLedgerSessionJsonlLines(path) {
|
|
@@ -6489,7 +6332,7 @@ async function readLedgerSessionJsonlLines(path) {
|
|
|
6489
6332
|
});
|
|
6490
6333
|
continue;
|
|
6491
6334
|
}
|
|
6492
|
-
if (!
|
|
6335
|
+
if (!isRecord5(row)) {
|
|
6493
6336
|
const kind = row === null ? "null" : Array.isArray(row) ? "array" : typeof row;
|
|
6494
6337
|
out.push({
|
|
6495
6338
|
line: lineNumber,
|
|
@@ -6542,7 +6385,7 @@ function extractSessionModelSequence(rows) {
|
|
|
6542
6385
|
if (row.type === "model_change" && typeof row.modelId === "string") {
|
|
6543
6386
|
push(row.modelId);
|
|
6544
6387
|
}
|
|
6545
|
-
const message =
|
|
6388
|
+
const message = isRecord5(row.message) ? row.message : void 0;
|
|
6546
6389
|
if (message?.role === "assistant" && typeof message.model === "string") {
|
|
6547
6390
|
push(message.model);
|
|
6548
6391
|
}
|
|
@@ -6558,11 +6401,11 @@ function extractSessionToolIntervals(rows) {
|
|
|
6558
6401
|
const openById = /* @__PURE__ */ new Map();
|
|
6559
6402
|
for (const row of rows) {
|
|
6560
6403
|
const rowTimestamp = typeof row.timestamp === "string" ? row.timestamp : void 0;
|
|
6561
|
-
const message =
|
|
6404
|
+
const message = isRecord5(row.message) ? row.message : void 0;
|
|
6562
6405
|
if (message?.role === "assistant" && Array.isArray(message.content)) {
|
|
6563
6406
|
const callTimestamp = typeof message.timestamp === "string" && message.timestamp ? message.timestamp : rowTimestamp;
|
|
6564
6407
|
for (const part of message.content) {
|
|
6565
|
-
if (!
|
|
6408
|
+
if (!isRecord5(part) || part.type !== "toolCall") continue;
|
|
6566
6409
|
if (typeof part.id !== "string" || part.id.length === 0) {
|
|
6567
6410
|
throw new Error("toolCall frame missing string id");
|
|
6568
6411
|
}
|
|
@@ -6575,7 +6418,7 @@ function extractSessionToolIntervals(rows) {
|
|
|
6575
6418
|
if (openById.has(part.id)) {
|
|
6576
6419
|
throw new Error(`duplicate toolCall id ${part.id}`);
|
|
6577
6420
|
}
|
|
6578
|
-
const args =
|
|
6421
|
+
const args = isRecord5(part.arguments) ? part.arguments : void 0;
|
|
6579
6422
|
const command = part.name === "bash" && args !== void 0 && typeof args.command === "string" ? bashCommandFirstLine(args.command) : void 0;
|
|
6580
6423
|
const interval = {
|
|
6581
6424
|
toolCallId: part.id,
|
|
@@ -6659,7 +6502,7 @@ var init_ledger_session_read = __esm({
|
|
|
6659
6502
|
});
|
|
6660
6503
|
|
|
6661
6504
|
// src/session-dialogue.ts
|
|
6662
|
-
function
|
|
6505
|
+
function isRecord6(value) {
|
|
6663
6506
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6664
6507
|
}
|
|
6665
6508
|
function nativeEventId(row) {
|
|
@@ -6669,7 +6512,7 @@ function nativeEventId(row) {
|
|
|
6669
6512
|
}
|
|
6670
6513
|
for (const nestKey of ["message", "payload"]) {
|
|
6671
6514
|
const nested = row[nestKey];
|
|
6672
|
-
if (!
|
|
6515
|
+
if (!isRecord6(nested)) continue;
|
|
6673
6516
|
for (const key of ["uuid", "id"]) {
|
|
6674
6517
|
const value = nested[key];
|
|
6675
6518
|
if (typeof value === "string" && value !== "") return value;
|
|
@@ -6682,19 +6525,19 @@ function textParts(content) {
|
|
|
6682
6525
|
if (!Array.isArray(content)) return [];
|
|
6683
6526
|
const out = [];
|
|
6684
6527
|
for (const part of content) {
|
|
6685
|
-
if (!
|
|
6528
|
+
if (!isRecord6(part) || !SPEAKER_TEXT_PART_TYPES.has(String(part.type))) continue;
|
|
6686
6529
|
const text = part.text;
|
|
6687
6530
|
if (typeof text === "string" && text !== "") out.push(text);
|
|
6688
6531
|
}
|
|
6689
6532
|
return out;
|
|
6690
6533
|
}
|
|
6691
6534
|
function responseItemMessage(row) {
|
|
6692
|
-
if (row.type !== "response_item" || !
|
|
6535
|
+
if (row.type !== "response_item" || !isRecord6(row.payload)) return void 0;
|
|
6693
6536
|
if (row.payload.type !== "message") return void 0;
|
|
6694
6537
|
return row.payload;
|
|
6695
6538
|
}
|
|
6696
6539
|
function messageBody(row) {
|
|
6697
|
-
if (
|
|
6540
|
+
if (isRecord6(row.message)) return row.message;
|
|
6698
6541
|
return responseItemMessage(row);
|
|
6699
6542
|
}
|
|
6700
6543
|
function speakerOf(message) {
|
|
@@ -6704,7 +6547,7 @@ function speakerOf(message) {
|
|
|
6704
6547
|
}
|
|
6705
6548
|
function codexContentItemKinds(message) {
|
|
6706
6549
|
const pass = message.internal_chat_message_metadata_passthrough;
|
|
6707
|
-
if (!
|
|
6550
|
+
if (!isRecord6(pass) || !Array.isArray(pass.content_item_kinds)) return void 0;
|
|
6708
6551
|
const kinds = [];
|
|
6709
6552
|
for (const kind of pass.content_item_kinds) {
|
|
6710
6553
|
if (typeof kind === "string" && kind !== "") kinds.push(kind);
|
|
@@ -6733,7 +6576,7 @@ function isFixedNonOwnerEnqueueShape(content) {
|
|
|
6733
6576
|
return hasFixedOpenTagPrefix(content, TASK_NOTIFICATION_OPEN_TAG);
|
|
6734
6577
|
}
|
|
6735
6578
|
function materializationOriginKind(row) {
|
|
6736
|
-
if (!
|
|
6579
|
+
if (!isRecord6(row.origin)) return void 0;
|
|
6737
6580
|
const kind = row.origin.kind;
|
|
6738
6581
|
return typeof kind === "string" && kind !== "" ? kind : void 0;
|
|
6739
6582
|
}
|
|
@@ -6824,12 +6667,6 @@ function ticketProvenanceRecordInput(ticketNumber, cwd, home, runDirectory) {
|
|
|
6824
6667
|
...home === void 0 ? {} : { home }
|
|
6825
6668
|
};
|
|
6826
6669
|
}
|
|
6827
|
-
function resolveTicketProvenanceVolume(ticketNumber, cwd, home) {
|
|
6828
|
-
const path = resolveSitianRecordPath(
|
|
6829
|
-
ticketProvenanceRecordInput(ticketNumber, cwd, home)
|
|
6830
|
-
);
|
|
6831
|
-
return { recordFile: path.recordFile, volumeDir: path.sessionDir };
|
|
6832
|
-
}
|
|
6833
6670
|
async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, home) {
|
|
6834
6671
|
const source = join13(runDirectory, "records.jsonl");
|
|
6835
6672
|
let content;
|
|
@@ -8326,7 +8163,7 @@ var init_option_definitions = __esm({
|
|
|
8326
8163
|
|
|
8327
8164
|
// src/public-cli/invocation.ts
|
|
8328
8165
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
8329
|
-
import { existsSync as
|
|
8166
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
8330
8167
|
import {
|
|
8331
8168
|
lstat as lstat3,
|
|
8332
8169
|
mkdtemp as mkdtemp2,
|
|
@@ -8552,7 +8389,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
8552
8389
|
for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
|
|
8553
8390
|
if (typeof childRunId !== "string") continue;
|
|
8554
8391
|
const childDirectory = join15(dirname10(oldRunDirectory), `${childRunId}@diarist`);
|
|
8555
|
-
if (!
|
|
8392
|
+
if (!existsSync3(childDirectory)) continue;
|
|
8556
8393
|
const childTarget = roleRunPlacement(ledgerHome, {
|
|
8557
8394
|
bookKey: admitted.bookKey,
|
|
8558
8395
|
subject: { ticketNumber: admitted.ticketNumber },
|
|
@@ -10034,7 +9871,7 @@ var init_invocation = __esm({
|
|
|
10034
9871
|
});
|
|
10035
9872
|
|
|
10036
9873
|
// src/public-cli/load-production-acp-host.ts
|
|
10037
|
-
import { existsSync as
|
|
9874
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
10038
9875
|
import { join as join16 } from "node:path";
|
|
10039
9876
|
import { pathToFileURL } from "node:url";
|
|
10040
9877
|
async function loadProductionAcpHostFactory(packageRoot, host) {
|
|
@@ -10044,7 +9881,7 @@ async function loadProductionAcpHostFactory(packageRoot, host) {
|
|
|
10044
9881
|
}
|
|
10045
9882
|
const built = join16(packageRoot, "dist/acp-host/production-host.js");
|
|
10046
9883
|
const source = join16(packageRoot, "src/acp-host/production-host.ts");
|
|
10047
|
-
const target =
|
|
9884
|
+
const target = existsSync4(built) ? built : source;
|
|
10048
9885
|
const href = pathToFileURL(target).href;
|
|
10049
9886
|
const mod = await import(href);
|
|
10050
9887
|
const create = mod.createProductionAcpRoleTurnHost;
|
|
@@ -10058,7 +9895,7 @@ var init_load_production_acp_host = __esm({
|
|
|
10058
9895
|
});
|
|
10059
9896
|
|
|
10060
9897
|
// src/public-cli/load-production-headless-host.ts
|
|
10061
|
-
import { existsSync as
|
|
9898
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
10062
9899
|
import { join as join17 } from "node:path";
|
|
10063
9900
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
10064
9901
|
async function loadProductionHeadlessHostFactory(packageRoot, host) {
|
|
@@ -10068,7 +9905,7 @@ async function loadProductionHeadlessHostFactory(packageRoot, host) {
|
|
|
10068
9905
|
}
|
|
10069
9906
|
const built = join17(packageRoot, "dist/headless-host/production-host.js");
|
|
10070
9907
|
const source = join17(packageRoot, "src/headless-host/production-host.ts");
|
|
10071
|
-
const target =
|
|
9908
|
+
const target = existsSync5(built) ? built : source;
|
|
10072
9909
|
const href = pathToFileURL2(target).href;
|
|
10073
9910
|
const mod = await import(href);
|
|
10074
9911
|
const create = mod.createProductionHeadlessRoleTurnHost;
|
|
@@ -10754,7 +10591,7 @@ __export(host_providers_exports, {
|
|
|
10754
10591
|
projectHostFacingProvider: () => projectHostFacingProvider,
|
|
10755
10592
|
renderHostProvidersTable: () => renderHostProvidersTable
|
|
10756
10593
|
});
|
|
10757
|
-
import { readFileSync
|
|
10594
|
+
import { readFileSync } from "node:fs";
|
|
10758
10595
|
import { join as join19 } from "node:path";
|
|
10759
10596
|
function hostProvidersPath(home) {
|
|
10760
10597
|
if (typeof home !== "string" || home.trim() === "") {
|
|
@@ -10802,7 +10639,7 @@ function parseHostProvidersTable(value) {
|
|
|
10802
10639
|
function loadHostProvidersTable(home) {
|
|
10803
10640
|
const path = hostProvidersPath(home);
|
|
10804
10641
|
try {
|
|
10805
|
-
const raw =
|
|
10642
|
+
const raw = readFileSync(path, "utf8");
|
|
10806
10643
|
return parseHostProvidersTable(JSON.parse(raw));
|
|
10807
10644
|
} catch (error) {
|
|
10808
10645
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
@@ -10820,7 +10657,7 @@ function listHermesProvidersForModel(home, seatModel) {
|
|
|
10820
10657
|
const path = hermesProviderModelsCachePath(home);
|
|
10821
10658
|
let text;
|
|
10822
10659
|
try {
|
|
10823
|
-
text =
|
|
10660
|
+
text = readFileSync(path, "utf8");
|
|
10824
10661
|
} catch (error) {
|
|
10825
10662
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
10826
10663
|
return [];
|
|
@@ -10920,7 +10757,7 @@ var init_host_providers = __esm({
|
|
|
10920
10757
|
// src/analyst-gate-cycles-read.ts
|
|
10921
10758
|
import { readdir as readdir4 } from "node:fs/promises";
|
|
10922
10759
|
import { join as join20 } from "node:path";
|
|
10923
|
-
function
|
|
10760
|
+
function isRecord7(value) {
|
|
10924
10761
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10925
10762
|
}
|
|
10926
10763
|
function isParentAttemptBindingRow(row) {
|
|
@@ -10950,7 +10787,7 @@ function isGateTerminatingToolName(toolName) {
|
|
|
10950
10787
|
function acceptedGateReceiptIds(rows) {
|
|
10951
10788
|
const accepted = /* @__PURE__ */ new Set();
|
|
10952
10789
|
for (const row of rows) {
|
|
10953
|
-
const message =
|
|
10790
|
+
const message = isRecord7(row.message) ? row.message : void 0;
|
|
10954
10791
|
if (message?.role !== "toolResult") continue;
|
|
10955
10792
|
if (typeof message.toolCallId !== "string" || message.toolCallId.length === 0) continue;
|
|
10956
10793
|
if (message.isError === false) accepted.add(message.toolCallId);
|
|
@@ -10985,7 +10822,7 @@ function nearestAttemptBindingBefore(rows, beforeIndex) {
|
|
|
10985
10822
|
for (let i = beforeIndex - 1; i >= 0; i -= 1) {
|
|
10986
10823
|
const row = rows[i];
|
|
10987
10824
|
if (!isParentAttemptBindingRow(row)) continue;
|
|
10988
|
-
if (!
|
|
10825
|
+
if (!isRecord7(row.data) || !isRecord7(row.data.parent)) continue;
|
|
10989
10826
|
const id = row.data.parent.attemptEntryId;
|
|
10990
10827
|
const sessionFile = row.data.parent.sessionFile;
|
|
10991
10828
|
return {
|
|
@@ -11000,10 +10837,10 @@ function extractAllAcceptedGateToolCalls(rows) {
|
|
|
11000
10837
|
const out = [];
|
|
11001
10838
|
for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
|
|
11002
10839
|
const row = rows[rowIndex];
|
|
11003
|
-
const message =
|
|
10840
|
+
const message = isRecord7(row.message) ? row.message : void 0;
|
|
11004
10841
|
if (message?.role !== "assistant" || !Array.isArray(message.content)) continue;
|
|
11005
10842
|
for (const part of message.content) {
|
|
11006
|
-
if (!
|
|
10843
|
+
if (!isRecord7(part) || part.type !== "toolCall") continue;
|
|
11007
10844
|
if (typeof part.id !== "string" || part.id.length === 0) continue;
|
|
11008
10845
|
if (typeof part.name !== "string" || part.name.length === 0) continue;
|
|
11009
10846
|
if (!isGateTerminatingToolName(part.name)) continue;
|
|
@@ -11011,7 +10848,7 @@ function extractAllAcceptedGateToolCalls(rows) {
|
|
|
11011
10848
|
const binding = nearestAttemptBindingBefore(rows, rowIndex);
|
|
11012
10849
|
out.push({
|
|
11013
10850
|
toolName: part.name,
|
|
11014
|
-
args:
|
|
10851
|
+
args: isRecord7(part.arguments) ? part.arguments : void 0,
|
|
11015
10852
|
accepted: true,
|
|
11016
10853
|
rowIndex,
|
|
11017
10854
|
...binding
|
|
@@ -11134,17 +10971,17 @@ function pairGateRounds(volumes) {
|
|
|
11134
10971
|
return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
|
|
11135
10972
|
}
|
|
11136
10973
|
async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
11137
|
-
const { readFile:
|
|
10974
|
+
const { readFile: readFile26 } = await import("node:fs/promises");
|
|
11138
10975
|
let raw;
|
|
11139
10976
|
try {
|
|
11140
|
-
raw = JSON.parse(await
|
|
10977
|
+
raw = JSON.parse(await readFile26(pointerPath, "utf8"));
|
|
11141
10978
|
} catch (error) {
|
|
11142
10979
|
throw new Error(
|
|
11143
10980
|
`direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
11144
10981
|
{ cause: error }
|
|
11145
10982
|
);
|
|
11146
10983
|
}
|
|
11147
|
-
if (!
|
|
10984
|
+
if (!isRecord7(raw) || raw.kind !== "direct-officer-run-pointer" || raw.version !== 1) {
|
|
11148
10985
|
throw new Error(`direct officer run pointer has unknown shape in ${pointerPath}`);
|
|
11149
10986
|
}
|
|
11150
10987
|
const sessionFile = raw.sessionFile;
|
|
@@ -11219,14 +11056,14 @@ var init_audit_escalation = __esm({
|
|
|
11219
11056
|
});
|
|
11220
11057
|
|
|
11221
11058
|
// src/session-opening-materials.ts
|
|
11222
|
-
import { existsSync as
|
|
11059
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
11223
11060
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
11224
11061
|
import { dirname as dirname12, join as join21 } from "node:path";
|
|
11225
11062
|
import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
11226
11063
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
11227
11064
|
let dir = dirname12(fileURLToPath(moduleUrl));
|
|
11228
11065
|
for (let i = 0; i < 8; i += 1) {
|
|
11229
|
-
if (
|
|
11066
|
+
if (existsSync6(join21(dir, "package.json")) && existsSync6(join21(dir, "souls"))) {
|
|
11230
11067
|
return dir;
|
|
11231
11068
|
}
|
|
11232
11069
|
const parent = dirname12(dir);
|
|
@@ -11449,7 +11286,7 @@ var init_serialize_thrown_value = __esm({
|
|
|
11449
11286
|
|
|
11450
11287
|
// src/engine-detour-usage.ts
|
|
11451
11288
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
11452
|
-
import { readFileSync as
|
|
11289
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
11453
11290
|
import { dirname as dirname13, join as join23 } from "node:path";
|
|
11454
11291
|
function engineDetourStdoutByteLength(stdout) {
|
|
11455
11292
|
return Buffer.byteLength(stdout, "utf8");
|
|
@@ -11503,11 +11340,11 @@ function reportEngineDetourCall(input) {
|
|
|
11503
11340
|
recordPointer: pointer
|
|
11504
11341
|
};
|
|
11505
11342
|
}
|
|
11506
|
-
function
|
|
11343
|
+
function isRecord8(value) {
|
|
11507
11344
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11508
11345
|
}
|
|
11509
11346
|
function callFactFromSitianPayload(payload, pointer) {
|
|
11510
|
-
if (!
|
|
11347
|
+
if (!isRecord8(payload)) return void 0;
|
|
11511
11348
|
if (payload.tool !== ENGINE_DETOUR_TOOL_NAME) return void 0;
|
|
11512
11349
|
if (typeof payload.toolCallId !== "string" || payload.toolCallId.length === 0) {
|
|
11513
11350
|
return void 0;
|
|
@@ -11524,11 +11361,11 @@ function callFactFromSitianPayload(payload, pointer) {
|
|
|
11524
11361
|
};
|
|
11525
11362
|
}
|
|
11526
11363
|
function invocationScopeIdOfRecord(record4) {
|
|
11527
|
-
if (
|
|
11364
|
+
if (isRecord8(record4.subject)) {
|
|
11528
11365
|
const fromSubject = record4.subject.invocationScopeId;
|
|
11529
11366
|
if (typeof fromSubject === "string" && fromSubject.length > 0) return fromSubject;
|
|
11530
11367
|
}
|
|
11531
|
-
if (
|
|
11368
|
+
if (isRecord8(record4.payload)) {
|
|
11532
11369
|
const fromPayload = record4.payload.invocationScopeId;
|
|
11533
11370
|
if (typeof fromPayload === "string" && fromPayload.length > 0) return fromPayload;
|
|
11534
11371
|
}
|
|
@@ -11544,7 +11381,7 @@ async function readEngineDetourToolUsage(input) {
|
|
|
11544
11381
|
...input.cwd === void 0 ? {} : { cwd: input.cwd }
|
|
11545
11382
|
});
|
|
11546
11383
|
const { records } = await readSitianRecords(recordFile);
|
|
11547
|
-
const
|
|
11384
|
+
const callsByToolCallId = /* @__PURE__ */ new Map();
|
|
11548
11385
|
for (const record4 of records) {
|
|
11549
11386
|
if (record4.kind !== ENGINE_DETOUR_CALL_KIND) continue;
|
|
11550
11387
|
const boundScope = invocationScopeIdOfRecord(record4);
|
|
@@ -11561,8 +11398,9 @@ async function readEngineDetourToolUsage(input) {
|
|
|
11561
11398
|
};
|
|
11562
11399
|
const fact = callFactFromSitianPayload(record4.payload, pointer);
|
|
11563
11400
|
if (fact === void 0) continue;
|
|
11564
|
-
|
|
11401
|
+
callsByToolCallId.set(fact.toolCallId, fact);
|
|
11565
11402
|
}
|
|
11403
|
+
const calls = Array.from(callsByToolCallId.values());
|
|
11566
11404
|
return { callCount: calls.length, calls };
|
|
11567
11405
|
}
|
|
11568
11406
|
function projectEngineDetourToolUsageForPublicTerminal(usage, options) {
|
|
@@ -11586,9 +11424,9 @@ function projectEngineDetourToolUsageForPublicTerminal(usage, options) {
|
|
|
11586
11424
|
function readInvocationRecord(runDirectory) {
|
|
11587
11425
|
try {
|
|
11588
11426
|
const raw = JSON.parse(
|
|
11589
|
-
|
|
11427
|
+
readFileSync2(join23(runDirectory, "invocation.json"), "utf8")
|
|
11590
11428
|
);
|
|
11591
|
-
return
|
|
11429
|
+
return isRecord8(raw) ? raw : void 0;
|
|
11592
11430
|
} catch (error) {
|
|
11593
11431
|
if (error?.code === "ENOENT") return void 0;
|
|
11594
11432
|
throw error;
|
|
@@ -11599,14 +11437,9 @@ async function readInvocationEngineMounted(runDirectory) {
|
|
|
11599
11437
|
if (raw === void 0) return false;
|
|
11600
11438
|
return typeof raw.engine === "string" && raw.engine.trim() !== "";
|
|
11601
11439
|
}
|
|
11602
|
-
function readInvocationSelectedHost(runDirectory) {
|
|
11603
|
-
const raw = readInvocationRecord(runDirectory);
|
|
11604
|
-
if (raw === void 0) return void 0;
|
|
11605
|
-
return typeof raw.host === "string" && raw.host.trim() !== "" ? raw.host.trim() : void 0;
|
|
11606
|
-
}
|
|
11607
11440
|
function withEngineDetourToolUsageFact(outcome, usage) {
|
|
11608
11441
|
if (usage === void 0) return outcome;
|
|
11609
|
-
const prior =
|
|
11442
|
+
const prior = isRecord8(outcome.decisiveFacts) ? outcome.decisiveFacts : {};
|
|
11610
11443
|
return {
|
|
11611
11444
|
...outcome,
|
|
11612
11445
|
decisiveFacts: {
|
|
@@ -11648,7 +11481,7 @@ var init_engine_detour_usage = __esm({
|
|
|
11648
11481
|
});
|
|
11649
11482
|
|
|
11650
11483
|
// src/dossier-resolution.ts
|
|
11651
|
-
import { existsSync as
|
|
11484
|
+
import { existsSync as existsSync7, statSync as statSync2 } from "node:fs";
|
|
11652
11485
|
import { resolve as resolve10 } from "node:path";
|
|
11653
11486
|
function isHostContext(value) {
|
|
11654
11487
|
return "sessionManager" in value;
|
|
@@ -11668,7 +11501,7 @@ function resolveAuditDossier(source) {
|
|
|
11668
11501
|
}
|
|
11669
11502
|
const runDirectory = resolve10(raw);
|
|
11670
11503
|
try {
|
|
11671
|
-
if (!
|
|
11504
|
+
if (!existsSync7(runDirectory) || !statSync2(runDirectory).isDirectory()) {
|
|
11672
11505
|
return { status: "incomplete", observation: { kind: "missing-dossier" } };
|
|
11673
11506
|
}
|
|
11674
11507
|
} catch {
|
|
@@ -11676,13 +11509,13 @@ function resolveAuditDossier(source) {
|
|
|
11676
11509
|
}
|
|
11677
11510
|
return { status: "ok", runDirectory };
|
|
11678
11511
|
}
|
|
11679
|
-
function
|
|
11512
|
+
function isRecord9(value) {
|
|
11680
11513
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11681
11514
|
}
|
|
11682
11515
|
function readDoctorAuditSubjects(context) {
|
|
11683
11516
|
const entries = context.sessionManager.getEntries?.() ?? [];
|
|
11684
11517
|
for (const entry of entries) {
|
|
11685
|
-
if (
|
|
11518
|
+
if (isRecord9(entry) && entry.type === "custom" && entry.customType === DOCTOR_CANDIDATE_ENTRY_TYPE) {
|
|
11686
11519
|
return { status: "ok" };
|
|
11687
11520
|
}
|
|
11688
11521
|
}
|
|
@@ -11926,11 +11759,11 @@ var init_navigator_invocation_identity = __esm({
|
|
|
11926
11759
|
});
|
|
11927
11760
|
|
|
11928
11761
|
// src/receipt-delivery-policy.ts
|
|
11929
|
-
function
|
|
11762
|
+
function isRecord10(value) {
|
|
11930
11763
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11931
11764
|
}
|
|
11932
11765
|
function parseNoReceiptLifecycleFacts(input) {
|
|
11933
|
-
if (!
|
|
11766
|
+
if (!isRecord10(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) => isRecord10(item) && typeof item.reason === "string")) {
|
|
11934
11767
|
throw new TypeError("malformed no-receipt lifecycle facts");
|
|
11935
11768
|
}
|
|
11936
11769
|
return {
|
|
@@ -12555,7 +12388,7 @@ async function readSitianRetainedAuditorProviderStop(sessionFile) {
|
|
|
12555
12388
|
const { records } = await readSitianRecords(recordFile);
|
|
12556
12389
|
for (let i = records.length - 1; i >= 0; i -= 1) {
|
|
12557
12390
|
const payload = records[i]?.payload;
|
|
12558
|
-
if (!
|
|
12391
|
+
if (!isRecord11(payload) || !isRecord11(payload.response)) continue;
|
|
12559
12392
|
if (typeof payload.type === "string") continue;
|
|
12560
12393
|
const stop = sessionProviderStopFromAssistant(payload.response);
|
|
12561
12394
|
if (stop !== void 0) return stop;
|
|
@@ -12605,7 +12438,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
12605
12438
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
12606
12439
|
}
|
|
12607
12440
|
const header = entries.find((entry) => entry.type === "session");
|
|
12608
|
-
if (!
|
|
12441
|
+
if (!isRecord11(header)) continue;
|
|
12609
12442
|
const bindingIndexes = [];
|
|
12610
12443
|
for (let i = 0; i < entries.length; i += 1) {
|
|
12611
12444
|
const entry = entries[i];
|
|
@@ -12619,7 +12452,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
12619
12452
|
end: idx + 1 < bindingIndexes.length ? bindingIndexes[idx + 1] : entries.length
|
|
12620
12453
|
})) : [{ entry: void 0, start: 0, end: entries.length }];
|
|
12621
12454
|
for (const { entry: bindingEntry, start, end } of bindingPasses) {
|
|
12622
|
-
const bindingParent = bindingEntry !== void 0 &&
|
|
12455
|
+
const bindingParent = bindingEntry !== void 0 && isRecord11(bindingEntry.data) && isRecord11(bindingEntry.data.parent) ? bindingEntry.data.parent : void 0;
|
|
12623
12456
|
const attemptEntryId = typeof bindingParent?.attemptEntryId === "string" ? bindingParent.attemptEntryId : void 0;
|
|
12624
12457
|
const boundSessionFile = typeof bindingParent?.sessionFile === "string" ? bindingParent.sessionFile : typeof header.parentSession === "string" ? header.parentSession : void 0;
|
|
12625
12458
|
if (boundSessionFile !== sessionFile) continue;
|
|
@@ -12643,12 +12476,12 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
12643
12476
|
if (stop === void 0) continue;
|
|
12644
12477
|
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
12645
12478
|
const entry = entries[i];
|
|
12646
|
-
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !
|
|
12647
|
-
const parent =
|
|
12648
|
-
const failure2 =
|
|
12479
|
+
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord11(entry.data)) continue;
|
|
12480
|
+
const parent = isRecord11(entry.data.parent) ? entry.data.parent : void 0;
|
|
12481
|
+
const failure2 = isRecord11(entry.data.failure) ? entry.data.failure : void 0;
|
|
12649
12482
|
if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId) continue;
|
|
12650
12483
|
if (failure2 === void 0) continue;
|
|
12651
|
-
const identity =
|
|
12484
|
+
const identity = isRecord11(failure2.identity) ? failure2.identity : void 0;
|
|
12652
12485
|
const typedCause = failure2.cause === "provider" || failure2.cause === "activation" || failure2.cause === "session" || failure2.cause === "output" || failure2.cause === "timeout" ? failure2.cause : void 0;
|
|
12653
12486
|
return {
|
|
12654
12487
|
...typedCause === void 0 ? {} : { cause: typedCause },
|
|
@@ -12657,7 +12490,7 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
12657
12490
|
...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
|
|
12658
12491
|
} },
|
|
12659
12492
|
...typeof failure2.diagnostic === "string" ? { diagnostic: failure2.diagnostic } : {},
|
|
12660
|
-
...
|
|
12493
|
+
...isRecord11(failure2.details) ? { details: failure2.details } : {}
|
|
12661
12494
|
};
|
|
12662
12495
|
}
|
|
12663
12496
|
}
|
|
@@ -12704,9 +12537,9 @@ function typedFailedTerminatingToolKnownFailure(entries) {
|
|
|
12704
12537
|
if (classification.kind !== "infrastructure") continue;
|
|
12705
12538
|
if (typeof message.toolCallId !== "string" || typeof message.toolName !== "string") continue;
|
|
12706
12539
|
if (boundRoleToolCallForResult(attemptEntries, i, message, message.toolName) === void 0) continue;
|
|
12707
|
-
const textPart = Array.isArray(message.content) ? message.content.find((part) =>
|
|
12708
|
-
const diagnostic =
|
|
12709
|
-
const details =
|
|
12540
|
+
const textPart = Array.isArray(message.content) ? message.content.find((part) => isRecord11(part) && part.type === "text" && typeof part.text === "string") : void 0;
|
|
12541
|
+
const diagnostic = isRecord11(textPart) ? textPart.text : void 0;
|
|
12542
|
+
const details = isRecord11(message.details) ? message.details : classification.fact;
|
|
12710
12543
|
return {
|
|
12711
12544
|
cause: "activation",
|
|
12712
12545
|
identity: { name: message.toolName, code: message.toolCallId },
|
|
@@ -12843,7 +12676,7 @@ function controlledFailureInputFromResolution(resolution) {
|
|
|
12843
12676
|
} : {}
|
|
12844
12677
|
};
|
|
12845
12678
|
}
|
|
12846
|
-
function
|
|
12679
|
+
function isRecord11(value) {
|
|
12847
12680
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12848
12681
|
}
|
|
12849
12682
|
function toolResultText(message) {
|
|
@@ -12868,7 +12701,7 @@ function extractCollectorTargetBindRejection(entries) {
|
|
|
12868
12701
|
const diagnostic = toolResultText(message);
|
|
12869
12702
|
if (diagnostic.length === 0) return void 0;
|
|
12870
12703
|
const details = message.details;
|
|
12871
|
-
const code =
|
|
12704
|
+
const code = isRecord11(details) && typeof details.code === "string" && details.code.trim() !== "" ? details.code : void 0;
|
|
12872
12705
|
return code === void 0 ? { diagnostic } : { diagnostic, code };
|
|
12873
12706
|
}
|
|
12874
12707
|
return void 0;
|
|
@@ -12969,7 +12802,7 @@ function boundRoleToolCallForResult(entries, resultIndex, message, outputToolNam
|
|
|
12969
12802
|
const candidateMessage = entries[index]?.message;
|
|
12970
12803
|
if (candidateMessage?.role === "assistant" && Array.isArray(candidateMessage.content)) {
|
|
12971
12804
|
for (const part of candidateMessage.content) {
|
|
12972
|
-
if (!
|
|
12805
|
+
if (!isRecord11(part) || part.type !== "toolCall" || part.id !== callId) {
|
|
12973
12806
|
continue;
|
|
12974
12807
|
}
|
|
12975
12808
|
if (part.name !== outputToolName) return void 0;
|
|
@@ -13040,7 +12873,7 @@ function parseNavigatorAttendanceDetails(details) {
|
|
|
13040
12873
|
if (typeof details.prose === "string" && details.prose.trim() !== "") {
|
|
13041
12874
|
prose = details.prose;
|
|
13042
12875
|
} else {
|
|
13043
|
-
const next =
|
|
12876
|
+
const next = isRecord11(details.next) && typeof details.next.role === "string" ? details.next.role : void 0;
|
|
13044
12877
|
const reason = typeof details.reason === "string" && details.reason.trim() !== "" ? details.reason : void 0;
|
|
13045
12878
|
const command = typeof details.command === "string" && details.command.trim() !== "" ? details.command : void 0;
|
|
13046
12879
|
if (reason !== void 0 && next !== void 0) {
|
|
@@ -13149,7 +12982,7 @@ function detourGateContext(admitted, scope) {
|
|
|
13149
12982
|
}
|
|
13150
12983
|
async function withOptionalGateProjection(base, sessionDirectory, gateContext = {}) {
|
|
13151
12984
|
const secondaryEvidence = base.roleOutcome.kind === "failure" ? base.roleOutcome.decisiveFacts.secondaryEvidence : void 0;
|
|
13152
|
-
const skipGate =
|
|
12985
|
+
const skipGate = isRecord11(secondaryEvidence) && secondaryEvidence.kind === "role_infrastructure_failure" && packagedSkipsGateOnInfrastructureStage(secondaryEvidence.stage);
|
|
13153
12986
|
let next = base;
|
|
13154
12987
|
if (!skipGate) {
|
|
13155
12988
|
const gate = await extractGateFactFromSessionDirectory(sessionDirectory, gateContext);
|
|
@@ -13162,7 +12995,7 @@ function routePlaybookFailureMessage(entries) {
|
|
|
13162
12995
|
const entry = entries[i];
|
|
13163
12996
|
if (entry?.type !== "custom" || entry.customType !== NAVIGATOR_ROUTE_PLAYBOOK_FAILURE_ENTRY) continue;
|
|
13164
12997
|
const data = entry.data;
|
|
13165
|
-
if (!
|
|
12998
|
+
if (!isRecord11(data) || typeof data.message !== "string" || data.message.trim() === "") return void 0;
|
|
13166
12999
|
return data.message;
|
|
13167
13000
|
}
|
|
13168
13001
|
return void 0;
|
|
@@ -13209,7 +13042,7 @@ function extractNavigatorAttendanceFact(entries) {
|
|
|
13209
13042
|
const entry = entries[i];
|
|
13210
13043
|
if (entry?.type === "custom_message" && entry.customType === "ak-navigator-attendance") {
|
|
13211
13044
|
const details = entry.message?.details ?? entry.details;
|
|
13212
|
-
if (!
|
|
13045
|
+
if (!isRecord11(details)) {
|
|
13213
13046
|
return {
|
|
13214
13047
|
disposition: "unavailable",
|
|
13215
13048
|
source: "unknown",
|
|
@@ -13360,7 +13193,7 @@ async function settleSealedAcceptedOrToolResidual(admitted, authority, scope, ro
|
|
|
13360
13193
|
const residual = boundErroredToolCandidate(entries, index, message, residualToolName);
|
|
13361
13194
|
if (residual === void 0) continue;
|
|
13362
13195
|
const candidate = residual.candidate;
|
|
13363
|
-
const details =
|
|
13196
|
+
const details = isRecord11(candidate) ? candidate : { candidate };
|
|
13364
13197
|
const failed = await settleFailureTerminalResult(
|
|
13365
13198
|
admitted,
|
|
13366
13199
|
{
|
|
@@ -13435,7 +13268,7 @@ function extractDoctorCandidateFacts(entries) {
|
|
|
13435
13268
|
continue;
|
|
13436
13269
|
}
|
|
13437
13270
|
const data = entry.data;
|
|
13438
|
-
if (!
|
|
13271
|
+
if (!isRecord11(data)) return {};
|
|
13439
13272
|
return {
|
|
13440
13273
|
...data.cost === void 0 ? {} : { cost: data.cost },
|
|
13441
13274
|
...data.auditNoReceipt === void 0 ? {} : { auditNoReceipt: data.auditNoReceipt }
|
|
@@ -13520,7 +13353,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
13520
13353
|
let residual;
|
|
13521
13354
|
for (let index = entries.length - 1; index >= scanStart; index -= 1) {
|
|
13522
13355
|
const entry = entries[index];
|
|
13523
|
-
if (entry?.type === "custom" && entry.customType === "ak-role-submission-closure" &&
|
|
13356
|
+
if (entry?.type === "custom" && entry.customType === "ak-role-submission-closure" && isRecord11(entry.data) && entry.data.toolName === spec.toolName && classifyPackagedRoleTerminalResult(entry.data).kind === "accepted") {
|
|
13524
13357
|
thisAttemptHasSeatSuccess = true;
|
|
13525
13358
|
}
|
|
13526
13359
|
const message = entries[index]?.message;
|
|
@@ -13560,7 +13393,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
13560
13393
|
);
|
|
13561
13394
|
}
|
|
13562
13395
|
if (residual !== void 0) {
|
|
13563
|
-
const details =
|
|
13396
|
+
const details = isRecord11(residual.candidate) ? residual.candidate : { candidate: residual.candidate };
|
|
13564
13397
|
const failed = await settleFailureTerminalResult(
|
|
13565
13398
|
admitted,
|
|
13566
13399
|
{
|
|
@@ -13610,7 +13443,7 @@ function countersignTerminalFromEntries(entries) {
|
|
|
13610
13443
|
return void 0;
|
|
13611
13444
|
}
|
|
13612
13445
|
function withCountersignTerminalFact(roleOutcome, officer) {
|
|
13613
|
-
const prior = roleOutcome.decisiveFacts !== void 0 &&
|
|
13446
|
+
const prior = roleOutcome.decisiveFacts !== void 0 && isRecord11(roleOutcome.decisiveFacts) ? roleOutcome.decisiveFacts : {};
|
|
13614
13447
|
return {
|
|
13615
13448
|
...roleOutcome,
|
|
13616
13449
|
decisiveFacts: {
|
|
@@ -13623,7 +13456,7 @@ function acceptedSecretariatDefinesOfficerProjection(roleOutcome) {
|
|
|
13623
13456
|
const payloads = roleOutcome.payloads ?? [];
|
|
13624
13457
|
for (let index = payloads.length - 1; index >= 0; index -= 1) {
|
|
13625
13458
|
const payload = payloads[index];
|
|
13626
|
-
if (!
|
|
13459
|
+
if (!isRecord11(payload)) continue;
|
|
13627
13460
|
const status = payload.secretariatStatus;
|
|
13628
13461
|
if (typeof status !== "string") continue;
|
|
13629
13462
|
return status === "converged";
|
|
@@ -14068,7 +13901,7 @@ var init_settlement = __esm({
|
|
|
14068
13901
|
});
|
|
14069
13902
|
|
|
14070
13903
|
// src/archivist-record-pointer.ts
|
|
14071
|
-
import { mkdirSync as mkdirSync2, writeFileSync
|
|
13904
|
+
import { mkdirSync as mkdirSync2, writeFileSync } from "node:fs";
|
|
14072
13905
|
import { dirname as dirname15, join as join25 } from "node:path";
|
|
14073
13906
|
function bookDirectOfficerRunPointer(options) {
|
|
14074
13907
|
const nest = join25(dirname15(options.parentSessionFile), "auditor-roles");
|
|
@@ -14080,7 +13913,7 @@ function bookDirectOfficerRunPointer(options) {
|
|
|
14080
13913
|
sessionFile: options.sessionFile,
|
|
14081
13914
|
...options.runDirectory !== void 0 && options.runDirectory.trim() !== "" ? { runDirectory: options.runDirectory } : {}
|
|
14082
13915
|
};
|
|
14083
|
-
|
|
13916
|
+
writeFileSync(
|
|
14084
13917
|
join25(nest, `${options.officer}.pointer.json`),
|
|
14085
13918
|
`${JSON.stringify(pointer)}
|
|
14086
13919
|
`,
|
|
@@ -14393,159 +14226,281 @@ var init_session_identity = __esm({
|
|
|
14393
14226
|
}
|
|
14394
14227
|
});
|
|
14395
14228
|
|
|
14396
|
-
// src/public-cli/
|
|
14397
|
-
|
|
14398
|
-
|
|
14399
|
-
|
|
14400
|
-
|
|
14401
|
-
|
|
14402
|
-
});
|
|
14403
|
-
import { mkdtemp as mkdtemp3, readFile as readFile17, rm as rm4, writeFile as writeFile7 } from "node:fs/promises";
|
|
14404
|
-
import { tmpdir as tmpdir3 } from "node:os";
|
|
14405
|
-
import { join as join27 } from "node:path";
|
|
14406
|
-
async function projectCaseDossierPointerSection(input) {
|
|
14407
|
-
if (input.ticketNumber === void 0) {
|
|
14408
|
-
return [
|
|
14409
|
-
UNBOUND_DOSSIER_PATH_HEADING,
|
|
14410
|
-
"",
|
|
14411
|
-
`\u8BB0\u5F55\u5377\u5B97\uFF1A${projectTicketRecordsPathShape()}`
|
|
14412
|
-
].join("\n");
|
|
14413
|
-
}
|
|
14414
|
-
const volume = resolveTicketProvenanceVolume(
|
|
14415
|
-
input.ticketNumber,
|
|
14416
|
-
input.projectRoot,
|
|
14417
|
-
input.home
|
|
14418
|
-
);
|
|
14419
|
-
return [
|
|
14420
|
-
CASE_DOSSIER_SECTION_HEADING,
|
|
14421
|
-
"",
|
|
14422
|
-
`\u7968\u53F7\uFF1A#${input.ticketNumber}`,
|
|
14423
|
-
`\u8BB0\u5F55\u5377\u5B97\uFF1A${volume.recordFile}`
|
|
14424
|
-
].join("\n");
|
|
14425
|
-
}
|
|
14426
|
-
async function deliverCaseDossierAsAttachment(input) {
|
|
14427
|
-
const section = await projectCaseDossierPointerSection({
|
|
14428
|
-
ticketNumber: input.ticketNumber,
|
|
14429
|
-
projectRoot: input.projectRoot,
|
|
14430
|
-
home: input.home
|
|
14431
|
-
});
|
|
14432
|
-
const stagingDir = await mkdtemp3(join27(tmpdir3(), "ak-case-dossier-"));
|
|
14433
|
-
try {
|
|
14434
|
-
const stagingPath = join27(stagingDir, CASE_DOSSIER_ATTACH_FILE);
|
|
14435
|
-
await writeFile7(stagingPath, `${section}
|
|
14436
|
-
`, "utf8");
|
|
14437
|
-
return await freezeAttachmentsIntoRun(
|
|
14438
|
-
[stagingPath],
|
|
14439
|
-
input.runDirectory,
|
|
14440
|
-
CASE_DOSSIER_ATTACH_KEY
|
|
14441
|
-
);
|
|
14442
|
-
} finally {
|
|
14443
|
-
await rm4(stagingDir, { recursive: true, force: true });
|
|
14229
|
+
// src/public-cli/process-cancel.ts
|
|
14230
|
+
function processCancelSignalName(signal) {
|
|
14231
|
+
if (signal === void 0 || signal.aborted !== true) return void 0;
|
|
14232
|
+
const reason = signal.reason;
|
|
14233
|
+
if (reason === "SIGTERM" || reason === "SIGINT" || reason === "SIGHUP") {
|
|
14234
|
+
return reason;
|
|
14444
14235
|
}
|
|
14236
|
+
return void 0;
|
|
14445
14237
|
}
|
|
14446
|
-
|
|
14447
|
-
|
|
14448
|
-
runDirectory,
|
|
14449
|
-
"attachments",
|
|
14450
|
-
CASE_DOSSIER_ATTACH_KEY,
|
|
14451
|
-
`00-${CASE_DOSSIER_ATTACH_FILE}`
|
|
14452
|
-
);
|
|
14453
|
-
let section;
|
|
14454
|
-
try {
|
|
14455
|
-
section = await readFile17(frozenPath, "utf8");
|
|
14456
|
-
} catch (error) {
|
|
14457
|
-
if (error.code === "ENOENT") return void 0;
|
|
14458
|
-
throw error;
|
|
14459
|
-
}
|
|
14460
|
-
if (section.trim() === "") return void 0;
|
|
14461
|
-
return { kind: "case-dossier-pointer", frozenPath, section };
|
|
14238
|
+
function processCancelDiagnostic(signalName) {
|
|
14239
|
+
return `ak-role terminated by ${signalName}`;
|
|
14462
14240
|
}
|
|
14463
|
-
var
|
|
14464
|
-
|
|
14465
|
-
"src/public-cli/case-dossier-delivery.ts"() {
|
|
14241
|
+
var init_process_cancel = __esm({
|
|
14242
|
+
"src/public-cli/process-cancel.ts"() {
|
|
14466
14243
|
"use strict";
|
|
14467
|
-
init_sitian_facade();
|
|
14468
|
-
init_ticket_provenance();
|
|
14469
|
-
init_invocation();
|
|
14470
|
-
CASE_DOSSIER_SECTION_HEADING = "## \u672C\u7968\u8D77\u5C45\u5F55\uFF08\u7CFB\u7EDF\u968F\u6848\u63D0\u4F9B\uFF09";
|
|
14471
|
-
UNBOUND_DOSSIER_PATH_HEADING = "## \u8D77\u5C45\u5F55\u8DEF\u5F84\uFF08\u7CFB\u7EDF\u968F\u6848\u63D0\u4F9B\uFF09";
|
|
14472
|
-
CASE_DOSSIER_ATTACH_KEY = "case-dossier";
|
|
14473
|
-
CASE_DOSSIER_ATTACH_FILE = "case-dossier-pointer.md";
|
|
14474
14244
|
}
|
|
14475
14245
|
});
|
|
14476
14246
|
|
|
14477
|
-
// src/host-
|
|
14478
|
-
import {
|
|
14479
|
-
import {
|
|
14480
|
-
|
|
14481
|
-
|
|
14247
|
+
// src/host-session-record.ts
|
|
14248
|
+
import { spawnSync } from "node:child_process";
|
|
14249
|
+
import {
|
|
14250
|
+
appendFileSync as appendFileSync2,
|
|
14251
|
+
copyFileSync,
|
|
14252
|
+
closeSync,
|
|
14253
|
+
existsSync as existsSync8,
|
|
14254
|
+
openSync,
|
|
14255
|
+
readFileSync as readFileSync3,
|
|
14256
|
+
mkdirSync as mkdirSync3,
|
|
14257
|
+
readdirSync as readdirSync2,
|
|
14258
|
+
rmSync,
|
|
14259
|
+
statSync as statSync3
|
|
14260
|
+
} from "node:fs";
|
|
14261
|
+
import { homedir } from "node:os";
|
|
14262
|
+
import { dirname as dirname17, join as join27 } from "node:path";
|
|
14263
|
+
function declareHostSessionFailure(error) {
|
|
14264
|
+
const message = error instanceof Error ? error.stack || error.message : String(error);
|
|
14265
|
+
process.stderr.write(`[host-session] Dossier record failure: ${message}
|
|
14266
|
+
`);
|
|
14482
14267
|
}
|
|
14483
|
-
|
|
14268
|
+
function sitianReportSafe(input) {
|
|
14484
14269
|
try {
|
|
14485
|
-
|
|
14486
|
-
return [sessionFile];
|
|
14270
|
+
sitianReport(input);
|
|
14487
14271
|
} catch (error) {
|
|
14488
|
-
|
|
14489
|
-
throw error;
|
|
14272
|
+
declareHostSessionFailure(error);
|
|
14490
14273
|
}
|
|
14491
14274
|
}
|
|
14492
|
-
|
|
14493
|
-
|
|
14494
|
-
|
|
14275
|
+
function findCodexRollout(sessionsDir, sessionId) {
|
|
14276
|
+
if (!existsSync8(sessionsDir)) return void 0;
|
|
14277
|
+
const matches = [];
|
|
14278
|
+
function scan(dir, depth = 0) {
|
|
14279
|
+
if (depth > 6) return;
|
|
14280
|
+
let entries;
|
|
14281
|
+
try {
|
|
14282
|
+
entries = readdirSync2(dir, { withFileTypes: true });
|
|
14283
|
+
} catch {
|
|
14284
|
+
return;
|
|
14285
|
+
}
|
|
14286
|
+
for (const entry of entries) {
|
|
14287
|
+
const fullPath = join27(dir, entry.name);
|
|
14288
|
+
if (entry.isDirectory()) {
|
|
14289
|
+
scan(fullPath, depth + 1);
|
|
14290
|
+
} else if (entry.isFile() && entry.name.endsWith(".jsonl") && entry.name.includes(sessionId)) {
|
|
14291
|
+
try {
|
|
14292
|
+
const stat2 = statSync3(fullPath);
|
|
14293
|
+
matches.push({ path: fullPath, mtime: stat2.mtimeMs });
|
|
14294
|
+
} catch {
|
|
14295
|
+
matches.push({ path: fullPath, mtime: 0 });
|
|
14296
|
+
}
|
|
14297
|
+
}
|
|
14298
|
+
}
|
|
14299
|
+
}
|
|
14300
|
+
scan(sessionsDir);
|
|
14301
|
+
if (matches.length === 0 || matches[0] === void 0) return void 0;
|
|
14302
|
+
matches.sort((a, b) => b.mtime - a.mtime);
|
|
14303
|
+
return matches[0]?.path;
|
|
14304
|
+
}
|
|
14305
|
+
function sanitizeClaudeCwd(cwd) {
|
|
14306
|
+
return cwd.replace(/[^a-zA-Z0-9]/g, "-");
|
|
14307
|
+
}
|
|
14308
|
+
function resolveNativeSessionPath(options) {
|
|
14309
|
+
const home = options.home || homedir();
|
|
14310
|
+
if (options.host === "claude") {
|
|
14311
|
+
const configDir = process.env.CLAUDE_CONFIG_DIR || join27(home, ".claude");
|
|
14312
|
+
const sanitizedCwd = sanitizeClaudeCwd(options.cwd);
|
|
14313
|
+
return join27(configDir, "projects", sanitizedCwd, `${options.sessionId}.jsonl`);
|
|
14314
|
+
}
|
|
14315
|
+
if (options.host === "codex") {
|
|
14316
|
+
return findCodexRollout(codexSessionsDirectory(home), options.sessionId);
|
|
14317
|
+
}
|
|
14318
|
+
if (options.host === "grok-build") {
|
|
14319
|
+
const grokHome = process.env.GROK_HOME || join27(home, ".grok");
|
|
14320
|
+
return join27(grokHome, "sessions", encodeURIComponent(options.cwd), options.sessionId);
|
|
14321
|
+
}
|
|
14322
|
+
return void 0;
|
|
14323
|
+
}
|
|
14324
|
+
function codexSessionsDirectory(home) {
|
|
14325
|
+
return join27(process.env.CODEX_HOME || join27(home || homedir(), ".codex"), "sessions");
|
|
14326
|
+
}
|
|
14327
|
+
function recordRunStart(runDirectory) {
|
|
14495
14328
|
try {
|
|
14496
|
-
|
|
14329
|
+
appendFileSync2(join27(runDirectory, ".run-starts"), "\n");
|
|
14497
14330
|
} catch (error) {
|
|
14498
|
-
|
|
14499
|
-
throw error;
|
|
14331
|
+
declareHostSessionFailure(error);
|
|
14500
14332
|
}
|
|
14501
|
-
|
|
14502
|
-
|
|
14503
|
-
|
|
14504
|
-
|
|
14333
|
+
}
|
|
14334
|
+
function resolveHostDossierLandingPath(options) {
|
|
14335
|
+
const sanitizedModel = (options.model?.model ?? "default").replace(/[\/\\]+/g, "-");
|
|
14336
|
+
let maxOrdinal = 0;
|
|
14337
|
+
if (existsSync8(options.sessionDirectory)) {
|
|
14505
14338
|
try {
|
|
14506
|
-
|
|
14507
|
-
|
|
14508
|
-
|
|
14509
|
-
|
|
14339
|
+
const entries = readdirSync2(options.sessionDirectory);
|
|
14340
|
+
for (const entry of entries) {
|
|
14341
|
+
const match = entry.match(/-(\d+)(?:\.jsonl|\.failed)?$/);
|
|
14342
|
+
const first = match?.[1];
|
|
14343
|
+
if (first !== void 0) {
|
|
14344
|
+
const val = parseInt(first, 10);
|
|
14345
|
+
if (!isNaN(val) && val > maxOrdinal) {
|
|
14346
|
+
maxOrdinal = val;
|
|
14347
|
+
}
|
|
14348
|
+
}
|
|
14349
|
+
}
|
|
14350
|
+
} catch {
|
|
14510
14351
|
}
|
|
14511
14352
|
}
|
|
14512
|
-
|
|
14513
|
-
|
|
14353
|
+
const startsPath = join27(dirname17(options.sessionDirectory), ".run-starts");
|
|
14354
|
+
let starts = 0;
|
|
14355
|
+
if (existsSync8(startsPath)) starts = readFileSync3(startsPath, "utf8").length;
|
|
14356
|
+
const ordinal = Math.max(maxOrdinal + 1, starts, options.continuation.kind === "resume" ? 2 : 1);
|
|
14357
|
+
const baseName = `${options.host}-${sanitizedModel}-${ordinal}`;
|
|
14358
|
+
const landingPath = options.host === "grok-build" ? join27(options.sessionDirectory, baseName) : join27(options.sessionDirectory, `${baseName}.jsonl`);
|
|
14359
|
+
return { landingPath, ordinal, sanitizedModel };
|
|
14514
14360
|
}
|
|
14515
|
-
|
|
14516
|
-
if (
|
|
14517
|
-
|
|
14518
|
-
return {
|
|
14519
|
-
priorNativeKind: "pi-native",
|
|
14520
|
-
priorNativePaths: await listPiNativeRecordPaths(input.piSessionFile)
|
|
14521
|
-
};
|
|
14361
|
+
function recordNativeSessionPointer(options) {
|
|
14362
|
+
if (options.host === "pi" || options.host === "hermes") {
|
|
14363
|
+
return void 0;
|
|
14522
14364
|
}
|
|
14523
|
-
|
|
14524
|
-
|
|
14525
|
-
|
|
14526
|
-
|
|
14365
|
+
const nativePath = options.host === "codex" ? codexSessionsDirectory(options.home) : resolveNativeSessionPath(options);
|
|
14366
|
+
if (nativePath === void 0) return void 0;
|
|
14367
|
+
sitianReportSafe({
|
|
14368
|
+
level: "event",
|
|
14369
|
+
kind: HOST_SESSION_RECORD_KIND,
|
|
14370
|
+
host: options.host,
|
|
14371
|
+
cwd: options.cwd,
|
|
14372
|
+
sessionParent: options.sessionParent,
|
|
14373
|
+
source: `${options.host}-dossier`,
|
|
14374
|
+
payload: {
|
|
14375
|
+
type: "native-session-pointer",
|
|
14376
|
+
nativePath,
|
|
14377
|
+
sessionId: options.sessionId
|
|
14378
|
+
}
|
|
14379
|
+
});
|
|
14380
|
+
return nativePath;
|
|
14527
14381
|
}
|
|
14528
|
-
|
|
14529
|
-
|
|
14530
|
-
"
|
|
14382
|
+
function copyFileCloneOrFallback(src, dest) {
|
|
14383
|
+
try {
|
|
14384
|
+
const res = spawnSync("cp", ["-c", src, dest]);
|
|
14385
|
+
if (res.status === 0) return;
|
|
14386
|
+
} catch {
|
|
14531
14387
|
}
|
|
14532
|
-
|
|
14533
|
-
|
|
14534
|
-
|
|
14535
|
-
|
|
14536
|
-
if (
|
|
14537
|
-
|
|
14538
|
-
if (reason === "SIGTERM" || reason === "SIGINT" || reason === "SIGHUP") {
|
|
14539
|
-
return reason;
|
|
14388
|
+
copyFileSync(src, dest);
|
|
14389
|
+
}
|
|
14390
|
+
function copyGrokDossier(srcDir, destDir) {
|
|
14391
|
+
const chatHistorySrc = join27(srcDir, "chat_history.jsonl");
|
|
14392
|
+
if (!existsSync8(chatHistorySrc)) {
|
|
14393
|
+
throw new Error(`Grok native chat_history.jsonl missing at ${chatHistorySrc}`);
|
|
14540
14394
|
}
|
|
14541
|
-
|
|
14395
|
+
mkdirSync3(destDir, { recursive: true });
|
|
14396
|
+
const chatHistoryDest = join27(destDir, "chat_history.jsonl");
|
|
14397
|
+
copyFileCloneOrFallback(chatHistorySrc, chatHistoryDest);
|
|
14398
|
+
const usageSrc = join27(srcDir, "usage.json");
|
|
14399
|
+
if (!existsSync8(usageSrc)) {
|
|
14400
|
+
throw new Error(`Grok native usage.json missing at ${usageSrc}`);
|
|
14401
|
+
}
|
|
14402
|
+
copyFileCloneOrFallback(usageSrc, join27(destDir, "usage.json"));
|
|
14542
14403
|
}
|
|
14543
|
-
function
|
|
14544
|
-
|
|
14404
|
+
function copyAndRecordHostDossier(options) {
|
|
14405
|
+
if (options.host === "pi" || options.host === "hermes") {
|
|
14406
|
+
return;
|
|
14407
|
+
}
|
|
14408
|
+
const nativePath = resolveNativeSessionPath({
|
|
14409
|
+
host: options.host,
|
|
14410
|
+
sessionId: options.sessionId,
|
|
14411
|
+
cwd: options.cwd,
|
|
14412
|
+
...options.home !== void 0 ? { home: options.home } : {}
|
|
14413
|
+
});
|
|
14414
|
+
if (nativePath === void 0 && options.host !== "codex") return;
|
|
14415
|
+
let destination;
|
|
14416
|
+
try {
|
|
14417
|
+
destination = resolveHostDossierLandingPath(options);
|
|
14418
|
+
} catch (error) {
|
|
14419
|
+
sitianReportSafe({
|
|
14420
|
+
level: "event",
|
|
14421
|
+
kind: HOST_SESSION_RECORD_KIND,
|
|
14422
|
+
host: options.host,
|
|
14423
|
+
cwd: options.cwd,
|
|
14424
|
+
sessionParent: options.sessionParent,
|
|
14425
|
+
source: `${options.host}-dossier`,
|
|
14426
|
+
payload: {
|
|
14427
|
+
type: "native-session-warning",
|
|
14428
|
+
sessionId: options.sessionId,
|
|
14429
|
+
error: error instanceof Error ? error.message : String(error)
|
|
14430
|
+
}
|
|
14431
|
+
});
|
|
14432
|
+
return;
|
|
14433
|
+
}
|
|
14434
|
+
const { landingPath, ordinal, sanitizedModel } = destination;
|
|
14435
|
+
let lastError;
|
|
14436
|
+
let copySuccess = false;
|
|
14437
|
+
for (let attempt = 1; attempt <= 2; attempt++) {
|
|
14438
|
+
try {
|
|
14439
|
+
if (options.host === "grok-build") {
|
|
14440
|
+
copyGrokDossier(nativePath, landingPath);
|
|
14441
|
+
} else {
|
|
14442
|
+
if (nativePath === void 0 || !existsSync8(nativePath)) {
|
|
14443
|
+
throw new Error(`Native session file missing for ${options.host} session ${options.sessionId}`);
|
|
14444
|
+
}
|
|
14445
|
+
mkdirSync3(dirname17(landingPath), { recursive: true });
|
|
14446
|
+
copyFileCloneOrFallback(nativePath, landingPath);
|
|
14447
|
+
}
|
|
14448
|
+
copySuccess = true;
|
|
14449
|
+
break;
|
|
14450
|
+
} catch (error) {
|
|
14451
|
+
lastError = error;
|
|
14452
|
+
}
|
|
14453
|
+
}
|
|
14454
|
+
if (copySuccess) {
|
|
14455
|
+
sitianReportSafe({
|
|
14456
|
+
level: "event",
|
|
14457
|
+
kind: HOST_SESSION_RECORD_KIND,
|
|
14458
|
+
host: options.host,
|
|
14459
|
+
cwd: options.cwd,
|
|
14460
|
+
sessionParent: options.sessionParent,
|
|
14461
|
+
source: `${options.host}-dossier`,
|
|
14462
|
+
payload: {
|
|
14463
|
+
type: "native-session-copy",
|
|
14464
|
+
nativePath,
|
|
14465
|
+
landingPath,
|
|
14466
|
+
ordinal,
|
|
14467
|
+
sessionId: options.sessionId
|
|
14468
|
+
}
|
|
14469
|
+
});
|
|
14470
|
+
} else {
|
|
14471
|
+
try {
|
|
14472
|
+
rmSync(landingPath, { recursive: options.host === "grok-build", force: true });
|
|
14473
|
+
} catch {
|
|
14474
|
+
}
|
|
14475
|
+
try {
|
|
14476
|
+
mkdirSync3(options.sessionDirectory, { recursive: true });
|
|
14477
|
+
closeSync(openSync(join27(options.sessionDirectory, `${options.host}-${sanitizedModel}-${ordinal}.failed`), "a"));
|
|
14478
|
+
} catch {
|
|
14479
|
+
}
|
|
14480
|
+
sitianReportSafe({
|
|
14481
|
+
level: "event",
|
|
14482
|
+
kind: HOST_SESSION_RECORD_KIND,
|
|
14483
|
+
host: options.host,
|
|
14484
|
+
cwd: options.cwd,
|
|
14485
|
+
sessionParent: options.sessionParent,
|
|
14486
|
+
source: `${options.host}-dossier`,
|
|
14487
|
+
payload: {
|
|
14488
|
+
type: "native-session-warning",
|
|
14489
|
+
nativePath,
|
|
14490
|
+
landingPath,
|
|
14491
|
+
ordinal,
|
|
14492
|
+
sessionId: options.sessionId,
|
|
14493
|
+
error: lastError instanceof Error ? lastError.message : String(lastError)
|
|
14494
|
+
}
|
|
14495
|
+
});
|
|
14496
|
+
}
|
|
14545
14497
|
}
|
|
14546
|
-
var
|
|
14547
|
-
|
|
14498
|
+
var HOST_SESSION_RECORD_KIND;
|
|
14499
|
+
var init_host_session_record = __esm({
|
|
14500
|
+
"src/host-session-record.ts"() {
|
|
14548
14501
|
"use strict";
|
|
14502
|
+
init_sitian_facade();
|
|
14503
|
+
HOST_SESSION_RECORD_KIND = "host-session";
|
|
14549
14504
|
}
|
|
14550
14505
|
});
|
|
14551
14506
|
|
|
@@ -14553,7 +14508,7 @@ var init_process_cancel = __esm({
|
|
|
14553
14508
|
import { constants as fsConstants2 } from "node:fs";
|
|
14554
14509
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
14555
14510
|
import { lstat as lstat5, mkdir as mkdir3, open } from "node:fs/promises";
|
|
14556
|
-
import { join as
|
|
14511
|
+
import { join as join28 } from "node:path";
|
|
14557
14512
|
async function persistReturnedRunState(admitted, authority, options) {
|
|
14558
14513
|
if (options?.lawful === true) {
|
|
14559
14514
|
await markRunTerminal(admitted.runDirectory);
|
|
@@ -14624,7 +14579,7 @@ function jsonSafeReplacer() {
|
|
|
14624
14579
|
};
|
|
14625
14580
|
}
|
|
14626
14581
|
async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
|
|
14627
|
-
const filePath =
|
|
14582
|
+
const filePath = join28(artifactsDir, `${namePrefix}-${randomUUID5()}.json`);
|
|
14628
14583
|
const body = `${JSON.stringify(payload, jsonSafeReplacer(), 2)}
|
|
14629
14584
|
`;
|
|
14630
14585
|
const noFollowFlag = typeof fsConstants2.O_NOFOLLOW === "number" ? fsConstants2.O_NOFOLLOW : 0;
|
|
@@ -14912,8 +14867,8 @@ var init_auto_resume = __esm({
|
|
|
14912
14867
|
|
|
14913
14868
|
// src/public-cli/post-admission.ts
|
|
14914
14869
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
14915
|
-
import { writeFile as
|
|
14916
|
-
import { isAbsolute as isAbsolute7, join as
|
|
14870
|
+
import { writeFile as writeFile7 } from "node:fs/promises";
|
|
14871
|
+
import { isAbsolute as isAbsolute7, join as join29, resolve as resolve12 } from "node:path";
|
|
14917
14872
|
function describeCaughtError(error) {
|
|
14918
14873
|
if (error instanceof Error) {
|
|
14919
14874
|
const code = error.code;
|
|
@@ -15008,8 +14963,8 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
15008
14963
|
} catch (appendError) {
|
|
15009
14964
|
try {
|
|
15010
14965
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
15011
|
-
await
|
|
15012
|
-
|
|
14966
|
+
await writeFile7(
|
|
14967
|
+
join29(artifactsDir, `post-admission-diagnostic-${randomUUID6()}.json`),
|
|
15013
14968
|
`${JSON.stringify({ version: 1, ...payload }, null, 2)}
|
|
15014
14969
|
`,
|
|
15015
14970
|
{ encoding: "utf8", flag: "wx" }
|
|
@@ -15155,7 +15110,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
15155
15110
|
const rows = await readRecordedSubmissionRows(
|
|
15156
15111
|
admitted.projectRoot,
|
|
15157
15112
|
admitted.runId,
|
|
15158
|
-
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent:
|
|
15113
|
+
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent: join29(admitted.runDirectory, "session", "session.jsonl") }
|
|
15159
15114
|
);
|
|
15160
15115
|
let ticketNumber;
|
|
15161
15116
|
for (const row of rows) {
|
|
@@ -15211,35 +15166,6 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
15211
15166
|
}
|
|
15212
15167
|
};
|
|
15213
15168
|
try {
|
|
15214
|
-
let previousHost;
|
|
15215
|
-
const liveHost = env.host;
|
|
15216
|
-
const principalCoordinates = admitted.principal === void 0 ? void 0 : env.principalAuthority.decode(admitted.principal);
|
|
15217
|
-
let hostTransition;
|
|
15218
|
-
try {
|
|
15219
|
-
previousHost = readInvocationSelectedHost(admitted.runDirectory);
|
|
15220
|
-
hostTransition = previousHost !== void 0 && liveHost !== void 0 && principalCoordinates !== void 0 ? await projectHostTransitionPriorNative({
|
|
15221
|
-
previousHost,
|
|
15222
|
-
liveHost,
|
|
15223
|
-
piSessionFile: principalCoordinates.sessionFile
|
|
15224
|
-
}) : void 0;
|
|
15225
|
-
} catch (error) {
|
|
15226
|
-
return {
|
|
15227
|
-
...await presentControlledFailure2(
|
|
15228
|
-
admitted,
|
|
15229
|
-
withEngineDetourInvocationScope({
|
|
15230
|
-
timedOut: false,
|
|
15231
|
-
code: null,
|
|
15232
|
-
stderr: "",
|
|
15233
|
-
thrown: error
|
|
15234
|
-
}, request.invocationScopeId),
|
|
15235
|
-
adapters,
|
|
15236
|
-
env.principalAuthority,
|
|
15237
|
-
io,
|
|
15238
|
-
persistRunState
|
|
15239
|
-
),
|
|
15240
|
-
...deferredPersist
|
|
15241
|
-
};
|
|
15242
|
-
}
|
|
15243
15169
|
await clearTypedProviderHttpObservation(admitted.runDirectory);
|
|
15244
15170
|
if (adapters.beforeDispatch !== void 0) {
|
|
15245
15171
|
try {
|
|
@@ -15275,18 +15201,9 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
15275
15201
|
if (env.stationChild !== void 0) {
|
|
15276
15202
|
turnRequest = { ...turnRequest, stationChild: env.stationChild };
|
|
15277
15203
|
}
|
|
15278
|
-
if (
|
|
15279
|
-
turnRequest = { ...turnRequest,
|
|
15280
|
-
}
|
|
15281
|
-
if (typeof liveHost === "string" && liveHost.trim() !== "") {
|
|
15282
|
-
turnRequest = { ...turnRequest, host: liveHost.trim() };
|
|
15204
|
+
if (typeof env.host === "string" && env.host.trim() !== "") {
|
|
15205
|
+
turnRequest = { ...turnRequest, host: env.host.trim() };
|
|
15283
15206
|
}
|
|
15284
|
-
await deliverCaseDossierAsAttachment({
|
|
15285
|
-
ticketNumber: admitted.ticketNumber,
|
|
15286
|
-
projectRoot: admitted.projectRoot,
|
|
15287
|
-
home: env.home,
|
|
15288
|
-
runDirectory: admitted.runDirectory
|
|
15289
|
-
});
|
|
15290
15207
|
await markRunRunning(
|
|
15291
15208
|
admitted.runDirectory,
|
|
15292
15209
|
env.model,
|
|
@@ -15296,6 +15213,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
15296
15213
|
);
|
|
15297
15214
|
let result;
|
|
15298
15215
|
try {
|
|
15216
|
+
recordRunStart(admitted.runDirectory);
|
|
15299
15217
|
result = await env.roleTurnHost.executeTurn(turnRequest);
|
|
15300
15218
|
} catch (error) {
|
|
15301
15219
|
const processCancelName = processCancelSignalName(env.signal);
|
|
@@ -15321,8 +15239,8 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
15321
15239
|
}
|
|
15322
15240
|
let stderrLogWriteFailure;
|
|
15323
15241
|
try {
|
|
15324
|
-
await
|
|
15325
|
-
|
|
15242
|
+
await writeFile7(
|
|
15243
|
+
join29(admitted.runDirectory, "stderr.log"),
|
|
15326
15244
|
result.stderr,
|
|
15327
15245
|
"utf8"
|
|
15328
15246
|
);
|
|
@@ -15601,7 +15519,7 @@ async function dispatchAfterWriterLease(input) {
|
|
|
15601
15519
|
}
|
|
15602
15520
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
15603
15521
|
const absolute = isAbsolute7(attachmentPath) ? attachmentPath : resolve12(attachmentPath);
|
|
15604
|
-
return pathContainedIn(
|
|
15522
|
+
return pathContainedIn(join29(runDirectory, "attachments"), absolute);
|
|
15605
15523
|
}
|
|
15606
15524
|
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
15607
15525
|
if (summons === void 0) return void 0;
|
|
@@ -15860,8 +15778,8 @@ async function presentResumeFailurePointer(io, thrown, publish) {
|
|
|
15860
15778
|
}
|
|
15861
15779
|
async function writeResumeDiagnosticFile(runDirectory, runId, failure2, role) {
|
|
15862
15780
|
const dir = await ensureRealArtifactsDirectory(runDirectory);
|
|
15863
|
-
const path =
|
|
15864
|
-
await
|
|
15781
|
+
const path = join29(dir, `resume-diagnostic-${randomUUID6()}.json`);
|
|
15782
|
+
await writeFile7(
|
|
15865
15783
|
path,
|
|
15866
15784
|
`${JSON.stringify({
|
|
15867
15785
|
runId,
|
|
@@ -15993,12 +15911,11 @@ var init_post_admission = __esm({
|
|
|
15993
15911
|
init_session_identity();
|
|
15994
15912
|
init_role_run_relocation();
|
|
15995
15913
|
init_packaged_role_registry();
|
|
15996
|
-
init_case_dossier_delivery();
|
|
15997
15914
|
init_engine_detour_usage();
|
|
15998
|
-
init_host_transition_prior_native();
|
|
15999
15915
|
init_run_lifecycle();
|
|
16000
15916
|
init_process_cancel();
|
|
16001
15917
|
init_activation_ledger_topology();
|
|
15918
|
+
init_host_session_record();
|
|
16002
15919
|
init_settlement();
|
|
16003
15920
|
init_terminal();
|
|
16004
15921
|
init_auto_resume();
|
|
@@ -16032,20 +15949,20 @@ var init_seat_ticket_binding = __esm({
|
|
|
16032
15949
|
});
|
|
16033
15950
|
|
|
16034
15951
|
// src/public-cli/machine-method-skills.ts
|
|
16035
|
-
import { accessSync, constants as constants2, statSync as
|
|
15952
|
+
import { accessSync, constants as constants2, statSync as statSync4 } from "node:fs";
|
|
16036
15953
|
import { lstat as lstat6, mkdir as mkdir4, symlink } from "node:fs/promises";
|
|
16037
|
-
import { join as
|
|
16038
|
-
import { spawnSync } from "node:child_process";
|
|
15954
|
+
import { join as join30 } from "node:path";
|
|
15955
|
+
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
16039
15956
|
function skillRoot(home) {
|
|
16040
|
-
return
|
|
15957
|
+
return join30(home, ".agents/skills");
|
|
16041
15958
|
}
|
|
16042
15959
|
function installedMethodSkillPath(home, name) {
|
|
16043
15960
|
return installedSkillPath(skillRoot(home), name);
|
|
16044
15961
|
}
|
|
16045
15962
|
function installedSkillPath(root, name) {
|
|
16046
|
-
const path =
|
|
15963
|
+
const path = join30(root, name, "SKILL.md");
|
|
16047
15964
|
try {
|
|
16048
|
-
if (!
|
|
15965
|
+
if (!statSync4(path).isFile()) return void 0;
|
|
16049
15966
|
accessSync(path, constants2.R_OK);
|
|
16050
15967
|
return path;
|
|
16051
15968
|
} catch (error) {
|
|
@@ -16056,9 +15973,9 @@ function installedSkillPath(root, name) {
|
|
|
16056
15973
|
}
|
|
16057
15974
|
function linkedSkillRoot(home, host) {
|
|
16058
15975
|
if (host === "claude" || host === "claude-code") {
|
|
16059
|
-
return
|
|
15976
|
+
return join30(process.env.CLAUDE_CONFIG_DIR?.trim() || join30(home, ".claude"), "skills");
|
|
16060
15977
|
}
|
|
16061
|
-
if (host === "hermes") return
|
|
15978
|
+
if (host === "hermes") return join30(home, ".hermes/skills");
|
|
16062
15979
|
return void 0;
|
|
16063
15980
|
}
|
|
16064
15981
|
async function occupied(path) {
|
|
@@ -16086,7 +16003,7 @@ async function warnMissingMethodSkills(home, host, role, skills, stdout) {
|
|
|
16086
16003
|
}
|
|
16087
16004
|
}
|
|
16088
16005
|
function runSkillsCli(args, home) {
|
|
16089
|
-
const result =
|
|
16006
|
+
const result = spawnSync2("npx", ["--yes", "skills", ...args], {
|
|
16090
16007
|
stdio: "inherit",
|
|
16091
16008
|
env: { ...process.env, HOME: home }
|
|
16092
16009
|
});
|
|
@@ -16115,7 +16032,7 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
16115
16032
|
const missingBySource = /* @__PURE__ */ new Map();
|
|
16116
16033
|
let unsourced = false;
|
|
16117
16034
|
for (const name of packagedMethodSkillNames()) {
|
|
16118
|
-
const path =
|
|
16035
|
+
const path = join30(canonical, name);
|
|
16119
16036
|
if (await occupied(path)) {
|
|
16120
16037
|
warnOccupied(path, stdout);
|
|
16121
16038
|
continue;
|
|
@@ -16139,15 +16056,15 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
16139
16056
|
const root = linkedSkillRoot(home, host);
|
|
16140
16057
|
const binaryFromHome = host === "claude-code" ? HEADLESS_HOST_DESCRIPTIONS.claude.binaryFromHome : HOST_DESCRIPTIONS.hermes.binaryFromHome;
|
|
16141
16058
|
try {
|
|
16142
|
-
accessSync(
|
|
16059
|
+
accessSync(join30(home, ...binaryFromHome), constants2.X_OK);
|
|
16143
16060
|
} catch (error) {
|
|
16144
16061
|
if (["ENOENT", "ENOTDIR", "EACCES"].includes(error.code ?? "")) continue;
|
|
16145
16062
|
throw error;
|
|
16146
16063
|
}
|
|
16147
16064
|
for (const name of packagedMethodSkillNames()) {
|
|
16148
|
-
const target =
|
|
16065
|
+
const target = join30(canonical, name);
|
|
16149
16066
|
if (installedMethodSkillPath(home, name) === void 0) continue;
|
|
16150
|
-
const link =
|
|
16067
|
+
const link = join30(root, name);
|
|
16151
16068
|
if (await occupied(link)) {
|
|
16152
16069
|
warnOccupied(link, stdout);
|
|
16153
16070
|
continue;
|
|
@@ -16273,11 +16190,11 @@ var init_turn_request = __esm({
|
|
|
16273
16190
|
});
|
|
16274
16191
|
|
|
16275
16192
|
// src/public-cli/countersign-run.ts
|
|
16276
|
-
function
|
|
16193
|
+
function isRecord12(value) {
|
|
16277
16194
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16278
16195
|
}
|
|
16279
16196
|
function isEscalatePayload(payload) {
|
|
16280
|
-
if (!
|
|
16197
|
+
if (!isRecord12(payload)) return false;
|
|
16281
16198
|
return payload.status === "escalate";
|
|
16282
16199
|
}
|
|
16283
16200
|
function courtDiaristPayloadRows(roleOutcome, submissions) {
|
|
@@ -17492,13 +17409,13 @@ var init_instruction_seat_run = __esm({
|
|
|
17492
17409
|
});
|
|
17493
17410
|
|
|
17494
17411
|
// src/analyst-book-key.ts
|
|
17495
|
-
import { statSync as
|
|
17412
|
+
import { statSync as statSync5 } from "node:fs";
|
|
17496
17413
|
import { isAbsolute as isAbsolute8 } from "node:path";
|
|
17497
17414
|
function resolveAnalystBookKey(projectRoot) {
|
|
17498
17415
|
const identity = physicalPathIdentity(projectRoot);
|
|
17499
17416
|
let stats;
|
|
17500
17417
|
try {
|
|
17501
|
-
stats =
|
|
17418
|
+
stats = statSync5(identity);
|
|
17502
17419
|
} catch (error) {
|
|
17503
17420
|
const code = errnoCode(error);
|
|
17504
17421
|
if (code === "ENOENT" || code === "ENOTDIR") return `root:${identity}`;
|
|
@@ -17527,16 +17444,16 @@ var init_analyst_book_key = __esm({
|
|
|
17527
17444
|
|
|
17528
17445
|
// src/atomic-write.ts
|
|
17529
17446
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
17530
|
-
import { rename as rename3, rm as
|
|
17531
|
-
import { dirname as dirname19, join as
|
|
17447
|
+
import { rename as rename3, rm as rm4, writeFile as writeFile8 } from "node:fs/promises";
|
|
17448
|
+
import { dirname as dirname19, join as join31 } from "node:path";
|
|
17532
17449
|
async function writeFileAtomically(destination, contents) {
|
|
17533
17450
|
const parent = dirname19(destination);
|
|
17534
|
-
const temporary =
|
|
17451
|
+
const temporary = join31(parent, `.atomic-write-${randomUUID7()}.tmp`);
|
|
17535
17452
|
try {
|
|
17536
|
-
await
|
|
17453
|
+
await writeFile8(temporary, contents);
|
|
17537
17454
|
await rename3(temporary, destination);
|
|
17538
17455
|
} catch (error) {
|
|
17539
|
-
await
|
|
17456
|
+
await rm4(temporary, { force: true }).catch(() => void 0);
|
|
17540
17457
|
throw error;
|
|
17541
17458
|
}
|
|
17542
17459
|
}
|
|
@@ -17547,8 +17464,8 @@ var init_atomic_write = __esm({
|
|
|
17547
17464
|
});
|
|
17548
17465
|
|
|
17549
17466
|
// src/analyst-index.ts
|
|
17550
|
-
import { open as open2, readFile as
|
|
17551
|
-
import { dirname as dirname20, join as
|
|
17467
|
+
import { open as open2, readFile as readFile17, unlink as unlink4 } from "node:fs/promises";
|
|
17468
|
+
import { dirname as dirname20, join as join32 } from "node:path";
|
|
17552
17469
|
function sleep(ms) {
|
|
17553
17470
|
return new Promise((resolve22) => {
|
|
17554
17471
|
setTimeout(resolve22, ms);
|
|
@@ -17557,7 +17474,7 @@ function sleep(ms) {
|
|
|
17557
17474
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
17558
17475
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
17559
17476
|
ensureRealDirectoryTree(ledgerHome, dirname20(indexPath));
|
|
17560
|
-
const lockPath =
|
|
17477
|
+
const lockPath = join32(dirname20(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
17561
17478
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
17562
17479
|
const startedAt = Date.now();
|
|
17563
17480
|
while (true) {
|
|
@@ -17584,7 +17501,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
17584
17501
|
}
|
|
17585
17502
|
}
|
|
17586
17503
|
function analystLibraryIndexPath(ledgerHome) {
|
|
17587
|
-
return
|
|
17504
|
+
return join32(ledgerHome, "analyst", "library-index.json");
|
|
17588
17505
|
}
|
|
17589
17506
|
function rowFromIssueMetricsPage(page) {
|
|
17590
17507
|
return {
|
|
@@ -17675,7 +17592,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
|
|
|
17675
17592
|
const path = analystLibraryIndexPath(ledgerHome);
|
|
17676
17593
|
let raw;
|
|
17677
17594
|
try {
|
|
17678
|
-
raw = await
|
|
17595
|
+
raw = await readFile17(path, "utf8");
|
|
17679
17596
|
} catch (error) {
|
|
17680
17597
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
|
|
17681
17598
|
return void 0;
|
|
@@ -17879,15 +17796,15 @@ var init_analyst_cohort = __esm({
|
|
|
17879
17796
|
});
|
|
17880
17797
|
|
|
17881
17798
|
// src/analyst-ledger.ts
|
|
17882
|
-
import { readdir as
|
|
17883
|
-
import { basename as basename8, join as
|
|
17799
|
+
import { readdir as readdir6, readFile as readFile18 } from "node:fs/promises";
|
|
17800
|
+
import { basename as basename8, join as join33 } from "node:path";
|
|
17884
17801
|
function isMissingPathError6(error) {
|
|
17885
17802
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
17886
17803
|
}
|
|
17887
17804
|
function errorText3(error) {
|
|
17888
17805
|
return error instanceof Error ? error.message : String(error);
|
|
17889
17806
|
}
|
|
17890
|
-
function
|
|
17807
|
+
function isRecord13(value) {
|
|
17891
17808
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17892
17809
|
}
|
|
17893
17810
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
@@ -17909,7 +17826,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
|
|
|
17909
17826
|
}
|
|
17910
17827
|
}
|
|
17911
17828
|
async function classifyGhostCandidate(input) {
|
|
17912
|
-
const autopsy = await autopsyWriterLock(
|
|
17829
|
+
const autopsy = await autopsyWriterLock(join33(input.runDirectory, "writer.lock"));
|
|
17913
17830
|
const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
|
|
17914
17831
|
if (leaseCheck === void 0) return { kind: "live" };
|
|
17915
17832
|
return {
|
|
@@ -17928,7 +17845,7 @@ function parseRunDirectoryName2(name) {
|
|
|
17928
17845
|
}
|
|
17929
17846
|
async function listLedgerBookNames(booksRoot) {
|
|
17930
17847
|
try {
|
|
17931
|
-
const entries = await
|
|
17848
|
+
const entries = await readdir6(booksRoot, { withFileTypes: true });
|
|
17932
17849
|
return entries.filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
17933
17850
|
} catch (error) {
|
|
17934
17851
|
if (isMissingPathError6(error)) return [];
|
|
@@ -17938,13 +17855,13 @@ async function listLedgerBookNames(booksRoot) {
|
|
|
17938
17855
|
async function readInvocationScopeFields(runDirectory) {
|
|
17939
17856
|
let raw;
|
|
17940
17857
|
try {
|
|
17941
|
-
raw = await
|
|
17858
|
+
raw = await readFile18(join33(runDirectory, "invocation.json"), "utf8");
|
|
17942
17859
|
} catch (error) {
|
|
17943
17860
|
if (isMissingPathError6(error)) return void 0;
|
|
17944
17861
|
throw error;
|
|
17945
17862
|
}
|
|
17946
17863
|
const parsed = JSON.parse(raw);
|
|
17947
|
-
if (!
|
|
17864
|
+
if (!isRecord13(parsed)) return void 0;
|
|
17948
17865
|
if (typeof parsed.projectRoot !== "string" || parsed.projectRoot.trim() === "") {
|
|
17949
17866
|
return void 0;
|
|
17950
17867
|
}
|
|
@@ -17971,15 +17888,15 @@ function decideIssueScope(input) {
|
|
|
17971
17888
|
}
|
|
17972
17889
|
async function resolveSessionFile(runDirectory) {
|
|
17973
17890
|
try {
|
|
17974
|
-
const raw = await
|
|
17891
|
+
const raw = await readFile18(join33(runDirectory, "invocation.json"), "utf8");
|
|
17975
17892
|
const parsed = JSON.parse(raw);
|
|
17976
|
-
if (
|
|
17893
|
+
if (isRecord13(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
17977
17894
|
return parsed.sessionFile;
|
|
17978
17895
|
}
|
|
17979
17896
|
} catch (error) {
|
|
17980
17897
|
if (!isMissingPathError6(error)) throw error;
|
|
17981
17898
|
}
|
|
17982
|
-
return
|
|
17899
|
+
return join33(runDirectory, "session", "session.jsonl");
|
|
17983
17900
|
}
|
|
17984
17901
|
function attributeSessionRowsForRun(input) {
|
|
17985
17902
|
if (pathContainedIn(input.runDirectory, input.sessionFile)) {
|
|
@@ -18171,9 +18088,9 @@ async function classifyScopedRun(input) {
|
|
|
18171
18088
|
}
|
|
18172
18089
|
let gateCycles;
|
|
18173
18090
|
try {
|
|
18174
|
-
const parentSessionFile =
|
|
18091
|
+
const parentSessionFile = join33(input.runDirectory, "session", "session.jsonl");
|
|
18175
18092
|
gateCycles = await readAnalystGateCyclesFromAuditorRoles(
|
|
18176
|
-
|
|
18093
|
+
join33(input.runDirectory, "session", "auditor-roles"),
|
|
18177
18094
|
{ parentSessionFile }
|
|
18178
18095
|
);
|
|
18179
18096
|
} catch (error) {
|
|
@@ -18208,7 +18125,7 @@ async function classifyScopedRun(input) {
|
|
|
18208
18125
|
async function scanAnalystIssueRuns(input) {
|
|
18209
18126
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
18210
18127
|
const scopeTicketNumber = input.ticketNumber;
|
|
18211
|
-
const booksRoot =
|
|
18128
|
+
const booksRoot = join33(ledgerHome, "books");
|
|
18212
18129
|
let wholeBook = false;
|
|
18213
18130
|
let scopeRootIdentity;
|
|
18214
18131
|
let bookNames;
|
|
@@ -18241,7 +18158,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
18241
18158
|
const ghostLegs = [];
|
|
18242
18159
|
const scopeConflicts = [];
|
|
18243
18160
|
for (const book of bookNames) {
|
|
18244
|
-
const bookDir =
|
|
18161
|
+
const bookDir = join33(booksRoot, book);
|
|
18245
18162
|
let runDirectories;
|
|
18246
18163
|
try {
|
|
18247
18164
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
@@ -18311,7 +18228,7 @@ var init_analyst_ledger = __esm({
|
|
|
18311
18228
|
});
|
|
18312
18229
|
|
|
18313
18230
|
// src/analyst-metric-families/acceptance-success-rework.ts
|
|
18314
|
-
function
|
|
18231
|
+
function isRecord14(value) {
|
|
18315
18232
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18316
18233
|
}
|
|
18317
18234
|
function wallMsFromSpan(span) {
|
|
@@ -18320,21 +18237,21 @@ function wallMsFromSpan(span) {
|
|
|
18320
18237
|
function findCollectorGroups(body) {
|
|
18321
18238
|
if (Array.isArray(body.groups)) return body.groups;
|
|
18322
18239
|
const receipt = body.receipt;
|
|
18323
|
-
if (
|
|
18240
|
+
if (isRecord14(receipt) && Array.isArray(receipt.groups)) return receipt.groups;
|
|
18324
18241
|
const outcome = body.outcome;
|
|
18325
|
-
if (
|
|
18242
|
+
if (isRecord14(outcome)) {
|
|
18326
18243
|
const facts = outcome.decisiveFacts;
|
|
18327
|
-
if (
|
|
18244
|
+
if (isRecord14(facts) && Array.isArray(facts.groups)) return facts.groups;
|
|
18328
18245
|
}
|
|
18329
18246
|
return void 0;
|
|
18330
18247
|
}
|
|
18331
18248
|
function extractStatus(body) {
|
|
18332
18249
|
const outcome = body.outcome;
|
|
18333
|
-
if (
|
|
18250
|
+
if (isRecord14(outcome) && typeof outcome.status === "string" && outcome.status.trim() !== "") {
|
|
18334
18251
|
return outcome.status;
|
|
18335
18252
|
}
|
|
18336
18253
|
const receipt = body.receipt;
|
|
18337
|
-
if (
|
|
18254
|
+
if (isRecord14(receipt) && typeof receipt.status === "string" && receipt.status.trim() !== "") {
|
|
18338
18255
|
return receipt.status;
|
|
18339
18256
|
}
|
|
18340
18257
|
if (typeof body.status === "string" && body.status.trim() !== "") {
|
|
@@ -18960,15 +18877,15 @@ var init_leg_wall_clock = __esm({
|
|
|
18960
18877
|
});
|
|
18961
18878
|
|
|
18962
18879
|
// src/analyst-metric-families/round-timeline.ts
|
|
18963
|
-
function
|
|
18880
|
+
function isRecord15(value) {
|
|
18964
18881
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18965
18882
|
}
|
|
18966
18883
|
function wallMsFromSpan2(startedAt, endedAt) {
|
|
18967
18884
|
return Date.parse(endedAt) - Date.parse(startedAt);
|
|
18968
18885
|
}
|
|
18969
18886
|
function readClassCount(body) {
|
|
18970
|
-
if (!
|
|
18971
|
-
if (!
|
|
18887
|
+
if (!isRecord15(body.outcome)) return void 0;
|
|
18888
|
+
if (!isRecord15(body.outcome.decisiveFacts)) return void 0;
|
|
18972
18889
|
const classCount = body.outcome.decisiveFacts.classCount;
|
|
18973
18890
|
if (typeof classCount !== "number" || !Number.isFinite(classCount)) {
|
|
18974
18891
|
return void 0;
|
|
@@ -19112,8 +19029,8 @@ var init_analyst_metric_family = __esm({
|
|
|
19112
19029
|
});
|
|
19113
19030
|
|
|
19114
19031
|
// src/analyst-page.ts
|
|
19115
|
-
import { createHash as
|
|
19116
|
-
import { dirname as dirname21, join as
|
|
19032
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
19033
|
+
import { dirname as dirname21, join as join34 } from "node:path";
|
|
19117
19034
|
function analystIssuePageKey(address) {
|
|
19118
19035
|
const parts = ["book", address.bookKey];
|
|
19119
19036
|
if (address.issueNumber !== void 0) {
|
|
@@ -19121,10 +19038,10 @@ function analystIssuePageKey(address) {
|
|
|
19121
19038
|
} else if (address.scopeRootIdentity !== void 0) {
|
|
19122
19039
|
parts.push("root", physicalPathIdentity(address.scopeRootIdentity));
|
|
19123
19040
|
}
|
|
19124
|
-
return
|
|
19041
|
+
return createHash5("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
19125
19042
|
}
|
|
19126
19043
|
function analystIssuePagePath(ledgerHome, address) {
|
|
19127
|
-
return
|
|
19044
|
+
return join34(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
19128
19045
|
}
|
|
19129
19046
|
function analystIssuePageAddressFromPage(page) {
|
|
19130
19047
|
return {
|
|
@@ -19260,7 +19177,7 @@ var init_analyst_page = __esm({
|
|
|
19260
19177
|
});
|
|
19261
19178
|
|
|
19262
19179
|
// src/analyst-entry.ts
|
|
19263
|
-
import { readFile as
|
|
19180
|
+
import { readFile as readFile19 } from "node:fs/promises";
|
|
19264
19181
|
import { Type as Type11 } from "typebox";
|
|
19265
19182
|
function isMissingPathError7(error) {
|
|
19266
19183
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
@@ -19291,7 +19208,7 @@ async function readOrComputeAnalystIssuePage(input, options) {
|
|
|
19291
19208
|
...issueNumber === void 0 && input.bookKey === void 0 ? { scopeRootIdentity: projectRoot } : {}
|
|
19292
19209
|
});
|
|
19293
19210
|
try {
|
|
19294
|
-
const raw = await
|
|
19211
|
+
const raw = await readFile19(pagePath, "utf8");
|
|
19295
19212
|
const page = JSON.parse(raw);
|
|
19296
19213
|
if (cachedPageMatchesRequestedScope(page, { bookKey, ...input })) {
|
|
19297
19214
|
const ghostScan = await scanAnalystIssueRuns({
|
|
@@ -19392,7 +19309,7 @@ async function runAnalystModelGroupsMode(input, home) {
|
|
|
19392
19309
|
scopeRootIdentity: projectRoot
|
|
19393
19310
|
});
|
|
19394
19311
|
try {
|
|
19395
|
-
const raw = await
|
|
19312
|
+
const raw = await readFile19(pagePath, "utf8");
|
|
19396
19313
|
JSON.parse(raw);
|
|
19397
19314
|
} catch (error) {
|
|
19398
19315
|
if (!isMissingPathError7(error)) {
|
|
@@ -19490,7 +19407,7 @@ var init_analyst_entry = __esm({
|
|
|
19490
19407
|
});
|
|
19491
19408
|
|
|
19492
19409
|
// src/public-cli/analyst-run.ts
|
|
19493
|
-
import { readFile as
|
|
19410
|
+
import { readFile as readFile20 } from "node:fs/promises";
|
|
19494
19411
|
import { isAbsolute as isAbsolute9, resolve as resolve14 } from "node:path";
|
|
19495
19412
|
import { Value as Value2 } from "typebox/value";
|
|
19496
19413
|
function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
|
|
@@ -19544,7 +19461,7 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
|
|
|
19544
19461
|
const absolute = isAbsolute9(sourcePath) ? sourcePath : resolve14(sourcePath);
|
|
19545
19462
|
let bytes;
|
|
19546
19463
|
try {
|
|
19547
|
-
bytes = await
|
|
19464
|
+
bytes = await readFile20(absolute);
|
|
19548
19465
|
} catch (error) {
|
|
19549
19466
|
throw new CliUsageError(
|
|
19550
19467
|
`analyst sweep attachment is not a readable regular file: ${sourcePath}`,
|
|
@@ -19664,7 +19581,7 @@ __export(cli_exports, {
|
|
|
19664
19581
|
runAkRole: () => runAkRole
|
|
19665
19582
|
});
|
|
19666
19583
|
import { realpath as realpath5 } from "node:fs/promises";
|
|
19667
|
-
import { join as
|
|
19584
|
+
import { join as join35 } from "node:path";
|
|
19668
19585
|
function publicSeatArgv(owner) {
|
|
19669
19586
|
return {
|
|
19670
19587
|
parse: (args) => parsePublicSeatArgv(owner, args),
|
|
@@ -19803,7 +19720,7 @@ function resolveHome(env) {
|
|
|
19803
19720
|
return env.home ?? packageMachineHome();
|
|
19804
19721
|
}
|
|
19805
19722
|
function resolveAgentDir(env, home) {
|
|
19806
|
-
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
19723
|
+
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join35(home, ".pi", "agent");
|
|
19807
19724
|
}
|
|
19808
19725
|
function parseThinking(value) {
|
|
19809
19726
|
return value;
|
|
@@ -20575,7 +20492,7 @@ __export(public_role_summons_exports, {
|
|
|
20575
20492
|
import { execFile as execFile3 } from "node:child_process";
|
|
20576
20493
|
import { existsSync as existsSync9 } from "node:fs";
|
|
20577
20494
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
20578
|
-
import { join as
|
|
20495
|
+
import { join as join36 } from "node:path";
|
|
20579
20496
|
import { promisify as promisify3 } from "node:util";
|
|
20580
20497
|
function createCapturingIo() {
|
|
20581
20498
|
const chunks = [];
|
|
@@ -20599,7 +20516,7 @@ function parentDir(path) {
|
|
|
20599
20516
|
function walkPackageRoot(start) {
|
|
20600
20517
|
let dir = start;
|
|
20601
20518
|
for (let i = 0; i < 12; i += 1) {
|
|
20602
|
-
if (existsSync9(
|
|
20519
|
+
if (existsSync9(join36(dir, "package.json")) && existsSync9(join36(dir, "souls"))) {
|
|
20603
20520
|
return dir;
|
|
20604
20521
|
}
|
|
20605
20522
|
const parent = parentDir(dir);
|
|
@@ -20715,7 +20632,7 @@ async function createSummonEnv(options, afterHost) {
|
|
|
20715
20632
|
async function summonPublicRole(options) {
|
|
20716
20633
|
const packageRoot = resolveSummonsPackageRoot(options.packageRoot);
|
|
20717
20634
|
const home = await resolveSummonHome(options);
|
|
20718
|
-
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
20635
|
+
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join36(home, ".pi", "agent");
|
|
20719
20636
|
const {
|
|
20720
20637
|
loadCredentialProviders: loadCredentialProviders2,
|
|
20721
20638
|
loadPublicCliConfig: loadPublicCliConfig2,
|
|
@@ -21223,7 +21140,7 @@ var init_compliance_transport = __esm({
|
|
|
21223
21140
|
});
|
|
21224
21141
|
|
|
21225
21142
|
// src/role-run-relocation.ts
|
|
21226
|
-
import { join as
|
|
21143
|
+
import { join as join37, sep as sep5 } from "node:path";
|
|
21227
21144
|
function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
|
|
21228
21145
|
if (typeof value !== "string") return value;
|
|
21229
21146
|
if (value === oldRunDirectory) return newRunDirectory;
|
|
@@ -21351,8 +21268,8 @@ __export(run_lifecycle_exports, {
|
|
|
21351
21268
|
renderResumeCommand: () => renderResumeCommand,
|
|
21352
21269
|
writeRoleRunState: () => writeRoleRunState
|
|
21353
21270
|
});
|
|
21354
|
-
import { chmod, lstat as lstat7, open as open3, readdir as
|
|
21355
|
-
import { basename as basename9, join as
|
|
21271
|
+
import { chmod, lstat as lstat7, open as open3, readdir as readdir7, readFile as readFile21, unlink as unlink5, writeFile as writeFile9 } from "node:fs/promises";
|
|
21272
|
+
import { basename as basename9, join as join38 } from "node:path";
|
|
21356
21273
|
function buildAutoResumeContinuationPrompt(options) {
|
|
21357
21274
|
return appendEngineSessionMaterial(
|
|
21358
21275
|
[RESUME_TRANSPORT_ENVELOPE],
|
|
@@ -21377,8 +21294,8 @@ function renderResumeCommand(runId) {
|
|
|
21377
21294
|
}
|
|
21378
21295
|
async function writeRoleRunState(runDirectory, record4) {
|
|
21379
21296
|
const payload = { ...record4, runDirectory };
|
|
21380
|
-
await
|
|
21381
|
-
|
|
21297
|
+
await writeFile9(
|
|
21298
|
+
join38(runDirectory, RUN_STATE_FILE),
|
|
21382
21299
|
`${JSON.stringify(payload, null, 2)}
|
|
21383
21300
|
`,
|
|
21384
21301
|
"utf8"
|
|
@@ -21428,9 +21345,9 @@ function parseCurrentCourtState(raw) {
|
|
|
21428
21345
|
async function readRoleRunStateRaw(runDirectory) {
|
|
21429
21346
|
let raw;
|
|
21430
21347
|
try {
|
|
21431
|
-
raw = JSON.parse(await
|
|
21348
|
+
raw = JSON.parse(await readFile21(join38(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
21432
21349
|
} catch (error) {
|
|
21433
|
-
if (
|
|
21350
|
+
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
21434
21351
|
throw error;
|
|
21435
21352
|
}
|
|
21436
21353
|
return raw;
|
|
@@ -21521,8 +21438,8 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
|
|
|
21521
21438
|
...disk.resumable === void 0 ? {} : { resumable: disk.resumable },
|
|
21522
21439
|
...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
|
|
21523
21440
|
};
|
|
21524
|
-
await
|
|
21525
|
-
|
|
21441
|
+
await writeFile9(
|
|
21442
|
+
join38(runDirectory, RUN_STATE_FILE),
|
|
21526
21443
|
`${JSON.stringify(payload, null, 2)}
|
|
21527
21444
|
`,
|
|
21528
21445
|
"utf8"
|
|
@@ -21675,7 +21592,7 @@ function describeErrorIdentity(error) {
|
|
|
21675
21592
|
const message = typeof candidate?.message === "string" && candidate.message !== "" ? `: ${candidate.message}` : "";
|
|
21676
21593
|
return `${name}${code}${message}`;
|
|
21677
21594
|
}
|
|
21678
|
-
function
|
|
21595
|
+
function errorCodeOf(error) {
|
|
21679
21596
|
return error.code;
|
|
21680
21597
|
}
|
|
21681
21598
|
function isProcessAlive(pid) {
|
|
@@ -21683,15 +21600,15 @@ function isProcessAlive(pid) {
|
|
|
21683
21600
|
process.kill(pid, 0);
|
|
21684
21601
|
return true;
|
|
21685
21602
|
} catch (error) {
|
|
21686
|
-
return
|
|
21603
|
+
return errorCodeOf(error) !== "ESRCH";
|
|
21687
21604
|
}
|
|
21688
21605
|
}
|
|
21689
21606
|
async function autopsyWriterLock(lockPath) {
|
|
21690
21607
|
let content;
|
|
21691
21608
|
try {
|
|
21692
|
-
content = await
|
|
21609
|
+
content = await readFile21(lockPath, "utf8");
|
|
21693
21610
|
} catch (error) {
|
|
21694
|
-
if (
|
|
21611
|
+
if (errorCodeOf(error) === "ENOENT") return { verdict: "absent" };
|
|
21695
21612
|
return { verdict: "unknown", reason: "unreadable", readFailure: error };
|
|
21696
21613
|
}
|
|
21697
21614
|
const normalized = content.trim();
|
|
@@ -21723,8 +21640,8 @@ async function reclaimStaleWriterLock(lockPath, runDirectory) {
|
|
|
21723
21640
|
await unlink5(lockPath);
|
|
21724
21641
|
return { reclaimed: true };
|
|
21725
21642
|
} catch (error) {
|
|
21726
|
-
if (
|
|
21727
|
-
if (
|
|
21643
|
+
if (errorCodeOf(error) === "ENOENT") return { reclaimed: false };
|
|
21644
|
+
if (errorCodeOf(error) !== "EACCES") throw error;
|
|
21728
21645
|
await chmod(runDirectory, 493);
|
|
21729
21646
|
return { reclaimed: false, eaccesFailure: error };
|
|
21730
21647
|
}
|
|
@@ -21748,7 +21665,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
21748
21665
|
},
|
|
21749
21666
|
relocate(nextRunDirectory) {
|
|
21750
21667
|
currentRunDirectory = nextRunDirectory;
|
|
21751
|
-
currentLockPath =
|
|
21668
|
+
currentLockPath = join38(nextRunDirectory, WRITER_LOCK_FILE);
|
|
21752
21669
|
},
|
|
21753
21670
|
async release() {
|
|
21754
21671
|
if (released) return;
|
|
@@ -21757,7 +21674,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
21757
21674
|
try {
|
|
21758
21675
|
await unlink5(currentLockPath);
|
|
21759
21676
|
} catch (error) {
|
|
21760
|
-
if (
|
|
21677
|
+
if (errorCodeOf(error) === "EACCES") {
|
|
21761
21678
|
try {
|
|
21762
21679
|
await chmod(currentRunDirectory, 493);
|
|
21763
21680
|
await unlink5(currentLockPath);
|
|
@@ -21787,17 +21704,17 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
21787
21704
|
};
|
|
21788
21705
|
const reportReadFailure = (error) => {
|
|
21789
21706
|
reportDiagnostic(
|
|
21790
|
-
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${
|
|
21707
|
+
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join38(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
21791
21708
|
);
|
|
21792
21709
|
};
|
|
21793
|
-
const lockPath =
|
|
21710
|
+
const lockPath = join38(runDirectory, WRITER_LOCK_FILE);
|
|
21794
21711
|
let lastAutopsy = { verdict: "absent" };
|
|
21795
21712
|
let lastReclaimFailure;
|
|
21796
21713
|
for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
|
|
21797
21714
|
try {
|
|
21798
21715
|
return await createWriterLease(lockPath, runDirectory, reportCleanupFailure);
|
|
21799
21716
|
} catch (error) {
|
|
21800
|
-
if (
|
|
21717
|
+
if (errorCodeOf(error) !== "EEXIST") throw error;
|
|
21801
21718
|
}
|
|
21802
21719
|
lastAutopsy = await autopsyWriterLock(lockPath);
|
|
21803
21720
|
if (lastAutopsy.verdict === "unknown" && lastAutopsy.reason === "unreadable") {
|
|
@@ -21845,12 +21762,12 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
21845
21762
|
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
21846
21763
|
if (runId.trim() === "") return void 0;
|
|
21847
21764
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
21848
|
-
const booksRoot =
|
|
21765
|
+
const booksRoot = join38(ledgerHome, "books");
|
|
21849
21766
|
let bookKeys;
|
|
21850
21767
|
try {
|
|
21851
|
-
bookKeys = await
|
|
21768
|
+
bookKeys = await readdir7(booksRoot);
|
|
21852
21769
|
} catch (error) {
|
|
21853
|
-
if (
|
|
21770
|
+
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
21854
21771
|
throw error;
|
|
21855
21772
|
}
|
|
21856
21773
|
const matches = [];
|
|
@@ -21861,7 +21778,7 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
|
21861
21778
|
try {
|
|
21862
21779
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
21863
21780
|
} catch (error) {
|
|
21864
|
-
if (
|
|
21781
|
+
if (errorCodeOf(error) === "ENOENT") continue;
|
|
21865
21782
|
throw error;
|
|
21866
21783
|
}
|
|
21867
21784
|
for (const runDirectory of runDirectories) {
|
|
@@ -21886,10 +21803,10 @@ async function readRunParentPath(runDirectory) {
|
|
|
21886
21803
|
let raw;
|
|
21887
21804
|
try {
|
|
21888
21805
|
raw = JSON.parse(
|
|
21889
|
-
await
|
|
21806
|
+
await readFile21(join38(runDirectory, "admitted-request.json"), "utf8")
|
|
21890
21807
|
);
|
|
21891
21808
|
} catch (error) {
|
|
21892
|
-
if (
|
|
21809
|
+
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
21893
21810
|
throw error;
|
|
21894
21811
|
}
|
|
21895
21812
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
@@ -21907,12 +21824,12 @@ async function readRunParentPath(runDirectory) {
|
|
|
21907
21824
|
async function runHasFormedSessionPrincipal(runDirectory) {
|
|
21908
21825
|
const disk = await readRoleRunStateDisk(runDirectory);
|
|
21909
21826
|
if (disk === void 0) return false;
|
|
21910
|
-
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile :
|
|
21827
|
+
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : join38(disk.principalWire.sessionDirectory, "session.jsonl");
|
|
21911
21828
|
try {
|
|
21912
21829
|
const stat2 = await lstat7(sessionFile);
|
|
21913
21830
|
return stat2.isFile() && !stat2.isSymbolicLink();
|
|
21914
21831
|
} catch (error) {
|
|
21915
|
-
if (
|
|
21832
|
+
if (errorCodeOf(error) === "ENOENT") return false;
|
|
21916
21833
|
throw error;
|
|
21917
21834
|
}
|
|
21918
21835
|
}
|
|
@@ -21925,10 +21842,10 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
21925
21842
|
let runDirectories;
|
|
21926
21843
|
try {
|
|
21927
21844
|
runDirectories = await listBookRunDirectories(
|
|
21928
|
-
input.ticketNumber === void 0 ? bookDir :
|
|
21845
|
+
input.ticketNumber === void 0 ? bookDir : join38(bookDir, String(input.ticketNumber))
|
|
21929
21846
|
);
|
|
21930
21847
|
} catch (error) {
|
|
21931
|
-
if (
|
|
21848
|
+
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
21932
21849
|
throw error;
|
|
21933
21850
|
}
|
|
21934
21851
|
const suffix = `@${input.role}`;
|
|
@@ -22052,7 +21969,7 @@ async function loadResumableRunRecord(home, runId, authority, allowUnformedAdmit
|
|
|
22052
21969
|
let sourceRun;
|
|
22053
21970
|
try {
|
|
22054
21971
|
const raw = JSON.parse(
|
|
22055
|
-
await
|
|
21972
|
+
await readFile21(run.admittedRequestPath, "utf8")
|
|
22056
21973
|
);
|
|
22057
21974
|
if (raw !== null && typeof raw === "object" && !Array.isArray(raw)) {
|
|
22058
21975
|
const record4 = raw;
|
|
@@ -22175,7 +22092,7 @@ async function loadResumableRunRecord(home, runId, authority, allowUnformedAdmit
|
|
|
22175
22092
|
let model;
|
|
22176
22093
|
try {
|
|
22177
22094
|
const invocationRaw = JSON.parse(
|
|
22178
|
-
await
|
|
22095
|
+
await readFile21(join38(run.runDirectory, "invocation.json"), "utf8")
|
|
22179
22096
|
);
|
|
22180
22097
|
if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
|
|
22181
22098
|
const rec = invocationRaw;
|
|
@@ -22559,7 +22476,7 @@ var init_run_lifecycle = __esm({
|
|
|
22559
22476
|
});
|
|
22560
22477
|
|
|
22561
22478
|
// src/submission-ledger.ts
|
|
22562
|
-
import { join as
|
|
22479
|
+
import { join as join39 } from "node:path";
|
|
22563
22480
|
function runIdentity(context) {
|
|
22564
22481
|
const directory = runDirectoryFromHostContext(context);
|
|
22565
22482
|
if (directory !== void 0) {
|
|
@@ -22581,7 +22498,7 @@ async function submissionRecordFile(cwd, runId, scope) {
|
|
|
22581
22498
|
if (sessionParent === void 0) {
|
|
22582
22499
|
const discoveredRun = await findRunDirectoryById(scope.home, runId);
|
|
22583
22500
|
if (discoveredRun === void 0) return void 0;
|
|
22584
|
-
sessionParent =
|
|
22501
|
+
sessionParent = join39(discoveredRun, "session", "session.jsonl");
|
|
22585
22502
|
}
|
|
22586
22503
|
return resolveSitianRecordPathInLedger({
|
|
22587
22504
|
level: "event",
|
|
@@ -22774,12 +22691,12 @@ async function restoreState(cwd, runId, scope) {
|
|
|
22774
22691
|
}
|
|
22775
22692
|
function sessionParentFromHostContext(context) {
|
|
22776
22693
|
const runDirectory = runDirectoryFromHostContext(context);
|
|
22777
|
-
if (runDirectory !== void 0) return
|
|
22694
|
+
if (runDirectory !== void 0) return join39(runDirectory, "session", "session.jsonl");
|
|
22778
22695
|
const sessionFile = context.sessionManager.getSessionFile?.();
|
|
22779
22696
|
if (typeof sessionFile === "string" && sessionFile.length > 0) return sessionFile;
|
|
22780
22697
|
const sessionDir = context.sessionManager.getSessionDir?.();
|
|
22781
22698
|
if (typeof sessionDir === "string" && sessionDir.length > 0) {
|
|
22782
|
-
return
|
|
22699
|
+
return join39(sessionDir, "session.jsonl");
|
|
22783
22700
|
}
|
|
22784
22701
|
return void 0;
|
|
22785
22702
|
}
|
|
@@ -22958,8 +22875,8 @@ var init_submission_ledger = __esm({
|
|
|
22958
22875
|
});
|
|
22959
22876
|
|
|
22960
22877
|
// src/archivist-record-topology.ts
|
|
22961
|
-
import { createHash as
|
|
22962
|
-
import { join as
|
|
22878
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
22879
|
+
import { join as join42 } from "node:path";
|
|
22963
22880
|
function resolveNavigatorWorkSubjectPlacement(input) {
|
|
22964
22881
|
let ledgerHome;
|
|
22965
22882
|
if (input.parentSessionFile !== void 0 && input.parentSessionFile.length > 0) {
|
|
@@ -22969,10 +22886,10 @@ function resolveNavigatorWorkSubjectPlacement(input) {
|
|
|
22969
22886
|
}
|
|
22970
22887
|
}
|
|
22971
22888
|
ledgerHome ??= resolveActivationLedgerHome(input.home);
|
|
22972
|
-
const digest =
|
|
22889
|
+
const digest = createHash6("sha256").update(input.subject).digest("hex").slice(0, 32);
|
|
22973
22890
|
return {
|
|
22974
22891
|
ledgerHome,
|
|
22975
|
-
sessionDir:
|
|
22892
|
+
sessionDir: join42(
|
|
22976
22893
|
activationBookDirectory(ledgerHome, resolveBookKeyFromGit(input.cwd)),
|
|
22977
22894
|
NAVIGATOR_RECORD_KIND,
|
|
22978
22895
|
digest
|
|
@@ -23034,20 +22951,20 @@ __export(archivist_record_entry_exports, {
|
|
|
23034
22951
|
resolveNavigatorWorkSubjectPlacement: () => resolveNavigatorWorkSubjectPlacement
|
|
23035
22952
|
});
|
|
23036
22953
|
import {
|
|
23037
|
-
closeSync,
|
|
22954
|
+
closeSync as closeSync2,
|
|
23038
22955
|
existsSync as existsSync12,
|
|
23039
|
-
openSync,
|
|
23040
|
-
readdirSync as
|
|
22956
|
+
openSync as openSync2,
|
|
22957
|
+
readdirSync as readdirSync3,
|
|
23041
22958
|
readFileSync as readFileSync4,
|
|
23042
22959
|
readSync,
|
|
23043
22960
|
realpathSync as realpathSync4,
|
|
23044
|
-
statSync as
|
|
23045
|
-
writeFileSync as
|
|
22961
|
+
statSync as statSync7,
|
|
22962
|
+
writeFileSync as writeFileSync3
|
|
23046
22963
|
} from "node:fs";
|
|
23047
|
-
import { dirname as dirname23, resolve as resolve17, join as
|
|
22964
|
+
import { dirname as dirname23, resolve as resolve17, join as join43 } from "node:path";
|
|
23048
22965
|
import { StringDecoder } from "node:string_decoder";
|
|
23049
22966
|
function readCurrentSession(sessionDir) {
|
|
23050
|
-
const ledger =
|
|
22967
|
+
const ledger = join43(sessionDir, CURRENT_SESSION_LEDGER);
|
|
23051
22968
|
try {
|
|
23052
22969
|
const value = JSON.parse(readFileSync4(ledger, "utf8"));
|
|
23053
22970
|
if (typeof value !== "object" || value === null || typeof value.sessionFile !== "string" || value.sessionFile.length === 0) {
|
|
@@ -23062,9 +22979,9 @@ function readCurrentSession(sessionDir) {
|
|
|
23062
22979
|
}
|
|
23063
22980
|
}
|
|
23064
22981
|
function writeCurrentSession(sessionDir, sessionFile) {
|
|
23065
|
-
const ledger =
|
|
22982
|
+
const ledger = join43(sessionDir, CURRENT_SESSION_LEDGER);
|
|
23066
22983
|
try {
|
|
23067
|
-
|
|
22984
|
+
writeFileSync3(ledger, `${JSON.stringify({ sessionFile })}
|
|
23068
22985
|
`, { flag: "wx" });
|
|
23069
22986
|
} catch (error) {
|
|
23070
22987
|
throw new ActivationLedgerError(
|
|
@@ -23078,10 +22995,10 @@ function isCurrentSessionClaimRace(error) {
|
|
|
23078
22995
|
return errnoCode(error.cause) === "EEXIST";
|
|
23079
22996
|
}
|
|
23080
22997
|
function currentSessionLedgerPath(sessionDir) {
|
|
23081
|
-
return
|
|
22998
|
+
return join43(sessionDir, CURRENT_SESSION_LEDGER);
|
|
23082
22999
|
}
|
|
23083
23000
|
function readBoundedSessionHeader(filePath) {
|
|
23084
|
-
const fd =
|
|
23001
|
+
const fd = openSync2(filePath, "r");
|
|
23085
23002
|
try {
|
|
23086
23003
|
const buffer = Buffer.allocUnsafe(SESSION_HEADER_CHUNK_BYTES);
|
|
23087
23004
|
const decoder2 = new StringDecoder("utf8");
|
|
@@ -23129,7 +23046,7 @@ function readBoundedSessionHeader(filePath) {
|
|
|
23129
23046
|
}
|
|
23130
23047
|
return void 0;
|
|
23131
23048
|
} finally {
|
|
23132
|
-
|
|
23049
|
+
closeSync2(fd);
|
|
23133
23050
|
}
|
|
23134
23051
|
}
|
|
23135
23052
|
function parseSessionHeaderLine(line2) {
|
|
@@ -23155,7 +23072,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
|
|
|
23155
23072
|
const absoluteCwd = resolve17(cwd);
|
|
23156
23073
|
let names;
|
|
23157
23074
|
try {
|
|
23158
|
-
names =
|
|
23075
|
+
names = readdirSync3(absoluteSessionDir);
|
|
23159
23076
|
} catch (error) {
|
|
23160
23077
|
throw new ActivationLedgerError(
|
|
23161
23078
|
`archivist navigator nest is not readable (${sessionDir}): ${errorText(error)}`,
|
|
@@ -23165,10 +23082,10 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
|
|
|
23165
23082
|
const matched = [];
|
|
23166
23083
|
for (const name of names) {
|
|
23167
23084
|
if (!name.endsWith(".jsonl")) continue;
|
|
23168
|
-
const filePath =
|
|
23085
|
+
const filePath = join43(absoluteSessionDir, name);
|
|
23169
23086
|
let st;
|
|
23170
23087
|
try {
|
|
23171
|
-
st =
|
|
23088
|
+
st = statSync7(filePath);
|
|
23172
23089
|
} catch (error) {
|
|
23173
23090
|
throw new ActivationLedgerError(
|
|
23174
23091
|
`archivist navigator session file is not stat-able (${filePath}): ${errorText(error)}`,
|
|
@@ -23277,7 +23194,7 @@ function createRecordSessionOpen(options, host = piRecordSessionHost) {
|
|
|
23277
23194
|
if (!physicallyContainedIn(ledgerHome, parentResolved)) {
|
|
23278
23195
|
throw new Error("Durable record ownership requires a parent session inside the ledger home");
|
|
23279
23196
|
}
|
|
23280
|
-
sessionDir =
|
|
23197
|
+
sessionDir = join43(dirname23(parentResolved), options.kind);
|
|
23281
23198
|
parentSession = parentFile;
|
|
23282
23199
|
mayResumeSameNest = options.kind === WORKER_SUBMISSION_GATE_KIND;
|
|
23283
23200
|
}
|
|
@@ -23309,7 +23226,7 @@ function createRecordSessionOpen(options, host = piRecordSessionHost) {
|
|
|
23309
23226
|
if (file !== void 0 && !existsSync12(file)) {
|
|
23310
23227
|
const header = session.getHeader();
|
|
23311
23228
|
if (header !== null && header.type === "session") {
|
|
23312
|
-
|
|
23229
|
+
writeFileSync3(file, `${JSON.stringify(header)}
|
|
23313
23230
|
`, { flag: "wx" });
|
|
23314
23231
|
session.setSessionFile(file);
|
|
23315
23232
|
}
|
|
@@ -23346,9 +23263,9 @@ import { randomUUID as randomUUID10 } from "node:crypto";
|
|
|
23346
23263
|
init_engine_detour();
|
|
23347
23264
|
init_packaged_role_registry();
|
|
23348
23265
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
23349
|
-
import { appendFile as appendFile3, mkdir as mkdir5, writeFile as
|
|
23266
|
+
import { appendFile as appendFile3, mkdir as mkdir5, writeFile as writeFile10 } from "node:fs/promises";
|
|
23350
23267
|
import { createServer } from "node:net";
|
|
23351
|
-
import { dirname as dirname25, join as
|
|
23268
|
+
import { dirname as dirname25, join as join46 } from "node:path";
|
|
23352
23269
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
23353
23270
|
|
|
23354
23271
|
// src/role-runtime.ts
|
|
@@ -23358,7 +23275,7 @@ init_submission_ledger();
|
|
|
23358
23275
|
init_collector_ledger();
|
|
23359
23276
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
23360
23277
|
import { readFileSync as readFileSync6, writeSync as writeSync2 } from "node:fs";
|
|
23361
|
-
import { join as
|
|
23278
|
+
import { join as join45 } from "node:path";
|
|
23362
23279
|
import { Value as Value4 } from "typebox/value";
|
|
23363
23280
|
|
|
23364
23281
|
// src/activation-trace.ts
|
|
@@ -23406,8 +23323,8 @@ init_activation_ledger_topology();
|
|
|
23406
23323
|
import {
|
|
23407
23324
|
lstatSync as lstatSync2,
|
|
23408
23325
|
realpathSync as realpathSync2,
|
|
23409
|
-
statSync as
|
|
23410
|
-
writeFileSync as
|
|
23326
|
+
statSync as statSync6,
|
|
23327
|
+
writeFileSync as writeFileSync2
|
|
23411
23328
|
} from "node:fs";
|
|
23412
23329
|
import { isAbsolute as isAbsolute11, resolve as resolve15 } from "node:path";
|
|
23413
23330
|
var ActivationSessionFileMissingError = class extends Error {
|
|
@@ -23428,7 +23345,7 @@ function materializeDeferredSessionFile(sessionManager, resolvedFile) {
|
|
|
23428
23345
|
throw new ActivationSessionFileMissingError(resolvedFile);
|
|
23429
23346
|
}
|
|
23430
23347
|
try {
|
|
23431
|
-
|
|
23348
|
+
writeFileSync2(resolvedFile, `${JSON.stringify(header)}
|
|
23432
23349
|
`, { flag: "wx" });
|
|
23433
23350
|
} catch (error) {
|
|
23434
23351
|
if (errnoCode(error) !== "EEXIST") {
|
|
@@ -23481,7 +23398,7 @@ function durableSessionPointer(sessionManager) {
|
|
|
23481
23398
|
}
|
|
23482
23399
|
let info;
|
|
23483
23400
|
try {
|
|
23484
|
-
info =
|
|
23401
|
+
info = statSync6(realFile);
|
|
23485
23402
|
} catch (error) {
|
|
23486
23403
|
throw new Error(
|
|
23487
23404
|
`Workflow role activation failed to stat durable session file (${realFile}): ${errorText(error)}`,
|
|
@@ -23681,8 +23598,8 @@ init_collector_github();
|
|
|
23681
23598
|
// src/collector-handbook.ts
|
|
23682
23599
|
init_atomic_write();
|
|
23683
23600
|
init_activation_ledger_topology();
|
|
23684
|
-
import { readFile as
|
|
23685
|
-
import { join as
|
|
23601
|
+
import { readFile as readFile22 } from "node:fs/promises";
|
|
23602
|
+
import { join as join40, sep as sep6 } from "node:path";
|
|
23686
23603
|
|
|
23687
23604
|
// src/collector-tool-schemas.ts
|
|
23688
23605
|
init_open_tool_schema();
|
|
@@ -23797,7 +23714,7 @@ function resolveCollectorHandbookRoot(sessionPath) {
|
|
|
23797
23714
|
throw new Error(`\u901A\u8FDB\u53F8\u624B\u518C\u62D2\u7EDD\u4E0D\u5B89\u5168 bookKey ${JSON.stringify(bookKey)}`);
|
|
23798
23715
|
}
|
|
23799
23716
|
const ledgerHome = resolveActivationLedgerHomeForPath(sessionPath);
|
|
23800
|
-
const root =
|
|
23717
|
+
const root = join40(activationBookDirectory(ledgerHome, bookKey), "collector-handbook");
|
|
23801
23718
|
return { ledgerHome, bookKey, root };
|
|
23802
23719
|
}
|
|
23803
23720
|
function collectorHandbookRepoFileName(repositoryCanonical) {
|
|
@@ -23809,9 +23726,9 @@ function collectorHandbookRepoFileName(repositoryCanonical) {
|
|
|
23809
23726
|
return `${repositoryCanonical.replaceAll("/", "__")}.md`;
|
|
23810
23727
|
}
|
|
23811
23728
|
function createCollectorHandbookStore(input) {
|
|
23812
|
-
const generalPath =
|
|
23813
|
-
const repoDir =
|
|
23814
|
-
const repoPath =
|
|
23729
|
+
const generalPath = join40(input.handbookRoot, "general.md");
|
|
23730
|
+
const repoDir = join40(input.handbookRoot, "repos");
|
|
23731
|
+
const repoPath = join40(repoDir, collectorHandbookRepoFileName(input.repositoryCanonical));
|
|
23815
23732
|
const assertHandbookBudget = (body, label) => {
|
|
23816
23733
|
const byteLength = Buffer.byteLength(body, "utf8");
|
|
23817
23734
|
if (byteLength > COLLECTOR_HANDBOOK_MAX_BYTES) {
|
|
@@ -23825,7 +23742,7 @@ function createCollectorHandbookStore(input) {
|
|
|
23825
23742
|
ensureRealDirectoryTree(input.ledgerHome, parentDir2);
|
|
23826
23743
|
assertLedgerFileInsideHome(path, input.ledgerHome);
|
|
23827
23744
|
try {
|
|
23828
|
-
const body = await
|
|
23745
|
+
const body = await readFile22(path, "utf8");
|
|
23829
23746
|
assertHandbookBudget(body, "\u6B63\u6587");
|
|
23830
23747
|
return body;
|
|
23831
23748
|
} catch (error) {
|
|
@@ -24823,7 +24740,7 @@ var AUDITOR_TOOL_SPEC = {
|
|
|
24823
24740
|
};
|
|
24824
24741
|
|
|
24825
24742
|
// src/navigator-attendance.ts
|
|
24826
|
-
import { createHash as
|
|
24743
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
24827
24744
|
init_navigator_invocation_identity();
|
|
24828
24745
|
init_packaged_role_registry();
|
|
24829
24746
|
init_activation_ledger_topology();
|
|
@@ -25028,11 +24945,11 @@ init_packaged_role_registry();
|
|
|
25028
24945
|
// src/navigator-work-base.ts
|
|
25029
24946
|
init_atomic_write();
|
|
25030
24947
|
import { existsSync as existsSync10, realpathSync as realpathSync3 } from "node:fs";
|
|
25031
|
-
import { readFile as
|
|
25032
|
-
import { basename as basename10, dirname as dirname22, join as
|
|
24948
|
+
import { readFile as readFile23 } from "node:fs/promises";
|
|
24949
|
+
import { basename as basename10, dirname as dirname22, join as join41, resolve as resolve16 } from "node:path";
|
|
25033
24950
|
var NAVIGATOR_WORK_CONTEXT_BASENAME = "work-context.json";
|
|
25034
24951
|
function navigatorWorkContextFile(sessionDir) {
|
|
25035
|
-
return
|
|
24952
|
+
return join41(sessionDir, NAVIGATOR_WORK_CONTEXT_BASENAME);
|
|
25036
24953
|
}
|
|
25037
24954
|
function isNavigatorWorkContextFile(path) {
|
|
25038
24955
|
const resolved = resolve16(path);
|
|
@@ -25057,7 +24974,7 @@ async function persistNavigatorWorkBase(sessionDir, body) {
|
|
|
25057
24974
|
const next = `${JSON.stringify({ subject: body.subject, authority: body.authority })}
|
|
25058
24975
|
`;
|
|
25059
24976
|
try {
|
|
25060
|
-
const current = await
|
|
24977
|
+
const current = await readFile23(path, "utf8");
|
|
25061
24978
|
if (current === next) return path;
|
|
25062
24979
|
} catch (error) {
|
|
25063
24980
|
if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) {
|
|
@@ -25072,7 +24989,7 @@ async function readNavigatorWorkBase(path) {
|
|
|
25072
24989
|
if (canonical === void 0) return void 0;
|
|
25073
24990
|
let text;
|
|
25074
24991
|
try {
|
|
25075
|
-
text = await
|
|
24992
|
+
text = await readFile23(canonical, "utf8");
|
|
25076
24993
|
} catch (error) {
|
|
25077
24994
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
25078
24995
|
return void 0;
|
|
@@ -25384,7 +25301,7 @@ function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
|
|
|
25384
25301
|
if (provenance === "placeholder") return subjectRoot;
|
|
25385
25302
|
const normalized = subject.trim().replace(/\s+/g, " ");
|
|
25386
25303
|
if (normalized === "") return subjectRoot;
|
|
25387
|
-
return `${subjectRoot}#${
|
|
25304
|
+
return `${subjectRoot}#${createHash7("sha256").update(normalized).digest("hex").slice(0, 32)}`;
|
|
25388
25305
|
}
|
|
25389
25306
|
function navigatorSubjectKeyForInput(subjectRoot, reference, cwd = process.cwd()) {
|
|
25390
25307
|
if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
|
|
@@ -25873,7 +25790,7 @@ init_worker_submission_contracts();
|
|
|
25873
25790
|
init_submission_errors();
|
|
25874
25791
|
init_worker_submission_contracts();
|
|
25875
25792
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
25876
|
-
import { existsSync as existsSync14, lstatSync as lstatSync3, readdirSync as
|
|
25793
|
+
import { existsSync as existsSync14, lstatSync as lstatSync3, readdirSync as readdirSync4, readFileSync as readFileSync5, rmdirSync, rmSync as rmSync2 } from "node:fs";
|
|
25877
25794
|
import { resolve as resolve19 } from "node:path";
|
|
25878
25795
|
var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
|
|
25879
25796
|
var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
|
|
@@ -25939,13 +25856,13 @@ function unsetOwnedHooksPath(file) {
|
|
|
25939
25856
|
function rmOwnedDir(dir) {
|
|
25940
25857
|
const hookPath = resolve19(dir, HOOK_FILE);
|
|
25941
25858
|
if (!ownedHook(hookPath)) return;
|
|
25942
|
-
|
|
25943
|
-
if (existsSync14(dir) &&
|
|
25859
|
+
rmSync2(hookPath, { force: true });
|
|
25860
|
+
if (existsSync14(dir) && readdirSync4(dir).length === 0) rmdirSync(dir);
|
|
25944
25861
|
}
|
|
25945
25862
|
function linkedGitDirs(commonDir) {
|
|
25946
25863
|
const root = resolve19(commonDir, "worktrees");
|
|
25947
25864
|
if (!existsSync14(root)) return [];
|
|
25948
|
-
return
|
|
25865
|
+
return readdirSync4(root).map((name) => resolve19(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
|
|
25949
25866
|
}
|
|
25950
25867
|
function uninstallPackageWorkerHooks(cwd) {
|
|
25951
25868
|
let inside;
|
|
@@ -25963,13 +25880,13 @@ function uninstallPackageWorkerHooks(cwd) {
|
|
|
25963
25880
|
clear(resolve19(commonDir, "config.worktree"));
|
|
25964
25881
|
rmOwnedDir(resolve19(commonDir, HOOKS_DIR));
|
|
25965
25882
|
const legacy = resolve19(commonDir, "hooks", HOOK_FILE);
|
|
25966
|
-
if (ownedHook(legacy))
|
|
25883
|
+
if (ownedHook(legacy)) rmSync2(legacy, { force: true });
|
|
25967
25884
|
for (const gitDir of linkedGitDirs(commonDir)) {
|
|
25968
25885
|
clear(resolve19(gitDir, "config.worktree"));
|
|
25969
25886
|
rmOwnedDir(resolve19(gitDir, HOOKS_DIR));
|
|
25970
25887
|
}
|
|
25971
25888
|
}
|
|
25972
|
-
function
|
|
25889
|
+
function isRecord16(value) {
|
|
25973
25890
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25974
25891
|
}
|
|
25975
25892
|
function unfinishedReasonPresent(details) {
|
|
@@ -25985,7 +25902,7 @@ function readGateState(session) {
|
|
|
25985
25902
|
if (entry.type !== "custom") continue;
|
|
25986
25903
|
if (entry.customType === WORKER_COMMIT_BASELINE_ENTRY_TYPE) {
|
|
25987
25904
|
const data = entry.data;
|
|
25988
|
-
if (
|
|
25905
|
+
if (isRecord16(data) && (data.head === null || typeof data.head === "string")) {
|
|
25989
25906
|
baseline = data.head;
|
|
25990
25907
|
}
|
|
25991
25908
|
} else if (entry.customType === WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE) {
|
|
@@ -26178,11 +26095,11 @@ var FIXER_PHASES = ["plan", "apply"];
|
|
|
26178
26095
|
function isWorkerPhase(value) {
|
|
26179
26096
|
return typeof value === "string" && FIXER_PHASES.includes(value);
|
|
26180
26097
|
}
|
|
26181
|
-
function
|
|
26098
|
+
function isRecord17(value) {
|
|
26182
26099
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26183
26100
|
}
|
|
26184
26101
|
function workerStatusOf(output) {
|
|
26185
|
-
return
|
|
26102
|
+
return isRecord17(output) && typeof output.status === "string" ? output.status : void 0;
|
|
26186
26103
|
}
|
|
26187
26104
|
function deepFreeze2(value) {
|
|
26188
26105
|
if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
|
|
@@ -26868,7 +26785,7 @@ function readDiaristTicketAssertion(submitted) {
|
|
|
26868
26785
|
function readRoleRunCoordinates(ctx, label) {
|
|
26869
26786
|
const runDirectory = runDirectoryFromHostContext(ctx);
|
|
26870
26787
|
if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
|
|
26871
|
-
const admittedPath =
|
|
26788
|
+
const admittedPath = join45(runDirectory, "admitted-request.json");
|
|
26872
26789
|
const admitted = JSON.parse(readFileSync6(admittedPath, "utf8"));
|
|
26873
26790
|
if (typeof admitted.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
|
|
26874
26791
|
throw new Error(`${label} admitted-request missing projectRoot (${admittedPath})`);
|
|
@@ -27221,14 +27138,6 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27221
27138
|
}
|
|
27222
27139
|
};
|
|
27223
27140
|
});
|
|
27224
|
-
roleHost.on("before_agent_start", async (_event, ctx) => {
|
|
27225
|
-
const runDir = runDirectoryFromHostContext(ctx);
|
|
27226
|
-
if (runDir === void 0) return;
|
|
27227
|
-
const { loadCaseDossierReadingMaterial: loadCaseDossierReadingMaterial2 } = await Promise.resolve().then(() => (init_case_dossier_delivery(), case_dossier_delivery_exports));
|
|
27228
|
-
const caseDossier = await loadCaseDossierReadingMaterial2(runDir);
|
|
27229
|
-
if (caseDossier === void 0) return;
|
|
27230
|
-
return { readingMaterial: caseDossier };
|
|
27231
|
-
});
|
|
27232
27141
|
roleHost.on("tool_result", async (event) => {
|
|
27233
27142
|
const role = selectedRole;
|
|
27234
27143
|
if (role === void 0) return;
|
|
@@ -27836,11 +27745,11 @@ async function prepareRoleEnvelope(options) {
|
|
|
27836
27745
|
const hostAbort = new AbortController();
|
|
27837
27746
|
const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID9();
|
|
27838
27747
|
await mkdir5(request.runDirectory, { recursive: true });
|
|
27839
|
-
let sessionFile = options.sessionFile ??
|
|
27748
|
+
let sessionFile = options.sessionFile ?? join46(request.runDirectory, "session", "session.jsonl");
|
|
27840
27749
|
await mkdir5(dirname25(sessionFile), { recursive: true });
|
|
27841
27750
|
if (request.continuation.kind !== "resume") {
|
|
27842
27751
|
try {
|
|
27843
|
-
await
|
|
27752
|
+
await writeFile10(
|
|
27844
27753
|
sessionFile,
|
|
27845
27754
|
`${JSON.stringify({
|
|
27846
27755
|
type: "session",
|
|
@@ -28355,13 +28264,13 @@ async function prepareRoleEnvelope(options) {
|
|
|
28355
28264
|
// src/role-runtime-dependencies.ts
|
|
28356
28265
|
init_collector_github();
|
|
28357
28266
|
init_doctor_evidence();
|
|
28358
|
-
import { readFile as
|
|
28359
|
-
import { join as
|
|
28267
|
+
import { readFile as readFile25 } from "node:fs/promises";
|
|
28268
|
+
import { join as join47 } from "node:path";
|
|
28360
28269
|
|
|
28361
28270
|
// src/navigator-work-context.ts
|
|
28362
28271
|
init_doctor_evidence();
|
|
28363
28272
|
init_host_contracts();
|
|
28364
|
-
import { readFile as
|
|
28273
|
+
import { readFile as readFile24 } from "node:fs/promises";
|
|
28365
28274
|
import { resolve as resolve20 } from "node:path";
|
|
28366
28275
|
init_notary_source_run();
|
|
28367
28276
|
init_packaged_role_registry();
|
|
@@ -28375,7 +28284,7 @@ function navigatorInputReference(getFlag, role) {
|
|
|
28375
28284
|
async function loadNavigatorWorkContext(options) {
|
|
28376
28285
|
const reference = navigatorInputReference(options.getFlag, options.role);
|
|
28377
28286
|
const subjectMode = packagedNavigatorSubject(options.role);
|
|
28378
|
-
const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await
|
|
28287
|
+
const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await readFile24(reference, "utf8");
|
|
28379
28288
|
const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
|
|
28380
28289
|
let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
|
|
28381
28290
|
let subject = input ?? `work subject: ${subjectKey}`;
|
|
@@ -28432,7 +28341,7 @@ async function loadNavigatorWorkContext(options) {
|
|
|
28432
28341
|
let authorityMaterial;
|
|
28433
28342
|
for (const path of authorityFiles) {
|
|
28434
28343
|
try {
|
|
28435
|
-
const content = await
|
|
28344
|
+
const content = await readFile24(path, "utf8");
|
|
28436
28345
|
if (content.trim() !== "") {
|
|
28437
28346
|
authorityMaterial = content;
|
|
28438
28347
|
break;
|
|
@@ -28469,19 +28378,19 @@ function loadRegisteredRoleSoul(role) {
|
|
|
28469
28378
|
return usesSubjectSoul(role) ? loadAuditorSoulFromSubjectInput() : loadMainRoleSessionMaterials(role);
|
|
28470
28379
|
}
|
|
28471
28380
|
function createRoleRuntimeDependencies(packageRoot) {
|
|
28472
|
-
const collectorHandbookSeedPath =
|
|
28381
|
+
const collectorHandbookSeedPath = join47(packageRoot, "resources/collector-bot-handbook.md");
|
|
28473
28382
|
const navigatorSessionFactory = createNativeNavigatorSessionFactory();
|
|
28474
28383
|
return {
|
|
28475
28384
|
packageRoot,
|
|
28476
28385
|
loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
|
|
28477
28386
|
loadRoleSoul: loadRegisteredRoleSoul,
|
|
28478
|
-
loadFixPacket: (path) =>
|
|
28479
|
-
loadCoderTask: (path) =>
|
|
28480
|
-
loadCollectorHandbookSeed: () =>
|
|
28387
|
+
loadFixPacket: (path) => readFile25(path, "utf8"),
|
|
28388
|
+
loadCoderTask: (path) => readFile25(path, "utf8"),
|
|
28389
|
+
loadCollectorHandbookSeed: () => readFile25(collectorHandbookSeedPath, "utf8"),
|
|
28481
28390
|
createCollectorTransport: () => createGhCollectorGitHubTransport(),
|
|
28482
28391
|
loadDoctorCase,
|
|
28483
28392
|
loadNotarySourceRun: loadNotarySourceRunLocator,
|
|
28484
|
-
loadMergerInput: async (path) => JSON.parse(await
|
|
28393
|
+
loadMergerInput: async (path) => JSON.parse(await readFile25(path, "utf8")),
|
|
28485
28394
|
loadNavigatorWorkContext: (options) => loadNavigatorWorkContext({
|
|
28486
28395
|
context: options.context,
|
|
28487
28396
|
role: options.role,
|
|
@@ -28506,9 +28415,9 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
28506
28415
|
init_session_identity();
|
|
28507
28416
|
|
|
28508
28417
|
// src/acp-host/description.ts
|
|
28509
|
-
import { join as
|
|
28418
|
+
import { join as join48 } from "node:path";
|
|
28510
28419
|
function resolveAcpBinary(description, operatorHome) {
|
|
28511
|
-
return
|
|
28420
|
+
return join48(operatorHome, ...description.binaryFromHome);
|
|
28512
28421
|
}
|
|
28513
28422
|
function acpStdioArgs(description, model, seat) {
|
|
28514
28423
|
const { prefix, suffix, modelFlag, thinkingFlag } = description.argv;
|
|
@@ -28527,27 +28436,17 @@ function acpModelId(modelPassing, model) {
|
|
|
28527
28436
|
}
|
|
28528
28437
|
|
|
28529
28438
|
// src/acp-host/role-turn-host.ts
|
|
28439
|
+
import { join as join49 } from "node:path";
|
|
28530
28440
|
import { spawn as spawn4 } from "node:child_process";
|
|
28531
28441
|
import { createInterface } from "node:readline";
|
|
28532
28442
|
|
|
28533
28443
|
// src/external-host-turn-loop.ts
|
|
28534
|
-
init_packaged_role_registry();
|
|
28535
28444
|
var EXTERNAL_ROLE_TURN_ROUND_LIMIT = 8;
|
|
28536
28445
|
function mergeRoleTurnAbortSignals(prepared, request) {
|
|
28537
28446
|
if (request === void 0) return prepared;
|
|
28538
28447
|
if (prepared === void 0) return request;
|
|
28539
28448
|
return AbortSignal.any([prepared, request]);
|
|
28540
28449
|
}
|
|
28541
|
-
function promptWithPriorNativePaths(basePrompt, request) {
|
|
28542
|
-
if (request.continuation.kind !== "resume") return basePrompt;
|
|
28543
|
-
if (request.stationChild === true && isOfficerReviewSeat(request.activation.role)) {
|
|
28544
|
-
return basePrompt;
|
|
28545
|
-
}
|
|
28546
|
-
const paths = request.hostTransition?.priorNativePaths;
|
|
28547
|
-
if (paths === void 0 || paths.length === 0) return basePrompt;
|
|
28548
|
-
return `${basePrompt}
|
|
28549
|
-
${paths.join("\n")}`;
|
|
28550
|
-
}
|
|
28551
28450
|
function isHostAbortedError(error) {
|
|
28552
28451
|
return typeof error === "object" && error !== null && error.code === "host-aborted";
|
|
28553
28452
|
}
|
|
@@ -28596,7 +28495,7 @@ async function settleHostAborted(prepared, sessionId) {
|
|
|
28596
28495
|
});
|
|
28597
28496
|
}
|
|
28598
28497
|
async function driveExternalRoleTurnRounds(prepared, request, driver) {
|
|
28599
|
-
let prompt =
|
|
28498
|
+
let prompt = prepared.prompt;
|
|
28600
28499
|
const abortSignal = mergeRoleTurnAbortSignals(prepared.abortSignal, request.signal);
|
|
28601
28500
|
let stderr = "";
|
|
28602
28501
|
for (let attempt = 0; attempt < EXTERNAL_ROLE_TURN_ROUND_LIMIT; attempt += 1) {
|
|
@@ -28640,31 +28539,8 @@ function createSerializedRoleTurnHost(execute) {
|
|
|
28640
28539
|
};
|
|
28641
28540
|
}
|
|
28642
28541
|
|
|
28643
|
-
// src/host-session-record.ts
|
|
28644
|
-
init_sitian_facade();
|
|
28645
|
-
var HOST_SESSION_RECORD_KIND = "host-session";
|
|
28646
|
-
function eventField(event, key) {
|
|
28647
|
-
if (typeof event !== "object" || event === null || Array.isArray(event)) return void 0;
|
|
28648
|
-
const value = event[key];
|
|
28649
|
-
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
28650
|
-
}
|
|
28651
|
-
function reportHostSessionEvent(input) {
|
|
28652
|
-
const identity = input.identity ?? eventField(input.event, "uuid");
|
|
28653
|
-
const timestamp2 = input.timestamp ?? eventField(input.event, "timestamp");
|
|
28654
|
-
sitianReport({
|
|
28655
|
-
level: "event",
|
|
28656
|
-
kind: HOST_SESSION_RECORD_KIND,
|
|
28657
|
-
host: input.host,
|
|
28658
|
-
cwd: input.cwd,
|
|
28659
|
-
sessionParent: input.sessionParent,
|
|
28660
|
-
source: input.source,
|
|
28661
|
-
payload: input.event,
|
|
28662
|
-
...identity === void 0 ? {} : { identity },
|
|
28663
|
-
...timestamp2 === void 0 ? {} : { timestamp: timestamp2 }
|
|
28664
|
-
});
|
|
28665
|
-
}
|
|
28666
|
-
|
|
28667
28542
|
// src/acp-host/role-turn-host.ts
|
|
28543
|
+
init_host_session_record();
|
|
28668
28544
|
init_navigator_output();
|
|
28669
28545
|
|
|
28670
28546
|
// src/agent-start-materials.ts
|
|
@@ -28679,18 +28555,6 @@ function renderSystemPromptOverride(authority) {
|
|
|
28679
28555
|
}
|
|
28680
28556
|
|
|
28681
28557
|
// src/acp-host/role-turn-host.ts
|
|
28682
|
-
var GROK_BUILD_HOST = "grok-build";
|
|
28683
|
-
function acpPromptResultHasUsage(result) {
|
|
28684
|
-
const meta = result._meta;
|
|
28685
|
-
if (typeof meta !== "object" || meta === null || Array.isArray(meta)) return false;
|
|
28686
|
-
return Object.prototype.hasOwnProperty.call(meta, "usage");
|
|
28687
|
-
}
|
|
28688
|
-
function isAcpAutoCompactCompletedNotification(method, params) {
|
|
28689
|
-
if (method !== "_x.ai/session_notification") return false;
|
|
28690
|
-
const update = params.update;
|
|
28691
|
-
if (typeof update !== "object" || update === null || Array.isArray(update)) return false;
|
|
28692
|
-
return update.sessionUpdate === "auto_compact_completed";
|
|
28693
|
-
}
|
|
28694
28558
|
function acpAgentTextChunk(params) {
|
|
28695
28559
|
let kind;
|
|
28696
28560
|
let content;
|
|
@@ -28862,189 +28726,142 @@ function createAcpRoleTurnHost(config) {
|
|
|
28862
28726
|
const systemPromptOverride = renderSystemPromptOverride(prepared.systemPrompt);
|
|
28863
28727
|
let connection;
|
|
28864
28728
|
let sessionId;
|
|
28729
|
+
let sessionOpened = false;
|
|
28865
28730
|
let accepted = false;
|
|
28731
|
+
const sessionParent = config.sessionIdentity.resolveSessionFile(request.principal);
|
|
28866
28732
|
let outcome = failure("session", "AcpNoOutcome", "no-outcome");
|
|
28867
28733
|
try {
|
|
28868
28734
|
if (prepared.mcpServers.length === 0) {
|
|
28869
28735
|
outcome = failure("activation", "UncontrolledAcpSession", "ak-config-missing");
|
|
28870
28736
|
} else {
|
|
28871
28737
|
connection = await config.connect(request);
|
|
28872
|
-
const
|
|
28873
|
-
const recordAbort = new AbortController();
|
|
28874
|
-
let hostSessionRecordFailure;
|
|
28875
|
-
const hostSessionRecordResult = () => ({
|
|
28876
|
-
code: null,
|
|
28877
|
-
stderr: "",
|
|
28878
|
-
timedOut: false,
|
|
28879
|
-
knownFailure: hostSessionRecordFailure
|
|
28880
|
-
});
|
|
28881
|
-
const noteHostSessionRecordFailure = (error) => {
|
|
28882
|
-
if (hostSessionRecordFailure !== void 0) return;
|
|
28883
|
-
hostSessionRecordFailure = {
|
|
28884
|
-
cause: "session",
|
|
28885
|
-
identity: { name: "HostSessionRecordFailure", code: "host-session-record-failed" },
|
|
28886
|
-
diagnostic: error instanceof Error ? error.message : String(error)
|
|
28887
|
-
};
|
|
28888
|
-
try {
|
|
28889
|
-
recordAbort.abort();
|
|
28890
|
-
} catch {
|
|
28891
|
-
}
|
|
28892
|
-
};
|
|
28893
|
-
const rpc = (method, params) => raceAgainstHostAbort(connection.request(method, params), recordAbort.signal, "host-session-record-failed");
|
|
28738
|
+
const rpc = (method, params) => connection.request(method, params);
|
|
28894
28739
|
const agentProseChunks = [];
|
|
28895
28740
|
let collectAgentProse = false;
|
|
28896
|
-
const ledgerGrokBuildObservability = config.hostName === GROK_BUILD_HOST;
|
|
28897
28741
|
connection.onNotification?.((method, params) => {
|
|
28898
|
-
if (hostSessionRecordFailure !== void 0) return;
|
|
28899
28742
|
const isSessionUpdate = method === "session/update";
|
|
28900
|
-
|
|
28901
|
-
if (
|
|
28902
|
-
if (isSessionUpdate && collectAgentProse) {
|
|
28743
|
+
if (!isSessionUpdate) return;
|
|
28744
|
+
if (collectAgentProse) {
|
|
28903
28745
|
const chunk = acpAgentTextChunk(params);
|
|
28904
28746
|
if (chunk !== void 0) agentProseChunks.push(chunk);
|
|
28905
28747
|
}
|
|
28906
|
-
|
|
28907
|
-
|
|
28748
|
+
});
|
|
28749
|
+
const initialized = await rpc("initialize", {
|
|
28750
|
+
protocolVersion: 1,
|
|
28751
|
+
clientCapabilities: {}
|
|
28752
|
+
});
|
|
28753
|
+
const initializeMeta = initialized._meta;
|
|
28754
|
+
const availableModels = Array.isArray(initializeMeta?.modelState?.availableModels) ? initializeMeta.modelState.availableModels : void 0;
|
|
28755
|
+
if (request.model !== void 0 && availableModels !== void 0 && !availableModels.some((entry) => typeof entry === "object" && entry !== null && entry.modelId === acpModelId(config.modelPassing, request.model))) {
|
|
28756
|
+
outcome = failure("activation", "AcpHostModelMismatch", "host-model-mismatch", {
|
|
28757
|
+
provider: request.model.provider,
|
|
28758
|
+
model: request.model.model
|
|
28759
|
+
});
|
|
28760
|
+
} else {
|
|
28761
|
+
const sessionBindParams = {
|
|
28762
|
+
cwd: request.cwd,
|
|
28763
|
+
mcpServers: prepared.mcpServers,
|
|
28764
|
+
_meta: { systemPromptOverride, yoloMode: false }
|
|
28765
|
+
};
|
|
28766
|
+
const loadSession = async (bindSessionId) => {
|
|
28767
|
+
const loaded = await rpc("session/load", {
|
|
28768
|
+
sessionId: bindSessionId,
|
|
28769
|
+
...sessionBindParams
|
|
28770
|
+
});
|
|
28771
|
+
const loadedId = typeof loaded.sessionId === "string" && loaded.sessionId !== "" ? loaded.sessionId : bindSessionId;
|
|
28772
|
+
if (config.hostName !== "hermes") recordNativeSessionPointer({
|
|
28908
28773
|
host: config.hostName,
|
|
28774
|
+
sessionId: loadedId,
|
|
28909
28775
|
cwd: request.cwd,
|
|
28910
28776
|
sessionParent,
|
|
28911
|
-
|
|
28912
|
-
event: { method, params }
|
|
28777
|
+
home: request.home
|
|
28913
28778
|
});
|
|
28914
|
-
|
|
28915
|
-
|
|
28779
|
+
return loadedId;
|
|
28780
|
+
};
|
|
28781
|
+
if (request.continuation.kind === "resume" && config.boundResume === "session/load") {
|
|
28782
|
+
const explicitHostSessionId = request.continuation.hostSessionId;
|
|
28783
|
+
const boundSessionId = explicitHostSessionId !== void 0 && explicitHostSessionId !== "" ? explicitHostSessionId : await config.sessionIdentity.load(request.principal);
|
|
28784
|
+
if (boundSessionId !== void 0 && boundSessionId !== "") {
|
|
28785
|
+
sessionId = boundSessionId;
|
|
28786
|
+
sessionId = await loadSession(boundSessionId);
|
|
28787
|
+
sessionOpened = true;
|
|
28788
|
+
}
|
|
28916
28789
|
}
|
|
28917
|
-
|
|
28918
|
-
|
|
28919
|
-
|
|
28920
|
-
|
|
28921
|
-
|
|
28922
|
-
|
|
28923
|
-
|
|
28924
|
-
|
|
28925
|
-
|
|
28926
|
-
|
|
28927
|
-
|
|
28928
|
-
|
|
28929
|
-
|
|
28930
|
-
|
|
28931
|
-
const sessionBindParams = {
|
|
28932
|
-
cwd: request.cwd,
|
|
28933
|
-
mcpServers: prepared.mcpServers,
|
|
28934
|
-
_meta: { systemPromptOverride, yoloMode: false }
|
|
28935
|
-
};
|
|
28936
|
-
const loadSession = async (bindSessionId) => {
|
|
28937
|
-
const loaded = await rpc("session/load", {
|
|
28938
|
-
sessionId: bindSessionId,
|
|
28939
|
-
...sessionBindParams
|
|
28790
|
+
let sessionReady = true;
|
|
28791
|
+
if (sessionId === void 0) {
|
|
28792
|
+
const session = await rpc("session/new", sessionBindParams);
|
|
28793
|
+
sessionId = typeof session.sessionId === "string" ? session.sessionId : void 0;
|
|
28794
|
+
if (sessionId === void 0 || sessionId === "") {
|
|
28795
|
+
outcome = failure("session", "AcpSessionFailure", "session-id-missing");
|
|
28796
|
+
sessionReady = false;
|
|
28797
|
+
} else {
|
|
28798
|
+
if (config.hostName !== "hermes") recordNativeSessionPointer({
|
|
28799
|
+
host: config.hostName,
|
|
28800
|
+
sessionId,
|
|
28801
|
+
cwd: request.cwd,
|
|
28802
|
+
sessionParent,
|
|
28803
|
+
home: request.home
|
|
28940
28804
|
});
|
|
28941
|
-
|
|
28942
|
-
|
|
28943
|
-
if (request.continuation.kind === "resume" && config.boundResume === "session/load") {
|
|
28944
|
-
const explicitHostSessionId = request.continuation.hostSessionId;
|
|
28945
|
-
const boundSessionId = explicitHostSessionId !== void 0 && explicitHostSessionId !== "" ? explicitHostSessionId : await config.sessionIdentity.load(request.principal);
|
|
28946
|
-
if (boundSessionId !== void 0 && boundSessionId !== "") {
|
|
28947
|
-
sessionId = await loadSession(boundSessionId);
|
|
28948
|
-
}
|
|
28805
|
+
sessionOpened = true;
|
|
28806
|
+
await config.sessionIdentity.bind(request.principal, sessionId);
|
|
28949
28807
|
}
|
|
28950
|
-
|
|
28951
|
-
|
|
28952
|
-
|
|
28953
|
-
|
|
28954
|
-
|
|
28955
|
-
|
|
28956
|
-
|
|
28957
|
-
|
|
28958
|
-
await config.sessionIdentity.bind(request.principal, sessionId);
|
|
28959
|
-
}
|
|
28808
|
+
}
|
|
28809
|
+
if (sessionReady) {
|
|
28810
|
+
if (config.modelPassing === "set_model" && request.model !== void 0 && sessionId !== void 0) {
|
|
28811
|
+
await rpc("session/set_model", {
|
|
28812
|
+
sessionId,
|
|
28813
|
+
modelId: acpModelId(config.modelPassing, request.model)
|
|
28814
|
+
});
|
|
28815
|
+
sessionId = await loadSession(sessionId);
|
|
28960
28816
|
}
|
|
28961
|
-
|
|
28962
|
-
|
|
28963
|
-
|
|
28964
|
-
|
|
28965
|
-
|
|
28966
|
-
|
|
28967
|
-
|
|
28968
|
-
|
|
28969
|
-
|
|
28970
|
-
|
|
28971
|
-
|
|
28972
|
-
|
|
28973
|
-
|
|
28974
|
-
|
|
28975
|
-
|
|
28976
|
-
|
|
28977
|
-
|
|
28978
|
-
|
|
28979
|
-
|
|
28980
|
-
agentProseChunks.length = 0;
|
|
28981
|
-
collectAgentProse = prepared.terminatingToolName === NAVIGATOR_OUTPUT_TOOL_NAME;
|
|
28982
|
-
try {
|
|
28983
|
-
result = await raceAgainstHostAbort(
|
|
28984
|
-
activeConnection.request("session/prompt", {
|
|
28985
|
-
sessionId: activeSessionId,
|
|
28986
|
-
prompt: [{ type: "text", text: prompt }]
|
|
28987
|
-
}),
|
|
28988
|
-
combinedAbort,
|
|
28989
|
-
"ACP host aborted"
|
|
28990
|
-
);
|
|
28991
|
-
} catch (error) {
|
|
28992
|
-
collectAgentProse = false;
|
|
28993
|
-
agentProseChunks.length = 0;
|
|
28994
|
-
if (hostSessionRecordFailure !== void 0) {
|
|
28995
|
-
return { status: "terminal", result: hostSessionRecordResult() };
|
|
28996
|
-
}
|
|
28997
|
-
throw error;
|
|
28998
|
-
}
|
|
28817
|
+
const activeConnection = connection;
|
|
28818
|
+
const activeSessionId = sessionId;
|
|
28819
|
+
const turnResult = await driveExternalRoleTurnRounds(prepared, request, {
|
|
28820
|
+
roundLimitName: "AcpRoundLimit",
|
|
28821
|
+
currentSessionId: () => sessionId,
|
|
28822
|
+
async runRound({ prompt, abortSignal }) {
|
|
28823
|
+
let result;
|
|
28824
|
+
agentProseChunks.length = 0;
|
|
28825
|
+
collectAgentProse = prepared.terminatingToolName === NAVIGATOR_OUTPUT_TOOL_NAME;
|
|
28826
|
+
try {
|
|
28827
|
+
result = await raceAgainstHostAbort(
|
|
28828
|
+
activeConnection.request("session/prompt", {
|
|
28829
|
+
sessionId: activeSessionId,
|
|
28830
|
+
prompt: [{ type: "text", text: prompt }]
|
|
28831
|
+
}),
|
|
28832
|
+
abortSignal,
|
|
28833
|
+
"ACP host aborted"
|
|
28834
|
+
);
|
|
28835
|
+
} catch (error) {
|
|
28999
28836
|
collectAgentProse = false;
|
|
29000
|
-
|
|
29001
|
-
|
|
29002
|
-
|
|
29003
|
-
|
|
29004
|
-
|
|
29005
|
-
|
|
29006
|
-
|
|
29007
|
-
|
|
29008
|
-
|
|
29009
|
-
|
|
29010
|
-
|
|
29011
|
-
|
|
29012
|
-
|
|
29013
|
-
|
|
29014
|
-
if (
|
|
29015
|
-
|
|
29016
|
-
}
|
|
29017
|
-
if (result.stopReason === "refusal") {
|
|
29018
|
-
agentProseChunks.length = 0;
|
|
29019
|
-
return {
|
|
29020
|
-
status: "terminal",
|
|
29021
|
-
result: failure("output", "AcpRefusal", "refusal", { sessionId })
|
|
29022
|
-
};
|
|
29023
|
-
}
|
|
29024
|
-
if (prepared.terminatingToolName === NAVIGATOR_OUTPUT_TOOL_NAME) {
|
|
29025
|
-
const prose = agentProseChunks.join("");
|
|
29026
|
-
agentProseChunks.length = 0;
|
|
29027
|
-
if (navigatorProseFromUnknown(prose) !== void 0) {
|
|
29028
|
-
await prepared.ingestStructuredOutput({ prose });
|
|
29029
|
-
}
|
|
29030
|
-
} else {
|
|
29031
|
-
agentProseChunks.length = 0;
|
|
28837
|
+
agentProseChunks.length = 0;
|
|
28838
|
+
throw error;
|
|
28839
|
+
}
|
|
28840
|
+
collectAgentProse = false;
|
|
28841
|
+
if (result.stopReason === "refusal") {
|
|
28842
|
+
agentProseChunks.length = 0;
|
|
28843
|
+
return {
|
|
28844
|
+
status: "terminal",
|
|
28845
|
+
result: failure("output", "AcpRefusal", "refusal", { sessionId })
|
|
28846
|
+
};
|
|
28847
|
+
}
|
|
28848
|
+
if (prepared.terminatingToolName === NAVIGATOR_OUTPUT_TOOL_NAME) {
|
|
28849
|
+
const prose = agentProseChunks.join("");
|
|
28850
|
+
agentProseChunks.length = 0;
|
|
28851
|
+
if (navigatorProseFromUnknown(prose) !== void 0) {
|
|
28852
|
+
await prepared.ingestStructuredOutput({ prose });
|
|
29032
28853
|
}
|
|
29033
|
-
|
|
29034
|
-
|
|
29035
|
-
async afterAccepted() {
|
|
29036
|
-
await rpc("session/close", { sessionId: activeSessionId });
|
|
29037
|
-
accepted = true;
|
|
28854
|
+
} else {
|
|
28855
|
+
agentProseChunks.length = 0;
|
|
29038
28856
|
}
|
|
29039
|
-
|
|
29040
|
-
|
|
29041
|
-
|
|
29042
|
-
|
|
29043
|
-
|
|
29044
|
-
|
|
29045
|
-
|
|
29046
|
-
|
|
29047
|
-
throw error;
|
|
28857
|
+
return { status: "delivered", stderr: activeConnection.stderr?.() ?? "" };
|
|
28858
|
+
},
|
|
28859
|
+
async afterAccepted() {
|
|
28860
|
+
await rpc("session/close", { sessionId: activeSessionId });
|
|
28861
|
+
accepted = true;
|
|
28862
|
+
}
|
|
28863
|
+
});
|
|
28864
|
+
outcome = turnResult;
|
|
29048
28865
|
}
|
|
29049
28866
|
}
|
|
29050
28867
|
}
|
|
@@ -29061,6 +28878,18 @@ function createAcpRoleTurnHost(config) {
|
|
|
29061
28878
|
} catch {
|
|
29062
28879
|
}
|
|
29063
28880
|
}
|
|
28881
|
+
if (config.hostName !== "hermes" && sessionOpened && sessionId !== void 0) {
|
|
28882
|
+
copyAndRecordHostDossier({
|
|
28883
|
+
host: config.hostName,
|
|
28884
|
+
sessionId,
|
|
28885
|
+
cwd: request.cwd,
|
|
28886
|
+
sessionDirectory: join49(request.runDirectory, "session"),
|
|
28887
|
+
sessionParent,
|
|
28888
|
+
continuation: request.continuation,
|
|
28889
|
+
...request.model !== void 0 ? { model: request.model } : {},
|
|
28890
|
+
...request.home !== void 0 ? { home: request.home } : {}
|
|
28891
|
+
});
|
|
28892
|
+
}
|
|
29064
28893
|
try {
|
|
29065
28894
|
await prepared.dispose?.();
|
|
29066
28895
|
} catch (cleanupError) {
|
|
@@ -29073,7 +28902,7 @@ function createAcpRoleTurnHost(config) {
|
|
|
29073
28902
|
|
|
29074
28903
|
// src/acp-host/seat-profile-soul.ts
|
|
29075
28904
|
import { constants as constants3 } from "node:fs";
|
|
29076
|
-
import { access as
|
|
28905
|
+
import { access as access3, copyFile, lstat as lstat8, mkdir as mkdir6, readlink, symlink as symlink2, unlink as unlink6 } from "node:fs/promises";
|
|
29077
28906
|
import { dirname as dirname26, join as join50, relative as relative3, resolve as resolve21 } from "node:path";
|
|
29078
28907
|
function seatProfileName(spec, role) {
|
|
29079
28908
|
return `${spec.namePrefix}${role}`;
|
|
@@ -29083,7 +28912,7 @@ function packageRoleSoulPath(packageRoot, role) {
|
|
|
29083
28912
|
}
|
|
29084
28913
|
async function pathExists2(path) {
|
|
29085
28914
|
try {
|
|
29086
|
-
await
|
|
28915
|
+
await access3(path, constants3.F_OK);
|
|
29087
28916
|
return true;
|
|
29088
28917
|
} catch {
|
|
29089
28918
|
return false;
|