@velum-labs/routekit-tool-claude 1.3.2 → 1.5.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/index.d.ts CHANGED
@@ -2,6 +2,6 @@ import type { ToolIntegration } from "@velum-labs/routekit-tools";
2
2
  export declare const claudeTool: ToolIntegration;
3
3
  export type { ClaudeDriverConfig, ClaudeDriverOptions, ClaudeQueryFn } from "./driver.js";
4
4
  export { claudeDriverConfigSchema, createClaudeDriver } from "./driver.js";
5
- export type { ClaudeInstallInput, ClaudeInstallOwner, ClaudeInstallResult } from "./install.js";
6
- export { claudeIntegrationConfigPath, installClaudeIntegration, uninstallClaudeIntegration } from "./install.js";
5
+ export type { ClaudeConfigLockScope, ClaudeInstallInput, ClaudeInstallOwner, ClaudeInstallResult } from "./install.js";
6
+ export { acquireClaudeConfigLock, claudeIntegrationConfigPath, installClaudeIntegration, uninstallClaudeIntegration } from "./install.js";
7
7
  export { claudeAgentsJson, claudeEnv, claudeLaunchArgs, launchClaude } from "./launch.js";
package/dist/index.js CHANGED
@@ -30,5 +30,5 @@ export const claudeTool = {
30
30
  }
31
31
  };
32
32
  export { claudeDriverConfigSchema, createClaudeDriver } from "./driver.js";
33
- export { claudeIntegrationConfigPath, installClaudeIntegration, uninstallClaudeIntegration } from "./install.js";
33
+ export { acquireClaudeConfigLock, claudeIntegrationConfigPath, installClaudeIntegration, uninstallClaudeIntegration } from "./install.js";
34
34
  export { claudeAgentsJson, claudeEnv, claudeLaunchArgs, launchClaude } from "./launch.js";
@@ -1,3 +1,4 @@
1
+ import { type ClaudeCatalogModel } from "./launch.js";
1
2
  export type ClaudeSettings = Record<string, unknown> & {
2
3
  env?: Record<string, unknown>;
3
4
  };
@@ -41,6 +42,11 @@ export type UninstallPendingManifest = {
41
42
  };
42
43
  export type ClaudeInstallManifest = InstalledManifest | InstallPendingManifest | UninstallPendingManifest;
43
44
  export declare const MANAGED_ENV_KEYS: readonly ["ANTHROPIC_BASE_URL", "CLAUDE_CODE_ALWAYS_ENABLE_EFFORT"];
45
+ export declare const REPOSITORY_CONNECTION_HEADER = "X-RouteKit-Repository-Connection-Id";
46
+ export declare const CLAUDE_CUSTOM_HEADERS_KEY = "ANTHROPIC_CUSTOM_HEADERS";
47
+ export declare const CLAUDE_CUSTOM_MODEL_OPTION_KEY = "ANTHROPIC_CUSTOM_MODEL_OPTION";
48
+ export declare const CLAUDE_AUTO_PICKER_MODEL_ID = "anthropic.routekit.auto";
49
+ export declare const BOUND_MANAGED_ENV_KEYS: readonly ["ANTHROPIC_CUSTOM_HEADERS", "ANTHROPIC_CUSTOM_MODEL_OPTION"];
44
50
  export declare function hash(content: string): string;
45
51
  export declare function serialize(value: unknown): string;
46
52
  export declare function snapshot(content: string | null, mode: number | null): FileSnapshot;
@@ -49,9 +55,10 @@ export declare function unsupportedManifest(manifestPath: string): Error;
49
55
  export declare function parseManifest(content: string, manifestPath: string): ClaudeInstallManifest;
50
56
  export declare function managedEnv(input: {
51
57
  gatewayUrl: string;
58
+ repositoryConnectionId?: string;
52
59
  }): Record<string, string>;
53
60
  export declare function pickerModels(input: {
54
- models: readonly string[];
61
+ models: readonly (string | ClaudeCatalogModel)[];
55
62
  }): string[];
56
63
  export declare function availableModels(settings: ClaudeSettings, configPath: string): string[] | undefined;
57
64
  export declare function enforceAvailableModels(settings: ClaudeSettings, configPath: string): boolean | undefined;
@@ -1,11 +1,19 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { gatewayOrigin } from "@velum-labs/routekit-runtime/network";
3
+ import { claudeModelId } from "./launch.js";
3
4
  export const MANAGED_ENV_KEYS = ["ANTHROPIC_BASE_URL", "CLAUDE_CODE_ALWAYS_ENABLE_EFFORT"];
5
+ export const REPOSITORY_CONNECTION_HEADER = "X-RouteKit-Repository-Connection-Id";
6
+ export const CLAUDE_CUSTOM_HEADERS_KEY = "ANTHROPIC_CUSTOM_HEADERS";
7
+ export const CLAUDE_CUSTOM_MODEL_OPTION_KEY = "ANTHROPIC_CUSTOM_MODEL_OPTION";
8
+ export const CLAUDE_AUTO_PICKER_MODEL_ID = "anthropic.routekit.auto";
9
+ export const BOUND_MANAGED_ENV_KEYS = [
10
+ CLAUDE_CUSTOM_HEADERS_KEY,
11
+ CLAUDE_CUSTOM_MODEL_OPTION_KEY
12
+ ];
4
13
  const RETIRED_MANAGED_ENV_KEYS = [
5
14
  "ANTHROPIC_AUTH_TOKEN",
6
15
  "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY"
7
16
  ];
8
- const CLAUDE_PICKER_PREFIX = "anthropic.routekit.";
9
17
  export function hash(content) {
10
18
  return createHash("sha256").update(content).digest("hex");
11
19
  }
@@ -117,18 +125,29 @@ export function parseManifest(content, manifestPath) {
117
125
  throw unsupportedManifest(manifestPath);
118
126
  }
119
127
  export function managedEnv(input) {
128
+ if (input.repositoryConnectionId !== undefined &&
129
+ !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(input.repositoryConnectionId)) {
130
+ throw new Error("RouteKit's Claude repository connection id must be a UUID");
131
+ }
120
132
  return {
121
133
  ANTHROPIC_BASE_URL: gatewayOrigin(input.gatewayUrl),
122
- CLAUDE_CODE_ALWAYS_ENABLE_EFFORT: "1"
134
+ CLAUDE_CODE_ALWAYS_ENABLE_EFFORT: "1",
135
+ ...(input.repositoryConnectionId !== undefined
136
+ ? {
137
+ [CLAUDE_CUSTOM_HEADERS_KEY]: `${REPOSITORY_CONNECTION_HEADER}: ${input.repositoryConnectionId.toLowerCase()}`,
138
+ [CLAUDE_CUSTOM_MODEL_OPTION_KEY]: CLAUDE_AUTO_PICKER_MODEL_ID
139
+ }
140
+ : {})
123
141
  };
124
142
  }
125
143
  export function pickerModels(input) {
126
144
  const models = new Set();
127
145
  for (const model of input.models) {
128
- if (typeof model !== "string" || model.length === 0) {
146
+ const id = typeof model === "string" ? model : model.id;
147
+ if (typeof id !== "string" || id.length === 0) {
129
148
  throw new Error("RouteKit's Claude picker catalog contains an invalid model id");
130
149
  }
131
- models.add(`${CLAUDE_PICKER_PREFIX}${model}`);
150
+ models.add(claudeModelId(id, input.models));
132
151
  }
133
152
  return [...models];
134
153
  }
package/dist/install.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { type ClaudeSettings } from "./install-codec.js";
2
+ import type { ClaudeCatalogModel } from "./launch.js";
1
3
  export type ClaudeInstallOwner = {
2
4
  id: string;
3
5
  displayName: string;
@@ -7,8 +9,10 @@ export type ClaudeInstallOwner = {
7
9
  };
8
10
  export type ClaudeInstallInput = {
9
11
  gatewayUrl: string;
10
- /** Canonical RouteKit catalog ids permitted by the current model policy. */
11
- models: readonly string[];
12
+ /** Explicit Cloud repository context. This is not a credential. */
13
+ repositoryConnectionId?: string;
14
+ /** Canonical RouteKit catalog routes permitted by the current model policy. */
15
+ models: readonly (string | ClaudeCatalogModel)[];
12
16
  /**
13
17
  * Command Claude Code invokes when it needs the gateway bearer token. The
14
18
  * helper output is never persisted in settings.json.
@@ -23,6 +27,29 @@ export type ClaudeInstallResult = {
23
27
  managedKeys: string[];
24
28
  };
25
29
  export declare function claudeIntegrationConfigPath(claudeConfigDir?: string): string;
30
+ export type ClaudeConfigLockScope = Readonly<{
31
+ install(input: ClaudeInstallInput, options?: {
32
+ validateSettings?: (settings: Readonly<ClaudeSettings>) => void;
33
+ }): ClaudeInstallResult;
34
+ uninstall(input: {
35
+ ownerId: string;
36
+ claudeConfigDir?: string;
37
+ }): {
38
+ configPath: string;
39
+ removed: boolean;
40
+ };
41
+ recover(ownerId: string): {
42
+ configPath: string;
43
+ recovered: boolean;
44
+ };
45
+ release(): void;
46
+ }>;
47
+ /**
48
+ * Hold Claude's owner-neutral config lock across an async caller transaction.
49
+ * A validator can inspect the parsed settings inside the lock before install
50
+ * writes any ownership metadata or settings changes.
51
+ */
52
+ export declare function acquireClaudeConfigLock(claudeConfigDir?: string): Promise<ClaudeConfigLockScope>;
26
53
  export declare function installClaudeIntegration(input: ClaudeInstallInput): Promise<ClaudeInstallResult>;
27
54
  export declare function uninstallClaudeIntegration(input: {
28
55
  ownerId: string;