@akagilnc/pi-workflow-roles 0.1.4444 → 0.1.4503
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 +2 -0
- package/README.zh-CN.md +2 -0
- package/dist/acp-host/description.js +2 -3
- package/dist/acp-host/production-host.js +512 -288
- package/dist/auditor-soul.js +8 -1
- package/dist/headless-host/description.js +3 -3
- package/dist/headless-host/production-host.js +519 -257
- package/dist/host-descriptions.js +3 -18
- package/dist/method-host-plugin/.claude-plugin/plugin.json +5 -0
- package/dist/method-host-plugin/skills/ak-cross-m-review/CONTEXT.md +48 -0
- package/dist/method-host-plugin/skills/ak-cross-m-review/LICENSE +21 -0
- package/dist/method-host-plugin/skills/ak-cross-m-review/SKILL.md +170 -0
- package/dist/method-host-plugin/skills/ak-cross-m-review/prompts/cmr-completeness.md +118 -0
- package/dist/method-host-plugin/skills/ak-cross-m-review/prompts/cmr-reviewer.md +128 -0
- package/dist/method-host-plugin/skills/ak-cross-m-review/provenance.json +41 -0
- package/dist/method-host-plugin/skills/diagnosing-bugs/SKILL.md +134 -0
- package/dist/method-host-plugin/skills/diagnosing-bugs/agents/openai.yaml +3 -0
- package/dist/method-host-plugin/skills/diagnosing-bugs/provenance.json +31 -0
- package/dist/method-host-plugin/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +41 -0
- package/dist/method-host-plugin/skills/resolving-merge-conflicts/SKILL.md +14 -0
- package/dist/method-host-plugin/skills/resolving-merge-conflicts/agents/openai.yaml +3 -0
- package/dist/method-host-plugin/skills/resolving-merge-conflicts/provenance.json +26 -0
- package/dist/method-host-plugin/skills/tdd/SKILL.md +38 -0
- package/dist/method-host-plugin/skills/tdd/agents/openai.yaml +3 -0
- package/dist/method-host-plugin/skills/tdd/mocking.md +59 -0
- package/dist/method-host-plugin/skills/tdd/provenance.json +36 -0
- package/dist/method-host-plugin/skills/tdd/tests.md +77 -0
- package/dist/public-cli/countersign-run.js +214 -155
- package/dist/public-cli/diarist-run.js +4 -1
- package/dist/public-cli/invocation.js +129 -21
- package/dist/public-cli/main.js +386 -202
- package/dist/session-opening-materials.js +17 -5
- package/extensions/role-runtime.ts +16 -6
- package/package.json +1 -1
- package/resources/method-host-plugin/.claude-plugin/plugin.json +5 -0
- package/scripts/build-package.mjs +6 -1
- package/src/acp-host/description.ts +2 -4
- package/src/acp-host/production-host.ts +0 -1
- package/src/auditor-soul.ts +10 -1
- package/src/headless-host/description.ts +4 -3
- package/src/headless-host/role-turn-host.ts +27 -4
- package/src/host-descriptions.ts +3 -23
- package/src/host-native-method.ts +67 -0
- package/src/public-cli/countersign-run.ts +326 -218
- package/src/public-cli/diarist-run.ts +4 -0
- package/src/public-cli/invocation.ts +205 -23
- package/src/role-envelope.ts +17 -47
- package/src/role-runtime-dependencies.ts +17 -2
- package/src/role-runtime.ts +12 -7
- package/src/session-opening-materials.ts +27 -11
|
@@ -1559,10 +1559,10 @@ __export(session_assistant_usage_exports, {
|
|
|
1559
1559
|
});
|
|
1560
1560
|
import { join as join5 } from "node:path";
|
|
1561
1561
|
async function readAssistantUsageFromSessionFile(sessionFile) {
|
|
1562
|
-
const { readFile:
|
|
1562
|
+
const { readFile: readFile23 } = await import("node:fs/promises");
|
|
1563
1563
|
let text;
|
|
1564
1564
|
try {
|
|
1565
|
-
text = await
|
|
1565
|
+
text = await readFile23(sessionFile, "utf8");
|
|
1566
1566
|
} catch (error) {
|
|
1567
1567
|
if (error?.code === "ENOENT") return void 0;
|
|
1568
1568
|
throw error;
|
|
@@ -3801,13 +3801,10 @@ function assertRegisteredHostName(host) {
|
|
|
3801
3801
|
}
|
|
3802
3802
|
throw new Error(`unregistered host: ${host}`);
|
|
3803
3803
|
}
|
|
3804
|
-
var
|
|
3804
|
+
var DEFAULT_ROLE_TURN_HOST, HOST_DESCRIPTIONS, HEADLESS_HOST_DESCRIPTIONS;
|
|
3805
3805
|
var init_host_descriptions = __esm({
|
|
3806
3806
|
"src/host-descriptions.ts"() {
|
|
3807
3807
|
"use strict";
|
|
3808
|
-
PRIVATE_COMPAT_ENV = Object.fromEntries(
|
|
3809
|
-
["CLAUDE", "CURSOR", "CODEX"].flatMap((vendor) => ["SKILLS", "RULES", "AGENTS", "MCPS", "HOOKS", "SESSIONS"].map((kind) => [`GROK_${vendor}_${kind}_ENABLED`, "false"]))
|
|
3810
|
-
);
|
|
3811
3808
|
DEFAULT_ROLE_TURN_HOST = "pi";
|
|
3812
3809
|
HOST_DESCRIPTIONS = Object.freeze({
|
|
3813
3810
|
/** Operator home `~/.grok`, native session/load resume, `agent [--model X] stdio`. */
|
|
@@ -3820,12 +3817,7 @@ var init_host_descriptions = __esm({
|
|
|
3820
3817
|
}),
|
|
3821
3818
|
modelPassing: "argv",
|
|
3822
3819
|
boundResume: "session/load",
|
|
3823
|
-
sessionBindingFile: "grok-acp-session.json"
|
|
3824
|
-
childEnv: Object.freeze({
|
|
3825
|
-
...PRIVATE_COMPAT_ENV,
|
|
3826
|
-
GROK_MEMORY: "0",
|
|
3827
|
-
GROK_SUBAGENTS: "0"
|
|
3828
|
-
})
|
|
3820
|
+
sessionBindingFile: "grok-acp-session.json"
|
|
3829
3821
|
}),
|
|
3830
3822
|
/**
|
|
3831
3823
|
* Operator home `~/.hermes`, native session/load resume, `acp` subcommand.
|
|
@@ -3844,7 +3836,6 @@ var init_host_descriptions = __esm({
|
|
|
3844
3836
|
modelPassing: "set_model",
|
|
3845
3837
|
boundResume: "session/load",
|
|
3846
3838
|
sessionBindingFile: "hermes-acp-session.json",
|
|
3847
|
-
childEnv: Object.freeze({}),
|
|
3848
3839
|
seatProfileSoul: Object.freeze({
|
|
3849
3840
|
flag: "-p",
|
|
3850
3841
|
namePrefix: "ak-",
|
|
@@ -3865,12 +3856,7 @@ var init_host_descriptions = __esm({
|
|
|
3865
3856
|
// Intermediate assistant/tool/system events require verbose with stream-json.
|
|
3866
3857
|
"--verbose",
|
|
3867
3858
|
"--permission-mode",
|
|
3868
|
-
"bypassPermissions"
|
|
3869
|
-
// Empty sources: no user/project/local operator surface (envelope owns materials).
|
|
3870
|
-
"--setting-sources",
|
|
3871
|
-
"",
|
|
3872
|
-
// With adapter-supplied --mcp-config only (AK relay); drops operator + claude.ai MCP.
|
|
3873
|
-
"--strict-mcp-config"
|
|
3859
|
+
"bypassPermissions"
|
|
3874
3860
|
]),
|
|
3875
3861
|
promptFlag: "-p",
|
|
3876
3862
|
modelFlag: "--model",
|
|
@@ -7172,10 +7158,12 @@ __export(invocation_exports, {
|
|
|
7172
7158
|
deriveMergerEnvelopeFromActiveMerge: () => deriveMergerEnvelopeFromActiveMerge,
|
|
7173
7159
|
ensureRunArtifactsDir: () => ensureRunArtifactsDir,
|
|
7174
7160
|
freezeAttachmentsIntoRun: () => freezeAttachmentsIntoRun,
|
|
7161
|
+
freezePreparedAttachmentsIntoRun: () => freezePreparedAttachmentsIntoRun,
|
|
7175
7162
|
homeFromRunDirectory: () => homeFromRunDirectory,
|
|
7176
7163
|
isReviewerLens: () => isReviewerLens,
|
|
7177
7164
|
issueAdmissionPlacement: () => issueAdmissionPlacement,
|
|
7178
7165
|
loadAdmittedJudgeRequest: () => loadAdmittedJudgeRequest,
|
|
7166
|
+
materializeCountersignInvocation: () => materializeCountersignInvocation,
|
|
7179
7167
|
observeLaunchedRolePackageIdentity: () => observeLaunchedRolePackageIdentity,
|
|
7180
7168
|
parseAnalystArgv: () => parseAnalystArgv,
|
|
7181
7169
|
parseAnalystCohortIssueToken: () => parseAnalystCohortIssueToken,
|
|
@@ -7199,6 +7187,7 @@ __export(invocation_exports, {
|
|
|
7199
7187
|
parseReviewerArgv: () => parseReviewerArgv,
|
|
7200
7188
|
parseSecretariatArgv: () => parseSecretariatArgv,
|
|
7201
7189
|
persistAdmittedSourceRunPath: () => persistAdmittedSourceRunPath,
|
|
7190
|
+
recordAdmittedCorrelation: () => recordAdmittedCorrelation,
|
|
7202
7191
|
recordEffectiveInvocationModel: () => recordEffectiveInvocationModel,
|
|
7203
7192
|
recordLaunchedPiIdentity: () => recordLaunchedPiIdentity,
|
|
7204
7193
|
recordLaunchedRolePackageIdentity: () => recordLaunchedRolePackageIdentity,
|
|
@@ -7207,17 +7196,21 @@ __export(invocation_exports, {
|
|
|
7207
7196
|
requireReviewerBaseRevision: () => requireReviewerBaseRevision,
|
|
7208
7197
|
requireReviewerLens: () => requireReviewerLens,
|
|
7209
7198
|
resolveDoctorCaseRunsPath: () => resolveDoctorCaseRunsPath,
|
|
7210
|
-
resolveGitHubRemoteRepository: () => resolveGitHubRemoteRepository
|
|
7199
|
+
resolveGitHubRemoteRepository: () => resolveGitHubRemoteRepository,
|
|
7200
|
+
withPreparedAttachments: () => withPreparedAttachments
|
|
7211
7201
|
});
|
|
7212
7202
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
7213
7203
|
import { existsSync as existsSync5 } from "node:fs";
|
|
7214
7204
|
import {
|
|
7215
7205
|
lstat as lstat4,
|
|
7206
|
+
mkdtemp as mkdtemp2,
|
|
7216
7207
|
readFile as readFile11,
|
|
7217
7208
|
realpath as realpath5,
|
|
7218
7209
|
rename,
|
|
7210
|
+
rm as rm2,
|
|
7219
7211
|
writeFile as writeFile5
|
|
7220
7212
|
} from "node:fs/promises";
|
|
7213
|
+
import { tmpdir as tmpdir2 } from "node:os";
|
|
7221
7214
|
import { basename as basename6, dirname as dirname9, isAbsolute as isAbsolute7, join as join15, resolve as resolve9, sep as sep4 } from "node:path";
|
|
7222
7215
|
function issueAdmissionPlacement(authority, request) {
|
|
7223
7216
|
const ledgerHome = resolveActivationLedgerHome(request.home);
|
|
@@ -7228,7 +7221,7 @@ function issueAdmissionPlacement(authority, request) {
|
|
|
7228
7221
|
runId: request.runId,
|
|
7229
7222
|
role: request.role
|
|
7230
7223
|
});
|
|
7231
|
-
ensureRoleRunPlacement(ledgerHome, placement);
|
|
7224
|
+
if (request.materialize !== false) ensureRoleRunPlacement(ledgerHome, placement);
|
|
7232
7225
|
return {
|
|
7233
7226
|
principal: authority.seal(placement),
|
|
7234
7227
|
...placement,
|
|
@@ -7353,6 +7346,31 @@ async function bindAdmittedTicketNumber(admitted, ticketNumber) {
|
|
|
7353
7346
|
await bindTicketNumberOnRunDirectory(admitted.runDirectory, ticketNumber);
|
|
7354
7347
|
admitted.ticketNumber = ticketNumber;
|
|
7355
7348
|
}
|
|
7349
|
+
async function recordAdmittedCorrelation(admitted, correlationId) {
|
|
7350
|
+
const current = JSON.parse(
|
|
7351
|
+
await readFile11(admitted.admittedRequestPath, "utf8")
|
|
7352
|
+
);
|
|
7353
|
+
const prior = [
|
|
7354
|
+
...Array.isArray(current.correlationIds) ? current.correlationIds.filter(
|
|
7355
|
+
(value) => typeof value === "string" && value.trim() !== ""
|
|
7356
|
+
) : [],
|
|
7357
|
+
...typeof current.correlationId === "string" && current.correlationId.trim() !== "" ? [current.correlationId] : []
|
|
7358
|
+
];
|
|
7359
|
+
const correlationIds = [.../* @__PURE__ */ new Set([...prior, correlationId])];
|
|
7360
|
+
await writeFile5(
|
|
7361
|
+
admitted.admittedRequestPath,
|
|
7362
|
+
`${JSON.stringify({ ...current, correlationId, correlationIds }, null, 2)}
|
|
7363
|
+
`,
|
|
7364
|
+
"utf8"
|
|
7365
|
+
);
|
|
7366
|
+
await mergeInvocationIdentityPage(admitted.runDirectory, {
|
|
7367
|
+
correlationId,
|
|
7368
|
+
correlationIds
|
|
7369
|
+
});
|
|
7370
|
+
const mutable = admitted;
|
|
7371
|
+
mutable.correlationId = correlationId;
|
|
7372
|
+
mutable.correlationIds = correlationIds;
|
|
7373
|
+
}
|
|
7356
7374
|
async function bindCourtTicketNumbersOnAdmitted(admitted, courtTicketNumbers) {
|
|
7357
7375
|
if (admitted.ticketNumber === void 0) {
|
|
7358
7376
|
throw new Error(
|
|
@@ -7743,7 +7761,7 @@ function parseFixerArgv(args) {
|
|
|
7743
7761
|
...project === void 0 ? {} : { project }
|
|
7744
7762
|
};
|
|
7745
7763
|
}
|
|
7746
|
-
async function
|
|
7764
|
+
async function readRegularFileAttachment(sourcePath) {
|
|
7747
7765
|
const absolute = isAbsolute7(sourcePath) ? sourcePath : resolve9(sourcePath);
|
|
7748
7766
|
let st;
|
|
7749
7767
|
try {
|
|
@@ -7759,18 +7777,72 @@ async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
|
|
|
7759
7777
|
`attachment must be a regular file (not a directory or symlink): ${sourcePath}`
|
|
7760
7778
|
);
|
|
7761
7779
|
}
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7780
|
+
try {
|
|
7781
|
+
return { absolute, bytes: await readFile11(absolute) };
|
|
7782
|
+
} catch (error) {
|
|
7783
|
+
throw new CliUsageError(
|
|
7784
|
+
`attachment is not a readable regular file: ${sourcePath}`,
|
|
7785
|
+
{ cause: error }
|
|
7786
|
+
);
|
|
7787
|
+
}
|
|
7788
|
+
}
|
|
7789
|
+
async function removePreparedAttachmentDirectory(stagingDirectory) {
|
|
7790
|
+
await rm2(stagingDirectory, { recursive: true, force: true });
|
|
7791
|
+
}
|
|
7792
|
+
async function withPreparedAttachments(attachmentPaths, use) {
|
|
7793
|
+
if (attachmentPaths.length === 0) return await use([]);
|
|
7794
|
+
const stagingDirectory = await mkdtemp2(join15(tmpdir2(), "ak-role-attachments-"));
|
|
7795
|
+
const prepared = [];
|
|
7796
|
+
let result;
|
|
7797
|
+
try {
|
|
7798
|
+
for (let index = 0; index < attachmentPaths.length; index += 1) {
|
|
7799
|
+
const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
|
|
7800
|
+
const snapshotPath = join15(stagingDirectory, String(index).padStart(6, "0"));
|
|
7801
|
+
await writeFile5(snapshotPath, bytes);
|
|
7802
|
+
prepared.push({ absolute, snapshotPath });
|
|
7803
|
+
}
|
|
7804
|
+
result = await use(prepared);
|
|
7805
|
+
} catch (primary) {
|
|
7806
|
+
try {
|
|
7807
|
+
await removePreparedAttachmentDirectory(stagingDirectory);
|
|
7808
|
+
} catch (cleanup) {
|
|
7809
|
+
throw new AggregateError(
|
|
7810
|
+
[primary, cleanup],
|
|
7811
|
+
"attachment snapshot operation failed and cleanup also failed",
|
|
7812
|
+
{ cause: primary }
|
|
7813
|
+
);
|
|
7814
|
+
}
|
|
7815
|
+
throw primary;
|
|
7816
|
+
}
|
|
7817
|
+
await removePreparedAttachmentDirectory(stagingDirectory);
|
|
7818
|
+
return result;
|
|
7819
|
+
}
|
|
7820
|
+
async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, index) {
|
|
7821
|
+
const frozenPath = join15(
|
|
7822
|
+
destinationDir,
|
|
7823
|
+
`${String(index).padStart(2, "0")}-${basename6(provenancePath)}`
|
|
7824
|
+
);
|
|
7765
7825
|
await writeFile5(frozenPath, bytes);
|
|
7766
7826
|
return {
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7827
|
+
provenancePath,
|
|
7828
|
+
frozenPath,
|
|
7829
|
+
byteLength: bytes.byteLength,
|
|
7830
|
+
sha256: sha256Hex(bytes),
|
|
7831
|
+
mediaKind: "regular-file"
|
|
7832
|
+
};
|
|
7833
|
+
}
|
|
7834
|
+
async function freezePreparedAttachment(prepared, destinationDir, index) {
|
|
7835
|
+
return freezeAttachmentBytes(
|
|
7836
|
+
prepared.absolute,
|
|
7837
|
+
await readFile11(prepared.snapshotPath),
|
|
7838
|
+
destinationDir,
|
|
7839
|
+
index
|
|
7840
|
+
);
|
|
7841
|
+
}
|
|
7842
|
+
async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
|
|
7843
|
+
const { absolute, bytes } = await readRegularFileAttachment(sourcePath);
|
|
7844
|
+
return {
|
|
7845
|
+
attachment: await freezeAttachmentBytes(absolute, bytes, destinationDir, index),
|
|
7774
7846
|
body: bytes
|
|
7775
7847
|
};
|
|
7776
7848
|
}
|
|
@@ -7793,6 +7865,17 @@ async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKe
|
|
|
7793
7865
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
7794
7866
|
return freezeAttachments(attachmentPaths, attachmentsDirectory);
|
|
7795
7867
|
}
|
|
7868
|
+
async function freezePreparedAttachmentsIntoRun(prepared, runDirectory, summonsKey) {
|
|
7869
|
+
if (prepared.length === 0) return [];
|
|
7870
|
+
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
7871
|
+
const attachmentsDirectory = summonsKey === void 0 ? join15(runDirectory, "attachments") : join15(runDirectory, "attachments", summonsKey);
|
|
7872
|
+
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
7873
|
+
const attachments = [];
|
|
7874
|
+
for (let index = 0; index < prepared.length; index += 1) {
|
|
7875
|
+
attachments.push(await freezePreparedAttachment(prepared[index], attachmentsDirectory, index));
|
|
7876
|
+
}
|
|
7877
|
+
return attachments;
|
|
7878
|
+
}
|
|
7796
7879
|
function ticketAdmissionFields(ticketNumber) {
|
|
7797
7880
|
if (ticketNumber === void 0) return {};
|
|
7798
7881
|
return {
|
|
@@ -7932,9 +8015,10 @@ async function admitCountersignInvocation(options) {
|
|
|
7932
8015
|
runId,
|
|
7933
8016
|
role: "countersign",
|
|
7934
8017
|
subject: { unbound: true },
|
|
7935
|
-
home: options.home
|
|
8018
|
+
home: options.home,
|
|
8019
|
+
materialize: options.deferPersistence !== true
|
|
7936
8020
|
});
|
|
7937
|
-
const attachments = await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
|
|
8021
|
+
const attachments = options.deferPersistence === true ? [] : await freezeAttachments(options.attachmentPaths, attachmentsDirectory);
|
|
7938
8022
|
const instruction = options.instruction;
|
|
7939
8023
|
const instructionEmpty = instruction.trim() === "";
|
|
7940
8024
|
const admitted = {
|
|
@@ -7956,11 +8040,13 @@ async function admitCountersignInvocation(options) {
|
|
|
7956
8040
|
}))
|
|
7957
8041
|
};
|
|
7958
8042
|
const admittedRequestPath = join15(runDirectory, "admitted-request.json");
|
|
7959
|
-
|
|
7960
|
-
|
|
7961
|
-
|
|
7962
|
-
|
|
7963
|
-
|
|
8043
|
+
if (options.deferPersistence !== true) {
|
|
8044
|
+
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
8045
|
+
sessionDirectory,
|
|
8046
|
+
sessionFile
|
|
8047
|
+
});
|
|
8048
|
+
await writeRoleInvocationLedger({ ...admitted, sessionDirectory, sessionFile }, admitted.role, options.model);
|
|
8049
|
+
}
|
|
7964
8050
|
return {
|
|
7965
8051
|
role: "countersign",
|
|
7966
8052
|
runId,
|
|
@@ -7975,6 +8061,29 @@ async function admitCountersignInvocation(options) {
|
|
|
7975
8061
|
...options.correlationId === void 0 ? {} : { correlationId: options.correlationId }
|
|
7976
8062
|
};
|
|
7977
8063
|
}
|
|
8064
|
+
async function materializeCountersignInvocation(admitted, options) {
|
|
8065
|
+
const placement = issueAdmissionPlacement(options.principalAuthority, {
|
|
8066
|
+
cwd: admitted.projectRoot,
|
|
8067
|
+
runId: admitted.runId,
|
|
8068
|
+
role: "countersign",
|
|
8069
|
+
subject: { unbound: true },
|
|
8070
|
+
home: options.home
|
|
8071
|
+
});
|
|
8072
|
+
const attachments = await freezePreparedAttachmentsIntoRun(
|
|
8073
|
+
options.preparedAttachments,
|
|
8074
|
+
admitted.runDirectory
|
|
8075
|
+
);
|
|
8076
|
+
admitted.attachments = attachments;
|
|
8077
|
+
await writeAdmittedRequestPersistence(admitted.admittedRequestPath, admitted, {
|
|
8078
|
+
sessionDirectory: placement.sessionDirectory,
|
|
8079
|
+
sessionFile: placement.sessionFile
|
|
8080
|
+
});
|
|
8081
|
+
await writeRoleInvocationLedger(
|
|
8082
|
+
{ ...admitted, sessionDirectory: placement.sessionDirectory, sessionFile: placement.sessionFile },
|
|
8083
|
+
admitted.role,
|
|
8084
|
+
options.model
|
|
8085
|
+
);
|
|
8086
|
+
}
|
|
7978
8087
|
function buildCountersignTransportPrompt(admitted, engineMaterial) {
|
|
7979
8088
|
return buildInstructionTransportPrompt(admitted, engineMaterial);
|
|
7980
8089
|
}
|
|
@@ -10765,10 +10874,10 @@ function pairGateRounds(volumes) {
|
|
|
10765
10874
|
return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
|
|
10766
10875
|
}
|
|
10767
10876
|
async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
10768
|
-
const { readFile:
|
|
10877
|
+
const { readFile: readFile23 } = await import("node:fs/promises");
|
|
10769
10878
|
let raw;
|
|
10770
10879
|
try {
|
|
10771
|
-
raw = JSON.parse(await
|
|
10880
|
+
raw = JSON.parse(await readFile23(pointerPath, "utf8"));
|
|
10772
10881
|
} catch (error) {
|
|
10773
10882
|
throw new Error(
|
|
10774
10883
|
`direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -11369,16 +11478,27 @@ async function readPackageMaterial(relativePath) {
|
|
|
11369
11478
|
}
|
|
11370
11479
|
async function joinPackageMaterials(relativePaths) {
|
|
11371
11480
|
const chunks = [];
|
|
11372
|
-
for (const relativePath of relativePaths)
|
|
11373
|
-
chunks.push(await readPackageMaterial(relativePath));
|
|
11374
|
-
}
|
|
11481
|
+
for (const relativePath of relativePaths) chunks.push(await readPackageMaterial(relativePath));
|
|
11375
11482
|
return chunks.join("\n\n");
|
|
11376
11483
|
}
|
|
11484
|
+
function roleSoulPath(role, materials) {
|
|
11485
|
+
const suffix = `/souls/${role}.md`;
|
|
11486
|
+
const path = materials.find((candidate) => `/${candidate}`.endsWith(suffix));
|
|
11487
|
+
if (path === void 0) throw new Error(`session materials omit the ${role} Soul`);
|
|
11488
|
+
return path;
|
|
11489
|
+
}
|
|
11490
|
+
async function loadSeparatedSessionPart(role, materials, part) {
|
|
11491
|
+
const soul = roleSoulPath(role, materials);
|
|
11492
|
+
return part === "soul" ? readPackageMaterial(soul) : joinPackageMaterials(materials.filter((path) => path !== soul));
|
|
11493
|
+
}
|
|
11377
11494
|
function loadMainRoleSessionMaterials(role) {
|
|
11378
|
-
return
|
|
11495
|
+
return loadSeparatedSessionPart(role, MAIN_ROLE_SESSION_MATERIALS[role], "soul");
|
|
11496
|
+
}
|
|
11497
|
+
function loadMainRoleReferenceMaterials(role) {
|
|
11498
|
+
return loadSeparatedSessionPart(role, MAIN_ROLE_SESSION_MATERIALS[role], "references");
|
|
11379
11499
|
}
|
|
11380
11500
|
function loadGatekeeperSessionMaterials(role) {
|
|
11381
|
-
return
|
|
11501
|
+
return loadSeparatedSessionPart(role, GATEKEEPER_SESSION_MATERIALS[role], "soul");
|
|
11382
11502
|
}
|
|
11383
11503
|
var packageRootUrl, MAIN_ROLE_SESSION_MATERIALS, GATEKEEPER_SESSION_MATERIALS;
|
|
11384
11504
|
var init_session_opening_materials = __esm({
|
|
@@ -11408,6 +11528,8 @@ __export(auditor_soul_exports, {
|
|
|
11408
11528
|
AUDITOR_SESSION_MATERIALS: () => AUDITOR_SESSION_MATERIALS,
|
|
11409
11529
|
AUDITOR_SOUL_ROLES: () => AUDITOR_SOUL_ROLES,
|
|
11410
11530
|
isAuditorSoulRole: () => isAuditorSoulRole,
|
|
11531
|
+
loadAuditorReferenceMaterials: () => loadAuditorReferenceMaterials,
|
|
11532
|
+
loadAuditorReferenceMaterialsFromSubjectInput: () => loadAuditorReferenceMaterialsFromSubjectInput,
|
|
11411
11533
|
loadAuditorSoul: () => loadAuditorSoul,
|
|
11412
11534
|
loadAuditorSoulFromSubjectInput: () => loadAuditorSoulFromSubjectInput,
|
|
11413
11535
|
resolveAuditorSubject: () => resolveAuditorSubject
|
|
@@ -11434,11 +11556,18 @@ async function loadAuditorSoul(role) {
|
|
|
11434
11556
|
if (soul.trim().length === 0) {
|
|
11435
11557
|
throw new Error(`The ${role} auditor Soul is blank`);
|
|
11436
11558
|
}
|
|
11437
|
-
return
|
|
11559
|
+
return soul;
|
|
11560
|
+
}
|
|
11561
|
+
function loadAuditorReferenceMaterials(role) {
|
|
11562
|
+
const soulPath = auditorSoulRelativePath(role);
|
|
11563
|
+
return joinPackageMaterials(AUDITOR_SESSION_MATERIALS[role].filter((path) => path !== soulPath));
|
|
11438
11564
|
}
|
|
11439
11565
|
async function loadAuditorSoulFromSubjectInput(raw) {
|
|
11440
11566
|
return loadAuditorSoul(resolveAuditorSubject(raw));
|
|
11441
11567
|
}
|
|
11568
|
+
function loadAuditorReferenceMaterialsFromSubjectInput(raw) {
|
|
11569
|
+
return loadAuditorReferenceMaterials(resolveAuditorSubject(raw));
|
|
11570
|
+
}
|
|
11442
11571
|
var AUDITOR_SOUL_ROLES, AK_ROLE_AUDITOR_SUBJECT_ENV, AK_ROLE_AUDITOR_SOURCE_RUN_ENV, AUDITOR_SESSION_MATERIALS;
|
|
11443
11572
|
var init_auditor_soul = __esm({
|
|
11444
11573
|
"src/auditor-soul.ts"() {
|
|
@@ -16927,8 +17056,8 @@ __export(case_dossier_delivery_exports, {
|
|
|
16927
17056
|
loadCaseDossierReadingMaterial: () => loadCaseDossierReadingMaterial,
|
|
16928
17057
|
projectCaseDossierPointerSection: () => projectCaseDossierPointerSection
|
|
16929
17058
|
});
|
|
16930
|
-
import { mkdtemp as
|
|
16931
|
-
import { tmpdir as
|
|
17059
|
+
import { mkdtemp as mkdtemp3, readFile as readFile19, rm as rm3, writeFile as writeFile9 } from "node:fs/promises";
|
|
17060
|
+
import { tmpdir as tmpdir3 } from "node:os";
|
|
16932
17061
|
import { join as join29 } from "node:path";
|
|
16933
17062
|
async function projectCaseDossierPointerSection(input) {
|
|
16934
17063
|
if (input.ticketNumber === void 0) {
|
|
@@ -16956,7 +17085,7 @@ async function deliverCaseDossierAsAttachment(input) {
|
|
|
16956
17085
|
projectRoot: input.projectRoot,
|
|
16957
17086
|
home: input.home
|
|
16958
17087
|
});
|
|
16959
|
-
const stagingDir = await
|
|
17088
|
+
const stagingDir = await mkdtemp3(join29(tmpdir3(), "ak-case-dossier-"));
|
|
16960
17089
|
try {
|
|
16961
17090
|
const stagingPath = join29(stagingDir, CASE_DOSSIER_ATTACH_FILE);
|
|
16962
17091
|
await writeFile9(stagingPath, `${section}
|
|
@@ -16967,7 +17096,7 @@ async function deliverCaseDossierAsAttachment(input) {
|
|
|
16967
17096
|
CASE_DOSSIER_ATTACH_KEY
|
|
16968
17097
|
);
|
|
16969
17098
|
} finally {
|
|
16970
|
-
await
|
|
17099
|
+
await rm3(stagingDir, { recursive: true, force: true });
|
|
16971
17100
|
}
|
|
16972
17101
|
}
|
|
16973
17102
|
async function loadCaseDossierReadingMaterial(runDirectory) {
|
|
@@ -19269,6 +19398,9 @@ function diaristAdapters(env) {
|
|
|
19269
19398
|
shouldPresentSettled: () => true,
|
|
19270
19399
|
// Resume interrupted state: board ticket already on pages, run still under unbound/.
|
|
19271
19400
|
beforeDispatch: async (admitted, lease) => {
|
|
19401
|
+
if (env.correlationId !== void 0 && env.correlationId.trim() !== "") {
|
|
19402
|
+
await recordAdmittedCorrelation(admitted, env.correlationId);
|
|
19403
|
+
}
|
|
19272
19404
|
await bindAndRelocateDiaristIfBoardBound(admitted, env.principalAuthority, lease);
|
|
19273
19405
|
},
|
|
19274
19406
|
// First post-turn assert: accept hook wrote board pages; relocate before lease release.
|
|
@@ -19453,7 +19585,8 @@ function courtDiaristEscalated(roleOutcome) {
|
|
|
19453
19585
|
if (roleOutcome.kind === "audit_escalation") return true;
|
|
19454
19586
|
if (roleOutcome.kind !== "accepted") return false;
|
|
19455
19587
|
return (roleOutcome.payloads ?? []).some((payload) => {
|
|
19456
|
-
if (typeof payload !== "object" || payload === null || Array.isArray(payload))
|
|
19588
|
+
if (typeof payload !== "object" || payload === null || Array.isArray(payload))
|
|
19589
|
+
return false;
|
|
19457
19590
|
const record4 = payload;
|
|
19458
19591
|
return record4.status === "escalate" || record4.countersignStatus === "escalate";
|
|
19459
19592
|
});
|
|
@@ -19506,7 +19639,10 @@ async function invokeCourtDiarist(input, env, io) {
|
|
|
19506
19639
|
}
|
|
19507
19640
|
const asserted = result.admitted?.ticketNumber;
|
|
19508
19641
|
if (isSafePositiveTicketNumber(asserted)) {
|
|
19509
|
-
const courtTicketNumbers = courtTicketNumbersFromOutcome(
|
|
19642
|
+
const courtTicketNumbers = courtTicketNumbersFromOutcome(
|
|
19643
|
+
roleOutcome,
|
|
19644
|
+
asserted
|
|
19645
|
+
);
|
|
19510
19646
|
return {
|
|
19511
19647
|
identity: {
|
|
19512
19648
|
kind: "ticket",
|
|
@@ -19555,7 +19691,9 @@ async function runCountersignCourtDiaristStation(admitted, env, io) {
|
|
|
19555
19691
|
);
|
|
19556
19692
|
}
|
|
19557
19693
|
if (outcome.failedWithoutEscalate !== void 0) {
|
|
19558
|
-
throw new StationChildExhaustedError(
|
|
19694
|
+
throw new StationChildExhaustedError(
|
|
19695
|
+
outcome.failedWithoutEscalate.diagnostic
|
|
19696
|
+
);
|
|
19559
19697
|
}
|
|
19560
19698
|
}
|
|
19561
19699
|
}
|
|
@@ -19581,7 +19719,8 @@ async function runPublicCountersign(argv, env, io, parseCountersignArgv2) {
|
|
|
19581
19719
|
...parsed.project === void 0 ? {} : { project: parsed.project },
|
|
19582
19720
|
...env.createRunId === void 0 ? {} : { createRunId: env.createRunId },
|
|
19583
19721
|
...env.model === void 0 ? {} : { model: env.model },
|
|
19584
|
-
...env.correlationId === void 0 ? {} : { correlationId: env.correlationId }
|
|
19722
|
+
...env.correlationId === void 0 ? {} : { correlationId: env.correlationId },
|
|
19723
|
+
deferPersistence: true
|
|
19585
19724
|
});
|
|
19586
19725
|
} catch (error) {
|
|
19587
19726
|
if (error instanceof CliUsageError) {
|
|
@@ -19590,160 +19729,216 @@ async function runPublicCountersign(argv, env, io, parseCountersignArgv2) {
|
|
|
19590
19729
|
}
|
|
19591
19730
|
throw error;
|
|
19592
19731
|
}
|
|
19593
|
-
|
|
19594
|
-
|
|
19595
|
-
|
|
19596
|
-
|
|
19597
|
-
|
|
19598
|
-
|
|
19599
|
-
|
|
19600
|
-
|
|
19601
|
-
|
|
19602
|
-
|
|
19603
|
-
|
|
19604
|
-
|
|
19605
|
-
|
|
19606
|
-
|
|
19607
|
-
|
|
19608
|
-
|
|
19609
|
-
|
|
19610
|
-
|
|
19611
|
-
|
|
19612
|
-
|
|
19613
|
-
|
|
19614
|
-
|
|
19615
|
-
|
|
19616
|
-
|
|
19617
|
-
|
|
19618
|
-
|
|
19619
|
-
|
|
19620
|
-
|
|
19621
|
-
|
|
19622
|
-
|
|
19623
|
-
|
|
19624
|
-
|
|
19625
|
-
|
|
19626
|
-
|
|
19627
|
-
|
|
19628
|
-
|
|
19629
|
-
|
|
19630
|
-
|
|
19631
|
-
|
|
19632
|
-
|
|
19633
|
-
|
|
19634
|
-
|
|
19635
|
-
|
|
19636
|
-
|
|
19637
|
-
|
|
19638
|
-
|
|
19639
|
-
|
|
19640
|
-
|
|
19641
|
-
|
|
19642
|
-
|
|
19643
|
-
|
|
19644
|
-
|
|
19645
|
-
|
|
19646
|
-
|
|
19647
|
-
|
|
19648
|
-
|
|
19649
|
-
|
|
19650
|
-
|
|
19651
|
-
|
|
19652
|
-
|
|
19653
|
-
|
|
19654
|
-
|
|
19655
|
-
|
|
19656
|
-
|
|
19657
|
-
|
|
19658
|
-
|
|
19659
|
-
|
|
19660
|
-
|
|
19661
|
-
|
|
19662
|
-
|
|
19663
|
-
|
|
19664
|
-
|
|
19665
|
-
|
|
19666
|
-
|
|
19667
|
-
|
|
19668
|
-
|
|
19669
|
-
|
|
19732
|
+
try {
|
|
19733
|
+
return await withPreparedAttachments(
|
|
19734
|
+
parsed.attachmentPaths,
|
|
19735
|
+
async (preparedAttachments) => {
|
|
19736
|
+
const materializeAdmission = async () => {
|
|
19737
|
+
await materializeCountersignInvocation(admitted, {
|
|
19738
|
+
home: env.home,
|
|
19739
|
+
principalAuthority: env.principalAuthority,
|
|
19740
|
+
preparedAttachments,
|
|
19741
|
+
...env.model === void 0 ? {} : { model: env.model }
|
|
19742
|
+
});
|
|
19743
|
+
};
|
|
19744
|
+
let typedTicket;
|
|
19745
|
+
let typedCourtTicketNumbers;
|
|
19746
|
+
let identityDiaristRan = false;
|
|
19747
|
+
if (env.runCourtDiaristStation === void 0) {
|
|
19748
|
+
let outcome;
|
|
19749
|
+
try {
|
|
19750
|
+
outcome = await invokeCourtDiarist(
|
|
19751
|
+
{
|
|
19752
|
+
instruction: parsed.instruction,
|
|
19753
|
+
projectRoot: admitted.projectRoot,
|
|
19754
|
+
failureLabel: "unbound summons"
|
|
19755
|
+
},
|
|
19756
|
+
env,
|
|
19757
|
+
io
|
|
19758
|
+
);
|
|
19759
|
+
} catch (error) {
|
|
19760
|
+
await materializeAdmission();
|
|
19761
|
+
await markRunAdmitted(admitted, env.principalAuthority);
|
|
19762
|
+
return await presentControlledFailure2(
|
|
19763
|
+
admitted,
|
|
19764
|
+
{ timedOut: false, code: null, stderr: "", thrown: error },
|
|
19765
|
+
countersignAdapters(),
|
|
19766
|
+
env.principalAuthority,
|
|
19767
|
+
io
|
|
19768
|
+
);
|
|
19769
|
+
}
|
|
19770
|
+
identityDiaristRan = true;
|
|
19771
|
+
if (outcome.identity.kind === "escalate") {
|
|
19772
|
+
await materializeAdmission();
|
|
19773
|
+
await markRunAdmitted(admitted, env.principalAuthority);
|
|
19774
|
+
return await presentControlledFailure2(
|
|
19775
|
+
admitted,
|
|
19776
|
+
{
|
|
19777
|
+
timedOut: false,
|
|
19778
|
+
code: null,
|
|
19779
|
+
stderr: "",
|
|
19780
|
+
thrown: new Error(
|
|
19781
|
+
"court diarist station escalated (cannot identify court target)"
|
|
19782
|
+
)
|
|
19783
|
+
},
|
|
19784
|
+
countersignAdapters(),
|
|
19785
|
+
env.principalAuthority,
|
|
19786
|
+
io
|
|
19787
|
+
);
|
|
19788
|
+
}
|
|
19789
|
+
if (outcome.failedWithoutEscalate !== void 0) {
|
|
19790
|
+
await materializeAdmission();
|
|
19791
|
+
await markRunAdmitted(admitted, env.principalAuthority);
|
|
19792
|
+
return await presentControlledFailure2(
|
|
19793
|
+
admitted,
|
|
19794
|
+
{
|
|
19795
|
+
timedOut: false,
|
|
19796
|
+
code: null,
|
|
19797
|
+
stderr: "",
|
|
19798
|
+
thrown: new Error(outcome.failedWithoutEscalate.diagnostic)
|
|
19799
|
+
},
|
|
19800
|
+
countersignAdapters(),
|
|
19801
|
+
env.principalAuthority,
|
|
19802
|
+
io
|
|
19803
|
+
);
|
|
19804
|
+
}
|
|
19805
|
+
if (outcome.identity.kind === "ticket") {
|
|
19806
|
+
const assertedTicket = outcome.identity.ticketNumber;
|
|
19807
|
+
typedTicket = assertedTicket;
|
|
19808
|
+
typedCourtTicketNumbers = outcome.identity.courtTicketNumbers;
|
|
19809
|
+
const summons = {
|
|
19810
|
+
instruction: parsed.instruction,
|
|
19811
|
+
instructionEmpty: parsed.instruction.trim() === ""
|
|
19812
|
+
};
|
|
19813
|
+
const resumed = await tryResumeSameTicketSeatRun({
|
|
19814
|
+
home: env.home,
|
|
19815
|
+
projectRoot: admitted.projectRoot,
|
|
19816
|
+
role: "countersign",
|
|
19817
|
+
ticketNumber: typedTicket,
|
|
19818
|
+
freshSummons: env.freshSummons,
|
|
19819
|
+
summons,
|
|
19820
|
+
resume: async (runId, materials) => {
|
|
19821
|
+
const retained = await loadResumableCountersignRun(
|
|
19822
|
+
env.home,
|
|
19823
|
+
runId,
|
|
19824
|
+
env.principalAuthority
|
|
19825
|
+
);
|
|
19826
|
+
if (retained.admitted === void 0) {
|
|
19827
|
+
throw new Error(
|
|
19828
|
+
`retained countersign run disappeared before resume: ${runId}`
|
|
19829
|
+
);
|
|
19830
|
+
}
|
|
19831
|
+
const frozenPaths = (await freezePreparedAttachmentsIntoRun(
|
|
19832
|
+
preparedAttachments,
|
|
19833
|
+
retained.admitted.runDirectory,
|
|
19834
|
+
`s-${Date.now().toString(36)}`
|
|
19835
|
+
)).map((attachment) => attachment.frozenPath);
|
|
19836
|
+
const preparedMaterials = {
|
|
19837
|
+
...materials ?? {},
|
|
19838
|
+
...frozenPaths.length === 0 ? {} : { attachmentPaths: frozenPaths }
|
|
19839
|
+
};
|
|
19840
|
+
return await runPublicCountersignResume(
|
|
19841
|
+
{
|
|
19842
|
+
runId,
|
|
19843
|
+
summons: preparedMaterials
|
|
19844
|
+
},
|
|
19845
|
+
{
|
|
19846
|
+
...env,
|
|
19847
|
+
...typedCourtTicketNumbers === void 0 ? {} : { pendingCourtTicketNumbers: typedCourtTicketNumbers }
|
|
19848
|
+
},
|
|
19849
|
+
io
|
|
19850
|
+
);
|
|
19851
|
+
}
|
|
19852
|
+
});
|
|
19853
|
+
if (resumed !== void 0) {
|
|
19854
|
+
return resumed;
|
|
19855
|
+
}
|
|
19856
|
+
}
|
|
19670
19857
|
}
|
|
19671
|
-
|
|
19672
|
-
|
|
19673
|
-
|
|
19674
|
-
|
|
19675
|
-
|
|
19676
|
-
|
|
19677
|
-
|
|
19678
|
-
|
|
19679
|
-
|
|
19680
|
-
|
|
19681
|
-
|
|
19682
|
-
|
|
19683
|
-
|
|
19684
|
-
|
|
19685
|
-
|
|
19686
|
-
|
|
19687
|
-
|
|
19688
|
-
|
|
19689
|
-
|
|
19690
|
-
|
|
19691
|
-
|
|
19692
|
-
|
|
19693
|
-
|
|
19694
|
-
|
|
19695
|
-
env.principalAuthority,
|
|
19696
|
-
io
|
|
19697
|
-
);
|
|
19698
|
-
}
|
|
19699
|
-
}
|
|
19700
|
-
const turnProjection = {
|
|
19701
|
-
packageRoot: env.packageRoot,
|
|
19702
|
-
home: env.home,
|
|
19703
|
-
agentDir: env.agentDir,
|
|
19704
|
-
...env.model === void 0 ? {} : { model: env.model },
|
|
19705
|
-
...pickEngineAxis(env),
|
|
19706
|
-
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
|
|
19707
|
-
...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
|
|
19708
|
-
continuation: {
|
|
19709
|
-
kind: "initial",
|
|
19710
|
-
prompt: buildCountersignTransportPrompt(
|
|
19711
|
-
admitted,
|
|
19712
|
-
engineSessionMaterialFromOptions({
|
|
19713
|
-
...pickEngineAxis(env),
|
|
19714
|
-
packageRoot: env.packageRoot
|
|
19715
|
-
})
|
|
19716
|
-
)
|
|
19717
|
-
}
|
|
19718
|
-
};
|
|
19719
|
-
const turnRequest = buildCountersignTurnRequest(admitted, turnProjection);
|
|
19720
|
-
const result = await runPostAdmissionOneShot({
|
|
19721
|
-
admitted,
|
|
19722
|
-
env,
|
|
19723
|
-
io,
|
|
19724
|
-
request: turnRequest,
|
|
19725
|
-
adapters: countersignAdapters({
|
|
19726
|
-
beforeDispatch: async (admittedSeat, lease) => {
|
|
19727
|
-
if (!identityDiaristRan) {
|
|
19728
|
-
await runCountersignCourtDiaristStation(admittedSeat, env, io);
|
|
19729
|
-
} else if (typedTicket !== void 0) {
|
|
19730
|
-
await runCountersignCourtDiaristStation(admittedSeat, env, io);
|
|
19858
|
+
await materializeAdmission();
|
|
19859
|
+
await markRunAdmitted(admitted, env.principalAuthority);
|
|
19860
|
+
if (identityDiaristRan && typedTicket !== void 0) {
|
|
19861
|
+
try {
|
|
19862
|
+
await bindAdmittedTicketNumber(admitted, typedTicket);
|
|
19863
|
+
await relocateAdmittedRunToTicket(admitted, env.principalAuthority);
|
|
19864
|
+
await bindCourtTicketNumbersOnAdmitted(
|
|
19865
|
+
admitted,
|
|
19866
|
+
typedCourtTicketNumbers ?? [typedTicket]
|
|
19867
|
+
);
|
|
19868
|
+
} catch (error) {
|
|
19869
|
+
return await presentControlledFailure2(
|
|
19870
|
+
admitted,
|
|
19871
|
+
{
|
|
19872
|
+
timedOut: false,
|
|
19873
|
+
code: null,
|
|
19874
|
+
stderr: "",
|
|
19875
|
+
thrown: error
|
|
19876
|
+
},
|
|
19877
|
+
countersignAdapters(),
|
|
19878
|
+
env.principalAuthority,
|
|
19879
|
+
io
|
|
19880
|
+
);
|
|
19881
|
+
}
|
|
19731
19882
|
}
|
|
19732
|
-
|
|
19733
|
-
|
|
19734
|
-
env.
|
|
19735
|
-
|
|
19736
|
-
|
|
19737
|
-
|
|
19738
|
-
|
|
19739
|
-
|
|
19883
|
+
const turnProjection = {
|
|
19884
|
+
packageRoot: env.packageRoot,
|
|
19885
|
+
home: env.home,
|
|
19886
|
+
agentDir: env.agentDir,
|
|
19887
|
+
...env.model === void 0 ? {} : { model: env.model },
|
|
19888
|
+
...pickEngineAxis(env),
|
|
19889
|
+
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
|
|
19890
|
+
...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
|
|
19891
|
+
continuation: {
|
|
19892
|
+
kind: "initial",
|
|
19893
|
+
prompt: buildCountersignTransportPrompt(
|
|
19894
|
+
admitted,
|
|
19895
|
+
engineSessionMaterialFromOptions({
|
|
19896
|
+
...pickEngineAxis(env),
|
|
19897
|
+
packageRoot: env.packageRoot
|
|
19898
|
+
})
|
|
19899
|
+
)
|
|
19900
|
+
}
|
|
19901
|
+
};
|
|
19902
|
+
const turnRequest = buildCountersignTurnRequest(
|
|
19903
|
+
admitted,
|
|
19904
|
+
turnProjection
|
|
19740
19905
|
);
|
|
19906
|
+
const result = await runPostAdmissionOneShot({
|
|
19907
|
+
admitted,
|
|
19908
|
+
env,
|
|
19909
|
+
io,
|
|
19910
|
+
request: turnRequest,
|
|
19911
|
+
adapters: countersignAdapters({
|
|
19912
|
+
beforeDispatch: async (admittedSeat, lease) => {
|
|
19913
|
+
if (!identityDiaristRan) {
|
|
19914
|
+
await runCountersignCourtDiaristStation(admittedSeat, env, io);
|
|
19915
|
+
} else if (typedTicket !== void 0) {
|
|
19916
|
+
await runCountersignCourtDiaristStation(admittedSeat, env, io);
|
|
19917
|
+
}
|
|
19918
|
+
await relocateAdmittedRunToTicket(
|
|
19919
|
+
admittedSeat,
|
|
19920
|
+
env.principalAuthority,
|
|
19921
|
+
lease
|
|
19922
|
+
);
|
|
19923
|
+
Object.assign(
|
|
19924
|
+
turnRequest,
|
|
19925
|
+
buildCountersignTurnRequest(admittedSeat, turnProjection)
|
|
19926
|
+
);
|
|
19927
|
+
}
|
|
19928
|
+
}),
|
|
19929
|
+
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
19930
|
+
});
|
|
19931
|
+
await relocateAdmittedRunToTicket(admitted, env.principalAuthority);
|
|
19932
|
+
return result;
|
|
19741
19933
|
}
|
|
19742
|
-
|
|
19743
|
-
|
|
19744
|
-
|
|
19745
|
-
|
|
19746
|
-
|
|
19934
|
+
);
|
|
19935
|
+
} catch (error) {
|
|
19936
|
+
if (error instanceof CliUsageError) {
|
|
19937
|
+
presentStructuralRejection(error, io);
|
|
19938
|
+
return { exitCode: 2 };
|
|
19939
|
+
}
|
|
19940
|
+
throw error;
|
|
19941
|
+
}
|
|
19747
19942
|
}
|
|
19748
19943
|
function countersignAdapters(options) {
|
|
19749
19944
|
return {
|
|
@@ -19781,7 +19976,9 @@ async function runPublicCountersignResume(request, env, io) {
|
|
|
19781
19976
|
adapters: countersignAdapters({
|
|
19782
19977
|
beforeDispatch: async (admitted) => {
|
|
19783
19978
|
if (admitted.courtTicketNumbersDamage !== void 0) {
|
|
19784
|
-
throw new StationChildExhaustedError(
|
|
19979
|
+
throw new StationChildExhaustedError(
|
|
19980
|
+
admitted.courtTicketNumbersDamage
|
|
19981
|
+
);
|
|
19785
19982
|
}
|
|
19786
19983
|
if (env.pendingCourtTicketNumbers !== void 0) {
|
|
19787
19984
|
await bindCourtTicketNumbersOnAdmitted(
|
|
@@ -22449,7 +22646,7 @@ import { join as join38, sep as sep5 } from "node:path";
|
|
|
22449
22646
|
|
|
22450
22647
|
// src/atomic-write.ts
|
|
22451
22648
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
22452
|
-
import { rename as rename3, rm as
|
|
22649
|
+
import { rename as rename3, rm as rm4, writeFile as writeFile11 } from "node:fs/promises";
|
|
22453
22650
|
import { dirname as dirname22, join as join37 } from "node:path";
|
|
22454
22651
|
async function writeFileAtomically(destination, contents) {
|
|
22455
22652
|
const parent = dirname22(destination);
|
|
@@ -22458,7 +22655,7 @@ async function writeFileAtomically(destination, contents) {
|
|
|
22458
22655
|
await writeFile11(temporary, contents);
|
|
22459
22656
|
await rename3(temporary, destination);
|
|
22460
22657
|
} catch (error) {
|
|
22461
|
-
await
|
|
22658
|
+
await rm4(temporary, { force: true }).catch(() => void 0);
|
|
22462
22659
|
throw error;
|
|
22463
22660
|
}
|
|
22464
22661
|
}
|
|
@@ -25266,6 +25463,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
25266
25463
|
});
|
|
25267
25464
|
let admitted = false;
|
|
25268
25465
|
let selectedRole;
|
|
25466
|
+
let roleReferenceMaterials = "";
|
|
25269
25467
|
let activeReviewerParent;
|
|
25270
25468
|
let reviewerOriginalRequest;
|
|
25271
25469
|
let reviewerExpansionCaptured = false;
|
|
@@ -25359,10 +25557,10 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
25359
25557
|
activeReviewerParent.skillBinding.name,
|
|
25360
25558
|
text
|
|
25361
25559
|
) ?? text;
|
|
25362
|
-
return text === event.text ? { action: "continue" } : { action: "transform", text };
|
|
25363
25560
|
}
|
|
25364
|
-
return
|
|
25561
|
+
return { action: "continue" };
|
|
25365
25562
|
});
|
|
25563
|
+
roleHost.on("before_agent_start", () => roleReferenceMaterials === "" ? void 0 : { readingMaterial: { kind: "role-reference-materials", content: roleReferenceMaterials } });
|
|
25366
25564
|
roleHost.on("before_agent_start", async (event, ctx) => {
|
|
25367
25565
|
const role = roleHost.getFlag(ROLE_FLAG.name);
|
|
25368
25566
|
const prompt = event.prompt;
|
|
@@ -25928,6 +26126,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
25928
26126
|
}
|
|
25929
26127
|
admitted = false;
|
|
25930
26128
|
selectedRole = void 0;
|
|
26129
|
+
roleReferenceMaterials = "";
|
|
25931
26130
|
activeReviewerParent = void 0;
|
|
25932
26131
|
reviewerOriginalRequest = void 0;
|
|
25933
26132
|
reviewerExpansionCaptured = false;
|
|
@@ -26062,6 +26261,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
26062
26261
|
}
|
|
26063
26262
|
}
|
|
26064
26263
|
await executeActivationStage(entry.role, activationStage(entry.role, runtime), { clock, writeTrace });
|
|
26264
|
+
roleReferenceMaterials = await dependencies.loadRoleReferenceMaterials?.(entry.role) ?? "";
|
|
26065
26265
|
if (!engineDetourRegistered) {
|
|
26066
26266
|
engineDetourRegistered = registerEngineDetourTool(roleHost, hostActions);
|
|
26067
26267
|
}
|
|
@@ -26101,11 +26301,15 @@ var navigatorRoutePlaybookPath = fileURLToPath2(
|
|
|
26101
26301
|
var collectorHandbookSeedPath = fileURLToPath2(
|
|
26102
26302
|
new URL("../resources/collector-bot-handbook.md", import.meta.url)
|
|
26103
26303
|
);
|
|
26304
|
+
function loadPackagedRoleReferenceMaterials(role) {
|
|
26305
|
+
return role === "auditor" ? loadAuditorReferenceMaterialsFromSubjectInput() : loadMainRoleReferenceMaterials(role);
|
|
26306
|
+
}
|
|
26104
26307
|
function createRoleRuntimeDependencies(packageRoot) {
|
|
26105
26308
|
const doctorAuditor = createPiDoctorAuditor();
|
|
26106
26309
|
const navigatorSessionFactory = createNativeNavigatorSessionFactory();
|
|
26107
26310
|
return {
|
|
26108
26311
|
packageRoot,
|
|
26312
|
+
loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
|
|
26109
26313
|
loadJudgeSoul: () => loadMainRoleSessionMaterials("judge"),
|
|
26110
26314
|
loadFixerSoul: () => loadMainRoleSessionMaterials("fixer"),
|
|
26111
26315
|
loadFixPacket: (path) => readFile22(path, "utf8"),
|
|
@@ -26166,9 +26370,9 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
26166
26370
|
// src/role-envelope.ts
|
|
26167
26371
|
init_engine_detour();
|
|
26168
26372
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
26169
|
-
import { mkdir as
|
|
26373
|
+
import { mkdir as mkdir6, writeFile as writeFile12 } from "node:fs/promises";
|
|
26170
26374
|
import { createServer } from "node:net";
|
|
26171
|
-
import {
|
|
26375
|
+
import { dirname as dirname24, join as join41 } from "node:path";
|
|
26172
26376
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
26173
26377
|
|
|
26174
26378
|
// src/gatekeeper-pass-envelope.ts
|
|
@@ -26253,25 +26457,68 @@ async function requireGatekeeperPass(options) {
|
|
|
26253
26457
|
}
|
|
26254
26458
|
}
|
|
26255
26459
|
|
|
26460
|
+
// src/host-native-method.ts
|
|
26461
|
+
import { lstat as lstat7, mkdir as mkdir5, readlink, realpath as realpath7, symlink } from "node:fs/promises";
|
|
26462
|
+
import { basename as basename9, dirname as dirname23, join as join40 } from "node:path";
|
|
26463
|
+
var HOST_METHOD_PLUGIN_NAME = "ak-methods";
|
|
26464
|
+
var packagedMethodsDir = (root) => join40(root, "resources", "methods");
|
|
26465
|
+
var packagedMethodPluginDir = (root) => join40(root, "dist", "method-host-plugin");
|
|
26466
|
+
function hostMethodSkills(methods) {
|
|
26467
|
+
return Object.freeze(methods.flatMap((method) => {
|
|
26468
|
+
if (method.kind !== "skill") return [];
|
|
26469
|
+
const name = basename9(dirname23(method.path));
|
|
26470
|
+
return name ? [Object.freeze({ name })] : [];
|
|
26471
|
+
}));
|
|
26472
|
+
}
|
|
26473
|
+
var alreadyPrefixed = (prompt, token) => {
|
|
26474
|
+
const text = prompt.trimStart();
|
|
26475
|
+
return text === token || text.startsWith(`${token} `) || text.startsWith(`${token}
|
|
26476
|
+
`);
|
|
26477
|
+
};
|
|
26478
|
+
function prefixMethodInvocation(token, prompt) {
|
|
26479
|
+
if (alreadyPrefixed(prompt, token)) return prompt;
|
|
26480
|
+
return prompt ? `${token} ${prompt}` : token;
|
|
26481
|
+
}
|
|
26482
|
+
function applyClaudeSkillInvocation(methods, prompt) {
|
|
26483
|
+
const skills = hostMethodSkills(methods);
|
|
26484
|
+
if (skills.length !== 1) return prompt;
|
|
26485
|
+
return prefixMethodInvocation(`/${HOST_METHOD_PLUGIN_NAME}:${skills[0].name}`, prompt);
|
|
26486
|
+
}
|
|
26487
|
+
function applyCodexSkillInvocation(methods, prompt) {
|
|
26488
|
+
return hostMethodSkills(methods).reduceRight(
|
|
26489
|
+
(invocation, skill) => prefixMethodInvocation(`$${skill.name}`, invocation),
|
|
26490
|
+
prompt
|
|
26491
|
+
);
|
|
26492
|
+
}
|
|
26493
|
+
async function installWorkspaceMethodSkills(cwd, packageRoot) {
|
|
26494
|
+
const target = await realpath7(packagedMethodsDir(packageRoot));
|
|
26495
|
+
const link = join40(cwd, ".agents", "skills");
|
|
26496
|
+
try {
|
|
26497
|
+
const stat2 = await lstat7(link);
|
|
26498
|
+
if (!stat2.isSymbolicLink() || await realpath7(link) !== target) {
|
|
26499
|
+
const detail = stat2.isSymbolicLink() ? `symlink to ${await readlink(link)}` : "non-symlink entry";
|
|
26500
|
+
throw new Error(`workspace method catalog conflict at ${link}: ${detail}`);
|
|
26501
|
+
}
|
|
26502
|
+
return;
|
|
26503
|
+
} catch (error) {
|
|
26504
|
+
if (error.code !== "ENOENT") throw error;
|
|
26505
|
+
}
|
|
26506
|
+
await mkdir5(dirname23(link), { recursive: true });
|
|
26507
|
+
try {
|
|
26508
|
+
await symlink(target, link);
|
|
26509
|
+
} catch (error) {
|
|
26510
|
+
if (error.code !== "EEXIST") throw error;
|
|
26511
|
+
if (await realpath7(link).catch(() => "") !== target) {
|
|
26512
|
+
throw new Error(`workspace method catalog conflict at ${link}`);
|
|
26513
|
+
}
|
|
26514
|
+
}
|
|
26515
|
+
}
|
|
26516
|
+
|
|
26256
26517
|
// src/role-envelope.ts
|
|
26257
26518
|
init_packaged_role_registry();
|
|
26258
|
-
init_method_skill();
|
|
26259
26519
|
init_role_activation_flags();
|
|
26260
26520
|
init_submission_correctable_error();
|
|
26261
26521
|
init_navigator_invocation_identity();
|
|
26262
|
-
function buildSkillExpansion(methodSkills, prompt) {
|
|
26263
|
-
if (methodSkills.size !== 1) return void 0;
|
|
26264
|
-
const entry = methodSkills.entries().next().value;
|
|
26265
|
-
if (entry === void 0) return void 0;
|
|
26266
|
-
const [name, method] = entry;
|
|
26267
|
-
return Object.freeze({
|
|
26268
|
-
name,
|
|
26269
|
-
location: method.path,
|
|
26270
|
-
content: method.body,
|
|
26271
|
-
// Non-pi typed chain keeps original task bytes (ticket #822 r3); no consumer trim.
|
|
26272
|
-
userMessage: prompt
|
|
26273
|
-
});
|
|
26274
|
-
}
|
|
26275
26522
|
async function listen(server, path) {
|
|
26276
26523
|
await new Promise((resolve21, reject) => {
|
|
26277
26524
|
server.once("error", reject);
|
|
@@ -26306,21 +26553,14 @@ async function prepareRoleEnvelope(options) {
|
|
|
26306
26553
|
const calls = [];
|
|
26307
26554
|
const customEntries = [];
|
|
26308
26555
|
const sessionEntries = [];
|
|
26309
|
-
const methodSkills = /* @__PURE__ */ new Map();
|
|
26310
26556
|
let preferredTools = [];
|
|
26311
26557
|
let rejection;
|
|
26312
26558
|
let infrastructureRoundFailure;
|
|
26313
26559
|
const hostAbort = new AbortController();
|
|
26314
26560
|
const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID8();
|
|
26315
|
-
await
|
|
26316
|
-
|
|
26317
|
-
|
|
26318
|
-
const name = basename9(dirname23(method.path));
|
|
26319
|
-
const raw = await readFile23(method.path, "utf8");
|
|
26320
|
-
methodSkills.set(name, { path: method.path, body: stripSkillFrontmatter(raw).trim() });
|
|
26321
|
-
}
|
|
26322
|
-
let sessionFile = options.sessionFile ?? join40(request.runDirectory, "session", "session.jsonl");
|
|
26323
|
-
await mkdir5(dirname23(sessionFile), { recursive: true });
|
|
26561
|
+
await mkdir6(request.runDirectory, { recursive: true });
|
|
26562
|
+
let sessionFile = options.sessionFile ?? join41(request.runDirectory, "session", "session.jsonl");
|
|
26563
|
+
await mkdir6(dirname24(sessionFile), { recursive: true });
|
|
26324
26564
|
if (request.continuation.kind !== "resume") {
|
|
26325
26565
|
try {
|
|
26326
26566
|
await writeFile12(
|
|
@@ -26351,7 +26591,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
26351
26591
|
getLeafEntry: () => sessionEntries.at(-1),
|
|
26352
26592
|
getLeafId: () => runId,
|
|
26353
26593
|
getEntries: () => sessionEntries,
|
|
26354
|
-
getSessionDir: () =>
|
|
26594
|
+
getSessionDir: () => dirname24(sessionFile),
|
|
26355
26595
|
getSessionFile: () => sessionFile,
|
|
26356
26596
|
getHeader: () => ({ type: "session", id: runId }),
|
|
26357
26597
|
setSessionFile(path) {
|
|
@@ -26386,8 +26626,9 @@ async function prepareRoleEnvelope(options) {
|
|
|
26386
26626
|
deliverSubmissionRejection(_value) {
|
|
26387
26627
|
},
|
|
26388
26628
|
capabilities: {
|
|
26389
|
-
|
|
26390
|
-
|
|
26629
|
+
// #922: native loaders own expansion; package does not pre-read bodies (ADR 0032).
|
|
26630
|
+
skillExpansion() {
|
|
26631
|
+
return void 0;
|
|
26391
26632
|
}
|
|
26392
26633
|
},
|
|
26393
26634
|
registerFlag(name, definition) {
|
|
@@ -26726,10 +26967,9 @@ async function prepareRoleEnvelope(options) {
|
|
|
26726
26967
|
message: { role: "user", content: prompt }
|
|
26727
26968
|
});
|
|
26728
26969
|
}
|
|
26729
|
-
const methodPrompt = (await Promise.all(request.methods.map(({ path }) => readFile23(path, "utf8")))).join("\n\n");
|
|
26730
26970
|
const promptResults = await emit("before_agent_start", {
|
|
26731
26971
|
prompt,
|
|
26732
|
-
systemPrompt:
|
|
26972
|
+
systemPrompt: "",
|
|
26733
26973
|
systemPromptOptions: {}
|
|
26734
26974
|
});
|
|
26735
26975
|
const systemPromptParts = promptResults.flatMap((value) => {
|
|
@@ -26737,7 +26977,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
26737
26977
|
if (!("systemPrompt" in value) || typeof value.systemPrompt !== "string") return [];
|
|
26738
26978
|
return [value.systemPrompt];
|
|
26739
26979
|
});
|
|
26740
|
-
const systemPromptBody = systemPromptParts.
|
|
26980
|
+
const systemPromptBody = systemPromptParts.join("\n\n");
|
|
26741
26981
|
const readingMaterials = [];
|
|
26742
26982
|
for (const value of promptResults) {
|
|
26743
26983
|
if (typeof value !== "object" || value === null) continue;
|
|
@@ -26750,6 +26990,13 @@ async function prepareRoleEnvelope(options) {
|
|
|
26750
26990
|
throw new Error(`terminating tool not registered after activation: ${terminatingToolName}`);
|
|
26751
26991
|
}
|
|
26752
26992
|
const jsonSchema = terminatingToolJsonSchema(terminating.parameters);
|
|
26993
|
+
if (request.host === "codex" && hostMethodSkills(request.methods).length > 0) {
|
|
26994
|
+
const packageRoot = options.dependencies.packageRoot;
|
|
26995
|
+
if (typeof packageRoot !== "string" || packageRoot === "") {
|
|
26996
|
+
throw new Error("codex project Skill catalog requires packageRoot");
|
|
26997
|
+
}
|
|
26998
|
+
await installWorkspaceMethodSkills(request.cwd, packageRoot);
|
|
26999
|
+
}
|
|
26753
27000
|
return {
|
|
26754
27001
|
mcpServers: [{
|
|
26755
27002
|
name: `ak-${request.activation.role}`,
|
|
@@ -26787,7 +27034,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
26787
27034
|
init_session_identity();
|
|
26788
27035
|
|
|
26789
27036
|
// src/headless-host/description.ts
|
|
26790
|
-
import { join as
|
|
27037
|
+
import { join as join42 } from "node:path";
|
|
26791
27038
|
function isClaudePrintDescription(description) {
|
|
26792
27039
|
return description.protocol === "claude-print";
|
|
26793
27040
|
}
|
|
@@ -26795,7 +27042,7 @@ function isCodexExecDescription(description) {
|
|
|
26795
27042
|
return description.protocol === "codex-exec";
|
|
26796
27043
|
}
|
|
26797
27044
|
function resolveHeadlessBinary(description, operatorHome) {
|
|
26798
|
-
return
|
|
27045
|
+
return join42(operatorHome, ...description.binaryFromHome);
|
|
26799
27046
|
}
|
|
26800
27047
|
function headlessTurnArgs(options) {
|
|
26801
27048
|
const { description } = options;
|
|
@@ -26807,6 +27054,7 @@ function headlessTurnArgs(options) {
|
|
|
26807
27054
|
description.jsonSchemaFlag,
|
|
26808
27055
|
JSON.stringify(options.jsonSchema)
|
|
26809
27056
|
];
|
|
27057
|
+
if (options.pluginDir) args.push("--plugin-dir", options.pluginDir);
|
|
26810
27058
|
if (options.mcpConfigPath !== void 0 && options.mcpConfigPath !== "") {
|
|
26811
27059
|
args.push(description.mcpConfigFlag, options.mcpConfigPath);
|
|
26812
27060
|
}
|
|
@@ -27003,7 +27251,6 @@ function codexTurnArgs(options) {
|
|
|
27003
27251
|
args.push("resume", options.session.id);
|
|
27004
27252
|
}
|
|
27005
27253
|
args.push("--json");
|
|
27006
|
-
args.push("--ignore-user-config", "--ignore-rules");
|
|
27007
27254
|
const roots = (options.writableRoots ?? []).filter((root) => root !== "");
|
|
27008
27255
|
if (roots.length > 0) {
|
|
27009
27256
|
args.push(
|
|
@@ -27051,7 +27298,7 @@ import { spawn as spawn4, spawnSync } from "node:child_process";
|
|
|
27051
27298
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
27052
27299
|
import { existsSync as existsSync13 } from "node:fs";
|
|
27053
27300
|
import { writeFile as writeFile13 } from "node:fs/promises";
|
|
27054
|
-
import { dirname as
|
|
27301
|
+
import { dirname as dirname25, isAbsolute as isAbsolute11, join as join43, resolve as resolve20 } from "node:path";
|
|
27055
27302
|
|
|
27056
27303
|
// src/external-host-turn-loop.ts
|
|
27057
27304
|
init_host_contracts();
|
|
@@ -27270,8 +27517,8 @@ function formatCodexFailurePayload(payload) {
|
|
|
27270
27517
|
function cwdIsGitWorkTree(cwd) {
|
|
27271
27518
|
let dir = cwd;
|
|
27272
27519
|
for (; ; ) {
|
|
27273
|
-
if (existsSync13(
|
|
27274
|
-
const parent =
|
|
27520
|
+
if (existsSync13(join43(dir, ".git"))) return true;
|
|
27521
|
+
const parent = dirname25(dir);
|
|
27275
27522
|
if (parent === dir) return false;
|
|
27276
27523
|
dir = parent;
|
|
27277
27524
|
}
|
|
@@ -27460,7 +27707,8 @@ function buildTurnArgs(options) {
|
|
|
27460
27707
|
mcpConfigPath: options.mcpConfigPath,
|
|
27461
27708
|
...options.model === void 0 ? {} : { model: options.model },
|
|
27462
27709
|
...options.effort === void 0 ? {} : { effort: options.effort },
|
|
27463
|
-
session: { kind: options.sessionKind, id: options.sessionId }
|
|
27710
|
+
session: { kind: options.sessionKind, id: options.sessionId },
|
|
27711
|
+
...options.pluginDir === void 0 ? {} : { pluginDir: options.pluginDir }
|
|
27464
27712
|
});
|
|
27465
27713
|
}
|
|
27466
27714
|
function createHeadlessRoleTurnHost(config) {
|
|
@@ -27477,23 +27725,36 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
27477
27725
|
await config.sessionIdentity.bind(request.principal, sessionId);
|
|
27478
27726
|
}
|
|
27479
27727
|
const env = { ...process.env, ...config.env ?? {} };
|
|
27480
|
-
const systemPromptPath =
|
|
27728
|
+
const systemPromptPath = join43(request.runDirectory, "headless-system-prompt.txt");
|
|
27481
27729
|
await writeFile13(systemPromptPath, systemPrompt, "utf8");
|
|
27482
27730
|
let mcpConfigPath;
|
|
27483
27731
|
let outputSchemaPath;
|
|
27732
|
+
let pluginDir;
|
|
27733
|
+
let applyMethodPrompt = codex ? (prompt) => applyCodexSkillInvocation(request.methods, prompt) : (prompt) => prompt;
|
|
27484
27734
|
if (codex) {
|
|
27485
|
-
outputSchemaPath =
|
|
27486
|
-
|
|
27487
|
-
|
|
27488
|
-
|
|
27735
|
+
outputSchemaPath = join43(request.runDirectory, "headless-output-schema.json");
|
|
27736
|
+
await writeFile13(
|
|
27737
|
+
outputSchemaPath,
|
|
27738
|
+
`${JSON.stringify(closeJsonSchemaForCodex(prepared.jsonSchema), null, 2)}
|
|
27739
|
+
`,
|
|
27740
|
+
"utf8"
|
|
27741
|
+
);
|
|
27489
27742
|
} else {
|
|
27490
|
-
mcpConfigPath =
|
|
27743
|
+
mcpConfigPath = join43(request.runDirectory, "headless-mcp-config.json");
|
|
27491
27744
|
await writeFile13(
|
|
27492
27745
|
mcpConfigPath,
|
|
27493
27746
|
`${JSON.stringify(headlessMcpConfigDocument(prepared.mcpServers), null, 2)}
|
|
27494
27747
|
`,
|
|
27495
27748
|
"utf8"
|
|
27496
27749
|
);
|
|
27750
|
+
if (hostMethodSkills(request.methods).length > 0) {
|
|
27751
|
+
const packageRoot = env.AK_PACKAGE_ROOT ?? process.env.AK_PACKAGE_ROOT;
|
|
27752
|
+
if (typeof packageRoot !== "string" || packageRoot === "") {
|
|
27753
|
+
throw new Error("claude method plugin-dir requires AK_PACKAGE_ROOT");
|
|
27754
|
+
}
|
|
27755
|
+
pluginDir = packagedMethodPluginDir(packageRoot);
|
|
27756
|
+
applyMethodPrompt = (prompt) => applyClaudeSkillInvocation(request.methods, prompt);
|
|
27757
|
+
}
|
|
27497
27758
|
}
|
|
27498
27759
|
const sessionParent = config.sessionIdentity.resolveSessionFile(request.principal);
|
|
27499
27760
|
outcome = await driveExternalRoleTurnRounds(prepared, request, {
|
|
@@ -27518,7 +27779,8 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
27518
27779
|
sessionId,
|
|
27519
27780
|
sessionKind,
|
|
27520
27781
|
cwd: request.cwd,
|
|
27521
|
-
...gitCommonDir === void 0 ? {} : { writableRoots: [gitCommonDir] }
|
|
27782
|
+
...gitCommonDir === void 0 ? {} : { writableRoots: [gitCommonDir] },
|
|
27783
|
+
...pluginDir === void 0 ? {} : { pluginDir }
|
|
27522
27784
|
});
|
|
27523
27785
|
} catch (error) {
|
|
27524
27786
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -27535,7 +27797,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
27535
27797
|
args,
|
|
27536
27798
|
cwd: request.cwd,
|
|
27537
27799
|
env,
|
|
27538
|
-
stdin: prompt,
|
|
27800
|
+
stdin: applyMethodPrompt(prompt),
|
|
27539
27801
|
...abortSignal === void 0 ? {} : { signal: abortSignal },
|
|
27540
27802
|
...request.timeoutMs === void 0 ? {} : { timeoutMs: request.timeoutMs },
|
|
27541
27803
|
onStdoutLine(line2) {
|