@akagilnc/pi-workflow-roles 0.1.5212 → 0.1.5235
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/acp-host/production-host.js +580 -1031
- package/dist/engine-detour-usage.js +4 -16
- package/dist/headless-host/production-host.js +701 -1066
- package/dist/host-session-record.js +303 -0
- package/dist/migrate-book-topology.js +0 -1
- package/dist/pi/role-turn-host.js +1 -21
- package/dist/public-cli/main.js +153 -362
- package/dist/public-cli/post-admission.js +7 -43
- package/dist/sitian-appender.js +10 -146
- package/dist/ticket-provenance-contracts.js +4 -42
- package/dist/ticket-provenance.js +27 -456
- package/package.json +1 -1
- package/src/acp-host/role-turn-host.ts +36 -108
- package/src/diarist.ts +5 -5
- 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/pi/role-turn-host.ts +1 -25
- package/src/public-cli/post-admission.ts +6 -51
- package/src/public-role-summons.ts +1 -2
- package/src/sitian-appender.ts +16 -191
- package/src/ticket-provenance-contracts.ts +10 -48
- package/src/ticket-provenance.ts +33 -499
- package/dist/host-transition-prior-native.js +0 -78
- package/src/host-transition-prior-native.ts +0 -80
- package/src/pi/pi-normalization.ts +0 -291
|
@@ -2867,17 +2867,6 @@ function positiveInteger(value) {
|
|
|
2867
2867
|
}
|
|
2868
2868
|
return void 0;
|
|
2869
2869
|
}
|
|
2870
|
-
function nonNegativeInteger(value) {
|
|
2871
|
-
if (typeof value === "number" && Number.isSafeInteger(value) && value >= 0) return value;
|
|
2872
|
-
if (typeof value === "string" && /^(0|[1-9][0-9]*)$/.test(value)) {
|
|
2873
|
-
const parsed = Number(value);
|
|
2874
|
-
if (Number.isSafeInteger(parsed)) return parsed;
|
|
2875
|
-
}
|
|
2876
|
-
return void 0;
|
|
2877
|
-
}
|
|
2878
|
-
function projectSpeaker(value) {
|
|
2879
|
-
return value === "owner" || value === "runner" ? value : void 0;
|
|
2880
|
-
}
|
|
2881
2870
|
function projectBound(value) {
|
|
2882
2871
|
if (!isRecord2(value)) return void 0;
|
|
2883
2872
|
const id = typeof value.id === "string" && value.id !== "" ? value.id : void 0;
|
|
@@ -2906,42 +2895,6 @@ function projectTicketProvenanceSessions(value) {
|
|
|
2906
2895
|
}
|
|
2907
2896
|
return sessions;
|
|
2908
2897
|
}
|
|
2909
|
-
function projectTicketProvenanceHeader(value) {
|
|
2910
|
-
if (!isRecord2(value)) return void 0;
|
|
2911
|
-
const ticket = value.ticket === null ? null : positiveInteger(value.ticket);
|
|
2912
|
-
if (ticket === void 0) return void 0;
|
|
2913
|
-
if (typeof value.repo !== "string") return void 0;
|
|
2914
|
-
if (typeof value.createdAt !== "string" || typeof value.updatedAt !== "string") {
|
|
2915
|
-
return void 0;
|
|
2916
|
-
}
|
|
2917
|
-
const sessions = projectTicketProvenanceSessions(value.sessions);
|
|
2918
|
-
if (sessions === void 0) return void 0;
|
|
2919
|
-
return {
|
|
2920
|
-
repo: value.repo,
|
|
2921
|
-
ticket,
|
|
2922
|
-
createdAt: value.createdAt,
|
|
2923
|
-
updatedAt: value.updatedAt,
|
|
2924
|
-
sessions
|
|
2925
|
-
};
|
|
2926
|
-
}
|
|
2927
|
-
function projectTicketProvenanceLine(value) {
|
|
2928
|
-
if (!isRecord2(value)) return void 0;
|
|
2929
|
-
const speaker = projectSpeaker(value.speaker);
|
|
2930
|
-
const s = nonNegativeInteger(value.s);
|
|
2931
|
-
if (speaker === void 0 || s === void 0) return void 0;
|
|
2932
|
-
if (typeof value.text !== "string") return void 0;
|
|
2933
|
-
const sourcePosition = nonNegativeInteger(value.sourcePosition);
|
|
2934
|
-
const sourceIdentity = typeof value.sourceIdentity === "string" && value.sourceIdentity !== "" ? value.sourceIdentity : void 0;
|
|
2935
|
-
const id = typeof value.id === "string" && value.id !== "" ? value.id : void 0;
|
|
2936
|
-
return {
|
|
2937
|
-
speaker,
|
|
2938
|
-
s,
|
|
2939
|
-
...sourcePosition === void 0 ? {} : { sourcePosition },
|
|
2940
|
-
...sourceIdentity === void 0 ? {} : { sourceIdentity },
|
|
2941
|
-
...id === void 0 ? {} : { id },
|
|
2942
|
-
text: value.text
|
|
2943
|
-
};
|
|
2944
|
-
}
|
|
2945
2898
|
var TICKET_PROVENANCE_KIND;
|
|
2946
2899
|
var init_ticket_provenance_contracts = __esm({
|
|
2947
2900
|
"src/ticket-provenance-contracts.ts"() {
|
|
@@ -4271,57 +4224,15 @@ var init_sitian_contracts = __esm({
|
|
|
4271
4224
|
});
|
|
4272
4225
|
|
|
4273
4226
|
// src/sitian-appender.ts
|
|
4274
|
-
import {
|
|
4275
|
-
import {
|
|
4276
|
-
appendFileSync,
|
|
4277
|
-
existsSync,
|
|
4278
|
-
readFileSync,
|
|
4279
|
-
unlinkSync,
|
|
4280
|
-
writeFileSync
|
|
4281
|
-
} from "node:fs";
|
|
4227
|
+
import { randomUUID } from "node:crypto";
|
|
4228
|
+
import { appendFileSync } from "node:fs";
|
|
4282
4229
|
import { dirname as dirname3, join as join4 } from "node:path";
|
|
4283
|
-
function isRecord3(value) {
|
|
4284
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4285
|
-
}
|
|
4286
|
-
function errorCodeOf(error) {
|
|
4287
|
-
return error.code;
|
|
4288
|
-
}
|
|
4289
|
-
function identityClaimPath(recordFile, identity) {
|
|
4290
|
-
const digest = createHash4("sha256").update(identity, "utf8").digest("hex");
|
|
4291
|
-
return `${recordFile}.id-${digest}`;
|
|
4292
|
-
}
|
|
4293
|
-
function createExclusiveFile(path, contents) {
|
|
4294
|
-
writeFileSync(path, contents, { encoding: "utf8", flag: "wx" });
|
|
4295
|
-
}
|
|
4296
|
-
function sealTornTail(recordFile) {
|
|
4297
|
-
if (!existsSync(recordFile)) return;
|
|
4298
|
-
const buffer = readFileSync(recordFile);
|
|
4299
|
-
if (buffer.length > 0 && buffer[buffer.length - 1] !== 10) {
|
|
4300
|
-
appendFileSync(recordFile, "\n", "utf8");
|
|
4301
|
-
}
|
|
4302
|
-
}
|
|
4303
4230
|
function appendSitianRecordBlock(input, block) {
|
|
4304
4231
|
if (block === "") return;
|
|
4305
4232
|
try {
|
|
4306
4233
|
const { sessionDir, recordFile, ledgerHome } = resolveSitianRecordPath(input);
|
|
4307
4234
|
ensureRealDirectoryTree(ledgerHome, sessionDir);
|
|
4308
|
-
appendFileSync(recordFile,
|
|
4309
|
-
sealTornTail(recordFile);
|
|
4310
|
-
const identityOf = (line2) => {
|
|
4311
|
-
try {
|
|
4312
|
-
const row = JSON.parse(line2);
|
|
4313
|
-
return isRecord3(row) && typeof row.identity === "string" ? row.identity : void 0;
|
|
4314
|
-
} catch {
|
|
4315
|
-
return void 0;
|
|
4316
|
-
}
|
|
4317
|
-
};
|
|
4318
|
-
const identities = new Set(readFileSync(recordFile, "utf8").split("\n").map(identityOf).filter((id) => id !== void 0));
|
|
4319
|
-
for (const line2 of block.match(/[^\n]*\n|[^\n]+$/g) ?? []) {
|
|
4320
|
-
const identity = identityOf(line2);
|
|
4321
|
-
if (identity !== void 0 && identities.has(identity)) continue;
|
|
4322
|
-
appendFileSync(recordFile, line2, "utf8");
|
|
4323
|
-
if (identity !== void 0) identities.add(identity);
|
|
4324
|
-
}
|
|
4235
|
+
appendFileSync(recordFile, block, "utf8");
|
|
4325
4236
|
} catch (error) {
|
|
4326
4237
|
if (error instanceof SitianInfrastructureError) throw error;
|
|
4327
4238
|
throw new SitianInfrastructureError(
|
|
@@ -4330,106 +4241,6 @@ function appendSitianRecordBlock(input, block) {
|
|
|
4330
4241
|
);
|
|
4331
4242
|
}
|
|
4332
4243
|
}
|
|
4333
|
-
function findIdentityPointer(recordFile, identity, kind, level) {
|
|
4334
|
-
if (!existsSync(recordFile)) return void 0;
|
|
4335
|
-
const text = readFileSync(recordFile, "utf8");
|
|
4336
|
-
for (const line2 of text.split("\n")) {
|
|
4337
|
-
const trimmed = line2.trim();
|
|
4338
|
-
if (!trimmed) continue;
|
|
4339
|
-
try {
|
|
4340
|
-
const parsed = JSON.parse(trimmed);
|
|
4341
|
-
if (isRecord3(parsed) && parsed.identity === identity) {
|
|
4342
|
-
return { identity, recordFile, kind, level };
|
|
4343
|
-
}
|
|
4344
|
-
} catch {
|
|
4345
|
-
}
|
|
4346
|
-
}
|
|
4347
|
-
return void 0;
|
|
4348
|
-
}
|
|
4349
|
-
function unlinkAbsentOk(path) {
|
|
4350
|
-
try {
|
|
4351
|
-
unlinkSync(path);
|
|
4352
|
-
return void 0;
|
|
4353
|
-
} catch (error) {
|
|
4354
|
-
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
4355
|
-
return error instanceof Error ? error : new Error(errorText(error));
|
|
4356
|
-
}
|
|
4357
|
-
}
|
|
4358
|
-
function appendWithIdentityClaim(recordFile, record4, row) {
|
|
4359
|
-
sealTornTail(recordFile);
|
|
4360
|
-
const claimPath = identityClaimPath(recordFile, record4.identity);
|
|
4361
|
-
const existing = findIdentityPointer(
|
|
4362
|
-
recordFile,
|
|
4363
|
-
record4.identity,
|
|
4364
|
-
record4.kind,
|
|
4365
|
-
record4.level
|
|
4366
|
-
);
|
|
4367
|
-
if (existing !== void 0) {
|
|
4368
|
-
unlinkAbsentOk(claimPath);
|
|
4369
|
-
return existing;
|
|
4370
|
-
}
|
|
4371
|
-
try {
|
|
4372
|
-
createExclusiveFile(claimPath, "");
|
|
4373
|
-
} catch (error) {
|
|
4374
|
-
if (errorCodeOf(error) !== "EEXIST") throw error;
|
|
4375
|
-
sealTornTail(recordFile);
|
|
4376
|
-
const published = findIdentityPointer(
|
|
4377
|
-
recordFile,
|
|
4378
|
-
record4.identity,
|
|
4379
|
-
record4.kind,
|
|
4380
|
-
record4.level
|
|
4381
|
-
);
|
|
4382
|
-
if (published !== void 0) {
|
|
4383
|
-
unlinkAbsentOk(claimPath);
|
|
4384
|
-
return published;
|
|
4385
|
-
}
|
|
4386
|
-
throw new SitianInfrastructureError(
|
|
4387
|
-
`Sitian identity claim at ${claimPath} already exists for identity ${record4.identity}`,
|
|
4388
|
-
{ cause: error }
|
|
4389
|
-
);
|
|
4390
|
-
}
|
|
4391
|
-
let primaryFailure;
|
|
4392
|
-
let result;
|
|
4393
|
-
let cleanupFailure;
|
|
4394
|
-
try {
|
|
4395
|
-
sealTornTail(recordFile);
|
|
4396
|
-
const raced = findIdentityPointer(
|
|
4397
|
-
recordFile,
|
|
4398
|
-
record4.identity,
|
|
4399
|
-
record4.kind,
|
|
4400
|
-
record4.level
|
|
4401
|
-
);
|
|
4402
|
-
if (raced !== void 0) {
|
|
4403
|
-
result = raced;
|
|
4404
|
-
} else {
|
|
4405
|
-
appendFileSync(recordFile, row, "utf8");
|
|
4406
|
-
result = {
|
|
4407
|
-
identity: record4.identity,
|
|
4408
|
-
recordFile,
|
|
4409
|
-
kind: record4.kind,
|
|
4410
|
-
level: record4.level
|
|
4411
|
-
};
|
|
4412
|
-
}
|
|
4413
|
-
} catch (error) {
|
|
4414
|
-
primaryFailure = error;
|
|
4415
|
-
} finally {
|
|
4416
|
-
cleanupFailure = unlinkAbsentOk(claimPath);
|
|
4417
|
-
}
|
|
4418
|
-
if (primaryFailure !== void 0) {
|
|
4419
|
-
if (primaryFailure instanceof SitianInfrastructureError) throw primaryFailure;
|
|
4420
|
-
throw new SitianInfrastructureError(
|
|
4421
|
-
`Sitian appender persistence failure: ${errorText(primaryFailure)}`,
|
|
4422
|
-
{ cause: primaryFailure }
|
|
4423
|
-
);
|
|
4424
|
-
}
|
|
4425
|
-
if (cleanupFailure !== void 0) {
|
|
4426
|
-
throw new SitianInfrastructureError(
|
|
4427
|
-
`Sitian identity claim at ${claimPath} could not be released after append for identity ${record4.identity}: ${errorText(cleanupFailure)}`,
|
|
4428
|
-
{ cause: cleanupFailure }
|
|
4429
|
-
);
|
|
4430
|
-
}
|
|
4431
|
-
return result;
|
|
4432
|
-
}
|
|
4433
4244
|
function resolveSitianVolumeCategory(kind) {
|
|
4434
4245
|
if (S4_SUBMISSION_LEDGER_KINDS.has(kind)) {
|
|
4435
4246
|
return "submission-ledger";
|
|
@@ -4502,7 +4313,13 @@ function appendSitianRecord(input) {
|
|
|
4502
4313
|
};
|
|
4503
4314
|
const row = `${JSON.stringify(record4)}
|
|
4504
4315
|
`;
|
|
4505
|
-
|
|
4316
|
+
appendFileSync(recordFile, row, "utf8");
|
|
4317
|
+
return {
|
|
4318
|
+
identity: record4.identity,
|
|
4319
|
+
recordFile,
|
|
4320
|
+
kind: record4.kind,
|
|
4321
|
+
level: record4.level
|
|
4322
|
+
};
|
|
4506
4323
|
} catch (error) {
|
|
4507
4324
|
if (error instanceof SitianInfrastructureError) throw error;
|
|
4508
4325
|
throw new SitianInfrastructureError(
|
|
@@ -4530,13 +4347,13 @@ var init_sitian_appender = __esm({
|
|
|
4530
4347
|
});
|
|
4531
4348
|
|
|
4532
4349
|
// src/sitian-reader.ts
|
|
4533
|
-
import { existsSync
|
|
4350
|
+
import { existsSync } from "node:fs";
|
|
4534
4351
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
4535
|
-
function
|
|
4352
|
+
function isRecord3(value) {
|
|
4536
4353
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4537
4354
|
}
|
|
4538
4355
|
async function readSitianRecords(recordFile) {
|
|
4539
|
-
if (!
|
|
4356
|
+
if (!existsSync(recordFile)) {
|
|
4540
4357
|
return { records: [], diagnostics: [] };
|
|
4541
4358
|
}
|
|
4542
4359
|
const text = await readFile3(recordFile, "utf8");
|
|
@@ -4548,7 +4365,7 @@ async function readSitianRecords(recordFile) {
|
|
|
4548
4365
|
if (!line2.trim()) continue;
|
|
4549
4366
|
try {
|
|
4550
4367
|
const parsed = JSON.parse(line2);
|
|
4551
|
-
if (
|
|
4368
|
+
if (isRecord3(parsed)) {
|
|
4552
4369
|
records.push(parsed);
|
|
4553
4370
|
} else {
|
|
4554
4371
|
const typeDesc = parsed === null ? "null" : Array.isArray(parsed) ? "array" : typeof parsed;
|
|
@@ -4689,14 +4506,14 @@ function isMissingPathError2(error) {
|
|
|
4689
4506
|
function errorText2(error) {
|
|
4690
4507
|
return error instanceof Error ? error.message : String(error);
|
|
4691
4508
|
}
|
|
4692
|
-
function
|
|
4509
|
+
function isRecord4(value) {
|
|
4693
4510
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4694
4511
|
}
|
|
4695
4512
|
function readUsableTerminalArtifactBody(body) {
|
|
4696
4513
|
if (body === null) {
|
|
4697
4514
|
return { ok: false, reason: "terminal artifact JSON value is null" };
|
|
4698
4515
|
}
|
|
4699
|
-
if (!
|
|
4516
|
+
if (!isRecord4(body)) {
|
|
4700
4517
|
return {
|
|
4701
4518
|
ok: false,
|
|
4702
4519
|
reason: `terminal artifact JSON value is not a typed object (${Array.isArray(body) ? "array" : typeof body})`
|
|
@@ -5387,7 +5204,7 @@ var init_session_assistant_usage = __esm({
|
|
|
5387
5204
|
});
|
|
5388
5205
|
|
|
5389
5206
|
// src/package-resources/engine-material.ts
|
|
5390
|
-
import { existsSync as
|
|
5207
|
+
import { existsSync as existsSync2, readdirSync } from "node:fs";
|
|
5391
5208
|
import { join as join10 } from "node:path";
|
|
5392
5209
|
function pickEngineAxis(source) {
|
|
5393
5210
|
return {
|
|
@@ -5430,7 +5247,7 @@ function engineSessionMaterialFromOptions(options) {
|
|
|
5430
5247
|
const model = options.engineModel === void 0 ? void 0 : assertLegalEngineModel(options.engineModel);
|
|
5431
5248
|
const materialPath = resolveEngineMaterialPath(options.packageRoot, name);
|
|
5432
5249
|
const modelField = model === void 0 ? {} : { model };
|
|
5433
|
-
if (
|
|
5250
|
+
if (existsSync2(materialPath)) {
|
|
5434
5251
|
return Object.freeze({ name, materialPath, ...modelField });
|
|
5435
5252
|
}
|
|
5436
5253
|
return Object.freeze({ name, ...modelField });
|
|
@@ -5797,19 +5614,7 @@ function createPiRoleTurnHost(config) {
|
|
|
5797
5614
|
});
|
|
5798
5615
|
return {
|
|
5799
5616
|
async executeTurn(request) {
|
|
5800
|
-
|
|
5801
|
-
const officerStationChild = request.stationChild === true && isOfficerReviewSeat(request.activation.role);
|
|
5802
|
-
const paths = !officerStationChild && request.hostTransition?.priorNativeKind === "sitian" ? request.hostTransition.priorNativePaths : void 0;
|
|
5803
|
-
if (request.continuation.kind === "resume" && paths !== void 0 && paths.length > 0) {
|
|
5804
|
-
turnRequest = {
|
|
5805
|
-
...request,
|
|
5806
|
-
continuation: {
|
|
5807
|
-
...request.continuation,
|
|
5808
|
-
prompt: `${request.continuation.prompt}
|
|
5809
|
-
${paths.join("\n")}`
|
|
5810
|
-
}
|
|
5811
|
-
};
|
|
5812
|
-
}
|
|
5617
|
+
const turnRequest = request;
|
|
5813
5618
|
const roleEntry = await realpath(resolveInternalRoleEntrypoint(config.packageRoot));
|
|
5814
5619
|
const extraArgs = buildPiTurnExtraArgs(
|
|
5815
5620
|
turnRequest,
|
|
@@ -5889,7 +5694,6 @@ var init_role_turn_host = __esm({
|
|
|
5889
5694
|
"src/pi/role-turn-host.ts"() {
|
|
5890
5695
|
"use strict";
|
|
5891
5696
|
init_host_contracts();
|
|
5892
|
-
init_packaged_role_registry();
|
|
5893
5697
|
init_engine_detour();
|
|
5894
5698
|
init_role_activation_flags();
|
|
5895
5699
|
init_user_dialogue_stdin();
|
|
@@ -6009,9 +5813,9 @@ var init_host_descriptions = __esm({
|
|
|
6009
5813
|
});
|
|
6010
5814
|
|
|
6011
5815
|
// src/sha256.ts
|
|
6012
|
-
import { createHash as
|
|
5816
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
6013
5817
|
function sha256Hex(bytes) {
|
|
6014
|
-
return
|
|
5818
|
+
return createHash4("sha256").update(bytes).digest("hex");
|
|
6015
5819
|
}
|
|
6016
5820
|
var init_sha256 = __esm({
|
|
6017
5821
|
"src/sha256.ts"() {
|
|
@@ -6511,7 +6315,7 @@ var init_merger_git_state = __esm({
|
|
|
6511
6315
|
|
|
6512
6316
|
// src/ledger-session-read.ts
|
|
6513
6317
|
import { readFile as readFile9 } from "node:fs/promises";
|
|
6514
|
-
function
|
|
6318
|
+
function isRecord5(value) {
|
|
6515
6319
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6516
6320
|
}
|
|
6517
6321
|
async function readLedgerSessionJsonlLines(path) {
|
|
@@ -6536,7 +6340,7 @@ async function readLedgerSessionJsonlLines(path) {
|
|
|
6536
6340
|
});
|
|
6537
6341
|
continue;
|
|
6538
6342
|
}
|
|
6539
|
-
if (!
|
|
6343
|
+
if (!isRecord5(row)) {
|
|
6540
6344
|
const kind = row === null ? "null" : Array.isArray(row) ? "array" : typeof row;
|
|
6541
6345
|
out.push({
|
|
6542
6346
|
line: lineNumber,
|
|
@@ -6589,7 +6393,7 @@ function extractSessionModelSequence(rows) {
|
|
|
6589
6393
|
if (row.type === "model_change" && typeof row.modelId === "string") {
|
|
6590
6394
|
push(row.modelId);
|
|
6591
6395
|
}
|
|
6592
|
-
const message =
|
|
6396
|
+
const message = isRecord5(row.message) ? row.message : void 0;
|
|
6593
6397
|
if (message?.role === "assistant" && typeof message.model === "string") {
|
|
6594
6398
|
push(message.model);
|
|
6595
6399
|
}
|
|
@@ -6605,11 +6409,11 @@ function extractSessionToolIntervals(rows) {
|
|
|
6605
6409
|
const openById = /* @__PURE__ */ new Map();
|
|
6606
6410
|
for (const row of rows) {
|
|
6607
6411
|
const rowTimestamp = typeof row.timestamp === "string" ? row.timestamp : void 0;
|
|
6608
|
-
const message =
|
|
6412
|
+
const message = isRecord5(row.message) ? row.message : void 0;
|
|
6609
6413
|
if (message?.role === "assistant" && Array.isArray(message.content)) {
|
|
6610
6414
|
const callTimestamp = typeof message.timestamp === "string" && message.timestamp ? message.timestamp : rowTimestamp;
|
|
6611
6415
|
for (const part of message.content) {
|
|
6612
|
-
if (!
|
|
6416
|
+
if (!isRecord5(part) || part.type !== "toolCall") continue;
|
|
6613
6417
|
if (typeof part.id !== "string" || part.id.length === 0) {
|
|
6614
6418
|
throw new Error("toolCall frame missing string id");
|
|
6615
6419
|
}
|
|
@@ -6622,7 +6426,7 @@ function extractSessionToolIntervals(rows) {
|
|
|
6622
6426
|
if (openById.has(part.id)) {
|
|
6623
6427
|
throw new Error(`duplicate toolCall id ${part.id}`);
|
|
6624
6428
|
}
|
|
6625
|
-
const args =
|
|
6429
|
+
const args = isRecord5(part.arguments) ? part.arguments : void 0;
|
|
6626
6430
|
const command = part.name === "bash" && args !== void 0 && typeof args.command === "string" ? bashCommandFirstLine(args.command) : void 0;
|
|
6627
6431
|
const interval = {
|
|
6628
6432
|
toolCallId: part.id,
|
|
@@ -6706,7 +6510,7 @@ var init_ledger_session_read = __esm({
|
|
|
6706
6510
|
});
|
|
6707
6511
|
|
|
6708
6512
|
// src/session-dialogue.ts
|
|
6709
|
-
function
|
|
6513
|
+
function isRecord6(value) {
|
|
6710
6514
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6711
6515
|
}
|
|
6712
6516
|
function nativeEventId(row) {
|
|
@@ -6716,7 +6520,7 @@ function nativeEventId(row) {
|
|
|
6716
6520
|
}
|
|
6717
6521
|
for (const nestKey of ["message", "payload"]) {
|
|
6718
6522
|
const nested = row[nestKey];
|
|
6719
|
-
if (!
|
|
6523
|
+
if (!isRecord6(nested)) continue;
|
|
6720
6524
|
for (const key of ["uuid", "id"]) {
|
|
6721
6525
|
const value = nested[key];
|
|
6722
6526
|
if (typeof value === "string" && value !== "") return value;
|
|
@@ -6729,19 +6533,19 @@ function textParts(content) {
|
|
|
6729
6533
|
if (!Array.isArray(content)) return [];
|
|
6730
6534
|
const out = [];
|
|
6731
6535
|
for (const part of content) {
|
|
6732
|
-
if (!
|
|
6536
|
+
if (!isRecord6(part) || !SPEAKER_TEXT_PART_TYPES.has(String(part.type))) continue;
|
|
6733
6537
|
const text = part.text;
|
|
6734
6538
|
if (typeof text === "string" && text !== "") out.push(text);
|
|
6735
6539
|
}
|
|
6736
6540
|
return out;
|
|
6737
6541
|
}
|
|
6738
6542
|
function responseItemMessage(row) {
|
|
6739
|
-
if (row.type !== "response_item" || !
|
|
6543
|
+
if (row.type !== "response_item" || !isRecord6(row.payload)) return void 0;
|
|
6740
6544
|
if (row.payload.type !== "message") return void 0;
|
|
6741
6545
|
return row.payload;
|
|
6742
6546
|
}
|
|
6743
6547
|
function messageBody(row) {
|
|
6744
|
-
if (
|
|
6548
|
+
if (isRecord6(row.message)) return row.message;
|
|
6745
6549
|
return responseItemMessage(row);
|
|
6746
6550
|
}
|
|
6747
6551
|
function speakerOf(message) {
|
|
@@ -6751,7 +6555,7 @@ function speakerOf(message) {
|
|
|
6751
6555
|
}
|
|
6752
6556
|
function codexContentItemKinds(message) {
|
|
6753
6557
|
const pass = message.internal_chat_message_metadata_passthrough;
|
|
6754
|
-
if (!
|
|
6558
|
+
if (!isRecord6(pass) || !Array.isArray(pass.content_item_kinds)) return void 0;
|
|
6755
6559
|
const kinds = [];
|
|
6756
6560
|
for (const kind of pass.content_item_kinds) {
|
|
6757
6561
|
if (typeof kind === "string" && kind !== "") kinds.push(kind);
|
|
@@ -6780,7 +6584,7 @@ function isFixedNonOwnerEnqueueShape(content) {
|
|
|
6780
6584
|
return hasFixedOpenTagPrefix(content, TASK_NOTIFICATION_OPEN_TAG);
|
|
6781
6585
|
}
|
|
6782
6586
|
function materializationOriginKind(row) {
|
|
6783
|
-
if (!
|
|
6587
|
+
if (!isRecord6(row.origin)) return void 0;
|
|
6784
6588
|
const kind = row.origin.kind;
|
|
6785
6589
|
return typeof kind === "string" && kind !== "" ? kind : void 0;
|
|
6786
6590
|
}
|
|
@@ -6827,7 +6631,6 @@ var init_session_dialogue = __esm({
|
|
|
6827
6631
|
});
|
|
6828
6632
|
|
|
6829
6633
|
// src/ticket-provenance.ts
|
|
6830
|
-
import { createHash as createHash6 } from "node:crypto";
|
|
6831
6634
|
import { readFile as readFile10, unlink as unlink2 } from "node:fs/promises";
|
|
6832
6635
|
import { basename as basename4, dirname as dirname8, join as join13, resolve as resolve7 } from "node:path";
|
|
6833
6636
|
function dialogueSessionSourceRoots(home) {
|
|
@@ -6878,175 +6681,6 @@ function resolveTicketProvenanceVolume(ticketNumber, cwd, home) {
|
|
|
6878
6681
|
);
|
|
6879
6682
|
return { recordFile: path.recordFile, volumeDir: path.sessionDir };
|
|
6880
6683
|
}
|
|
6881
|
-
function projectTicketProvenanceRaw(value) {
|
|
6882
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
6883
|
-
const raw = value;
|
|
6884
|
-
if (typeof raw.raw !== "string" || !Number.isInteger(raw.s) || raw.s < 0 || !Number.isInteger(raw.sourcePosition) || raw.sourcePosition < 0) {
|
|
6885
|
-
return void 0;
|
|
6886
|
-
}
|
|
6887
|
-
const sourceIdentity = typeof raw.sourceIdentity === "string" && raw.sourceIdentity !== "" ? raw.sourceIdentity : void 0;
|
|
6888
|
-
return {
|
|
6889
|
-
raw: raw.raw,
|
|
6890
|
-
s: raw.s,
|
|
6891
|
-
sourcePosition: raw.sourcePosition,
|
|
6892
|
-
...sourceIdentity === void 0 ? {} : { sourceIdentity }
|
|
6893
|
-
};
|
|
6894
|
-
}
|
|
6895
|
-
function projectTicketProvenanceCommit(value) {
|
|
6896
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
6897
|
-
const record4 = value;
|
|
6898
|
-
if (record4.kind !== TICKET_PROVENANCE_KIND || typeof record4.timestamp !== "string") {
|
|
6899
|
-
return void 0;
|
|
6900
|
-
}
|
|
6901
|
-
const payload = record4.payload;
|
|
6902
|
-
if (typeof payload !== "object" || payload === null || Array.isArray(payload)) return void 0;
|
|
6903
|
-
const body = payload;
|
|
6904
|
-
if (body.type !== "ticket-provenance-append") return void 0;
|
|
6905
|
-
const sessions = projectTicketProvenanceSessions(body.sessions);
|
|
6906
|
-
if (sessions === void 0 || !Array.isArray(body.lines)) return void 0;
|
|
6907
|
-
const lines = [];
|
|
6908
|
-
for (const raw of body.lines) {
|
|
6909
|
-
if (typeof raw === "string") {
|
|
6910
|
-
lines.push(raw);
|
|
6911
|
-
continue;
|
|
6912
|
-
}
|
|
6913
|
-
const line2 = projectTicketProvenanceLine(raw);
|
|
6914
|
-
if (line2 !== void 0) {
|
|
6915
|
-
lines.push(line2);
|
|
6916
|
-
continue;
|
|
6917
|
-
}
|
|
6918
|
-
const preserved = projectTicketProvenanceRaw(raw);
|
|
6919
|
-
if (preserved === void 0) return void 0;
|
|
6920
|
-
lines.push(preserved);
|
|
6921
|
-
}
|
|
6922
|
-
return { timestamp: record4.timestamp, sessions, lines };
|
|
6923
|
-
}
|
|
6924
|
-
async function readTicketProvenance(ticketNumber, cwd, home, runDirectory) {
|
|
6925
|
-
const { recordFile } = ticketNumber === null ? resolveSitianRecordPath(ticketProvenanceRecordInput(null, cwd, home, runDirectory)) : resolveTicketProvenanceVolume(ticketNumber, cwd, home);
|
|
6926
|
-
let text;
|
|
6927
|
-
try {
|
|
6928
|
-
text = await readFile10(recordFile, "utf8");
|
|
6929
|
-
} catch (error) {
|
|
6930
|
-
if (error.code === "ENOENT") {
|
|
6931
|
-
return {
|
|
6932
|
-
header: void 0,
|
|
6933
|
-
lines: [],
|
|
6934
|
-
unprojectedRaw: [],
|
|
6935
|
-
recordFile,
|
|
6936
|
-
sourceIdentities: /* @__PURE__ */ new Map(),
|
|
6937
|
-
legacySourcePositions: /* @__PURE__ */ new Map()
|
|
6938
|
-
};
|
|
6939
|
-
}
|
|
6940
|
-
throw error;
|
|
6941
|
-
}
|
|
6942
|
-
const physical = text.split("\n");
|
|
6943
|
-
let header;
|
|
6944
|
-
const lines = [];
|
|
6945
|
-
const unprojectedRaw = [];
|
|
6946
|
-
const sourceIdentities = /* @__PURE__ */ new Map();
|
|
6947
|
-
const legacySourcePositions = /* @__PURE__ */ new Map();
|
|
6948
|
-
const rememberIdentity = (s, identity) => {
|
|
6949
|
-
const seen = sourceIdentities.get(s) ?? /* @__PURE__ */ new Set();
|
|
6950
|
-
const fresh = !seen.has(identity);
|
|
6951
|
-
seen.add(identity);
|
|
6952
|
-
sourceIdentities.set(s, seen);
|
|
6953
|
-
return fresh;
|
|
6954
|
-
};
|
|
6955
|
-
const rememberLegacyPosition = (s, position) => {
|
|
6956
|
-
const seen = legacySourcePositions.get(s) ?? /* @__PURE__ */ new Set();
|
|
6957
|
-
seen.add(position);
|
|
6958
|
-
legacySourcePositions.set(s, seen);
|
|
6959
|
-
};
|
|
6960
|
-
const remapCoverage = (coverage, priorIndexes) => {
|
|
6961
|
-
const normalized = /* @__PURE__ */ new Map();
|
|
6962
|
-
for (const [s, values] of coverage) {
|
|
6963
|
-
const target = priorIndexes[s] ?? s;
|
|
6964
|
-
const union = normalized.get(target) ?? /* @__PURE__ */ new Set();
|
|
6965
|
-
for (const value of values) union.add(value);
|
|
6966
|
-
normalized.set(target, union);
|
|
6967
|
-
}
|
|
6968
|
-
coverage.clear();
|
|
6969
|
-
for (const [s, values] of normalized) coverage.set(s, values);
|
|
6970
|
-
};
|
|
6971
|
-
let sawFirst = false;
|
|
6972
|
-
for (let index = 0; index < physical.length; index += 1) {
|
|
6973
|
-
const raw = physical[index];
|
|
6974
|
-
if (!raw.trim()) continue;
|
|
6975
|
-
let parsed;
|
|
6976
|
-
try {
|
|
6977
|
-
parsed = JSON.parse(raw);
|
|
6978
|
-
} catch {
|
|
6979
|
-
unprojectedRaw.push(raw);
|
|
6980
|
-
continue;
|
|
6981
|
-
}
|
|
6982
|
-
if (!sawFirst) {
|
|
6983
|
-
sawFirst = true;
|
|
6984
|
-
header = projectTicketProvenanceHeader(parsed);
|
|
6985
|
-
if (header !== void 0) continue;
|
|
6986
|
-
}
|
|
6987
|
-
const line2 = projectTicketProvenanceLine(parsed);
|
|
6988
|
-
if (line2 !== void 0) {
|
|
6989
|
-
lines.push(line2);
|
|
6990
|
-
continue;
|
|
6991
|
-
}
|
|
6992
|
-
const commit = projectTicketProvenanceCommit(parsed);
|
|
6993
|
-
if (commit !== void 0) {
|
|
6994
|
-
const merged = mergeSessionBounds(header?.sessions, commit.sessions);
|
|
6995
|
-
remapCoverage(sourceIdentities, merged.priorIndexes);
|
|
6996
|
-
remapCoverage(legacySourcePositions, merged.priorIndexes);
|
|
6997
|
-
const remapped = [];
|
|
6998
|
-
for (const entry of commit.lines) {
|
|
6999
|
-
if (typeof entry === "string") {
|
|
7000
|
-
unprojectedRaw.push(entry);
|
|
7001
|
-
continue;
|
|
7002
|
-
}
|
|
7003
|
-
const s = merged.incomingIndexes[entry.s] ?? merged.priorIndexes[entry.s] ?? entry.s;
|
|
7004
|
-
if ("raw" in entry) {
|
|
7005
|
-
if (entry.sourceIdentity !== void 0) {
|
|
7006
|
-
if (rememberIdentity(s, entry.sourceIdentity)) unprojectedRaw.push(entry.raw);
|
|
7007
|
-
} else {
|
|
7008
|
-
rememberLegacyPosition(s, entry.sourcePosition);
|
|
7009
|
-
unprojectedRaw.push(entry.raw);
|
|
7010
|
-
}
|
|
7011
|
-
continue;
|
|
7012
|
-
}
|
|
7013
|
-
remapped.push({ ...entry, s });
|
|
7014
|
-
if (entry.id === void 0) {
|
|
7015
|
-
if (entry.sourceIdentity !== void 0) rememberIdentity(s, entry.sourceIdentity);
|
|
7016
|
-
else if (entry.sourcePosition !== void 0) rememberLegacyPosition(s, entry.sourcePosition);
|
|
7017
|
-
}
|
|
7018
|
-
}
|
|
7019
|
-
const now = commit.timestamp;
|
|
7020
|
-
header = {
|
|
7021
|
-
repo: header?.repo ?? resolveBookKeyFromGit(cwd),
|
|
7022
|
-
ticket: ticketNumber,
|
|
7023
|
-
createdAt: header?.createdAt ?? now,
|
|
7024
|
-
updatedAt: header?.updatedAt !== void 0 && header.updatedAt > now ? header.updatedAt : now,
|
|
7025
|
-
sessions: merged.sessions
|
|
7026
|
-
};
|
|
7027
|
-
const carried = lines.map((entry) => ({
|
|
7028
|
-
...entry,
|
|
7029
|
-
s: merged.priorIndexes[entry.s] ?? entry.s
|
|
7030
|
-
}));
|
|
7031
|
-
lines.splice(0, lines.length, ...mergeFreshIntoCarried(carried, remapped));
|
|
7032
|
-
continue;
|
|
7033
|
-
}
|
|
7034
|
-
unprojectedRaw.push(raw);
|
|
7035
|
-
}
|
|
7036
|
-
for (const line2 of lines) {
|
|
7037
|
-
if (line2.id !== void 0) continue;
|
|
7038
|
-
if (line2.sourceIdentity !== void 0) rememberIdentity(line2.s, line2.sourceIdentity);
|
|
7039
|
-
else if (line2.sourcePosition !== void 0) rememberLegacyPosition(line2.s, line2.sourcePosition);
|
|
7040
|
-
}
|
|
7041
|
-
return {
|
|
7042
|
-
header,
|
|
7043
|
-
lines,
|
|
7044
|
-
unprojectedRaw,
|
|
7045
|
-
recordFile,
|
|
7046
|
-
sourceIdentities,
|
|
7047
|
-
legacySourcePositions
|
|
7048
|
-
};
|
|
7049
|
-
}
|
|
7050
6684
|
async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, home) {
|
|
7051
6685
|
const source = join13(runDirectory, "records.jsonl");
|
|
7052
6686
|
let content;
|
|
@@ -7076,110 +6710,6 @@ function resolveBoundIndex(bound, sessionLines) {
|
|
|
7076
6710
|
}
|
|
7077
6711
|
return void 0;
|
|
7078
6712
|
}
|
|
7079
|
-
function dialogueIdentity(s, id) {
|
|
7080
|
-
return `${s}\0${id}`;
|
|
7081
|
-
}
|
|
7082
|
-
function rangeDeclarationKey(range) {
|
|
7083
|
-
return JSON.stringify({
|
|
7084
|
-
from: range.from,
|
|
7085
|
-
to: range.to
|
|
7086
|
-
});
|
|
7087
|
-
}
|
|
7088
|
-
function mergeSessionBounds(prior, incoming) {
|
|
7089
|
-
const merged = [];
|
|
7090
|
-
const indexByIdentity = /* @__PURE__ */ new Map();
|
|
7091
|
-
const absorb = (sessions) => {
|
|
7092
|
-
const indexes = [];
|
|
7093
|
-
for (const session of sessions) {
|
|
7094
|
-
const identity = physicalPathIdentity(session.path);
|
|
7095
|
-
let targetIndex = indexByIdentity.get(identity);
|
|
7096
|
-
if (targetIndex === void 0) {
|
|
7097
|
-
targetIndex = merged.length;
|
|
7098
|
-
indexByIdentity.set(identity, targetIndex);
|
|
7099
|
-
merged.push({ path: session.path, ranges: [] });
|
|
7100
|
-
}
|
|
7101
|
-
indexes.push(targetIndex);
|
|
7102
|
-
const target = merged[targetIndex];
|
|
7103
|
-
const seen = new Set(target.ranges.map(rangeDeclarationKey));
|
|
7104
|
-
for (const range of session.ranges) {
|
|
7105
|
-
const key = rangeDeclarationKey(range);
|
|
7106
|
-
if (seen.has(key)) continue;
|
|
7107
|
-
seen.add(key);
|
|
7108
|
-
target.ranges.push({ from: { ...range.from }, to: { ...range.to } });
|
|
7109
|
-
}
|
|
7110
|
-
}
|
|
7111
|
-
return indexes;
|
|
7112
|
-
};
|
|
7113
|
-
const priorIndexes = absorb(prior ?? []);
|
|
7114
|
-
const incomingIndexes = absorb(incoming);
|
|
7115
|
-
return { sessions: merged, priorIndexes, incomingIndexes };
|
|
7116
|
-
}
|
|
7117
|
-
function undeclaredSessionRanges(prior, merged) {
|
|
7118
|
-
const priorKeys = /* @__PURE__ */ new Map();
|
|
7119
|
-
for (const session of prior ?? []) {
|
|
7120
|
-
const identity = physicalPathIdentity(session.path);
|
|
7121
|
-
let keys = priorKeys.get(identity);
|
|
7122
|
-
if (keys === void 0) {
|
|
7123
|
-
keys = /* @__PURE__ */ new Set();
|
|
7124
|
-
priorKeys.set(identity, keys);
|
|
7125
|
-
}
|
|
7126
|
-
for (const range of session.ranges) keys.add(rangeDeclarationKey(range));
|
|
7127
|
-
}
|
|
7128
|
-
const out = [];
|
|
7129
|
-
for (let s = 0; s < merged.length; s += 1) {
|
|
7130
|
-
const session = merged[s];
|
|
7131
|
-
const identity = physicalPathIdentity(session.path);
|
|
7132
|
-
const declared = priorKeys.get(identity) ?? /* @__PURE__ */ new Set();
|
|
7133
|
-
const fresh = session.ranges.filter(
|
|
7134
|
-
(range) => !declared.has(rangeDeclarationKey(range))
|
|
7135
|
-
);
|
|
7136
|
-
if (fresh.length === 0) continue;
|
|
7137
|
-
out.push({
|
|
7138
|
-
s,
|
|
7139
|
-
session: {
|
|
7140
|
-
path: session.path,
|
|
7141
|
-
ranges: fresh.map((range) => ({
|
|
7142
|
-
from: { ...range.from },
|
|
7143
|
-
to: { ...range.to }
|
|
7144
|
-
}))
|
|
7145
|
-
}
|
|
7146
|
-
});
|
|
7147
|
-
}
|
|
7148
|
-
return out;
|
|
7149
|
-
}
|
|
7150
|
-
function mergeFreshIntoCarried(carried, fresh) {
|
|
7151
|
-
const seenSources = /* @__PURE__ */ new Map();
|
|
7152
|
-
const bySession = /* @__PURE__ */ new Map();
|
|
7153
|
-
const absorb = (lines) => {
|
|
7154
|
-
for (const line2 of lines) {
|
|
7155
|
-
const sourceIdentity = line2.id === void 0 ? line2.sourceIdentity : `id\0${line2.id}`;
|
|
7156
|
-
const identity = sourceIdentity === void 0 ? void 0 : `${line2.s}\0${sourceIdentity}`;
|
|
7157
|
-
const seen = identity === void 0 ? void 0 : seenSources.get(identity);
|
|
7158
|
-
if (seen !== void 0) {
|
|
7159
|
-
if (line2.sourcePosition !== void 0) {
|
|
7160
|
-
Object.assign(seen, { sourcePosition: line2.sourcePosition });
|
|
7161
|
-
}
|
|
7162
|
-
continue;
|
|
7163
|
-
}
|
|
7164
|
-
const bucket = bySession.get(line2.s) ?? [];
|
|
7165
|
-
bucket.push({ ...line2 });
|
|
7166
|
-
if (identity !== void 0) seenSources.set(identity, bucket.at(-1));
|
|
7167
|
-
bySession.set(line2.s, bucket);
|
|
7168
|
-
}
|
|
7169
|
-
};
|
|
7170
|
-
absorb(carried);
|
|
7171
|
-
absorb(fresh);
|
|
7172
|
-
return [...bySession.entries()].sort(([left], [right]) => left - right).flatMap(([, lines]) => lines.map((line2, archiveIndex) => ({ line: line2, archiveIndex })).sort((left, right) => {
|
|
7173
|
-
const leftPosition = left.line.sourcePosition;
|
|
7174
|
-
const rightPosition = right.line.sourcePosition;
|
|
7175
|
-
if (leftPosition === void 0 && rightPosition === void 0) {
|
|
7176
|
-
return left.archiveIndex - right.archiveIndex;
|
|
7177
|
-
}
|
|
7178
|
-
if (leftPosition === void 0) return 1;
|
|
7179
|
-
if (rightPosition === void 0) return -1;
|
|
7180
|
-
return leftPosition - rightPosition || left.archiveIndex - right.archiveIndex;
|
|
7181
|
-
}).map(({ line: line2 }) => line2));
|
|
7182
|
-
}
|
|
7183
6713
|
function stableSourceFacts(sessionLines) {
|
|
7184
6714
|
const positionByIdentity = /* @__PURE__ */ new Map();
|
|
7185
6715
|
const facts = [];
|
|
@@ -7254,13 +6784,7 @@ async function projectSessionRanges(input) {
|
|
|
7254
6784
|
const rows = sessionLines.map((entry) => entry.row);
|
|
7255
6785
|
const dialogue = adaptSessionDialogue(rows);
|
|
7256
6786
|
const sourceFacts = stableSourceFacts(sessionLines);
|
|
7257
|
-
const
|
|
7258
|
-
for (const fact of sourceFacts) {
|
|
7259
|
-
sourcePositionByIdentity.set(fact.identity, fact.position);
|
|
7260
|
-
}
|
|
7261
|
-
const seenIds = input.seenIds;
|
|
7262
|
-
const lines = [];
|
|
7263
|
-
const raw = [];
|
|
6787
|
+
const entries = [];
|
|
7264
6788
|
const ranges = normalizeResolvedRanges(
|
|
7265
6789
|
input.session.ranges,
|
|
7266
6790
|
sessionLines,
|
|
@@ -7269,19 +6793,13 @@ async function projectSessionRanges(input) {
|
|
|
7269
6793
|
for (const range of ranges) {
|
|
7270
6794
|
for (let index = range.fromIndex; index <= range.toIndex; index += 1) {
|
|
7271
6795
|
const { position: sourcePosition, identity: sourceIdentity } = sourceFacts[index];
|
|
7272
|
-
if (input.coveredSourceIdentities.has(sourceIdentity) || input.legacyCoveredSourcePositions.has(sourcePosition)) continue;
|
|
7273
6796
|
const entry = sessionLines[index];
|
|
7274
6797
|
if (entry.row === void 0) {
|
|
7275
|
-
|
|
6798
|
+
entries.push({ raw: entry.raw, s: input.s, sourcePosition, sourceIdentity });
|
|
7276
6799
|
continue;
|
|
7277
6800
|
}
|
|
7278
6801
|
for (const event of dialogue[index] ?? []) {
|
|
7279
|
-
|
|
7280
|
-
const identity = dialogueIdentity(input.s, event.id);
|
|
7281
|
-
if (seenIds.has(identity)) continue;
|
|
7282
|
-
seenIds.add(identity);
|
|
7283
|
-
}
|
|
7284
|
-
lines.push({
|
|
6802
|
+
entries.push({
|
|
7285
6803
|
speaker: event.speaker,
|
|
7286
6804
|
s: input.s,
|
|
7287
6805
|
sourcePosition,
|
|
@@ -7291,106 +6809,49 @@ async function projectSessionRanges(input) {
|
|
|
7291
6809
|
}
|
|
7292
6810
|
}
|
|
7293
6811
|
}
|
|
7294
|
-
return {
|
|
6812
|
+
return { entries };
|
|
7295
6813
|
}
|
|
7296
6814
|
async function reprojectTicketProvenance(input) {
|
|
7297
|
-
const
|
|
6815
|
+
const recordInput = ticketProvenanceRecordInput(
|
|
6816
|
+
input.ticketNumber,
|
|
6817
|
+
input.cwd,
|
|
6818
|
+
input.home,
|
|
6819
|
+
input.runDirectory
|
|
6820
|
+
);
|
|
6821
|
+
const resolved = resolveSitianRecordPath(recordInput);
|
|
7298
6822
|
if (input.sessions.length === 0) {
|
|
7299
|
-
const now2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
7300
6823
|
return {
|
|
7301
|
-
recordFile:
|
|
7302
|
-
|
|
7303
|
-
repo: resolveBookKeyFromGit(input.cwd),
|
|
7304
|
-
ticket: input.ticketNumber,
|
|
7305
|
-
createdAt: now2,
|
|
7306
|
-
updatedAt: now2,
|
|
7307
|
-
sessions: []
|
|
7308
|
-
},
|
|
7309
|
-
lines: prior.lines
|
|
6824
|
+
recordFile: resolved.recordFile,
|
|
6825
|
+
lines: []
|
|
7310
6826
|
};
|
|
7311
6827
|
}
|
|
7312
|
-
const
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
const now2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
7316
|
-
return {
|
|
7317
|
-
recordFile: prior.recordFile,
|
|
7318
|
-
header: prior.header ?? {
|
|
7319
|
-
repo: resolveBookKeyFromGit(input.cwd),
|
|
7320
|
-
ticket: input.ticketNumber,
|
|
7321
|
-
createdAt: now2,
|
|
7322
|
-
updatedAt: now2,
|
|
7323
|
-
sessions: merged.sessions
|
|
7324
|
-
},
|
|
7325
|
-
lines: prior.lines
|
|
7326
|
-
};
|
|
7327
|
-
}
|
|
7328
|
-
const seenIds = new Set(
|
|
7329
|
-
prior.lines.flatMap(
|
|
7330
|
-
(line2) => line2.id === void 0 ? [] : [dialogueIdentity(line2.s, line2.id)]
|
|
7331
|
-
)
|
|
7332
|
-
);
|
|
7333
|
-
const fresh = [];
|
|
7334
|
-
const raw = [];
|
|
7335
|
-
for (const delta of deltas) {
|
|
6828
|
+
const entries = [];
|
|
6829
|
+
for (let s = 0; s < input.sessions.length; s += 1) {
|
|
6830
|
+
const session = input.sessions[s];
|
|
7336
6831
|
const projected = await projectSessionRanges({
|
|
7337
|
-
s
|
|
7338
|
-
session
|
|
7339
|
-
seenIds,
|
|
7340
|
-
coveredSourceIdentities: prior.sourceIdentities.get(delta.s) ?? /* @__PURE__ */ new Set(),
|
|
7341
|
-
legacyCoveredSourcePositions: prior.legacySourcePositions.get(delta.s) ?? /* @__PURE__ */ new Set(),
|
|
6832
|
+
s,
|
|
6833
|
+
session,
|
|
7342
6834
|
...input.home === void 0 ? {} : { home: input.home }
|
|
7343
6835
|
});
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
const sourceIdentity = line2.id === void 0 ? line2.sourceIdentity : `id\0${line2.id}`;
|
|
7347
|
-
if (sourceIdentity === void 0) return [];
|
|
7348
|
-
const sourcePosition = projected.sourcePositionByIdentity.get(sourceIdentity);
|
|
7349
|
-
return sourcePosition === void 0 ? [] : [{ ...line2, sourcePosition }];
|
|
7350
|
-
}));
|
|
7351
|
-
fresh.push(...projected.lines);
|
|
7352
|
-
raw.push(...projected.raw);
|
|
7353
|
-
}
|
|
7354
|
-
const lines = mergeFreshIntoCarried(prior.lines, fresh);
|
|
7355
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
7356
|
-
const header = {
|
|
7357
|
-
repo: prior.header?.repo ?? resolveBookKeyFromGit(input.cwd),
|
|
7358
|
-
ticket: input.ticketNumber,
|
|
7359
|
-
createdAt: prior.header?.createdAt ?? now,
|
|
7360
|
-
updatedAt: now,
|
|
7361
|
-
sessions: merged.sessions
|
|
7362
|
-
};
|
|
7363
|
-
const identityMaterial = JSON.stringify({
|
|
7364
|
-
ticket: input.ticketNumber,
|
|
7365
|
-
deltas: deltas.map(({ s, session }) => ({
|
|
7366
|
-
s,
|
|
7367
|
-
path: physicalPathIdentity(session.path),
|
|
7368
|
-
ranges: session.ranges
|
|
7369
|
-
})),
|
|
7370
|
-
lines: [...fresh, ...raw]
|
|
7371
|
-
});
|
|
7372
|
-
const identity = `ticket-provenance:${createHash6("sha256").update(identityMaterial).digest("hex")}`;
|
|
6836
|
+
entries.push(...projected.entries);
|
|
6837
|
+
}
|
|
7373
6838
|
const pointer = appendSitianRecord({
|
|
7374
|
-
...
|
|
7375
|
-
identity,
|
|
6839
|
+
...recordInput,
|
|
7376
6840
|
payload: {
|
|
7377
6841
|
type: "ticket-provenance-append",
|
|
7378
|
-
sessions:
|
|
7379
|
-
lines:
|
|
6842
|
+
sessions: input.sessions,
|
|
6843
|
+
lines: entries
|
|
7380
6844
|
}
|
|
7381
6845
|
});
|
|
7382
|
-
const folded = await readTicketProvenance(input.ticketNumber, input.cwd, input.home, input.runDirectory);
|
|
7383
6846
|
return {
|
|
7384
6847
|
recordFile: pointer.recordFile,
|
|
7385
|
-
|
|
7386
|
-
lines: folded.lines
|
|
6848
|
+
lines: entries.filter((entry) => "speaker" in entry)
|
|
7387
6849
|
};
|
|
7388
6850
|
}
|
|
7389
6851
|
var TicketProvenanceInputError;
|
|
7390
6852
|
var init_ticket_provenance = __esm({
|
|
7391
6853
|
"src/ticket-provenance.ts"() {
|
|
7392
6854
|
"use strict";
|
|
7393
|
-
init_activation_ledger_git();
|
|
7394
6855
|
init_activation_ledger_topology();
|
|
7395
6856
|
init_ledger_session_read();
|
|
7396
6857
|
init_run_ticket_number();
|
|
@@ -8716,7 +8177,7 @@ var init_option_definitions = __esm({
|
|
|
8716
8177
|
|
|
8717
8178
|
// src/public-cli/invocation.ts
|
|
8718
8179
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
8719
|
-
import { existsSync as
|
|
8180
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
8720
8181
|
import {
|
|
8721
8182
|
lstat as lstat3,
|
|
8722
8183
|
mkdtemp as mkdtemp2,
|
|
@@ -8942,7 +8403,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
8942
8403
|
for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
|
|
8943
8404
|
if (typeof childRunId !== "string") continue;
|
|
8944
8405
|
const childDirectory = join15(dirname10(oldRunDirectory), `${childRunId}@diarist`);
|
|
8945
|
-
if (!
|
|
8406
|
+
if (!existsSync3(childDirectory)) continue;
|
|
8946
8407
|
const childTarget = roleRunPlacement(ledgerHome, {
|
|
8947
8408
|
bookKey: admitted.bookKey,
|
|
8948
8409
|
subject: { ticketNumber: admitted.ticketNumber },
|
|
@@ -10424,7 +9885,7 @@ var init_invocation = __esm({
|
|
|
10424
9885
|
});
|
|
10425
9886
|
|
|
10426
9887
|
// src/public-cli/load-production-acp-host.ts
|
|
10427
|
-
import { existsSync as
|
|
9888
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
10428
9889
|
import { join as join16 } from "node:path";
|
|
10429
9890
|
import { pathToFileURL } from "node:url";
|
|
10430
9891
|
async function loadProductionAcpHostFactory(packageRoot, host) {
|
|
@@ -10434,7 +9895,7 @@ async function loadProductionAcpHostFactory(packageRoot, host) {
|
|
|
10434
9895
|
}
|
|
10435
9896
|
const built = join16(packageRoot, "dist/acp-host/production-host.js");
|
|
10436
9897
|
const source = join16(packageRoot, "src/acp-host/production-host.ts");
|
|
10437
|
-
const target =
|
|
9898
|
+
const target = existsSync4(built) ? built : source;
|
|
10438
9899
|
const href = pathToFileURL(target).href;
|
|
10439
9900
|
const mod = await import(href);
|
|
10440
9901
|
const create = mod.createProductionAcpRoleTurnHost;
|
|
@@ -10448,7 +9909,7 @@ var init_load_production_acp_host = __esm({
|
|
|
10448
9909
|
});
|
|
10449
9910
|
|
|
10450
9911
|
// src/public-cli/load-production-headless-host.ts
|
|
10451
|
-
import { existsSync as
|
|
9912
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
10452
9913
|
import { join as join17 } from "node:path";
|
|
10453
9914
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
10454
9915
|
async function loadProductionHeadlessHostFactory(packageRoot, host) {
|
|
@@ -10458,7 +9919,7 @@ async function loadProductionHeadlessHostFactory(packageRoot, host) {
|
|
|
10458
9919
|
}
|
|
10459
9920
|
const built = join17(packageRoot, "dist/headless-host/production-host.js");
|
|
10460
9921
|
const source = join17(packageRoot, "src/headless-host/production-host.ts");
|
|
10461
|
-
const target =
|
|
9922
|
+
const target = existsSync5(built) ? built : source;
|
|
10462
9923
|
const href = pathToFileURL2(target).href;
|
|
10463
9924
|
const mod = await import(href);
|
|
10464
9925
|
const create = mod.createProductionHeadlessRoleTurnHost;
|
|
@@ -11144,7 +10605,7 @@ __export(host_providers_exports, {
|
|
|
11144
10605
|
projectHostFacingProvider: () => projectHostFacingProvider,
|
|
11145
10606
|
renderHostProvidersTable: () => renderHostProvidersTable
|
|
11146
10607
|
});
|
|
11147
|
-
import { readFileSync
|
|
10608
|
+
import { readFileSync } from "node:fs";
|
|
11148
10609
|
import { join as join19 } from "node:path";
|
|
11149
10610
|
function hostProvidersPath(home) {
|
|
11150
10611
|
if (typeof home !== "string" || home.trim() === "") {
|
|
@@ -11192,7 +10653,7 @@ function parseHostProvidersTable(value) {
|
|
|
11192
10653
|
function loadHostProvidersTable(home) {
|
|
11193
10654
|
const path = hostProvidersPath(home);
|
|
11194
10655
|
try {
|
|
11195
|
-
const raw =
|
|
10656
|
+
const raw = readFileSync(path, "utf8");
|
|
11196
10657
|
return parseHostProvidersTable(JSON.parse(raw));
|
|
11197
10658
|
} catch (error) {
|
|
11198
10659
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
@@ -11210,7 +10671,7 @@ function listHermesProvidersForModel(home, seatModel) {
|
|
|
11210
10671
|
const path = hermesProviderModelsCachePath(home);
|
|
11211
10672
|
let text;
|
|
11212
10673
|
try {
|
|
11213
|
-
text =
|
|
10674
|
+
text = readFileSync(path, "utf8");
|
|
11214
10675
|
} catch (error) {
|
|
11215
10676
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
11216
10677
|
return [];
|
|
@@ -11310,7 +10771,7 @@ var init_host_providers = __esm({
|
|
|
11310
10771
|
// src/analyst-gate-cycles-read.ts
|
|
11311
10772
|
import { readdir as readdir4 } from "node:fs/promises";
|
|
11312
10773
|
import { join as join20 } from "node:path";
|
|
11313
|
-
function
|
|
10774
|
+
function isRecord7(value) {
|
|
11314
10775
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11315
10776
|
}
|
|
11316
10777
|
function isParentAttemptBindingRow(row) {
|
|
@@ -11340,7 +10801,7 @@ function isGateTerminatingToolName(toolName) {
|
|
|
11340
10801
|
function acceptedGateReceiptIds(rows) {
|
|
11341
10802
|
const accepted = /* @__PURE__ */ new Set();
|
|
11342
10803
|
for (const row of rows) {
|
|
11343
|
-
const message =
|
|
10804
|
+
const message = isRecord7(row.message) ? row.message : void 0;
|
|
11344
10805
|
if (message?.role !== "toolResult") continue;
|
|
11345
10806
|
if (typeof message.toolCallId !== "string" || message.toolCallId.length === 0) continue;
|
|
11346
10807
|
if (message.isError === false) accepted.add(message.toolCallId);
|
|
@@ -11375,7 +10836,7 @@ function nearestAttemptBindingBefore(rows, beforeIndex) {
|
|
|
11375
10836
|
for (let i = beforeIndex - 1; i >= 0; i -= 1) {
|
|
11376
10837
|
const row = rows[i];
|
|
11377
10838
|
if (!isParentAttemptBindingRow(row)) continue;
|
|
11378
|
-
if (!
|
|
10839
|
+
if (!isRecord7(row.data) || !isRecord7(row.data.parent)) continue;
|
|
11379
10840
|
const id = row.data.parent.attemptEntryId;
|
|
11380
10841
|
const sessionFile = row.data.parent.sessionFile;
|
|
11381
10842
|
return {
|
|
@@ -11390,10 +10851,10 @@ function extractAllAcceptedGateToolCalls(rows) {
|
|
|
11390
10851
|
const out = [];
|
|
11391
10852
|
for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
|
|
11392
10853
|
const row = rows[rowIndex];
|
|
11393
|
-
const message =
|
|
10854
|
+
const message = isRecord7(row.message) ? row.message : void 0;
|
|
11394
10855
|
if (message?.role !== "assistant" || !Array.isArray(message.content)) continue;
|
|
11395
10856
|
for (const part of message.content) {
|
|
11396
|
-
if (!
|
|
10857
|
+
if (!isRecord7(part) || part.type !== "toolCall") continue;
|
|
11397
10858
|
if (typeof part.id !== "string" || part.id.length === 0) continue;
|
|
11398
10859
|
if (typeof part.name !== "string" || part.name.length === 0) continue;
|
|
11399
10860
|
if (!isGateTerminatingToolName(part.name)) continue;
|
|
@@ -11401,7 +10862,7 @@ function extractAllAcceptedGateToolCalls(rows) {
|
|
|
11401
10862
|
const binding = nearestAttemptBindingBefore(rows, rowIndex);
|
|
11402
10863
|
out.push({
|
|
11403
10864
|
toolName: part.name,
|
|
11404
|
-
args:
|
|
10865
|
+
args: isRecord7(part.arguments) ? part.arguments : void 0,
|
|
11405
10866
|
accepted: true,
|
|
11406
10867
|
rowIndex,
|
|
11407
10868
|
...binding
|
|
@@ -11534,7 +10995,7 @@ async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
|
11534
10995
|
{ cause: error }
|
|
11535
10996
|
);
|
|
11536
10997
|
}
|
|
11537
|
-
if (!
|
|
10998
|
+
if (!isRecord7(raw) || raw.kind !== "direct-officer-run-pointer" || raw.version !== 1) {
|
|
11538
10999
|
throw new Error(`direct officer run pointer has unknown shape in ${pointerPath}`);
|
|
11539
11000
|
}
|
|
11540
11001
|
const sessionFile = raw.sessionFile;
|
|
@@ -11609,14 +11070,14 @@ var init_audit_escalation = __esm({
|
|
|
11609
11070
|
});
|
|
11610
11071
|
|
|
11611
11072
|
// src/session-opening-materials.ts
|
|
11612
|
-
import { existsSync as
|
|
11073
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
11613
11074
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
11614
11075
|
import { dirname as dirname12, join as join21 } from "node:path";
|
|
11615
11076
|
import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
11616
11077
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
11617
11078
|
let dir = dirname12(fileURLToPath(moduleUrl));
|
|
11618
11079
|
for (let i = 0; i < 8; i += 1) {
|
|
11619
|
-
if (
|
|
11080
|
+
if (existsSync6(join21(dir, "package.json")) && existsSync6(join21(dir, "souls"))) {
|
|
11620
11081
|
return dir;
|
|
11621
11082
|
}
|
|
11622
11083
|
const parent = dirname12(dir);
|
|
@@ -11839,7 +11300,7 @@ var init_serialize_thrown_value = __esm({
|
|
|
11839
11300
|
|
|
11840
11301
|
// src/engine-detour-usage.ts
|
|
11841
11302
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
11842
|
-
import { readFileSync as
|
|
11303
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
11843
11304
|
import { dirname as dirname13, join as join23 } from "node:path";
|
|
11844
11305
|
function engineDetourStdoutByteLength(stdout) {
|
|
11845
11306
|
return Buffer.byteLength(stdout, "utf8");
|
|
@@ -11893,11 +11354,11 @@ function reportEngineDetourCall(input) {
|
|
|
11893
11354
|
recordPointer: pointer
|
|
11894
11355
|
};
|
|
11895
11356
|
}
|
|
11896
|
-
function
|
|
11357
|
+
function isRecord8(value) {
|
|
11897
11358
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11898
11359
|
}
|
|
11899
11360
|
function callFactFromSitianPayload(payload, pointer) {
|
|
11900
|
-
if (!
|
|
11361
|
+
if (!isRecord8(payload)) return void 0;
|
|
11901
11362
|
if (payload.tool !== ENGINE_DETOUR_TOOL_NAME) return void 0;
|
|
11902
11363
|
if (typeof payload.toolCallId !== "string" || payload.toolCallId.length === 0) {
|
|
11903
11364
|
return void 0;
|
|
@@ -11914,11 +11375,11 @@ function callFactFromSitianPayload(payload, pointer) {
|
|
|
11914
11375
|
};
|
|
11915
11376
|
}
|
|
11916
11377
|
function invocationScopeIdOfRecord(record4) {
|
|
11917
|
-
if (
|
|
11378
|
+
if (isRecord8(record4.subject)) {
|
|
11918
11379
|
const fromSubject = record4.subject.invocationScopeId;
|
|
11919
11380
|
if (typeof fromSubject === "string" && fromSubject.length > 0) return fromSubject;
|
|
11920
11381
|
}
|
|
11921
|
-
if (
|
|
11382
|
+
if (isRecord8(record4.payload)) {
|
|
11922
11383
|
const fromPayload = record4.payload.invocationScopeId;
|
|
11923
11384
|
if (typeof fromPayload === "string" && fromPayload.length > 0) return fromPayload;
|
|
11924
11385
|
}
|
|
@@ -11934,7 +11395,7 @@ async function readEngineDetourToolUsage(input) {
|
|
|
11934
11395
|
...input.cwd === void 0 ? {} : { cwd: input.cwd }
|
|
11935
11396
|
});
|
|
11936
11397
|
const { records } = await readSitianRecords(recordFile);
|
|
11937
|
-
const
|
|
11398
|
+
const callsByToolCallId = /* @__PURE__ */ new Map();
|
|
11938
11399
|
for (const record4 of records) {
|
|
11939
11400
|
if (record4.kind !== ENGINE_DETOUR_CALL_KIND) continue;
|
|
11940
11401
|
const boundScope = invocationScopeIdOfRecord(record4);
|
|
@@ -11951,8 +11412,9 @@ async function readEngineDetourToolUsage(input) {
|
|
|
11951
11412
|
};
|
|
11952
11413
|
const fact = callFactFromSitianPayload(record4.payload, pointer);
|
|
11953
11414
|
if (fact === void 0) continue;
|
|
11954
|
-
|
|
11415
|
+
callsByToolCallId.set(fact.toolCallId, fact);
|
|
11955
11416
|
}
|
|
11417
|
+
const calls = Array.from(callsByToolCallId.values());
|
|
11956
11418
|
return { callCount: calls.length, calls };
|
|
11957
11419
|
}
|
|
11958
11420
|
function projectEngineDetourToolUsageForPublicTerminal(usage, options) {
|
|
@@ -11976,9 +11438,9 @@ function projectEngineDetourToolUsageForPublicTerminal(usage, options) {
|
|
|
11976
11438
|
function readInvocationRecord(runDirectory) {
|
|
11977
11439
|
try {
|
|
11978
11440
|
const raw = JSON.parse(
|
|
11979
|
-
|
|
11441
|
+
readFileSync2(join23(runDirectory, "invocation.json"), "utf8")
|
|
11980
11442
|
);
|
|
11981
|
-
return
|
|
11443
|
+
return isRecord8(raw) ? raw : void 0;
|
|
11982
11444
|
} catch (error) {
|
|
11983
11445
|
if (error?.code === "ENOENT") return void 0;
|
|
11984
11446
|
throw error;
|
|
@@ -11989,14 +11451,9 @@ async function readInvocationEngineMounted(runDirectory) {
|
|
|
11989
11451
|
if (raw === void 0) return false;
|
|
11990
11452
|
return typeof raw.engine === "string" && raw.engine.trim() !== "";
|
|
11991
11453
|
}
|
|
11992
|
-
function readInvocationSelectedHost(runDirectory) {
|
|
11993
|
-
const raw = readInvocationRecord(runDirectory);
|
|
11994
|
-
if (raw === void 0) return void 0;
|
|
11995
|
-
return typeof raw.host === "string" && raw.host.trim() !== "" ? raw.host.trim() : void 0;
|
|
11996
|
-
}
|
|
11997
11454
|
function withEngineDetourToolUsageFact(outcome, usage) {
|
|
11998
11455
|
if (usage === void 0) return outcome;
|
|
11999
|
-
const prior =
|
|
11456
|
+
const prior = isRecord8(outcome.decisiveFacts) ? outcome.decisiveFacts : {};
|
|
12000
11457
|
return {
|
|
12001
11458
|
...outcome,
|
|
12002
11459
|
decisiveFacts: {
|
|
@@ -12038,7 +11495,7 @@ var init_engine_detour_usage = __esm({
|
|
|
12038
11495
|
});
|
|
12039
11496
|
|
|
12040
11497
|
// src/dossier-resolution.ts
|
|
12041
|
-
import { existsSync as
|
|
11498
|
+
import { existsSync as existsSync7, statSync as statSync2 } from "node:fs";
|
|
12042
11499
|
import { resolve as resolve10 } from "node:path";
|
|
12043
11500
|
function isHostContext(value) {
|
|
12044
11501
|
return "sessionManager" in value;
|
|
@@ -12058,7 +11515,7 @@ function resolveAuditDossier(source) {
|
|
|
12058
11515
|
}
|
|
12059
11516
|
const runDirectory = resolve10(raw);
|
|
12060
11517
|
try {
|
|
12061
|
-
if (!
|
|
11518
|
+
if (!existsSync7(runDirectory) || !statSync2(runDirectory).isDirectory()) {
|
|
12062
11519
|
return { status: "incomplete", observation: { kind: "missing-dossier" } };
|
|
12063
11520
|
}
|
|
12064
11521
|
} catch {
|
|
@@ -12066,13 +11523,13 @@ function resolveAuditDossier(source) {
|
|
|
12066
11523
|
}
|
|
12067
11524
|
return { status: "ok", runDirectory };
|
|
12068
11525
|
}
|
|
12069
|
-
function
|
|
11526
|
+
function isRecord9(value) {
|
|
12070
11527
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12071
11528
|
}
|
|
12072
11529
|
function readDoctorAuditSubjects(context) {
|
|
12073
11530
|
const entries = context.sessionManager.getEntries?.() ?? [];
|
|
12074
11531
|
for (const entry of entries) {
|
|
12075
|
-
if (
|
|
11532
|
+
if (isRecord9(entry) && entry.type === "custom" && entry.customType === DOCTOR_CANDIDATE_ENTRY_TYPE) {
|
|
12076
11533
|
return { status: "ok" };
|
|
12077
11534
|
}
|
|
12078
11535
|
}
|
|
@@ -12316,11 +11773,11 @@ var init_navigator_invocation_identity = __esm({
|
|
|
12316
11773
|
});
|
|
12317
11774
|
|
|
12318
11775
|
// src/receipt-delivery-policy.ts
|
|
12319
|
-
function
|
|
11776
|
+
function isRecord10(value) {
|
|
12320
11777
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12321
11778
|
}
|
|
12322
11779
|
function parseNoReceiptLifecycleFacts(input) {
|
|
12323
|
-
if (!
|
|
11780
|
+
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")) {
|
|
12324
11781
|
throw new TypeError("malformed no-receipt lifecycle facts");
|
|
12325
11782
|
}
|
|
12326
11783
|
return {
|
|
@@ -12945,7 +12402,7 @@ async function readSitianRetainedAuditorProviderStop(sessionFile) {
|
|
|
12945
12402
|
const { records } = await readSitianRecords(recordFile);
|
|
12946
12403
|
for (let i = records.length - 1; i >= 0; i -= 1) {
|
|
12947
12404
|
const payload = records[i]?.payload;
|
|
12948
|
-
if (!
|
|
12405
|
+
if (!isRecord11(payload) || !isRecord11(payload.response)) continue;
|
|
12949
12406
|
if (typeof payload.type === "string") continue;
|
|
12950
12407
|
const stop = sessionProviderStopFromAssistant(payload.response);
|
|
12951
12408
|
if (stop !== void 0) return stop;
|
|
@@ -12995,7 +12452,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
12995
12452
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
12996
12453
|
}
|
|
12997
12454
|
const header = entries.find((entry) => entry.type === "session");
|
|
12998
|
-
if (!
|
|
12455
|
+
if (!isRecord11(header)) continue;
|
|
12999
12456
|
const bindingIndexes = [];
|
|
13000
12457
|
for (let i = 0; i < entries.length; i += 1) {
|
|
13001
12458
|
const entry = entries[i];
|
|
@@ -13009,7 +12466,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
13009
12466
|
end: idx + 1 < bindingIndexes.length ? bindingIndexes[idx + 1] : entries.length
|
|
13010
12467
|
})) : [{ entry: void 0, start: 0, end: entries.length }];
|
|
13011
12468
|
for (const { entry: bindingEntry, start, end } of bindingPasses) {
|
|
13012
|
-
const bindingParent = bindingEntry !== void 0 &&
|
|
12469
|
+
const bindingParent = bindingEntry !== void 0 && isRecord11(bindingEntry.data) && isRecord11(bindingEntry.data.parent) ? bindingEntry.data.parent : void 0;
|
|
13013
12470
|
const attemptEntryId = typeof bindingParent?.attemptEntryId === "string" ? bindingParent.attemptEntryId : void 0;
|
|
13014
12471
|
const boundSessionFile = typeof bindingParent?.sessionFile === "string" ? bindingParent.sessionFile : typeof header.parentSession === "string" ? header.parentSession : void 0;
|
|
13015
12472
|
if (boundSessionFile !== sessionFile) continue;
|
|
@@ -13033,12 +12490,12 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
13033
12490
|
if (stop === void 0) continue;
|
|
13034
12491
|
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
13035
12492
|
const entry = entries[i];
|
|
13036
|
-
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !
|
|
13037
|
-
const parent =
|
|
13038
|
-
const failure2 =
|
|
12493
|
+
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord11(entry.data)) continue;
|
|
12494
|
+
const parent = isRecord11(entry.data.parent) ? entry.data.parent : void 0;
|
|
12495
|
+
const failure2 = isRecord11(entry.data.failure) ? entry.data.failure : void 0;
|
|
13039
12496
|
if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId) continue;
|
|
13040
12497
|
if (failure2 === void 0) continue;
|
|
13041
|
-
const identity =
|
|
12498
|
+
const identity = isRecord11(failure2.identity) ? failure2.identity : void 0;
|
|
13042
12499
|
const typedCause = failure2.cause === "provider" || failure2.cause === "activation" || failure2.cause === "session" || failure2.cause === "output" || failure2.cause === "timeout" ? failure2.cause : void 0;
|
|
13043
12500
|
return {
|
|
13044
12501
|
...typedCause === void 0 ? {} : { cause: typedCause },
|
|
@@ -13047,7 +12504,7 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
13047
12504
|
...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
|
|
13048
12505
|
} },
|
|
13049
12506
|
...typeof failure2.diagnostic === "string" ? { diagnostic: failure2.diagnostic } : {},
|
|
13050
|
-
...
|
|
12507
|
+
...isRecord11(failure2.details) ? { details: failure2.details } : {}
|
|
13051
12508
|
};
|
|
13052
12509
|
}
|
|
13053
12510
|
}
|
|
@@ -13094,9 +12551,9 @@ function typedFailedTerminatingToolKnownFailure(entries) {
|
|
|
13094
12551
|
if (classification.kind !== "infrastructure") continue;
|
|
13095
12552
|
if (typeof message.toolCallId !== "string" || typeof message.toolName !== "string") continue;
|
|
13096
12553
|
if (boundRoleToolCallForResult(attemptEntries, i, message, message.toolName) === void 0) continue;
|
|
13097
|
-
const textPart = Array.isArray(message.content) ? message.content.find((part) =>
|
|
13098
|
-
const diagnostic =
|
|
13099
|
-
const details =
|
|
12554
|
+
const textPart = Array.isArray(message.content) ? message.content.find((part) => isRecord11(part) && part.type === "text" && typeof part.text === "string") : void 0;
|
|
12555
|
+
const diagnostic = isRecord11(textPart) ? textPart.text : void 0;
|
|
12556
|
+
const details = isRecord11(message.details) ? message.details : classification.fact;
|
|
13100
12557
|
return {
|
|
13101
12558
|
cause: "activation",
|
|
13102
12559
|
identity: { name: message.toolName, code: message.toolCallId },
|
|
@@ -13233,7 +12690,7 @@ function controlledFailureInputFromResolution(resolution) {
|
|
|
13233
12690
|
} : {}
|
|
13234
12691
|
};
|
|
13235
12692
|
}
|
|
13236
|
-
function
|
|
12693
|
+
function isRecord11(value) {
|
|
13237
12694
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13238
12695
|
}
|
|
13239
12696
|
function toolResultText(message) {
|
|
@@ -13258,7 +12715,7 @@ function extractCollectorTargetBindRejection(entries) {
|
|
|
13258
12715
|
const diagnostic = toolResultText(message);
|
|
13259
12716
|
if (diagnostic.length === 0) return void 0;
|
|
13260
12717
|
const details = message.details;
|
|
13261
|
-
const code =
|
|
12718
|
+
const code = isRecord11(details) && typeof details.code === "string" && details.code.trim() !== "" ? details.code : void 0;
|
|
13262
12719
|
return code === void 0 ? { diagnostic } : { diagnostic, code };
|
|
13263
12720
|
}
|
|
13264
12721
|
return void 0;
|
|
@@ -13359,7 +12816,7 @@ function boundRoleToolCallForResult(entries, resultIndex, message, outputToolNam
|
|
|
13359
12816
|
const candidateMessage = entries[index]?.message;
|
|
13360
12817
|
if (candidateMessage?.role === "assistant" && Array.isArray(candidateMessage.content)) {
|
|
13361
12818
|
for (const part of candidateMessage.content) {
|
|
13362
|
-
if (!
|
|
12819
|
+
if (!isRecord11(part) || part.type !== "toolCall" || part.id !== callId) {
|
|
13363
12820
|
continue;
|
|
13364
12821
|
}
|
|
13365
12822
|
if (part.name !== outputToolName) return void 0;
|
|
@@ -13430,7 +12887,7 @@ function parseNavigatorAttendanceDetails(details) {
|
|
|
13430
12887
|
if (typeof details.prose === "string" && details.prose.trim() !== "") {
|
|
13431
12888
|
prose = details.prose;
|
|
13432
12889
|
} else {
|
|
13433
|
-
const next =
|
|
12890
|
+
const next = isRecord11(details.next) && typeof details.next.role === "string" ? details.next.role : void 0;
|
|
13434
12891
|
const reason = typeof details.reason === "string" && details.reason.trim() !== "" ? details.reason : void 0;
|
|
13435
12892
|
const command = typeof details.command === "string" && details.command.trim() !== "" ? details.command : void 0;
|
|
13436
12893
|
if (reason !== void 0 && next !== void 0) {
|
|
@@ -13539,7 +12996,7 @@ function detourGateContext(admitted, scope) {
|
|
|
13539
12996
|
}
|
|
13540
12997
|
async function withOptionalGateProjection(base, sessionDirectory, gateContext = {}) {
|
|
13541
12998
|
const secondaryEvidence = base.roleOutcome.kind === "failure" ? base.roleOutcome.decisiveFacts.secondaryEvidence : void 0;
|
|
13542
|
-
const skipGate =
|
|
12999
|
+
const skipGate = isRecord11(secondaryEvidence) && secondaryEvidence.kind === "role_infrastructure_failure" && packagedSkipsGateOnInfrastructureStage(secondaryEvidence.stage);
|
|
13543
13000
|
let next = base;
|
|
13544
13001
|
if (!skipGate) {
|
|
13545
13002
|
const gate = await extractGateFactFromSessionDirectory(sessionDirectory, gateContext);
|
|
@@ -13552,7 +13009,7 @@ function routePlaybookFailureMessage(entries) {
|
|
|
13552
13009
|
const entry = entries[i];
|
|
13553
13010
|
if (entry?.type !== "custom" || entry.customType !== NAVIGATOR_ROUTE_PLAYBOOK_FAILURE_ENTRY) continue;
|
|
13554
13011
|
const data = entry.data;
|
|
13555
|
-
if (!
|
|
13012
|
+
if (!isRecord11(data) || typeof data.message !== "string" || data.message.trim() === "") return void 0;
|
|
13556
13013
|
return data.message;
|
|
13557
13014
|
}
|
|
13558
13015
|
return void 0;
|
|
@@ -13599,7 +13056,7 @@ function extractNavigatorAttendanceFact(entries) {
|
|
|
13599
13056
|
const entry = entries[i];
|
|
13600
13057
|
if (entry?.type === "custom_message" && entry.customType === "ak-navigator-attendance") {
|
|
13601
13058
|
const details = entry.message?.details ?? entry.details;
|
|
13602
|
-
if (!
|
|
13059
|
+
if (!isRecord11(details)) {
|
|
13603
13060
|
return {
|
|
13604
13061
|
disposition: "unavailable",
|
|
13605
13062
|
source: "unknown",
|
|
@@ -13750,7 +13207,7 @@ async function settleSealedAcceptedOrToolResidual(admitted, authority, scope, ro
|
|
|
13750
13207
|
const residual = boundErroredToolCandidate(entries, index, message, residualToolName);
|
|
13751
13208
|
if (residual === void 0) continue;
|
|
13752
13209
|
const candidate = residual.candidate;
|
|
13753
|
-
const details =
|
|
13210
|
+
const details = isRecord11(candidate) ? candidate : { candidate };
|
|
13754
13211
|
const failed = await settleFailureTerminalResult(
|
|
13755
13212
|
admitted,
|
|
13756
13213
|
{
|
|
@@ -13825,7 +13282,7 @@ function extractDoctorCandidateFacts(entries) {
|
|
|
13825
13282
|
continue;
|
|
13826
13283
|
}
|
|
13827
13284
|
const data = entry.data;
|
|
13828
|
-
if (!
|
|
13285
|
+
if (!isRecord11(data)) return {};
|
|
13829
13286
|
return {
|
|
13830
13287
|
...data.cost === void 0 ? {} : { cost: data.cost },
|
|
13831
13288
|
...data.auditNoReceipt === void 0 ? {} : { auditNoReceipt: data.auditNoReceipt }
|
|
@@ -13910,7 +13367,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
13910
13367
|
let residual;
|
|
13911
13368
|
for (let index = entries.length - 1; index >= scanStart; index -= 1) {
|
|
13912
13369
|
const entry = entries[index];
|
|
13913
|
-
if (entry?.type === "custom" && entry.customType === "ak-role-submission-closure" &&
|
|
13370
|
+
if (entry?.type === "custom" && entry.customType === "ak-role-submission-closure" && isRecord11(entry.data) && entry.data.toolName === spec.toolName && classifyPackagedRoleTerminalResult(entry.data).kind === "accepted") {
|
|
13914
13371
|
thisAttemptHasSeatSuccess = true;
|
|
13915
13372
|
}
|
|
13916
13373
|
const message = entries[index]?.message;
|
|
@@ -13950,7 +13407,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
13950
13407
|
);
|
|
13951
13408
|
}
|
|
13952
13409
|
if (residual !== void 0) {
|
|
13953
|
-
const details =
|
|
13410
|
+
const details = isRecord11(residual.candidate) ? residual.candidate : { candidate: residual.candidate };
|
|
13954
13411
|
const failed = await settleFailureTerminalResult(
|
|
13955
13412
|
admitted,
|
|
13956
13413
|
{
|
|
@@ -14000,7 +13457,7 @@ function countersignTerminalFromEntries(entries) {
|
|
|
14000
13457
|
return void 0;
|
|
14001
13458
|
}
|
|
14002
13459
|
function withCountersignTerminalFact(roleOutcome, officer) {
|
|
14003
|
-
const prior = roleOutcome.decisiveFacts !== void 0 &&
|
|
13460
|
+
const prior = roleOutcome.decisiveFacts !== void 0 && isRecord11(roleOutcome.decisiveFacts) ? roleOutcome.decisiveFacts : {};
|
|
14004
13461
|
return {
|
|
14005
13462
|
...roleOutcome,
|
|
14006
13463
|
decisiveFacts: {
|
|
@@ -14013,7 +13470,7 @@ function acceptedSecretariatDefinesOfficerProjection(roleOutcome) {
|
|
|
14013
13470
|
const payloads = roleOutcome.payloads ?? [];
|
|
14014
13471
|
for (let index = payloads.length - 1; index >= 0; index -= 1) {
|
|
14015
13472
|
const payload = payloads[index];
|
|
14016
|
-
if (!
|
|
13473
|
+
if (!isRecord11(payload)) continue;
|
|
14017
13474
|
const status = payload.secretariatStatus;
|
|
14018
13475
|
if (typeof status !== "string") continue;
|
|
14019
13476
|
return status === "converged";
|
|
@@ -14458,7 +13915,7 @@ var init_settlement = __esm({
|
|
|
14458
13915
|
});
|
|
14459
13916
|
|
|
14460
13917
|
// src/archivist-record-pointer.ts
|
|
14461
|
-
import { mkdirSync as mkdirSync2, writeFileSync
|
|
13918
|
+
import { mkdirSync as mkdirSync2, writeFileSync } from "node:fs";
|
|
14462
13919
|
import { dirname as dirname15, join as join25 } from "node:path";
|
|
14463
13920
|
function bookDirectOfficerRunPointer(options) {
|
|
14464
13921
|
const nest = join25(dirname15(options.parentSessionFile), "auditor-roles");
|
|
@@ -14470,7 +13927,7 @@ function bookDirectOfficerRunPointer(options) {
|
|
|
14470
13927
|
sessionFile: options.sessionFile,
|
|
14471
13928
|
...options.runDirectory !== void 0 && options.runDirectory.trim() !== "" ? { runDirectory: options.runDirectory } : {}
|
|
14472
13929
|
};
|
|
14473
|
-
|
|
13930
|
+
writeFileSync(
|
|
14474
13931
|
join25(nest, `${options.officer}.pointer.json`),
|
|
14475
13932
|
`${JSON.stringify(pointer)}
|
|
14476
13933
|
`,
|
|
@@ -14864,78 +14321,281 @@ var init_case_dossier_delivery = __esm({
|
|
|
14864
14321
|
}
|
|
14865
14322
|
});
|
|
14866
14323
|
|
|
14867
|
-
// src/
|
|
14868
|
-
|
|
14324
|
+
// src/public-cli/process-cancel.ts
|
|
14325
|
+
function processCancelSignalName(signal) {
|
|
14326
|
+
if (signal === void 0 || signal.aborted !== true) return void 0;
|
|
14327
|
+
const reason = signal.reason;
|
|
14328
|
+
if (reason === "SIGTERM" || reason === "SIGINT" || reason === "SIGHUP") {
|
|
14329
|
+
return reason;
|
|
14330
|
+
}
|
|
14331
|
+
return void 0;
|
|
14332
|
+
}
|
|
14333
|
+
function processCancelDiagnostic(signalName) {
|
|
14334
|
+
return `ak-role terminated by ${signalName}`;
|
|
14335
|
+
}
|
|
14336
|
+
var init_process_cancel = __esm({
|
|
14337
|
+
"src/public-cli/process-cancel.ts"() {
|
|
14338
|
+
"use strict";
|
|
14339
|
+
}
|
|
14340
|
+
});
|
|
14341
|
+
|
|
14342
|
+
// src/host-session-record.ts
|
|
14343
|
+
import { spawnSync } from "node:child_process";
|
|
14344
|
+
import {
|
|
14345
|
+
appendFileSync as appendFileSync2,
|
|
14346
|
+
copyFileSync,
|
|
14347
|
+
closeSync,
|
|
14348
|
+
existsSync as existsSync8,
|
|
14349
|
+
openSync,
|
|
14350
|
+
readFileSync as readFileSync3,
|
|
14351
|
+
mkdirSync as mkdirSync3,
|
|
14352
|
+
readdirSync as readdirSync2,
|
|
14353
|
+
rmSync,
|
|
14354
|
+
statSync as statSync3
|
|
14355
|
+
} from "node:fs";
|
|
14356
|
+
import { homedir } from "node:os";
|
|
14869
14357
|
import { dirname as dirname17, join as join28 } from "node:path";
|
|
14870
|
-
function
|
|
14871
|
-
|
|
14358
|
+
function declareHostSessionFailure(error) {
|
|
14359
|
+
const message = error instanceof Error ? error.stack || error.message : String(error);
|
|
14360
|
+
process.stderr.write(`[host-session] Dossier record failure: ${message}
|
|
14361
|
+
`);
|
|
14872
14362
|
}
|
|
14873
|
-
|
|
14363
|
+
function sitianReportSafe(input) {
|
|
14874
14364
|
try {
|
|
14875
|
-
|
|
14876
|
-
return [sessionFile];
|
|
14365
|
+
sitianReport(input);
|
|
14877
14366
|
} catch (error) {
|
|
14878
|
-
|
|
14879
|
-
|
|
14367
|
+
declareHostSessionFailure(error);
|
|
14368
|
+
}
|
|
14369
|
+
}
|
|
14370
|
+
function findCodexRollout(sessionsDir, sessionId) {
|
|
14371
|
+
if (!existsSync8(sessionsDir)) return void 0;
|
|
14372
|
+
const matches = [];
|
|
14373
|
+
function scan(dir, depth = 0) {
|
|
14374
|
+
if (depth > 6) return;
|
|
14375
|
+
let entries;
|
|
14376
|
+
try {
|
|
14377
|
+
entries = readdirSync2(dir, { withFileTypes: true });
|
|
14378
|
+
} catch {
|
|
14379
|
+
return;
|
|
14380
|
+
}
|
|
14381
|
+
for (const entry of entries) {
|
|
14382
|
+
const fullPath = join28(dir, entry.name);
|
|
14383
|
+
if (entry.isDirectory()) {
|
|
14384
|
+
scan(fullPath, depth + 1);
|
|
14385
|
+
} else if (entry.isFile() && entry.name.endsWith(".jsonl") && entry.name.includes(sessionId)) {
|
|
14386
|
+
try {
|
|
14387
|
+
const stat2 = statSync3(fullPath);
|
|
14388
|
+
matches.push({ path: fullPath, mtime: stat2.mtimeMs });
|
|
14389
|
+
} catch {
|
|
14390
|
+
matches.push({ path: fullPath, mtime: 0 });
|
|
14391
|
+
}
|
|
14392
|
+
}
|
|
14393
|
+
}
|
|
14394
|
+
}
|
|
14395
|
+
scan(sessionsDir);
|
|
14396
|
+
if (matches.length === 0 || matches[0] === void 0) return void 0;
|
|
14397
|
+
matches.sort((a, b) => b.mtime - a.mtime);
|
|
14398
|
+
return matches[0]?.path;
|
|
14399
|
+
}
|
|
14400
|
+
function sanitizeClaudeCwd(cwd) {
|
|
14401
|
+
return cwd.replace(/[^a-zA-Z0-9]/g, "-");
|
|
14402
|
+
}
|
|
14403
|
+
function resolveNativeSessionPath(options) {
|
|
14404
|
+
const home = options.home || homedir();
|
|
14405
|
+
if (options.host === "claude") {
|
|
14406
|
+
const configDir = process.env.CLAUDE_CONFIG_DIR || join28(home, ".claude");
|
|
14407
|
+
const sanitizedCwd = sanitizeClaudeCwd(options.cwd);
|
|
14408
|
+
return join28(configDir, "projects", sanitizedCwd, `${options.sessionId}.jsonl`);
|
|
14409
|
+
}
|
|
14410
|
+
if (options.host === "codex") {
|
|
14411
|
+
return findCodexRollout(codexSessionsDirectory(home), options.sessionId);
|
|
14412
|
+
}
|
|
14413
|
+
if (options.host === "grok-build") {
|
|
14414
|
+
const grokHome = process.env.GROK_HOME || join28(home, ".grok");
|
|
14415
|
+
return join28(grokHome, "sessions", encodeURIComponent(options.cwd), options.sessionId);
|
|
14880
14416
|
}
|
|
14417
|
+
return void 0;
|
|
14418
|
+
}
|
|
14419
|
+
function codexSessionsDirectory(home) {
|
|
14420
|
+
return join28(process.env.CODEX_HOME || join28(home || homedir(), ".codex"), "sessions");
|
|
14881
14421
|
}
|
|
14882
|
-
|
|
14883
|
-
const sessionRoot = dirname17(sessionParent);
|
|
14884
|
-
let entries;
|
|
14422
|
+
function recordRunStart(runDirectory) {
|
|
14885
14423
|
try {
|
|
14886
|
-
|
|
14424
|
+
appendFileSync2(join28(runDirectory, ".run-starts"), "\n");
|
|
14887
14425
|
} catch (error) {
|
|
14888
|
-
|
|
14889
|
-
throw error;
|
|
14426
|
+
declareHostSessionFailure(error);
|
|
14890
14427
|
}
|
|
14891
|
-
|
|
14892
|
-
|
|
14893
|
-
|
|
14894
|
-
|
|
14428
|
+
}
|
|
14429
|
+
function resolveHostDossierLandingPath(options) {
|
|
14430
|
+
const sanitizedModel = (options.model?.model ?? "default").replace(/[\/\\]+/g, "-");
|
|
14431
|
+
let maxOrdinal = 0;
|
|
14432
|
+
if (existsSync8(options.sessionDirectory)) {
|
|
14895
14433
|
try {
|
|
14896
|
-
|
|
14897
|
-
|
|
14898
|
-
|
|
14899
|
-
|
|
14434
|
+
const entries = readdirSync2(options.sessionDirectory);
|
|
14435
|
+
for (const entry of entries) {
|
|
14436
|
+
const match = entry.match(/-(\d+)(?:\.jsonl|\.failed)?$/);
|
|
14437
|
+
const first = match?.[1];
|
|
14438
|
+
if (first !== void 0) {
|
|
14439
|
+
const val = parseInt(first, 10);
|
|
14440
|
+
if (!isNaN(val) && val > maxOrdinal) {
|
|
14441
|
+
maxOrdinal = val;
|
|
14442
|
+
}
|
|
14443
|
+
}
|
|
14444
|
+
}
|
|
14445
|
+
} catch {
|
|
14900
14446
|
}
|
|
14901
14447
|
}
|
|
14902
|
-
|
|
14903
|
-
|
|
14448
|
+
const startsPath = join28(dirname17(options.sessionDirectory), ".run-starts");
|
|
14449
|
+
let starts = 0;
|
|
14450
|
+
if (existsSync8(startsPath)) starts = readFileSync3(startsPath, "utf8").length;
|
|
14451
|
+
const ordinal = Math.max(maxOrdinal + 1, starts, options.continuation.kind === "resume" ? 2 : 1);
|
|
14452
|
+
const baseName = `${options.host}-${sanitizedModel}-${ordinal}`;
|
|
14453
|
+
const landingPath = options.host === "grok-build" ? join28(options.sessionDirectory, baseName) : join28(options.sessionDirectory, `${baseName}.jsonl`);
|
|
14454
|
+
return { landingPath, ordinal, sanitizedModel };
|
|
14904
14455
|
}
|
|
14905
|
-
|
|
14906
|
-
if (
|
|
14907
|
-
|
|
14908
|
-
return {
|
|
14909
|
-
priorNativeKind: "pi-native",
|
|
14910
|
-
priorNativePaths: await listPiNativeRecordPaths(input.piSessionFile)
|
|
14911
|
-
};
|
|
14456
|
+
function recordNativeSessionPointer(options) {
|
|
14457
|
+
if (options.host === "pi" || options.host === "hermes") {
|
|
14458
|
+
return void 0;
|
|
14912
14459
|
}
|
|
14913
|
-
|
|
14914
|
-
|
|
14915
|
-
|
|
14916
|
-
|
|
14460
|
+
const nativePath = options.host === "codex" ? codexSessionsDirectory(options.home) : resolveNativeSessionPath(options);
|
|
14461
|
+
if (nativePath === void 0) return void 0;
|
|
14462
|
+
sitianReportSafe({
|
|
14463
|
+
level: "event",
|
|
14464
|
+
kind: HOST_SESSION_RECORD_KIND,
|
|
14465
|
+
host: options.host,
|
|
14466
|
+
cwd: options.cwd,
|
|
14467
|
+
sessionParent: options.sessionParent,
|
|
14468
|
+
source: `${options.host}-dossier`,
|
|
14469
|
+
payload: {
|
|
14470
|
+
type: "native-session-pointer",
|
|
14471
|
+
nativePath,
|
|
14472
|
+
sessionId: options.sessionId
|
|
14473
|
+
}
|
|
14474
|
+
});
|
|
14475
|
+
return nativePath;
|
|
14917
14476
|
}
|
|
14918
|
-
|
|
14919
|
-
|
|
14920
|
-
"
|
|
14477
|
+
function copyFileCloneOrFallback(src, dest) {
|
|
14478
|
+
try {
|
|
14479
|
+
const res = spawnSync("cp", ["-c", src, dest]);
|
|
14480
|
+
if (res.status === 0) return;
|
|
14481
|
+
} catch {
|
|
14921
14482
|
}
|
|
14922
|
-
|
|
14923
|
-
|
|
14924
|
-
|
|
14925
|
-
|
|
14926
|
-
if (
|
|
14927
|
-
|
|
14928
|
-
if (reason === "SIGTERM" || reason === "SIGINT" || reason === "SIGHUP") {
|
|
14929
|
-
return reason;
|
|
14483
|
+
copyFileSync(src, dest);
|
|
14484
|
+
}
|
|
14485
|
+
function copyGrokDossier(srcDir, destDir) {
|
|
14486
|
+
const chatHistorySrc = join28(srcDir, "chat_history.jsonl");
|
|
14487
|
+
if (!existsSync8(chatHistorySrc)) {
|
|
14488
|
+
throw new Error(`Grok native chat_history.jsonl missing at ${chatHistorySrc}`);
|
|
14930
14489
|
}
|
|
14931
|
-
|
|
14490
|
+
mkdirSync3(destDir, { recursive: true });
|
|
14491
|
+
const chatHistoryDest = join28(destDir, "chat_history.jsonl");
|
|
14492
|
+
copyFileCloneOrFallback(chatHistorySrc, chatHistoryDest);
|
|
14493
|
+
const usageSrc = join28(srcDir, "usage.json");
|
|
14494
|
+
if (!existsSync8(usageSrc)) {
|
|
14495
|
+
throw new Error(`Grok native usage.json missing at ${usageSrc}`);
|
|
14496
|
+
}
|
|
14497
|
+
copyFileCloneOrFallback(usageSrc, join28(destDir, "usage.json"));
|
|
14932
14498
|
}
|
|
14933
|
-
function
|
|
14934
|
-
|
|
14499
|
+
function copyAndRecordHostDossier(options) {
|
|
14500
|
+
if (options.host === "pi" || options.host === "hermes") {
|
|
14501
|
+
return;
|
|
14502
|
+
}
|
|
14503
|
+
const nativePath = resolveNativeSessionPath({
|
|
14504
|
+
host: options.host,
|
|
14505
|
+
sessionId: options.sessionId,
|
|
14506
|
+
cwd: options.cwd,
|
|
14507
|
+
...options.home !== void 0 ? { home: options.home } : {}
|
|
14508
|
+
});
|
|
14509
|
+
if (nativePath === void 0 && options.host !== "codex") return;
|
|
14510
|
+
let destination;
|
|
14511
|
+
try {
|
|
14512
|
+
destination = resolveHostDossierLandingPath(options);
|
|
14513
|
+
} catch (error) {
|
|
14514
|
+
sitianReportSafe({
|
|
14515
|
+
level: "event",
|
|
14516
|
+
kind: HOST_SESSION_RECORD_KIND,
|
|
14517
|
+
host: options.host,
|
|
14518
|
+
cwd: options.cwd,
|
|
14519
|
+
sessionParent: options.sessionParent,
|
|
14520
|
+
source: `${options.host}-dossier`,
|
|
14521
|
+
payload: {
|
|
14522
|
+
type: "native-session-warning",
|
|
14523
|
+
sessionId: options.sessionId,
|
|
14524
|
+
error: error instanceof Error ? error.message : String(error)
|
|
14525
|
+
}
|
|
14526
|
+
});
|
|
14527
|
+
return;
|
|
14528
|
+
}
|
|
14529
|
+
const { landingPath, ordinal, sanitizedModel } = destination;
|
|
14530
|
+
let lastError;
|
|
14531
|
+
let copySuccess = false;
|
|
14532
|
+
for (let attempt = 1; attempt <= 2; attempt++) {
|
|
14533
|
+
try {
|
|
14534
|
+
if (options.host === "grok-build") {
|
|
14535
|
+
copyGrokDossier(nativePath, landingPath);
|
|
14536
|
+
} else {
|
|
14537
|
+
if (nativePath === void 0 || !existsSync8(nativePath)) {
|
|
14538
|
+
throw new Error(`Native session file missing for ${options.host} session ${options.sessionId}`);
|
|
14539
|
+
}
|
|
14540
|
+
mkdirSync3(dirname17(landingPath), { recursive: true });
|
|
14541
|
+
copyFileCloneOrFallback(nativePath, landingPath);
|
|
14542
|
+
}
|
|
14543
|
+
copySuccess = true;
|
|
14544
|
+
break;
|
|
14545
|
+
} catch (error) {
|
|
14546
|
+
lastError = error;
|
|
14547
|
+
}
|
|
14548
|
+
}
|
|
14549
|
+
if (copySuccess) {
|
|
14550
|
+
sitianReportSafe({
|
|
14551
|
+
level: "event",
|
|
14552
|
+
kind: HOST_SESSION_RECORD_KIND,
|
|
14553
|
+
host: options.host,
|
|
14554
|
+
cwd: options.cwd,
|
|
14555
|
+
sessionParent: options.sessionParent,
|
|
14556
|
+
source: `${options.host}-dossier`,
|
|
14557
|
+
payload: {
|
|
14558
|
+
type: "native-session-copy",
|
|
14559
|
+
nativePath,
|
|
14560
|
+
landingPath,
|
|
14561
|
+
ordinal,
|
|
14562
|
+
sessionId: options.sessionId
|
|
14563
|
+
}
|
|
14564
|
+
});
|
|
14565
|
+
} else {
|
|
14566
|
+
try {
|
|
14567
|
+
rmSync(landingPath, { recursive: options.host === "grok-build", force: true });
|
|
14568
|
+
} catch {
|
|
14569
|
+
}
|
|
14570
|
+
try {
|
|
14571
|
+
mkdirSync3(options.sessionDirectory, { recursive: true });
|
|
14572
|
+
closeSync(openSync(join28(options.sessionDirectory, `${options.host}-${sanitizedModel}-${ordinal}.failed`), "a"));
|
|
14573
|
+
} catch {
|
|
14574
|
+
}
|
|
14575
|
+
sitianReportSafe({
|
|
14576
|
+
level: "event",
|
|
14577
|
+
kind: HOST_SESSION_RECORD_KIND,
|
|
14578
|
+
host: options.host,
|
|
14579
|
+
cwd: options.cwd,
|
|
14580
|
+
sessionParent: options.sessionParent,
|
|
14581
|
+
source: `${options.host}-dossier`,
|
|
14582
|
+
payload: {
|
|
14583
|
+
type: "native-session-warning",
|
|
14584
|
+
nativePath,
|
|
14585
|
+
landingPath,
|
|
14586
|
+
ordinal,
|
|
14587
|
+
sessionId: options.sessionId,
|
|
14588
|
+
error: lastError instanceof Error ? lastError.message : String(lastError)
|
|
14589
|
+
}
|
|
14590
|
+
});
|
|
14591
|
+
}
|
|
14935
14592
|
}
|
|
14936
|
-
var
|
|
14937
|
-
|
|
14593
|
+
var HOST_SESSION_RECORD_KIND;
|
|
14594
|
+
var init_host_session_record = __esm({
|
|
14595
|
+
"src/host-session-record.ts"() {
|
|
14938
14596
|
"use strict";
|
|
14597
|
+
init_sitian_facade();
|
|
14598
|
+
HOST_SESSION_RECORD_KIND = "host-session";
|
|
14939
14599
|
}
|
|
14940
14600
|
});
|
|
14941
14601
|
|
|
@@ -15601,35 +15261,6 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
15601
15261
|
}
|
|
15602
15262
|
};
|
|
15603
15263
|
try {
|
|
15604
|
-
let previousHost;
|
|
15605
|
-
const liveHost = env.host;
|
|
15606
|
-
const principalCoordinates = admitted.principal === void 0 ? void 0 : env.principalAuthority.decode(admitted.principal);
|
|
15607
|
-
let hostTransition;
|
|
15608
|
-
try {
|
|
15609
|
-
previousHost = readInvocationSelectedHost(admitted.runDirectory);
|
|
15610
|
-
hostTransition = previousHost !== void 0 && liveHost !== void 0 && principalCoordinates !== void 0 ? await projectHostTransitionPriorNative({
|
|
15611
|
-
previousHost,
|
|
15612
|
-
liveHost,
|
|
15613
|
-
piSessionFile: principalCoordinates.sessionFile
|
|
15614
|
-
}) : void 0;
|
|
15615
|
-
} catch (error) {
|
|
15616
|
-
return {
|
|
15617
|
-
...await presentControlledFailure2(
|
|
15618
|
-
admitted,
|
|
15619
|
-
withEngineDetourInvocationScope({
|
|
15620
|
-
timedOut: false,
|
|
15621
|
-
code: null,
|
|
15622
|
-
stderr: "",
|
|
15623
|
-
thrown: error
|
|
15624
|
-
}, request.invocationScopeId),
|
|
15625
|
-
adapters,
|
|
15626
|
-
env.principalAuthority,
|
|
15627
|
-
io,
|
|
15628
|
-
persistRunState
|
|
15629
|
-
),
|
|
15630
|
-
...deferredPersist
|
|
15631
|
-
};
|
|
15632
|
-
}
|
|
15633
15264
|
await clearTypedProviderHttpObservation(admitted.runDirectory);
|
|
15634
15265
|
if (adapters.beforeDispatch !== void 0) {
|
|
15635
15266
|
try {
|
|
@@ -15665,11 +15296,8 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
15665
15296
|
if (env.stationChild !== void 0) {
|
|
15666
15297
|
turnRequest = { ...turnRequest, stationChild: env.stationChild };
|
|
15667
15298
|
}
|
|
15668
|
-
if (
|
|
15669
|
-
turnRequest = { ...turnRequest,
|
|
15670
|
-
}
|
|
15671
|
-
if (typeof liveHost === "string" && liveHost.trim() !== "") {
|
|
15672
|
-
turnRequest = { ...turnRequest, host: liveHost.trim() };
|
|
15299
|
+
if (typeof env.host === "string" && env.host.trim() !== "") {
|
|
15300
|
+
turnRequest = { ...turnRequest, host: env.host.trim() };
|
|
15673
15301
|
}
|
|
15674
15302
|
await deliverCaseDossierAsAttachment({
|
|
15675
15303
|
ticketNumber: admitted.ticketNumber,
|
|
@@ -15686,6 +15314,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
15686
15314
|
);
|
|
15687
15315
|
let result;
|
|
15688
15316
|
try {
|
|
15317
|
+
recordRunStart(admitted.runDirectory);
|
|
15689
15318
|
result = await env.roleTurnHost.executeTurn(turnRequest);
|
|
15690
15319
|
} catch (error) {
|
|
15691
15320
|
const processCancelName = processCancelSignalName(env.signal);
|
|
@@ -16385,10 +16014,10 @@ var init_post_admission = __esm({
|
|
|
16385
16014
|
init_packaged_role_registry();
|
|
16386
16015
|
init_case_dossier_delivery();
|
|
16387
16016
|
init_engine_detour_usage();
|
|
16388
|
-
init_host_transition_prior_native();
|
|
16389
16017
|
init_run_lifecycle();
|
|
16390
16018
|
init_process_cancel();
|
|
16391
16019
|
init_activation_ledger_topology();
|
|
16020
|
+
init_host_session_record();
|
|
16392
16021
|
init_settlement();
|
|
16393
16022
|
init_terminal();
|
|
16394
16023
|
init_auto_resume();
|
|
@@ -16422,10 +16051,10 @@ var init_seat_ticket_binding = __esm({
|
|
|
16422
16051
|
});
|
|
16423
16052
|
|
|
16424
16053
|
// src/public-cli/machine-method-skills.ts
|
|
16425
|
-
import { accessSync, constants as constants2, statSync as
|
|
16054
|
+
import { accessSync, constants as constants2, statSync as statSync4 } from "node:fs";
|
|
16426
16055
|
import { lstat as lstat6, mkdir as mkdir4, symlink } from "node:fs/promises";
|
|
16427
16056
|
import { join as join31 } from "node:path";
|
|
16428
|
-
import { spawnSync } from "node:child_process";
|
|
16057
|
+
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
16429
16058
|
function skillRoot(home) {
|
|
16430
16059
|
return join31(home, ".agents/skills");
|
|
16431
16060
|
}
|
|
@@ -16435,7 +16064,7 @@ function installedMethodSkillPath(home, name) {
|
|
|
16435
16064
|
function installedSkillPath(root, name) {
|
|
16436
16065
|
const path = join31(root, name, "SKILL.md");
|
|
16437
16066
|
try {
|
|
16438
|
-
if (!
|
|
16067
|
+
if (!statSync4(path).isFile()) return void 0;
|
|
16439
16068
|
accessSync(path, constants2.R_OK);
|
|
16440
16069
|
return path;
|
|
16441
16070
|
} catch (error) {
|
|
@@ -16476,7 +16105,7 @@ async function warnMissingMethodSkills(home, host, role, skills, stdout) {
|
|
|
16476
16105
|
}
|
|
16477
16106
|
}
|
|
16478
16107
|
function runSkillsCli(args, home) {
|
|
16479
|
-
const result =
|
|
16108
|
+
const result = spawnSync2("npx", ["--yes", "skills", ...args], {
|
|
16480
16109
|
stdio: "inherit",
|
|
16481
16110
|
env: { ...process.env, HOME: home }
|
|
16482
16111
|
});
|
|
@@ -16663,11 +16292,11 @@ var init_turn_request = __esm({
|
|
|
16663
16292
|
});
|
|
16664
16293
|
|
|
16665
16294
|
// src/public-cli/countersign-run.ts
|
|
16666
|
-
function
|
|
16295
|
+
function isRecord12(value) {
|
|
16667
16296
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16668
16297
|
}
|
|
16669
16298
|
function isEscalatePayload(payload) {
|
|
16670
|
-
if (!
|
|
16299
|
+
if (!isRecord12(payload)) return false;
|
|
16671
16300
|
return payload.status === "escalate";
|
|
16672
16301
|
}
|
|
16673
16302
|
function courtDiaristPayloadRows(roleOutcome, submissions) {
|
|
@@ -17882,13 +17511,13 @@ var init_instruction_seat_run = __esm({
|
|
|
17882
17511
|
});
|
|
17883
17512
|
|
|
17884
17513
|
// src/analyst-book-key.ts
|
|
17885
|
-
import { statSync as
|
|
17514
|
+
import { statSync as statSync5 } from "node:fs";
|
|
17886
17515
|
import { isAbsolute as isAbsolute8 } from "node:path";
|
|
17887
17516
|
function resolveAnalystBookKey(projectRoot) {
|
|
17888
17517
|
const identity = physicalPathIdentity(projectRoot);
|
|
17889
17518
|
let stats;
|
|
17890
17519
|
try {
|
|
17891
|
-
stats =
|
|
17520
|
+
stats = statSync5(identity);
|
|
17892
17521
|
} catch (error) {
|
|
17893
17522
|
const code = errnoCode(error);
|
|
17894
17523
|
if (code === "ENOENT" || code === "ENOTDIR") return `root:${identity}`;
|
|
@@ -18269,7 +17898,7 @@ var init_analyst_cohort = __esm({
|
|
|
18269
17898
|
});
|
|
18270
17899
|
|
|
18271
17900
|
// src/analyst-ledger.ts
|
|
18272
|
-
import { readdir as
|
|
17901
|
+
import { readdir as readdir6, readFile as readFile19 } from "node:fs/promises";
|
|
18273
17902
|
import { basename as basename8, join as join34 } from "node:path";
|
|
18274
17903
|
function isMissingPathError6(error) {
|
|
18275
17904
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
@@ -18277,7 +17906,7 @@ function isMissingPathError6(error) {
|
|
|
18277
17906
|
function errorText3(error) {
|
|
18278
17907
|
return error instanceof Error ? error.message : String(error);
|
|
18279
17908
|
}
|
|
18280
|
-
function
|
|
17909
|
+
function isRecord13(value) {
|
|
18281
17910
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18282
17911
|
}
|
|
18283
17912
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
@@ -18318,7 +17947,7 @@ function parseRunDirectoryName2(name) {
|
|
|
18318
17947
|
}
|
|
18319
17948
|
async function listLedgerBookNames(booksRoot) {
|
|
18320
17949
|
try {
|
|
18321
|
-
const entries = await
|
|
17950
|
+
const entries = await readdir6(booksRoot, { withFileTypes: true });
|
|
18322
17951
|
return entries.filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
18323
17952
|
} catch (error) {
|
|
18324
17953
|
if (isMissingPathError6(error)) return [];
|
|
@@ -18334,7 +17963,7 @@ async function readInvocationScopeFields(runDirectory) {
|
|
|
18334
17963
|
throw error;
|
|
18335
17964
|
}
|
|
18336
17965
|
const parsed = JSON.parse(raw);
|
|
18337
|
-
if (!
|
|
17966
|
+
if (!isRecord13(parsed)) return void 0;
|
|
18338
17967
|
if (typeof parsed.projectRoot !== "string" || parsed.projectRoot.trim() === "") {
|
|
18339
17968
|
return void 0;
|
|
18340
17969
|
}
|
|
@@ -18363,7 +17992,7 @@ async function resolveSessionFile(runDirectory) {
|
|
|
18363
17992
|
try {
|
|
18364
17993
|
const raw = await readFile19(join34(runDirectory, "invocation.json"), "utf8");
|
|
18365
17994
|
const parsed = JSON.parse(raw);
|
|
18366
|
-
if (
|
|
17995
|
+
if (isRecord13(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
18367
17996
|
return parsed.sessionFile;
|
|
18368
17997
|
}
|
|
18369
17998
|
} catch (error) {
|
|
@@ -18701,7 +18330,7 @@ var init_analyst_ledger = __esm({
|
|
|
18701
18330
|
});
|
|
18702
18331
|
|
|
18703
18332
|
// src/analyst-metric-families/acceptance-success-rework.ts
|
|
18704
|
-
function
|
|
18333
|
+
function isRecord14(value) {
|
|
18705
18334
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18706
18335
|
}
|
|
18707
18336
|
function wallMsFromSpan(span) {
|
|
@@ -18710,21 +18339,21 @@ function wallMsFromSpan(span) {
|
|
|
18710
18339
|
function findCollectorGroups(body) {
|
|
18711
18340
|
if (Array.isArray(body.groups)) return body.groups;
|
|
18712
18341
|
const receipt = body.receipt;
|
|
18713
|
-
if (
|
|
18342
|
+
if (isRecord14(receipt) && Array.isArray(receipt.groups)) return receipt.groups;
|
|
18714
18343
|
const outcome = body.outcome;
|
|
18715
|
-
if (
|
|
18344
|
+
if (isRecord14(outcome)) {
|
|
18716
18345
|
const facts = outcome.decisiveFacts;
|
|
18717
|
-
if (
|
|
18346
|
+
if (isRecord14(facts) && Array.isArray(facts.groups)) return facts.groups;
|
|
18718
18347
|
}
|
|
18719
18348
|
return void 0;
|
|
18720
18349
|
}
|
|
18721
18350
|
function extractStatus(body) {
|
|
18722
18351
|
const outcome = body.outcome;
|
|
18723
|
-
if (
|
|
18352
|
+
if (isRecord14(outcome) && typeof outcome.status === "string" && outcome.status.trim() !== "") {
|
|
18724
18353
|
return outcome.status;
|
|
18725
18354
|
}
|
|
18726
18355
|
const receipt = body.receipt;
|
|
18727
|
-
if (
|
|
18356
|
+
if (isRecord14(receipt) && typeof receipt.status === "string" && receipt.status.trim() !== "") {
|
|
18728
18357
|
return receipt.status;
|
|
18729
18358
|
}
|
|
18730
18359
|
if (typeof body.status === "string" && body.status.trim() !== "") {
|
|
@@ -19350,15 +18979,15 @@ var init_leg_wall_clock = __esm({
|
|
|
19350
18979
|
});
|
|
19351
18980
|
|
|
19352
18981
|
// src/analyst-metric-families/round-timeline.ts
|
|
19353
|
-
function
|
|
18982
|
+
function isRecord15(value) {
|
|
19354
18983
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19355
18984
|
}
|
|
19356
18985
|
function wallMsFromSpan2(startedAt, endedAt) {
|
|
19357
18986
|
return Date.parse(endedAt) - Date.parse(startedAt);
|
|
19358
18987
|
}
|
|
19359
18988
|
function readClassCount(body) {
|
|
19360
|
-
if (!
|
|
19361
|
-
if (!
|
|
18989
|
+
if (!isRecord15(body.outcome)) return void 0;
|
|
18990
|
+
if (!isRecord15(body.outcome.decisiveFacts)) return void 0;
|
|
19362
18991
|
const classCount = body.outcome.decisiveFacts.classCount;
|
|
19363
18992
|
if (typeof classCount !== "number" || !Number.isFinite(classCount)) {
|
|
19364
18993
|
return void 0;
|
|
@@ -19502,7 +19131,7 @@ var init_analyst_metric_family = __esm({
|
|
|
19502
19131
|
});
|
|
19503
19132
|
|
|
19504
19133
|
// src/analyst-page.ts
|
|
19505
|
-
import { createHash as
|
|
19134
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
19506
19135
|
import { dirname as dirname21, join as join35 } from "node:path";
|
|
19507
19136
|
function analystIssuePageKey(address) {
|
|
19508
19137
|
const parts = ["book", address.bookKey];
|
|
@@ -19511,7 +19140,7 @@ function analystIssuePageKey(address) {
|
|
|
19511
19140
|
} else if (address.scopeRootIdentity !== void 0) {
|
|
19512
19141
|
parts.push("root", physicalPathIdentity(address.scopeRootIdentity));
|
|
19513
19142
|
}
|
|
19514
|
-
return
|
|
19143
|
+
return createHash5("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
19515
19144
|
}
|
|
19516
19145
|
function analystIssuePagePath(ledgerHome, address) {
|
|
19517
19146
|
return join35(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
@@ -21741,7 +21370,7 @@ __export(run_lifecycle_exports, {
|
|
|
21741
21370
|
renderResumeCommand: () => renderResumeCommand,
|
|
21742
21371
|
writeRoleRunState: () => writeRoleRunState
|
|
21743
21372
|
});
|
|
21744
|
-
import { chmod, lstat as lstat7, open as open3, readdir as
|
|
21373
|
+
import { chmod, lstat as lstat7, open as open3, readdir as readdir7, readFile as readFile22, unlink as unlink5, writeFile as writeFile10 } from "node:fs/promises";
|
|
21745
21374
|
import { basename as basename9, join as join39 } from "node:path";
|
|
21746
21375
|
function buildAutoResumeContinuationPrompt(options) {
|
|
21747
21376
|
return appendEngineSessionMaterial(
|
|
@@ -21820,7 +21449,7 @@ async function readRoleRunStateRaw(runDirectory) {
|
|
|
21820
21449
|
try {
|
|
21821
21450
|
raw = JSON.parse(await readFile22(join39(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
21822
21451
|
} catch (error) {
|
|
21823
|
-
if (
|
|
21452
|
+
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
21824
21453
|
throw error;
|
|
21825
21454
|
}
|
|
21826
21455
|
return raw;
|
|
@@ -22065,7 +21694,7 @@ function describeErrorIdentity(error) {
|
|
|
22065
21694
|
const message = typeof candidate?.message === "string" && candidate.message !== "" ? `: ${candidate.message}` : "";
|
|
22066
21695
|
return `${name}${code}${message}`;
|
|
22067
21696
|
}
|
|
22068
|
-
function
|
|
21697
|
+
function errorCodeOf(error) {
|
|
22069
21698
|
return error.code;
|
|
22070
21699
|
}
|
|
22071
21700
|
function isProcessAlive(pid) {
|
|
@@ -22073,7 +21702,7 @@ function isProcessAlive(pid) {
|
|
|
22073
21702
|
process.kill(pid, 0);
|
|
22074
21703
|
return true;
|
|
22075
21704
|
} catch (error) {
|
|
22076
|
-
return
|
|
21705
|
+
return errorCodeOf(error) !== "ESRCH";
|
|
22077
21706
|
}
|
|
22078
21707
|
}
|
|
22079
21708
|
async function autopsyWriterLock(lockPath) {
|
|
@@ -22081,7 +21710,7 @@ async function autopsyWriterLock(lockPath) {
|
|
|
22081
21710
|
try {
|
|
22082
21711
|
content = await readFile22(lockPath, "utf8");
|
|
22083
21712
|
} catch (error) {
|
|
22084
|
-
if (
|
|
21713
|
+
if (errorCodeOf(error) === "ENOENT") return { verdict: "absent" };
|
|
22085
21714
|
return { verdict: "unknown", reason: "unreadable", readFailure: error };
|
|
22086
21715
|
}
|
|
22087
21716
|
const normalized = content.trim();
|
|
@@ -22113,8 +21742,8 @@ async function reclaimStaleWriterLock(lockPath, runDirectory) {
|
|
|
22113
21742
|
await unlink5(lockPath);
|
|
22114
21743
|
return { reclaimed: true };
|
|
22115
21744
|
} catch (error) {
|
|
22116
|
-
if (
|
|
22117
|
-
if (
|
|
21745
|
+
if (errorCodeOf(error) === "ENOENT") return { reclaimed: false };
|
|
21746
|
+
if (errorCodeOf(error) !== "EACCES") throw error;
|
|
22118
21747
|
await chmod(runDirectory, 493);
|
|
22119
21748
|
return { reclaimed: false, eaccesFailure: error };
|
|
22120
21749
|
}
|
|
@@ -22147,7 +21776,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
22147
21776
|
try {
|
|
22148
21777
|
await unlink5(currentLockPath);
|
|
22149
21778
|
} catch (error) {
|
|
22150
|
-
if (
|
|
21779
|
+
if (errorCodeOf(error) === "EACCES") {
|
|
22151
21780
|
try {
|
|
22152
21781
|
await chmod(currentRunDirectory, 493);
|
|
22153
21782
|
await unlink5(currentLockPath);
|
|
@@ -22187,7 +21816,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
22187
21816
|
try {
|
|
22188
21817
|
return await createWriterLease(lockPath, runDirectory, reportCleanupFailure);
|
|
22189
21818
|
} catch (error) {
|
|
22190
|
-
if (
|
|
21819
|
+
if (errorCodeOf(error) !== "EEXIST") throw error;
|
|
22191
21820
|
}
|
|
22192
21821
|
lastAutopsy = await autopsyWriterLock(lockPath);
|
|
22193
21822
|
if (lastAutopsy.verdict === "unknown" && lastAutopsy.reason === "unreadable") {
|
|
@@ -22238,9 +21867,9 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
|
22238
21867
|
const booksRoot = join39(ledgerHome, "books");
|
|
22239
21868
|
let bookKeys;
|
|
22240
21869
|
try {
|
|
22241
|
-
bookKeys = await
|
|
21870
|
+
bookKeys = await readdir7(booksRoot);
|
|
22242
21871
|
} catch (error) {
|
|
22243
|
-
if (
|
|
21872
|
+
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
22244
21873
|
throw error;
|
|
22245
21874
|
}
|
|
22246
21875
|
const matches = [];
|
|
@@ -22251,7 +21880,7 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
|
22251
21880
|
try {
|
|
22252
21881
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
22253
21882
|
} catch (error) {
|
|
22254
|
-
if (
|
|
21883
|
+
if (errorCodeOf(error) === "ENOENT") continue;
|
|
22255
21884
|
throw error;
|
|
22256
21885
|
}
|
|
22257
21886
|
for (const runDirectory of runDirectories) {
|
|
@@ -22279,7 +21908,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
22279
21908
|
await readFile22(join39(runDirectory, "admitted-request.json"), "utf8")
|
|
22280
21909
|
);
|
|
22281
21910
|
} catch (error) {
|
|
22282
|
-
if (
|
|
21911
|
+
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
22283
21912
|
throw error;
|
|
22284
21913
|
}
|
|
22285
21914
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
@@ -22302,7 +21931,7 @@ async function runHasFormedSessionPrincipal(runDirectory) {
|
|
|
22302
21931
|
const stat2 = await lstat7(sessionFile);
|
|
22303
21932
|
return stat2.isFile() && !stat2.isSymbolicLink();
|
|
22304
21933
|
} catch (error) {
|
|
22305
|
-
if (
|
|
21934
|
+
if (errorCodeOf(error) === "ENOENT") return false;
|
|
22306
21935
|
throw error;
|
|
22307
21936
|
}
|
|
22308
21937
|
}
|
|
@@ -22318,7 +21947,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
22318
21947
|
input.ticketNumber === void 0 ? bookDir : join39(bookDir, String(input.ticketNumber))
|
|
22319
21948
|
);
|
|
22320
21949
|
} catch (error) {
|
|
22321
|
-
if (
|
|
21950
|
+
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
22322
21951
|
throw error;
|
|
22323
21952
|
}
|
|
22324
21953
|
const suffix = `@${input.role}`;
|
|
@@ -23348,7 +22977,7 @@ var init_submission_ledger = __esm({
|
|
|
23348
22977
|
});
|
|
23349
22978
|
|
|
23350
22979
|
// src/archivist-record-topology.ts
|
|
23351
|
-
import { createHash as
|
|
22980
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
23352
22981
|
import { join as join43 } from "node:path";
|
|
23353
22982
|
function resolveNavigatorWorkSubjectPlacement(input) {
|
|
23354
22983
|
let ledgerHome;
|
|
@@ -23359,7 +22988,7 @@ function resolveNavigatorWorkSubjectPlacement(input) {
|
|
|
23359
22988
|
}
|
|
23360
22989
|
}
|
|
23361
22990
|
ledgerHome ??= resolveActivationLedgerHome(input.home);
|
|
23362
|
-
const digest =
|
|
22991
|
+
const digest = createHash6("sha256").update(input.subject).digest("hex").slice(0, 32);
|
|
23363
22992
|
return {
|
|
23364
22993
|
ledgerHome,
|
|
23365
22994
|
sessionDir: join43(
|
|
@@ -23424,15 +23053,15 @@ __export(archivist_record_entry_exports, {
|
|
|
23424
23053
|
resolveNavigatorWorkSubjectPlacement: () => resolveNavigatorWorkSubjectPlacement
|
|
23425
23054
|
});
|
|
23426
23055
|
import {
|
|
23427
|
-
closeSync,
|
|
23056
|
+
closeSync as closeSync2,
|
|
23428
23057
|
existsSync as existsSync12,
|
|
23429
|
-
openSync,
|
|
23430
|
-
readdirSync as
|
|
23058
|
+
openSync as openSync2,
|
|
23059
|
+
readdirSync as readdirSync3,
|
|
23431
23060
|
readFileSync as readFileSync4,
|
|
23432
23061
|
readSync,
|
|
23433
23062
|
realpathSync as realpathSync4,
|
|
23434
|
-
statSync as
|
|
23435
|
-
writeFileSync as
|
|
23063
|
+
statSync as statSync7,
|
|
23064
|
+
writeFileSync as writeFileSync3
|
|
23436
23065
|
} from "node:fs";
|
|
23437
23066
|
import { dirname as dirname23, resolve as resolve17, join as join44 } from "node:path";
|
|
23438
23067
|
import { StringDecoder } from "node:string_decoder";
|
|
@@ -23454,7 +23083,7 @@ function readCurrentSession(sessionDir) {
|
|
|
23454
23083
|
function writeCurrentSession(sessionDir, sessionFile) {
|
|
23455
23084
|
const ledger = join44(sessionDir, CURRENT_SESSION_LEDGER);
|
|
23456
23085
|
try {
|
|
23457
|
-
|
|
23086
|
+
writeFileSync3(ledger, `${JSON.stringify({ sessionFile })}
|
|
23458
23087
|
`, { flag: "wx" });
|
|
23459
23088
|
} catch (error) {
|
|
23460
23089
|
throw new ActivationLedgerError(
|
|
@@ -23471,7 +23100,7 @@ function currentSessionLedgerPath(sessionDir) {
|
|
|
23471
23100
|
return join44(sessionDir, CURRENT_SESSION_LEDGER);
|
|
23472
23101
|
}
|
|
23473
23102
|
function readBoundedSessionHeader(filePath) {
|
|
23474
|
-
const fd =
|
|
23103
|
+
const fd = openSync2(filePath, "r");
|
|
23475
23104
|
try {
|
|
23476
23105
|
const buffer = Buffer.allocUnsafe(SESSION_HEADER_CHUNK_BYTES);
|
|
23477
23106
|
const decoder2 = new StringDecoder("utf8");
|
|
@@ -23519,7 +23148,7 @@ function readBoundedSessionHeader(filePath) {
|
|
|
23519
23148
|
}
|
|
23520
23149
|
return void 0;
|
|
23521
23150
|
} finally {
|
|
23522
|
-
|
|
23151
|
+
closeSync2(fd);
|
|
23523
23152
|
}
|
|
23524
23153
|
}
|
|
23525
23154
|
function parseSessionHeaderLine(line2) {
|
|
@@ -23545,7 +23174,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
|
|
|
23545
23174
|
const absoluteCwd = resolve17(cwd);
|
|
23546
23175
|
let names;
|
|
23547
23176
|
try {
|
|
23548
|
-
names =
|
|
23177
|
+
names = readdirSync3(absoluteSessionDir);
|
|
23549
23178
|
} catch (error) {
|
|
23550
23179
|
throw new ActivationLedgerError(
|
|
23551
23180
|
`archivist navigator nest is not readable (${sessionDir}): ${errorText(error)}`,
|
|
@@ -23558,7 +23187,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
|
|
|
23558
23187
|
const filePath = join44(absoluteSessionDir, name);
|
|
23559
23188
|
let st;
|
|
23560
23189
|
try {
|
|
23561
|
-
st =
|
|
23190
|
+
st = statSync7(filePath);
|
|
23562
23191
|
} catch (error) {
|
|
23563
23192
|
throw new ActivationLedgerError(
|
|
23564
23193
|
`archivist navigator session file is not stat-able (${filePath}): ${errorText(error)}`,
|
|
@@ -23699,7 +23328,7 @@ function createRecordSessionOpen(options, host = piRecordSessionHost) {
|
|
|
23699
23328
|
if (file !== void 0 && !existsSync12(file)) {
|
|
23700
23329
|
const header = session.getHeader();
|
|
23701
23330
|
if (header !== null && header.type === "session") {
|
|
23702
|
-
|
|
23331
|
+
writeFileSync3(file, `${JSON.stringify(header)}
|
|
23703
23332
|
`, { flag: "wx" });
|
|
23704
23333
|
session.setSessionFile(file);
|
|
23705
23334
|
}
|
|
@@ -23796,8 +23425,8 @@ init_activation_ledger_topology();
|
|
|
23796
23425
|
import {
|
|
23797
23426
|
lstatSync as lstatSync2,
|
|
23798
23427
|
realpathSync as realpathSync2,
|
|
23799
|
-
statSync as
|
|
23800
|
-
writeFileSync as
|
|
23428
|
+
statSync as statSync6,
|
|
23429
|
+
writeFileSync as writeFileSync2
|
|
23801
23430
|
} from "node:fs";
|
|
23802
23431
|
import { isAbsolute as isAbsolute11, resolve as resolve15 } from "node:path";
|
|
23803
23432
|
var ActivationSessionFileMissingError = class extends Error {
|
|
@@ -23818,7 +23447,7 @@ function materializeDeferredSessionFile(sessionManager, resolvedFile) {
|
|
|
23818
23447
|
throw new ActivationSessionFileMissingError(resolvedFile);
|
|
23819
23448
|
}
|
|
23820
23449
|
try {
|
|
23821
|
-
|
|
23450
|
+
writeFileSync2(resolvedFile, `${JSON.stringify(header)}
|
|
23822
23451
|
`, { flag: "wx" });
|
|
23823
23452
|
} catch (error) {
|
|
23824
23453
|
if (errnoCode(error) !== "EEXIST") {
|
|
@@ -23871,7 +23500,7 @@ function durableSessionPointer(sessionManager) {
|
|
|
23871
23500
|
}
|
|
23872
23501
|
let info;
|
|
23873
23502
|
try {
|
|
23874
|
-
info =
|
|
23503
|
+
info = statSync6(realFile);
|
|
23875
23504
|
} catch (error) {
|
|
23876
23505
|
throw new Error(
|
|
23877
23506
|
`Workflow role activation failed to stat durable session file (${realFile}): ${errorText(error)}`,
|
|
@@ -25213,7 +24842,7 @@ var AUDITOR_TOOL_SPEC = {
|
|
|
25213
24842
|
};
|
|
25214
24843
|
|
|
25215
24844
|
// src/navigator-attendance.ts
|
|
25216
|
-
import { createHash as
|
|
24845
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
25217
24846
|
init_navigator_invocation_identity();
|
|
25218
24847
|
init_packaged_role_registry();
|
|
25219
24848
|
init_activation_ledger_topology();
|
|
@@ -25774,7 +25403,7 @@ function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
|
|
|
25774
25403
|
if (provenance === "placeholder") return subjectRoot;
|
|
25775
25404
|
const normalized = subject.trim().replace(/\s+/g, " ");
|
|
25776
25405
|
if (normalized === "") return subjectRoot;
|
|
25777
|
-
return `${subjectRoot}#${
|
|
25406
|
+
return `${subjectRoot}#${createHash7("sha256").update(normalized).digest("hex").slice(0, 32)}`;
|
|
25778
25407
|
}
|
|
25779
25408
|
function navigatorSubjectKeyForInput(subjectRoot, reference, cwd = process.cwd()) {
|
|
25780
25409
|
if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
|
|
@@ -26263,7 +25892,7 @@ init_worker_submission_contracts();
|
|
|
26263
25892
|
init_submission_errors();
|
|
26264
25893
|
init_worker_submission_contracts();
|
|
26265
25894
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
26266
|
-
import { existsSync as existsSync14, lstatSync as lstatSync3, readdirSync as
|
|
25895
|
+
import { existsSync as existsSync14, lstatSync as lstatSync3, readdirSync as readdirSync4, readFileSync as readFileSync5, rmdirSync, rmSync as rmSync2 } from "node:fs";
|
|
26267
25896
|
import { resolve as resolve19 } from "node:path";
|
|
26268
25897
|
var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
|
|
26269
25898
|
var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
|
|
@@ -26329,13 +25958,13 @@ function unsetOwnedHooksPath(file) {
|
|
|
26329
25958
|
function rmOwnedDir(dir) {
|
|
26330
25959
|
const hookPath = resolve19(dir, HOOK_FILE);
|
|
26331
25960
|
if (!ownedHook(hookPath)) return;
|
|
26332
|
-
|
|
26333
|
-
if (existsSync14(dir) &&
|
|
25961
|
+
rmSync2(hookPath, { force: true });
|
|
25962
|
+
if (existsSync14(dir) && readdirSync4(dir).length === 0) rmdirSync(dir);
|
|
26334
25963
|
}
|
|
26335
25964
|
function linkedGitDirs(commonDir) {
|
|
26336
25965
|
const root = resolve19(commonDir, "worktrees");
|
|
26337
25966
|
if (!existsSync14(root)) return [];
|
|
26338
|
-
return
|
|
25967
|
+
return readdirSync4(root).map((name) => resolve19(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
|
|
26339
25968
|
}
|
|
26340
25969
|
function uninstallPackageWorkerHooks(cwd) {
|
|
26341
25970
|
let inside;
|
|
@@ -26353,13 +25982,13 @@ function uninstallPackageWorkerHooks(cwd) {
|
|
|
26353
25982
|
clear(resolve19(commonDir, "config.worktree"));
|
|
26354
25983
|
rmOwnedDir(resolve19(commonDir, HOOKS_DIR));
|
|
26355
25984
|
const legacy = resolve19(commonDir, "hooks", HOOK_FILE);
|
|
26356
|
-
if (ownedHook(legacy))
|
|
25985
|
+
if (ownedHook(legacy)) rmSync2(legacy, { force: true });
|
|
26357
25986
|
for (const gitDir of linkedGitDirs(commonDir)) {
|
|
26358
25987
|
clear(resolve19(gitDir, "config.worktree"));
|
|
26359
25988
|
rmOwnedDir(resolve19(gitDir, HOOKS_DIR));
|
|
26360
25989
|
}
|
|
26361
25990
|
}
|
|
26362
|
-
function
|
|
25991
|
+
function isRecord16(value) {
|
|
26363
25992
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26364
25993
|
}
|
|
26365
25994
|
function unfinishedReasonPresent(details) {
|
|
@@ -26375,7 +26004,7 @@ function readGateState(session) {
|
|
|
26375
26004
|
if (entry.type !== "custom") continue;
|
|
26376
26005
|
if (entry.customType === WORKER_COMMIT_BASELINE_ENTRY_TYPE) {
|
|
26377
26006
|
const data = entry.data;
|
|
26378
|
-
if (
|
|
26007
|
+
if (isRecord16(data) && (data.head === null || typeof data.head === "string")) {
|
|
26379
26008
|
baseline = data.head;
|
|
26380
26009
|
}
|
|
26381
26010
|
} else if (entry.customType === WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE) {
|
|
@@ -26568,11 +26197,11 @@ var FIXER_PHASES = ["plan", "apply"];
|
|
|
26568
26197
|
function isWorkerPhase(value) {
|
|
26569
26198
|
return typeof value === "string" && FIXER_PHASES.includes(value);
|
|
26570
26199
|
}
|
|
26571
|
-
function
|
|
26200
|
+
function isRecord17(value) {
|
|
26572
26201
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26573
26202
|
}
|
|
26574
26203
|
function workerStatusOf(output) {
|
|
26575
|
-
return
|
|
26204
|
+
return isRecord17(output) && typeof output.status === "string" ? output.status : void 0;
|
|
26576
26205
|
}
|
|
26577
26206
|
function deepFreeze2(value) {
|
|
26578
26207
|
if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
|
|
@@ -28917,27 +28546,17 @@ function acpModelId(modelPassing, model) {
|
|
|
28917
28546
|
}
|
|
28918
28547
|
|
|
28919
28548
|
// src/acp-host/role-turn-host.ts
|
|
28549
|
+
import { join as join50 } from "node:path";
|
|
28920
28550
|
import { spawn as spawn4 } from "node:child_process";
|
|
28921
28551
|
import { createInterface } from "node:readline";
|
|
28922
28552
|
|
|
28923
28553
|
// src/external-host-turn-loop.ts
|
|
28924
|
-
init_packaged_role_registry();
|
|
28925
28554
|
var EXTERNAL_ROLE_TURN_ROUND_LIMIT = 8;
|
|
28926
28555
|
function mergeRoleTurnAbortSignals(prepared, request) {
|
|
28927
28556
|
if (request === void 0) return prepared;
|
|
28928
28557
|
if (prepared === void 0) return request;
|
|
28929
28558
|
return AbortSignal.any([prepared, request]);
|
|
28930
28559
|
}
|
|
28931
|
-
function promptWithPriorNativePaths(basePrompt, request) {
|
|
28932
|
-
if (request.continuation.kind !== "resume") return basePrompt;
|
|
28933
|
-
if (request.stationChild === true && isOfficerReviewSeat(request.activation.role)) {
|
|
28934
|
-
return basePrompt;
|
|
28935
|
-
}
|
|
28936
|
-
const paths = request.hostTransition?.priorNativePaths;
|
|
28937
|
-
if (paths === void 0 || paths.length === 0) return basePrompt;
|
|
28938
|
-
return `${basePrompt}
|
|
28939
|
-
${paths.join("\n")}`;
|
|
28940
|
-
}
|
|
28941
28560
|
function isHostAbortedError(error) {
|
|
28942
28561
|
return typeof error === "object" && error !== null && error.code === "host-aborted";
|
|
28943
28562
|
}
|
|
@@ -28986,7 +28605,7 @@ async function settleHostAborted(prepared, sessionId) {
|
|
|
28986
28605
|
});
|
|
28987
28606
|
}
|
|
28988
28607
|
async function driveExternalRoleTurnRounds(prepared, request, driver) {
|
|
28989
|
-
let prompt =
|
|
28608
|
+
let prompt = prepared.prompt;
|
|
28990
28609
|
const abortSignal = mergeRoleTurnAbortSignals(prepared.abortSignal, request.signal);
|
|
28991
28610
|
let stderr = "";
|
|
28992
28611
|
for (let attempt = 0; attempt < EXTERNAL_ROLE_TURN_ROUND_LIMIT; attempt += 1) {
|
|
@@ -29030,31 +28649,8 @@ function createSerializedRoleTurnHost(execute) {
|
|
|
29030
28649
|
};
|
|
29031
28650
|
}
|
|
29032
28651
|
|
|
29033
|
-
// src/host-session-record.ts
|
|
29034
|
-
init_sitian_facade();
|
|
29035
|
-
var HOST_SESSION_RECORD_KIND = "host-session";
|
|
29036
|
-
function eventField(event, key) {
|
|
29037
|
-
if (typeof event !== "object" || event === null || Array.isArray(event)) return void 0;
|
|
29038
|
-
const value = event[key];
|
|
29039
|
-
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
29040
|
-
}
|
|
29041
|
-
function reportHostSessionEvent(input) {
|
|
29042
|
-
const identity = input.identity ?? eventField(input.event, "uuid");
|
|
29043
|
-
const timestamp2 = input.timestamp ?? eventField(input.event, "timestamp");
|
|
29044
|
-
sitianReport({
|
|
29045
|
-
level: "event",
|
|
29046
|
-
kind: HOST_SESSION_RECORD_KIND,
|
|
29047
|
-
host: input.host,
|
|
29048
|
-
cwd: input.cwd,
|
|
29049
|
-
sessionParent: input.sessionParent,
|
|
29050
|
-
source: input.source,
|
|
29051
|
-
payload: input.event,
|
|
29052
|
-
...identity === void 0 ? {} : { identity },
|
|
29053
|
-
...timestamp2 === void 0 ? {} : { timestamp: timestamp2 }
|
|
29054
|
-
});
|
|
29055
|
-
}
|
|
29056
|
-
|
|
29057
28652
|
// src/acp-host/role-turn-host.ts
|
|
28653
|
+
init_host_session_record();
|
|
29058
28654
|
init_navigator_output();
|
|
29059
28655
|
|
|
29060
28656
|
// src/agent-start-materials.ts
|
|
@@ -29069,18 +28665,6 @@ function renderSystemPromptOverride(authority) {
|
|
|
29069
28665
|
}
|
|
29070
28666
|
|
|
29071
28667
|
// src/acp-host/role-turn-host.ts
|
|
29072
|
-
var GROK_BUILD_HOST = "grok-build";
|
|
29073
|
-
function acpPromptResultHasUsage(result) {
|
|
29074
|
-
const meta = result._meta;
|
|
29075
|
-
if (typeof meta !== "object" || meta === null || Array.isArray(meta)) return false;
|
|
29076
|
-
return Object.prototype.hasOwnProperty.call(meta, "usage");
|
|
29077
|
-
}
|
|
29078
|
-
function isAcpAutoCompactCompletedNotification(method, params) {
|
|
29079
|
-
if (method !== "_x.ai/session_notification") return false;
|
|
29080
|
-
const update = params.update;
|
|
29081
|
-
if (typeof update !== "object" || update === null || Array.isArray(update)) return false;
|
|
29082
|
-
return update.sessionUpdate === "auto_compact_completed";
|
|
29083
|
-
}
|
|
29084
28668
|
function acpAgentTextChunk(params) {
|
|
29085
28669
|
let kind;
|
|
29086
28670
|
let content;
|
|
@@ -29252,189 +28836,142 @@ function createAcpRoleTurnHost(config) {
|
|
|
29252
28836
|
const systemPromptOverride = renderSystemPromptOverride(prepared.systemPrompt);
|
|
29253
28837
|
let connection;
|
|
29254
28838
|
let sessionId;
|
|
28839
|
+
let sessionOpened = false;
|
|
29255
28840
|
let accepted = false;
|
|
28841
|
+
const sessionParent = config.sessionIdentity.resolveSessionFile(request.principal);
|
|
29256
28842
|
let outcome = failure("session", "AcpNoOutcome", "no-outcome");
|
|
29257
28843
|
try {
|
|
29258
28844
|
if (prepared.mcpServers.length === 0) {
|
|
29259
28845
|
outcome = failure("activation", "UncontrolledAcpSession", "ak-config-missing");
|
|
29260
28846
|
} else {
|
|
29261
28847
|
connection = await config.connect(request);
|
|
29262
|
-
const
|
|
29263
|
-
const recordAbort = new AbortController();
|
|
29264
|
-
let hostSessionRecordFailure;
|
|
29265
|
-
const hostSessionRecordResult = () => ({
|
|
29266
|
-
code: null,
|
|
29267
|
-
stderr: "",
|
|
29268
|
-
timedOut: false,
|
|
29269
|
-
knownFailure: hostSessionRecordFailure
|
|
29270
|
-
});
|
|
29271
|
-
const noteHostSessionRecordFailure = (error) => {
|
|
29272
|
-
if (hostSessionRecordFailure !== void 0) return;
|
|
29273
|
-
hostSessionRecordFailure = {
|
|
29274
|
-
cause: "session",
|
|
29275
|
-
identity: { name: "HostSessionRecordFailure", code: "host-session-record-failed" },
|
|
29276
|
-
diagnostic: error instanceof Error ? error.message : String(error)
|
|
29277
|
-
};
|
|
29278
|
-
try {
|
|
29279
|
-
recordAbort.abort();
|
|
29280
|
-
} catch {
|
|
29281
|
-
}
|
|
29282
|
-
};
|
|
29283
|
-
const rpc = (method, params) => raceAgainstHostAbort(connection.request(method, params), recordAbort.signal, "host-session-record-failed");
|
|
28848
|
+
const rpc = (method, params) => connection.request(method, params);
|
|
29284
28849
|
const agentProseChunks = [];
|
|
29285
28850
|
let collectAgentProse = false;
|
|
29286
|
-
const ledgerGrokBuildObservability = config.hostName === GROK_BUILD_HOST;
|
|
29287
28851
|
connection.onNotification?.((method, params) => {
|
|
29288
|
-
if (hostSessionRecordFailure !== void 0) return;
|
|
29289
28852
|
const isSessionUpdate = method === "session/update";
|
|
29290
|
-
|
|
29291
|
-
if (
|
|
29292
|
-
if (isSessionUpdate && collectAgentProse) {
|
|
28853
|
+
if (!isSessionUpdate) return;
|
|
28854
|
+
if (collectAgentProse) {
|
|
29293
28855
|
const chunk = acpAgentTextChunk(params);
|
|
29294
28856
|
if (chunk !== void 0) agentProseChunks.push(chunk);
|
|
29295
28857
|
}
|
|
29296
|
-
|
|
29297
|
-
|
|
28858
|
+
});
|
|
28859
|
+
const initialized = await rpc("initialize", {
|
|
28860
|
+
protocolVersion: 1,
|
|
28861
|
+
clientCapabilities: {}
|
|
28862
|
+
});
|
|
28863
|
+
const initializeMeta = initialized._meta;
|
|
28864
|
+
const availableModels = Array.isArray(initializeMeta?.modelState?.availableModels) ? initializeMeta.modelState.availableModels : void 0;
|
|
28865
|
+
if (request.model !== void 0 && availableModels !== void 0 && !availableModels.some((entry) => typeof entry === "object" && entry !== null && entry.modelId === acpModelId(config.modelPassing, request.model))) {
|
|
28866
|
+
outcome = failure("activation", "AcpHostModelMismatch", "host-model-mismatch", {
|
|
28867
|
+
provider: request.model.provider,
|
|
28868
|
+
model: request.model.model
|
|
28869
|
+
});
|
|
28870
|
+
} else {
|
|
28871
|
+
const sessionBindParams = {
|
|
28872
|
+
cwd: request.cwd,
|
|
28873
|
+
mcpServers: prepared.mcpServers,
|
|
28874
|
+
_meta: { systemPromptOverride, yoloMode: false }
|
|
28875
|
+
};
|
|
28876
|
+
const loadSession = async (bindSessionId) => {
|
|
28877
|
+
const loaded = await rpc("session/load", {
|
|
28878
|
+
sessionId: bindSessionId,
|
|
28879
|
+
...sessionBindParams
|
|
28880
|
+
});
|
|
28881
|
+
const loadedId = typeof loaded.sessionId === "string" && loaded.sessionId !== "" ? loaded.sessionId : bindSessionId;
|
|
28882
|
+
if (config.hostName !== "hermes") recordNativeSessionPointer({
|
|
29298
28883
|
host: config.hostName,
|
|
28884
|
+
sessionId: loadedId,
|
|
29299
28885
|
cwd: request.cwd,
|
|
29300
28886
|
sessionParent,
|
|
29301
|
-
|
|
29302
|
-
event: { method, params }
|
|
28887
|
+
home: request.home
|
|
29303
28888
|
});
|
|
29304
|
-
|
|
29305
|
-
|
|
28889
|
+
return loadedId;
|
|
28890
|
+
};
|
|
28891
|
+
if (request.continuation.kind === "resume" && config.boundResume === "session/load") {
|
|
28892
|
+
const explicitHostSessionId = request.continuation.hostSessionId;
|
|
28893
|
+
const boundSessionId = explicitHostSessionId !== void 0 && explicitHostSessionId !== "" ? explicitHostSessionId : await config.sessionIdentity.load(request.principal);
|
|
28894
|
+
if (boundSessionId !== void 0 && boundSessionId !== "") {
|
|
28895
|
+
sessionId = boundSessionId;
|
|
28896
|
+
sessionId = await loadSession(boundSessionId);
|
|
28897
|
+
sessionOpened = true;
|
|
28898
|
+
}
|
|
29306
28899
|
}
|
|
29307
|
-
|
|
29308
|
-
|
|
29309
|
-
|
|
29310
|
-
|
|
29311
|
-
|
|
29312
|
-
|
|
29313
|
-
|
|
29314
|
-
|
|
29315
|
-
|
|
29316
|
-
|
|
29317
|
-
|
|
29318
|
-
|
|
29319
|
-
|
|
29320
|
-
|
|
29321
|
-
const sessionBindParams = {
|
|
29322
|
-
cwd: request.cwd,
|
|
29323
|
-
mcpServers: prepared.mcpServers,
|
|
29324
|
-
_meta: { systemPromptOverride, yoloMode: false }
|
|
29325
|
-
};
|
|
29326
|
-
const loadSession = async (bindSessionId) => {
|
|
29327
|
-
const loaded = await rpc("session/load", {
|
|
29328
|
-
sessionId: bindSessionId,
|
|
29329
|
-
...sessionBindParams
|
|
28900
|
+
let sessionReady = true;
|
|
28901
|
+
if (sessionId === void 0) {
|
|
28902
|
+
const session = await rpc("session/new", sessionBindParams);
|
|
28903
|
+
sessionId = typeof session.sessionId === "string" ? session.sessionId : void 0;
|
|
28904
|
+
if (sessionId === void 0 || sessionId === "") {
|
|
28905
|
+
outcome = failure("session", "AcpSessionFailure", "session-id-missing");
|
|
28906
|
+
sessionReady = false;
|
|
28907
|
+
} else {
|
|
28908
|
+
if (config.hostName !== "hermes") recordNativeSessionPointer({
|
|
28909
|
+
host: config.hostName,
|
|
28910
|
+
sessionId,
|
|
28911
|
+
cwd: request.cwd,
|
|
28912
|
+
sessionParent,
|
|
28913
|
+
home: request.home
|
|
29330
28914
|
});
|
|
29331
|
-
|
|
29332
|
-
|
|
29333
|
-
if (request.continuation.kind === "resume" && config.boundResume === "session/load") {
|
|
29334
|
-
const explicitHostSessionId = request.continuation.hostSessionId;
|
|
29335
|
-
const boundSessionId = explicitHostSessionId !== void 0 && explicitHostSessionId !== "" ? explicitHostSessionId : await config.sessionIdentity.load(request.principal);
|
|
29336
|
-
if (boundSessionId !== void 0 && boundSessionId !== "") {
|
|
29337
|
-
sessionId = await loadSession(boundSessionId);
|
|
29338
|
-
}
|
|
28915
|
+
sessionOpened = true;
|
|
28916
|
+
await config.sessionIdentity.bind(request.principal, sessionId);
|
|
29339
28917
|
}
|
|
29340
|
-
|
|
29341
|
-
|
|
29342
|
-
|
|
29343
|
-
|
|
29344
|
-
|
|
29345
|
-
|
|
29346
|
-
|
|
29347
|
-
|
|
29348
|
-
await config.sessionIdentity.bind(request.principal, sessionId);
|
|
29349
|
-
}
|
|
28918
|
+
}
|
|
28919
|
+
if (sessionReady) {
|
|
28920
|
+
if (config.modelPassing === "set_model" && request.model !== void 0 && sessionId !== void 0) {
|
|
28921
|
+
await rpc("session/set_model", {
|
|
28922
|
+
sessionId,
|
|
28923
|
+
modelId: acpModelId(config.modelPassing, request.model)
|
|
28924
|
+
});
|
|
28925
|
+
sessionId = await loadSession(sessionId);
|
|
29350
28926
|
}
|
|
29351
|
-
|
|
29352
|
-
|
|
29353
|
-
|
|
29354
|
-
|
|
29355
|
-
|
|
29356
|
-
|
|
29357
|
-
|
|
29358
|
-
|
|
29359
|
-
|
|
29360
|
-
|
|
29361
|
-
|
|
29362
|
-
|
|
29363
|
-
|
|
29364
|
-
|
|
29365
|
-
|
|
29366
|
-
|
|
29367
|
-
|
|
29368
|
-
|
|
29369
|
-
|
|
29370
|
-
agentProseChunks.length = 0;
|
|
29371
|
-
collectAgentProse = prepared.terminatingToolName === NAVIGATOR_OUTPUT_TOOL_NAME;
|
|
29372
|
-
try {
|
|
29373
|
-
result = await raceAgainstHostAbort(
|
|
29374
|
-
activeConnection.request("session/prompt", {
|
|
29375
|
-
sessionId: activeSessionId,
|
|
29376
|
-
prompt: [{ type: "text", text: prompt }]
|
|
29377
|
-
}),
|
|
29378
|
-
combinedAbort,
|
|
29379
|
-
"ACP host aborted"
|
|
29380
|
-
);
|
|
29381
|
-
} catch (error) {
|
|
29382
|
-
collectAgentProse = false;
|
|
29383
|
-
agentProseChunks.length = 0;
|
|
29384
|
-
if (hostSessionRecordFailure !== void 0) {
|
|
29385
|
-
return { status: "terminal", result: hostSessionRecordResult() };
|
|
29386
|
-
}
|
|
29387
|
-
throw error;
|
|
29388
|
-
}
|
|
28927
|
+
const activeConnection = connection;
|
|
28928
|
+
const activeSessionId = sessionId;
|
|
28929
|
+
const turnResult = await driveExternalRoleTurnRounds(prepared, request, {
|
|
28930
|
+
roundLimitName: "AcpRoundLimit",
|
|
28931
|
+
currentSessionId: () => sessionId,
|
|
28932
|
+
async runRound({ prompt, abortSignal }) {
|
|
28933
|
+
let result;
|
|
28934
|
+
agentProseChunks.length = 0;
|
|
28935
|
+
collectAgentProse = prepared.terminatingToolName === NAVIGATOR_OUTPUT_TOOL_NAME;
|
|
28936
|
+
try {
|
|
28937
|
+
result = await raceAgainstHostAbort(
|
|
28938
|
+
activeConnection.request("session/prompt", {
|
|
28939
|
+
sessionId: activeSessionId,
|
|
28940
|
+
prompt: [{ type: "text", text: prompt }]
|
|
28941
|
+
}),
|
|
28942
|
+
abortSignal,
|
|
28943
|
+
"ACP host aborted"
|
|
28944
|
+
);
|
|
28945
|
+
} catch (error) {
|
|
29389
28946
|
collectAgentProse = false;
|
|
29390
|
-
|
|
29391
|
-
|
|
29392
|
-
|
|
29393
|
-
|
|
29394
|
-
|
|
29395
|
-
|
|
29396
|
-
|
|
29397
|
-
|
|
29398
|
-
|
|
29399
|
-
|
|
29400
|
-
|
|
29401
|
-
|
|
29402
|
-
|
|
29403
|
-
|
|
29404
|
-
if (
|
|
29405
|
-
|
|
29406
|
-
}
|
|
29407
|
-
if (result.stopReason === "refusal") {
|
|
29408
|
-
agentProseChunks.length = 0;
|
|
29409
|
-
return {
|
|
29410
|
-
status: "terminal",
|
|
29411
|
-
result: failure("output", "AcpRefusal", "refusal", { sessionId })
|
|
29412
|
-
};
|
|
29413
|
-
}
|
|
29414
|
-
if (prepared.terminatingToolName === NAVIGATOR_OUTPUT_TOOL_NAME) {
|
|
29415
|
-
const prose = agentProseChunks.join("");
|
|
29416
|
-
agentProseChunks.length = 0;
|
|
29417
|
-
if (navigatorProseFromUnknown(prose) !== void 0) {
|
|
29418
|
-
await prepared.ingestStructuredOutput({ prose });
|
|
29419
|
-
}
|
|
29420
|
-
} else {
|
|
29421
|
-
agentProseChunks.length = 0;
|
|
28947
|
+
agentProseChunks.length = 0;
|
|
28948
|
+
throw error;
|
|
28949
|
+
}
|
|
28950
|
+
collectAgentProse = false;
|
|
28951
|
+
if (result.stopReason === "refusal") {
|
|
28952
|
+
agentProseChunks.length = 0;
|
|
28953
|
+
return {
|
|
28954
|
+
status: "terminal",
|
|
28955
|
+
result: failure("output", "AcpRefusal", "refusal", { sessionId })
|
|
28956
|
+
};
|
|
28957
|
+
}
|
|
28958
|
+
if (prepared.terminatingToolName === NAVIGATOR_OUTPUT_TOOL_NAME) {
|
|
28959
|
+
const prose = agentProseChunks.join("");
|
|
28960
|
+
agentProseChunks.length = 0;
|
|
28961
|
+
if (navigatorProseFromUnknown(prose) !== void 0) {
|
|
28962
|
+
await prepared.ingestStructuredOutput({ prose });
|
|
29422
28963
|
}
|
|
29423
|
-
|
|
29424
|
-
|
|
29425
|
-
async afterAccepted() {
|
|
29426
|
-
await rpc("session/close", { sessionId: activeSessionId });
|
|
29427
|
-
accepted = true;
|
|
28964
|
+
} else {
|
|
28965
|
+
agentProseChunks.length = 0;
|
|
29428
28966
|
}
|
|
29429
|
-
|
|
29430
|
-
|
|
29431
|
-
|
|
29432
|
-
|
|
29433
|
-
|
|
29434
|
-
|
|
29435
|
-
|
|
29436
|
-
|
|
29437
|
-
throw error;
|
|
28967
|
+
return { status: "delivered", stderr: activeConnection.stderr?.() ?? "" };
|
|
28968
|
+
},
|
|
28969
|
+
async afterAccepted() {
|
|
28970
|
+
await rpc("session/close", { sessionId: activeSessionId });
|
|
28971
|
+
accepted = true;
|
|
28972
|
+
}
|
|
28973
|
+
});
|
|
28974
|
+
outcome = turnResult;
|
|
29438
28975
|
}
|
|
29439
28976
|
}
|
|
29440
28977
|
}
|
|
@@ -29451,6 +28988,18 @@ function createAcpRoleTurnHost(config) {
|
|
|
29451
28988
|
} catch {
|
|
29452
28989
|
}
|
|
29453
28990
|
}
|
|
28991
|
+
if (config.hostName !== "hermes" && sessionOpened && sessionId !== void 0) {
|
|
28992
|
+
copyAndRecordHostDossier({
|
|
28993
|
+
host: config.hostName,
|
|
28994
|
+
sessionId,
|
|
28995
|
+
cwd: request.cwd,
|
|
28996
|
+
sessionDirectory: join50(request.runDirectory, "session"),
|
|
28997
|
+
sessionParent,
|
|
28998
|
+
continuation: request.continuation,
|
|
28999
|
+
...request.model !== void 0 ? { model: request.model } : {},
|
|
29000
|
+
...request.home !== void 0 ? { home: request.home } : {}
|
|
29001
|
+
});
|
|
29002
|
+
}
|
|
29454
29003
|
try {
|
|
29455
29004
|
await prepared.dispose?.();
|
|
29456
29005
|
} catch (cleanupError) {
|
|
@@ -29463,17 +29012,17 @@ function createAcpRoleTurnHost(config) {
|
|
|
29463
29012
|
|
|
29464
29013
|
// src/acp-host/seat-profile-soul.ts
|
|
29465
29014
|
import { constants as constants3 } from "node:fs";
|
|
29466
|
-
import { access as
|
|
29467
|
-
import { dirname as dirname26, join as
|
|
29015
|
+
import { access as access3, copyFile, lstat as lstat8, mkdir as mkdir6, readlink, symlink as symlink2, unlink as unlink6 } from "node:fs/promises";
|
|
29016
|
+
import { dirname as dirname26, join as join51, relative as relative3, resolve as resolve21 } from "node:path";
|
|
29468
29017
|
function seatProfileName(spec, role) {
|
|
29469
29018
|
return `${spec.namePrefix}${role}`;
|
|
29470
29019
|
}
|
|
29471
29020
|
function packageRoleSoulPath(packageRoot, role) {
|
|
29472
|
-
return
|
|
29021
|
+
return join51(packageRoot, "souls", `${role}.md`);
|
|
29473
29022
|
}
|
|
29474
29023
|
async function pathExists2(path) {
|
|
29475
29024
|
try {
|
|
29476
|
-
await
|
|
29025
|
+
await access3(path, constants3.F_OK);
|
|
29477
29026
|
return true;
|
|
29478
29027
|
} catch {
|
|
29479
29028
|
return false;
|
|
@@ -29486,16 +29035,16 @@ async function ensureSeatProfileSoul(options) {
|
|
|
29486
29035
|
if (!await pathExists2(soulTarget)) {
|
|
29487
29036
|
throw new Error(`packaged role soul missing: ${soulTarget}`);
|
|
29488
29037
|
}
|
|
29489
|
-
const profilesRoot =
|
|
29490
|
-
const profileDir =
|
|
29038
|
+
const profilesRoot = join51(operatorHome, ...spec.profilesRootFromHome);
|
|
29039
|
+
const profileDir = join51(profilesRoot, profileName);
|
|
29491
29040
|
const hostRoot = dirname26(profilesRoot);
|
|
29492
|
-
const soulPath =
|
|
29041
|
+
const soulPath = join51(profileDir, spec.soulFileName);
|
|
29493
29042
|
if (!await pathExists2(profileDir)) {
|
|
29494
29043
|
await mkdir6(profileDir, { recursive: true });
|
|
29495
29044
|
for (const name of ["auth.json", ".env", "config.yaml"]) {
|
|
29496
|
-
const source =
|
|
29045
|
+
const source = join51(hostRoot, name);
|
|
29497
29046
|
if (!await pathExists2(source)) continue;
|
|
29498
|
-
await copyFile(source,
|
|
29047
|
+
await copyFile(source, join51(profileDir, name));
|
|
29499
29048
|
}
|
|
29500
29049
|
} else {
|
|
29501
29050
|
await mkdir6(profileDir, { recursive: true });
|