@tangle-network/sdk-provider-claude-code 0.6.82 → 0.6.84

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/index.d.mts CHANGED
@@ -289,6 +289,8 @@ interface ContentBlockState {
289
289
  declare abstract class ClaudeLaunchAdapter extends CliProviderAdapterBase<ClaudeCodeConfig, ClaudeCodeEvent> {
290
290
  readonly provider = "claude-code";
291
291
  protected readonly profileHarness: HarnessId;
292
+ /** The shared launch writes profile MCP secrets as references its spawn serves (#19297). */
293
+ protected readonly referencesSharedFileSecrets = true;
292
294
  protected readonly defaultCliPath = "claude";
293
295
  /** Per-turn state must not bleed between concurrent execute calls. */
294
296
  private readonly executionContext;
@@ -343,6 +345,16 @@ declare abstract class ClaudeLaunchAdapter extends CliProviderAdapterBase<Claude
343
345
  * binding on each dispatch. Only the Tangle router receives them.
344
346
  */
345
347
  protected bindExecutionCorrelation(environment: Record<string, string | undefined>, correlationHeaders: Readonly<Record<string, string>> | undefined): Record<string, string | undefined>;
348
+ /**
349
+ * A shared-launch turn whose profile MCP config names a secret: the file
350
+ * holds references only, and the turn reads an inline copy in its place in
351
+ * which each such server is the executor's loopback proxy under the
352
+ * session's placeholder. The proxy's lease holds a remote server's headers;
353
+ * a stdio one runs in the sidecar's bridge once it declares its workspace
354
+ * subdirectory. A server the proxy cannot serve refuses the turn.
355
+ */
356
+ protected spawnExecutionProcess(request: CliTurnSpawn<ClaudeCodeConfig, ClaudeCodeEvent>): CliTurnProcess | Promise<CliTurnProcess>;
357
+ private spawnServingSecretMcp;
346
358
  protected buildMcpAddArgs(name: string, config: McpConfig): string[];
347
359
  /**
348
360
  * Record the server for inline `--mcp-config` merging, then register it with
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { randomBytes, randomUUID } from "node:crypto";
2
2
  import { InteractionKind, ProxySecretBindingSchema, ProxySecretGrantSchema, ProxySecretReceiptSchema, ProxySecretUpdateControlsSchema, ProxySecretsSchema, isProxySecretScopeAttenuation, ownPropertyRecordSchema, proxySecretPresentationsEqual, resolveTangleRouterDefaults } from "@tangle-network/agent-interface";
3
- import { CliProviderAdapterBase, EXECUTION_CORRELATION_HEADERS, InteractionBroker, InteractionMcpServer, TerminalPlanSupport, executionCorrelationHeaders, interactionMcpToolName, interactionToggleEnabled, jsonEventParser, localMcpArgv, localMcpEnv, nativeEffortArgs, partitionImageAttachments, reasoningEvents, recordCliTokenUsage, sessionObservedEvents, streamPartBase, textSnapshotEvents, toolResultEvents, toolStartEvents, trackFilePart, withTurnInteractions } from "@tangle-network/sdk-provider-cli-base";
3
+ import { CliProviderAdapterBase, EXECUTION_CORRELATION_HEADERS, InteractionBroker, InteractionMcpServer, SECRET_REFERENCE_PREFIX, SHARED_WORKSPACE_DIR_ENV, TerminalPlanSupport, executionCorrelationHeaders, interactionMcpToolName, interactionToggleEnabled, isPlainRecord, jsonEventParser, localMcpArgv, localMcpEnv, nativeEffortArgs, partitionImageAttachments, reasoningEvents, recordCliTokenUsage, refuseSecretLaunch, secretMcpScope, servableMcpServer, servableStdioServer, sessionObservedEvents, sharedSecretMcpRefused, spawnUnderSecretMcpLease, streamPartBase, textSnapshotEvents, toolResultEvents, toolStartEvents, trackFilePart, withTurnInteractions } from "@tangle-network/sdk-provider-cli-base";
4
4
  import { z } from "zod";
5
5
  import { HELD_SPARE_IDLE_MS, argAfter, createDeferredParser, createHeldSpareRegistry, launchDifferences, shellQuote } from "@tangle-network/sdk-cli-runner";
6
6
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -927,6 +927,8 @@ const MAX_ARGV_PROMPT_BYTES = 120 * 1024;
927
927
  var ClaudeLaunchAdapter = class extends CliProviderAdapterBase {
928
928
  provider = "claude-code";
929
929
  profileHarness = "claude-code";
930
+ /** The shared launch writes profile MCP secrets as references its spawn serves (#19297). */
931
+ referencesSharedFileSecrets = true;
930
932
  defaultCliPath = "claude";
931
933
  /** Per-turn state must not bleed between concurrent execute calls. */
932
934
  executionContext = registerClaudeExecutionContext(this, new AsyncLocalStorage());
@@ -1077,6 +1079,56 @@ var ClaudeLaunchAdapter = class extends CliProviderAdapterBase {
1077
1079
  ANTHROPIC_CUSTOM_HEADERS: [inherited, ...lines].filter((line) => Boolean(line)).join("\n")
1078
1080
  };
1079
1081
  }
1082
+ /**
1083
+ * A shared-launch turn whose profile MCP config names a secret: the file
1084
+ * holds references only, and the turn reads an inline copy in its place in
1085
+ * which each such server is the executor's loopback proxy under the
1086
+ * session's placeholder. The proxy's lease holds a remote server's headers;
1087
+ * a stdio one runs in the sidecar's bridge once it declares its workspace
1088
+ * subdirectory. A server the proxy cannot serve refuses the turn.
1089
+ */
1090
+ spawnExecutionProcess(request) {
1091
+ const references = this.secretProfileReferences(request.profilePlan);
1092
+ return references ? this.spawnServingSecretMcp(request, references) : super.spawnExecutionProcess(request);
1093
+ }
1094
+ async spawnServingSecretMcp(request, references) {
1095
+ const args = [...request.execArgs.args];
1096
+ const files = request.profilePlan?.secretSlotFiles ?? {};
1097
+ const at = args.findIndex((path, index) => args[index - 1] === "--mcp-config" && Object.hasOwn(files, path));
1098
+ const servers = JSON.parse(files[args[at] ?? ""] ?? "{}").mcpServers ?? {};
1099
+ const proxy = this.mcpOwner.proxy;
1100
+ const served = [];
1101
+ for (const [name, entry] of Object.entries(servers)) {
1102
+ if (!JSON.stringify(entry).includes(`{env:${SECRET_REFERENCE_PREFIX}`)) continue;
1103
+ const env = isPlainRecord(entry.env) ? entry.env : {};
1104
+ const server = entry.type === "sse" ? "the loopback proxy relays no SSE transport" : entry.type !== "stdio" ? servableMcpServer(name, entry, references) : SHARED_WORKSPACE_DIR_ENV in env ? servableStdioServer(name, {
1105
+ command: [entry.command, ...Array.isArray(entry.args) ? entry.args : []],
1106
+ environment: env
1107
+ }, references, {
1108
+ files: this.secretProfileMounts(request.profilePlan),
1109
+ workspaceRoot: request.workspaceRoot
1110
+ }) : `only the sidecar's bridge runs it, once it declares ${SHARED_WORKSPACE_DIR_ENV}`;
1111
+ if (typeof server === "string") refuseSecretLaunch(`Claude Code cannot serve MCP server "${name}", which names a profile secret: ${server}`);
1112
+ served.push(server);
1113
+ }
1114
+ if (served.length === 0) return super.spawnExecutionProcess(request);
1115
+ if (!proxy || sharedSecretMcpRefused(served, this.subprocessIdentity()?.uid)) refuseSecretLaunch("Claude Code profile secrets need the executor's MCP proxy and a root sidecar running the agent under another UID");
1116
+ const scope = secretMcpScope(request.sessionId, this.config.subprocessUser?.uid, this.mcpOwner);
1117
+ const { placeholder, urls } = await proxy.endpoint(scope, served.map((server) => server.name));
1118
+ for (const { name } of served) servers[name] = {
1119
+ type: "http",
1120
+ url: urls[name],
1121
+ headers: { Authorization: `Bearer ${placeholder}` }
1122
+ };
1123
+ args[at] = JSON.stringify({ mcpServers: servers });
1124
+ return spawnUnderSecretMcpLease(scope, request.signal, () => proxy.lease(scope, served, request.input), () => super.spawnExecutionProcess({
1125
+ ...request,
1126
+ execArgs: {
1127
+ ...request.execArgs,
1128
+ args
1129
+ }
1130
+ }));
1131
+ }
1080
1132
  buildMcpAddArgs(name, config) {
1081
1133
  const args = ["mcp", "add"];
1082
1134
  if (config.type === "http" || config.type === "remote") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/sdk-provider-claude-code",
3
- "version": "0.6.82",
3
+ "version": "0.6.84",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -19,7 +19,7 @@
19
19
  "@tangle-network/agent-interface": "^5.10.27",
20
20
  "@tangle-network/agent-profile-materialize": "1.1.128",
21
21
  "@tangle-network/sdk-cli-runner": "0.3.12",
22
- "@tangle-network/sdk-provider-cli-base": "0.13.106",
22
+ "@tangle-network/sdk-provider-cli-base": "0.13.108",
23
23
  "@tangle-network/sdk-session-persistence": "0.7.13",
24
24
  "zod": "4.6.7"
25
25
  },
@@ -35,8 +35,8 @@
35
35
  "registry": "https://registry.npmjs.org"
36
36
  },
37
37
  "tangleRelease": {
38
- "sourceSha": "d6370521dc203efd37527d5057c1805765b7c2fd",
39
- "mergedAt": "2026-11-16T16:39:41-08:00"
38
+ "sourceSha": "cf28db313cb28826df29ab6638c4953327a94349",
39
+ "mergedAt": "2026-11-16T19:57:07-08:00"
40
40
  },
41
41
  "scripts": {
42
42
  "build": "tsdown",