@tickernelz/wardmote-adapter-utils 2026.1109.0 → 2026.1112.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/acpx-engine/composed-run-characterization.test.js +13 -16
- package/dist/acpx-engine/composed-run-characterization.test.js.map +1 -1
- package/dist/acpx-engine/ephemeral-session-environment.test.js +1 -1
- package/dist/acpx-engine/ephemeral-session-environment.test.js.map +1 -1
- package/dist/acpx-engine/execute-identity.test.js +3 -3
- package/dist/acpx-engine/execute-identity.test.js.map +1 -1
- package/dist/acpx-engine/execute.d.ts +2 -28
- package/dist/acpx-engine/execute.d.ts.map +1 -1
- package/dist/acpx-engine/execute.js +142 -203
- package/dist/acpx-engine/execute.js.map +1 -1
- package/dist/acpx-engine/execute.test.js +171 -187
- package/dist/acpx-engine/execute.test.js.map +1 -1
- package/dist/acpx-engine/filesystem-protocol.test.js +1 -1
- package/dist/acpx-engine/filesystem-protocol.test.js.map +1 -1
- package/dist/acpx-engine/managed-codex-skills-manifest.d.ts +3 -0
- package/dist/acpx-engine/managed-codex-skills-manifest.d.ts.map +1 -0
- package/dist/acpx-engine/managed-codex-skills-manifest.js +30 -0
- package/dist/acpx-engine/managed-codex-skills-manifest.js.map +1 -0
- package/dist/acpx-engine/managed-codex-skills-manifest.test.d.ts +2 -0
- package/dist/acpx-engine/managed-codex-skills-manifest.test.d.ts.map +1 -0
- package/dist/acpx-engine/managed-codex-skills-manifest.test.js +29 -0
- package/dist/acpx-engine/managed-codex-skills-manifest.test.js.map +1 -0
- package/dist/acpx-engine/operator-stop.test.js +1 -1
- package/dist/acpx-engine/operator-stop.test.js.map +1 -1
- package/dist/acpx-engine/remote-spawn-smoke.test.js +5 -5
- package/dist/acpx-engine/remote-spawn-smoke.test.js.map +1 -1
- package/dist/acpx-engine/run-contracts.d.ts +5 -15
- package/dist/acpx-engine/run-contracts.d.ts.map +1 -1
- package/dist/acpx-engine/run-contracts.js.map +1 -1
- package/dist/acpx-engine/run-fault-matrix.test.js +7 -7
- package/dist/acpx-engine/run-fault-matrix.test.js.map +1 -1
- package/dist/acpx-engine/run-site-sandbox.d.ts +5 -12
- package/dist/acpx-engine/run-site-sandbox.d.ts.map +1 -1
- package/dist/acpx-engine/run-site-sandbox.js +4 -16
- package/dist/acpx-engine/run-site-sandbox.js.map +1 -1
- package/dist/acpx-engine/run-site-sandbox.test.js +10 -13
- package/dist/acpx-engine/run-site-sandbox.test.js.map +1 -1
- package/dist/acpx-engine/settlement-characterization.test.js +20 -20
- package/dist/acpx-engine/settlement-characterization.test.js.map +1 -1
- package/dist/acpx-engine/spawn-smoke.test.js +6 -6
- package/dist/acpx-engine/spawn-smoke.test.js.map +1 -1
- package/dist/acpx-engine/startup-characterization.test.js +14 -18
- package/dist/acpx-engine/startup-characterization.test.js.map +1 -1
- package/dist/acpx-engine/startup-timing.d.ts +27 -45
- package/dist/acpx-engine/startup-timing.d.ts.map +1 -1
- package/dist/acpx-engine/startup-timing.js +1 -19
- package/dist/acpx-engine/startup-timing.js.map +1 -1
- package/dist/acpx-engine/turn-characterization.test.js +3 -3
- package/dist/acpx-engine/turn-characterization.test.js.map +1 -1
- package/dist/acpx-engine/turn-sequence.js +1 -1
- package/dist/acpx-engine/turn-sequence.js.map +1 -1
- package/dist/chat-file-delivery.d.ts +3 -3
- package/dist/chat-file-delivery.d.ts.map +1 -1
- package/dist/chat-file-delivery.js +5 -5
- package/dist/chat-file-delivery.js.map +1 -1
- package/dist/chat-file-delivery.test.js +10 -10
- package/dist/chat-file-delivery.test.js.map +1 -1
- package/dist/command-managed-runtime.js +5 -5
- package/dist/command-managed-runtime.js.map +1 -1
- package/dist/command-managed-runtime.test.js +36 -38
- package/dist/command-managed-runtime.test.js.map +1 -1
- package/dist/directory-merge-lock.test.js +1 -1
- package/dist/directory-merge-lock.test.js.map +1 -1
- package/dist/execution-target-sandbox.test.js +259 -267
- package/dist/execution-target-sandbox.test.js.map +1 -1
- package/dist/execution-target-stdin-race.test.js +55 -65
- package/dist/execution-target-stdin-race.test.js.map +1 -1
- package/dist/execution-target.d.ts +6 -36
- package/dist/execution-target.d.ts.map +1 -1
- package/dist/execution-target.js +35 -86
- package/dist/execution-target.js.map +1 -1
- package/dist/execution-target.test.js +1 -1
- package/dist/execution-target.test.js.map +1 -1
- package/dist/forbidden-config-env.test.js +2 -2
- package/dist/forbidden-config-env.test.js.map +1 -1
- package/dist/git-workspace-sync.d.ts +2 -2
- package/dist/git-workspace-sync.d.ts.map +1 -1
- package/dist/git-workspace-sync.js +7 -7
- package/dist/git-workspace-sync.js.map +1 -1
- package/dist/git-workspace-sync.test.js +61 -61
- package/dist/git-workspace-sync.test.js.map +1 -1
- package/dist/github-launcher-environment.test.js +5 -5
- package/dist/github-launcher-environment.test.js.map +1 -1
- package/dist/github-launcher.js +8 -8
- package/dist/github-launcher.test.js +6 -6
- package/dist/github-launcher.test.js.map +1 -1
- package/dist/http2-bridge-server.test.js +1 -1
- package/dist/http2-bridge-server.test.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/local-process-sandbox.js +7 -7
- package/dist/local-process-sandbox.js.map +1 -1
- package/dist/local-process-sandbox.test.js +16 -16
- package/dist/local-process-sandbox.test.js.map +1 -1
- package/dist/mcp-isolation.integration.test.js +4 -4
- package/dist/mcp-isolation.integration.test.js.map +1 -1
- package/dist/prompt-sections.test.js +11 -11
- package/dist/prompt-sections.test.js.map +1 -1
- package/dist/provider-models/claude.d.ts +0 -1
- package/dist/provider-models/claude.d.ts.map +1 -1
- package/dist/provider-models/claude.js +0 -1
- package/dist/provider-models/claude.js.map +1 -1
- package/dist/remote-managed-runtime.js +6 -6
- package/dist/remote-managed-runtime.js.map +1 -1
- package/dist/remote-managed-runtime.test.js +14 -14
- package/dist/remote-managed-runtime.test.js.map +1 -1
- package/dist/retired-marker-names.d.ts +2 -0
- package/dist/retired-marker-names.d.ts.map +1 -0
- package/dist/retired-marker-names.js +2 -0
- package/dist/retired-marker-names.js.map +1 -0
- package/dist/retired-skill-names.d.ts +3 -0
- package/dist/retired-skill-names.d.ts.map +1 -0
- package/dist/retired-skill-names.js +8 -0
- package/dist/retired-skill-names.js.map +1 -0
- package/dist/runner-connectivity.d.ts +5 -5
- package/dist/runner-connectivity.d.ts.map +1 -1
- package/dist/runner-connectivity.js +11 -11
- package/dist/runner-connectivity.js.map +1 -1
- package/dist/runner-connectivity.test.js +21 -21
- package/dist/runner-connectivity.test.js.map +1 -1
- package/dist/runtime-progress.d.ts.map +1 -1
- package/dist/runtime-progress.js +1 -4
- package/dist/runtime-progress.js.map +1 -1
- package/dist/runtime-progress.test.js +13 -13
- package/dist/runtime-progress.test.js.map +1 -1
- package/dist/sandbox-callback-bridge.d.ts +1 -16
- package/dist/sandbox-callback-bridge.d.ts.map +1 -1
- package/dist/sandbox-callback-bridge.js +28 -61
- package/dist/sandbox-callback-bridge.js.map +1 -1
- package/dist/sandbox-callback-bridge.test.js +67 -88
- package/dist/sandbox-callback-bridge.test.js.map +1 -1
- package/dist/sandbox-file-sync.test.js +9 -9
- package/dist/sandbox-file-sync.test.js.map +1 -1
- package/dist/sandbox-managed-runtime.d.ts +0 -30
- package/dist/sandbox-managed-runtime.d.ts.map +1 -1
- package/dist/sandbox-managed-runtime.js +12 -34
- package/dist/sandbox-managed-runtime.js.map +1 -1
- package/dist/sandbox-managed-runtime.test.js +130 -140
- package/dist/sandbox-managed-runtime.test.js.map +1 -1
- package/dist/sandbox-run-log-stream.js +1 -1
- package/dist/sandbox-run-log-stream.js.map +1 -1
- package/dist/server-utils-env.test.js +8 -7
- package/dist/server-utils-env.test.js.map +1 -1
- package/dist/server-utils.d.ts +118 -144
- package/dist/server-utils.d.ts.map +1 -1
- package/dist/server-utils.js +243 -270
- package/dist/server-utils.js.map +1 -1
- package/dist/server-utils.test.js +274 -257
- package/dist/server-utils.test.js.map +1 -1
- package/dist/session-compaction.js +1 -1
- package/dist/session-compaction.js.map +1 -1
- package/dist/skill-library-manifest.d.ts +2 -2
- package/dist/skill-library-manifest.d.ts.map +1 -1
- package/dist/skill-library-manifest.test.js +4 -4
- package/dist/skill-library-manifest.test.js.map +1 -1
- package/dist/ssh-fixture.test.js +57 -57
- package/dist/ssh-fixture.test.js.map +1 -1
- package/dist/ssh.d.ts.map +1 -1
- package/dist/ssh.js +16 -38
- package/dist/ssh.js.map +1 -1
- package/dist/test-fixtures/prompt-context.d.ts +5 -5
- package/dist/test-fixtures/prompt-context.js +5 -5
- package/dist/test-fixtures/prompt-context.js.map +1 -1
- package/dist/tool-profile.d.ts +1 -1
- package/dist/tool-profile.d.ts.map +1 -1
- package/dist/tool-profile.js +1 -1
- package/dist/tool-profile.js.map +1 -1
- package/dist/types.d.ts +13 -31
- package/dist/types.d.ts.map +1 -1
- package/dist/wardmote-mcp-mount.d.ts +9 -9
- package/dist/wardmote-mcp-mount.d.ts.map +1 -1
- package/dist/wardmote-mcp-mount.js +9 -9
- package/dist/wardmote-mcp-mount.js.map +1 -1
- package/dist/wardmote-mcp.d.ts +23 -25
- package/dist/wardmote-mcp.d.ts.map +1 -1
- package/dist/wardmote-mcp.js +32 -33
- package/dist/wardmote-mcp.js.map +1 -1
- package/dist/wardmote-mcp.test.js +52 -52
- package/dist/wardmote-mcp.test.js.map +1 -1
- package/dist/wardmote-runner-permissions.d.ts +14 -19
- package/dist/wardmote-runner-permissions.d.ts.map +1 -1
- package/dist/wardmote-runner-permissions.js +8 -13
- package/dist/wardmote-runner-permissions.js.map +1 -1
- package/dist/wardmote-runner-permissions.test.js +32 -32
- package/dist/wardmote-runner-permissions.test.js.map +1 -1
- package/dist/workspace-git-stream.test.js +1 -1
- package/dist/workspace-git-stream.test.js.map +1 -1
- package/dist/workspace-manifest.test.js +3 -3
- package/dist/workspace-manifest.test.js.map +1 -1
- package/dist/workspace-restore-diagnostics.js +1 -1
- package/dist/workspace-restore-diagnostics.js.map +1 -1
- package/dist/workspace-restore-diagnostics.test.js +5 -5
- package/dist/workspace-restore-diagnostics.test.js.map +1 -1
- package/dist/workspace-restore-merge.js +3 -3
- package/dist/workspace-restore-merge.js.map +1 -1
- package/dist/workspace-restore-merge.test.js +50 -56
- package/dist/workspace-restore-merge.test.js.map +1 -1
- package/dist/workspace-restore-result.test.js +2 -2
- package/dist/workspace-restore-result.test.js.map +1 -1
- package/dist/workspace-restore-teardown.test.js +6 -6
- package/dist/workspace-restore-teardown.test.js.map +1 -1
- package/package.json +2 -2
|
@@ -9,15 +9,16 @@ import { promisify } from "node:util";
|
|
|
9
9
|
import { createHash, randomUUID } from "node:crypto";
|
|
10
10
|
import { parseFrontmatterMarkdown } from "@tickernelz/wardmote-shared";
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
12
|
-
import {
|
|
12
|
+
import { readManagedCodexSkillsManifest, writeManagedCodexSkillsManifest } from "./managed-codex-skills-manifest.js";
|
|
13
|
+
import { adapterExecutionTargetSessionIdentity, describeAdapterExecutionTarget, adapterExecutionTargetDuplexObservabilityRecorder, adapterExecutionTargetEnablesSandboxDuplexBridge, formatAdapterExecutionTimeoutErrorMessage, formatAdapterExecutionTimeoutStartLogLine, prepareAdapterExecutionTargetRuntime, readAdapterExecutionTarget, resolveAdapterExecutionTargetTimeout, resolveReferencedSourceIgnore, runAdapterExecutionTargetShellCommand, startAdapterExecutionTargetWardmoteBridge, startAdapterExecutionTargetProcessSessionBridge, } from "@tickernelz/wardmote-adapter-utils/execution-target";
|
|
13
14
|
import { captureLocalProcess, capturedProcessExited, killCapturedLocalProcess } from "./local-process-control.js";
|
|
14
15
|
import { DUPLEX_CHANNEL_LOST_ERROR_CODE } from "../bridge-transport-contract.js";
|
|
15
16
|
import { classifyToolDefinitionFailure, formatTerminalSessionFailure, sanitizeTerminalSessionFailure, } from "./terminal-session-failure.js";
|
|
16
|
-
import {
|
|
17
|
+
import { resolveDefaultWardmoteHomeDir } from "@tickernelz/wardmote-shared/home-paths";
|
|
17
18
|
import { classifyWorkspaceRestoreFailure, describeWorkspaceRestoreFailure, } from "../workspace-restore-merge.js";
|
|
18
|
-
import {
|
|
19
|
-
import { WARDMOTE_MCP_SERVER_NAME,
|
|
20
|
-
import {
|
|
19
|
+
import { wardmoteAgentPromptTemplate, DEFAULT_WARDMOTE_CONVERSATION_PROMPT_TEMPLATE, applyWardmoteWorkspaceEnv, asNumber, asString, buildInvocationEnvForLogs, buildWardmoteEnv, ensureAbsoluteDirectory, ensurePathInEnv, ensureWardmoteSkillSymlink, isForbiddenConfigEnvKey, isWardmoteExternalChatTurn, isWardmoteRuntimeEnvKey, joinPromptSections, materializeWardmoteSkillCopy, parseObject, isWardmoteSkillSourceMissing, readWardmoteRuntimeSkillEntries, readWardmoteIssueWorkModeFromContext, renderTemplate, resolveWardmoteInstanceRootForAdapter, hydrateFreshSessionHandoff, selectInitialCommunicationGuidance, selectWardmotePromptSections, resolveLegacyWardmoteDesiredSkillNames, removeMaintainerOnlySkillSymlinks, removeRetiredBundledSkillLinks, rewriteWorkspaceCwdEnvVarsForExecution, shapeWardmoteWorkspaceEnvForExecution, } from "@tickernelz/wardmote-adapter-utils/server-utils";
|
|
20
|
+
import { WARDMOTE_MCP_SERVER_NAME, wardmoteAccessGuidance, wardmoteAccessMode, wardmoteMcpToolsets, } from "@tickernelz/wardmote-adapter-utils/wardmote-mcp";
|
|
21
|
+
import { wardmoteMcpHttpTarget } from "@tickernelz/wardmote-adapter-utils/wardmote-mcp-mount";
|
|
21
22
|
import { shellQuote } from "@tickernelz/wardmote-adapter-utils/ssh";
|
|
22
23
|
import { runToolProfile } from "@tickernelz/wardmote-adapter-utils/tool-profile";
|
|
23
24
|
import { createEphemeralSessionEnvironmentStore } from "./ephemeral-session-environment.js";
|
|
@@ -31,7 +32,6 @@ import { createHostRunSite, } from "./run-site-host.js";
|
|
|
31
32
|
import { createSandboxRunSite } from "./run-site-sandbox.js";
|
|
32
33
|
import { createRuntimeSpanRunner, emitRunPhaseTiming, emitSkippedStartupStep, getActiveStepContext, measureStartupStep, NOOP_STARTUP_SPAN, NOOP_STARTUP_TRACE_CONTEXT, runWithRuntimeParent, setSandboxRootSpanAttributes, } from "./startup-timing.js";
|
|
33
34
|
const defaultModuleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
34
|
-
const WARDMOTE_MANAGED_CODEX_SKILLS_MANIFEST = ".paperclip-managed-skills.json";
|
|
35
35
|
const BENIGN_NES_CLOSE_STDERR = /method: ['"]nes\/close['"].*-32601/;
|
|
36
36
|
function routeChildStderr(state, chunk) {
|
|
37
37
|
if (state.logPath) {
|
|
@@ -93,19 +93,9 @@ function shortHash(value) {
|
|
|
93
93
|
export function buildSessionFingerprint(identity) {
|
|
94
94
|
return shortHash(identity);
|
|
95
95
|
}
|
|
96
|
-
/**
|
|
97
|
-
* Build the session key from the fingerprint and the outer-key identity. The key
|
|
98
|
-
* form is `paperclip:companyId:agentId:taskKey:fingerprint`.
|
|
99
|
-
*/
|
|
100
96
|
export function buildSessionKey(identity, fingerprint) {
|
|
101
97
|
return `paperclip:${identity.companyId}:${identity.agentId}:${identity.taskKey}:${fingerprint}`;
|
|
102
98
|
}
|
|
103
|
-
// ACPX runs inside the long-lived Paperclip server process. A local child needs
|
|
104
|
-
// a small amount of host context (PATH, locale, certificate/proxy settings, and
|
|
105
|
-
// provider authentication), but it must not inherit the server's complete
|
|
106
|
-
// environment. A runner-backed remote sandbox inherits no ambient host context
|
|
107
|
-
// at all. In particular, native-runner bootstrap and MCP credentials are host
|
|
108
|
-
// authority, not provider credentials.
|
|
109
99
|
const ACPX_INHERITED_HOST_ENV_KEYS = new Set([
|
|
110
100
|
"PATH",
|
|
111
101
|
"PATHEXT",
|
|
@@ -320,22 +310,22 @@ export async function referencedSourceContentSignature(localPath, ignoreResoluti
|
|
|
320
310
|
}
|
|
321
311
|
return hash.digest("hex").slice(0, 16);
|
|
322
312
|
}
|
|
323
|
-
function
|
|
324
|
-
const home = process.env.WARDMOTE_HOME?.trim() ||
|
|
313
|
+
function defaultWardmoteInstanceDir() {
|
|
314
|
+
const home = process.env.WARDMOTE_HOME?.trim() || resolveDefaultWardmoteHomeDir();
|
|
325
315
|
const instanceId = process.env.WARDMOTE_INSTANCE_ID?.trim() || "default";
|
|
326
|
-
return
|
|
316
|
+
return resolveWardmoteInstanceRootForAdapter({
|
|
327
317
|
homeDir: home,
|
|
328
318
|
instanceId,
|
|
329
319
|
});
|
|
330
320
|
}
|
|
331
321
|
function defaultStateDir(companyId, agentId) {
|
|
332
|
-
return path.join(
|
|
322
|
+
return path.join(defaultWardmoteInstanceDir(), "companies", companyId, "acp-engine", "agents", agentId);
|
|
333
323
|
}
|
|
334
324
|
function resolveManagedCodexHomeDir(companyId) {
|
|
335
|
-
return path.join(
|
|
325
|
+
return path.join(defaultWardmoteInstanceDir(), "companies", companyId, "codex-home");
|
|
336
326
|
}
|
|
337
327
|
function isCodexCredentialStoreHome(homePath) {
|
|
338
|
-
const companiesRoot = path.resolve(
|
|
328
|
+
const companiesRoot = path.resolve(defaultWardmoteInstanceDir(), "companies");
|
|
339
329
|
const resolved = path.resolve(homePath);
|
|
340
330
|
if (!resolved.startsWith(companiesRoot + path.sep))
|
|
341
331
|
return false;
|
|
@@ -346,7 +336,7 @@ function resolveManagedCodexApiKeyHomeDir(companyId, agentId) {
|
|
|
346
336
|
return path.join(defaultStateDir(companyId, agentId), "codex-home");
|
|
347
337
|
}
|
|
348
338
|
function resolveManagedGrokHomeDir(companyId) {
|
|
349
|
-
return path.join(
|
|
339
|
+
return path.join(defaultWardmoteInstanceDir(), "companies", companyId, "grok-home");
|
|
350
340
|
}
|
|
351
341
|
// Walk up from startDir looking for `node_modules/.bin/<binName>`. This matches
|
|
352
342
|
// npm/pnpm binary hoisting in packaged installs while preserving monorepo dev.
|
|
@@ -520,7 +510,7 @@ async function prepareManagedCodexHome(input) {
|
|
|
520
510
|
await fs.mkdir(targetHome, { recursive: true });
|
|
521
511
|
const targetAuth = path.join(targetHome, "auth.json");
|
|
522
512
|
if (apiKey && isCodexCredentialStoreHome(targetHome)) {
|
|
523
|
-
await onLog("stdout", `[
|
|
513
|
+
await onLog("stdout", `[wardmote] Refusing to write an API-key auth.json into credential-store entry "${targetHome}"; the bound account's stored login stays authoritative.\n`);
|
|
524
514
|
}
|
|
525
515
|
else if (apiKey) {
|
|
526
516
|
await writeFileAtomically({
|
|
@@ -539,7 +529,7 @@ async function prepareManagedCodexHome(input) {
|
|
|
539
529
|
if (await pathExists(source))
|
|
540
530
|
await ensureCopiedFile(path.join(targetHome, name), source);
|
|
541
531
|
}
|
|
542
|
-
await onLog("stdout", `[
|
|
532
|
+
await onLog("stdout", `[wardmote] Using Wardmote-managed ACPX Codex home "${targetHome}" (seeded from "${sourceHome}").\n`);
|
|
543
533
|
return targetHome;
|
|
544
534
|
}
|
|
545
535
|
async function hashPathContents(candidate, hash, relativePath, seenDirectories) {
|
|
@@ -574,7 +564,7 @@ async function hashPathContents(candidate, hash, relativePath, seenDirectories)
|
|
|
574
564
|
}
|
|
575
565
|
async function buildSkillSetKey(input) {
|
|
576
566
|
const hash = createHash("sha256");
|
|
577
|
-
hash.update(`
|
|
567
|
+
hash.update(`wardmote-acpx-${input.label}-skills:v1\n`);
|
|
578
568
|
const sorted = [...input.skills].sort((left, right) => left.runtimeName.localeCompare(right.runtimeName));
|
|
579
569
|
for (const entry of sorted) {
|
|
580
570
|
hash.update(`skill:${entry.key}:${entry.runtimeName}\n`);
|
|
@@ -583,15 +573,15 @@ async function buildSkillSetKey(input) {
|
|
|
583
573
|
return hash.digest("hex");
|
|
584
574
|
}
|
|
585
575
|
async function resolveSelectedRuntimeSkills(config, moduleDir) {
|
|
586
|
-
const allSkills = await
|
|
587
|
-
const desiredSkillNames =
|
|
576
|
+
const allSkills = await readWardmoteRuntimeSkillEntries(config, moduleDir);
|
|
577
|
+
const desiredSkillNames = resolveLegacyWardmoteDesiredSkillNames(config, allSkills);
|
|
588
578
|
const desiredSet = new Set(desiredSkillNames);
|
|
589
579
|
return {
|
|
590
580
|
allSkills,
|
|
591
581
|
// Missing-source entries never mount: buildSkillSetKey hashes each
|
|
592
582
|
// selected entry's path contents, and a nonexistent source would abort
|
|
593
583
|
// runtime construction over one broken skill.
|
|
594
|
-
selectedSkills: allSkills.filter((entry) => desiredSet.has(entry.key) && !
|
|
584
|
+
selectedSkills: allSkills.filter((entry) => desiredSet.has(entry.key) && !isWardmoteSkillSourceMissing(entry)),
|
|
595
585
|
desiredSkillNames,
|
|
596
586
|
};
|
|
597
587
|
}
|
|
@@ -612,20 +602,20 @@ async function prepareClaudeSkillRuntime(input) {
|
|
|
612
602
|
for (const entry of selectedSkills) {
|
|
613
603
|
const target = path.join(skillsHome, entry.runtimeName);
|
|
614
604
|
try {
|
|
615
|
-
const result = await
|
|
605
|
+
const result = await materializeWardmoteSkillCopy(entry.source, target);
|
|
616
606
|
const skillMdStat = await fs.stat(path.join(target, "SKILL.md")).catch(() => null);
|
|
617
607
|
if (!skillMdStat?.isFile()) {
|
|
618
608
|
await fs.rm(target, { recursive: true, force: true });
|
|
619
|
-
await input.onLog("stderr", `[
|
|
609
|
+
await input.onLog("stderr", `[wardmote] Skipped ACPX Claude skill "${entry.key}": the staged copy at ${target} has no usable SKILL.md.\n`);
|
|
620
610
|
continue;
|
|
621
611
|
}
|
|
622
612
|
materializedNames.push(entry.runtimeName);
|
|
623
613
|
if (result.skippedSymlinks.length > 0) {
|
|
624
|
-
await input.onLog("stdout", `[
|
|
614
|
+
await input.onLog("stdout", `[wardmote] Materialized ACPX Claude skill "${entry.runtimeName}" into ${skillsHome} and skipped ${result.skippedSymlinks.length} symlink(s).\n`);
|
|
625
615
|
}
|
|
626
616
|
}
|
|
627
617
|
catch (err) {
|
|
628
|
-
await input.onLog("stderr", `[
|
|
618
|
+
await input.onLog("stderr", `[wardmote] Failed to materialize ACPX Claude skill "${entry.key}" into ${skillsHome}: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
629
619
|
}
|
|
630
620
|
}
|
|
631
621
|
const selectedNames = materializedNames.sort();
|
|
@@ -644,7 +634,7 @@ async function prepareClaudeSkillRuntime(input) {
|
|
|
644
634
|
}));
|
|
645
635
|
const promptInstructions = selectedNames.length > 0
|
|
646
636
|
? [
|
|
647
|
-
"
|
|
637
|
+
"Wardmote has materialized selected runtime skills for this ACPX Claude session.",
|
|
648
638
|
`Skill root: ${skillsHome}`,
|
|
649
639
|
`Selected skills: ${selectedNames.join(", ")}`,
|
|
650
640
|
...skillDescriptions,
|
|
@@ -661,29 +651,11 @@ async function prepareClaudeSkillRuntime(input) {
|
|
|
661
651
|
},
|
|
662
652
|
promptInstructions,
|
|
663
653
|
commandNotes: selectedNames.length > 0
|
|
664
|
-
? [`Materialized ${selectedNames.length}
|
|
654
|
+
? [`Materialized ${selectedNames.length} Wardmote skill(s) for ACPX Claude at ${skillsHome}.`]
|
|
665
655
|
: [],
|
|
666
656
|
bundleDir: selectedNames.length > 0 ? skillsHome : null,
|
|
667
657
|
};
|
|
668
658
|
}
|
|
669
|
-
async function readManagedCodexSkillsManifest(skillsHome) {
|
|
670
|
-
const manifestPath = path.join(skillsHome, WARDMOTE_MANAGED_CODEX_SKILLS_MANIFEST);
|
|
671
|
-
try {
|
|
672
|
-
const raw = JSON.parse(await fs.readFile(manifestPath, "utf8"));
|
|
673
|
-
const parsed = parseObject(raw);
|
|
674
|
-
const skills = Array.isArray(parsed.managedSkillNames)
|
|
675
|
-
? parsed.managedSkillNames.filter((value) => typeof value === "string" && value.trim().length > 0)
|
|
676
|
-
: [];
|
|
677
|
-
return new Set(skills);
|
|
678
|
-
}
|
|
679
|
-
catch {
|
|
680
|
-
return new Set();
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
async function writeManagedCodexSkillsManifest(skillsHome, skillNames) {
|
|
684
|
-
const managedSkillNames = Array.from(new Set(skillNames)).sort();
|
|
685
|
-
await fs.writeFile(path.join(skillsHome, WARDMOTE_MANAGED_CODEX_SKILLS_MANIFEST), `${JSON.stringify({ version: 1, managedSkillNames }, null, 2)}\n`, "utf8");
|
|
686
|
-
}
|
|
687
659
|
async function removeSkillTarget(target) {
|
|
688
660
|
const existing = await fs.lstat(target).catch(() => null);
|
|
689
661
|
if (!existing)
|
|
@@ -699,7 +671,7 @@ async function reconcileManagedCodexSkills(input) {
|
|
|
699
671
|
if (desired.has(name))
|
|
700
672
|
continue;
|
|
701
673
|
if (await removeSkillTarget(path.join(input.skillsHome, name))) {
|
|
702
|
-
await input.onLog("stdout", `[
|
|
674
|
+
await input.onLog("stdout", `[wardmote] Revoked ACPX Codex skill "${name}" from ${input.skillsHome}\n`);
|
|
703
675
|
}
|
|
704
676
|
}
|
|
705
677
|
for (const entry of input.allSkills) {
|
|
@@ -716,14 +688,14 @@ async function reconcileManagedCodexSkills(input) {
|
|
|
716
688
|
if (resolvedLinkedPath !== path.resolve(entry.source))
|
|
717
689
|
continue;
|
|
718
690
|
if (await removeSkillTarget(target)) {
|
|
719
|
-
await input.onLog("stdout", `[
|
|
691
|
+
await input.onLog("stdout", `[wardmote] Revoked legacy ACPX Codex skill "${entry.runtimeName}" from ${input.skillsHome}\n`);
|
|
720
692
|
}
|
|
721
693
|
}
|
|
722
694
|
for (const name of managed) {
|
|
723
695
|
if (desired.has(name) || availableByRuntimeName.has(name))
|
|
724
696
|
continue;
|
|
725
697
|
if (await removeSkillTarget(path.join(input.skillsHome, name))) {
|
|
726
|
-
await input.onLog("stdout", `[
|
|
698
|
+
await input.onLog("stdout", `[wardmote] Revoked unavailable ACPX Codex skill "${name}" from ${input.skillsHome}\n`);
|
|
727
699
|
}
|
|
728
700
|
}
|
|
729
701
|
}
|
|
@@ -777,13 +749,13 @@ async function prepareCodexSkillRuntime(input) {
|
|
|
777
749
|
for (const entry of selectedSkills) {
|
|
778
750
|
const target = path.join(skillsHome, entry.runtimeName);
|
|
779
751
|
try {
|
|
780
|
-
const result = await
|
|
752
|
+
const result = await materializeWardmoteSkillCopy(entry.source, target);
|
|
781
753
|
if (result.skippedSymlinks.length > 0) {
|
|
782
|
-
await input.onLog("stdout", `[
|
|
754
|
+
await input.onLog("stdout", `[wardmote] Materialized ACPX Codex skill "${entry.runtimeName}" into ${skillsHome} and skipped ${result.skippedSymlinks.length} symlink(s).\n`);
|
|
783
755
|
}
|
|
784
756
|
}
|
|
785
757
|
catch (err) {
|
|
786
|
-
await input.onLog("stderr", `[
|
|
758
|
+
await input.onLog("stderr", `[wardmote] Failed to inject ACPX Codex skill "${entry.key}" into ${skillsHome}: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
787
759
|
}
|
|
788
760
|
}
|
|
789
761
|
await writeManagedCodexSkillsManifest(skillsHome, selectedSkills.map((entry) => entry.runtimeName));
|
|
@@ -813,25 +785,28 @@ async function prepareGeminiSkillRuntime(input) {
|
|
|
813
785
|
const skillsHome = resolveGeminiSkillsHome(input.config);
|
|
814
786
|
await fs.mkdir(skillsHome, { recursive: true });
|
|
815
787
|
const allowedSkillNames = selectedSkills.map((entry) => entry.runtimeName);
|
|
788
|
+
for (const skillName of await removeRetiredBundledSkillLinks(skillsHome)) {
|
|
789
|
+
await input.onLog("stdout", `[wardmote] Removed retired bundled ACPX Gemini skill link "${skillName}" from ${skillsHome}\n`);
|
|
790
|
+
}
|
|
816
791
|
const removedSkills = await removeMaintainerOnlySkillSymlinks(skillsHome, allowedSkillNames);
|
|
817
792
|
for (const skillName of removedSkills) {
|
|
818
|
-
await input.onLog("stdout", `[
|
|
793
|
+
await input.onLog("stdout", `[wardmote] Removed maintainer-only ACPX Gemini skill "${skillName}" from ${skillsHome}\n`);
|
|
819
794
|
}
|
|
820
795
|
for (const entry of selectedSkills) {
|
|
821
796
|
const target = path.join(skillsHome, entry.runtimeName);
|
|
822
797
|
try {
|
|
823
|
-
const result = await
|
|
798
|
+
const result = await ensureWardmoteSkillSymlink(entry.source, target);
|
|
824
799
|
if (result === "created" || result === "repaired") {
|
|
825
|
-
await input.onLog("stdout", `[
|
|
800
|
+
await input.onLog("stdout", `[wardmote] ${result === "repaired" ? "Repaired" : "Linked"} ACPX Gemini skill "${entry.runtimeName}" into ${skillsHome}\n`);
|
|
826
801
|
}
|
|
827
802
|
}
|
|
828
803
|
catch (err) {
|
|
829
804
|
if (isErrnoException(err, "EPERM")) {
|
|
830
|
-
const result = await
|
|
831
|
-
await input.onLog("stdout", `[
|
|
805
|
+
const result = await materializeWardmoteSkillCopy(entry.source, target);
|
|
806
|
+
await input.onLog("stdout", `[wardmote] Copied ACPX Gemini skill "${entry.runtimeName}" into ${skillsHome} because symlinks are unavailable.${result.skippedSymlinks.length > 0 ? ` Skipped ${result.skippedSymlinks.length} nested symlink(s).` : ""}\n`);
|
|
832
807
|
continue;
|
|
833
808
|
}
|
|
834
|
-
await input.onLog("stderr", `[
|
|
809
|
+
await input.onLog("stderr", `[wardmote] Failed to link ACPX Gemini skill "${entry.key}" into ${skillsHome}: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
835
810
|
}
|
|
836
811
|
}
|
|
837
812
|
return {
|
|
@@ -883,11 +858,11 @@ async function applyReadOnlySessionMode(input) {
|
|
|
883
858
|
return;
|
|
884
859
|
if (!input.runtime.setMode) {
|
|
885
860
|
const message = "ACPX runtime does not expose session mode controls, so the read_only tool profile cannot be applied.";
|
|
886
|
-
await input.onLog("stderr", `[
|
|
861
|
+
await input.onLog("stderr", `[wardmote] ${message}\n`);
|
|
887
862
|
throw new Error(message);
|
|
888
863
|
}
|
|
889
864
|
await input.runtime.setMode({ handle: input.handle, mode });
|
|
890
|
-
await input.onLog("stdout", `[
|
|
865
|
+
await input.onLog("stdout", `[wardmote] Applied read_only tool profile: ACPX ${input.prepared.acpxAgent} session mode ${mode}\n`);
|
|
891
866
|
}
|
|
892
867
|
function normalizeNonInteractivePermissions(config) {
|
|
893
868
|
return asString(config.nonInteractivePermissions, DEFAULT_ACP_ENGINE_NON_INTERACTIVE_PERMISSIONS) === "fail"
|
|
@@ -983,28 +958,21 @@ function buildSessionParams(input) {
|
|
|
983
958
|
function uniqueSorted(values) {
|
|
984
959
|
return [...new Set(values.filter((value) => typeof value === "string" && value.length > 0))].sort();
|
|
985
960
|
}
|
|
986
|
-
|
|
987
|
-
// `settingSources: ["user", "project", "local"]`. By writing a per-worktree
|
|
988
|
-
// `.claude/settings.local.json` we override the user's potentially-restrictive
|
|
989
|
-
// `~/.claude/settings.json` (e.g. `defaultMode: "dontAsk"`, which silently
|
|
990
|
-
// denies every non-allowlisted tool and never reaches `canUseTool`), and we
|
|
991
|
-
// widen the SDK's Read sandbox to include the Paperclip state dirs the agent
|
|
992
|
-
// needs to talk to its own control plane.
|
|
993
|
-
async function writePaperclipClaudeSettings(input) {
|
|
961
|
+
async function writeWardmoteClaudeSettings(input) {
|
|
994
962
|
const filePath = path.join(input.cwd, ".claude", "settings.local.json");
|
|
995
|
-
const instanceRoot =
|
|
963
|
+
const instanceRoot = defaultWardmoteInstanceDir();
|
|
996
964
|
const companyRoot = path.join(instanceRoot, "companies", input.companyId);
|
|
997
|
-
const
|
|
965
|
+
const wardmoteAdditionalDirectories = uniqueSorted([
|
|
998
966
|
input.stateDir,
|
|
999
967
|
input.agentHome,
|
|
1000
968
|
companyRoot,
|
|
1001
969
|
]);
|
|
1002
|
-
const
|
|
970
|
+
const wardmoteAllow = uniqueSorted([
|
|
1003
971
|
"Bash(curl:*)",
|
|
1004
972
|
"Bash(env:*)",
|
|
1005
973
|
"Bash(env)",
|
|
1006
|
-
`Bash(${input.cwd}/scripts/
|
|
1007
|
-
`Bash(${input.cwd}/scripts/
|
|
974
|
+
`Bash(${input.cwd}/scripts/wardmote-issue-update.sh:*)`,
|
|
975
|
+
`Bash(${input.cwd}/scripts/wardmote:*)`,
|
|
1008
976
|
]);
|
|
1009
977
|
let existing = {};
|
|
1010
978
|
const existingRaw = await fs.readFile(filePath, "utf8").catch(() => null);
|
|
@@ -1027,10 +995,10 @@ async function writePaperclipClaudeSettings(input) {
|
|
|
1027
995
|
const existingAdditionalDirectories = Array.isArray(existingPerms.additionalDirectories)
|
|
1028
996
|
? existingPerms.additionalDirectories.filter((value) => typeof value === "string")
|
|
1029
997
|
: [];
|
|
1030
|
-
const mergedAllow = uniqueSorted([...existingAllow, ...
|
|
998
|
+
const mergedAllow = uniqueSorted([...existingAllow, ...wardmoteAllow]);
|
|
1031
999
|
const mergedAdditionalDirectories = uniqueSorted([
|
|
1032
1000
|
...existingAdditionalDirectories,
|
|
1033
|
-
...
|
|
1001
|
+
...wardmoteAdditionalDirectories,
|
|
1034
1002
|
]);
|
|
1035
1003
|
const existingDefaultMode = typeof existingPerms.defaultMode === "string" ? existingPerms.defaultMode : "";
|
|
1036
1004
|
const defaultMode = existingDefaultMode && existingDefaultMode !== "dontAsk" ? existingDefaultMode : "default";
|
|
@@ -1067,7 +1035,7 @@ async function writePaperclipClaudeSettings(input) {
|
|
|
1067
1035
|
// `restoreWorkspace` fires the per-asset `restore` (codex copy-back) at
|
|
1068
1036
|
// teardown.
|
|
1069
1037
|
async function stageAcpRemoteRuntime(input) {
|
|
1070
|
-
await input.onLog("stdout", `[
|
|
1038
|
+
await input.onLog("stdout", `[wardmote] Syncing workspace to ${describeAdapterExecutionTarget(input.target)}.\n`);
|
|
1071
1039
|
return await prepareAdapterExecutionTargetRuntime({
|
|
1072
1040
|
runId: input.runId,
|
|
1073
1041
|
target: input.target,
|
|
@@ -1105,7 +1073,7 @@ async function disposeFreshStagedRuntime(input) {
|
|
|
1105
1073
|
});
|
|
1106
1074
|
}
|
|
1107
1075
|
catch (err) {
|
|
1108
|
-
await input.onLog("stderr", `[
|
|
1076
|
+
await input.onLog("stderr", `[wardmote] Failed to dispose the fresh staged runtime after a managed-home seam error: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
1109
1077
|
}
|
|
1110
1078
|
}
|
|
1111
1079
|
async function buildRuntime(input) {
|
|
@@ -1114,8 +1082,8 @@ async function buildRuntime(input) {
|
|
|
1114
1082
|
// first instrumented boundary (step 1 `workspace.resolve`, below) so every
|
|
1115
1083
|
// `measureStartupStep` call in this function shares one deterministic clock.
|
|
1116
1084
|
const nowMs = input.deps.now ?? (() => Date.now());
|
|
1117
|
-
const workspaceContext = parseObject(context.
|
|
1118
|
-
const secretsContext = parseObject(context.
|
|
1085
|
+
const workspaceContext = parseObject(context.wardmoteWorkspace);
|
|
1086
|
+
const secretsContext = parseObject(context.wardmoteSecrets);
|
|
1119
1087
|
const secretManifest = Array.isArray(secretsContext.manifest) ? secretsContext.manifest : [];
|
|
1120
1088
|
const workspaceCwd = asString(workspaceContext.cwd, "");
|
|
1121
1089
|
const workspaceSource = asString(workspaceContext.source, "");
|
|
@@ -1189,8 +1157,8 @@ async function buildRuntime(input) {
|
|
|
1189
1157
|
// list joins the anchor project's alternative workspaces with the referenced (mentioned) projects.
|
|
1190
1158
|
// On the confined sandbox lane the run repoints each referenced hint at its staged directory after
|
|
1191
1159
|
// staging below. Empty unless run prep resolved referenced projects or alternative workspaces.
|
|
1192
|
-
const workspaceHints = Array.isArray(context.
|
|
1193
|
-
? context.
|
|
1160
|
+
const workspaceHints = Array.isArray(context.wardmoteWorkspaces)
|
|
1161
|
+
? context.wardmoteWorkspaces.filter((value) => typeof value === "object" && value !== null)
|
|
1194
1162
|
: [];
|
|
1195
1163
|
const executionTarget = readAdapterExecutionTarget({
|
|
1196
1164
|
executionTarget: input.ctx.executionTarget,
|
|
@@ -1215,7 +1183,7 @@ async function buildRuntime(input) {
|
|
|
1215
1183
|
batch: STARTUP_BRIDGE_BATCH,
|
|
1216
1184
|
criticalPath: false,
|
|
1217
1185
|
};
|
|
1218
|
-
const shapedWorkspaceEnv =
|
|
1186
|
+
const shapedWorkspaceEnv = shapeWardmoteWorkspaceEnvForExecution({
|
|
1219
1187
|
workspaceCwd: effectiveWorkspaceCwd,
|
|
1220
1188
|
workspaceWorktreePath,
|
|
1221
1189
|
executionTargetIsRemote,
|
|
@@ -1247,17 +1215,17 @@ async function buildRuntime(input) {
|
|
|
1247
1215
|
url: server.url,
|
|
1248
1216
|
headers: [{ name: "Authorization", value: `Bearer ${server.token}` }],
|
|
1249
1217
|
}));
|
|
1250
|
-
const
|
|
1251
|
-
...
|
|
1218
|
+
const wardmoteEnvForAccess = {
|
|
1219
|
+
...buildWardmoteEnv(agent, { sameHost: !executionTargetIsRemote }),
|
|
1252
1220
|
WARDMOTE_RUN_ID: runId,
|
|
1253
1221
|
...(authToken ? { WARDMOTE_API_KEY: authToken } : {}),
|
|
1254
1222
|
};
|
|
1255
|
-
const
|
|
1256
|
-
const
|
|
1257
|
-
if (
|
|
1258
|
-
const target =
|
|
1259
|
-
env:
|
|
1260
|
-
toolsets:
|
|
1223
|
+
const wardmoteAccess = wardmoteAccessMode(config, wardmoteEnvForAccess);
|
|
1224
|
+
const wardmoteToolsets = wardmoteMcpToolsets(config);
|
|
1225
|
+
if (wardmoteAccess === "mcp") {
|
|
1226
|
+
const target = wardmoteMcpHttpTarget({
|
|
1227
|
+
env: wardmoteEnvForAccess,
|
|
1228
|
+
toolsets: wardmoteToolsets,
|
|
1261
1229
|
});
|
|
1262
1230
|
mcpServers.unshift({
|
|
1263
1231
|
type: "http",
|
|
@@ -1275,7 +1243,7 @@ async function buildRuntime(input) {
|
|
|
1275
1243
|
await fs.mkdir(stateDir, { recursive: true });
|
|
1276
1244
|
const envConfig = parseObject(config.env);
|
|
1277
1245
|
const env = {
|
|
1278
|
-
...
|
|
1246
|
+
...buildWardmoteEnv(agent, { sameHost: !executionTargetIsRemote }, input.ctx.agentIdentity),
|
|
1279
1247
|
WARDMOTE_RUN_ID: runId,
|
|
1280
1248
|
};
|
|
1281
1249
|
const wakeTaskId = (typeof context.taskId === "string" && context.taskId.trim()) ||
|
|
@@ -1290,7 +1258,7 @@ async function buildRuntime(input) {
|
|
|
1290
1258
|
const linkedIssueIds = Array.isArray(context.issueIds)
|
|
1291
1259
|
? context.issueIds.filter((value) => typeof value === "string" && value.trim().length > 0)
|
|
1292
1260
|
: [];
|
|
1293
|
-
const issueWorkMode =
|
|
1261
|
+
const issueWorkMode = readWardmoteIssueWorkModeFromContext(context);
|
|
1294
1262
|
if (wakeTaskId)
|
|
1295
1263
|
env.WARDMOTE_TASK_ID = wakeTaskId;
|
|
1296
1264
|
if (issueWorkMode)
|
|
@@ -1305,7 +1273,7 @@ async function buildRuntime(input) {
|
|
|
1305
1273
|
env.WARDMOTE_APPROVAL_STATUS = approvalStatus;
|
|
1306
1274
|
if (linkedIssueIds.length > 0)
|
|
1307
1275
|
env.WARDMOTE_LINKED_ISSUE_IDS = linkedIssueIds.join(",");
|
|
1308
|
-
|
|
1276
|
+
applyWardmoteWorkspaceEnv(env, {
|
|
1309
1277
|
workspaceCwd: shapedWorkspaceEnv.workspaceCwd,
|
|
1310
1278
|
workspaceSource,
|
|
1311
1279
|
workspaceStrategy,
|
|
@@ -1331,7 +1299,7 @@ async function buildRuntime(input) {
|
|
|
1331
1299
|
// `env` above and are never present in shapedEnvConfig, so they inherently
|
|
1332
1300
|
// stay out of the hash and don't reset the session every heartbeat.
|
|
1333
1301
|
const resolvedAdapterEnv = {};
|
|
1334
|
-
const scratch = parseObject(context.
|
|
1302
|
+
const scratch = parseObject(context.wardmoteScratch);
|
|
1335
1303
|
const scratchKeys = scratch.type === "heartbeat_run" && typeof scratch.dir === "string"
|
|
1336
1304
|
? new Set(["WARDMOTE_RUN_SCRATCH_DIR", "WARDMOTE_TASK_SCRATCH_DIR", "WARDMOTE_SCRATCH_DIR", "WARDMOTE_TMPDIR",
|
|
1337
1305
|
...(Array.isArray(scratch.tempKeysApplied) ? scratch.tempKeysApplied.filter((key) => typeof key === "string" && ["TMPDIR", "TEMP", "TMP"].includes(key)) : [])])
|
|
@@ -1340,14 +1308,9 @@ async function buildRuntime(input) {
|
|
|
1340
1308
|
for (const [key, value] of Object.entries(shapedEnvConfig)) {
|
|
1341
1309
|
if (typeof value !== "string")
|
|
1342
1310
|
continue;
|
|
1343
|
-
// Runtime WARDMOTE_* always wins over config: skip a WARDMOTE_* key that
|
|
1344
|
-
// Paperclip has already assigned this run. WARDMOTE_API_KEY is never
|
|
1345
|
-
// accepted from config — the harness-minted run token is the only source.
|
|
1346
|
-
// A WARDMOTE_* key Paperclip did NOT set is stable per-run config, so it
|
|
1347
|
-
// applies and feeds the fingerprint hash below.
|
|
1348
1311
|
if (isForbiddenConfigEnvKey(key))
|
|
1349
1312
|
continue;
|
|
1350
|
-
if (
|
|
1313
|
+
if (isWardmoteRuntimeEnvKey(key) && key in env)
|
|
1351
1314
|
continue;
|
|
1352
1315
|
env[key] = value;
|
|
1353
1316
|
// The server rotates run-owned scratch paths on every wake. Still forward
|
|
@@ -1379,8 +1342,6 @@ async function buildRuntime(input) {
|
|
|
1379
1342
|
...(input.ctx.agentIdentity ? { identityEnvironmentKeys: [...new Set([
|
|
1380
1343
|
"PATH", "HOME", "LANG", "TMPDIR", "CODEX_HOME",
|
|
1381
1344
|
"WARDMOTE_AGENT_KEY_ID", "WARDMOTE_AGENT_PUBLIC_KEY", "WARDMOTE_AGENT_PRIVATE_KEY",
|
|
1382
|
-
// Preserve Codex's default secret-name exclusions. The short-lived
|
|
1383
|
-
// Paperclip API token is required by the agent skill's Bash/curl calls.
|
|
1384
1345
|
...Object.keys(env).filter(key => key === "WARDMOTE_API_KEY" || !/key|secret|token/i.test(key)),
|
|
1385
1346
|
])] } : {}),
|
|
1386
1347
|
requestedModel,
|
|
@@ -1388,7 +1349,7 @@ async function buildRuntime(input) {
|
|
|
1388
1349
|
fastMode,
|
|
1389
1350
|
});
|
|
1390
1351
|
if (codexStartupConfig.invalidExistingConfig) {
|
|
1391
|
-
await input.ctx.onLog("stderr", "[
|
|
1352
|
+
await input.ctx.onLog("stderr", "[wardmote] Ignoring invalid user CODEX_CONFIG while applying runtime Codex settings; expected a JSON object.\n");
|
|
1392
1353
|
}
|
|
1393
1354
|
if (codexStartupConfig.value)
|
|
1394
1355
|
env.CODEX_CONFIG = codexStartupConfig.value;
|
|
@@ -1402,7 +1363,7 @@ async function buildRuntime(input) {
|
|
|
1402
1363
|
// below, after `placeWorkspace` returns). This field is `null` for every
|
|
1403
1364
|
// non-Claude agent, and for a Claude run with no skill selected.
|
|
1404
1365
|
let claudeSkillsBundleDir = null;
|
|
1405
|
-
let
|
|
1366
|
+
let wardmoteClaudeSettings = null;
|
|
1406
1367
|
if (acpxAgent === "claude") {
|
|
1407
1368
|
const preparedSkills = await prepareClaudeSkillRuntime({
|
|
1408
1369
|
stateDir,
|
|
@@ -1414,7 +1375,7 @@ async function buildRuntime(input) {
|
|
|
1414
1375
|
skillsIdentity = preparedSkills.identity;
|
|
1415
1376
|
skillCommandNotes.push(...preparedSkills.commandNotes);
|
|
1416
1377
|
claudeSkillsBundleDir = preparedSkills.bundleDir;
|
|
1417
|
-
|
|
1378
|
+
wardmoteClaudeSettings = await writeWardmoteClaudeSettings({
|
|
1418
1379
|
cwd,
|
|
1419
1380
|
stateDir,
|
|
1420
1381
|
// A run's writable AGENT_HOME moves, but the existing permission root
|
|
@@ -1424,7 +1385,7 @@ async function buildRuntime(input) {
|
|
|
1424
1385
|
agentHome: asString(workspaceContext.agentHomeForPermissions, agentHome),
|
|
1425
1386
|
companyId: agent.companyId,
|
|
1426
1387
|
});
|
|
1427
|
-
skillCommandNotes.push(`Wrote
|
|
1388
|
+
skillCommandNotes.push(`Wrote Wardmote-managed Claude settings to ${wardmoteClaudeSettings.filePath} (defaultMode=${wardmoteClaudeSettings.defaultMode}${wardmoteClaudeSettings.overrodeDontAsk ? "; overrode user dontAsk" : ""}, +${wardmoteClaudeSettings.additionalDirectories.length} read root(s), +${wardmoteClaudeSettings.allow.length} allow rule(s)).`);
|
|
1428
1389
|
}
|
|
1429
1390
|
else if (acpxAgent === "codex") {
|
|
1430
1391
|
// Step 2 — codex-home.seed: the codex managed-home + skills preparation.
|
|
@@ -1463,10 +1424,10 @@ async function buildRuntime(input) {
|
|
|
1463
1424
|
if (acpxAgent === "grok" && !config.managedAiConnection) {
|
|
1464
1425
|
env.GROK_HOME = resolveManagedGrokHomeDir(agent.companyId);
|
|
1465
1426
|
}
|
|
1466
|
-
const desired =
|
|
1427
|
+
const desired = resolveLegacyWardmoteDesiredSkillNames(config, await readWardmoteRuntimeSkillEntries(config, input.engine.moduleDir));
|
|
1467
1428
|
skillsIdentity = { mode: "custom_unsupported", desiredSkillNames: desired };
|
|
1468
1429
|
if (desired.length > 0) {
|
|
1469
|
-
skillCommandNotes.push("Selected
|
|
1430
|
+
skillCommandNotes.push("Selected Wardmote skills are tracked only; ACPX custom commands do not expose a runtime skill contract yet.");
|
|
1470
1431
|
}
|
|
1471
1432
|
}
|
|
1472
1433
|
const configuredCommand = asString(config.agentCommand, "").trim();
|
|
@@ -1549,11 +1510,11 @@ async function buildRuntime(input) {
|
|
|
1549
1510
|
additionalSourcesIdentity: additionalSourcesIdentity,
|
|
1550
1511
|
skillsIdentity,
|
|
1551
1512
|
skillPromptInstructions,
|
|
1552
|
-
|
|
1513
|
+
wardmoteClaudeSettings: wardmoteClaudeSettings
|
|
1553
1514
|
? {
|
|
1554
|
-
allow:
|
|
1555
|
-
additionalDirectories:
|
|
1556
|
-
defaultMode:
|
|
1515
|
+
allow: wardmoteClaudeSettings.allow,
|
|
1516
|
+
additionalDirectories: wardmoteClaudeSettings.additionalDirectories,
|
|
1517
|
+
defaultMode: wardmoteClaudeSettings.defaultMode,
|
|
1557
1518
|
}
|
|
1558
1519
|
: null,
|
|
1559
1520
|
// Qualified built-in ACP harnesses reconnect to the supplied MCP servers
|
|
@@ -1696,7 +1657,7 @@ async function buildRuntime(input) {
|
|
|
1696
1657
|
}),
|
|
1697
1658
|
measureStageStep: (run) => measureStartupStep(input.ctx, nowMs, "stage.sync", run, stepMetrics),
|
|
1698
1659
|
publishStagedProjectHints: (stagedProjectDirs) => {
|
|
1699
|
-
const shapedHints =
|
|
1660
|
+
const shapedHints = shapeWardmoteWorkspaceEnvForExecution({
|
|
1700
1661
|
workspaceCwd: effectiveWorkspaceCwd,
|
|
1701
1662
|
workspaceWorktreePath,
|
|
1702
1663
|
workspaceHints,
|
|
@@ -1708,8 +1669,8 @@ async function buildRuntime(input) {
|
|
|
1708
1669
|
env.WARDMOTE_WORKSPACES_JSON = JSON.stringify(shapedHints);
|
|
1709
1670
|
}
|
|
1710
1671
|
},
|
|
1711
|
-
onReuseLog: () => input.ctx.onLog("stdout", "[
|
|
1712
|
-
|
|
1672
|
+
onReuseLog: () => input.ctx.onLog("stdout", "[wardmote] Reusing the staged in-sandbox runtime for this resumed session (no workspace re-ship / managed-home re-seed).\n"),
|
|
1673
|
+
startWardmoteBridge: (runtimeRootDir) => startAdapterExecutionTargetWardmoteBridge({
|
|
1713
1674
|
runId,
|
|
1714
1675
|
target: { ...remoteTarget, streamRunLogs: false },
|
|
1715
1676
|
runtimeRootDir,
|
|
@@ -1742,7 +1703,7 @@ async function buildRuntime(input) {
|
|
|
1742
1703
|
acpxAgent,
|
|
1743
1704
|
inheritHostEnvironment: !useRemoteProcessSession,
|
|
1744
1705
|
}).env,
|
|
1745
|
-
|
|
1706
|
+
onWardmoteBridgeLog: () => input.ctx.onLog("stdout", "[wardmote] Sandbox ACP API callback bridge enabled for this run.\n"),
|
|
1746
1707
|
stopBridges: async ({ controlBridge, agentBridge }) => {
|
|
1747
1708
|
await Promise.allSettled([agentBridge?.stop(), controlBridge?.stop()]);
|
|
1748
1709
|
if (remoteManagedHomeTeardown) {
|
|
@@ -1776,7 +1737,7 @@ async function buildRuntime(input) {
|
|
|
1776
1737
|
if (acpxAgent === "claude" && stagedRuntime && claudeSkillsBundleDir) {
|
|
1777
1738
|
const inSandboxSkillsRoot = stagedRuntime.assetDirs.skills ??
|
|
1778
1739
|
path.posix.join(stagedRuntime.runtimeRootDir ??
|
|
1779
|
-
path.posix.join(stagedRuntime.workspaceRemoteDir ?? cwd, ".
|
|
1740
|
+
path.posix.join(stagedRuntime.workspaceRemoteDir ?? cwd, ".wardmote-runtime", acpxAgent), "skills");
|
|
1780
1741
|
const rebaseToSandbox = (value) => value.split(claudeSkillsBundleDir).join(inSandboxSkillsRoot);
|
|
1781
1742
|
skillPromptInstructions = rebaseToSandbox(skillPromptInstructions);
|
|
1782
1743
|
skillsIdentity = {
|
|
@@ -1789,25 +1750,14 @@ async function buildRuntime(input) {
|
|
|
1789
1750
|
skillCommandNotes[i] = rebaseToSandbox(skillCommandNotes[i]);
|
|
1790
1751
|
}
|
|
1791
1752
|
}
|
|
1792
|
-
|
|
1793
|
-
// paperclip callback bridge — fires the same abandon-path cleanup. The
|
|
1794
|
-
// paperclip bridge starts after the workspace + managed home were already
|
|
1795
|
-
// staged and the per-session staging lease is already held, so leaving it
|
|
1796
|
-
// outside the catch would strand the lease (and the staged temp) on a
|
|
1797
|
-
// start failure and deadlock the next run of this session.
|
|
1798
|
-
let paperclipBridge = null;
|
|
1753
|
+
let wardmoteBridge = null;
|
|
1799
1754
|
let processSessionBridge = null;
|
|
1800
1755
|
let runtimeEnv = {};
|
|
1801
1756
|
const startTransportStart = nowMs();
|
|
1802
1757
|
try {
|
|
1803
1758
|
if (useRemoteProcessSession && sandboxSite) {
|
|
1804
|
-
// The sandbox run site brings up both host-side bridges concurrently, keeps
|
|
1805
|
-
// the one paperclip-env → process-session-launch dependency at a single
|
|
1806
|
-
// sequencing point, settles both starts, and returns the started handles
|
|
1807
|
-
// plus the finalized launch env. On a partial failure it stops nothing and
|
|
1808
|
-
// rethrows; the catch below stops whichever bridge the site started.
|
|
1809
1759
|
const transport = await sandboxSite.startTransport({ sessionKey });
|
|
1810
|
-
|
|
1760
|
+
wardmoteBridge = transport.controlBridge;
|
|
1811
1761
|
processSessionBridge = transport.agentBridge;
|
|
1812
1762
|
runtimeEnv = transport.launchEnv;
|
|
1813
1763
|
await emitRunPhaseTiming(input.ctx, "start_transport", nowMs() - startTransportStart, "ok");
|
|
@@ -1828,7 +1778,7 @@ async function buildRuntime(input) {
|
|
|
1828
1778
|
// bridge leaks (mirrors the settlement `stopTransport` step). The site sets its
|
|
1829
1779
|
// started bridges before it rethrows, so read them from the site here (the
|
|
1830
1780
|
// local handles stay null when `startTransport` throws before it returns).
|
|
1831
|
-
const startedControl = sandboxSite?.controlBridge ??
|
|
1781
|
+
const startedControl = sandboxSite?.controlBridge ?? wardmoteBridge;
|
|
1832
1782
|
const startedAgent = sandboxSite?.agentBridge ?? processSessionBridge;
|
|
1833
1783
|
await Promise.allSettled([startedControl?.stop(), startedAgent?.stop()]);
|
|
1834
1784
|
// The staged home / copy-back teardown must run even if a bridge fails to
|
|
@@ -1868,13 +1818,13 @@ async function buildRuntime(input) {
|
|
|
1868
1818
|
// remember a previous home's skill paths; supply the current root on every
|
|
1869
1819
|
// turn, after the remote launch environment has rebased CODEX_HOME.
|
|
1870
1820
|
skillPromptInstructions = [
|
|
1871
|
-
`
|
|
1821
|
+
`Wardmote has materialized selected runtime skills for this ACPX ${acpxAgent === "codex" ? "Codex" : "Gemini"} run.`,
|
|
1872
1822
|
`Skill root for this run: ${currentSkillRoot}`,
|
|
1873
1823
|
`Selected skills: ${skillsIdentity.selectedSkills.join(", ")}`,
|
|
1874
1824
|
"When a task calls for one of these skills, read its SKILL.md from this root and follow it. Resolve referenced scripts and files relative to that skill. Use this run's root even when an earlier turn used a different path.",
|
|
1875
|
-
...(acpxAgent === "gemini" && skillsIdentity.selectedSkills.includes("
|
|
1825
|
+
...(acpxAgent === "gemini" && skillsIdentity.selectedSkills.includes("wardmote")
|
|
1876
1826
|
? [
|
|
1877
|
-
"Before calling
|
|
1827
|
+
"Before calling Wardmote APIs or delivering task artifacts, read the selected paperclip skill's SKILL.md and its referenced artifact workflow. A completion comment does not upload an artifact or change task status.",
|
|
1878
1828
|
"Gemini's shell tool rejects command substitution. Write JSON request bodies to a workspace file and use curl --data-binary @file, or use the selected skill's helpers, instead of constructing a body with command substitution.",
|
|
1879
1829
|
]
|
|
1880
1830
|
: []),
|
|
@@ -1925,7 +1875,7 @@ async function buildRuntime(input) {
|
|
|
1925
1875
|
agentCommand,
|
|
1926
1876
|
agentRegistry,
|
|
1927
1877
|
processSessionBridge,
|
|
1928
|
-
|
|
1878
|
+
wardmoteBridge,
|
|
1929
1879
|
stagedRuntime,
|
|
1930
1880
|
remoteManagedHomeTeardown,
|
|
1931
1881
|
remoteStagingDispose,
|
|
@@ -1933,14 +1883,14 @@ async function buildRuntime(input) {
|
|
|
1933
1883
|
sessionStagingLeaseRelease,
|
|
1934
1884
|
remoteExecutionIdentity,
|
|
1935
1885
|
skillPromptInstructions,
|
|
1936
|
-
|
|
1937
|
-
|
|
1886
|
+
wardmoteAccess,
|
|
1887
|
+
wardmoteToolsets,
|
|
1938
1888
|
skillsIdentity: {
|
|
1939
1889
|
...skillsIdentity,
|
|
1940
1890
|
commandNotes: skillCommandNotes,
|
|
1941
1891
|
},
|
|
1942
1892
|
childStderrLogPath,
|
|
1943
|
-
|
|
1893
|
+
wardmoteClaudeSettings,
|
|
1944
1894
|
mcpServers,
|
|
1945
1895
|
mcpIdentity,
|
|
1946
1896
|
stepMetrics,
|
|
@@ -1974,7 +1924,7 @@ async function applySessionConfigOptions(input) {
|
|
|
1974
1924
|
return;
|
|
1975
1925
|
if (!input.runtime.setConfigOption) {
|
|
1976
1926
|
const message = "ACPX runtime does not expose session config controls; upgrade ACPX or remove configured model, effort, and fast mode overrides.";
|
|
1977
|
-
await input.onLog("stderr", `[
|
|
1927
|
+
await input.onLog("stderr", `[wardmote] ${message}\n`);
|
|
1978
1928
|
throw new Error(message);
|
|
1979
1929
|
}
|
|
1980
1930
|
for (const option of options) {
|
|
@@ -1983,7 +1933,7 @@ async function applySessionConfigOptions(input) {
|
|
|
1983
1933
|
key: option.key,
|
|
1984
1934
|
value: option.value,
|
|
1985
1935
|
});
|
|
1986
|
-
await input.onLog("stdout", `[
|
|
1936
|
+
await input.onLog("stdout", `[wardmote] Applied ACPX ${input.prepared.acpxAgent} config ${option.key}=${option.value}\n`);
|
|
1987
1937
|
}
|
|
1988
1938
|
}
|
|
1989
1939
|
/**
|
|
@@ -2044,7 +1994,7 @@ function mergeRuntimeEnvironment(inheritedEnv, explicitEnv, caseInsensitiveKeys)
|
|
|
2044
1994
|
async function stopRunTransport(prepared) {
|
|
2045
1995
|
await Promise.allSettled([
|
|
2046
1996
|
prepared.processSessionBridge?.stop(),
|
|
2047
|
-
prepared.
|
|
1997
|
+
prepared.wardmoteBridge?.stop(),
|
|
2048
1998
|
]);
|
|
2049
1999
|
}
|
|
2050
2000
|
// The site sync-back. This is the settlement `syncBack` effect. It runs AFTER the
|
|
@@ -2213,28 +2163,28 @@ function guardEnsureSession(params) {
|
|
|
2213
2163
|
});
|
|
2214
2164
|
});
|
|
2215
2165
|
}
|
|
2216
|
-
function
|
|
2217
|
-
const
|
|
2166
|
+
function renderWardmoteEnvNote(env) {
|
|
2167
|
+
const wardmoteKeys = Object.keys(env)
|
|
2218
2168
|
.filter((key) => key.startsWith("WARDMOTE_"))
|
|
2219
2169
|
.sort();
|
|
2220
|
-
if (
|
|
2170
|
+
if (wardmoteKeys.length === 0)
|
|
2221
2171
|
return "";
|
|
2222
2172
|
return [
|
|
2223
|
-
"
|
|
2224
|
-
`The following WARDMOTE_* environment variables are available in this run: ${
|
|
2173
|
+
"Wardmote runtime note:",
|
|
2174
|
+
`The following WARDMOTE_* environment variables are available in this run: ${wardmoteKeys.join(", ")}`,
|
|
2225
2175
|
"Do not assume these variables are missing without checking your shell environment.",
|
|
2226
2176
|
].join("\n");
|
|
2227
2177
|
}
|
|
2228
2178
|
function renderApiAccessNote(env, access, toolsets) {
|
|
2229
2179
|
if (!env.WARDMOTE_API_URL || !env.WARDMOTE_API_KEY)
|
|
2230
2180
|
return "";
|
|
2231
|
-
const lines = ["
|
|
2181
|
+
const lines = ["Wardmote API access note:", wardmoteAccessGuidance(access, { toolsets })];
|
|
2232
2182
|
if (!env.WARDMOTE_TASK_ID) {
|
|
2233
2183
|
lines.push("Use a real issue id from the current context before making issue write requests.");
|
|
2234
2184
|
}
|
|
2235
2185
|
return lines.join("\n");
|
|
2236
2186
|
}
|
|
2237
|
-
async function buildPrompt(ctx, resumedSession, env,
|
|
2187
|
+
async function buildPrompt(ctx, resumedSession, env, wardmoteAccess, wardmoteToolsets) {
|
|
2238
2188
|
const { agent, runId, config, context, onLog } = ctx;
|
|
2239
2189
|
const configuredPromptTemplate = asString(config.promptTemplate, "");
|
|
2240
2190
|
const hasCustomPromptTemplate = configuredPromptTemplate.trim().length > 0;
|
|
@@ -2242,7 +2192,7 @@ async function buildPrompt(ctx, resumedSession, env, paperclipAccess, paperclipT
|
|
|
2242
2192
|
? configuredPromptTemplate
|
|
2243
2193
|
: context.conversationMode === true
|
|
2244
2194
|
? DEFAULT_WARDMOTE_CONVERSATION_PROMPT_TEMPLATE
|
|
2245
|
-
:
|
|
2195
|
+
: wardmoteAgentPromptTemplate(wardmoteAccess);
|
|
2246
2196
|
const instructionsFilePath = asString(config.instructionsFilePath, "").trim();
|
|
2247
2197
|
const instructionsDir = instructionsFilePath ? `${path.dirname(instructionsFilePath)}/` : "";
|
|
2248
2198
|
let instructionsPrefix = "";
|
|
@@ -2258,7 +2208,7 @@ async function buildPrompt(ctx, resumedSession, env, paperclipAccess, paperclipT
|
|
|
2258
2208
|
}
|
|
2259
2209
|
catch (err) {
|
|
2260
2210
|
const reason = err instanceof Error ? err.message : String(err);
|
|
2261
|
-
await onLog("stderr", `[
|
|
2211
|
+
await onLog("stderr", `[wardmote] Warning: could not read agent instructions file "${instructionsFilePath}": ${reason}\n`);
|
|
2262
2212
|
commandNotes.push(`Configured instructionsFilePath ${instructionsFilePath}, but file could not be read.`);
|
|
2263
2213
|
}
|
|
2264
2214
|
}
|
|
@@ -2276,20 +2226,20 @@ async function buildPrompt(ctx, resumedSession, env, paperclipAccess, paperclipT
|
|
|
2276
2226
|
? renderTemplate(bootstrapPromptTemplate, templateData).trim()
|
|
2277
2227
|
: "";
|
|
2278
2228
|
await hydrateFreshSessionHandoff(ctx, { resumedSession });
|
|
2279
|
-
const { taskContextNote, wakePrompt } =
|
|
2229
|
+
const { taskContextNote, wakePrompt } = selectWardmotePromptSections(context, {
|
|
2280
2230
|
resumedSession,
|
|
2281
2231
|
includeCommunicationGuidance: false,
|
|
2282
|
-
|
|
2232
|
+
wardmoteAccess,
|
|
2283
2233
|
});
|
|
2284
|
-
const externalChatTurn =
|
|
2234
|
+
const externalChatTurn = isWardmoteExternalChatTurn(context.wardmoteWake);
|
|
2285
2235
|
const shouldUseResumeDeltaPrompt = resumedSession && wakePrompt.length > 0;
|
|
2286
2236
|
const promptInstructionsPrefix = shouldUseResumeDeltaPrompt ? "" : instructionsPrefix;
|
|
2287
2237
|
const renderedPrompt = shouldUseResumeDeltaPrompt || (externalChatTurn && !hasCustomPromptTemplate)
|
|
2288
2238
|
? ""
|
|
2289
2239
|
: renderTemplate(promptTemplate, templateData);
|
|
2290
|
-
const sessionHandoffNote = asString(context.
|
|
2291
|
-
const
|
|
2292
|
-
const apiAccessNote = externalChatTurn ? "" : renderApiAccessNote(env,
|
|
2240
|
+
const sessionHandoffNote = asString(context.wardmoteSessionHandoffMarkdown, "").trim();
|
|
2241
|
+
const wardmoteEnvNote = externalChatTurn ? "" : renderWardmoteEnvNote(env);
|
|
2242
|
+
const apiAccessNote = externalChatTurn ? "" : renderApiAccessNote(env, wardmoteAccess, wardmoteToolsets);
|
|
2293
2243
|
const prompt = joinPromptSections([
|
|
2294
2244
|
promptInstructionsPrefix,
|
|
2295
2245
|
renderedBootstrapPrompt,
|
|
@@ -2297,7 +2247,7 @@ async function buildPrompt(ctx, resumedSession, env, paperclipAccess, paperclipT
|
|
|
2297
2247
|
wakePrompt,
|
|
2298
2248
|
sessionHandoffNote,
|
|
2299
2249
|
taskContextNote,
|
|
2300
|
-
|
|
2250
|
+
wardmoteEnvNote,
|
|
2301
2251
|
apiAccessNote,
|
|
2302
2252
|
renderedPrompt,
|
|
2303
2253
|
]);
|
|
@@ -2311,7 +2261,7 @@ async function buildPrompt(ctx, resumedSession, env, paperclipAccess, paperclipT
|
|
|
2311
2261
|
wakePromptChars: wakePrompt.length,
|
|
2312
2262
|
sessionHandoffChars: sessionHandoffNote.length,
|
|
2313
2263
|
taskContextChars: taskContextNote.length,
|
|
2314
|
-
runtimeNoteChars:
|
|
2264
|
+
runtimeNoteChars: wardmoteEnvNote.length + apiAccessNote.length,
|
|
2315
2265
|
heartbeatPromptChars: renderedPrompt.length,
|
|
2316
2266
|
},
|
|
2317
2267
|
};
|
|
@@ -2319,14 +2269,6 @@ async function buildPrompt(ctx, resumedSession, env, paperclipAccess, paperclipT
|
|
|
2319
2269
|
async function emitAcpxLog(ctx, payload) {
|
|
2320
2270
|
await ctx.onLog("stdout", `${JSON.stringify(payload)}\n`);
|
|
2321
2271
|
}
|
|
2322
|
-
/**
|
|
2323
|
-
* Build the short run summary that Paperclip may auto-post as an issue comment
|
|
2324
|
-
* when the agent leaves no comment of its own.
|
|
2325
|
-
*
|
|
2326
|
-
* Prefer the last non-empty *output* segment after a tool call. Intermediate
|
|
2327
|
-
* "let me check…" narration between tools must not become a 50k-char dump.
|
|
2328
|
-
* Thought-stream text is never included (callers must not push it into segments).
|
|
2329
|
-
*/
|
|
2330
2272
|
export function buildAcpxRunSummary(input) {
|
|
2331
2273
|
for (let i = input.outputSegments.length - 1; i >= 0; i -= 1) {
|
|
2332
2274
|
const text = (input.outputSegments[i] ?? "").trim();
|
|
@@ -2641,7 +2583,7 @@ async function emitAcpxFailure(input) {
|
|
|
2641
2583
|
? null
|
|
2642
2584
|
: await readChildStderrTail({ logPath: prepared.childStderrLogPath });
|
|
2643
2585
|
if (childStderrTail) {
|
|
2644
|
-
await ctx.onLog("stderr", `[
|
|
2586
|
+
await ctx.onLog("stderr", `[wardmote] ACPX child stderr tail (${phase}):\n${childStderrTail}\n`);
|
|
2645
2587
|
}
|
|
2646
2588
|
await emitAcpxLog(ctx, {
|
|
2647
2589
|
type: "acpx.error",
|
|
@@ -2873,10 +2815,10 @@ const TURN_SPAN_NAME = "agent.turn";
|
|
|
2873
2815
|
/** The attribute prefix for the run root span. It groups the run-level span
|
|
2874
2816
|
* attributes under one namespace, the same shape as the sandbox startup
|
|
2875
2817
|
* prefix. */
|
|
2876
|
-
const RUN_ROOT_SPAN_ATTR_PREFIX = "
|
|
2818
|
+
const RUN_ROOT_SPAN_ATTR_PREFIX = "wardmote.task.run.";
|
|
2877
2819
|
/** The attribute prefix for the agent turn span. It groups the turn-level span
|
|
2878
2820
|
* attributes under one namespace, the same shape as the run root prefix. */
|
|
2879
|
-
const TURN_SPAN_ATTR_PREFIX = "
|
|
2821
|
+
const TURN_SPAN_ATTR_PREFIX = "wardmote.agent.turn.";
|
|
2880
2822
|
/** Map a run id to a non-reversible 12-hex hash for a span attribute. The raw
|
|
2881
2823
|
* run id never rides a span; only this hash does. This mirrors the id-hash rule
|
|
2882
2824
|
* that `clampSpanLabel` uses for the startup ids. */
|
|
@@ -3028,7 +2970,7 @@ export function createAcpxEngineExecutor(deps = {}) {
|
|
|
3028
2970
|
idleMs: warmIdleMs,
|
|
3029
2971
|
closeWarmEntry: async (entry) => {
|
|
3030
2972
|
await entry.runtime
|
|
3031
|
-
.close({ handle: entry.handle, reason: "
|
|
2973
|
+
.close({ handle: entry.handle, reason: "wardmote idle cleanup", discardPersistentState: false })
|
|
3032
2974
|
.catch(() => { });
|
|
3033
2975
|
flushChildStderr(entry.childStderrState);
|
|
3034
2976
|
},
|
|
@@ -3202,7 +3144,7 @@ export function createAcpxEngineExecutor(deps = {}) {
|
|
|
3202
3144
|
? teardownErr.message
|
|
3203
3145
|
: String(teardownErr);
|
|
3204
3146
|
await withAdapterExecutionPhase(ctx, "phase_reporting", () => ctx
|
|
3205
|
-
.onLog("stderr", `[
|
|
3147
|
+
.onLog("stderr", `[wardmote] ACPX teardown step "${step}" failed: ${reason}\n`)
|
|
3206
3148
|
.catch(() => { }));
|
|
3207
3149
|
};
|
|
3208
3150
|
// Emit one per-phase timing run-log event. It is not an OpenTelemetry
|
|
@@ -3326,13 +3268,13 @@ export function createAcpxEngineExecutor(deps = {}) {
|
|
|
3326
3268
|
// the failed project (per-project failure isolation). Goes to stderr: the
|
|
3327
3269
|
// acpx stdout log stream carries machine-parseable JSON event payloads.
|
|
3328
3270
|
for (const failure of referencedProjectStagingFailures) {
|
|
3329
|
-
await ctx.onLog("stderr", `[
|
|
3271
|
+
await ctx.onLog("stderr", `[wardmote] Referenced project ${failure.projectId} failed to stage; the run continues without it: ${failure.error}\n`);
|
|
3330
3272
|
}
|
|
3331
3273
|
// State the effective wall-clock timeout and its source up front so a
|
|
3332
3274
|
// later timeout is diagnosable from the run log alone. Goes to stderr:
|
|
3333
3275
|
// the acpx stdout log stream carries JSON acpx.* event payloads and must
|
|
3334
3276
|
// stay machine-parseable line by line.
|
|
3335
|
-
await ctx.onLog("stderr", `[
|
|
3277
|
+
await ctx.onLog("stderr", `[wardmote] ${formatAdapterExecutionTimeoutStartLogLine(prepared.timeoutResolution)}\n`);
|
|
3336
3278
|
await hostStore.evictIdle(now());
|
|
3337
3279
|
const previousParams = parseObject(ctx.runtime.sessionParams);
|
|
3338
3280
|
const canResume = isCompatibleSession(previousParams, prepared);
|
|
@@ -3387,9 +3329,6 @@ export function createAcpxEngineExecutor(deps = {}) {
|
|
|
3387
3329
|
// and custom agents already emit their own per-tool output and don't
|
|
3388
3330
|
// benefit from doubling the log volume.
|
|
3389
3331
|
verbose: prepared.acpxAgent === "claude",
|
|
3390
|
-
// The engine passes a complete, sanitized launch environment. ACPX
|
|
3391
|
-
// must not merge the Paperclip server's ambient environment back in
|
|
3392
|
-
// when it spawns the provider child.
|
|
3393
3332
|
inheritProcessEnv: false,
|
|
3394
3333
|
onAgentStderr: prepared.childStderrLogPath
|
|
3395
3334
|
? (chunk) => routeChildStderr(childStderrState, chunk)
|
|
@@ -3446,14 +3385,14 @@ export function createAcpxEngineExecutor(deps = {}) {
|
|
|
3446
3385
|
scope: "per_run",
|
|
3447
3386
|
});
|
|
3448
3387
|
if (!canResume && asString(previousParams.runtimeSessionName, "")) {
|
|
3449
|
-
await ctx.onLog("stdout", `[
|
|
3388
|
+
await ctx.onLog("stdout", `[wardmote] ACPX session "${asString(previousParams.runtimeSessionName, "")}" does not match the current agent/cwd/mode/runtime identity; starting fresh in "${prepared.cwd}".\n`);
|
|
3450
3389
|
}
|
|
3451
3390
|
let handle = cached?.handle ?? null;
|
|
3452
3391
|
// The ensure_session phase covers the handshake (session establishment or
|
|
3453
3392
|
// resume) up to the established handle.
|
|
3454
3393
|
const ensureSessionPhaseStart = now();
|
|
3455
3394
|
resumedSession = Boolean(handle ?? resumeSessionId);
|
|
3456
|
-
const isHandshakeTransportLost = () => prepared.
|
|
3395
|
+
const isHandshakeTransportLost = () => prepared.wardmoteBridge?.readRunDisposition?.().failed ?? false;
|
|
3457
3396
|
// The fence's own close, for a real handle that resolves after
|
|
3458
3397
|
// `endSession` already sealed. `endSession` closed the synthetic
|
|
3459
3398
|
// placeholder by then (or skipped closing because the channel was
|
|
@@ -3471,11 +3410,11 @@ export function createAcpxEngineExecutor(deps = {}) {
|
|
|
3471
3410
|
void runtime
|
|
3472
3411
|
.close({
|
|
3473
3412
|
handle: lateHandle,
|
|
3474
|
-
reason: "
|
|
3413
|
+
reason: "wardmote late handshake cleanup",
|
|
3475
3414
|
discardPersistentState: false,
|
|
3476
3415
|
})
|
|
3477
3416
|
.catch(() => ctx
|
|
3478
|
-
.onLog("stderr", "[
|
|
3417
|
+
.onLog("stderr", "[wardmote] ACPX handshake late close failed: acpx_handshake_late_close_failed\n")
|
|
3479
3418
|
.catch(() => { }));
|
|
3480
3419
|
};
|
|
3481
3420
|
// The late rejection comes from inside the sandbox. It crosses the
|
|
@@ -3483,7 +3422,7 @@ export function createAcpxEngineExecutor(deps = {}) {
|
|
|
3483
3422
|
// the result, or a classification: log the fixed closed code only.
|
|
3484
3423
|
const recordLateHandshakeRejection = () => {
|
|
3485
3424
|
void ctx
|
|
3486
|
-
.onLog("stderr", "[
|
|
3425
|
+
.onLog("stderr", "[wardmote] ACPX handshake late rejection: acpx_handshake_late_rejection\n")
|
|
3487
3426
|
.catch(() => { });
|
|
3488
3427
|
};
|
|
3489
3428
|
try {
|
|
@@ -3526,7 +3465,7 @@ export function createAcpxEngineExecutor(deps = {}) {
|
|
|
3526
3465
|
throw err;
|
|
3527
3466
|
clearSession = true;
|
|
3528
3467
|
resumedSession = false;
|
|
3529
|
-
await ctx.onLog("stdout", `[
|
|
3468
|
+
await ctx.onLog("stdout", `[wardmote] ACPX resume session "${resumeSessionId}" is unavailable; retrying with a fresh session.\n`);
|
|
3530
3469
|
// Fresh-session retry: the runtime was already constructed on the
|
|
3531
3470
|
// first attempt (never re-created), so this event reports only its
|
|
3532
3471
|
// own `ensureSessionMs` — no `createRuntimeMs`.
|
|
@@ -3604,7 +3543,7 @@ export function createAcpxEngineExecutor(deps = {}) {
|
|
|
3604
3543
|
runtimeSettlement = {
|
|
3605
3544
|
mode: "direct",
|
|
3606
3545
|
handle: handle ?? syntheticCloseHandle(),
|
|
3607
|
-
reason: "
|
|
3546
|
+
reason: "wardmote handshake cleanup",
|
|
3608
3547
|
discardPersistentState: false,
|
|
3609
3548
|
dropWarmEntry: true,
|
|
3610
3549
|
recordCloseError: true,
|
|
@@ -3740,7 +3679,7 @@ export function createAcpxEngineExecutor(deps = {}) {
|
|
|
3740
3679
|
runtimeSettlement = {
|
|
3741
3680
|
mode: "direct",
|
|
3742
3681
|
handle: sessionHandle,
|
|
3743
|
-
reason: "
|
|
3682
|
+
reason: "wardmote config cleanup",
|
|
3744
3683
|
discardPersistentState: false,
|
|
3745
3684
|
dropWarmEntry: true,
|
|
3746
3685
|
recordCloseError: true,
|
|
@@ -3834,7 +3773,7 @@ export function createAcpxEngineExecutor(deps = {}) {
|
|
|
3834
3773
|
// boundary. A failure here returns an error result with phase
|
|
3835
3774
|
// `prepare_turn`.
|
|
3836
3775
|
preparePhaseStart = now();
|
|
3837
|
-
const { prompt, promptMetrics, commandNotes } = await buildPrompt(ctx, resumedSession, prepared.env, prepared.
|
|
3776
|
+
const { prompt, promptMetrics, commandNotes } = await buildPrompt(ctx, resumedSession, prepared.env, prepared.wardmoteAccess, prepared.wardmoteToolsets);
|
|
3838
3777
|
runPrompt = joinPromptSections([prepared.skillPromptInstructions, prompt]);
|
|
3839
3778
|
await emitAcpxLog(ctx, {
|
|
3840
3779
|
type: "acpx.session",
|
|
@@ -3855,7 +3794,7 @@ export function createAcpxEngineExecutor(deps = {}) {
|
|
|
3855
3794
|
command: prepared.agentCommand ?? prepared.acpxAgent,
|
|
3856
3795
|
cwd: prepared.cwd,
|
|
3857
3796
|
commandNotes: [
|
|
3858
|
-
`ACPX runtime embedded in
|
|
3797
|
+
`ACPX runtime embedded in Wardmote with ${prepared.mode} session mode.`,
|
|
3859
3798
|
`Effective ACPX permission mode: ${prepared.permissionMode}.`,
|
|
3860
3799
|
...(prepared.requestedModel
|
|
3861
3800
|
? [
|
|
@@ -3924,10 +3863,10 @@ export function createAcpxEngineExecutor(deps = {}) {
|
|
|
3924
3863
|
// before this turn started — so the turn returns a terminal result
|
|
3925
3864
|
// right away. `turnFinalize` reads the same latch and builds the
|
|
3926
3865
|
// failure from the typed loss reason alone.
|
|
3927
|
-
const bridge = prepared.
|
|
3866
|
+
const bridge = prepared.wardmoteBridge;
|
|
3928
3867
|
if (bridge?.onLoss) {
|
|
3929
3868
|
const cancelForLoss = (reason) => {
|
|
3930
|
-
void turn.cancel({ reason: `
|
|
3869
|
+
void turn.cancel({ reason: `wardmote sandbox duplex channel lost (${reason})` }).catch(() => { });
|
|
3931
3870
|
// `cancel()` only asks the agent to end the turn; it does not end
|
|
3932
3871
|
// the turn by itself. Start the fail-fast deadline the moment the
|
|
3933
3872
|
// loss latches, so the run does not wait past this bound for an
|
|
@@ -4078,7 +4017,7 @@ export function createAcpxEngineExecutor(deps = {}) {
|
|
|
4078
4017
|
// nominally completed terminal. The file bridge path never sets this
|
|
4079
4018
|
// method, so the optional call no-ops there.
|
|
4080
4019
|
let duplexLossReason = null;
|
|
4081
|
-
const disposition = prepared.
|
|
4020
|
+
const disposition = prepared.wardmoteBridge?.settleRunDisposition?.() ?? null;
|
|
4082
4021
|
if (disposition?.failed) {
|
|
4083
4022
|
duplexLossReason = disposition.lossReason ?? "other";
|
|
4084
4023
|
}
|
|
@@ -4137,12 +4076,12 @@ export function createAcpxEngineExecutor(deps = {}) {
|
|
|
4137
4076
|
mode: "warm_or_close",
|
|
4138
4077
|
handle: sessionHandle,
|
|
4139
4078
|
reason: timedOut
|
|
4140
|
-
? "
|
|
4079
|
+
? "wardmote timeout cleanup"
|
|
4141
4080
|
: channelLost
|
|
4142
|
-
? "
|
|
4081
|
+
? "wardmote duplex channel lost cleanup"
|
|
4143
4082
|
: failedTurn
|
|
4144
|
-
? `
|
|
4145
|
-
: "
|
|
4083
|
+
? `wardmote turn ${terminal.status}`
|
|
4084
|
+
: "wardmote completed turn cleanup",
|
|
4146
4085
|
discardPersistentState: sessionUnavailable || (terminal.status === "cancelled" && !preserveInterruptedSession) || timedOut || channelLost,
|
|
4147
4086
|
dropWarmEntry: false,
|
|
4148
4087
|
recordCloseError: false,
|
|
@@ -4298,7 +4237,7 @@ export function createAcpxEngineExecutor(deps = {}) {
|
|
|
4298
4237
|
runtimeSettlement = {
|
|
4299
4238
|
mode: "direct",
|
|
4300
4239
|
handle: sessionHandle,
|
|
4301
|
-
reason: timedOut ? "
|
|
4240
|
+
reason: timedOut ? "wardmote timeout cleanup" : "wardmote error cleanup",
|
|
4302
4241
|
discardPersistentState: timedOut,
|
|
4303
4242
|
dropWarmEntry: true,
|
|
4304
4243
|
recordCloseError: true,
|
|
@@ -4421,7 +4360,7 @@ export function createAcpxEngineExecutor(deps = {}) {
|
|
|
4421
4360
|
const baseSettlement = runtimeSettlement ?? {
|
|
4422
4361
|
mode: "direct",
|
|
4423
4362
|
handle: syntheticCloseHandle(),
|
|
4424
|
-
reason: "
|
|
4363
|
+
reason: "wardmote cleanup",
|
|
4425
4364
|
discardPersistentState: false,
|
|
4426
4365
|
dropWarmEntry: false,
|
|
4427
4366
|
recordCloseError: true,
|
|
@@ -4446,7 +4385,7 @@ export function createAcpxEngineExecutor(deps = {}) {
|
|
|
4446
4385
|
// a stale `false` on the snapshot must not force a call onto a
|
|
4447
4386
|
// channel that is dead by now. The read is non-mutating and only
|
|
4448
4387
|
// adds a later-observed loss; it never clears the snapshot's `true`.
|
|
4449
|
-
const remoteChannelLost = settlement.skipRemoteClose || (prepared.
|
|
4388
|
+
const remoteChannelLost = settlement.skipRemoteClose || (prepared.wardmoteBridge?.readRunDisposition?.().failed ?? false);
|
|
4450
4389
|
// The control channel is already known lost, so no remote call can
|
|
4451
4390
|
// reach the backend. Release the local bookkeeping only and place no
|
|
4452
4391
|
// `runtime.close(...)` call — that call has no deadline of its own
|