@rynfar/meridian 1.23.0 → 1.24.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 +2 -1
- package/dist/{cli-jxs230js.js → cli-adpwqa7a.js} +133 -9
- package/dist/cli.js +1 -1
- package/dist/proxy/adapter.d.ts +8 -0
- package/dist/proxy/adapter.d.ts.map +1 -1
- package/dist/proxy/adapters/detect.d.ts +2 -1
- package/dist/proxy/adapters/detect.d.ts.map +1 -1
- package/dist/proxy/adapters/passthrough.d.ts +19 -0
- package/dist/proxy/adapters/passthrough.d.ts.map +1 -0
- package/dist/proxy/errors.d.ts.map +1 -1
- package/dist/proxy/query.d.ts +6 -2
- package/dist/proxy/query.d.ts.map +1 -1
- package/dist/proxy/server.d.ts.map +1 -1
- package/dist/server.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -228,7 +228,8 @@ src/proxy/
|
|
|
228
228
|
│ ├── detect.ts ← Agent detection from request headers
|
|
229
229
|
│ ├── opencode.ts ← OpenCode adapter
|
|
230
230
|
│ ├── crush.ts ← Crush (Charm) adapter
|
|
231
|
-
│
|
|
231
|
+
│ ├── droid.ts ← Droid (Factory AI) adapter
|
|
232
|
+
│ └── passthrough.ts ← LiteLLM passthrough adapter
|
|
232
233
|
├── query.ts ← SDK query options builder
|
|
233
234
|
├── errors.ts ← Error classification
|
|
234
235
|
├── models.ts ← Model mapping (sonnet/opus/haiku)
|
|
@@ -6964,11 +6964,21 @@ function classifyError(errMsg) {
|
|
|
6964
6964
|
if (lower.includes("exited with code") || lower.includes("process exited")) {
|
|
6965
6965
|
const codeMatch = errMsg.match(/exited with code (\d+)/);
|
|
6966
6966
|
const code = codeMatch ? codeMatch[1] : "unknown";
|
|
6967
|
+
const hasStderr = lower.includes("subprocess stderr:");
|
|
6968
|
+
const stderrContent = hasStderr ? lower.split("subprocess stderr:")[1]?.trim() ?? "" : "";
|
|
6969
|
+
if (stderrContent.includes("authentication") || stderrContent.includes("401") || stderrContent.includes("oauth")) {
|
|
6970
|
+
return {
|
|
6971
|
+
status: 401,
|
|
6972
|
+
type: "authentication_error",
|
|
6973
|
+
message: "Claude authentication expired or invalid. Run 'claude login' in your terminal to re-authenticate, then restart the proxy."
|
|
6974
|
+
};
|
|
6975
|
+
}
|
|
6967
6976
|
if (code === "1" && !lower.includes("tool") && !lower.includes("mcp")) {
|
|
6977
|
+
const stderrHint = stderrContent ? ` Subprocess output: ${stderrContent.slice(0, 200)}` : " Run with CLAUDE_PROXY_DEBUG=1 for more detail.";
|
|
6968
6978
|
return {
|
|
6969
6979
|
status: 401,
|
|
6970
6980
|
type: "authentication_error",
|
|
6971
|
-
message:
|
|
6981
|
+
message: `Claude Code process exited (code 1). This is often an authentication issue — try 'claude login' and restart the proxy.${stderrHint}`
|
|
6972
6982
|
};
|
|
6973
6983
|
}
|
|
6974
6984
|
return {
|
|
@@ -7638,7 +7648,92 @@ var crushAdapter = {
|
|
|
7638
7648
|
}
|
|
7639
7649
|
};
|
|
7640
7650
|
|
|
7651
|
+
// src/proxy/adapters/passthrough.ts
|
|
7652
|
+
var MCP_SERVER_NAME2 = "litellm";
|
|
7653
|
+
var ALLOWED_MCP_TOOLS2 = [
|
|
7654
|
+
`mcp__${MCP_SERVER_NAME2}__read`,
|
|
7655
|
+
`mcp__${MCP_SERVER_NAME2}__write`,
|
|
7656
|
+
`mcp__${MCP_SERVER_NAME2}__edit`,
|
|
7657
|
+
`mcp__${MCP_SERVER_NAME2}__bash`,
|
|
7658
|
+
`mcp__${MCP_SERVER_NAME2}__glob`,
|
|
7659
|
+
`mcp__${MCP_SERVER_NAME2}__grep`
|
|
7660
|
+
];
|
|
7661
|
+
function extractCwdFromBody(body) {
|
|
7662
|
+
if (!body)
|
|
7663
|
+
return;
|
|
7664
|
+
let promptContent = "";
|
|
7665
|
+
if (typeof body.prompt === "string") {
|
|
7666
|
+
promptContent = body.prompt;
|
|
7667
|
+
} else if (Array.isArray(body.messages)) {
|
|
7668
|
+
for (const msg of body.messages) {
|
|
7669
|
+
if (msg.role === "user") {
|
|
7670
|
+
if (typeof msg.content === "string") {
|
|
7671
|
+
promptContent += msg.content;
|
|
7672
|
+
} else if (Array.isArray(msg.content)) {
|
|
7673
|
+
for (const block of msg.content) {
|
|
7674
|
+
if (block.type === "text" && block.text) {
|
|
7675
|
+
promptContent += block.text;
|
|
7676
|
+
}
|
|
7677
|
+
}
|
|
7678
|
+
}
|
|
7679
|
+
}
|
|
7680
|
+
}
|
|
7681
|
+
}
|
|
7682
|
+
const envMatch = promptContent.match(/<env[^>]*cwd=["']([^"']+)["']/s);
|
|
7683
|
+
if (envMatch)
|
|
7684
|
+
return envMatch[1];
|
|
7685
|
+
const cwdMatch = promptContent.match(/cwd=["']([^"']+)["']/);
|
|
7686
|
+
if (cwdMatch)
|
|
7687
|
+
return cwdMatch[1];
|
|
7688
|
+
return;
|
|
7689
|
+
}
|
|
7690
|
+
var passthroughAdapter = {
|
|
7691
|
+
name: "passthrough",
|
|
7692
|
+
getSessionId(c) {
|
|
7693
|
+
return c.req.header("x-litellm-session-id");
|
|
7694
|
+
},
|
|
7695
|
+
extractWorkingDirectory(body) {
|
|
7696
|
+
return extractCwdFromBody(body);
|
|
7697
|
+
},
|
|
7698
|
+
normalizeContent(content) {
|
|
7699
|
+
return normalizeContent(content);
|
|
7700
|
+
},
|
|
7701
|
+
getBlockedBuiltinTools() {
|
|
7702
|
+
return [];
|
|
7703
|
+
},
|
|
7704
|
+
getAgentIncompatibleTools() {
|
|
7705
|
+
return [];
|
|
7706
|
+
},
|
|
7707
|
+
getMcpServerName() {
|
|
7708
|
+
return MCP_SERVER_NAME2;
|
|
7709
|
+
},
|
|
7710
|
+
getAllowedMcpTools() {
|
|
7711
|
+
return ALLOWED_MCP_TOOLS2;
|
|
7712
|
+
},
|
|
7713
|
+
buildSdkAgents(_body, _mcpToolNames) {
|
|
7714
|
+
return {};
|
|
7715
|
+
},
|
|
7716
|
+
buildSdkHooks(_body, _sdkAgents) {
|
|
7717
|
+
return;
|
|
7718
|
+
},
|
|
7719
|
+
buildSystemContextAddendum(_body, _sdkAgents) {
|
|
7720
|
+
return "";
|
|
7721
|
+
},
|
|
7722
|
+
usesPassthrough() {
|
|
7723
|
+
return true;
|
|
7724
|
+
},
|
|
7725
|
+
prefersStreaming(_body) {
|
|
7726
|
+
return false;
|
|
7727
|
+
}
|
|
7728
|
+
};
|
|
7729
|
+
|
|
7641
7730
|
// src/proxy/adapters/detect.ts
|
|
7731
|
+
function isLiteLLMRequest(c) {
|
|
7732
|
+
if ((c.req.header("user-agent") || "").startsWith("litellm/"))
|
|
7733
|
+
return true;
|
|
7734
|
+
const headers = c.req.header();
|
|
7735
|
+
return Object.keys(headers).some((k) => k.toLowerCase().startsWith("x-litellm-"));
|
|
7736
|
+
}
|
|
7642
7737
|
function detectAdapter(c) {
|
|
7643
7738
|
const userAgent = c.req.header("user-agent") || "";
|
|
7644
7739
|
if (userAgent.startsWith("factory-cli/")) {
|
|
@@ -7647,6 +7742,9 @@ function detectAdapter(c) {
|
|
|
7647
7742
|
if (userAgent.startsWith("Charm-Crush/")) {
|
|
7648
7743
|
return crushAdapter;
|
|
7649
7744
|
}
|
|
7745
|
+
if (isLiteLLMRequest(c)) {
|
|
7746
|
+
return passthroughAdapter;
|
|
7747
|
+
}
|
|
7650
7748
|
return openCodeAdapter;
|
|
7651
7749
|
}
|
|
7652
7750
|
|
|
@@ -13358,7 +13456,8 @@ function buildQueryOptions(ctx) {
|
|
|
13358
13456
|
isUndo,
|
|
13359
13457
|
undoRollbackUuid,
|
|
13360
13458
|
sdkHooks,
|
|
13361
|
-
adapter
|
|
13459
|
+
adapter,
|
|
13460
|
+
onStderr
|
|
13362
13461
|
} = ctx;
|
|
13363
13462
|
const blockedTools = [...adapter.getBlockedBuiltinTools(), ...adapter.getAgentIncompatibleTools()];
|
|
13364
13463
|
const mcpServerName = adapter.getMcpServerName();
|
|
@@ -13388,6 +13487,7 @@ function buildQueryOptions(ctx) {
|
|
|
13388
13487
|
mcpServers: { [mcpServerName]: createOpencodeMcpServer() }
|
|
13389
13488
|
},
|
|
13390
13489
|
plugins: [],
|
|
13490
|
+
...onStderr ? { stderr: onStderr } : {},
|
|
13391
13491
|
env: {
|
|
13392
13492
|
...cleanEnv,
|
|
13393
13493
|
ENABLE_TOOL_SEARCH: "false",
|
|
@@ -14038,8 +14138,9 @@ function createProxyServer(config = {}) {
|
|
|
14038
14138
|
const body = await c.req.json();
|
|
14039
14139
|
const authStatus = await getClaudeAuthStatusAsync();
|
|
14040
14140
|
let model = mapModelToClaudeModel(body.model || "sonnet", authStatus?.subscriptionType);
|
|
14041
|
-
const stream2 = body.stream ?? true;
|
|
14042
14141
|
const adapter = detectAdapter(c);
|
|
14142
|
+
const adapterStreamPref = adapter.prefersStreaming?.(body);
|
|
14143
|
+
const stream2 = adapterStreamPref !== undefined ? adapterStreamPref : body.stream ?? true;
|
|
14043
14144
|
const workingDirectory = (process.env.MERIDIAN_WORKDIR ?? process.env.CLAUDE_PROXY_WORKDIR) || adapter.extractWorkingDirectory(body) || process.cwd();
|
|
14044
14145
|
const {
|
|
14045
14146
|
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS,
|
|
@@ -14215,6 +14316,11 @@ function createProxyServer(config = {}) {
|
|
|
14215
14316
|
...adapter.buildSdkHooks?.(body, sdkAgents) ?? {},
|
|
14216
14317
|
...fileChangeHook ? { PostToolUse: [fileChangeHook] } : {}
|
|
14217
14318
|
};
|
|
14319
|
+
const stderrLines = [];
|
|
14320
|
+
const onStderr = (data) => {
|
|
14321
|
+
stderrLines.push(data.trimEnd());
|
|
14322
|
+
claudeLog("subprocess.stderr", { line: data.trimEnd() });
|
|
14323
|
+
};
|
|
14218
14324
|
if (!stream2) {
|
|
14219
14325
|
const contentBlocks = [];
|
|
14220
14326
|
let assistantMessages = 0;
|
|
@@ -14251,7 +14357,8 @@ function createProxyServer(config = {}) {
|
|
|
14251
14357
|
isUndo,
|
|
14252
14358
|
undoRollbackUuid,
|
|
14253
14359
|
sdkHooks,
|
|
14254
|
-
adapter
|
|
14360
|
+
adapter,
|
|
14361
|
+
onStderr
|
|
14255
14362
|
}))) {
|
|
14256
14363
|
if (event.type === "assistant") {
|
|
14257
14364
|
didYieldContent = true;
|
|
@@ -14289,7 +14396,8 @@ function createProxyServer(config = {}) {
|
|
|
14289
14396
|
isUndo: false,
|
|
14290
14397
|
undoRollbackUuid: undefined,
|
|
14291
14398
|
sdkHooks,
|
|
14292
|
-
adapter
|
|
14399
|
+
adapter,
|
|
14400
|
+
onStderr
|
|
14293
14401
|
}));
|
|
14294
14402
|
return;
|
|
14295
14403
|
}
|
|
@@ -14358,11 +14466,18 @@ function createProxyServer(config = {}) {
|
|
|
14358
14466
|
durationMs: Date.now() - upstreamStartAt
|
|
14359
14467
|
});
|
|
14360
14468
|
} catch (error) {
|
|
14469
|
+
const stderrOutput = stderrLines.join(`
|
|
14470
|
+
`).trim();
|
|
14471
|
+
if (stderrOutput && error instanceof Error && !error.message.includes(stderrOutput)) {
|
|
14472
|
+
error.message = `${error.message}
|
|
14473
|
+
Subprocess stderr: ${stderrOutput}`;
|
|
14474
|
+
}
|
|
14361
14475
|
claudeLog("upstream.failed", {
|
|
14362
14476
|
mode: "non_stream",
|
|
14363
14477
|
model,
|
|
14364
14478
|
durationMs: Date.now() - upstreamStartAt,
|
|
14365
|
-
error: error instanceof Error ? error.message : String(error)
|
|
14479
|
+
error: error instanceof Error ? error.message : String(error),
|
|
14480
|
+
...stderrOutput ? { stderr: stderrOutput } : {}
|
|
14366
14481
|
});
|
|
14367
14482
|
throw error;
|
|
14368
14483
|
}
|
|
@@ -14512,7 +14627,8 @@ function createProxyServer(config = {}) {
|
|
|
14512
14627
|
isUndo,
|
|
14513
14628
|
undoRollbackUuid,
|
|
14514
14629
|
sdkHooks,
|
|
14515
|
-
adapter
|
|
14630
|
+
adapter,
|
|
14631
|
+
onStderr
|
|
14516
14632
|
}))) {
|
|
14517
14633
|
if (event.type === "stream_event") {
|
|
14518
14634
|
didYieldClientEvent = true;
|
|
@@ -14550,7 +14666,8 @@ function createProxyServer(config = {}) {
|
|
|
14550
14666
|
isUndo: false,
|
|
14551
14667
|
undoRollbackUuid: undefined,
|
|
14552
14668
|
sdkHooks,
|
|
14553
|
-
adapter
|
|
14669
|
+
adapter,
|
|
14670
|
+
onStderr
|
|
14554
14671
|
}));
|
|
14555
14672
|
return;
|
|
14556
14673
|
}
|
|
@@ -14857,6 +14974,12 @@ data: {"type":"message_stop"}
|
|
|
14857
14974
|
});
|
|
14858
14975
|
return;
|
|
14859
14976
|
}
|
|
14977
|
+
const stderrOutput = stderrLines.join(`
|
|
14978
|
+
`).trim();
|
|
14979
|
+
if (stderrOutput && error instanceof Error && !error.message.includes(stderrOutput)) {
|
|
14980
|
+
error.message = `${error.message}
|
|
14981
|
+
Subprocess stderr: ${stderrOutput}`;
|
|
14982
|
+
}
|
|
14860
14983
|
const errMsg = error instanceof Error ? error.message : String(error);
|
|
14861
14984
|
claudeLog("upstream.failed", {
|
|
14862
14985
|
mode: "stream",
|
|
@@ -14864,7 +14987,8 @@ data: {"type":"message_stop"}
|
|
|
14864
14987
|
durationMs: Date.now() - upstreamStartAt,
|
|
14865
14988
|
streamEventsSeen,
|
|
14866
14989
|
textEventsForwarded,
|
|
14867
|
-
error: errMsg
|
|
14990
|
+
error: errMsg,
|
|
14991
|
+
...stderrOutput ? { stderr: stderrOutput } : {}
|
|
14868
14992
|
});
|
|
14869
14993
|
const streamErr = classifyError(errMsg);
|
|
14870
14994
|
claudeLog("proxy.anthropic.error", { error: errMsg, classified: streamErr.type });
|
package/dist/cli.js
CHANGED
package/dist/proxy/adapter.d.ts
CHANGED
|
@@ -64,6 +64,14 @@ export interface AgentAdapter {
|
|
|
64
64
|
* Return empty string if nothing to add.
|
|
65
65
|
*/
|
|
66
66
|
buildSystemContextAddendum?(body: any, sdkAgents: Record<string, any>): string;
|
|
67
|
+
/**
|
|
68
|
+
* Whether this agent prefers non-streaming (JSON) responses.
|
|
69
|
+
*
|
|
70
|
+
* When this method is defined and returns false, the proxy forces
|
|
71
|
+
* stream=false regardless of the client's body.stream setting.
|
|
72
|
+
* When undefined or returns true, body.stream is used (defaulting to true).
|
|
73
|
+
*/
|
|
74
|
+
prefersStreaming?(body: any): boolean;
|
|
67
75
|
/**
|
|
68
76
|
* Whether this agent uses passthrough mode for tool execution.
|
|
69
77
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/proxy/adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnC;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,sCAAsC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAErB;;;OAGG;IACH,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAA;IAE5C;;;OAGG;IACH,uBAAuB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,GAAG,SAAS,CAAA;IAEtD;;;OAGG;IACH,gBAAgB,CAAC,OAAO,EAAE,GAAG,GAAG,MAAM,CAAA;IAEtC;;;OAGG;IACH,sBAAsB,IAAI,SAAS,MAAM,EAAE,CAAA;IAE3C;;;;OAIG;IACH,yBAAyB,IAAI,SAAS,MAAM,EAAE,CAAA;IAE9C;;;OAGG;IACH,gBAAgB,IAAI,MAAM,CAAA;IAE1B;;OAEG;IACH,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAAA;IAEvC;;;;OAIG;IACH,cAAc,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAEhF;;;OAGG;IACH,aAAa,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,MAA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hF;;;OAGG;IACH,aAAa,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,CAAA;IAE9D;;;OAGG;IACH,0BAA0B,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAA;IAE9E;;;;;;OAMG;IACH,gBAAgB,CAAC,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAA;IAErC;;;;;;;;OAQG;IACH,eAAe,CAAC,IAAI,OAAO,CAAA;IAE3B;;;;;;;;;;;;;;;OAeG;IACH,6BAA6B,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,eAAe,EAAE,UAAU,EAAE,CAAA;CAC3G"}
|
|
@@ -12,7 +12,8 @@ import type { AgentAdapter } from "../adapter";
|
|
|
12
12
|
* Detection rules (evaluated in order):
|
|
13
13
|
* 1. User-Agent starts with "factory-cli/" → Droid adapter
|
|
14
14
|
* 2. User-Agent starts with "Charm-Crush/" → Crush adapter
|
|
15
|
-
* 3.
|
|
15
|
+
* 3. litellm/* UA or x-litellm-* headers → LiteLLM passthrough adapter
|
|
16
|
+
* 4. Default → OpenCode adapter (backward compatible)
|
|
16
17
|
*/
|
|
17
18
|
export declare function detectAdapter(c: Context): AgentAdapter;
|
|
18
19
|
//# sourceMappingURL=detect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../../src/proxy/adapters/detect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../../src/proxy/adapters/detect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAmB9C;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,GAAG,YAAY,CAgBtD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LiteLLM passthrough adapter.
|
|
3
|
+
*
|
|
4
|
+
* Handles requests from LiteLLM (detected via x-litellm-* headers or
|
|
5
|
+
* litellm/* User-Agent). LiteLLM manages its own tool execution loop,
|
|
6
|
+
* so this adapter forces passthrough mode — the proxy returns tool_use
|
|
7
|
+
* blocks to LiteLLM for execution rather than running them internally.
|
|
8
|
+
*
|
|
9
|
+
* Key characteristics:
|
|
10
|
+
* - Passthrough mode always enabled (overrides MERIDIAN_PASSTHROUGH env var)
|
|
11
|
+
* - Non-streaming: LiteLLM health checks don't send x-litellm-* headers
|
|
12
|
+
* so we can't reliably distinguish them; non-streaming is safe for all requests
|
|
13
|
+
* - Session continuity: uses x-litellm-session-id header when present
|
|
14
|
+
* - CWD: extracts from <env cwd="..."> blocks in the prompt if available
|
|
15
|
+
* - MCP server name: "litellm" (tools appear as mcp__litellm__*)
|
|
16
|
+
*/
|
|
17
|
+
import type { AgentAdapter } from "../adapter";
|
|
18
|
+
export declare const passthroughAdapter: AgentAdapter;
|
|
19
|
+
//# sourceMappingURL=passthrough.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passthrough.d.ts","sourceRoot":"","sources":["../../../src/proxy/adapters/passthrough.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAiD9C,eAAO,MAAM,kBAAkB,EAAE,YA4EhC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/proxy/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/proxy/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,CAmG7D;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAG3D;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAGxD"}
|
package/dist/proxy/query.d.ts
CHANGED
|
@@ -37,6 +37,8 @@ export interface QueryContext {
|
|
|
37
37
|
sdkHooks?: any;
|
|
38
38
|
/** The agent adapter providing tool configuration */
|
|
39
39
|
adapter: AgentAdapter;
|
|
40
|
+
/** Callback to receive stderr lines from the Claude subprocess */
|
|
41
|
+
onStderr?: (line: string) => void;
|
|
40
42
|
}
|
|
41
43
|
/**
|
|
42
44
|
* Build the options object for the Claude Agent SDK query() call.
|
|
@@ -51,11 +53,12 @@ export declare function buildQueryOptions(ctx: QueryContext): {
|
|
|
51
53
|
forkSession?: boolean | undefined;
|
|
52
54
|
resume?: string | undefined;
|
|
53
55
|
agents?: Record<string, any> | undefined;
|
|
54
|
-
plugins: never[];
|
|
55
56
|
env: {
|
|
56
57
|
ENABLE_CLAUDEAI_MCP_SERVERS?: string | undefined;
|
|
57
58
|
ENABLE_TOOL_SEARCH: string;
|
|
58
59
|
};
|
|
60
|
+
stderr?: ((line: string) => void) | undefined;
|
|
61
|
+
plugins: never[];
|
|
59
62
|
allowedTools?: string[] | undefined;
|
|
60
63
|
mcpServers?: {
|
|
61
64
|
oc: import("@anthropic-ai/claude-agent-sdk").McpSdkServerConfigWithInstance;
|
|
@@ -79,11 +82,12 @@ export declare function buildQueryOptions(ctx: QueryContext): {
|
|
|
79
82
|
forkSession?: boolean | undefined;
|
|
80
83
|
resume?: string | undefined;
|
|
81
84
|
agents?: Record<string, any> | undefined;
|
|
82
|
-
plugins: never[];
|
|
83
85
|
env: {
|
|
84
86
|
ENABLE_CLAUDEAI_MCP_SERVERS?: string | undefined;
|
|
85
87
|
ENABLE_TOOL_SEARCH: string;
|
|
86
88
|
};
|
|
89
|
+
stderr?: ((line: string) => void) | undefined;
|
|
90
|
+
plugins: never[];
|
|
87
91
|
disallowedTools: string[];
|
|
88
92
|
allowedTools: string[];
|
|
89
93
|
mcpServers: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/proxy/query.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAE7C,OAAO,EAAE,0BAA0B,EAAwB,MAAM,oBAAoB,CAAA;AAErF,MAAM,WAAW,YAAY;IAC3B,iEAAiE;IACjE,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,CAAA;IACnC,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,+BAA+B;IAC/B,gBAAgB,EAAE,MAAM,CAAA;IACxB,yCAAyC;IACzC,aAAa,EAAE,MAAM,CAAA;IACrB,gCAAgC;IAChC,gBAAgB,EAAE,MAAM,CAAA;IACxB,0CAA0C;IAC1C,WAAW,EAAE,OAAO,CAAA;IACpB,0CAA0C;IAC1C,MAAM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,CAAC,WAAW,CAAM,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/proxy/server.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACtE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,CAAA;AAiBvD,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACpB,KAAK,aAAa,EACnB,MAAM,mBAAmB,CAAA;AAG1B,OAAO,EAA+B,iBAAiB,EAAE,mBAAmB,EAAgB,MAAM,iBAAiB,CAAA;AAEnH,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAA;AAChE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,CAAA;AACjD,YAAY,EAAE,aAAa,EAAE,CAAA;AAyF7B,wBAAgB,iBAAiB,CAAC,MAAM,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,WAAW,CAosChF;AAED,wBAAsB,gBAAgB,CAAC,MAAM,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CA0ChG"}
|
package/dist/server.js
CHANGED
package/package.json
CHANGED