impel-cli 0.18.18-beta.0 → 0.19.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 CHANGED
@@ -180,6 +180,68 @@ impel claude --model opus
180
180
  impel codex exec "review this repository"
181
181
  ```
182
182
 
183
+ ## Remote Fargate sessions
184
+
185
+ Start a disposable AWS Fargate runner for the current Git repository:
186
+
187
+ ```sh
188
+ impel remote up --provider codex
189
+ ```
190
+
191
+ The command creates a one-day, provider-scoped disposable PAT, starts the
192
+ TTL-bounded task, installs a concrete SSH alias, transfers Git history plus the
193
+ tracked and nonignored working tree, restores recognized Node/Python lockfile
194
+ dependencies, and uploads the disposable credential only through encrypted
195
+ SSH. The user's stored PAT, ignored files, SSH agent, Keychain, and environment
196
+ are not copied. Select variables explicitly when they are genuinely required:
197
+
198
+ ```sh
199
+ impel remote up --provider claude --env API_HOST,FEATURE_FLAG
200
+ ```
201
+
202
+ Use the remote session from a terminal:
203
+
204
+ ```sh
205
+ impel remote status
206
+ impel remote attach --provider codex
207
+ impel remote attach --provider claude
208
+ ```
209
+
210
+ For Codex Desktop on macOS, open the native connection flow:
211
+
212
+ ```sh
213
+ impel remote attach --provider codex --desktop
214
+ ```
215
+
216
+ Save `/workspace/repo` as the remote project. In an existing Codex chat, use
217
+ the footer's run-location picker and choose the generated SSH host. Codex then
218
+ uses its supported SSH app-server transport to move the chat and Git state and
219
+ stream prompts, approvals, tools, diffs, and output in the local app.
220
+
221
+ Claude Desktop can open a new native SSH session on the same alias. Claude does
222
+ not expose an arbitrary-host equivalent of Codex's exact chat handoff. To move
223
+ an existing Impel Claude/Codex CLI session, checkpoint it and create a remote
224
+ continuation or fork:
225
+
226
+ ```sh
227
+ impel remote dispatch --provider claude --session <session-id> --fork
228
+ impel remote dispatch --provider codex --session <session-id> --fork
229
+ ```
230
+
231
+ Remote vendor commands run in dangerous/bypass mode as the unprivileged
232
+ `agent` user; the disposable Fargate task is the isolation boundary. Existing
233
+ Impel lifecycle hooks continue mirroring remote transcripts to
234
+ `impel-sessions`. Stop the task and revoke its credential when finished:
235
+
236
+ ```sh
237
+ impel remote down --yes
238
+ ```
239
+
240
+ The current lifecycle client requires macOS or Linux, OpenSSH, the AWS CLI, the
241
+ AWS Session Manager plugin, and permission to use the deployed
242
+ `impel-remote-dev` stack. Use `impel remote help` for region, profile, TTL,
243
+ dependency, and setup overrides.
244
+
183
245
  Changing the selected tenant does not install, remove, or rewrite any other
184
246
  tenant. It changes only the default used by CLI launches and selected-tenant
185
247
  workspace commands.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impel-cli",
3
- "version": "0.18.18-beta.0",
3
+ "version": "0.19.0",
4
4
  "description": "Prepare isolated Claude and Codex workspaces for every accessible Impel tenant",
5
5
  "type": "module",
6
6
  "bin": {
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 = 5;
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,9 +329,6 @@ 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 completionGuidance = usesVerbatimRelay(agent)
346
- ? claudeHardCompletionGuidance()
347
- : claudeSoftCompletionGuidance();
348
332
  return [
349
333
  `You are a thin transport adapter for the exact Impel native agent ${JSON.stringify(agent.agentId)} in tenant ${JSON.stringify(tenantId)}.`,
350
334
  `Do not perform the assigned task yourself and do not delegate to any other agent.`,
@@ -352,7 +336,7 @@ function claudeAdapterInstructions(tenantId, agent) {
352
336
  sideEffectInstruction,
353
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}`,
354
338
  `Then call ${toolName(NATIVE_AGENT_READ_TOOL)} with the returned runId and waitSeconds 20 until the run reaches a terminal state.`,
355
- completionGuidance,
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.`,
356
340
  ].join(" ");
357
341
  }
358
342
 
@@ -510,36 +494,22 @@ function codexAdapterInstructions(tenantId, agent) {
510
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.`
511
495
  : `The catalog declares that this agent is read-only; the orchestration omits confirmedSideEffects.`;
512
496
  const source = renderCodexAdapterOrchestration(tenantId, agent);
513
- const callerSpawnGuidance = usesVerbatimRelay(agent)
514
- ? adapterCallerSpawnGuidance("Codex")
515
- : null;
516
- const completionGuidance = usesVerbatimRelay(agent)
517
- ? adapterHardCompletionGuidance()
518
- : adapterSoftCompletionGuidance();
519
497
  return [
520
498
  `You are a thin transport adapter for the exact Impel native agent ${JSON.stringify(agent.agentId)} in tenant ${JSON.stringify(tenantId)}.`,
521
- ...(callerSpawnGuidance ? [callerSpawnGuidance] : []),
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.`,
522
500
  `Do not perform the assigned task yourself, do not delegate to any other agent, and do not independently synthesize or rewrite the result.`,
523
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}`,
524
502
  sideEffectInstruction,
525
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.`,
526
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.`,
527
- completionGuidance,
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.`,
528
506
  "",
529
507
  source,
530
508
  ].join("\n\n");
531
509
  }
532
510
 
533
- function customAgentDescription(tenantId, agent) {
534
- const sideEffectsLabel = agent.sideEffects === "writes" ? " (may write user or workspace data)" : " (read-only)";
535
- return (usesVerbatimRelay(agent)
536
- ? `${customAgentVerbatimDescriptionLead()}. Runs ${agent.title} for Impel tenant ${tenantId}${sideEffectsLabel}: ${agent.description}`
537
- : `Explicitly runs ${agent.title} for Impel tenant ${tenantId}${sideEffectsLabel}: ${agent.description}`
538
- ).slice(0, 900);
539
- }
540
-
541
511
  function renderClaudeAgent({ tenantId, agent, name, invocation }) {
542
- const description = customAgentDescription(tenantId, agent);
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);
543
513
  const lines = [
544
514
  "---",
545
515
  `name: ${JSON.stringify(name)}`,
@@ -564,7 +534,7 @@ function renderClaudeAgent({ tenantId, agent, name, invocation }) {
564
534
  }
565
535
 
566
536
  function renderCodexAgent({ tenantId, agent, name, invocation }) {
567
- const description = customAgentDescription(tenantId, agent);
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);
568
538
  const envEntries = Object.entries(invocation.env || {})
569
539
  .map(([key, value]) => `${JSON.stringify(key)} = ${JSON.stringify(value)}`)
570
540
  .join(", ");
@@ -658,7 +628,7 @@ export function syncAgentProfile({ client, root, label, tenantId, agents, now =
658
628
  const prior = readManifest(manifestPath);
659
629
  const rendered = renderManagedAgents(client, tenantId, agents);
660
630
  const priorFiles = new Set(prior?.files || []);
661
- const priorUsesDiscoveryRoot = [2, 3, 4, MANAGED_AGENT_MANIFEST_VERSION].includes(prior?.version);
631
+ const priorUsesDiscoveryRoot = [2, 3, MANAGED_AGENT_MANIFEST_VERSION].includes(prior?.version);
662
632
 
663
633
  // Native clients discover standalone definitions directly under `agents/`.
664
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
- // 27: add managed ChatGPT parent delegation instructions, including custom-agent verbatim relay opt-in.
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/cli.js CHANGED
@@ -20,6 +20,7 @@ import { cmdUpdate } from "./commands/update.js";
20
20
  import { cmdNuke } from "./commands/nuke.js";
21
21
  import { cmdExperimental } from "./commands/experimental.js";
22
22
  import { cmdConverge } from "./commands/converge.js";
23
+ import { cmdRemote } from "./commands/remote.js";
23
24
  import { ensureMacDeveloperTools } from "./macDeveloperTools.js";
24
25
  import { refuseElevatedMacExecution } from "./privileges.js";
25
26
 
@@ -34,6 +35,7 @@ Get started:
34
35
  Work:
35
36
  impel claude [args...] Launch Claude Code with an isolated Impel profile
36
37
  impel codex [args...] Launch Codex with an isolated Impel profile
38
+ impel remote up|status|attach|down Run a local repository on AWS Fargate
37
39
  impel tenant list List accessible organizations
38
40
  impel tenant current Show the CLI's current organization
39
41
  impel tenant use <org> Select the organization for CLI launches
@@ -120,6 +122,9 @@ export async function main(argv) {
120
122
  case "codex":
121
123
  return cmdLaunch(cmd, rest);
122
124
 
125
+ case "remote":
126
+ return cmdRemote(rest);
127
+
123
128
  case "status":
124
129
  return cmdStatus();
125
130
 
@@ -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", IMPEL_CLAUDE_PARENT_DELEGATION_INSTRUCTIONS, ...argv];
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(IMPEL_CODEX_PARENT_DELEGATION_INSTRUCTIONS)}`,
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
  ];
@@ -302,7 +302,7 @@ async function requestControlPlane({ appUrl, currentPat, path, method, body, fea
302
302
  return payload;
303
303
  }
304
304
 
305
- async function createPat({ appUrl, currentPat, body }) {
305
+ export async function createPat({ appUrl, currentPat, body }) {
306
306
  const payload = await requestControlPlane({
307
307
  appUrl,
308
308
  currentPat,
@@ -318,7 +318,7 @@ async function createPat({ appUrl, currentPat, body }) {
318
318
  return created;
319
319
  }
320
320
 
321
- async function revokePat({ appUrl, currentPat, tokenId }) {
321
+ export async function revokePat({ appUrl, currentPat, tokenId }) {
322
322
  await requestControlPlane({
323
323
  appUrl,
324
324
  currentPat,