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