@akagilnc/pi-workflow-roles 0.1.3733 → 0.1.3741
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 -3
- package/README.zh-CN.md +1 -3
- package/dist/acp-host/production-host.js +278 -201
- package/dist/public-cli/config.js +2 -102
- package/dist/public-cli/host-providers.js +188 -0
- package/dist/public-cli/main.js +350 -324
- package/dist/public-cli/option-definitions.js +1 -4
- package/dist/public-role-summons.js +8 -4
- package/package.json +1 -1
- package/souls/countersign.md +1 -1
- package/souls/judge.md +21 -68
- package/souls/notary.md +1 -1
- package/src/public-cli/cli.ts +38 -71
- package/src/public-cli/config.ts +3 -153
- package/src/public-cli/host-providers.ts +246 -0
- package/src/public-cli/option-definitions.ts +1 -4
- package/src/public-role-summons.ts +14 -7
package/dist/public-cli/main.js
CHANGED
|
@@ -15610,50 +15610,6 @@ function parseAutoResumeLimit(value) {
|
|
|
15610
15610
|
function setAutoResumeLimit(config, limit) {
|
|
15611
15611
|
return { ...config, autoResumeLimit: parseAutoResumeLimit(limit) };
|
|
15612
15612
|
}
|
|
15613
|
-
function requireNonEmptyToken(value, label) {
|
|
15614
|
-
const trimmed = value.trim();
|
|
15615
|
-
if (trimmed === "") {
|
|
15616
|
-
throw new Error(`${label} must be a non-empty string`);
|
|
15617
|
-
}
|
|
15618
|
-
return trimmed;
|
|
15619
|
-
}
|
|
15620
|
-
function setProviderHostAlias(config, provider, host, alias) {
|
|
15621
|
-
const from = requireNonEmptyToken(provider, "provider");
|
|
15622
|
-
const hostName = requireNonEmptyToken(host, "host");
|
|
15623
|
-
const to = requireNonEmptyToken(alias, "alias");
|
|
15624
|
-
const previous = config.providerAliases ?? {};
|
|
15625
|
-
return {
|
|
15626
|
-
...config,
|
|
15627
|
-
providerAliases: {
|
|
15628
|
-
...previous,
|
|
15629
|
-
[from]: {
|
|
15630
|
-
...previous[from] ?? {},
|
|
15631
|
-
[hostName]: to
|
|
15632
|
-
}
|
|
15633
|
-
}
|
|
15634
|
-
};
|
|
15635
|
-
}
|
|
15636
|
-
function unsetProviderHostAlias(config, provider, host) {
|
|
15637
|
-
const from = requireNonEmptyToken(provider, "provider");
|
|
15638
|
-
const hostName = requireNonEmptyToken(host, "host");
|
|
15639
|
-
const previous = config.providerAliases;
|
|
15640
|
-
if (previous === void 0 || previous[from] === void 0) return config;
|
|
15641
|
-
const { [hostName]: _dropped, ...restHosts } = previous[from];
|
|
15642
|
-
const nextForProvider = Object.keys(restHosts).length === 0 ? void 0 : restHosts;
|
|
15643
|
-
const { [from]: _provider, ...restProviders } = previous;
|
|
15644
|
-
const nextAliases = nextForProvider === void 0 ? restProviders : { ...restProviders, [from]: nextForProvider };
|
|
15645
|
-
if (Object.keys(nextAliases).length === 0) {
|
|
15646
|
-
const { providerAliases: _gone, ...rest } = config;
|
|
15647
|
-
return rest;
|
|
15648
|
-
}
|
|
15649
|
-
return { ...config, providerAliases: nextAliases };
|
|
15650
|
-
}
|
|
15651
|
-
function applyProviderHostAlias(selection, host, aliases) {
|
|
15652
|
-
if (selection === void 0 || aliases === void 0) return selection;
|
|
15653
|
-
const mapped = aliases[selection.provider]?.[host];
|
|
15654
|
-
if (mapped === void 0) return selection;
|
|
15655
|
-
return { ...selection, provider: mapped };
|
|
15656
|
-
}
|
|
15657
15613
|
function validatePublicCliConfigAxes(config, _packageRoot) {
|
|
15658
15614
|
for (const seat of Object.keys(config.seats)) {
|
|
15659
15615
|
const row = config.seats[seat];
|
|
@@ -15713,44 +15669,9 @@ function serializePublicCliConfig(config) {
|
|
|
15713
15669
|
...config.unknownSeats ?? {},
|
|
15714
15670
|
...config.seats
|
|
15715
15671
|
},
|
|
15716
|
-
...config.autoResumeLimit === void 0 ? {} : { autoResumeLimit: config.autoResumeLimit }
|
|
15717
|
-
...config.providerAliases === void 0 || Object.keys(config.providerAliases).length === 0 ? {} : { providerAliases: config.providerAliases }
|
|
15672
|
+
...config.autoResumeLimit === void 0 ? {} : { autoResumeLimit: config.autoResumeLimit }
|
|
15718
15673
|
};
|
|
15719
15674
|
}
|
|
15720
|
-
function parseProviderHostAliases(value) {
|
|
15721
|
-
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
15722
|
-
throw new Error("public CLI config.providerAliases must be an object");
|
|
15723
|
-
}
|
|
15724
|
-
const out = {};
|
|
15725
|
-
for (const [provider, byHost] of Object.entries(value)) {
|
|
15726
|
-
if (provider.trim() === "") {
|
|
15727
|
-
throw new Error("public CLI config.providerAliases provider key must be non-empty");
|
|
15728
|
-
}
|
|
15729
|
-
if (byHost === null || typeof byHost !== "object" || Array.isArray(byHost)) {
|
|
15730
|
-
throw new Error(
|
|
15731
|
-
`public CLI config.providerAliases[${provider}] must be an object`
|
|
15732
|
-
);
|
|
15733
|
-
}
|
|
15734
|
-
const hosts = {};
|
|
15735
|
-
for (const [host, alias] of Object.entries(byHost)) {
|
|
15736
|
-
if (host.trim() === "") {
|
|
15737
|
-
throw new Error(
|
|
15738
|
-
`public CLI config.providerAliases[${provider}] host key must be non-empty`
|
|
15739
|
-
);
|
|
15740
|
-
}
|
|
15741
|
-
if (typeof alias !== "string" || alias.trim() === "") {
|
|
15742
|
-
throw new Error(
|
|
15743
|
-
`public CLI config.providerAliases[${provider}][${host}] must be a non-empty string`
|
|
15744
|
-
);
|
|
15745
|
-
}
|
|
15746
|
-
hosts[host] = alias;
|
|
15747
|
-
}
|
|
15748
|
-
if (Object.keys(hosts).length > 0) {
|
|
15749
|
-
out[provider] = hosts;
|
|
15750
|
-
}
|
|
15751
|
-
}
|
|
15752
|
-
return out;
|
|
15753
|
-
}
|
|
15754
15675
|
function parsePublicCliConfig(value) {
|
|
15755
15676
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
15756
15677
|
throw new Error("public CLI config must be an object");
|
|
@@ -15760,13 +15681,6 @@ function parsePublicCliConfig(value) {
|
|
|
15760
15681
|
if (record4.autoResumeLimit !== void 0) {
|
|
15761
15682
|
autoResumeLimit = parseAutoResumeLimit(record4.autoResumeLimit);
|
|
15762
15683
|
}
|
|
15763
|
-
let providerAliases;
|
|
15764
|
-
if (record4.providerAliases !== void 0) {
|
|
15765
|
-
const parsed = parseProviderHostAliases(record4.providerAliases);
|
|
15766
|
-
if (Object.keys(parsed).length > 0) {
|
|
15767
|
-
providerAliases = parsed;
|
|
15768
|
-
}
|
|
15769
|
-
}
|
|
15770
15684
|
const unknownSeats = {};
|
|
15771
15685
|
if (record4.unknownSeats !== void 0) {
|
|
15772
15686
|
if (record4.unknownSeats === null || typeof record4.unknownSeats !== "object" || Array.isArray(record4.unknownSeats)) {
|
|
@@ -15777,7 +15691,6 @@ function parsePublicCliConfig(value) {
|
|
|
15777
15691
|
const withOpaque = (seats2) => ({
|
|
15778
15692
|
seats: seats2,
|
|
15779
15693
|
...autoResumeLimit === void 0 ? {} : { autoResumeLimit },
|
|
15780
|
-
...providerAliases === void 0 ? {} : { providerAliases },
|
|
15781
15694
|
...Object.keys(unknownSeats).length === 0 ? {} : { unknownSeats }
|
|
15782
15695
|
});
|
|
15783
15696
|
if (record4.seats === void 0) {
|
|
@@ -15954,21 +15867,11 @@ function resolveEffectiveSeat(config, seat, credentials, invocation) {
|
|
|
15954
15867
|
};
|
|
15955
15868
|
}
|
|
15956
15869
|
}
|
|
15957
|
-
|
|
15870
|
+
return attachHostAxis(
|
|
15958
15871
|
attachEngineAxis(modelSeat, config, invocation),
|
|
15959
15872
|
config,
|
|
15960
15873
|
invocation
|
|
15961
15874
|
);
|
|
15962
|
-
const selection = applyProviderHostAlias(
|
|
15963
|
-
withAxes.selection,
|
|
15964
|
-
withAxes.host,
|
|
15965
|
-
config.providerAliases
|
|
15966
|
-
);
|
|
15967
|
-
if (selection === void 0) {
|
|
15968
|
-
const { selection: _dropped, ...rest } = withAxes;
|
|
15969
|
-
return rest;
|
|
15970
|
-
}
|
|
15971
|
-
return { ...withAxes, selection };
|
|
15972
15875
|
}
|
|
15973
15876
|
function effectiveSeatConfigurations(config, credentials, invocation) {
|
|
15974
15877
|
return PUBLIC_CONFIGURABLE_SEATS.map(
|
|
@@ -16012,6 +15915,170 @@ var init_config2 = __esm({
|
|
|
16012
15915
|
}
|
|
16013
15916
|
});
|
|
16014
15917
|
|
|
15918
|
+
// src/public-cli/host-providers.ts
|
|
15919
|
+
import { readFileSync } from "node:fs";
|
|
15920
|
+
import { join as join6 } from "node:path";
|
|
15921
|
+
function hostProvidersPath(home) {
|
|
15922
|
+
if (typeof home !== "string" || home.trim() === "") {
|
|
15923
|
+
throw new Error("home must be explicitly provided");
|
|
15924
|
+
}
|
|
15925
|
+
return join6(home, ".ak-roles", "host-providers.json");
|
|
15926
|
+
}
|
|
15927
|
+
function hermesProviderModelsCachePath(home) {
|
|
15928
|
+
return join6(home, ".hermes", "provider_models_cache.json");
|
|
15929
|
+
}
|
|
15930
|
+
function parseHostProvidersTable(value) {
|
|
15931
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
15932
|
+
throw new Error("host-providers.json must be an object");
|
|
15933
|
+
}
|
|
15934
|
+
const out = {};
|
|
15935
|
+
for (const [host, byProvider] of Object.entries(value)) {
|
|
15936
|
+
if (host.trim() === "") {
|
|
15937
|
+
throw new Error("host-providers.json host key must be non-empty");
|
|
15938
|
+
}
|
|
15939
|
+
if (byProvider === null || typeof byProvider !== "object" || Array.isArray(byProvider)) {
|
|
15940
|
+
throw new Error(`host-providers.json[${host}] must be an object`);
|
|
15941
|
+
}
|
|
15942
|
+
const providers = {};
|
|
15943
|
+
for (const [seatProvider, hostProvider] of Object.entries(
|
|
15944
|
+
byProvider
|
|
15945
|
+
)) {
|
|
15946
|
+
if (seatProvider.trim() === "") {
|
|
15947
|
+
throw new Error(
|
|
15948
|
+
`host-providers.json[${host}] seat-provider key must be non-empty`
|
|
15949
|
+
);
|
|
15950
|
+
}
|
|
15951
|
+
if (typeof hostProvider !== "string" || hostProvider.trim() === "") {
|
|
15952
|
+
throw new Error(
|
|
15953
|
+
`host-providers.json[${host}][${seatProvider}] must be a non-empty string`
|
|
15954
|
+
);
|
|
15955
|
+
}
|
|
15956
|
+
providers[seatProvider] = hostProvider;
|
|
15957
|
+
}
|
|
15958
|
+
if (Object.keys(providers).length > 0) {
|
|
15959
|
+
out[host] = providers;
|
|
15960
|
+
}
|
|
15961
|
+
}
|
|
15962
|
+
return out;
|
|
15963
|
+
}
|
|
15964
|
+
function loadHostProvidersTable(home) {
|
|
15965
|
+
const path = hostProvidersPath(home);
|
|
15966
|
+
try {
|
|
15967
|
+
const raw = readFileSync(path, "utf8");
|
|
15968
|
+
return parseHostProvidersTable(JSON.parse(raw));
|
|
15969
|
+
} catch (error) {
|
|
15970
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
15971
|
+
return {};
|
|
15972
|
+
}
|
|
15973
|
+
throw error;
|
|
15974
|
+
}
|
|
15975
|
+
}
|
|
15976
|
+
function hostCatalogOffersModel(catalogModels, seatModel) {
|
|
15977
|
+
return catalogModels.some(
|
|
15978
|
+
(entry) => entry === seatModel || entry.endsWith(`/${seatModel}`)
|
|
15979
|
+
);
|
|
15980
|
+
}
|
|
15981
|
+
function listHermesProvidersForModel(home, seatModel) {
|
|
15982
|
+
const path = hermesProviderModelsCachePath(home);
|
|
15983
|
+
let text;
|
|
15984
|
+
try {
|
|
15985
|
+
text = readFileSync(path, "utf8");
|
|
15986
|
+
} catch (error) {
|
|
15987
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
15988
|
+
return [];
|
|
15989
|
+
}
|
|
15990
|
+
throw error;
|
|
15991
|
+
}
|
|
15992
|
+
const raw = JSON.parse(text);
|
|
15993
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
15994
|
+
throw new Error(
|
|
15995
|
+
`hermes provider_models_cache.json must be an object: ${path}`
|
|
15996
|
+
);
|
|
15997
|
+
}
|
|
15998
|
+
const found = [];
|
|
15999
|
+
for (const [provider, entry] of Object.entries(raw)) {
|
|
16000
|
+
if (entry === null || typeof entry !== "object" || Array.isArray(entry)) {
|
|
16001
|
+
continue;
|
|
16002
|
+
}
|
|
16003
|
+
const models = entry.models;
|
|
16004
|
+
if (!Array.isArray(models)) continue;
|
|
16005
|
+
const names = models.filter((m) => typeof m === "string");
|
|
16006
|
+
if (hostCatalogOffersModel(names, seatModel)) {
|
|
16007
|
+
found.push(provider);
|
|
16008
|
+
}
|
|
16009
|
+
}
|
|
16010
|
+
return found.sort();
|
|
16011
|
+
}
|
|
16012
|
+
function listDirectoryProvidersForModel(home, host, seatModel) {
|
|
16013
|
+
if (host === "hermes") {
|
|
16014
|
+
return listHermesProvidersForModel(home, seatModel);
|
|
16015
|
+
}
|
|
16016
|
+
return void 0;
|
|
16017
|
+
}
|
|
16018
|
+
function projectHostFacingProvider(selection, host, table, home) {
|
|
16019
|
+
if (selection === void 0) return void 0;
|
|
16020
|
+
const mapped = table[host]?.[selection.provider];
|
|
16021
|
+
if (mapped !== void 0) {
|
|
16022
|
+
return mapped === selection.provider ? selection : { ...selection, provider: mapped };
|
|
16023
|
+
}
|
|
16024
|
+
const directory = listDirectoryProvidersForModel(home, host, selection.model);
|
|
16025
|
+
if (directory === void 0) {
|
|
16026
|
+
return selection;
|
|
16027
|
+
}
|
|
16028
|
+
if (directory.length === 1) {
|
|
16029
|
+
const only = directory[0];
|
|
16030
|
+
return only === selection.provider ? selection : { ...selection, provider: only };
|
|
16031
|
+
}
|
|
16032
|
+
if (directory.length === 0) {
|
|
16033
|
+
throw new HostProviderResolutionError({
|
|
16034
|
+
message: `host ${host} has no provider offering model ${selection.model}; seat provider was ${selection.provider}`,
|
|
16035
|
+
host,
|
|
16036
|
+
seatProvider: selection.provider,
|
|
16037
|
+
seatModel: selection.model
|
|
16038
|
+
});
|
|
16039
|
+
}
|
|
16040
|
+
throw new HostProviderResolutionError({
|
|
16041
|
+
message: `host ${host} has multiple providers for model ${selection.model}: ${directory.join(", ")}; set host-providers.json[${host}][${selection.provider}] to one of them`,
|
|
16042
|
+
host,
|
|
16043
|
+
seatProvider: selection.provider,
|
|
16044
|
+
seatModel: selection.model,
|
|
16045
|
+
candidates: directory
|
|
16046
|
+
});
|
|
16047
|
+
}
|
|
16048
|
+
function renderHostProvidersTable(table) {
|
|
16049
|
+
const lines = [];
|
|
16050
|
+
for (const host of Object.keys(table).sort()) {
|
|
16051
|
+
const byProvider = table[host];
|
|
16052
|
+
for (const seatProvider of Object.keys(byProvider).sort()) {
|
|
16053
|
+
lines.push(
|
|
16054
|
+
`hostProvider ${host} ${seatProvider} ${byProvider[seatProvider]}`
|
|
16055
|
+
);
|
|
16056
|
+
}
|
|
16057
|
+
}
|
|
16058
|
+
return lines.length === 0 ? "" : `${lines.join("\n")}
|
|
16059
|
+
`;
|
|
16060
|
+
}
|
|
16061
|
+
var HostProviderResolutionError;
|
|
16062
|
+
var init_host_providers = __esm({
|
|
16063
|
+
"src/public-cli/host-providers.ts"() {
|
|
16064
|
+
"use strict";
|
|
16065
|
+
HostProviderResolutionError = class extends Error {
|
|
16066
|
+
host;
|
|
16067
|
+
seatProvider;
|
|
16068
|
+
seatModel;
|
|
16069
|
+
candidates;
|
|
16070
|
+
constructor(options) {
|
|
16071
|
+
super(options.message);
|
|
16072
|
+
this.name = "HostProviderResolutionError";
|
|
16073
|
+
this.host = options.host;
|
|
16074
|
+
this.seatProvider = options.seatProvider;
|
|
16075
|
+
this.seatModel = options.seatModel;
|
|
16076
|
+
this.candidates = options.candidates ?? [];
|
|
16077
|
+
}
|
|
16078
|
+
};
|
|
16079
|
+
}
|
|
16080
|
+
});
|
|
16081
|
+
|
|
16015
16082
|
// src/public-cli/cli-errors.ts
|
|
16016
16083
|
var CliUsageError;
|
|
16017
16084
|
var init_cli_errors = __esm({
|
|
@@ -16032,15 +16099,15 @@ var init_cli_errors = __esm({
|
|
|
16032
16099
|
|
|
16033
16100
|
// src/public-cli/load-production-acp-host.ts
|
|
16034
16101
|
import { existsSync as existsSync3 } from "node:fs";
|
|
16035
|
-
import { join as
|
|
16102
|
+
import { join as join7 } from "node:path";
|
|
16036
16103
|
import { pathToFileURL } from "node:url";
|
|
16037
16104
|
async function loadProductionAcpHostFactory(packageRoot2, host) {
|
|
16038
16105
|
const description = lookupHostDescription(host);
|
|
16039
16106
|
if (description === void 0) {
|
|
16040
16107
|
throw new Error(`unregistered host: ${host}`);
|
|
16041
16108
|
}
|
|
16042
|
-
const built =
|
|
16043
|
-
const source =
|
|
16109
|
+
const built = join7(packageRoot2, "dist/acp-host/production-host.js");
|
|
16110
|
+
const source = join7(packageRoot2, "src/acp-host/production-host.ts");
|
|
16044
16111
|
const target = existsSync3(built) ? built : source;
|
|
16045
16112
|
const href = pathToFileURL(target).href;
|
|
16046
16113
|
const mod = await import(href);
|
|
@@ -16122,11 +16189,11 @@ import { createHash as createHash2, randomUUID } from "node:crypto";
|
|
|
16122
16189
|
import {
|
|
16123
16190
|
appendFileSync,
|
|
16124
16191
|
existsSync as existsSync4,
|
|
16125
|
-
readFileSync,
|
|
16192
|
+
readFileSync as readFileSync2,
|
|
16126
16193
|
unlinkSync,
|
|
16127
16194
|
writeFileSync
|
|
16128
16195
|
} from "node:fs";
|
|
16129
|
-
import { basename as basename3, dirname as dirname5, join as
|
|
16196
|
+
import { basename as basename3, dirname as dirname5, join as join8, resolve as resolve3 } from "node:path";
|
|
16130
16197
|
function isRecord7(value) {
|
|
16131
16198
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16132
16199
|
}
|
|
@@ -16142,14 +16209,14 @@ function createExclusiveFile(path, contents) {
|
|
|
16142
16209
|
}
|
|
16143
16210
|
function sealTornTail(recordFile) {
|
|
16144
16211
|
if (!existsSync4(recordFile)) return;
|
|
16145
|
-
const buffer =
|
|
16212
|
+
const buffer = readFileSync2(recordFile);
|
|
16146
16213
|
if (buffer.length > 0 && buffer[buffer.length - 1] !== 10) {
|
|
16147
16214
|
appendFileSync(recordFile, "\n", "utf8");
|
|
16148
16215
|
}
|
|
16149
16216
|
}
|
|
16150
16217
|
function findIdentityPointer(recordFile, identity, kind, level) {
|
|
16151
16218
|
if (!existsSync4(recordFile)) return void 0;
|
|
16152
|
-
const text =
|
|
16219
|
+
const text = readFileSync2(recordFile, "utf8");
|
|
16153
16220
|
for (const line2 of text.split("\n")) {
|
|
16154
16221
|
const trimmed = line2.trim();
|
|
16155
16222
|
if (!trimmed) continue;
|
|
@@ -16265,7 +16332,7 @@ function resolveSitianRecordPathInLedger(input, ledgerHome) {
|
|
|
16265
16332
|
const category = resolveSitianVolumeCategory(input.kind);
|
|
16266
16333
|
let sessionDir;
|
|
16267
16334
|
if (input.sessionParent !== void 0 && input.sessionParent.length > 0 && physicallyContainedIn(ledgerHome, input.sessionParent)) {
|
|
16268
|
-
sessionDir =
|
|
16335
|
+
sessionDir = join8(dirname5(input.sessionParent), category);
|
|
16269
16336
|
} else {
|
|
16270
16337
|
const bookKey = safeBookKey(cwd);
|
|
16271
16338
|
const bookDir = activationBookDirectory(ledgerHome, bookKey);
|
|
@@ -16279,12 +16346,12 @@ function resolveSitianRecordPathInLedger(input, ledgerHome) {
|
|
|
16279
16346
|
subjectStr = JSON.stringify(input.subject);
|
|
16280
16347
|
}
|
|
16281
16348
|
const digest = createHash2("sha256").update(subjectStr).digest("hex").slice(0, 32);
|
|
16282
|
-
sessionDir =
|
|
16349
|
+
sessionDir = join8(bookDir, category, digest);
|
|
16283
16350
|
} else {
|
|
16284
|
-
sessionDir =
|
|
16351
|
+
sessionDir = join8(bookDir, category);
|
|
16285
16352
|
}
|
|
16286
16353
|
}
|
|
16287
|
-
const recordFile =
|
|
16354
|
+
const recordFile = join8(sessionDir, "records.jsonl");
|
|
16288
16355
|
return { sessionDir, recordFile, ledgerHome };
|
|
16289
16356
|
}
|
|
16290
16357
|
function resolveSitianRecordPath(input) {
|
|
@@ -16405,12 +16472,12 @@ var init_sitian_facade = __esm({
|
|
|
16405
16472
|
import { execFile, spawn } from "node:child_process";
|
|
16406
16473
|
import { constants } from "node:fs";
|
|
16407
16474
|
import { access, appendFile, readFile as readFile3, realpath } from "node:fs/promises";
|
|
16408
|
-
import { delimiter as delimiter2, isAbsolute as isAbsolute3, join as
|
|
16475
|
+
import { delimiter as delimiter2, isAbsolute as isAbsolute3, join as join9, resolve as resolve4 } from "node:path";
|
|
16409
16476
|
import { platform } from "node:process";
|
|
16410
16477
|
import { promisify } from "node:util";
|
|
16411
16478
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
16412
16479
|
function resolveInternalRoleEntrypoint(packageRoot2) {
|
|
16413
|
-
return
|
|
16480
|
+
return join9(packageRoot2, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
|
|
16414
16481
|
}
|
|
16415
16482
|
function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
|
|
16416
16483
|
return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
|
|
@@ -16755,7 +16822,7 @@ var init_role_turn_host = __esm({
|
|
|
16755
16822
|
|
|
16756
16823
|
// src/run-ticket-number.ts
|
|
16757
16824
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
16758
|
-
import { join as
|
|
16825
|
+
import { join as join10 } from "node:path";
|
|
16759
16826
|
function isEnoent(error) {
|
|
16760
16827
|
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
16761
16828
|
}
|
|
@@ -16768,7 +16835,7 @@ function ticketFromRecord(record4) {
|
|
|
16768
16835
|
}
|
|
16769
16836
|
async function readPageTicketNumber(runDirectory, page) {
|
|
16770
16837
|
try {
|
|
16771
|
-
const raw = JSON.parse(await readFile4(
|
|
16838
|
+
const raw = JSON.parse(await readFile4(join10(runDirectory, page), "utf8"));
|
|
16772
16839
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
16773
16840
|
return void 0;
|
|
16774
16841
|
}
|
|
@@ -17321,9 +17388,9 @@ var init_uuidv7 = __esm({
|
|
|
17321
17388
|
|
|
17322
17389
|
// src/typed-provider-http.ts
|
|
17323
17390
|
import { readFile as readFile7, unlink, writeFile as writeFile2 } from "node:fs/promises";
|
|
17324
|
-
import { join as
|
|
17391
|
+
import { join as join11 } from "node:path";
|
|
17325
17392
|
function typedProviderHttpPath(runDirectory) {
|
|
17326
|
-
return
|
|
17393
|
+
return join11(runDirectory, TYPED_HTTP_FILE);
|
|
17327
17394
|
}
|
|
17328
17395
|
async function clearTypedProviderHttpObservation(runDirectory) {
|
|
17329
17396
|
try {
|
|
@@ -17368,7 +17435,7 @@ var init_typed_provider_http = __esm({
|
|
|
17368
17435
|
|
|
17369
17436
|
// src/public-cli/run-lifecycle.ts
|
|
17370
17437
|
import { chmod, open, readdir as readdir2, readFile as readFile8, unlink as unlink2, writeFile as writeFile3 } from "node:fs/promises";
|
|
17371
|
-
import { isAbsolute as isAbsolute4, join as
|
|
17438
|
+
import { isAbsolute as isAbsolute4, join as join12 } from "node:path";
|
|
17372
17439
|
function resumeRereadInstruction(materialPath, handbook) {
|
|
17373
17440
|
return handbook ? `\u91CD\u65B0\u8BFB ${materialPath}\uFF0C\u518D\u7EC4\u88C5\u5916\u5305 argv` : `\u91CD\u65B0\u8BFB ${materialPath}`;
|
|
17374
17441
|
}
|
|
@@ -17416,7 +17483,7 @@ function renderResumeCommand(runId) {
|
|
|
17416
17483
|
async function writeRoleRunState(runDirectory, record4) {
|
|
17417
17484
|
const payload = { ...record4, runDirectory };
|
|
17418
17485
|
await writeFile3(
|
|
17419
|
-
|
|
17486
|
+
join12(runDirectory, RUN_STATE_FILE),
|
|
17420
17487
|
`${JSON.stringify(payload, null, 2)}
|
|
17421
17488
|
`,
|
|
17422
17489
|
"utf8"
|
|
@@ -17466,7 +17533,7 @@ function parseCurrentCourtState(raw) {
|
|
|
17466
17533
|
async function readRoleRunStateDisk(runDirectory) {
|
|
17467
17534
|
let raw;
|
|
17468
17535
|
try {
|
|
17469
|
-
raw = JSON.parse(await readFile8(
|
|
17536
|
+
raw = JSON.parse(await readFile8(join12(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
17470
17537
|
} catch {
|
|
17471
17538
|
return void 0;
|
|
17472
17539
|
}
|
|
@@ -17533,7 +17600,7 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
|
|
|
17533
17600
|
...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
|
|
17534
17601
|
};
|
|
17535
17602
|
await writeFile3(
|
|
17536
|
-
|
|
17603
|
+
join12(runDirectory, RUN_STATE_FILE),
|
|
17537
17604
|
`${JSON.stringify(payload, null, 2)}
|
|
17538
17605
|
`,
|
|
17539
17606
|
"utf8"
|
|
@@ -17777,15 +17844,15 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
17777
17844
|
};
|
|
17778
17845
|
const reportCleanupFailure = (error) => {
|
|
17779
17846
|
reportDiagnostic(
|
|
17780
|
-
`writer lease lock cleanup failed (release is best-effort; residual lock left in place) at ${
|
|
17847
|
+
`writer lease lock cleanup failed (release is best-effort; residual lock left in place) at ${join12(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
17781
17848
|
);
|
|
17782
17849
|
};
|
|
17783
17850
|
const reportReadFailure = (error) => {
|
|
17784
17851
|
reportDiagnostic(
|
|
17785
|
-
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${
|
|
17852
|
+
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join12(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
17786
17853
|
);
|
|
17787
17854
|
};
|
|
17788
|
-
const lockPath =
|
|
17855
|
+
const lockPath = join12(runDirectory, WRITER_LOCK_FILE);
|
|
17789
17856
|
let lastAutopsy = { verdict: "absent" };
|
|
17790
17857
|
let lastReclaimFailure;
|
|
17791
17858
|
for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
|
|
@@ -17835,7 +17902,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
17835
17902
|
async function findRunDirectoryById(home, runId) {
|
|
17836
17903
|
if (runId.trim() === "") return void 0;
|
|
17837
17904
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
17838
|
-
const booksRoot =
|
|
17905
|
+
const booksRoot = join12(ledgerHome, "books");
|
|
17839
17906
|
let bookKeys;
|
|
17840
17907
|
try {
|
|
17841
17908
|
bookKeys = await readdir2(booksRoot);
|
|
@@ -17843,7 +17910,7 @@ async function findRunDirectoryById(home, runId) {
|
|
|
17843
17910
|
return void 0;
|
|
17844
17911
|
}
|
|
17845
17912
|
for (const bookKey of bookKeys) {
|
|
17846
|
-
const runsDir =
|
|
17913
|
+
const runsDir = join12(activationBookDirectory(ledgerHome, bookKey), "runs");
|
|
17847
17914
|
let entries;
|
|
17848
17915
|
try {
|
|
17849
17916
|
entries = await readdir2(runsDir);
|
|
@@ -17852,7 +17919,7 @@ async function findRunDirectoryById(home, runId) {
|
|
|
17852
17919
|
}
|
|
17853
17920
|
for (const entry of entries) {
|
|
17854
17921
|
if (entry === `${runId}@judge` || entry.startsWith(`${runId}@`)) {
|
|
17855
|
-
return
|
|
17922
|
+
return join12(runsDir, entry);
|
|
17856
17923
|
}
|
|
17857
17924
|
}
|
|
17858
17925
|
}
|
|
@@ -17867,7 +17934,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
17867
17934
|
let raw;
|
|
17868
17935
|
try {
|
|
17869
17936
|
raw = JSON.parse(
|
|
17870
|
-
await readFile8(
|
|
17937
|
+
await readFile8(join12(runDirectory, "admitted-request.json"), "utf8")
|
|
17871
17938
|
);
|
|
17872
17939
|
} catch (error) {
|
|
17873
17940
|
if (errorCodeOf2(error) === "ENOENT") return void 0;
|
|
@@ -17887,7 +17954,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
17887
17954
|
}
|
|
17888
17955
|
async function findLatestRunIdForSeatTicket(input) {
|
|
17889
17956
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
17890
|
-
const runsDir =
|
|
17957
|
+
const runsDir = join12(
|
|
17891
17958
|
activationBookDirectory(ledgerHome, input.bookKey),
|
|
17892
17959
|
"runs"
|
|
17893
17960
|
);
|
|
@@ -17904,7 +17971,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
17904
17971
|
if (!entry.endsWith(suffix)) continue;
|
|
17905
17972
|
const runId = entry.slice(0, entry.length - suffix.length);
|
|
17906
17973
|
if (runId.length === 0) continue;
|
|
17907
|
-
const runDirectory =
|
|
17974
|
+
const runDirectory = join12(runsDir, entry);
|
|
17908
17975
|
if (input.parentRunPath !== void 0) {
|
|
17909
17976
|
const parentPath = await readRunParentPath(runDirectory);
|
|
17910
17977
|
if (parentPath !== input.parentRunPath) continue;
|
|
@@ -18089,7 +18156,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
18089
18156
|
let model;
|
|
18090
18157
|
try {
|
|
18091
18158
|
const invocationRaw = JSON.parse(
|
|
18092
|
-
await readFile8(
|
|
18159
|
+
await readFile8(join12(run.runDirectory, "invocation.json"), "utf8")
|
|
18093
18160
|
);
|
|
18094
18161
|
if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
|
|
18095
18162
|
const rec = invocationRaw;
|
|
@@ -18497,7 +18564,7 @@ __export(notary_source_run_exports, {
|
|
|
18497
18564
|
loadNotarySourceRunLocator: () => loadNotarySourceRunLocator,
|
|
18498
18565
|
resolveNotarySourceRunLocator: () => resolveNotarySourceRunLocator
|
|
18499
18566
|
});
|
|
18500
|
-
import { dirname as dirname7, isAbsolute as isAbsolute5, join as
|
|
18567
|
+
import { dirname as dirname7, isAbsolute as isAbsolute5, join as join13, resolve as resolve6, basename as basename4 } from "node:path";
|
|
18501
18568
|
import { lstat as lstat2, realpath as realpath3 } from "node:fs/promises";
|
|
18502
18569
|
function parseRunDirectoryName(name) {
|
|
18503
18570
|
const match = RUN_DIR_NAME.exec(name);
|
|
@@ -18543,11 +18610,11 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
18543
18610
|
}
|
|
18544
18611
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
18545
18612
|
const bookKey = resolveBookKeyFromGit(options.projectRoot);
|
|
18546
|
-
const bookRunsRoot =
|
|
18613
|
+
const bookRunsRoot = join13(activationBookDirectory(ledgerHome, bookKey), "runs");
|
|
18547
18614
|
let candidate;
|
|
18548
18615
|
const bare = parseRunDirectoryName(raw);
|
|
18549
18616
|
if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
|
|
18550
|
-
candidate =
|
|
18617
|
+
candidate = join13(bookRunsRoot, `${bare.runId}@${bare.role}`);
|
|
18551
18618
|
} else {
|
|
18552
18619
|
candidate = isAbsolute5(raw) ? raw : resolve6(options.projectRoot, raw);
|
|
18553
18620
|
}
|
|
@@ -19608,7 +19675,7 @@ var init_option_definitions = __esm({
|
|
|
19608
19675
|
},
|
|
19609
19676
|
config: {
|
|
19610
19677
|
command: "config",
|
|
19611
|
-
summary: "Persistent seat model, labor-engine, host, and auto-resume defaults.",
|
|
19678
|
+
summary: "Persistent seat model, labor-engine, host, and auto-resume defaults. Host providers live in ~/.ak-roles/host-providers.json (owner-edited).",
|
|
19612
19679
|
usage: [
|
|
19613
19680
|
"ak-role config set <seat> <provider/model[:thinking]> [<seat> <spec> ...]",
|
|
19614
19681
|
"ak-role config unset <gatekeeper|inspector|notary>",
|
|
@@ -19616,17 +19683,14 @@ var init_option_definitions = __esm({
|
|
|
19616
19683
|
"ak-role config unset-engine <seat>",
|
|
19617
19684
|
"ak-role config set-host <seat> <name>",
|
|
19618
19685
|
"ak-role config unset-host <seat>",
|
|
19619
|
-
"ak-role config set-auto-resume-limit <N>"
|
|
19620
|
-
"ak-role config set-provider-alias <provider> <host> <alias>",
|
|
19621
|
-
"ak-role config unset-provider-alias <provider> <host>"
|
|
19686
|
+
"ak-role config set-auto-resume-limit <N>"
|
|
19622
19687
|
],
|
|
19623
19688
|
examples: [
|
|
19624
19689
|
"ak-role config set judge openai-codex/gpt-5.6-sol:high",
|
|
19625
19690
|
"ak-role config unset gatekeeper",
|
|
19626
19691
|
"ak-role config set-engine judge opus",
|
|
19627
19692
|
"ak-role config set-host judge grok-build",
|
|
19628
|
-
"ak-role config set-auto-resume-limit 3"
|
|
19629
|
-
"ak-role config set-provider-alias xai hermes xai-oauth"
|
|
19693
|
+
"ak-role config set-auto-resume-limit 3"
|
|
19630
19694
|
]
|
|
19631
19695
|
},
|
|
19632
19696
|
help: {
|
|
@@ -19674,11 +19738,11 @@ import {
|
|
|
19674
19738
|
realpath as realpath4,
|
|
19675
19739
|
writeFile as writeFile4
|
|
19676
19740
|
} from "node:fs/promises";
|
|
19677
|
-
import { basename as basename5, isAbsolute as isAbsolute6, join as
|
|
19741
|
+
import { basename as basename5, isAbsolute as isAbsolute6, join as join14, resolve as resolve7, sep as sep3 } from "node:path";
|
|
19678
19742
|
function issueAdmissionPlacement(authority, request) {
|
|
19679
19743
|
const principal = authority.issue(request);
|
|
19680
19744
|
const { sessionDirectory, sessionFile } = authority.decode(principal);
|
|
19681
|
-
const runDirectory =
|
|
19745
|
+
const runDirectory = join14(sessionDirectory, "..");
|
|
19682
19746
|
const ledgerHome = resolveActivationLedgerHome(request.home);
|
|
19683
19747
|
const bookKey = resolveBookKeyFromGit(request.cwd);
|
|
19684
19748
|
return {
|
|
@@ -19726,14 +19790,14 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
|
|
|
19726
19790
|
...effectiveModelLedgerFields(effectiveModel)
|
|
19727
19791
|
};
|
|
19728
19792
|
await writeFile4(
|
|
19729
|
-
|
|
19793
|
+
join14(source.runDirectory, "invocation.json"),
|
|
19730
19794
|
`${JSON.stringify(identity, null, 2)}
|
|
19731
19795
|
`,
|
|
19732
19796
|
"utf8"
|
|
19733
19797
|
);
|
|
19734
19798
|
}
|
|
19735
19799
|
async function recordEffectiveInvocationModel(runDirectory, model, engine, host) {
|
|
19736
|
-
const ledgerPath =
|
|
19800
|
+
const ledgerPath = join14(runDirectory, "invocation.json");
|
|
19737
19801
|
const current = JSON.parse(await readFile9(ledgerPath, "utf8"));
|
|
19738
19802
|
const next = { ...current };
|
|
19739
19803
|
if (model !== void 0) {
|
|
@@ -19761,7 +19825,7 @@ async function recordEffectiveInvocationModel(runDirectory, model, engine, host)
|
|
|
19761
19825
|
);
|
|
19762
19826
|
}
|
|
19763
19827
|
async function mergeInvocationIdentityPage(runDirectory, fields) {
|
|
19764
|
-
const ledgerPath =
|
|
19828
|
+
const ledgerPath = join14(runDirectory, "invocation.json");
|
|
19765
19829
|
const current = JSON.parse(await readFile9(ledgerPath, "utf8"));
|
|
19766
19830
|
await writeFile4(
|
|
19767
19831
|
ledgerPath,
|
|
@@ -19822,7 +19886,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
19822
19886
|
async function observeLaunchedRolePackageIdentity(packageRoot2, selectedRoleEntry) {
|
|
19823
19887
|
const rolePackageRoot = packageRoot2;
|
|
19824
19888
|
const raw = JSON.parse(
|
|
19825
|
-
await readFile9(
|
|
19889
|
+
await readFile9(join14(rolePackageRoot, "package.json"), "utf8")
|
|
19826
19890
|
);
|
|
19827
19891
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
19828
19892
|
throw new Error(
|
|
@@ -20069,7 +20133,7 @@ async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
|
|
|
20069
20133
|
}
|
|
20070
20134
|
const bytes = await readFile9(absolute);
|
|
20071
20135
|
const name = `${String(index).padStart(2, "0")}-${basename5(absolute)}`;
|
|
20072
|
-
const frozenPath =
|
|
20136
|
+
const frozenPath = join14(destinationDir, name);
|
|
20073
20137
|
await writeFile4(frozenPath, bytes);
|
|
20074
20138
|
return {
|
|
20075
20139
|
attachment: {
|
|
@@ -20097,7 +20161,7 @@ async function freezeAttachments(attachmentPaths, attachmentsDirectory) {
|
|
|
20097
20161
|
async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
|
|
20098
20162
|
if (attachmentPaths.length === 0) return [];
|
|
20099
20163
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
20100
|
-
const attachmentsDirectory =
|
|
20164
|
+
const attachmentsDirectory = join14(runDirectory, "attachments", summonsKey);
|
|
20101
20165
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
20102
20166
|
return freezeAttachments(attachmentPaths, attachmentsDirectory);
|
|
20103
20167
|
}
|
|
@@ -20123,7 +20187,7 @@ async function admitStandardMaterialInvocation(role, options) {
|
|
|
20123
20187
|
role,
|
|
20124
20188
|
home: options.home
|
|
20125
20189
|
});
|
|
20126
|
-
const attachmentsDirectory =
|
|
20190
|
+
const attachmentsDirectory = join14(runDirectory, "attachments");
|
|
20127
20191
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
20128
20192
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
20129
20193
|
const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
|
|
@@ -20148,7 +20212,7 @@ async function admitStandardMaterialInvocation(role, options) {
|
|
|
20148
20212
|
mediaKind: a.mediaKind
|
|
20149
20213
|
}))
|
|
20150
20214
|
};
|
|
20151
|
-
const admittedRequestPath =
|
|
20215
|
+
const admittedRequestPath = join14(runDirectory, "admitted-request.json");
|
|
20152
20216
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
20153
20217
|
sessionDirectory,
|
|
20154
20218
|
sessionFile
|
|
@@ -20226,7 +20290,7 @@ async function admitCountersignInvocation(options) {
|
|
|
20226
20290
|
role: "countersign",
|
|
20227
20291
|
home: options.home
|
|
20228
20292
|
});
|
|
20229
|
-
const attachmentsDirectory =
|
|
20293
|
+
const attachmentsDirectory = join14(runDirectory, "attachments");
|
|
20230
20294
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
20231
20295
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
20232
20296
|
const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
|
|
@@ -20250,7 +20314,7 @@ async function admitCountersignInvocation(options) {
|
|
|
20250
20314
|
mediaKind: a.mediaKind
|
|
20251
20315
|
}))
|
|
20252
20316
|
};
|
|
20253
|
-
const admittedRequestPath =
|
|
20317
|
+
const admittedRequestPath = join14(runDirectory, "admitted-request.json");
|
|
20254
20318
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
20255
20319
|
sessionDirectory,
|
|
20256
20320
|
sessionFile
|
|
@@ -20274,7 +20338,7 @@ function buildCountersignTransportPrompt(admitted, engineMaterial) {
|
|
|
20274
20338
|
return buildInstructionTransportPrompt(admitted, engineMaterial);
|
|
20275
20339
|
}
|
|
20276
20340
|
async function ensureRunArtifactsDir(runDirectory) {
|
|
20277
|
-
const dir =
|
|
20341
|
+
const dir = join14(runDirectory, "artifacts");
|
|
20278
20342
|
await mkdir2(dir, { recursive: true });
|
|
20279
20343
|
return dir;
|
|
20280
20344
|
}
|
|
@@ -20306,11 +20370,11 @@ async function admitCoderInvocation(options) {
|
|
|
20306
20370
|
role: "coder",
|
|
20307
20371
|
home: options.home
|
|
20308
20372
|
});
|
|
20309
|
-
const attachmentsDirectory =
|
|
20373
|
+
const attachmentsDirectory = join14(runDirectory, "attachments");
|
|
20310
20374
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
20311
20375
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
20312
20376
|
const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
|
|
20313
|
-
const taskPath =
|
|
20377
|
+
const taskPath = join14(runDirectory, "task.md");
|
|
20314
20378
|
await writeFile4(taskPath, instruction, "utf8");
|
|
20315
20379
|
const admitted = {
|
|
20316
20380
|
role: "coder",
|
|
@@ -20331,7 +20395,7 @@ async function admitCoderInvocation(options) {
|
|
|
20331
20395
|
mediaKind: a.mediaKind
|
|
20332
20396
|
}))
|
|
20333
20397
|
};
|
|
20334
|
-
const admittedRequestPath =
|
|
20398
|
+
const admittedRequestPath = join14(runDirectory, "admitted-request.json");
|
|
20335
20399
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
20336
20400
|
sessionDirectory,
|
|
20337
20401
|
sessionFile
|
|
@@ -20412,13 +20476,13 @@ async function admitFixerInvocation(options) {
|
|
|
20412
20476
|
role: "fixer",
|
|
20413
20477
|
home: options.home
|
|
20414
20478
|
});
|
|
20415
|
-
const attachmentsDirectory =
|
|
20479
|
+
const attachmentsDirectory = join14(runDirectory, "attachments");
|
|
20416
20480
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
20417
20481
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
20418
20482
|
const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
|
|
20419
20483
|
let prerequisitesPath;
|
|
20420
20484
|
if (prerequisitesSource !== void 0) {
|
|
20421
|
-
prerequisitesPath =
|
|
20485
|
+
prerequisitesPath = join14(runDirectory, "prerequisites.json");
|
|
20422
20486
|
await writeFile4(
|
|
20423
20487
|
prerequisitesPath,
|
|
20424
20488
|
`${JSON.stringify(prerequisites, null, 2)}
|
|
@@ -20426,7 +20490,7 @@ async function admitFixerInvocation(options) {
|
|
|
20426
20490
|
"utf8"
|
|
20427
20491
|
);
|
|
20428
20492
|
}
|
|
20429
|
-
const packetPath =
|
|
20493
|
+
const packetPath = join14(runDirectory, "fix-packet.md");
|
|
20430
20494
|
await writeFile4(packetPath, instruction, "utf8");
|
|
20431
20495
|
const admitted = {
|
|
20432
20496
|
role: "fixer",
|
|
@@ -20452,7 +20516,7 @@ async function admitFixerInvocation(options) {
|
|
|
20452
20516
|
mediaKind: a.mediaKind
|
|
20453
20517
|
}))
|
|
20454
20518
|
};
|
|
20455
|
-
const admittedRequestPath =
|
|
20519
|
+
const admittedRequestPath = join14(runDirectory, "admitted-request.json");
|
|
20456
20520
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
20457
20521
|
sessionDirectory,
|
|
20458
20522
|
sessionFile
|
|
@@ -20661,13 +20725,13 @@ async function admitCollectorInvocation(options) {
|
|
|
20661
20725
|
role: "collector",
|
|
20662
20726
|
home: options.home
|
|
20663
20727
|
});
|
|
20664
|
-
const attachmentsDirectory =
|
|
20728
|
+
const attachmentsDirectory = join14(runDirectory, "attachments");
|
|
20665
20729
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
20666
20730
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
20667
20731
|
const attachments = await freezeAttachments(options.attachmentPaths ?? [], attachmentsDirectory);
|
|
20668
20732
|
let requestManifestPath;
|
|
20669
20733
|
if (manifestCanonicalJson !== void 0) {
|
|
20670
|
-
requestManifestPath =
|
|
20734
|
+
requestManifestPath = join14(runDirectory, "request-manifest.json");
|
|
20671
20735
|
await writeFile4(requestManifestPath, manifestCanonicalJson, "utf8");
|
|
20672
20736
|
}
|
|
20673
20737
|
const instruction = options.instruction ?? "";
|
|
@@ -20694,7 +20758,7 @@ async function admitCollectorInvocation(options) {
|
|
|
20694
20758
|
mediaKind: a.mediaKind
|
|
20695
20759
|
}))
|
|
20696
20760
|
};
|
|
20697
|
-
const admittedRequestPath =
|
|
20761
|
+
const admittedRequestPath = join14(runDirectory, "admitted-request.json");
|
|
20698
20762
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
20699
20763
|
sessionDirectory,
|
|
20700
20764
|
sessionFile
|
|
@@ -20791,7 +20855,7 @@ function parseDoctorArgv(args) {
|
|
|
20791
20855
|
}
|
|
20792
20856
|
async function resolveDoctorCaseRunsPath(options) {
|
|
20793
20857
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
20794
|
-
const defaultRuns =
|
|
20858
|
+
const defaultRuns = join14(
|
|
20795
20859
|
activationBookDirectory(ledgerHome, options.bookKey),
|
|
20796
20860
|
"issues",
|
|
20797
20861
|
String(options.issueNumber),
|
|
@@ -20898,7 +20962,7 @@ async function admitDoctorInvocation(options) {
|
|
|
20898
20962
|
{ cause: error }
|
|
20899
20963
|
);
|
|
20900
20964
|
}
|
|
20901
|
-
const attachmentsDirectory =
|
|
20965
|
+
const attachmentsDirectory = join14(runDirectory, "attachments");
|
|
20902
20966
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
20903
20967
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
20904
20968
|
const attachments = await freezeAttachments(options.attachmentPaths ?? [], attachmentsDirectory);
|
|
@@ -20924,7 +20988,7 @@ async function admitDoctorInvocation(options) {
|
|
|
20924
20988
|
mediaKind: a.mediaKind
|
|
20925
20989
|
}))
|
|
20926
20990
|
};
|
|
20927
|
-
const admittedRequestPath =
|
|
20991
|
+
const admittedRequestPath = join14(runDirectory, "admitted-request.json");
|
|
20928
20992
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
20929
20993
|
sessionDirectory,
|
|
20930
20994
|
sessionFile
|
|
@@ -21056,7 +21120,7 @@ async function admitNotaryInvocation(options) {
|
|
|
21056
21120
|
...ticketFields,
|
|
21057
21121
|
...options.correlationId === void 0 ? {} : { correlationId: options.correlationId }
|
|
21058
21122
|
};
|
|
21059
|
-
const admittedRequestPath =
|
|
21123
|
+
const admittedRequestPath = join14(runDirectory, "admitted-request.json");
|
|
21060
21124
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
21061
21125
|
sessionDirectory,
|
|
21062
21126
|
sessionFile
|
|
@@ -21158,7 +21222,7 @@ async function admitGleanerLeftInvocation(options) {
|
|
|
21158
21222
|
attachments: [],
|
|
21159
21223
|
...options.correlationId === void 0 ? {} : { correlationId: options.correlationId }
|
|
21160
21224
|
};
|
|
21161
|
-
const admittedRequestPath =
|
|
21225
|
+
const admittedRequestPath = join14(runDirectory, "admitted-request.json");
|
|
21162
21226
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
21163
21227
|
sessionDirectory,
|
|
21164
21228
|
sessionFile
|
|
@@ -21263,7 +21327,7 @@ async function admitReviewerInvocation(options) {
|
|
|
21263
21327
|
role: "reviewer",
|
|
21264
21328
|
home: options.home
|
|
21265
21329
|
});
|
|
21266
|
-
const attachmentsDirectory =
|
|
21330
|
+
const attachmentsDirectory = join14(runDirectory, "attachments");
|
|
21267
21331
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
21268
21332
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
21269
21333
|
const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
|
|
@@ -21288,7 +21352,7 @@ async function admitReviewerInvocation(options) {
|
|
|
21288
21352
|
mediaKind: a.mediaKind
|
|
21289
21353
|
}))
|
|
21290
21354
|
};
|
|
21291
|
-
const admittedRequestPath =
|
|
21355
|
+
const admittedRequestPath = join14(runDirectory, "admitted-request.json");
|
|
21292
21356
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
21293
21357
|
sessionDirectory,
|
|
21294
21358
|
sessionFile
|
|
@@ -21415,7 +21479,7 @@ async function admitMergerInvocation(options) {
|
|
|
21415
21479
|
role: "merger",
|
|
21416
21480
|
home: options.home
|
|
21417
21481
|
});
|
|
21418
|
-
const attachmentsDirectory =
|
|
21482
|
+
const attachmentsDirectory = join14(runDirectory, "attachments");
|
|
21419
21483
|
ensureRealDirectoryTree(ledgerHome, sessionDirectory);
|
|
21420
21484
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
21421
21485
|
const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
|
|
@@ -21443,7 +21507,7 @@ async function admitMergerInvocation(options) {
|
|
|
21443
21507
|
// Authorized checks remain available on the assignment; default none.
|
|
21444
21508
|
authorizedChecks: []
|
|
21445
21509
|
});
|
|
21446
|
-
const mergerInputPath =
|
|
21510
|
+
const mergerInputPath = join14(runDirectory, "merger-input.json");
|
|
21447
21511
|
await writeFile4(
|
|
21448
21512
|
mergerInputPath,
|
|
21449
21513
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
@@ -21475,7 +21539,7 @@ async function admitMergerInvocation(options) {
|
|
|
21475
21539
|
mediaKind: a.mediaKind
|
|
21476
21540
|
}))
|
|
21477
21541
|
};
|
|
21478
|
-
const admittedRequestPath =
|
|
21542
|
+
const admittedRequestPath = join14(runDirectory, "admitted-request.json");
|
|
21479
21543
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
21480
21544
|
sessionDirectory,
|
|
21481
21545
|
sessionFile
|
|
@@ -21766,7 +21830,7 @@ var init_invocation = __esm({
|
|
|
21766
21830
|
// src/package-resources/method-skill.ts
|
|
21767
21831
|
import { createHash as createHash4 } from "node:crypto";
|
|
21768
21832
|
import { readFile as readFile10, realpath as realpath5 } from "node:fs/promises";
|
|
21769
|
-
import { join as
|
|
21833
|
+
import { join as join15 } from "node:path";
|
|
21770
21834
|
function gitBlobOid(bytes) {
|
|
21771
21835
|
const body = typeof bytes === "string" ? Buffer.from(bytes, "utf8") : Buffer.from(bytes);
|
|
21772
21836
|
const header = Buffer.from(`blob ${body.byteLength}\0`, "utf8");
|
|
@@ -21783,10 +21847,10 @@ function packagedMethodSkillRelativeDirectory(name) {
|
|
|
21783
21847
|
return `${METHOD_SKILL_RELATIVE_ROOT}/${name}`;
|
|
21784
21848
|
}
|
|
21785
21849
|
function resolvePackagedMethodSkillRoot(packageRoot2, name) {
|
|
21786
|
-
return
|
|
21850
|
+
return join15(packageRoot2, packagedMethodSkillRelativeDirectory(name));
|
|
21787
21851
|
}
|
|
21788
21852
|
function resolvePackagedMethodSkillPath(packageRoot2, name) {
|
|
21789
|
-
return
|
|
21853
|
+
return join15(resolvePackagedMethodSkillRoot(packageRoot2, name), "SKILL.md");
|
|
21790
21854
|
}
|
|
21791
21855
|
function isRecord9(value) {
|
|
21792
21856
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -21880,8 +21944,8 @@ function parseProvenance(raw, expectedName) {
|
|
|
21880
21944
|
}
|
|
21881
21945
|
async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
|
|
21882
21946
|
const rootDirectory = resolvePackagedMethodSkillRoot(packageRoot2, name);
|
|
21883
|
-
const skillPathConfigured =
|
|
21884
|
-
const provenancePath =
|
|
21947
|
+
const skillPathConfigured = join15(rootDirectory, "SKILL.md");
|
|
21948
|
+
const provenancePath = join15(rootDirectory, "provenance.json");
|
|
21885
21949
|
let provenanceRaw;
|
|
21886
21950
|
try {
|
|
21887
21951
|
provenanceRaw = await readFile10(provenancePath, "utf8");
|
|
@@ -21898,7 +21962,7 @@ async function loadPackagedMethodSkillMaterial(packageRoot2, name) {
|
|
|
21898
21962
|
}
|
|
21899
21963
|
const provenance = parseProvenance(provenanceJson, name);
|
|
21900
21964
|
for (const [rel, expected] of Object.entries(provenance.files)) {
|
|
21901
|
-
const absolute =
|
|
21965
|
+
const absolute = join15(rootDirectory, rel);
|
|
21902
21966
|
let bytes;
|
|
21903
21967
|
try {
|
|
21904
21968
|
bytes = await readFile10(absolute);
|
|
@@ -22200,7 +22264,7 @@ var init_ledger_session_read = __esm({
|
|
|
22200
22264
|
|
|
22201
22265
|
// src/analyst-gate-cycles-read.ts
|
|
22202
22266
|
import { readdir as readdir3 } from "node:fs/promises";
|
|
22203
|
-
import { join as
|
|
22267
|
+
import { join as join16 } from "node:path";
|
|
22204
22268
|
function isRecord11(value) {
|
|
22205
22269
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22206
22270
|
}
|
|
@@ -22462,7 +22526,7 @@ async function readAnalystGateCyclesFromAuditorRoles(auditorRolesDirectory, opti
|
|
|
22462
22526
|
throw error;
|
|
22463
22527
|
}
|
|
22464
22528
|
for (const name of names) {
|
|
22465
|
-
const path =
|
|
22529
|
+
const path = join16(directory, name);
|
|
22466
22530
|
const fromPointer = name.endsWith(".pointer.json");
|
|
22467
22531
|
const sessionPath = fromPointer ? await resolveOfficerSessionFromPointerFile(path) : path;
|
|
22468
22532
|
if (sessionPath === void 0) continue;
|
|
@@ -22505,7 +22569,7 @@ var init_analyst_gate_cycles_read = __esm({
|
|
|
22505
22569
|
|
|
22506
22570
|
// src/run-terminal-artifacts.ts
|
|
22507
22571
|
import { readdir as readdir4, readFile as readFile12 } from "node:fs/promises";
|
|
22508
|
-
import { basename as basename6, dirname as dirname8, join as
|
|
22572
|
+
import { basename as basename6, dirname as dirname8, join as join17 } from "node:path";
|
|
22509
22573
|
function isMissingPathError2(error) {
|
|
22510
22574
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
22511
22575
|
}
|
|
@@ -22580,7 +22644,7 @@ async function listUniqueErrorFallbackPaths(directories) {
|
|
|
22580
22644
|
}
|
|
22581
22645
|
for (const name of names.sort((a, b) => a.localeCompare(b))) {
|
|
22582
22646
|
if (!UNIQUE_ERROR_FALLBACK_NAME.test(name)) continue;
|
|
22583
|
-
found.push(
|
|
22647
|
+
found.push(join17(dir, name));
|
|
22584
22648
|
}
|
|
22585
22649
|
}
|
|
22586
22650
|
return found;
|
|
@@ -22596,14 +22660,14 @@ function presentUniqueFallbackBoundToRun(body, expectedRunId) {
|
|
|
22596
22660
|
return typeof body.runId === "string" && body.runId === expectedRunId;
|
|
22597
22661
|
}
|
|
22598
22662
|
async function readRunTerminalArtifact(runDirectory) {
|
|
22599
|
-
const artifactsDir =
|
|
22663
|
+
const artifactsDir = join17(runDirectory, "artifacts");
|
|
22600
22664
|
for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
|
|
22601
|
-
const path =
|
|
22665
|
+
const path = join17(artifactsDir, file);
|
|
22602
22666
|
const read3 = await readTerminalArtifactAtPath(path, file);
|
|
22603
22667
|
if (read3 !== void 0) return read3;
|
|
22604
22668
|
}
|
|
22605
22669
|
for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
|
|
22606
|
-
const path =
|
|
22670
|
+
const path = join17(runDirectory, relative3);
|
|
22607
22671
|
const read3 = await readTerminalArtifactAtPath(path, "error.json");
|
|
22608
22672
|
if (read3 !== void 0) return read3;
|
|
22609
22673
|
}
|
|
@@ -22743,12 +22807,12 @@ var init_submission_ledger = __esm({
|
|
|
22743
22807
|
// src/session-opening-materials.ts
|
|
22744
22808
|
import { existsSync as existsSync6 } from "node:fs";
|
|
22745
22809
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
22746
|
-
import { dirname as dirname9, join as
|
|
22810
|
+
import { dirname as dirname9, join as join18 } from "node:path";
|
|
22747
22811
|
import { fileURLToPath, pathToFileURL as pathToFileURL2 } from "node:url";
|
|
22748
22812
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
22749
22813
|
let dir = dirname9(fileURLToPath(moduleUrl));
|
|
22750
22814
|
for (let i = 0; i < 8; i += 1) {
|
|
22751
|
-
if (existsSync6(
|
|
22815
|
+
if (existsSync6(join18(dir, "package.json")) && existsSync6(join18(dir, "souls"))) {
|
|
22752
22816
|
return dir;
|
|
22753
22817
|
}
|
|
22754
22818
|
const parent = dirname9(dir);
|
|
@@ -23028,12 +23092,12 @@ var init_reviewer_dispatch = __esm({
|
|
|
23028
23092
|
|
|
23029
23093
|
// src/public-cli/reviewer-dispatch-rejection.ts
|
|
23030
23094
|
import { readFile as readFile14, unlink as unlink3 } from "node:fs/promises";
|
|
23031
|
-
import { join as
|
|
23095
|
+
import { join as join19 } from "node:path";
|
|
23032
23096
|
function isReviewerPreflightViolation(value) {
|
|
23033
23097
|
return typeof value === "string" && REVIEWER_PREFLIGHT_VIOLATIONS.includes(value);
|
|
23034
23098
|
}
|
|
23035
23099
|
function reviewerDispatchRejectionPath(runDirectory) {
|
|
23036
|
-
return
|
|
23100
|
+
return join19(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
|
|
23037
23101
|
}
|
|
23038
23102
|
async function clearReviewerDispatchRejection(runDirectory) {
|
|
23039
23103
|
try {
|
|
@@ -23449,7 +23513,7 @@ var init_terminal = __esm({
|
|
|
23449
23513
|
// src/public-cli/settlement.ts
|
|
23450
23514
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
23451
23515
|
import { appendFile as appendFile2, readFile as readFile15, readdir as readdir5, writeFile as writeFile5 } from "node:fs/promises";
|
|
23452
|
-
import { dirname as dirname10, join as
|
|
23516
|
+
import { dirname as dirname10, join as join20 } from "node:path";
|
|
23453
23517
|
function sealedLedgerHome(admitted) {
|
|
23454
23518
|
return homeFromRunDirectory(admitted.runDirectory);
|
|
23455
23519
|
}
|
|
@@ -23850,7 +23914,7 @@ async function readSessionProviderStop(sessionFile) {
|
|
|
23850
23914
|
}
|
|
23851
23915
|
}
|
|
23852
23916
|
async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
23853
|
-
const childDirectory =
|
|
23917
|
+
const childDirectory = join20(dirname10(sessionFile), "evidence-children");
|
|
23854
23918
|
let names;
|
|
23855
23919
|
try {
|
|
23856
23920
|
names = await readdir5(childDirectory);
|
|
@@ -23861,7 +23925,7 @@ async function readBoundEvidenceChildKnownFailure(sessionFile) {
|
|
|
23861
23925
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
23862
23926
|
let entries;
|
|
23863
23927
|
try {
|
|
23864
|
-
entries = await readBoundSessionEntries(
|
|
23928
|
+
entries = await readBoundSessionEntries(join20(childDirectory, file));
|
|
23865
23929
|
} catch (error) {
|
|
23866
23930
|
throw sessionReadFailure(error, "failed to read discovered evidence-child session");
|
|
23867
23931
|
}
|
|
@@ -23915,7 +23979,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
23915
23979
|
latestParentUserIndex = i;
|
|
23916
23980
|
break;
|
|
23917
23981
|
}
|
|
23918
|
-
const childDirectories = [
|
|
23982
|
+
const childDirectories = [join20(dirname10(sessionFile), "auditor-roles")];
|
|
23919
23983
|
const valid = [];
|
|
23920
23984
|
let sawAnyDirectory = false;
|
|
23921
23985
|
for (const childDirectory of childDirectories) {
|
|
@@ -23930,7 +23994,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
23930
23994
|
for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
|
|
23931
23995
|
let entries;
|
|
23932
23996
|
try {
|
|
23933
|
-
entries = await readBoundSessionEntries(
|
|
23997
|
+
entries = await readBoundSessionEntries(join20(childDirectory, file));
|
|
23934
23998
|
} catch (error) {
|
|
23935
23999
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
23936
24000
|
}
|
|
@@ -24462,8 +24526,8 @@ function projectTerminalGateFact(rounds) {
|
|
|
24462
24526
|
};
|
|
24463
24527
|
}
|
|
24464
24528
|
async function extractGateFactFromSessionDirectory(sessionDirectory, options = {}) {
|
|
24465
|
-
const directories = [
|
|
24466
|
-
const parentSessionFile = options.parentSessionFile ??
|
|
24529
|
+
const directories = [join20(sessionDirectory, "auditor-roles")];
|
|
24530
|
+
const parentSessionFile = options.parentSessionFile ?? join20(sessionDirectory, "session.jsonl");
|
|
24467
24531
|
const rounds = await readAnalystGateCyclesFromAuditorRoles(directories, {
|
|
24468
24532
|
parentSessionFile
|
|
24469
24533
|
});
|
|
@@ -24561,8 +24625,8 @@ async function extractNavigatorFactFromAdmittedSession(sessionFile) {
|
|
|
24561
24625
|
async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
|
|
24562
24626
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
24563
24627
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
24564
|
-
const reportPath =
|
|
24565
|
-
const evidencePath =
|
|
24628
|
+
const reportPath = join20(artifactsDir, "report.json");
|
|
24629
|
+
const evidencePath = join20(artifactsDir, "evidence.json");
|
|
24566
24630
|
await writeFile5(
|
|
24567
24631
|
reportPath,
|
|
24568
24632
|
`${JSON.stringify(
|
|
@@ -24606,8 +24670,8 @@ async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
|
|
|
24606
24670
|
async function publishCoderArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
24607
24671
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
24608
24672
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
24609
|
-
const reportPath =
|
|
24610
|
-
const evidencePath =
|
|
24673
|
+
const reportPath = join20(artifactsDir, "report.json");
|
|
24674
|
+
const evidencePath = join20(artifactsDir, "evidence.json");
|
|
24611
24675
|
await writeFile5(
|
|
24612
24676
|
reportPath,
|
|
24613
24677
|
`${JSON.stringify(
|
|
@@ -24758,8 +24822,8 @@ function extractFixerMethodInvocations(entries, options) {
|
|
|
24758
24822
|
async function publishFixerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
24759
24823
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
24760
24824
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
24761
|
-
const reportPath =
|
|
24762
|
-
const evidencePath =
|
|
24825
|
+
const reportPath = join20(artifactsDir, "report.json");
|
|
24826
|
+
const evidencePath = join20(artifactsDir, "evidence.json");
|
|
24763
24827
|
await writeFile5(
|
|
24764
24828
|
reportPath,
|
|
24765
24829
|
`${JSON.stringify(
|
|
@@ -24849,8 +24913,8 @@ async function settleLawfulFixerTerminalResult(admitted, authority, options) {
|
|
|
24849
24913
|
async function publishCollectorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
24850
24914
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
24851
24915
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
24852
|
-
const reportPath =
|
|
24853
|
-
const evidencePath =
|
|
24916
|
+
const reportPath = join20(artifactsDir, "report.json");
|
|
24917
|
+
const evidencePath = join20(artifactsDir, "evidence.json");
|
|
24854
24918
|
await writeFile5(
|
|
24855
24919
|
reportPath,
|
|
24856
24920
|
`${JSON.stringify(
|
|
@@ -24957,8 +25021,8 @@ async function trySettleCollectorTerminalResult(admitted, authority) {
|
|
|
24957
25021
|
async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
|
|
24958
25022
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
24959
25023
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
24960
|
-
const reportPath =
|
|
24961
|
-
const evidencePath =
|
|
25024
|
+
const reportPath = join20(artifactsDir, "report.json");
|
|
25025
|
+
const evidencePath = join20(artifactsDir, "evidence.json");
|
|
24962
25026
|
await writeFile5(
|
|
24963
25027
|
reportPath,
|
|
24964
25028
|
`${JSON.stringify(
|
|
@@ -25218,8 +25282,8 @@ function extractReviewerMethodInvocations(entries, options) {
|
|
|
25218
25282
|
async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
25219
25283
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
25220
25284
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
25221
|
-
const reportPath =
|
|
25222
|
-
const evidencePath =
|
|
25285
|
+
const reportPath = join20(artifactsDir, "report.json");
|
|
25286
|
+
const evidencePath = join20(artifactsDir, "evidence.json");
|
|
25223
25287
|
await writeFile5(
|
|
25224
25288
|
reportPath,
|
|
25225
25289
|
`${JSON.stringify(
|
|
@@ -25333,8 +25397,8 @@ function extractMergerMethodInvocations(entries, options) {
|
|
|
25333
25397
|
async function publishMergerArtifacts(admitted, roleOutcome, coordinates, options) {
|
|
25334
25398
|
await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
|
|
25335
25399
|
const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
|
|
25336
|
-
const reportPath =
|
|
25337
|
-
const evidencePath =
|
|
25400
|
+
const reportPath = join20(artifactsDir, "report.json");
|
|
25401
|
+
const evidencePath = join20(artifactsDir, "evidence.json");
|
|
25338
25402
|
await writeFile5(
|
|
25339
25403
|
reportPath,
|
|
25340
25404
|
`${JSON.stringify(
|
|
@@ -25479,7 +25543,7 @@ function uniqueFailureFallbackDirs(runDirectory, baseDir) {
|
|
|
25479
25543
|
return dirs;
|
|
25480
25544
|
}
|
|
25481
25545
|
async function resolveFailureArtifactsBase(runDirectory) {
|
|
25482
|
-
const artifactsDir =
|
|
25546
|
+
const artifactsDir = join20(runDirectory, "artifacts");
|
|
25483
25547
|
try {
|
|
25484
25548
|
await ensureRunArtifactsDir(runDirectory);
|
|
25485
25549
|
return { baseDir: artifactsDir };
|
|
@@ -25495,7 +25559,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
|
|
|
25495
25559
|
const candidates = [
|
|
25496
25560
|
...preferredCandidates,
|
|
25497
25561
|
// One unique name per fallback dir — collisions on fixed names cannot exhaust this.
|
|
25498
|
-
...uniqueFallbackDirs.map((dir) =>
|
|
25562
|
+
...uniqueFallbackDirs.map((dir) => join20(dir, `${stem}.${randomUUID3()}.json`))
|
|
25499
25563
|
];
|
|
25500
25564
|
for (let i = 0; i < candidates.length; i += 1) {
|
|
25501
25565
|
const path = candidates[i];
|
|
@@ -25540,26 +25604,26 @@ async function publishFailureArtifacts(admitted, failure, authority) {
|
|
|
25540
25604
|
} catch (error) {
|
|
25541
25605
|
priorIssues.push(publicationAttemptFromError(sessionFile, error));
|
|
25542
25606
|
}
|
|
25543
|
-
const underArtifacts = baseDir ===
|
|
25607
|
+
const underArtifacts = baseDir === join20(admitted.runDirectory, "artifacts");
|
|
25544
25608
|
const uniqueFallbackDirs = uniqueFailureFallbackDirs(
|
|
25545
25609
|
admitted.runDirectory,
|
|
25546
25610
|
baseDir
|
|
25547
25611
|
);
|
|
25548
25612
|
const errorCandidates = underArtifacts ? [
|
|
25549
|
-
|
|
25550
|
-
|
|
25551
|
-
|
|
25613
|
+
join20(baseDir, "error.json"),
|
|
25614
|
+
join20(baseDir, "error.settlement.json"),
|
|
25615
|
+
join20(admitted.runDirectory, "error.settlement.json")
|
|
25552
25616
|
] : [
|
|
25553
|
-
|
|
25554
|
-
|
|
25617
|
+
join20(baseDir, "error.settlement.json"),
|
|
25618
|
+
join20(baseDir, "error.json")
|
|
25555
25619
|
];
|
|
25556
25620
|
const evidenceCandidates = underArtifacts ? [
|
|
25557
|
-
|
|
25558
|
-
|
|
25559
|
-
|
|
25621
|
+
join20(baseDir, "evidence.json"),
|
|
25622
|
+
join20(baseDir, "evidence.settlement.json"),
|
|
25623
|
+
join20(admitted.runDirectory, "evidence.settlement.json")
|
|
25560
25624
|
] : [
|
|
25561
|
-
|
|
25562
|
-
|
|
25625
|
+
join20(baseDir, "evidence.settlement.json"),
|
|
25626
|
+
join20(baseDir, "evidence.json")
|
|
25563
25627
|
];
|
|
25564
25628
|
const errorPayloadBase = {
|
|
25565
25629
|
kind: "error",
|
|
@@ -25842,7 +25906,7 @@ var init_ticket_provenance_contracts = __esm({
|
|
|
25842
25906
|
});
|
|
25843
25907
|
|
|
25844
25908
|
// src/ticket-provenance.ts
|
|
25845
|
-
import { join as
|
|
25909
|
+
import { join as join21 } from "node:path";
|
|
25846
25910
|
function ticketProvenanceSubject(ticketNumber) {
|
|
25847
25911
|
if (!Number.isSafeInteger(ticketNumber) || ticketNumber < 1) {
|
|
25848
25912
|
throw new Error(`ticket-provenance subject requires a positive ticket number, got ${String(ticketNumber)}`);
|
|
@@ -25860,7 +25924,7 @@ function resolveTicketProvenanceVolume(ticketNumber, cwd, home) {
|
|
|
25860
25924
|
return {
|
|
25861
25925
|
recordFile: path.recordFile,
|
|
25862
25926
|
volumeDir: path.sessionDir,
|
|
25863
|
-
humanViewFile:
|
|
25927
|
+
humanViewFile: join21(path.sessionDir, TICKET_PROVENANCE_HUMAN_VIEW)
|
|
25864
25928
|
};
|
|
25865
25929
|
}
|
|
25866
25930
|
var init_ticket_provenance = __esm({
|
|
@@ -25910,7 +25974,7 @@ var init_case_dossier_delivery = __esm({
|
|
|
25910
25974
|
|
|
25911
25975
|
// src/host-transition-prior-native.ts
|
|
25912
25976
|
import { access as access2, readdir as readdir6 } from "node:fs/promises";
|
|
25913
|
-
import { dirname as dirname11, join as
|
|
25977
|
+
import { dirname as dirname11, join as join22 } from "node:path";
|
|
25914
25978
|
function isEnoent2(error) {
|
|
25915
25979
|
return typeof error === "object" && error !== null && error.code === "ENOENT";
|
|
25916
25980
|
}
|
|
@@ -25935,7 +25999,7 @@ async function listSitianRecordPaths(sessionParent) {
|
|
|
25935
25999
|
const recordPaths = [];
|
|
25936
26000
|
for (const entry of entries) {
|
|
25937
26001
|
if (!entry.isDirectory()) continue;
|
|
25938
|
-
const recordFile =
|
|
26002
|
+
const recordFile = join22(sessionRoot, entry.name, "records.jsonl");
|
|
25939
26003
|
try {
|
|
25940
26004
|
await access2(recordFile);
|
|
25941
26005
|
recordPaths.push(recordFile);
|
|
@@ -26005,7 +26069,7 @@ var init_public_run_credentials = __esm({
|
|
|
26005
26069
|
import { constants as fsConstants } from "node:fs";
|
|
26006
26070
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
26007
26071
|
import { lstat as lstat5, mkdir as mkdir4, open as open2 } from "node:fs/promises";
|
|
26008
|
-
import { join as
|
|
26072
|
+
import { join as join23 } from "node:path";
|
|
26009
26073
|
function presentTerminal(terminal, io) {
|
|
26010
26074
|
if (terminal.roleOutcome.kind === "failure" || terminal.roleOutcome.kind === "no_receipt") {
|
|
26011
26075
|
presentFailureTerminal(terminal, io);
|
|
@@ -26024,7 +26088,7 @@ async function finalizeExceptionRunBestEffort(runDirectory, io) {
|
|
|
26024
26088
|
}
|
|
26025
26089
|
}
|
|
26026
26090
|
function runArtifactsDirectory(runDirectory) {
|
|
26027
|
-
return
|
|
26091
|
+
return join23(runDirectory, "artifacts");
|
|
26028
26092
|
}
|
|
26029
26093
|
async function ensureRealArtifactsDirectory(runDirectory) {
|
|
26030
26094
|
const runStat = await lstat5(runDirectory);
|
|
@@ -26107,7 +26171,7 @@ function jsonSafeReplacer() {
|
|
|
26107
26171
|
}
|
|
26108
26172
|
async function retainDispatchError(admitted, principalAuthority, sessionAppender, attempt, error) {
|
|
26109
26173
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
26110
|
-
const filePath =
|
|
26174
|
+
const filePath = join23(
|
|
26111
26175
|
artifactsDir,
|
|
26112
26176
|
`dispatch-error-attempt-${attempt}-${randomUUID4()}.json`
|
|
26113
26177
|
);
|
|
@@ -26356,7 +26420,7 @@ var init_auto_resume = __esm({
|
|
|
26356
26420
|
// src/public-cli/post-admission.ts
|
|
26357
26421
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
26358
26422
|
import { readFile as readFile16, writeFile as writeFile6 } from "node:fs/promises";
|
|
26359
|
-
import { isAbsolute as isAbsolute7, join as
|
|
26423
|
+
import { isAbsolute as isAbsolute7, join as join24, resolve as resolve8 } from "node:path";
|
|
26360
26424
|
function appendContinuationSection(continuation, section) {
|
|
26361
26425
|
const prompt = `${continuation.prompt}
|
|
26362
26426
|
|
|
@@ -26365,7 +26429,7 @@ ${section}`;
|
|
|
26365
26429
|
}
|
|
26366
26430
|
async function readInvocationHost(runDirectory) {
|
|
26367
26431
|
try {
|
|
26368
|
-
const raw = JSON.parse(await readFile16(
|
|
26432
|
+
const raw = JSON.parse(await readFile16(join24(runDirectory, "invocation.json"), "utf8"));
|
|
26369
26433
|
return typeof raw.host === "string" && raw.host.trim() !== "" ? raw.host : void 0;
|
|
26370
26434
|
} catch (error) {
|
|
26371
26435
|
if (error.code === "ENOENT") return void 0;
|
|
@@ -26519,7 +26583,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
26519
26583
|
}
|
|
26520
26584
|
try {
|
|
26521
26585
|
await writeFile6(
|
|
26522
|
-
|
|
26586
|
+
join24(admitted.runDirectory, "stderr.log"),
|
|
26523
26587
|
result2.stderr,
|
|
26524
26588
|
"utf8"
|
|
26525
26589
|
);
|
|
@@ -26628,7 +26692,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
26628
26692
|
}
|
|
26629
26693
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
26630
26694
|
const absolute = isAbsolute7(attachmentPath) ? attachmentPath : resolve8(attachmentPath);
|
|
26631
|
-
return pathContainedIn(
|
|
26695
|
+
return pathContainedIn(join24(runDirectory, "attachments"), absolute);
|
|
26632
26696
|
}
|
|
26633
26697
|
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
26634
26698
|
if (summons === void 0) return void 0;
|
|
@@ -28796,7 +28860,7 @@ var init_judge_run = __esm({
|
|
|
28796
28860
|
|
|
28797
28861
|
// src/public-cli/merger-run.ts
|
|
28798
28862
|
import { mkdir as mkdir5, writeFile as writeFile7 } from "node:fs/promises";
|
|
28799
|
-
import { join as
|
|
28863
|
+
import { join as join25, resolve as resolve9 } from "node:path";
|
|
28800
28864
|
function mergerMethods(packageRoot2) {
|
|
28801
28865
|
return [
|
|
28802
28866
|
{
|
|
@@ -28862,8 +28926,8 @@ async function admitMergerShellForActivationFailure(options) {
|
|
|
28862
28926
|
expectedConflictPaths: [],
|
|
28863
28927
|
resolutionScope: []
|
|
28864
28928
|
};
|
|
28865
|
-
const admittedRequestPath =
|
|
28866
|
-
const mergerInputPath =
|
|
28929
|
+
const admittedRequestPath = join25(runDirectory, "admitted-request.json");
|
|
28930
|
+
const mergerInputPath = join25(runDirectory, "merger-input.json");
|
|
28867
28931
|
await writeFile7(
|
|
28868
28932
|
admittedRequestPath,
|
|
28869
28933
|
`${JSON.stringify(
|
|
@@ -29303,10 +29367,10 @@ var init_analyst_book_key = __esm({
|
|
|
29303
29367
|
// src/atomic-write.ts
|
|
29304
29368
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
29305
29369
|
import { rename, rm, writeFile as writeFile8 } from "node:fs/promises";
|
|
29306
|
-
import { dirname as dirname12, join as
|
|
29370
|
+
import { dirname as dirname12, join as join26 } from "node:path";
|
|
29307
29371
|
async function writeFileAtomically(destination, contents) {
|
|
29308
29372
|
const parent = dirname12(destination);
|
|
29309
|
-
const temporary =
|
|
29373
|
+
const temporary = join26(parent, `.atomic-write-${randomUUID6()}.tmp`);
|
|
29310
29374
|
try {
|
|
29311
29375
|
await writeFile8(temporary, contents);
|
|
29312
29376
|
await rename(temporary, destination);
|
|
@@ -29323,7 +29387,7 @@ var init_atomic_write = __esm({
|
|
|
29323
29387
|
|
|
29324
29388
|
// src/analyst-index.ts
|
|
29325
29389
|
import { open as open3, readFile as readFile17, unlink as unlink4 } from "node:fs/promises";
|
|
29326
|
-
import { dirname as dirname13, join as
|
|
29390
|
+
import { dirname as dirname13, join as join27 } from "node:path";
|
|
29327
29391
|
function sleep(ms) {
|
|
29328
29392
|
return new Promise((resolve11) => {
|
|
29329
29393
|
setTimeout(resolve11, ms);
|
|
@@ -29332,7 +29396,7 @@ function sleep(ms) {
|
|
|
29332
29396
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
29333
29397
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
29334
29398
|
ensureRealDirectoryTree(ledgerHome, dirname13(indexPath));
|
|
29335
|
-
const lockPath =
|
|
29399
|
+
const lockPath = join27(dirname13(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
29336
29400
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
29337
29401
|
const startedAt = Date.now();
|
|
29338
29402
|
while (true) {
|
|
@@ -29359,7 +29423,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
29359
29423
|
}
|
|
29360
29424
|
}
|
|
29361
29425
|
function analystLibraryIndexPath(ledgerHome) {
|
|
29362
|
-
return
|
|
29426
|
+
return join27(ledgerHome, "analyst", "library-index.json");
|
|
29363
29427
|
}
|
|
29364
29428
|
function rowFromIssueMetricsPage(page) {
|
|
29365
29429
|
return {
|
|
@@ -29655,7 +29719,7 @@ var init_analyst_cohort = __esm({
|
|
|
29655
29719
|
|
|
29656
29720
|
// src/analyst-ledger.ts
|
|
29657
29721
|
import { readdir as readdir7, readFile as readFile18 } from "node:fs/promises";
|
|
29658
|
-
import { join as
|
|
29722
|
+
import { join as join28 } from "node:path";
|
|
29659
29723
|
function isMissingPathError5(error) {
|
|
29660
29724
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
29661
29725
|
}
|
|
@@ -29668,7 +29732,7 @@ function isRecord15(value) {
|
|
|
29668
29732
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
29669
29733
|
try {
|
|
29670
29734
|
const raw = JSON.parse(
|
|
29671
|
-
await readFile18(
|
|
29735
|
+
await readFile18(join28(runDirectory, "run-state.json"), "utf8")
|
|
29672
29736
|
);
|
|
29673
29737
|
if (!isRecord15(raw) || typeof raw.state !== "string") return void 0;
|
|
29674
29738
|
return raw.state;
|
|
@@ -29700,7 +29764,7 @@ async function listLedgerBookNames(booksRoot) {
|
|
|
29700
29764
|
async function readInvocationScopeFields(runDirectory) {
|
|
29701
29765
|
let raw;
|
|
29702
29766
|
try {
|
|
29703
|
-
raw = await readFile18(
|
|
29767
|
+
raw = await readFile18(join28(runDirectory, "invocation.json"), "utf8");
|
|
29704
29768
|
} catch (error) {
|
|
29705
29769
|
if (isMissingPathError5(error)) return void 0;
|
|
29706
29770
|
throw error;
|
|
@@ -29732,7 +29796,7 @@ function decideIssueScope(input) {
|
|
|
29732
29796
|
}
|
|
29733
29797
|
async function resolveSessionFile(runDirectory) {
|
|
29734
29798
|
try {
|
|
29735
|
-
const raw = await readFile18(
|
|
29799
|
+
const raw = await readFile18(join28(runDirectory, "invocation.json"), "utf8");
|
|
29736
29800
|
const parsed = JSON.parse(raw);
|
|
29737
29801
|
if (isRecord15(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
29738
29802
|
return parsed.sessionFile;
|
|
@@ -29740,7 +29804,7 @@ async function resolveSessionFile(runDirectory) {
|
|
|
29740
29804
|
} catch (error) {
|
|
29741
29805
|
if (!isMissingPathError5(error)) throw error;
|
|
29742
29806
|
}
|
|
29743
|
-
return
|
|
29807
|
+
return join28(runDirectory, "session", "session.jsonl");
|
|
29744
29808
|
}
|
|
29745
29809
|
function attributeSessionRowsForRun(input) {
|
|
29746
29810
|
if (pathContainedIn(input.runDirectory, input.sessionFile)) {
|
|
@@ -29912,9 +29976,9 @@ async function classifyScopedRun(input) {
|
|
|
29912
29976
|
}
|
|
29913
29977
|
let gateCycles;
|
|
29914
29978
|
try {
|
|
29915
|
-
const parentSessionFile =
|
|
29979
|
+
const parentSessionFile = join28(input.runDirectory, "session", "session.jsonl");
|
|
29916
29980
|
gateCycles = await readAnalystGateCyclesFromAuditorRoles(
|
|
29917
|
-
|
|
29981
|
+
join28(input.runDirectory, "session", "auditor-roles"),
|
|
29918
29982
|
{ parentSessionFile }
|
|
29919
29983
|
);
|
|
29920
29984
|
} catch (error) {
|
|
@@ -29947,7 +30011,7 @@ async function classifyScopedRun(input) {
|
|
|
29947
30011
|
async function scanAnalystIssueRuns(input) {
|
|
29948
30012
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
29949
30013
|
const scopeTicketNumber = input.ticketNumber;
|
|
29950
|
-
const booksRoot =
|
|
30014
|
+
const booksRoot = join28(ledgerHome, "books");
|
|
29951
30015
|
let wholeBook = false;
|
|
29952
30016
|
let scopeRootIdentity;
|
|
29953
30017
|
let bookNames;
|
|
@@ -29979,7 +30043,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
29979
30043
|
const unreadable = [];
|
|
29980
30044
|
const scopeConflicts = [];
|
|
29981
30045
|
for (const book of bookNames) {
|
|
29982
|
-
const runsDir =
|
|
30046
|
+
const runsDir = join28(booksRoot, book, "runs");
|
|
29983
30047
|
let runNames;
|
|
29984
30048
|
try {
|
|
29985
30049
|
const entries = await readdir7(runsDir, { withFileTypes: true });
|
|
@@ -29991,7 +30055,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
29991
30055
|
for (const runName of runNames) {
|
|
29992
30056
|
const parsed = parseRunDirectoryName2(runName);
|
|
29993
30057
|
if (parsed === void 0) continue;
|
|
29994
|
-
const runDirectory =
|
|
30058
|
+
const runDirectory = join28(runsDir, runName);
|
|
29995
30059
|
let scopeFields;
|
|
29996
30060
|
try {
|
|
29997
30061
|
scopeFields = await readInvocationScopeFields(runDirectory);
|
|
@@ -30845,7 +30909,7 @@ var init_analyst_metric_family = __esm({
|
|
|
30845
30909
|
|
|
30846
30910
|
// src/analyst-page.ts
|
|
30847
30911
|
import { createHash as createHash5 } from "node:crypto";
|
|
30848
|
-
import { dirname as dirname14, join as
|
|
30912
|
+
import { dirname as dirname14, join as join29 } from "node:path";
|
|
30849
30913
|
function analystIssuePageKey(address) {
|
|
30850
30914
|
const parts = ["book", address.bookKey];
|
|
30851
30915
|
if (address.issueNumber !== void 0) {
|
|
@@ -30856,7 +30920,7 @@ function analystIssuePageKey(address) {
|
|
|
30856
30920
|
return createHash5("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
30857
30921
|
}
|
|
30858
30922
|
function analystIssuePagePath(ledgerHome, address) {
|
|
30859
|
-
return
|
|
30923
|
+
return join29(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
30860
30924
|
}
|
|
30861
30925
|
function analystIssuePageAddressFromPage(page) {
|
|
30862
30926
|
return {
|
|
@@ -31389,7 +31453,7 @@ __export(cli_exports, {
|
|
|
31389
31453
|
runAkRole: () => runAkRole
|
|
31390
31454
|
});
|
|
31391
31455
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
31392
|
-
import { join as
|
|
31456
|
+
import { join as join30 } from "node:path";
|
|
31393
31457
|
function takePublicGlobalFlag(argv, index, options) {
|
|
31394
31458
|
const tokens = argv.slice(index);
|
|
31395
31459
|
const taken = options.takeDashed(tokens);
|
|
@@ -31475,23 +31539,30 @@ function createRoleEnvironment(env, options) {
|
|
|
31475
31539
|
const role = options.role;
|
|
31476
31540
|
const extraPiArgs = role === "coder" ? env.coderExtraPiArgs : role === "fixer" ? env.fixerExtraPiArgs : role === "reviewer" ? env.reviewerExtraPiArgs : role === "merger" ? env.mergerExtraPiArgs : role === "judge" ? env.judgeExtraPiArgs : role === "collector" ? env.collectorExtraPiArgs : role === "doctor" ? env.doctorExtraPiArgs : role === "notary" ? env.notaryExtraPiArgs : void 0;
|
|
31477
31541
|
const timeoutMs = role === "coder" ? env.coderTimeoutMs : role === "fixer" ? env.fixerTimeoutMs : role === "reviewer" ? env.reviewerTimeoutMs : role === "merger" ? env.mergerTimeoutMs : role === "judge" ? env.judgeTimeoutMs : role === "collector" ? env.collectorTimeoutMs : role === "doctor" ? env.doctorTimeoutMs : role === "notary" ? env.notaryTimeoutMs : void 0;
|
|
31542
|
+
const roleTurnHost = resolveRoleTurnHost(env, {
|
|
31543
|
+
role,
|
|
31544
|
+
seat: options.seat,
|
|
31545
|
+
principalAuthority: env.principalAuthority,
|
|
31546
|
+
...extraPiArgs === void 0 ? {} : { extraPiArgs },
|
|
31547
|
+
...timeoutMs === void 0 ? {} : { timeoutMs }
|
|
31548
|
+
});
|
|
31549
|
+
const hostFacingSelection = options.seat.selection === void 0 ? void 0 : projectHostFacingProvider(
|
|
31550
|
+
options.seat.selection,
|
|
31551
|
+
options.seat.host,
|
|
31552
|
+
loadHostProvidersTable(options.home),
|
|
31553
|
+
options.home
|
|
31554
|
+
);
|
|
31478
31555
|
return {
|
|
31479
31556
|
home: options.home,
|
|
31480
31557
|
principalAuthority: env.principalAuthority,
|
|
31481
31558
|
agentDir: options.agentDir,
|
|
31482
31559
|
sessionAppender: appendPiSessionCustomEntry,
|
|
31483
31560
|
packageRoot: env.packageRoot,
|
|
31484
|
-
roleTurnHost
|
|
31485
|
-
role,
|
|
31486
|
-
seat: options.seat,
|
|
31487
|
-
principalAuthority: env.principalAuthority,
|
|
31488
|
-
...extraPiArgs === void 0 ? {} : { extraPiArgs },
|
|
31489
|
-
...timeoutMs === void 0 ? {} : { timeoutMs }
|
|
31490
|
-
}),
|
|
31561
|
+
roleTurnHost,
|
|
31491
31562
|
cwd: options.cwd,
|
|
31492
31563
|
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
31493
31564
|
...env.correlationId === void 0 ? {} : { correlationId: env.correlationId },
|
|
31494
|
-
...
|
|
31565
|
+
...hostFacingSelection === void 0 ? {} : { model: hostFacingSelection },
|
|
31495
31566
|
...projectSeatEngine(options.seat),
|
|
31496
31567
|
...projectSeatHost(options.seat),
|
|
31497
31568
|
...timeoutMs === void 0 ? {} : { timeoutMs },
|
|
@@ -31521,7 +31592,7 @@ function resolveHome(env) {
|
|
|
31521
31592
|
return env.home ?? packageMachineHome();
|
|
31522
31593
|
}
|
|
31523
31594
|
function resolveAgentDir(env, home) {
|
|
31524
|
-
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
31595
|
+
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join30(home, ".pi", "agent");
|
|
31525
31596
|
}
|
|
31526
31597
|
function parseThinking(value) {
|
|
31527
31598
|
return value;
|
|
@@ -31726,7 +31797,7 @@ function renderHelp() {
|
|
|
31726
31797
|
"Persistent config: ak-role config set <seat> <provider/model[:thinking]> | unset <gatekeeper|inspector|notary>",
|
|
31727
31798
|
"Persistent engine (callable roles): ak-role config set-engine <seat> <name> | unset-engine <seat>",
|
|
31728
31799
|
"Persistent host (callable roles): ak-role config set-host <seat> <name> | unset-host <seat>",
|
|
31729
|
-
"
|
|
31800
|
+
"Host providers: ~/.ak-roles/host-providers.json (owner-edited; table > unique host directory > fail)",
|
|
31730
31801
|
"Host resolution: --host \u2192 persistent seat host \u2192 pi (resume uses the same order; #617)",
|
|
31731
31802
|
"Effective seats: ak-role roles"
|
|
31732
31803
|
);
|
|
@@ -31815,7 +31886,7 @@ function renderConfigDisplaySeat(row) {
|
|
|
31815
31886
|
const host = row.host === void 0 ? "-" : row.host;
|
|
31816
31887
|
return `${row.seat} ${row.source} ${model} ${engine} ${host}`;
|
|
31817
31888
|
}
|
|
31818
|
-
function renderConfig(config) {
|
|
31889
|
+
function renderConfig(config, home) {
|
|
31819
31890
|
const lines = ["seat source model engine host"];
|
|
31820
31891
|
const rows = projectConfigDisplaySeats(config);
|
|
31821
31892
|
if (rows.length === 0) {
|
|
@@ -31826,17 +31897,9 @@ function renderConfig(config) {
|
|
|
31826
31897
|
}
|
|
31827
31898
|
}
|
|
31828
31899
|
lines.push(`autoResumeLimit ${config.autoResumeLimit ?? AUTO_RESUME_LIMIT}`);
|
|
31829
|
-
const
|
|
31830
|
-
if (aliases !== void 0) {
|
|
31831
|
-
for (const provider of Object.keys(aliases).sort()) {
|
|
31832
|
-
const byHost = aliases[provider];
|
|
31833
|
-
for (const host of Object.keys(byHost).sort()) {
|
|
31834
|
-
lines.push(`providerAlias ${provider} ${host} ${byHost[host]}`);
|
|
31835
|
-
}
|
|
31836
|
-
}
|
|
31837
|
-
}
|
|
31900
|
+
const hostProvidersBlock = renderHostProvidersTable(loadHostProvidersTable(home));
|
|
31838
31901
|
return `${lines.join("\n")}
|
|
31839
|
-
`;
|
|
31902
|
+
${hostProvidersBlock}`;
|
|
31840
31903
|
}
|
|
31841
31904
|
async function runConfigCommand(args, home, packageRoot2, io) {
|
|
31842
31905
|
if (args.length === 0 || args[0] === "get" || args[0] === "list" || args[0] === "show") {
|
|
@@ -31851,7 +31914,7 @@ async function runConfigCommand(args, home, packageRoot2, io) {
|
|
|
31851
31914
|
);
|
|
31852
31915
|
return 0;
|
|
31853
31916
|
}
|
|
31854
|
-
io.stdout(renderConfig(config));
|
|
31917
|
+
io.stdout(renderConfig(config, home));
|
|
31855
31918
|
return 0;
|
|
31856
31919
|
}
|
|
31857
31920
|
if (args[0] === "set") {
|
|
@@ -31876,7 +31939,7 @@ async function runConfigCommand(args, home, packageRoot2, io) {
|
|
|
31876
31939
|
config = setPersistentSeatConfig(config, seat, parseModelSpec(spec));
|
|
31877
31940
|
}
|
|
31878
31941
|
await savePublicCliConfig(config, home);
|
|
31879
|
-
io.stdout(renderConfig(config));
|
|
31942
|
+
io.stdout(renderConfig(config, home));
|
|
31880
31943
|
return 0;
|
|
31881
31944
|
}
|
|
31882
31945
|
if (args[0] === "unset") {
|
|
@@ -31896,7 +31959,7 @@ async function runConfigCommand(args, home, packageRoot2, io) {
|
|
|
31896
31959
|
seat
|
|
31897
31960
|
);
|
|
31898
31961
|
await savePublicCliConfig(config, home);
|
|
31899
|
-
io.stdout(renderConfig(config));
|
|
31962
|
+
io.stdout(renderConfig(config, home));
|
|
31900
31963
|
return 0;
|
|
31901
31964
|
}
|
|
31902
31965
|
if (args[0] === "set-host" || args[0] === "unset-host") {
|
|
@@ -31913,7 +31976,7 @@ async function runConfigCommand(args, home, packageRoot2, io) {
|
|
|
31913
31976
|
throw new CliUsageError(error instanceof Error ? error.message : String(error), { cause: error });
|
|
31914
31977
|
}
|
|
31915
31978
|
await savePublicCliConfig(config, home);
|
|
31916
|
-
io.stdout(renderConfig(config));
|
|
31979
|
+
io.stdout(renderConfig(config, home));
|
|
31917
31980
|
return 0;
|
|
31918
31981
|
}
|
|
31919
31982
|
if (args[0] === "set-engine") {
|
|
@@ -31936,7 +31999,7 @@ async function runConfigCommand(args, home, packageRoot2, io) {
|
|
|
31936
31999
|
);
|
|
31937
32000
|
}
|
|
31938
32001
|
await savePublicCliConfig(config, home);
|
|
31939
|
-
io.stdout(renderConfig(config));
|
|
32002
|
+
io.stdout(renderConfig(config, home));
|
|
31940
32003
|
return 0;
|
|
31941
32004
|
}
|
|
31942
32005
|
if (args[0] === "unset-engine") {
|
|
@@ -31957,7 +32020,7 @@ async function runConfigCommand(args, home, packageRoot2, io) {
|
|
|
31957
32020
|
);
|
|
31958
32021
|
}
|
|
31959
32022
|
await savePublicCliConfig(config, home);
|
|
31960
|
-
io.stdout(renderConfig(config));
|
|
32023
|
+
io.stdout(renderConfig(config, home));
|
|
31961
32024
|
return 0;
|
|
31962
32025
|
}
|
|
31963
32026
|
if (args[0] === "set-auto-resume-limit") {
|
|
@@ -31981,45 +32044,7 @@ async function runConfigCommand(args, home, packageRoot2, io) {
|
|
|
31981
32044
|
let config = await loadAndValidateConfig(home, packageRoot2);
|
|
31982
32045
|
config = setAutoResumeLimit(config, converted);
|
|
31983
32046
|
await savePublicCliConfig(config, home);
|
|
31984
|
-
io.stdout(renderConfig(config));
|
|
31985
|
-
return 0;
|
|
31986
|
-
}
|
|
31987
|
-
if (args[0] === "set-provider-alias") {
|
|
31988
|
-
if (args.length !== 4) {
|
|
31989
|
-
throw new CliUsageError(
|
|
31990
|
-
"usage: ak-role config set-provider-alias <provider> <host> <alias>"
|
|
31991
|
-
);
|
|
31992
|
-
}
|
|
31993
|
-
let config = await loadAndValidateConfig(home, packageRoot2);
|
|
31994
|
-
try {
|
|
31995
|
-
config = setProviderHostAlias(config, args[1], args[2], args[3]);
|
|
31996
|
-
} catch (error) {
|
|
31997
|
-
throw new CliUsageError(
|
|
31998
|
-
error instanceof Error ? error.message : String(error),
|
|
31999
|
-
{ cause: error }
|
|
32000
|
-
);
|
|
32001
|
-
}
|
|
32002
|
-
await savePublicCliConfig(config, home);
|
|
32003
|
-
io.stdout(renderConfig(config));
|
|
32004
|
-
return 0;
|
|
32005
|
-
}
|
|
32006
|
-
if (args[0] === "unset-provider-alias") {
|
|
32007
|
-
if (args.length !== 3) {
|
|
32008
|
-
throw new CliUsageError(
|
|
32009
|
-
"usage: ak-role config unset-provider-alias <provider> <host>"
|
|
32010
|
-
);
|
|
32011
|
-
}
|
|
32012
|
-
let config = await loadAndValidateConfig(home, packageRoot2);
|
|
32013
|
-
try {
|
|
32014
|
-
config = unsetProviderHostAlias(config, args[1], args[2]);
|
|
32015
|
-
} catch (error) {
|
|
32016
|
-
throw new CliUsageError(
|
|
32017
|
-
error instanceof Error ? error.message : String(error),
|
|
32018
|
-
{ cause: error }
|
|
32019
|
-
);
|
|
32020
|
-
}
|
|
32021
|
-
await savePublicCliConfig(config, home);
|
|
32022
|
-
io.stdout(renderConfig(config));
|
|
32047
|
+
io.stdout(renderConfig(config, home));
|
|
32023
32048
|
return 0;
|
|
32024
32049
|
}
|
|
32025
32050
|
throw new CliUsageError(`unknown config subcommand: ${args[0]}`);
|
|
@@ -32450,6 +32475,7 @@ var init_cli = __esm({
|
|
|
32450
32475
|
init_engine_material();
|
|
32451
32476
|
init_institutional_resolution();
|
|
32452
32477
|
init_config2();
|
|
32478
|
+
init_host_providers();
|
|
32453
32479
|
init_registry2();
|
|
32454
32480
|
init_cli_errors();
|
|
32455
32481
|
init_host_descriptions();
|
|
@@ -32525,7 +32551,7 @@ var init_cli = __esm({
|
|
|
32525
32551
|
|
|
32526
32552
|
// src/public-cli/main.ts
|
|
32527
32553
|
import { existsSync as existsSync7 } from "node:fs";
|
|
32528
|
-
import { dirname as dirname15, join as
|
|
32554
|
+
import { dirname as dirname15, join as join31 } from "node:path";
|
|
32529
32555
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
32530
32556
|
|
|
32531
32557
|
// src/public-cli/host-pi-runtime.ts
|
|
@@ -32614,8 +32640,8 @@ function linkPackage(packageRoot2, name, targetDir) {
|
|
|
32614
32640
|
// src/public-cli/main.ts
|
|
32615
32641
|
var here = dirname15(fileURLToPath2(import.meta.url));
|
|
32616
32642
|
function resolvePackageRoot(binDir) {
|
|
32617
|
-
const canonical =
|
|
32618
|
-
if (existsSync7(
|
|
32643
|
+
const canonical = join31(binDir, "..", "..");
|
|
32644
|
+
if (existsSync7(join31(canonical, "package.json"))) {
|
|
32619
32645
|
return canonical;
|
|
32620
32646
|
}
|
|
32621
32647
|
return binDir;
|