@tickernelz/wardmote-adapter-utils 2026.1108.2 → 2026.1109.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/dist/acpx-engine/ephemeral-session-environment.test.js +5 -5
- package/dist/acpx-engine/ephemeral-session-environment.test.js.map +1 -1
- package/dist/acpx-engine/execute-identity.test.js +11 -11
- package/dist/acpx-engine/execute-identity.test.js.map +1 -1
- package/dist/acpx-engine/execute.d.ts.map +1 -1
- package/dist/acpx-engine/execute.js +39 -40
- package/dist/acpx-engine/execute.js.map +1 -1
- package/dist/acpx-engine/execute.test.js +78 -78
- 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/operator-stop.test.js +2 -2
- package/dist/acpx-engine/operator-stop.test.js.map +1 -1
- package/dist/acpx-engine/run-site-sandbox.test.js +3 -3
- package/dist/acpx-engine/run-site-sandbox.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 +13 -13
- package/dist/acpx-engine/startup-characterization.test.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/command-managed-runtime.test.js +2 -2
- package/dist/command-managed-runtime.test.js.map +1 -1
- package/dist/directory-merge-lock.test.js +2 -2
- package/dist/directory-merge-lock.test.js.map +1 -1
- package/dist/execution-target-sandbox.test.js +102 -102
- package/dist/execution-target-sandbox.test.js.map +1 -1
- package/dist/execution-target-stdin-race.test.js +25 -25
- package/dist/execution-target-stdin-race.test.js.map +1 -1
- package/dist/execution-target.d.ts.map +1 -1
- package/dist/execution-target.js +59 -60
- package/dist/execution-target.js.map +1 -1
- package/dist/execution-target.test.js +2 -2
- 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.js +1 -1
- package/dist/git-workspace-sync.js.map +1 -1
- package/dist/github-launcher-environment.test.js +31 -31
- package/dist/github-launcher-environment.test.js.map +1 -1
- package/dist/github-launcher.js +9 -9
- package/dist/github-launcher.js.map +1 -1
- package/dist/index.d.ts +3 -3
- 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.test.js +8 -8
- package/dist/local-process-sandbox.test.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/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 +2 -2
- package/dist/runner-connectivity.d.ts.map +1 -1
- package/dist/runner-connectivity.js +5 -5
- package/dist/runner-connectivity.js.map +1 -1
- package/dist/sandbox-callback-bridge.js +27 -27
- package/dist/sandbox-callback-bridge.js.map +1 -1
- package/dist/sandbox-callback-bridge.test.js +27 -27
- package/dist/sandbox-callback-bridge.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.test.js +4 -4
- package/dist/sandbox-managed-runtime.test.js.map +1 -1
- package/dist/sandbox-run-log-stream.js +4 -4
- package/dist/sandbox-run-log-stream.js.map +1 -1
- package/dist/server-utils-env.test.js +2 -2
- package/dist/server-utils-env.test.js.map +1 -1
- package/dist/server-utils.d.ts +5 -5
- package/dist/server-utils.d.ts.map +1 -1
- package/dist/server-utils.js +87 -87
- package/dist/server-utils.js.map +1 -1
- package/dist/server-utils.test.js +75 -75
- package/dist/server-utils.test.js.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.js +2 -2
- package/dist/ssh.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/{paperclip-mcp-mount.d.ts → wardmote-mcp-mount.d.ts} +1 -1
- package/dist/wardmote-mcp-mount.d.ts.map +1 -0
- package/dist/{paperclip-mcp-mount.js → wardmote-mcp-mount.js} +10 -10
- package/dist/wardmote-mcp-mount.js.map +1 -0
- package/dist/{paperclip-mcp.d.ts → wardmote-mcp.d.ts} +9 -9
- package/dist/wardmote-mcp.d.ts.map +1 -0
- package/dist/{paperclip-mcp.js → wardmote-mcp.js} +36 -36
- 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/{paperclip-mcp.test.js → wardmote-mcp.test.js} +14 -14
- package/dist/wardmote-mcp.test.js.map +1 -0
- package/dist/{paperclip-runner-permissions.d.ts → wardmote-runner-permissions.d.ts} +18 -18
- package/dist/wardmote-runner-permissions.d.ts.map +1 -0
- package/dist/{paperclip-runner-permissions.js → wardmote-runner-permissions.js} +22 -22
- 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/{paperclip-runner-permissions.test.js → wardmote-runner-permissions.test.js} +7 -7
- package/dist/wardmote-runner-permissions.test.js.map +1 -0
- package/dist/workspace-manifest.js +1 -1
- package/dist/workspace-manifest.js.map +1 -1
- package/dist/workspace-manifest.test.js +2 -2
- package/dist/workspace-manifest.test.js.map +1 -1
- package/dist/workspace-restore-merge.js +5 -5
- package/dist/workspace-restore-merge.js.map +1 -1
- package/dist/workspace-restore-merge.test.js +27 -27
- package/dist/workspace-restore-merge.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.map +0 -1
- 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.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.map +0 -1
- package/node_modules/sisteransi/src/index.js +0 -58
- package/node_modules/sisteransi/src/sisteransi.d.ts +0 -35
package/dist/server-utils.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { currentEnvKey } from "@tickernelz/wardmote-shared/retired-env-file";
|
|
1
2
|
import { spawn } from "node:child_process";
|
|
2
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
3
4
|
import { constants as fsConstants, promises as fs } from "node:fs";
|
|
4
5
|
import os from "node:os";
|
|
5
6
|
import path from "node:path";
|
|
6
7
|
import { CONNECTION_INTENT_AGENT_GUIDANCE } from "@tickernelz/wardmote-shared";
|
|
7
|
-
import { legacyEnvKey, withWardmoteEnvAliases } from "@tickernelz/wardmote-shared/env-aliases";
|
|
8
8
|
import { resolveDefaultPaperclipHomeDir } from "@tickernelz/wardmote-shared/home-paths";
|
|
9
9
|
import { sanitizeRemoteExecutionEnv } from "./remote-execution-env.js";
|
|
10
10
|
import { buildLocalProcessSandboxSpawnTarget, } from "./local-process-sandbox.js";
|
|
@@ -12,18 +12,18 @@ import { buildSshSpawnTarget } from "./ssh.js";
|
|
|
12
12
|
import { redactCommandText } from "./command-redaction.js";
|
|
13
13
|
import { applyRunOomScoreAdj } from "./run-oom-score.js";
|
|
14
14
|
import { paperclipChatFilePreparationDelivery } from "./chat-file-delivery.js";
|
|
15
|
-
import {
|
|
15
|
+
import { WARDMOTE_RUNNER_PERMISSION_CAPABILITIES, resolvePaperclipRunnerModel, normalizeLegacyRunnerProvider, } from "./wardmote-runner-permissions.js";
|
|
16
16
|
export function buildRuntimeToolsEnv(access) {
|
|
17
17
|
if (!access)
|
|
18
18
|
return {};
|
|
19
19
|
return {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
WARDMOTE_RUNTIME_TOOLS_MCP_URL: access.mcpEndpoint,
|
|
21
|
+
WARDMOTE_RUNTIME_TOOLS_TOKEN: access.bearerToken,
|
|
22
|
+
WARDMOTE_RUNTIME_TOOLS_EXPIRES_AT: access.expiresAt,
|
|
23
|
+
WARDMOTE_RUNTIME_TOOLS_CONNECTIONS_SEARCH_URL: access.rest.connectionsSearch,
|
|
24
|
+
WARDMOTE_RUNTIME_TOOLS_CONNECTION_REQUEST_URL: access.rest.connectionRequest,
|
|
25
|
+
WARDMOTE_RUNTIME_TOOLS_AVAILABLE: access.tools.join(","),
|
|
26
|
+
WARDMOTE_RUNTIME_TOOLS_GUIDANCE: access.guidance,
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
export const UNMANAGED_BACKGROUND_TASK_STOP_REASON = "unmanaged_background_task_stopped";
|
|
@@ -57,28 +57,28 @@ export const runningProcesses = new Map();
|
|
|
57
57
|
export const MAX_CAPTURE_BYTES = 4 * 1024 * 1024;
|
|
58
58
|
export const MAX_EXCERPT_BYTES = 32 * 1024;
|
|
59
59
|
const TERMINAL_RESULT_SCAN_OVERLAP_CHARS = 64 * 1024;
|
|
60
|
-
const
|
|
60
|
+
const DEFAULT_WARDMOTE_INSTANCE_ID = "default";
|
|
61
61
|
const PATH_SEGMENT_RE = /^[a-zA-Z0-9_-]+$/;
|
|
62
62
|
const SENSITIVE_ENV_KEY = /(key|token|secret|password|passwd|authorization|cookie)/i;
|
|
63
63
|
const REDACTED_LOG_VALUE = "***REDACTED***";
|
|
64
|
-
//
|
|
64
|
+
// WARDMOTE_* is the reserved runtime namespace: these vars are generated by
|
|
65
65
|
// Paperclip per run (identity, wake, workspace, API access). Adapter/user
|
|
66
66
|
// config env must never override them.
|
|
67
67
|
export function isPaperclipRuntimeEnvKey(key) {
|
|
68
|
-
return
|
|
68
|
+
return key.startsWith("WARDMOTE_");
|
|
69
69
|
}
|
|
70
|
-
//
|
|
70
|
+
// WARDMOTE_API_KEY is never accepted from adapter/user config env: the
|
|
71
71
|
// harness-minted run token is the only source of Paperclip API identity.
|
|
72
|
-
//
|
|
72
|
+
// WARDMOTE_WAKE_PAYLOAD_JSON is retired: wake context travels in the prompt,
|
|
73
73
|
// and a configured copy can exceed OS process-launch limits.
|
|
74
|
-
// Other
|
|
74
|
+
// Other WARDMOTE_*-named config keys are allowed as long as Paperclip has
|
|
75
75
|
// not assigned the same key for the run (runtime vars always win).
|
|
76
76
|
export function isForbiddenConfigEnvKey(key) {
|
|
77
|
-
const
|
|
78
|
-
return
|
|
79
|
-
AGENT_IDENTITY_ENV_KEYS.includes(
|
|
77
|
+
const current = currentEnvKey(key);
|
|
78
|
+
return current === "WARDMOTE_API_KEY" || current === "WARDMOTE_WAKE_PAYLOAD_JSON" ||
|
|
79
|
+
AGENT_IDENTITY_ENV_KEYS.includes(currentEnvKey(key.toUpperCase()));
|
|
80
80
|
}
|
|
81
|
-
const
|
|
81
|
+
const WARDMOTE_SKILL_ROOT_RELATIVE_CANDIDATES = [
|
|
82
82
|
"../../skills",
|
|
83
83
|
"../../../../../skills",
|
|
84
84
|
];
|
|
@@ -94,13 +94,13 @@ function expandHomePrefix(value) {
|
|
|
94
94
|
}
|
|
95
95
|
export function resolvePaperclipInstanceRootForAdapter(input = {}) {
|
|
96
96
|
const env = input.env ?? process.env;
|
|
97
|
-
const homeRaw = input.homeDir?.trim() || env.
|
|
97
|
+
const homeRaw = input.homeDir?.trim() || env.WARDMOTE_HOME?.trim();
|
|
98
98
|
const homeDir = path.resolve(homeRaw ? expandHomePrefix(homeRaw) : resolveDefaultPaperclipHomeDir());
|
|
99
99
|
const instanceId = input.instanceId?.trim() ||
|
|
100
|
-
env.
|
|
101
|
-
|
|
100
|
+
env.WARDMOTE_INSTANCE_ID?.trim() ||
|
|
101
|
+
DEFAULT_WARDMOTE_INSTANCE_ID;
|
|
102
102
|
if (!PATH_SEGMENT_RE.test(instanceId))
|
|
103
|
-
throw new Error(`Invalid
|
|
103
|
+
throw new Error(`Invalid WARDMOTE_INSTANCE_ID '${instanceId}'.`);
|
|
104
104
|
return path.resolve(homeDir, "instances", instanceId);
|
|
105
105
|
}
|
|
106
106
|
/** The heartbeat contract, rendered against the Paperclip surface the adapter actually armed. */
|
|
@@ -119,14 +119,14 @@ export function paperclipAgentPromptTemplate(access) {
|
|
|
119
119
|
"- Use child issues for parallel or long delegated work instead of polling agents, sessions, or processes.",
|
|
120
120
|
"- If woken by a human comment on a dependency-blocked issue, respond or triage the comment without treating the blocked deliverable work as unblocked.",
|
|
121
121
|
"- Create child issues directly when you know what needs to be done; use issue-thread interactions when the board/user must choose suggested tasks, answer structured questions, or confirm a proposal.",
|
|
122
|
-
"- Use `
|
|
122
|
+
"- Use `WARDMOTE_SCRATCH_DIR` / `WARDMOTE_RUN_SCRATCH_DIR` for temporary scratch files instead of ad hoc `/tmp` paths; Paperclip removes that run-owned directory after the run ends.",
|
|
123
123
|
mcp
|
|
124
|
-
? "- To ask for that input, create an interaction on the current issue with `paperclipSuggestTasks`, `paperclipAskUserQuestions`, or `paperclipRequestConfirmation` using `issueId: $
|
|
125
|
-
: "- To ask for that input, create an interaction on the current issue with POST /api/issues/$
|
|
124
|
+
? "- To ask for that input, create an interaction on the current issue with `paperclipSuggestTasks`, `paperclipAskUserQuestions`, or `paperclipRequestConfirmation` using `issueId: $WARDMOTE_TASK_ID`. Use continuationPolicy wake_assignee when you need to resume after a response (it wakes on acceptance and rejection alike; only expiry does not wake); use wake_assignee_on_accept when you want to resume only after acceptance."
|
|
125
|
+
: "- To ask for that input, create an interaction on the current issue with POST /api/issues/$WARDMOTE_TASK_ID/interactions using kind suggest_tasks, ask_user_questions, or request_confirmation. Use continuationPolicy wake_assignee when you need to resume after a response (it wakes on acceptance and rejection alike; only expiry does not wake); use wake_assignee_on_accept when you want to resume only after acceptance.",
|
|
126
126
|
"- Never create probe or throwaway issue-thread interactions to discover the interactions API shape or your permissions; schema discovery goes through the OpenAPI spec and explicit validation errors, not placeholder cards. Every ask_user_questions, suggest_tasks, or request_confirmation you post must carry a real, answerable prompt; withdraw one you no longer need instead of leaving it pending.",
|
|
127
127
|
mcp
|
|
128
128
|
? "- When you intentionally restart follow-up work on a completed assigned issue, include structured `resume: true` in the `paperclipAddComment` or `paperclipUpdateIssue` arguments for that issue (substitute that issue's real id when it is not the current task). Generic agent comments on closed issues are inert by default."
|
|
129
|
-
: "- When you intentionally restart follow-up work on a completed assigned issue, include structured `resume: true` with the POST /api/issues/$
|
|
129
|
+
: "- When you intentionally restart follow-up work on a completed assigned issue, include structured `resume: true` with the POST /api/issues/$WARDMOTE_TASK_ID/comments or PATCH /api/issues/$WARDMOTE_TASK_ID comment payload (substitute that issue's real id when it is not the current task). Generic agent comments on closed issues are inert by default.",
|
|
130
130
|
"- For plan approval, update the plan document first, then create request_confirmation targeting the latest plan revision with idempotencyKey confirmation:{issueId}:plan:{revisionId}. Wait for acceptance before creating implementation subtasks, and create a fresh confirmation after superseding board/user comments if approval is still needed.",
|
|
131
131
|
"- If blocked, mark the issue blocked and name the unblock owner and action.",
|
|
132
132
|
"- Respect budget, pause/cancel, approval gates, and company boundaries.",
|
|
@@ -135,14 +135,14 @@ export function paperclipAgentPromptTemplate(access) {
|
|
|
135
135
|
CONNECTION_INTENT_AGENT_GUIDANCE,
|
|
136
136
|
].join("\n");
|
|
137
137
|
}
|
|
138
|
-
export const
|
|
138
|
+
export const DEFAULT_WARDMOTE_AGENT_PROMPT_TEMPLATE = [
|
|
139
139
|
"You are agent {{agent.id}} ({{agent.name}}).",
|
|
140
140
|
"",
|
|
141
141
|
CONNECTION_INTENT_AGENT_GUIDANCE,
|
|
142
142
|
].join("\n");
|
|
143
143
|
// Task/chat modes arrive in server-owned context; operational procedures live
|
|
144
144
|
// in the harness-delivered Paperclip skill rather than either default template.
|
|
145
|
-
export const
|
|
145
|
+
export const DEFAULT_WARDMOTE_CONVERSATION_PROMPT_TEMPLATE = DEFAULT_WARDMOTE_AGENT_PROMPT_TEMPLATE;
|
|
146
146
|
export const WATCHDOG_DEFAULT_MANDATE = [
|
|
147
147
|
"You are running as a task watchdog, not as the original deliverable worker.",
|
|
148
148
|
"Your mission is to keep the watched issue tree moving by verifying stopped work, not by trusting agent claims.",
|
|
@@ -926,7 +926,7 @@ function markdownFencedText(value) {
|
|
|
926
926
|
const fence = "`".repeat(Math.max(3, longestBacktickRun + 1));
|
|
927
927
|
return `${fence}text\n${value}\n${fence}`;
|
|
928
928
|
}
|
|
929
|
-
const
|
|
929
|
+
const WARDMOTE_EXTERNAL_CHAT_PROVIDERS = new Set([
|
|
930
930
|
"slack",
|
|
931
931
|
"github",
|
|
932
932
|
"discord",
|
|
@@ -937,7 +937,7 @@ const PAPERCLIP_EXTERNAL_CHAT_PROVIDERS = new Set([
|
|
|
937
937
|
]);
|
|
938
938
|
function normalizePaperclipExternalChatProvider(value) {
|
|
939
939
|
const provider = asString(value, "").trim().toLowerCase();
|
|
940
|
-
return
|
|
940
|
+
return WARDMOTE_EXTERNAL_CHAT_PROVIDERS.has(provider)
|
|
941
941
|
? provider
|
|
942
942
|
: null;
|
|
943
943
|
}
|
|
@@ -1133,7 +1133,7 @@ export function isPaperclipRecoveryWakePayload(value) {
|
|
|
1133
1133
|
return Boolean(normalized?.recovery ||
|
|
1134
1134
|
normalized?.reason === "source_scoped_recovery_action");
|
|
1135
1135
|
}
|
|
1136
|
-
const
|
|
1136
|
+
const WARDMOTE_EXTERNAL_CHAT_WAKE_REASONS = new Set([
|
|
1137
1137
|
"External chat message received",
|
|
1138
1138
|
"issue_assigned",
|
|
1139
1139
|
"issue_commented",
|
|
@@ -1143,7 +1143,7 @@ function hasNormalizedPaperclipExternalChatContext(normalized) {
|
|
|
1143
1143
|
(!normalized.checkedOutByHarness &&
|
|
1144
1144
|
!normalized.externalChatExecutionBound) ||
|
|
1145
1145
|
!normalized.issue?.id ||
|
|
1146
|
-
!
|
|
1146
|
+
!WARDMOTE_EXTERNAL_CHAT_WAKE_REASONS.has(normalized.reason ?? "")) {
|
|
1147
1147
|
return false;
|
|
1148
1148
|
}
|
|
1149
1149
|
if (normalized.issue.workMode !== "standard" &&
|
|
@@ -1271,7 +1271,7 @@ export function readPaperclipIssueWorkModeFromContext(value) {
|
|
|
1271
1271
|
}
|
|
1272
1272
|
// Wake reasons that (re)start work on an issue, where the session may not have
|
|
1273
1273
|
// seen the task brief yet even though the adapter session itself is resuming.
|
|
1274
|
-
const
|
|
1274
|
+
const ASSIGNMENT_SHAPED_WARDMOTE_WAKE_REASONS = new Set([
|
|
1275
1275
|
"issue_assigned",
|
|
1276
1276
|
"issue_reopened_via_comment",
|
|
1277
1277
|
"issue_recovery_action_restored",
|
|
@@ -1279,7 +1279,7 @@ const ASSIGNMENT_SHAPED_PAPERCLIP_WAKE_REASONS = new Set([
|
|
|
1279
1279
|
]);
|
|
1280
1280
|
export function isAssignmentShapedPaperclipWakeReason(reason) {
|
|
1281
1281
|
return (typeof reason === "string" &&
|
|
1282
|
-
|
|
1282
|
+
ASSIGNMENT_SHAPED_WARDMOTE_WAKE_REASONS.has(reason));
|
|
1283
1283
|
}
|
|
1284
1284
|
// Select at the actual provider attempt boundary so a failed resume restores
|
|
1285
1285
|
// the original snapshot once when retrying with a fresh session.
|
|
@@ -1950,7 +1950,7 @@ function renderPaperclipWakePromptBody(value, options = {}) {
|
|
|
1950
1950
|
}
|
|
1951
1951
|
if (normalized.checkedOutByHarness && !externalChatContract) {
|
|
1952
1952
|
lines.push("", "The harness already checked out this issue for the current run.", options.paperclipAccess === "rest"
|
|
1953
|
-
? "Do not call `POST /api/issues/$
|
|
1953
|
+
? "Do not call `POST /api/issues/$WARDMOTE_TASK_ID/checkout` again unless you intentionally switch to a different task."
|
|
1954
1954
|
: "Do not call `paperclipCheckoutIssue` for it again unless you intentionally switch to a different task.", "");
|
|
1955
1955
|
}
|
|
1956
1956
|
const appendQuestionResponse = () => {
|
|
@@ -2035,19 +2035,19 @@ export function buildInvocationEnvForLogs(env, options = {}) {
|
|
|
2035
2035
|
}
|
|
2036
2036
|
const resolvedCommand = options.resolvedCommand?.trim();
|
|
2037
2037
|
if (resolvedCommand) {
|
|
2038
|
-
merged[options.resolvedCommandEnvKey ?? "
|
|
2038
|
+
merged[options.resolvedCommandEnvKey ?? "WARDMOTE_RESOLVED_COMMAND"] =
|
|
2039
2039
|
redactCommandTextForLogs(resolvedCommand);
|
|
2040
2040
|
}
|
|
2041
2041
|
return redactEnvForLogs(merged);
|
|
2042
2042
|
}
|
|
2043
2043
|
export const AGENT_IDENTITY_ENV_KEYS = [
|
|
2044
|
-
"
|
|
2044
|
+
"WARDMOTE_AGENT_KEY_ID", "WARDMOTE_AGENT_PUBLIC_KEY", "WARDMOTE_AGENT_PRIVATE_KEY",
|
|
2045
2045
|
];
|
|
2046
2046
|
export function buildAgentIdentityEnv(identity) {
|
|
2047
2047
|
return identity ? {
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2048
|
+
WARDMOTE_AGENT_KEY_ID: identity.keyId,
|
|
2049
|
+
WARDMOTE_AGENT_PUBLIC_KEY: identity.publicKeyPem,
|
|
2050
|
+
WARDMOTE_AGENT_PRIVATE_KEY: identity.privateKeyPem,
|
|
2051
2051
|
} : {};
|
|
2052
2052
|
}
|
|
2053
2053
|
export function buildPaperclipEnv(agent, options = {}, identity) {
|
|
@@ -2060,35 +2060,35 @@ export function buildPaperclipEnv(agent, options = {}, identity) {
|
|
|
2060
2060
|
return host;
|
|
2061
2061
|
};
|
|
2062
2062
|
const vars = {
|
|
2063
|
-
|
|
2064
|
-
|
|
2063
|
+
WARDMOTE_AGENT_ID: agent.id,
|
|
2064
|
+
WARDMOTE_COMPANY_ID: agent.companyId,
|
|
2065
2065
|
...buildAgentIdentityEnv(identity),
|
|
2066
2066
|
};
|
|
2067
|
-
const runtimeHost = resolveHostForUrl(process.env.
|
|
2068
|
-
const runtimePort = process.env.
|
|
2069
|
-
// An explicit
|
|
2067
|
+
const runtimeHost = resolveHostForUrl(process.env.WARDMOTE_LISTEN_HOST ?? process.env.HOST ?? "localhost");
|
|
2068
|
+
const runtimePort = process.env.WARDMOTE_LISTEN_PORT ?? process.env.PORT ?? "3100";
|
|
2069
|
+
// An explicit WARDMOTE_API_URL override must win over the URL derived from
|
|
2070
2070
|
// authPublicBaseUrl: the derived URL can be unreachable from inside the
|
|
2071
2071
|
// runtime container (e.g. when the public base URL is VPN/tailnet-only).
|
|
2072
2072
|
const derivedApiUrl = `http://${runtimeHost}:${runtimePort}`;
|
|
2073
|
-
const listenHost = (process.env.
|
|
2073
|
+
const listenHost = (process.env.WARDMOTE_LISTEN_HOST ?? "").trim();
|
|
2074
2074
|
const loopbackHost = listenHost === "0.0.0.0" ? "127.0.0.1" : listenHost === "::" ? "[::1]" : resolveHostForUrl(listenHost);
|
|
2075
|
-
const apiUrl = (options.sameHost || identity) && process.env.
|
|
2076
|
-
? process.env.
|
|
2077
|
-
`http://${loopbackHost}:${process.env.
|
|
2078
|
-
: process.env.
|
|
2079
|
-
vars.
|
|
2075
|
+
const apiUrl = (options.sameHost || identity) && process.env.WARDMOTE_LISTEN_PORT
|
|
2076
|
+
? process.env.WARDMOTE_API_URL_OVERRIDE?.trim() ||
|
|
2077
|
+
`http://${loopbackHost}:${process.env.WARDMOTE_LISTEN_PORT}`
|
|
2078
|
+
: process.env.WARDMOTE_API_URL ?? process.env.WARDMOTE_RUNTIME_API_URL ?? derivedApiUrl;
|
|
2079
|
+
vars.WARDMOTE_API_URL = apiUrl;
|
|
2080
2080
|
return vars;
|
|
2081
2081
|
}
|
|
2082
2082
|
export function applyPaperclipWorkspaceEnv(env, input) {
|
|
2083
2083
|
const mappings = [
|
|
2084
|
-
["
|
|
2085
|
-
["
|
|
2086
|
-
["
|
|
2087
|
-
["
|
|
2088
|
-
["
|
|
2089
|
-
["
|
|
2090
|
-
["
|
|
2091
|
-
["
|
|
2084
|
+
["WARDMOTE_WORKSPACE_CWD", input.workspaceCwd],
|
|
2085
|
+
["WARDMOTE_WORKSPACE_SOURCE", input.workspaceSource],
|
|
2086
|
+
["WARDMOTE_WORKSPACE_STRATEGY", input.workspaceStrategy],
|
|
2087
|
+
["WARDMOTE_WORKSPACE_ID", input.workspaceId],
|
|
2088
|
+
["WARDMOTE_WORKSPACE_REPO_URL", input.workspaceRepoUrl],
|
|
2089
|
+
["WARDMOTE_WORKSPACE_REPO_REF", input.workspaceRepoRef],
|
|
2090
|
+
["WARDMOTE_WORKSPACE_BRANCH", input.workspaceBranch],
|
|
2091
|
+
["WARDMOTE_WORKSPACE_WORKTREE_PATH", input.workspaceWorktreePath],
|
|
2092
2092
|
["AGENT_HOME", input.agentHome],
|
|
2093
2093
|
];
|
|
2094
2094
|
for (const [key, value] of mappings) {
|
|
@@ -2219,9 +2219,9 @@ export function refreshPaperclipWorkspaceEnvForExecution(input) {
|
|
|
2219
2219
|
executionCwd: input.executionCwd,
|
|
2220
2220
|
stagedProjectDirs: input.stagedProjectDirs,
|
|
2221
2221
|
});
|
|
2222
|
-
delete input.env.
|
|
2223
|
-
delete input.env.
|
|
2224
|
-
delete input.env.
|
|
2222
|
+
delete input.env.WARDMOTE_WORKSPACE_CWD;
|
|
2223
|
+
delete input.env.WARDMOTE_WORKSPACE_WORKTREE_PATH;
|
|
2224
|
+
delete input.env.WARDMOTE_WORKSPACES_JSON;
|
|
2225
2225
|
applyPaperclipWorkspaceEnv(input.env, {
|
|
2226
2226
|
workspaceCwd: shapedWorkspaceEnv.workspaceCwd,
|
|
2227
2227
|
workspaceSource: input.workspaceSource,
|
|
@@ -2234,7 +2234,7 @@ export function refreshPaperclipWorkspaceEnvForExecution(input) {
|
|
|
2234
2234
|
agentHome: input.agentHome,
|
|
2235
2235
|
});
|
|
2236
2236
|
if (shapedWorkspaceEnv.workspaceHints.length > 0) {
|
|
2237
|
-
input.env.
|
|
2237
|
+
input.env.WARDMOTE_WORKSPACES_JSON = JSON.stringify(shapedWorkspaceEnv.workspaceHints);
|
|
2238
2238
|
}
|
|
2239
2239
|
const shapedEnvConfig = rewriteWorkspaceCwdEnvVarsForExecution({
|
|
2240
2240
|
env: input.envConfig ?? {},
|
|
@@ -2244,16 +2244,16 @@ export function refreshPaperclipWorkspaceEnvForExecution(input) {
|
|
|
2244
2244
|
});
|
|
2245
2245
|
for (const [key, value] of Object.entries(shapedEnvConfig)) {
|
|
2246
2246
|
// Adapter/user-configured env must never override a Paperclip-managed
|
|
2247
|
-
// runtime variable. Non-
|
|
2248
|
-
// secret_ref values) always forward to the spawned process; a
|
|
2247
|
+
// runtime variable. Non-WARDMOTE_* keys (plain values and resolved
|
|
2248
|
+
// secret_ref values) always forward to the spawned process; a WARDMOTE_*
|
|
2249
2249
|
// key from config only applies when Paperclip has NOT already assigned it
|
|
2250
|
-
// for this run.
|
|
2250
|
+
// for this run. WARDMOTE_API_KEY is never accepted from config — the
|
|
2251
2251
|
// harness-minted run token is the only source. This keeps runtime
|
|
2252
2252
|
// identity, wake, and workspace vars authoritative regardless of what a
|
|
2253
2253
|
// config binding sets.
|
|
2254
2254
|
if (isForbiddenConfigEnvKey(key))
|
|
2255
2255
|
continue;
|
|
2256
|
-
if (isPaperclipRuntimeEnvKey(key) &&
|
|
2256
|
+
if (isPaperclipRuntimeEnvKey(key) && key in input.env)
|
|
2257
2257
|
continue;
|
|
2258
2258
|
input.env[key] = value;
|
|
2259
2259
|
}
|
|
@@ -2266,18 +2266,18 @@ export function sanitizeInheritedPaperclipEnv(baseEnv) {
|
|
|
2266
2266
|
delete env.WATCHDOG_USEC;
|
|
2267
2267
|
delete env.WATCHDOG_PID;
|
|
2268
2268
|
for (const key of Object.keys(env)) {
|
|
2269
|
-
if (AGENT_IDENTITY_ENV_KEYS.includes(
|
|
2269
|
+
if (AGENT_IDENTITY_ENV_KEYS.includes(currentEnvKey(key.toUpperCase()))) {
|
|
2270
2270
|
delete env[key];
|
|
2271
2271
|
continue;
|
|
2272
2272
|
}
|
|
2273
|
-
const
|
|
2274
|
-
if (!
|
|
2273
|
+
const current = currentEnvKey(key);
|
|
2274
|
+
if (!current.startsWith("WARDMOTE_"))
|
|
2275
2275
|
continue;
|
|
2276
|
-
if (
|
|
2276
|
+
if (current === "WARDMOTE_RUNTIME_API_URL")
|
|
2277
2277
|
continue;
|
|
2278
|
-
if (
|
|
2278
|
+
if (current === "WARDMOTE_LISTEN_HOST")
|
|
2279
2279
|
continue;
|
|
2280
|
-
if (
|
|
2280
|
+
if (current === "WARDMOTE_LISTEN_PORT")
|
|
2281
2281
|
continue;
|
|
2282
2282
|
delete env[key];
|
|
2283
2283
|
}
|
|
@@ -2445,7 +2445,7 @@ export async function ensureAbsoluteDirectory(cwd, opts = {}) {
|
|
|
2445
2445
|
}
|
|
2446
2446
|
export async function resolvePaperclipSkillsDir(moduleDir, additionalCandidates = []) {
|
|
2447
2447
|
const candidates = [
|
|
2448
|
-
...
|
|
2448
|
+
...WARDMOTE_SKILL_ROOT_RELATIVE_CANDIDATES.map((relativePath) => path.resolve(moduleDir, relativePath)),
|
|
2449
2449
|
...additionalCandidates.map((candidate) => path.resolve(candidate)),
|
|
2450
2450
|
];
|
|
2451
2451
|
const seenRoots = new Set();
|
|
@@ -2470,7 +2470,7 @@ export async function listPaperclipSkillEntries(moduleDir, additionalCandidates
|
|
|
2470
2470
|
const entries = await fs.readdir(root, { withFileTypes: true });
|
|
2471
2471
|
const dirs = entries.filter((entry) => entry.isDirectory());
|
|
2472
2472
|
return dirs.map((entry) => ({
|
|
2473
|
-
key: `
|
|
2473
|
+
key: `tickernelz/wardmote/${entry.name}`,
|
|
2474
2474
|
runtimeName: entry.name,
|
|
2475
2475
|
source: path.join(root, entry.name),
|
|
2476
2476
|
}));
|
|
@@ -2821,10 +2821,10 @@ export function resolvePaperclipDesiredSkillNames(config, availableEntries) {
|
|
|
2821
2821
|
* through their protocol and must continue to use the configurable-only
|
|
2822
2822
|
* resolver above.
|
|
2823
2823
|
*/
|
|
2824
|
-
export const
|
|
2825
|
-
export const
|
|
2826
|
-
"
|
|
2827
|
-
"
|
|
2824
|
+
export const WARDMOTE_OPERATIONAL_SKILL_KEY = "tickernelz/wardmote/paperclip";
|
|
2825
|
+
export const WARDMOTE_FEEDBACK_SKILL_KEYS = [
|
|
2826
|
+
"tickernelz/wardmote/complain",
|
|
2827
|
+
"tickernelz/wardmote/suggestion-box",
|
|
2828
2828
|
];
|
|
2829
2829
|
/**
|
|
2830
2830
|
* Native Paperclip Runner sessions receive the control-plane contract through
|
|
@@ -2837,7 +2837,7 @@ export function normalizePaperclipOperationalSkillPreference(adapterType, config
|
|
|
2837
2837
|
if (adapterType !== "paperclip_runner")
|
|
2838
2838
|
return config;
|
|
2839
2839
|
const preference = readPaperclipSkillSyncPreference(config);
|
|
2840
|
-
const desiredSkillEntries = preference.desiredSkillEntries.filter((entry) => entry.key.trim().toLowerCase() !==
|
|
2840
|
+
const desiredSkillEntries = preference.desiredSkillEntries.filter((entry) => entry.key.trim().toLowerCase() !== WARDMOTE_OPERATIONAL_SKILL_KEY);
|
|
2841
2841
|
return desiredSkillEntries.length === preference.desiredSkillEntries.length
|
|
2842
2842
|
? config
|
|
2843
2843
|
: writePaperclipSkillSyncPreference(config, desiredSkillEntries);
|
|
@@ -2852,7 +2852,7 @@ export function normalizePaperclipRunnerAdapterConfig(adapterType, config) {
|
|
|
2852
2852
|
}
|
|
2853
2853
|
const next = {
|
|
2854
2854
|
provider: "codex",
|
|
2855
|
-
codexPermissionMode:
|
|
2855
|
+
codexPermissionMode: WARDMOTE_RUNNER_PERMISSION_CAPABILITIES.codex.defaultMode,
|
|
2856
2856
|
lifecycleMode: "per_turn",
|
|
2857
2857
|
...config,
|
|
2858
2858
|
};
|
|
@@ -2867,10 +2867,10 @@ export function normalizePaperclipRunnerAdapterConfig(adapterType, config) {
|
|
|
2867
2867
|
}
|
|
2868
2868
|
export function resolveLegacyPaperclipDesiredSkillNames(config, availableEntries) {
|
|
2869
2869
|
const desiredSkills = resolvePaperclipDesiredSkillNames(config, availableEntries);
|
|
2870
|
-
const operationalEntry = availableEntries.find((entry) => entry.key.trim().toLowerCase() ===
|
|
2870
|
+
const operationalEntry = availableEntries.find((entry) => entry.key.trim().toLowerCase() === WARDMOTE_OPERATIONAL_SKILL_KEY);
|
|
2871
2871
|
if (!operationalEntry)
|
|
2872
2872
|
return desiredSkills;
|
|
2873
|
-
const feedbackEntries =
|
|
2873
|
+
const feedbackEntries = WARDMOTE_FEEDBACK_SKILL_KEYS.flatMap((key) => {
|
|
2874
2874
|
const entry = availableEntries.find((candidate) => candidate.key.trim().toLowerCase() === key);
|
|
2875
2875
|
return entry ? [entry.key] : [];
|
|
2876
2876
|
});
|
|
@@ -3212,10 +3212,10 @@ export async function runChildProcess(runId, command, args, opts) {
|
|
|
3212
3212
|
const onLogError = opts.onLogError ??
|
|
3213
3213
|
((err, id, msg) => console.warn({ err, runId: id }, msg));
|
|
3214
3214
|
return new Promise((resolve, reject) => {
|
|
3215
|
-
const rawMerged =
|
|
3215
|
+
const rawMerged = {
|
|
3216
3216
|
...sanitizeInheritedPaperclipEnv(process.env),
|
|
3217
3217
|
...opts.env,
|
|
3218
|
-
}
|
|
3218
|
+
};
|
|
3219
3219
|
// Strip Claude Code nesting-guard env vars so spawned `claude` processes
|
|
3220
3220
|
// don't refuse to start with "cannot be launched inside another session".
|
|
3221
3221
|
// These vars leak in when the Paperclip server itself is started from
|
|
@@ -3236,7 +3236,7 @@ export async function runChildProcess(runId, command, args, opts) {
|
|
|
3236
3236
|
}
|
|
3237
3237
|
void resolveSpawnTarget(command, args, opts.cwd, mergedEnv, {
|
|
3238
3238
|
remoteExecution: opts.remoteExecution ?? null,
|
|
3239
|
-
remoteEnv: opts.remoteExecution ?
|
|
3239
|
+
remoteEnv: opts.remoteExecution ? { ...opts.env } : null,
|
|
3240
3240
|
localProcessSandbox: opts.localProcessSandbox ?? null,
|
|
3241
3241
|
})
|
|
3242
3242
|
.then((target) => {
|