@heyditto/cli 3.3.1 → 3.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/README.md +65 -0
- package/dist/agents/claude-mcp.d.ts +24 -0
- package/dist/agents/claude-mcp.js +18 -0
- package/dist/agents/claude-mcp.js.map +1 -1
- package/dist/agents/claude.js +13 -4
- package/dist/agents/claude.js.map +1 -1
- package/dist/agents/cliproxy.d.ts +13 -0
- package/dist/agents/cliproxy.js +115 -0
- package/dist/agents/cliproxy.js.map +1 -0
- package/dist/agents/codex.js +1 -1
- package/dist/agents/codex.js.map +1 -1
- package/dist/agents/launch.d.ts +2 -0
- package/dist/agents/launch.js +58 -19
- package/dist/agents/launch.js.map +1 -1
- package/dist/agents/sessions.d.ts +2 -0
- package/dist/agents/sessions.js.map +1 -1
- package/dist/agents/types.d.ts +4 -0
- package/dist/agents/types.js.map +1 -1
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands.js +4 -0
- package/dist/commands.js.map +1 -1
- package/dist/relay/client.d.ts +28 -0
- package/dist/relay/client.js +166 -0
- package/dist/relay/client.js.map +1 -0
- package/dist/relay/commands.d.ts +2 -0
- package/dist/relay/commands.js +71 -0
- package/dist/relay/commands.js.map +1 -0
- package/dist/update-lock.json +1 -1
- package/docs/t3-code.md +110 -0
- package/package.json +3 -1
- package/scripts/claude-router-launcher.sh +113 -0
package/README.md
CHANGED
|
@@ -1281,6 +1281,71 @@ says so. Tracked artifact directories are flagged rather than claimed excluded.
|
|
|
1281
1281
|
`heyditto offload` refuses to delete a folder when unrelated files, unknown projects or
|
|
1282
1282
|
escaping symlinks beneath it would be lost.
|
|
1283
1283
|
|
|
1284
|
+
### Cloud-assisted CLIProxy inference
|
|
1285
|
+
|
|
1286
|
+
To use subscription inference with Router optimizations, cloud session recording
|
|
1287
|
+
and remote control, connect a local CLIProxy through an outbound relay. Use a
|
|
1288
|
+
dedicated **personal** endpoint and a model exposed by your local proxy:
|
|
1289
|
+
|
|
1290
|
+
```sh
|
|
1291
|
+
heyditto endpoints create my-local-models
|
|
1292
|
+
heyditto cliproxy relay --endpoint my-local-models --enable --model gpt-6.1-sol
|
|
1293
|
+
# In another terminal, while the relay stays running:
|
|
1294
|
+
heyditto claude --endpoint my-local-models
|
|
1295
|
+
```
|
|
1296
|
+
|
|
1297
|
+
The first `--enable` changes that endpoint to relay-only BYOK inference, enables
|
|
1298
|
+
cloud trace recording and selects Router inference instead of a native-account
|
|
1299
|
+
default. Later relay starts omit `--enable`. The CLI keeps an outbound
|
|
1300
|
+
authenticated connection; your local proxy access key and provider credentials
|
|
1301
|
+
stay on your computer. Stopping the relay makes requests fail without switching
|
|
1302
|
+
to paid inference. Existing Router optimization/tool resource costs still apply.
|
|
1303
|
+
|
|
1304
|
+
The first release supports one relay per personal endpoint and requires the API
|
|
1305
|
+
and inference request to reach the same backend process. Organization endpoints
|
|
1306
|
+
and routing across multiple backend processes are not supported yet. The local
|
|
1307
|
+
model IDs must match the endpoint's routes/aliases; the cloud model list does not
|
|
1308
|
+
discover laptop providers. Deploy the matching backend before enabling an endpoint.
|
|
1309
|
+
|
|
1310
|
+
For the official T3 Code app, see [the Router setup guide](docs/t3-code.md).
|
|
1311
|
+
|
|
1312
|
+
### Direct local CLIProxy inference
|
|
1313
|
+
|
|
1314
|
+
Use a locally installed CLIProxy with Claude Code or Codex instead of Ditto Router
|
|
1315
|
+
inference:
|
|
1316
|
+
|
|
1317
|
+
```sh
|
|
1318
|
+
heyditto claude --cliproxy --endpoint my-tools
|
|
1319
|
+
heyditto codex --cliproxy --endpoint my-tools --model gpt-6-luna
|
|
1320
|
+
heyditto claude --cliproxy http://127.0.0.1:8317/v1 --dry-run --endpoint my-tools
|
|
1321
|
+
```
|
|
1322
|
+
|
|
1323
|
+
`--cliproxy` detects EasyCLIProxyAPI's saved host, port and API access key. It
|
|
1324
|
+
reads the GUI configuration from the platform's `com.cpa.gui` application-data
|
|
1325
|
+
directory. Set `CLIPROXY_CONFIG` for another EasyCLIProxyAPI TOML file, or use
|
|
1326
|
+
`CLIPROXY_BASE_URL` and `CLIPROXY_API_KEY` for a standalone CLIProxy installation.
|
|
1327
|
+
The URL must be loopback (`127.0.0.1`, `localhost` or `::1`); discovery does not
|
|
1328
|
+
accept LAN/public hosts, URL credentials or redirects. An API key is never
|
|
1329
|
+
copied between two different proxy addresses automatically.
|
|
1330
|
+
|
|
1331
|
+
Before launching, the CLI authenticates `/v1/models` and selects a Claude/GPT
|
|
1332
|
+
model exposed by the proxy, or checks your explicit `--model`. Local failure
|
|
1333
|
+
stops the launch without switching to paid Router inference. `--dry-run` checks
|
|
1334
|
+
the proxy and prints a plan with credentials masked; it mints no Ditto key.
|
|
1335
|
+
Resume remembers the proxy URL and reads its credential again, so `--resume`
|
|
1336
|
+
keeps local inference. Use `--no-cliproxy` to return to the normal inference mode.
|
|
1337
|
+
|
|
1338
|
+
This mode still uses a Ditto login and endpoint for selected Claude MCP tools
|
|
1339
|
+
and remote control. The local API access key stays local; Ditto MCP uses a
|
|
1340
|
+
separate temporary endpoint key, which is revoked on exit. `--no-mcp` omits the
|
|
1341
|
+
selected Claude MCP tools; `--no-remote-control` omits cloud session registration.
|
|
1342
|
+
Those flags do not remove the current launcher's Ditto login/endpoint dependency.
|
|
1343
|
+
Local inference bypasses Router compression, routing and inference recording;
|
|
1344
|
+
cloud-assisted relay is a separate mode. Cloud MCP calls and remote-control
|
|
1345
|
+
activity still reach Ditto when enabled. `--mcp-only` keeps using the native
|
|
1346
|
+
Claude account instead; it cannot be combined with `--cliproxy`. `--budget`
|
|
1347
|
+
cannot cap subscription inference and is rejected in direct CLIProxy mode.
|
|
1348
|
+
|
|
1284
1349
|
### Native Claude inference and remote delivery
|
|
1285
1350
|
|
|
1286
1351
|
`heyditto claude` keeps using Ditto Router for inference. `--mcp` changes
|
|
@@ -36,13 +36,37 @@ export interface McpCatalogServer {
|
|
|
36
36
|
url: string;
|
|
37
37
|
tools: McpCatalogTool[];
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* A connection Ditto could not open for this session (DITTO-1639): its tools
|
|
41
|
+
* are missing, and the server it would have been served under offers only
|
|
42
|
+
* `connection_status`, which tells the agent why.
|
|
43
|
+
*/
|
|
44
|
+
export interface McpUnavailableSource {
|
|
45
|
+
serverId: string;
|
|
46
|
+
name: string;
|
|
47
|
+
/** The catalog server name its tools would have had. */
|
|
48
|
+
prefix: string;
|
|
49
|
+
/** oauth_not_connected (sign-in expired or revoked), oauth_error, … */
|
|
50
|
+
reason: string;
|
|
51
|
+
/** Where its owner reconnects it; absent for someone else's connection. */
|
|
52
|
+
reconnectUrl?: string;
|
|
53
|
+
personal: boolean;
|
|
54
|
+
}
|
|
39
55
|
/** GET /v1/mcp. */
|
|
40
56
|
export interface McpCatalog {
|
|
41
57
|
endpoint: string;
|
|
42
58
|
approvalMode: string;
|
|
43
59
|
clientApprovals: boolean;
|
|
44
60
|
servers: McpCatalogServer[];
|
|
61
|
+
/** Absent from a backend that predates DITTO-1639. */
|
|
62
|
+
unavailable?: McpUnavailableSource[];
|
|
45
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* One line per connection whose tools are missing from this session, with
|
|
66
|
+
* where to reconnect it, so the person sees it before the agent stumbles on
|
|
67
|
+
* it mid-task.
|
|
68
|
+
*/
|
|
69
|
+
export declare function mcpUnavailableLines(catalog: Pick<McpCatalog, "unavailable">): string[];
|
|
46
70
|
/** What a Claude launch needs to attach the catalog. */
|
|
47
71
|
export interface ClaudeMcpAttachment {
|
|
48
72
|
/** The `--mcp-config` JSON. */
|
|
@@ -30,6 +30,24 @@ export const TOOL_SURFACE_MCP = "mcp";
|
|
|
30
30
|
* lands in a file or in argv.
|
|
31
31
|
*/
|
|
32
32
|
export const MCP_KEY_ENV = "DITTO_ROUTER_MCP_KEY";
|
|
33
|
+
const UNAVAILABLE_REASONS = {
|
|
34
|
+
oauth_not_connected: "sign-in expired or revoked",
|
|
35
|
+
oauth_error: "sign-in could not be refreshed",
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* One line per connection whose tools are missing from this session, with
|
|
39
|
+
* where to reconnect it, so the person sees it before the agent stumbles on
|
|
40
|
+
* it mid-task.
|
|
41
|
+
*/
|
|
42
|
+
export function mcpUnavailableLines(catalog) {
|
|
43
|
+
const sources = Array.isArray(catalog.unavailable) ? catalog.unavailable : [];
|
|
44
|
+
return sources.map((s) => {
|
|
45
|
+
const name = s.name?.trim() || s.prefix || "an MCP connection";
|
|
46
|
+
const why = UNAVAILABLE_REASONS[s.reason] ?? "could not be opened";
|
|
47
|
+
const fix = s.personal && s.reconnectUrl ? `reconnect: ${s.reconnectUrl}` : "ask whoever connected it to reconnect it";
|
|
48
|
+
return `${name} is disconnected (${why}); its tools are missing — ${fix}`;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
33
51
|
/** Claude Code server name for a catalog server: the built-ins keep "ditto", the rest are "ditto-<source>". */
|
|
34
52
|
export function claudeServerName(server) {
|
|
35
53
|
return server === "ditto" ? "ditto" : `ditto-${server}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-mcp.js","sourceRoot":"","sources":["../../src/agents/claude-mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACzH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;;;;;;;;;;;;;;GAiBG;AAEH,mFAAmF;AACnF,MAAM,CAAC,MAAM,mBAAmB,GAAG,sBAAsB,CAAC;AAC1D,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CA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CAAC,KAAK,CAAC;IACpD,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM;QAAE,WAAW,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC;IAC9C,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAChE,CAAC"}
|
package/dist/agents/claude.js
CHANGED
|
@@ -53,7 +53,7 @@ export function planClaude(input) {
|
|
|
53
53
|
if (input.model)
|
|
54
54
|
envSet.ANTHROPIC_MODEL = input.model;
|
|
55
55
|
if (input.mcp)
|
|
56
|
-
envSet[MCP_KEY_ENV] = input.apiKey;
|
|
56
|
+
envSet[MCP_KEY_ENV] = input.mcpApiKey ?? input.apiKey;
|
|
57
57
|
if (input.mcpOnly) {
|
|
58
58
|
// Endpoint keys are only MCP credentials in this mode. Never forward one
|
|
59
59
|
// to Anthropic or inherit a parent launch's inference gateway settings.
|
|
@@ -64,11 +64,20 @@ export function planClaude(input) {
|
|
|
64
64
|
installHint: "install Claude Code and sign in with `claude auth login`",
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
// Claude Code's
|
|
68
|
-
//
|
|
69
|
-
// denies every auto-mode tool use. Decide locally unless the caller chose.
|
|
67
|
+
// Intermediaries do not forward Claude Code's auto-mode classifier fields.
|
|
68
|
+
// Decide locally for Router and CLIProxy inference unless the caller chose.
|
|
70
69
|
if (input.env.CLAUDE_CODE_AUTO_MODE_SERVER === undefined)
|
|
71
70
|
envSet.CLAUDE_CODE_AUTO_MODE_SERVER = "0";
|
|
71
|
+
if (input.localInference) {
|
|
72
|
+
// Cloud MCP auth never becomes the local inference credential, and a
|
|
73
|
+
// parent Router launch's custom headers/other provider modes stay out.
|
|
74
|
+
delete envSet.ANTHROPIC_CUSTOM_HEADERS;
|
|
75
|
+
return {
|
|
76
|
+
command: "claude", args: finalArgs, envSet,
|
|
77
|
+
envUnset: ["ANTHROPIC_API_KEY", "ANTHROPIC_CUSTOM_HEADERS", "CLAUDE_CODE_OAUTH_TOKEN", "CLAUDE_CODE_USE_BEDROCK", "CLAUDE_CODE_USE_VERTEX", "CLAUDE_CODE_USE_FOUNDRY", ...(!input.model ? ["ANTHROPIC_MODEL"] : []), ...(!input.mcp ? [MCP_KEY_ENV] : [])],
|
|
78
|
+
installHint: "install Claude Code: npm i -g @anthropic-ai/claude-code",
|
|
79
|
+
};
|
|
80
|
+
}
|
|
72
81
|
// Claude Code only labels requests (x-claude-code-request-class: main,
|
|
73
82
|
// subagent, auxiliary) for gateways when asked. The router uses the label to
|
|
74
83
|
// skip memory recall on housekeeping calls such as the auto-mode classifier.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude.js","sourceRoot":"","sources":["../../src/agents/claude.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC7H,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAoC,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEjI;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,KAAgB;IACzC,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,KAAK,CAAC,IAAI;QAAE,IAAI,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;SACvD,IAAI,KAAK,CAAC,MAAM;QAAE,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;SAChE,IAAI,KAAK,CAAC,IAAI;QAAE,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;IAE5D,uEAAuE;IACvE,2EAA2E;IAC3E,iB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AI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface CliProxy {
|
|
2
|
+
/** Canonical loopback OpenAI/Responses root. */
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
/** Local credential, never a Ditto endpoint key. */
|
|
5
|
+
apiKey: string;
|
|
6
|
+
models: string[];
|
|
7
|
+
}
|
|
8
|
+
/** Deliberately no public/LAN destinations, embedded credentials or redirects. */
|
|
9
|
+
export declare function cliProxyBaseUrl(value: string): string;
|
|
10
|
+
export declare function cliProxyConfigPaths(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform, home?: string): string[];
|
|
11
|
+
/** Reads only the API access key; OAuth/provider/management credentials stay untouched. */
|
|
12
|
+
export declare function resolveCliProxy(requested: string | true, env?: NodeJS.ProcessEnv): Promise<CliProxy>;
|
|
13
|
+
export declare function cliProxyModel(proxy: Pick<CliProxy, "models">, harness: "claude" | "codex", requested?: string): string;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { parse } from "smol-toml";
|
|
5
|
+
/** Deliberately no public/LAN destinations, embedded credentials or redirects. */
|
|
6
|
+
export function cliProxyBaseUrl(value) {
|
|
7
|
+
let url;
|
|
8
|
+
try {
|
|
9
|
+
url = new URL(value);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
throw new Error("CLIProxy URL must be an http(s) loopback URL, such as http://127.0.0.1:8317/v1");
|
|
13
|
+
}
|
|
14
|
+
if (!["http:", "https:"].includes(url.protocol) || !["127.0.0.1", "[::1]", "localhost"].includes(url.hostname) ||
|
|
15
|
+
url.username || url.password || url.search || url.hash || !["", "/", "/v1", "/v1/"].includes(url.pathname)) {
|
|
16
|
+
throw new Error("CLIProxy requires a loopback URL with no credentials, query or fragment, ending in /v1 or /");
|
|
17
|
+
}
|
|
18
|
+
// Pin localhost rather than resolving it through potentially modified DNS.
|
|
19
|
+
if (url.hostname === "localhost")
|
|
20
|
+
url.hostname = "127.0.0.1";
|
|
21
|
+
url.pathname = "/v1";
|
|
22
|
+
return url.toString().replace(/\/$/, "");
|
|
23
|
+
}
|
|
24
|
+
export function cliProxyConfigPaths(env = process.env, platform = process.platform, home = os.homedir()) {
|
|
25
|
+
if (env.CLIPROXY_CONFIG)
|
|
26
|
+
return [env.CLIPROXY_CONFIG];
|
|
27
|
+
if (platform === "darwin")
|
|
28
|
+
return [path.join(home, "Library", "Application Support", "com.cpa.gui", "config.toml")];
|
|
29
|
+
if (platform === "win32")
|
|
30
|
+
return [path.join(env.APPDATA || path.join(home, "AppData", "Roaming"), "com.cpa.gui", "config.toml")];
|
|
31
|
+
return [
|
|
32
|
+
path.join(env.XDG_DATA_HOME || path.join(home, ".local", "share"), "com.cpa.gui", "config.toml"),
|
|
33
|
+
path.join(env.XDG_CONFIG_HOME || path.join(home, ".config"), "com.cpa.gui", "config.toml"),
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
/** Reads only the API access key; OAuth/provider/management credentials stay untouched. */
|
|
37
|
+
export async function resolveCliProxy(requested, env = process.env) {
|
|
38
|
+
let config;
|
|
39
|
+
const explicitUrl = typeof requested === "string" ? requested : env.CLIPROXY_BASE_URL;
|
|
40
|
+
for (const file of explicitUrl && env.CLIPROXY_API_KEY ? [] : cliProxyConfigPaths(env)) {
|
|
41
|
+
try {
|
|
42
|
+
config = parse(await readFile(file, "utf8"));
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
if (err.code === "ENOENT" && !env.CLIPROXY_CONFIG)
|
|
47
|
+
continue;
|
|
48
|
+
throw new Error("Could not read CLIProxy configuration; check CLIPROXY_CONFIG or set CLIPROXY_BASE_URL and CLIPROXY_API_KEY");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
let detectedUrl;
|
|
52
|
+
if (config) {
|
|
53
|
+
const port = config.port;
|
|
54
|
+
const host = config.host === "::1" ? "[::1]" : (config.host || "127.0.0.1");
|
|
55
|
+
if (typeof host === "string" && typeof port === "number" && Number.isInteger(port) && port > 0 && port <= 65535) {
|
|
56
|
+
try {
|
|
57
|
+
detectedUrl = cliProxyBaseUrl(`http://${host}:${port}`);
|
|
58
|
+
}
|
|
59
|
+
catch { /* A LAN-configured application is not eligible for auto-discovery. */ }
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const baseUrl = cliProxyBaseUrl(typeof requested === "string" ? requested : env.CLIPROXY_BASE_URL || detectedUrl || "http://127.0.0.1:8317/v1");
|
|
63
|
+
const keys = config?.["api-keys"];
|
|
64
|
+
// EasyCLIProxyAPI also writes annotated entries as [[api-keys]] tables.
|
|
65
|
+
// Only their access-key field is relevant; remarks are display metadata.
|
|
66
|
+
const detectedKey = detectedUrl === baseUrl && Array.isArray(keys)
|
|
67
|
+
? keys.map((entry) => typeof entry === "string" ? entry : entry && typeof entry === "object" && "key" in entry ? entry.key : undefined)
|
|
68
|
+
.find((key) => typeof key === "string" && Boolean(key.trim()))
|
|
69
|
+
: undefined;
|
|
70
|
+
const apiKey = env.CLIPROXY_API_KEY || detectedKey || "";
|
|
71
|
+
if (!apiKey || /[\r\n]/.test(apiKey)) {
|
|
72
|
+
throw new Error("No CLIProxy API access key found; set CLIPROXY_API_KEY or configure an API key in EasyCLIProxyAPI");
|
|
73
|
+
}
|
|
74
|
+
let response;
|
|
75
|
+
try {
|
|
76
|
+
response = await fetch(`${baseUrl}/models`, {
|
|
77
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
78
|
+
redirect: "error",
|
|
79
|
+
signal: AbortSignal.timeout(5_000),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
throw new Error("CLIProxy is not reachable at the configured loopback address; start the proxy and check its port. Ditto Router inference was not used");
|
|
84
|
+
}
|
|
85
|
+
if (!response.ok) {
|
|
86
|
+
await response.body?.cancel();
|
|
87
|
+
throw new Error(`CLIProxy model check failed (HTTP ${response.status}); check its API access key and provider setup. Ditto Router inference was not used`);
|
|
88
|
+
}
|
|
89
|
+
let data;
|
|
90
|
+
try {
|
|
91
|
+
data = await response.json();
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
throw new Error("CLIProxy returned an invalid model catalog; Ditto Router inference was not used");
|
|
95
|
+
}
|
|
96
|
+
if (data?.object !== "list" || !Array.isArray(data.data))
|
|
97
|
+
throw new Error("CLIProxy returned an invalid model catalog; Ditto Router inference was not used");
|
|
98
|
+
const models = data.data.flatMap((model) => typeof model?.id === "string" && model.id.trim() ? [model.id] : []);
|
|
99
|
+
if (!models.length)
|
|
100
|
+
throw new Error("CLIProxy has no models; connect a provider in the proxy before launching");
|
|
101
|
+
return { baseUrl, apiKey, models };
|
|
102
|
+
}
|
|
103
|
+
export function cliProxyModel(proxy, harness, requested) {
|
|
104
|
+
if (requested) {
|
|
105
|
+
if (!proxy.models.includes(requested))
|
|
106
|
+
throw new Error("The requested model is not in CLIProxy's model catalog; select a model exposed by your local proxy");
|
|
107
|
+
return requested;
|
|
108
|
+
}
|
|
109
|
+
const pattern = harness === "claude" ? /^claude-/ : /^(gpt-|o[1-9])/;
|
|
110
|
+
const model = proxy.models.find((id) => pattern.test(id));
|
|
111
|
+
if (!model)
|
|
112
|
+
throw new Error(`CLIProxy has no default ${harness} model; pass --model with an ID exposed by your local proxy`);
|
|
113
|
+
return model;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=cliproxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cliproxy.js","sourceRoot":"","sources":["../../src/agents/cliproxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;A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if (resuming) {
|
|
34
34
|
args.push("resume");
|
|
35
35
|
}
|
|
36
|
-
args.push("-c", `model_provider=${tomlString("ditto")}`, "-c", `model_providers.ditto.name=${tomlString("Ditto")}`, "-c", `model_providers.ditto.base_url=${tomlString(input.baseUrl)}`, "-c", `model_providers.ditto.env_key=${tomlString(CODEX_KEY_ENV)}`, "-c", `model_providers.ditto.wire_api=${tomlString("responses")}`, "-c", `model_providers.ditto.http_headers=${tomlInlineTable([[SESSION_HEADER, input.sessionId], ...harnessHeaders("codex", input.harnessVersion)])}`);
|
|
36
|
+
args.push("-c", `model_provider=${tomlString("ditto")}`, "-c", `model_providers.ditto.name=${tomlString(input.localInference ? "CLIProxy" : "Ditto")}`, "-c", `model_providers.ditto.base_url=${tomlString(input.baseUrl)}`, "-c", `model_providers.ditto.env_key=${tomlString(CODEX_KEY_ENV)}`, "-c", `model_providers.ditto.wire_api=${tomlString("responses")}`, "-c", `model_providers.ditto.http_headers=${tomlInlineTable(input.localInference ? [] : [[SESSION_HEADER, input.sessionId], ...harnessHeaders("codex", input.harnessVersion)])}`);
|
|
37
37
|
if (input.model)
|
|
38
38
|
args.push("-m", input.model);
|
|
39
39
|
if (input.yolo)
|
package/dist/agents/codex.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex.js","sourceRoot":"","sources":["../../src/agents/codex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAoC,cAAc,EAAE,MAAM,YAAY,CAAC;AAE7F,uEAAuE;AACvE,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,eAAe,CAAC,OAAgC;IAC9D,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,E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AAE,EAAE,CAAC,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,EAAE;QACzC,QAAQ,EAAE,EAAE;QACZ,WAAW,EAAE,+DAA+D;KAC7E,CAAC;AACJ,CAAC"}
|
package/dist/agents/launch.d.ts
CHANGED
|
@@ -40,6 +40,8 @@ export interface LaunchOptions {
|
|
|
40
40
|
*/
|
|
41
41
|
mcp?: boolean;
|
|
42
42
|
mcpOnly?: boolean;
|
|
43
|
+
/** Direct inference through a loopback CLIProxy; URL is persisted, keys are not. */
|
|
44
|
+
cliproxy?: string | boolean;
|
|
43
45
|
remoteTransport?: "cli" | "channels";
|
|
44
46
|
}
|
|
45
47
|
/** Explicit flags (or resumed choices) win over repo/cloud launch defaults. */
|
package/dist/agents/launch.js
CHANGED
|
@@ -14,12 +14,13 @@ import { findProfileEndpoint, repoDefaultProfile } from "../dittoconfig/profiles
|
|
|
14
14
|
import { err as c } from "../ui.js";
|
|
15
15
|
import { holdNotesForTui, releaseNotes, writeNote } from "../terminal-note.js";
|
|
16
16
|
import { claudeDittoDenyRules } from "./claude-deny.js";
|
|
17
|
-
import { claudeMcpAttachment, fetchMcpCatalog, mcpApprovalNote } from "./claude-mcp.js";
|
|
17
|
+
import { claudeMcpAttachment, fetchMcpCatalog, mcpApprovalNote, mcpUnavailableLines } from "./claude-mcp.js";
|
|
18
18
|
import { liftResumeFlags, planClaude } from "./claude.js";
|
|
19
19
|
import { resolveClaudeResume, transcriptCwd } from "./claude-resume.js";
|
|
20
20
|
import { findTranscriptById, isUuid, listTranscriptsIn } from "./claude-transcripts.js";
|
|
21
21
|
import { watchClaudeSessionTitle } from "./claude-title-sync.js";
|
|
22
22
|
import { planCodex } from "./codex.js";
|
|
23
|
+
import { cliProxyModel, resolveCliProxy } from "./cliproxy.js";
|
|
23
24
|
import { readHarnessVersion } from "./harness-headers.js";
|
|
24
25
|
import { ensureGrokHome, planGrok } from "./grok.js";
|
|
25
26
|
import { latestSession, readSession, sessionForHarnessId, writeSession } from "./sessions.js";
|
|
@@ -33,7 +34,7 @@ import { loadPty, spawnInPty } from "../remote/pty.js";
|
|
|
33
34
|
import { checkpointPush } from "../teleport/commands.js";
|
|
34
35
|
/** Explicit flags (or resumed choices) win over repo/cloud launch defaults. */
|
|
35
36
|
export function resolveClaudeLaunchDefaults(options, defaults = {}) {
|
|
36
|
-
const mcpOnly = options.mcpOnly ?? (defaults.claude_inference === "native");
|
|
37
|
+
const mcpOnly = options.cliproxy ? false : options.mcpOnly ?? (defaults.claude_inference === "native");
|
|
37
38
|
const channelsUsable = !options.headless && remoteMode(options) === "tui";
|
|
38
39
|
const remoteTransport = options.remoteTransport ?? (mcpOnly && channelsUsable && defaults.claude_remote_transport === "channels" ? "channels" : "cli");
|
|
39
40
|
return { ...options, mcpOnly, remoteTransport };
|
|
@@ -297,6 +298,12 @@ function waitForExit(child, command, cwd) {
|
|
|
297
298
|
}
|
|
298
299
|
/** Launches a coding harness against a Ditto inference endpoint with a temporary key. */
|
|
299
300
|
export async function launchHarness(harness, rawArgs, options) {
|
|
301
|
+
// An explicit empty value (often an unset shell variable) still requests
|
|
302
|
+
// CLIProxy. Reject it before any launch/setup work rather than treating it
|
|
303
|
+
// as a false boolean and silently using Router inference.
|
|
304
|
+
if (typeof options.cliproxy === "string" && !options.cliproxy.trim()) {
|
|
305
|
+
throw new Error("--cliproxy requires a loopback URL; pass --cliproxy alone to auto-detect");
|
|
306
|
+
}
|
|
300
307
|
let passthrough = stripSeparator(rawArgs);
|
|
301
308
|
if (harness === "claude") {
|
|
302
309
|
const lifted = liftResumeFlags(passthrough);
|
|
@@ -377,7 +384,26 @@ export async function launchHarness(harness, rawArgs, options) {
|
|
|
377
384
|
if (!record.harnessSessionId)
|
|
378
385
|
resumeLast = true;
|
|
379
386
|
}
|
|
380
|
-
options = {
|
|
387
|
+
options = {
|
|
388
|
+
...options,
|
|
389
|
+
cliproxy: options.cliproxy ?? (options.mcpOnly !== undefined ? false : record?.cliproxy),
|
|
390
|
+
mcpOnly: options.cliproxy ? options.mcpOnly : options.mcpOnly ?? record?.mcpOnly,
|
|
391
|
+
remoteTransport: options.remoteTransport ?? (remoteMode(options) === "tui" ? record?.remoteTransport : undefined),
|
|
392
|
+
};
|
|
393
|
+
if (typeof options.cliproxy === "string" && !options.cliproxy.trim()) {
|
|
394
|
+
throw new Error("The saved CLIProxy URL is empty; pass --cliproxy to auto-detect or --no-cliproxy to change inference mode");
|
|
395
|
+
}
|
|
396
|
+
if (options.cliproxy && options.mcpOnly)
|
|
397
|
+
throw new Error("choose either --cliproxy or --mcp-only");
|
|
398
|
+
if (options.cliproxy && harness === "grok")
|
|
399
|
+
throw new Error("--cliproxy is supported for claude and codex");
|
|
400
|
+
if (options.cliproxy && options.budget !== undefined)
|
|
401
|
+
throw new Error("--budget cannot cap CLIProxy subscription inference; configure limits in your local proxy instead");
|
|
402
|
+
// Check the local proxy before sign-in or minting any cloud key. A failure
|
|
403
|
+
// must never silently switch inference back to the paid Router.
|
|
404
|
+
const proxy = options.cliproxy ? await resolveCliProxy(options.cliproxy) : undefined;
|
|
405
|
+
if (proxy)
|
|
406
|
+
options = { ...options, cliproxy: proxy.baseUrl, mcpOnly: false };
|
|
381
407
|
const requestedEndpoint = options.endpoint ?? record?.endpointSlug;
|
|
382
408
|
let selected = options.dryRun ? undefined : await ensureLoggedIn(harness, requestedEndpoint);
|
|
383
409
|
let catalog;
|
|
@@ -462,7 +488,7 @@ export async function launchHarness(harness, rawArgs, options) {
|
|
|
462
488
|
endpoint = { ...endpoint, providerOptions: { ...endpoint.providerOptions, ...repoLaunchDefaults } };
|
|
463
489
|
options = resolveClaudeLaunchDefaults(options, endpoint.providerOptions);
|
|
464
490
|
}
|
|
465
|
-
if (!options.mcpOnly)
|
|
491
|
+
if (!options.mcpOnly && !proxy)
|
|
466
492
|
await assertEndpointActive(endpoint);
|
|
467
493
|
if (options.mcpOnly && (harness !== "claude" || options.mcp === false))
|
|
468
494
|
throw new Error("--mcp-only requires Claude Code with MCP tools enabled");
|
|
@@ -484,7 +510,7 @@ export async function launchHarness(harness, rawArgs, options) {
|
|
|
484
510
|
// claude-* ids). Earlier releases pinned Codex sessions to the endpoint
|
|
485
511
|
// slug; that pin is dropped on resume so they pass through too.
|
|
486
512
|
const recordedModel = record?.model === endpoint.slug ? undefined : record?.model;
|
|
487
|
-
const model = options.model ?? recordedModel;
|
|
513
|
+
const model = proxy ? cliProxyModel(proxy, harness, options.model ?? recordedModel) : options.model ?? recordedModel;
|
|
488
514
|
const now = new Date().toISOString();
|
|
489
515
|
if (!(await isDirectory(cwd)))
|
|
490
516
|
throw new Error(`launch directory ${cwd} does not exist`);
|
|
@@ -528,14 +554,17 @@ export async function launchHarness(harness, rawArgs, options) {
|
|
|
528
554
|
let noTools = false;
|
|
529
555
|
if (wantMcp && key?.key) {
|
|
530
556
|
try {
|
|
531
|
-
const
|
|
557
|
+
const mcpCatalog = await fetchMcpCatalog(catalog.baseUrl, key.key, sessionId);
|
|
558
|
+
const attachment = claudeMcpAttachment(mcpCatalog, sessionId, { yolo: options.yolo, toolDeny: claudeDittoDenyRules(cwd, process.env) });
|
|
532
559
|
if (attachment.tools > 0)
|
|
533
560
|
mcp = attachment;
|
|
534
561
|
else
|
|
535
562
|
noTools = true;
|
|
563
|
+
for (const line of mcpUnavailableLines(mcpCatalog))
|
|
564
|
+
log(c("yellow", line));
|
|
536
565
|
}
|
|
537
566
|
catch (err) {
|
|
538
|
-
if (options.mcpOnly) {
|
|
567
|
+
if (options.mcpOnly || proxy) {
|
|
539
568
|
if (!options.keepKey) {
|
|
540
569
|
try {
|
|
541
570
|
await revokeKey(endpoint.id, key.id);
|
|
@@ -544,7 +573,7 @@ export async function launchHarness(harness, rawArgs, options) {
|
|
|
544
573
|
log(`could not revoke session key …${key.keyHint}; it expires in ${expiresIn}`);
|
|
545
574
|
}
|
|
546
575
|
}
|
|
547
|
-
throw new Error(
|
|
576
|
+
throw new Error(`${proxy ? "CLIProxy MCP" : "MCP-only"} setup failed; no inference Router fallback: ${err.message}`);
|
|
548
577
|
}
|
|
549
578
|
const note = c(chosen ? "yellow" : "dim", "native MCP unavailable");
|
|
550
579
|
log(`${note} (${err.message}); the router keeps this endpoint's tools`);
|
|
@@ -553,8 +582,10 @@ export async function launchHarness(harness, rawArgs, options) {
|
|
|
553
582
|
// Read once per launch and reused by every turn.
|
|
554
583
|
const harnessVersion = await harnessVersionProbe;
|
|
555
584
|
const plan = planFor(harness, {
|
|
556
|
-
baseUrl: catalog.baseUrl,
|
|
557
|
-
apiKey: key?.key ?? DRY_RUN_KEY,
|
|
585
|
+
baseUrl: proxy?.baseUrl ?? catalog.baseUrl,
|
|
586
|
+
apiKey: proxy?.apiKey ?? key?.key ?? DRY_RUN_KEY,
|
|
587
|
+
mcpApiKey: key?.key ?? DRY_RUN_KEY,
|
|
588
|
+
localInference: Boolean(proxy),
|
|
558
589
|
sessionId,
|
|
559
590
|
harnessVersion,
|
|
560
591
|
model,
|
|
@@ -575,7 +606,7 @@ export async function launchHarness(harness, rawArgs, options) {
|
|
|
575
606
|
const field = (name, value) => `${c("dim", `${name}=`)}${value}`;
|
|
576
607
|
const banner = [
|
|
577
608
|
field("endpoint", c(["bold", "cyan"], endpoint.slug)),
|
|
578
|
-
field("inference", options.mcpOnly ? "native Claude Code account (MCP only)" : "Ditto Router"),
|
|
609
|
+
field("inference", proxy ? `CLIProxy (${proxy.baseUrl})` : options.mcpOnly ? "native Claude Code account (MCP only)" : "Ditto Router"),
|
|
579
610
|
field("model", model ?? c("dim", options.mcpOnly ? "(native Claude Code default)" : "(harness default → endpoint routes)")),
|
|
580
611
|
field("key", key ? `…${key.keyHint || maskKey(key.key ?? "")}` : "(dry run)"),
|
|
581
612
|
field("expires", `${expiresIn}${options.keepKey ? "" : c("dim", " (revoked on exit)")}`),
|
|
@@ -586,9 +617,12 @@ export async function launchHarness(harness, rawArgs, options) {
|
|
|
586
617
|
.filter(Boolean)
|
|
587
618
|
.join(" ");
|
|
588
619
|
log(banner);
|
|
589
|
-
|
|
620
|
+
if (proxy)
|
|
621
|
+
log("inference stays on CLIProxy; Ditto provides MCP tools/remote control, without Router inference optimizations or inference traces");
|
|
622
|
+
else
|
|
623
|
+
log(`traces: ${c(["underline", "cyan"], endpointURL(endpoint.id))}`);
|
|
590
624
|
if (options.dryRun) {
|
|
591
|
-
const env = Object.fromEntries(Object.entries(plan.envSet).map(([k, v]) => [k, v === DRY_RUN_KEY ? "<key>" : v]));
|
|
625
|
+
const env = Object.fromEntries(Object.entries(plan.envSet).map(([k, v]) => [k, v === DRY_RUN_KEY || v === proxy?.apiKey ? "<key>" : v]));
|
|
592
626
|
process.stdout.write(`${JSON.stringify({
|
|
593
627
|
harness,
|
|
594
628
|
command: plan.command,
|
|
@@ -600,9 +634,9 @@ export async function launchHarness(harness, rawArgs, options) {
|
|
|
600
634
|
sessionId,
|
|
601
635
|
// A dry run reads no catalog, so the plan above is the router's; say
|
|
602
636
|
// which surface a real launch would ask for, separately.
|
|
603
|
-
toolSurface: mcp ? "mcp" : "router",
|
|
604
|
-
toolSurfaceRequested: wantMcp ? "mcp" : "router",
|
|
605
|
-
inference: options.mcpOnly ? "native" : "router",
|
|
637
|
+
toolSurface: mcp ? "mcp" : proxy ? "none" : "router",
|
|
638
|
+
toolSurfaceRequested: wantMcp ? "mcp" : proxy ? "none" : "router",
|
|
639
|
+
inference: proxy ? "cliproxy" : options.mcpOnly ? "native" : "router",
|
|
606
640
|
remoteTransport: options.remoteTransport ?? "cli",
|
|
607
641
|
key: { name: keyName, expiresIn, spendLimitTokens: budget ?? null },
|
|
608
642
|
}, null, 2)}\n`);
|
|
@@ -626,6 +660,7 @@ export async function launchHarness(harness, rawArgs, options) {
|
|
|
626
660
|
lastLaunchedAt: now,
|
|
627
661
|
launches: (record?.launches ?? 0) + 1,
|
|
628
662
|
mcpOnly: options.mcpOnly,
|
|
663
|
+
cliproxy: proxy?.baseUrl,
|
|
629
664
|
remoteTransport: options.remoteTransport,
|
|
630
665
|
...(explicitLaunchTitle ? { explicitLaunchTitle } : {}),
|
|
631
666
|
};
|
|
@@ -633,7 +668,7 @@ export async function launchHarness(harness, rawArgs, options) {
|
|
|
633
668
|
const remote = remoteMode(options);
|
|
634
669
|
const launchRegistration = {
|
|
635
670
|
sessionId, endpointId: endpoint.id, harness: harness === "claude" ? "claude-code" : harness,
|
|
636
|
-
inference: options.mcpOnly ? "native" : "router", transport: options.remoteTransport ?? "cli",
|
|
671
|
+
inference: proxy || options.mcpOnly ? "native" : "router", transport: options.remoteTransport ?? "cli",
|
|
637
672
|
title: explicitLaunchTitle || `${path.basename(cwd)} · ${sessionId.slice(0, 8)}`,
|
|
638
673
|
...(harness === "claude" && harnessSessionId && isUuid(harnessSessionId) ? { nativeSessionId: harnessSessionId } : {}),
|
|
639
674
|
};
|
|
@@ -668,8 +703,10 @@ export async function launchHarness(harness, rawArgs, options) {
|
|
|
668
703
|
cwd,
|
|
669
704
|
sessionId,
|
|
670
705
|
harnessSessionId,
|
|
671
|
-
baseUrl: catalog.baseUrl,
|
|
672
|
-
apiKey: key.key ?? "",
|
|
706
|
+
baseUrl: proxy?.baseUrl ?? catalog.baseUrl,
|
|
707
|
+
apiKey: proxy?.apiKey ?? key.key ?? "",
|
|
708
|
+
mcpApiKey: key.key ?? "",
|
|
709
|
+
localInference: Boolean(proxy),
|
|
673
710
|
harnessVersion,
|
|
674
711
|
model,
|
|
675
712
|
options,
|
|
@@ -893,6 +930,8 @@ async function runHeadless(harness, ctx) {
|
|
|
893
930
|
base: {
|
|
894
931
|
baseUrl: ctx.baseUrl,
|
|
895
932
|
apiKey: ctx.apiKey,
|
|
933
|
+
mcpApiKey: ctx.mcpApiKey,
|
|
934
|
+
localInference: ctx.localInference,
|
|
896
935
|
sessionId: ctx.sessionId,
|
|
897
936
|
harnessVersion: ctx.harnessVersion,
|
|
898
937
|
model: ctx.model,
|