impel-cli 0.19.2-beta.0 → 0.19.3
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/package.json +1 -1
- package/src/agents.js +7 -41
- package/src/apps.js +1 -6
- package/src/commands/launch.js +2 -11
- package/src/remote/transfer.js +53 -2
- package/src/verbatimRelay.js +0 -64
package/package.json
CHANGED
package/src/agents.js
CHANGED
|
@@ -12,15 +12,6 @@ import path from "node:path";
|
|
|
12
12
|
import { normalizeGatewayUrl, redactSecretText } from "./config.js";
|
|
13
13
|
import { impelMcpInvocation } from "./selfInvocation.js";
|
|
14
14
|
import { normalizeTenantId } from "./tenants.js";
|
|
15
|
-
import {
|
|
16
|
-
adapterCallerSpawnGuidance,
|
|
17
|
-
adapterHardCompletionGuidance,
|
|
18
|
-
adapterSoftCompletionGuidance,
|
|
19
|
-
claudeHardCompletionGuidance,
|
|
20
|
-
claudeSoftCompletionGuidance,
|
|
21
|
-
customAgentVerbatimDescriptionLead,
|
|
22
|
-
usesVerbatimRelay,
|
|
23
|
-
} from "./verbatimRelay.js";
|
|
24
15
|
import { renameWithWindowsRetry } from "./windowsFs.js";
|
|
25
16
|
|
|
26
17
|
export const AGENT_SYNC_TTL_MS = 6 * 60 * 60 * 1000;
|
|
@@ -30,7 +21,7 @@ export const NATIVE_AGENT_LIST_TOOL = "impel_specialists-list_native_agents";
|
|
|
30
21
|
export const NATIVE_AGENT_START_TOOL = "impel_specialists-start_native_agent_run";
|
|
31
22
|
export const NATIVE_AGENT_READ_TOOL = "impel_specialists-read_native_agent_run";
|
|
32
23
|
export const MANAGED_AGENT_MCP_SERVER = "impel_agent";
|
|
33
|
-
export const MANAGED_AGENT_MANIFEST_VERSION =
|
|
24
|
+
export const MANAGED_AGENT_MANIFEST_VERSION = 4;
|
|
34
25
|
|
|
35
26
|
const NATIVE_AGENT_TOOL_NAMES = [
|
|
36
27
|
NATIVE_AGENT_LIST_TOOL,
|
|
@@ -134,9 +125,6 @@ export function normalizeNativeAgentCatalog(payload, expectedTenantId) {
|
|
|
134
125
|
throw new Error(`native-agent catalog returned duplicate binding ${binding}`);
|
|
135
126
|
}
|
|
136
127
|
seenBindings.add(binding);
|
|
137
|
-
if (agent.verbatimRelay !== undefined && typeof agent.verbatimRelay !== "boolean") {
|
|
138
|
-
throw new Error("native-agent catalog returned an invalid verbatimRelay");
|
|
139
|
-
}
|
|
140
128
|
return {
|
|
141
129
|
agentId,
|
|
142
130
|
title: boundedString(agent.title, "title", { max: 160 }),
|
|
@@ -147,7 +135,6 @@ export function normalizeNativeAgentCatalog(payload, expectedTenantId) {
|
|
|
147
135
|
exclusions: stringList(agent.exclusions, "exclusions"),
|
|
148
136
|
requiredContext: stringList(agent.requiredContext, "requiredContext"),
|
|
149
137
|
sideEffects: enumString(agent.sideEffects, "sideEffects", ["read-only", "writes"]),
|
|
150
|
-
...(agent.verbatimRelay === true ? { verbatimRelay: true } : {}),
|
|
151
138
|
};
|
|
152
139
|
});
|
|
153
140
|
return { orgId: tenantId, agents };
|
|
@@ -342,21 +329,14 @@ function claudeAdapterInstructions(tenantId, agent) {
|
|
|
342
329
|
const sideEffectInstruction = agent.sideEffects === "writes"
|
|
343
330
|
? `The catalog declares that this agent writes user or workspace data. Use this adapter only when the user explicitly selected this exact agent for the current request; that explicit selection is the required side-effect confirmation, so pass confirmedSideEffects true. If the agent was chosen automatically or the selection is ambiguous, do not start it and ask the user to select it explicitly.`
|
|
344
331
|
: `The catalog declares that this agent is read-only; omit confirmedSideEffects.`;
|
|
345
|
-
const callerSpawnGuidance = usesVerbatimRelay(agent)
|
|
346
|
-
? adapterCallerSpawnGuidance("Claude")
|
|
347
|
-
: null;
|
|
348
|
-
const completionGuidance = usesVerbatimRelay(agent)
|
|
349
|
-
? claudeHardCompletionGuidance()
|
|
350
|
-
: claudeSoftCompletionGuidance();
|
|
351
332
|
return [
|
|
352
333
|
`You are a thin transport adapter for the exact Impel native agent ${JSON.stringify(agent.agentId)} in tenant ${JSON.stringify(tenantId)}.`,
|
|
353
|
-
...(callerSpawnGuidance ? [callerSpawnGuidance] : []),
|
|
354
334
|
`Do not perform the assigned task yourself and do not delegate to any other agent.`,
|
|
355
335
|
`First call ${toolName(NATIVE_AGENT_LIST_TOOL)} and verify that the exact agentId is still available with sideEffects ${JSON.stringify(agent.sideEffects)}. If it is unavailable or its policy excludes the request, stop with that explicit error.`,
|
|
356
336
|
sideEffectInstruction,
|
|
357
337
|
`Call ${toolName(NATIVE_AGENT_START_TOOL)} exactly once with agentId ${JSON.stringify(agent.agentId)}, scopeParam ${JSON.stringify(agent.scopeParam)}, task set to the complete assigned task, optional context set to one string containing all supplied context (omit it when no context was supplied), contextKeys naming the context fields present in that string, confirmedSideEffects as directed above, and one stable idempotencyKey that you reuse for this logical task.${contextRequirement}`,
|
|
358
338
|
`Then call ${toolName(NATIVE_AGENT_READ_TOOL)} with the returned runId and waitSeconds 20 until the run reaches a terminal state.`,
|
|
359
|
-
|
|
339
|
+
`When it succeeds, return result.finalText faithfully as the answer. When it fails, return the durable runId, preserved output, and error. Never invent or independently synthesize a replacement result.`,
|
|
360
340
|
].join(" ");
|
|
361
341
|
}
|
|
362
342
|
|
|
@@ -514,36 +494,22 @@ function codexAdapterInstructions(tenantId, agent) {
|
|
|
514
494
|
? `The catalog declares that this agent writes user or workspace data. Use this adapter only when the user explicitly selected this exact agent for the current request; that explicit selection is the required side-effect confirmation. If the agent was chosen automatically or the selection is ambiguous, do not run the orchestration and ask the user to select this exact agent explicitly.`
|
|
515
495
|
: `The catalog declares that this agent is read-only; the orchestration omits confirmedSideEffects.`;
|
|
516
496
|
const source = renderCodexAdapterOrchestration(tenantId, agent);
|
|
517
|
-
const callerSpawnGuidance = usesVerbatimRelay(agent)
|
|
518
|
-
? adapterCallerSpawnGuidance("Codex")
|
|
519
|
-
: null;
|
|
520
|
-
const completionGuidance = usesVerbatimRelay(agent)
|
|
521
|
-
? adapterHardCompletionGuidance()
|
|
522
|
-
: adapterSoftCompletionGuidance();
|
|
523
497
|
return [
|
|
524
498
|
`You are a thin transport adapter for the exact Impel native agent ${JSON.stringify(agent.agentId)} in tenant ${JSON.stringify(tenantId)}.`,
|
|
525
|
-
|
|
499
|
+
`Callers must spawn this explicit custom Codex agent with fork_turns="none" and must relay your result verbatim; this is caller guidance and cannot enforce host spawn behavior.`,
|
|
526
500
|
`Do not perform the assigned task yourself, do not delegate to any other agent, and do not independently synthesize or rewrite the result.`,
|
|
527
501
|
`Confirm that the assigned request fits the cataloged capabilities ${JSON.stringify(agent.capabilities)} and none of the exclusions ${JSON.stringify(agent.exclusions)} before starting.${contextRequirement}`,
|
|
528
502
|
sideEffectInstruction,
|
|
529
503
|
`Invoke functions.exec exactly once for the orchestration below. Do not call the MCP tools directly or select a separate MCP call for any poll. Replace ${CODEX_TASK_PLACEHOLDER} with a JSON string literal for the complete assigned task. Replace ${CODEX_CONTEXT_PLACEHOLDER} with one JSON string literal containing all supplied caller context, or with null when no context was supplied; never use an object or array. Replace ${CODEX_CONTEXT_KEYS_PLACEHOLDER} with a JSON array naming the context fields present in that string, or [] when context is absent. Replace ${CODEX_IDEMPOTENCY_KEY_PLACEHOLDER} with one new opaque idempotency key for this logical invocation: choose it exactly once, reuse it unchanged for any retry of this invocation, and never reuse it for a separate request even when task and context are identical. Then pass the raw JavaScript without Markdown fences.`,
|
|
530
504
|
`The JavaScript validates the exact tenant, agent binding, and catalog policy; passes the one stable logical-invocation idempotencyKey; starts exactly once; and polls deterministically with the compatible 20-second server wait until status is succeeded or failed. If functions.exec yields a running cell, use functions.wait with max_tokens 30000 only to resume that same orchestration; never start another orchestration or poll the MCP tool yourself.`,
|
|
531
|
-
|
|
505
|
+
`After the orchestration completes, return its single text output verbatim with no preface, rewriting, Markdown changes, or independent synthesis. A successful output is result.finalText exactly. A failure output preserves the durable runId, output, and error.`,
|
|
532
506
|
"",
|
|
533
507
|
source,
|
|
534
508
|
].join("\n\n");
|
|
535
509
|
}
|
|
536
510
|
|
|
537
|
-
function customAgentDescription(tenantId, agent) {
|
|
538
|
-
const sideEffectsLabel = agent.sideEffects === "writes" ? " (may write user or workspace data)" : " (read-only)";
|
|
539
|
-
return (usesVerbatimRelay(agent)
|
|
540
|
-
? `${customAgentVerbatimDescriptionLead()}. Runs ${agent.title} for Impel tenant ${tenantId}${sideEffectsLabel}: ${agent.description}`
|
|
541
|
-
: `Explicitly runs ${agent.title} for Impel tenant ${tenantId}${sideEffectsLabel}: ${agent.description}`
|
|
542
|
-
).slice(0, 900);
|
|
543
|
-
}
|
|
544
|
-
|
|
545
511
|
function renderClaudeAgent({ tenantId, agent, name, invocation }) {
|
|
546
|
-
const description =
|
|
512
|
+
const description = `Explicitly runs ${agent.title} for Impel tenant ${tenantId}${agent.sideEffects === "writes" ? " (may write user or workspace data)" : " (read-only)"}: ${agent.description}`.slice(0, 900);
|
|
547
513
|
const lines = [
|
|
548
514
|
"---",
|
|
549
515
|
`name: ${JSON.stringify(name)}`,
|
|
@@ -568,7 +534,7 @@ function renderClaudeAgent({ tenantId, agent, name, invocation }) {
|
|
|
568
534
|
}
|
|
569
535
|
|
|
570
536
|
function renderCodexAgent({ tenantId, agent, name, invocation }) {
|
|
571
|
-
const description =
|
|
537
|
+
const description = `Explicit custom agent: callers must use fork_turns="none" and relay its result verbatim. Runs ${agent.title} for Impel tenant ${tenantId}${agent.sideEffects === "writes" ? " (may write user or workspace data)" : " (read-only)"}: ${agent.description}`.slice(0, 900);
|
|
572
538
|
const envEntries = Object.entries(invocation.env || {})
|
|
573
539
|
.map(([key, value]) => `${JSON.stringify(key)} = ${JSON.stringify(value)}`)
|
|
574
540
|
.join(", ");
|
|
@@ -662,7 +628,7 @@ export function syncAgentProfile({ client, root, label, tenantId, agents, now =
|
|
|
662
628
|
const prior = readManifest(manifestPath);
|
|
663
629
|
const rendered = renderManagedAgents(client, tenantId, agents);
|
|
664
630
|
const priorFiles = new Set(prior?.files || []);
|
|
665
|
-
const priorUsesDiscoveryRoot = [2, 3,
|
|
631
|
+
const priorUsesDiscoveryRoot = [2, 3, MANAGED_AGENT_MANIFEST_VERSION].includes(prior?.version);
|
|
666
632
|
|
|
667
633
|
// Native clients discover standalone definitions directly under `agents/`.
|
|
668
634
|
// Preflight every destination before writing so an unmanaged file with the
|
package/src/apps.js
CHANGED
|
@@ -16,7 +16,6 @@ import { ensureClaudeSessionHooks, ensureCodexSessionHooks } from "./sessionHook
|
|
|
16
16
|
import { ADHOC_IDENTITY, codesignIdentityArgs, desiredSigningMode, resolveSigningIdentity } from "./codesign.js";
|
|
17
17
|
import { applyImpelClaudeSandbox } from "./claudeSandbox.js";
|
|
18
18
|
import { brandedEnvironmentName, RUNTIME_BRAND } from "./runtimeBrand.js";
|
|
19
|
-
import { IMPEL_CODEX_PARENT_DELEGATION_INSTRUCTIONS } from "./commands/launch.js";
|
|
20
19
|
|
|
21
20
|
export const CLAUDE_CONFIG_ID = "1ced0000-0000-4000-8000-000000000001";
|
|
22
21
|
const CHATGPT_CONFIG_START = `# >>> ${RUNTIME_BRAND.cli.command} app managed gateway >>>`;
|
|
@@ -267,8 +266,7 @@ export function managedAppIdentity(target, tenantId = null, tenantName = null) {
|
|
|
267
266
|
// 26: remember the managed provider defaults and move legacy GPT-5.5 profiles
|
|
268
267
|
// onto GPT-5.6 Sol so ChatGPT's compact Work picker does not fall back to its
|
|
269
268
|
// unsupported-selection "Reset to default" treatment.
|
|
270
|
-
|
|
271
|
-
export const CURRENT_CONFIG_VERSION = 27;
|
|
269
|
+
export const CURRENT_CONFIG_VERSION = 26;
|
|
272
270
|
|
|
273
271
|
// Identifies the bundle-BUILDING logic — the asar patches, plist rewrites,
|
|
274
272
|
// helper rebranding, and signing. A vendored bundle is rebuilt only when this
|
|
@@ -1271,9 +1269,6 @@ function writeChatGPTConfig(
|
|
|
1271
1269
|
`model_catalog_json = ${tomlString(paths.chatgpt.catalog)}`,
|
|
1272
1270
|
...(selectedEffort ? [`model_reasoning_effort = ${tomlString(selectedEffort)}`] : []),
|
|
1273
1271
|
...(selectedTier ? [`service_tier = ${tomlString(selectedTier)}`] : []),
|
|
1274
|
-
...(RUNTIME_BRAND.features.agents
|
|
1275
|
-
? [`developer_instructions = ${tomlString(IMPEL_CODEX_PARENT_DELEGATION_INSTRUCTIONS)}`]
|
|
1276
|
-
: []),
|
|
1277
1272
|
"",
|
|
1278
1273
|
// The built-in ChatGPT provider derives its inference endpoint from
|
|
1279
1274
|
// chatgpt.com even when chatgpt_base_url points at the gateway. Keep the
|
package/src/commands/launch.js
CHANGED
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
resolveDefaultGateway,
|
|
15
15
|
saveConfig,
|
|
16
16
|
} from "../config.js";
|
|
17
|
-
import { parentVerbatimRelayAppendix } from "../verbatimRelay.js";
|
|
18
17
|
import { impelClaudeBaseUrl, impelCrossAppClaudeBaseUrl } from "../claudeSetup.js";
|
|
19
18
|
import { withGitEnvironment } from "../skills.js";
|
|
20
19
|
import { assertProviderScopes, ensureTenantSelection, tenantCredential } from "../tenants.js";
|
|
@@ -50,18 +49,10 @@ export {
|
|
|
50
49
|
|
|
51
50
|
export const IMPEL_SPECIALIST_DELEGATION_INSTRUCTIONS = `You are running in an Impel tenant-scoped session. Before starting any non-trivial task, call the Impel MCP tool list_specialists. If exactly one available specialist clearly matches the user's request, its capabilities and its exclusions, delegate the complete request by calling start_specialist_run exactly once with a stable idempotency key, then call read_specialist_run until it reaches a terminal state. When the run succeeds, use the specialist's result as your response instead of redoing the work. If no specialist clearly matches, the tools are unavailable, or the run fails, continue normally yourself. Do not delegate trivial requests, do not call a specialist excluded from the request, and never invent a specialist result.`;
|
|
52
51
|
|
|
53
|
-
export const IMPEL_CUSTOM_AGENT_VERBATIM_RELAY_APPENDIX = parentVerbatimRelayAppendix();
|
|
54
|
-
|
|
55
|
-
export const IMPEL_CLAUDE_PARENT_DELEGATION_INSTRUCTIONS =
|
|
56
|
-
`${IMPEL_SPECIALIST_DELEGATION_INSTRUCTIONS} ${IMPEL_CUSTOM_AGENT_VERBATIM_RELAY_APPENDIX}`;
|
|
57
|
-
|
|
58
52
|
export const IMPEL_CODEX_SPECIALIST_DELEGATION_INSTRUCTIONS =
|
|
59
53
|
`${IMPEL_SPECIALIST_DELEGATION_INSTRUCTIONS} ` +
|
|
60
54
|
`Codex can defer MCP tools behind tool_search. If an Impel specialist tool is not directly visible, call tool_search for its exact name before treating it as unavailable: impel_specialists-list_specialists for discovery, impel_specialists-start_specialist_run to delegate, and impel_specialists-read_specialist_run to poll the result. Use the returned tool for the same one-run delegation flow.`;
|
|
61
55
|
|
|
62
|
-
export const IMPEL_CODEX_PARENT_DELEGATION_INSTRUCTIONS =
|
|
63
|
-
`${IMPEL_CODEX_SPECIALIST_DELEGATION_INSTRUCTIONS} ${IMPEL_CUSTOM_AGENT_VERBATIM_RELAY_APPENDIX}`;
|
|
64
|
-
|
|
65
56
|
const IMPEL_CODEX_RUNTIME_OVERRIDES = [
|
|
66
57
|
// Codex models may select code mode even when the standalone
|
|
67
58
|
// `codex-code-mode-host` companion is not present in the vendor install.
|
|
@@ -73,14 +64,14 @@ const IMPEL_CODEX_RUNTIME_OVERRIDES = [
|
|
|
73
64
|
export function impelLaunchArguments(tool, argv) {
|
|
74
65
|
if (!RUNTIME_BRAND.features.agents) return [...argv];
|
|
75
66
|
if (tool === "claude") {
|
|
76
|
-
return ["--append-system-prompt",
|
|
67
|
+
return ["--append-system-prompt", IMPEL_SPECIALIST_DELEGATION_INSTRUCTIONS, ...argv];
|
|
77
68
|
}
|
|
78
69
|
if (tool === "codex") {
|
|
79
70
|
// `-c` is a Codex global option, so it must precede subcommands such as
|
|
80
71
|
// `exec`, `resume`, and `mcp`. JSON strings are valid TOML basic strings.
|
|
81
72
|
return [
|
|
82
73
|
"-c",
|
|
83
|
-
`developer_instructions=${JSON.stringify(
|
|
74
|
+
`developer_instructions=${JSON.stringify(IMPEL_CODEX_SPECIALIST_DELEGATION_INSTRUCTIONS)}`,
|
|
84
75
|
...IMPEL_CODEX_RUNTIME_OVERRIDES.flatMap((override) => ["-c", override]),
|
|
85
76
|
...argv,
|
|
86
77
|
];
|
package/src/remote/transfer.js
CHANGED
|
@@ -40,6 +40,14 @@ function writePrivate(filePath, contents) {
|
|
|
40
40
|
try { fs.chmodSync(filePath, 0o600); } catch { /* Best effort on Windows. */ }
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
function localTarEnvironment() {
|
|
44
|
+
// macOS libarchive serializes extended attributes into AppleDouble `._*`
|
|
45
|
+
// entries unless copyfile metadata is explicitly disabled. Those synthetic
|
|
46
|
+
// files make a clean transferred repository appear dirty on Linux even when
|
|
47
|
+
// tar's --no-xattrs option is present.
|
|
48
|
+
return { ...process.env, COPYFILE_DISABLE: "1" };
|
|
49
|
+
}
|
|
50
|
+
|
|
43
51
|
export function inspectRepository(requestedPath = process.cwd()) {
|
|
44
52
|
const requested = path.resolve(requestedPath);
|
|
45
53
|
const candidate = fs.realpathSync(requested);
|
|
@@ -98,7 +106,7 @@ export function createRepositoryTransfer(state, repository) {
|
|
|
98
106
|
"--no-xattrs",
|
|
99
107
|
"--null",
|
|
100
108
|
"-T", paths.fileList,
|
|
101
|
-
], { cwd: repository.root });
|
|
109
|
+
], { cwd: repository.root, env: localTarEnvironment() });
|
|
102
110
|
return paths;
|
|
103
111
|
}
|
|
104
112
|
|
|
@@ -119,6 +127,18 @@ function joinNullBuffer(entries) {
|
|
|
119
127
|
return Buffer.concat(entries.flatMap((entry) => [entry, Buffer.from([0])]));
|
|
120
128
|
}
|
|
121
129
|
|
|
130
|
+
function claudeProjectStorageKey(projectPath) {
|
|
131
|
+
return String(projectPath).replace(/[^A-Za-z0-9]/gu, "-");
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function checkpointRemoteRelativePath(provider, relativePath, remoteProjectPath) {
|
|
135
|
+
const normalized = String(relativePath).split(path.sep).join("/");
|
|
136
|
+
if (provider !== "claude") return normalized;
|
|
137
|
+
const segments = normalized.split("/");
|
|
138
|
+
if (segments[0] !== "projects" || segments.length < 3) return normalized;
|
|
139
|
+
return ["projects", claudeProjectStorageKey(remoteProjectPath), ...segments.slice(2)].join("/");
|
|
140
|
+
}
|
|
141
|
+
|
|
122
142
|
export async function waitForSsh(state, timeoutSeconds = 120) {
|
|
123
143
|
const deadline = Date.now() + timeoutSeconds * 1000;
|
|
124
144
|
let lastError = "SSH did not accept a connection";
|
|
@@ -274,15 +294,46 @@ export function transferSessionCheckpoint(state, { provider, sessionId, tenantId
|
|
|
274
294
|
}
|
|
275
295
|
const checkpointList = path.join(runPaths(state.runId).root, `checkpoint-${provider}.list`);
|
|
276
296
|
const checkpointArchive = path.join(runPaths(state.runId).root, `checkpoint-${provider}.tar`);
|
|
297
|
+
const mappings = files.map((relative) => ({
|
|
298
|
+
source: relative.split(path.sep).join("/"),
|
|
299
|
+
destination: checkpointRemoteRelativePath(provider, relative, state.repository.remoteProjectPath),
|
|
300
|
+
}));
|
|
277
301
|
writePrivate(checkpointList, Buffer.from(`${files.join("\0")}\0`, "utf8"));
|
|
278
302
|
try {
|
|
279
303
|
runCapture(process.env.IMPEL_REMOTE_TAR_BIN || "tar", [
|
|
280
304
|
"-cf", checkpointArchive, "--no-xattrs", "--null", "-T", checkpointList,
|
|
281
|
-
], { cwd: localRoot });
|
|
305
|
+
], { cwd: localRoot, env: localTarEnvironment() });
|
|
282
306
|
sshCapture(state, `mkdir -p ${remoteRoot}`);
|
|
283
307
|
runInteractive(process.env.IMPEL_REMOTE_SSH_BIN || "ssh", sshArgs(state, `tar -xf - -C ${remoteRoot}`), {
|
|
284
308
|
inputFile: checkpointArchive,
|
|
285
309
|
});
|
|
310
|
+
if (provider === "claude") {
|
|
311
|
+
remoteNode(state, String.raw`
|
|
312
|
+
const fs = require("node:fs");
|
|
313
|
+
const path = require("node:path");
|
|
314
|
+
const payload = JSON.parse(fs.readFileSync(0, "utf8"));
|
|
315
|
+
const root = path.resolve(payload.root);
|
|
316
|
+
for (const mapping of payload.mappings) {
|
|
317
|
+
const source = path.resolve(root, mapping.source);
|
|
318
|
+
const destination = path.resolve(root, mapping.destination);
|
|
319
|
+
if (!source.startsWith(root + path.sep) || !destination.startsWith(root + path.sep)) {
|
|
320
|
+
throw new Error("unsafe checkpoint path");
|
|
321
|
+
}
|
|
322
|
+
if (source === destination) continue;
|
|
323
|
+
if (!fs.statSync(source, { throwIfNoEntry: false })?.isFile()) {
|
|
324
|
+
throw new Error("checkpoint source is missing");
|
|
325
|
+
}
|
|
326
|
+
if (fs.existsSync(destination)) throw new Error("checkpoint destination already exists");
|
|
327
|
+
fs.mkdirSync(path.dirname(destination), { recursive: true, mode: 0o700 });
|
|
328
|
+
fs.renameSync(source, destination);
|
|
329
|
+
let emptyParent = path.dirname(source);
|
|
330
|
+
while (emptyParent !== root && emptyParent.startsWith(root + path.sep)) {
|
|
331
|
+
try { fs.rmdirSync(emptyParent); } catch { break; }
|
|
332
|
+
emptyParent = path.dirname(emptyParent);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
`, { root: remoteRoot, mappings });
|
|
336
|
+
}
|
|
286
337
|
} finally {
|
|
287
338
|
fs.rmSync(checkpointList, { force: true });
|
|
288
339
|
fs.rmSync(checkpointArchive, { force: true });
|
package/src/verbatimRelay.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
export const VERBATIM_RELAY_OPT_IN_MARKER = "verbatimRelay enabled";
|
|
2
|
-
|
|
3
|
-
export const VERBATIM_SPAWN_REQUIREMENT = 'fork_turns="none"';
|
|
4
|
-
|
|
5
|
-
export const VERBATIM_FINAL_TEXT_CONSTRAINTS =
|
|
6
|
-
"no preface, rewriting, Markdown changes, or independent synthesis";
|
|
7
|
-
|
|
8
|
-
export function usesVerbatimRelay(agent) {
|
|
9
|
-
return agent?.verbatimRelay === true;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function parentVerbatimRelayAppendix() {
|
|
13
|
-
return (
|
|
14
|
-
`When an explicit custom agent's catalog-derived description declares ${VERBATIM_RELAY_OPT_IN_MARKER}, ` +
|
|
15
|
-
`spawn it with ${VERBATIM_SPAWN_REQUIREMENT} and relay its finalText verbatim with ${VERBATIM_FINAL_TEXT_CONSTRAINTS}; ` +
|
|
16
|
-
"preserve Sources sections and citations exactly. " +
|
|
17
|
-
"Custom agents without that declaration keep the default delegation behavior."
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function customAgentVerbatimDescriptionLead() {
|
|
22
|
-
return (
|
|
23
|
-
`Explicit custom agent with ${VERBATIM_RELAY_OPT_IN_MARKER}: ` +
|
|
24
|
-
`callers must use ${VERBATIM_SPAWN_REQUIREMENT} and relay its result verbatim`
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function adapterCallerSpawnGuidance(clientLabel) {
|
|
29
|
-
return (
|
|
30
|
-
`Callers must spawn this explicit custom ${clientLabel} agent with ${VERBATIM_SPAWN_REQUIREMENT} ` +
|
|
31
|
-
"and must relay your result verbatim; this is caller guidance and cannot enforce host spawn behavior."
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function adapterHardCompletionGuidance() {
|
|
36
|
-
return (
|
|
37
|
-
`After the orchestration completes, return its single text output verbatim with ${VERBATIM_FINAL_TEXT_CONSTRAINTS}. ` +
|
|
38
|
-
"A successful output is result.finalText exactly. A failure output preserves the durable runId, output, and error."
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function adapterSoftCompletionGuidance() {
|
|
43
|
-
return (
|
|
44
|
-
"After the orchestration completes, return its single text output as the answer. " +
|
|
45
|
-
"A successful output is result.finalText. A failure output preserves the durable runId, output, and error. " +
|
|
46
|
-
"Never invent or independently synthesize a replacement result."
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function claudeHardCompletionGuidance() {
|
|
51
|
-
return (
|
|
52
|
-
`When it succeeds, return result.finalText exactly with ${VERBATIM_FINAL_TEXT_CONSTRAINTS}. ` +
|
|
53
|
-
"When it fails, return the durable runId, preserved output, and error. " +
|
|
54
|
-
"Never invent or independently synthesize a replacement result."
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function claudeSoftCompletionGuidance() {
|
|
59
|
-
return (
|
|
60
|
-
"When it succeeds, return result.finalText faithfully as the answer. " +
|
|
61
|
-
"When it fails, return the durable runId, preserved output, and error. " +
|
|
62
|
-
"Never invent or independently synthesize a replacement result."
|
|
63
|
-
);
|
|
64
|
-
}
|