@rynfar/meridian 1.58.2 → 1.58.3
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/{cli-jwm61pg9.js → cli-deynz4ef.js} +190 -115
- package/dist/cli.js +1 -1
- package/dist/proxy/adapters/pi.d.ts.map +1 -1
- package/dist/proxy/sanitize.d.ts +23 -0
- package/dist/proxy/sanitize.d.ts.map +1 -1
- package/dist/proxy/server.d.ts.map +1 -1
- package/dist/proxy/transforms/claudecode.d.ts +17 -0
- package/dist/proxy/transforms/claudecode.d.ts.map +1 -0
- package/dist/proxy/transforms/registry.d.ts.map +1 -1
- package/dist/server.js +1 -1
- package/package.json +1 -1
|
@@ -12396,6 +12396,96 @@ var passthroughAdapter = {
|
|
|
12396
12396
|
// src/proxy/adapters/pi.ts
|
|
12397
12397
|
init_env();
|
|
12398
12398
|
|
|
12399
|
+
// src/proxy/adapters/claudecode.ts
|
|
12400
|
+
init_env();
|
|
12401
|
+
function extractClaudeCodeClientCwd(body) {
|
|
12402
|
+
let systemText = "";
|
|
12403
|
+
if (typeof body.system === "string") {
|
|
12404
|
+
systemText = body.system;
|
|
12405
|
+
} else if (Array.isArray(body.system)) {
|
|
12406
|
+
systemText = body.system.filter((b) => b.type === "text" && b.text).map((b) => b.text).join(`
|
|
12407
|
+
`);
|
|
12408
|
+
}
|
|
12409
|
+
if (!systemText)
|
|
12410
|
+
return;
|
|
12411
|
+
const match2 = systemText.match(/Primary working directory:\s*([^\n<]+)/i);
|
|
12412
|
+
return match2?.[1]?.trim() || undefined;
|
|
12413
|
+
}
|
|
12414
|
+
function extractClaudeCodeSessionId(body) {
|
|
12415
|
+
if (!body || typeof body !== "object")
|
|
12416
|
+
return;
|
|
12417
|
+
const metadata = body.metadata;
|
|
12418
|
+
if (!metadata || typeof metadata !== "object")
|
|
12419
|
+
return;
|
|
12420
|
+
const rawUserId = metadata.user_id;
|
|
12421
|
+
let userMetadata = rawUserId;
|
|
12422
|
+
if (typeof rawUserId === "string") {
|
|
12423
|
+
try {
|
|
12424
|
+
userMetadata = JSON.parse(rawUserId);
|
|
12425
|
+
} catch {
|
|
12426
|
+
return;
|
|
12427
|
+
}
|
|
12428
|
+
}
|
|
12429
|
+
if (!userMetadata || typeof userMetadata !== "object")
|
|
12430
|
+
return;
|
|
12431
|
+
const sessionId = userMetadata.session_id;
|
|
12432
|
+
return typeof sessionId === "string" && sessionId.length > 0 ? sessionId : undefined;
|
|
12433
|
+
}
|
|
12434
|
+
var claudeCodeAdapter = {
|
|
12435
|
+
name: "claude-code",
|
|
12436
|
+
getSessionId(_c, body) {
|
|
12437
|
+
return extractClaudeCodeSessionId(body);
|
|
12438
|
+
},
|
|
12439
|
+
extractWorkingDirectory(_body) {
|
|
12440
|
+
return;
|
|
12441
|
+
},
|
|
12442
|
+
extractClientWorkingDirectory(body) {
|
|
12443
|
+
return extractClaudeCodeClientCwd(body);
|
|
12444
|
+
},
|
|
12445
|
+
normalizeContent(content) {
|
|
12446
|
+
return normalizeContent(content);
|
|
12447
|
+
},
|
|
12448
|
+
getBlockedBuiltinTools() {
|
|
12449
|
+
return BLOCKED_BUILTIN_TOOLS;
|
|
12450
|
+
},
|
|
12451
|
+
getAgentIncompatibleTools() {
|
|
12452
|
+
return CLAUDE_CODE_ONLY_TOOLS;
|
|
12453
|
+
},
|
|
12454
|
+
getMcpServerName() {
|
|
12455
|
+
return MCP_SERVER_NAME;
|
|
12456
|
+
},
|
|
12457
|
+
getAllowedMcpTools() {
|
|
12458
|
+
return ALLOWED_MCP_TOOLS;
|
|
12459
|
+
},
|
|
12460
|
+
getCoreToolNames() {
|
|
12461
|
+
return ["Read", "Write", "Edit", "Bash", "Glob", "Grep"];
|
|
12462
|
+
},
|
|
12463
|
+
usesPassthrough() {
|
|
12464
|
+
return resolvePassthrough(true);
|
|
12465
|
+
},
|
|
12466
|
+
supportsThinking() {
|
|
12467
|
+
return true;
|
|
12468
|
+
},
|
|
12469
|
+
shouldTrackFileChanges() {
|
|
12470
|
+
return false;
|
|
12471
|
+
},
|
|
12472
|
+
extractFileChangesFromToolUse(toolName, toolInput) {
|
|
12473
|
+
const input = toolInput;
|
|
12474
|
+
const filePath = input?.file_path ?? input?.filePath ?? input?.path;
|
|
12475
|
+
const lowerName = toolName.toLowerCase();
|
|
12476
|
+
if (lowerName === "write" && filePath) {
|
|
12477
|
+
return [{ operation: "wrote", path: String(filePath) }];
|
|
12478
|
+
}
|
|
12479
|
+
if ((lowerName === "edit" || lowerName === "multiedit") && filePath) {
|
|
12480
|
+
return [{ operation: "edited", path: String(filePath) }];
|
|
12481
|
+
}
|
|
12482
|
+
if (lowerName === "bash" && input?.command) {
|
|
12483
|
+
return extractFileChangesFromBash(String(input.command));
|
|
12484
|
+
}
|
|
12485
|
+
return [];
|
|
12486
|
+
}
|
|
12487
|
+
};
|
|
12488
|
+
|
|
12399
12489
|
// src/proxy/transforms/pi.ts
|
|
12400
12490
|
init_env();
|
|
12401
12491
|
var PI_MCP_SERVER_NAME = "pi";
|
|
@@ -12465,8 +12555,8 @@ function extractPiCwd(body) {
|
|
|
12465
12555
|
}
|
|
12466
12556
|
var piAdapter = {
|
|
12467
12557
|
name: "pi",
|
|
12468
|
-
getSessionId(c) {
|
|
12469
|
-
return c.req.header("x-session-affinity");
|
|
12558
|
+
getSessionId(c, body) {
|
|
12559
|
+
return c.req.header("x-session-affinity") ?? extractClaudeCodeSessionId(body);
|
|
12470
12560
|
},
|
|
12471
12561
|
extractWorkingDirectory(body) {
|
|
12472
12562
|
return extractPiCwd(body);
|
|
@@ -12629,96 +12719,6 @@ var forgeCodeAdapter = {
|
|
|
12629
12719
|
}
|
|
12630
12720
|
};
|
|
12631
12721
|
|
|
12632
|
-
// src/proxy/adapters/claudecode.ts
|
|
12633
|
-
init_env();
|
|
12634
|
-
function extractClaudeCodeClientCwd(body) {
|
|
12635
|
-
let systemText = "";
|
|
12636
|
-
if (typeof body.system === "string") {
|
|
12637
|
-
systemText = body.system;
|
|
12638
|
-
} else if (Array.isArray(body.system)) {
|
|
12639
|
-
systemText = body.system.filter((b) => b.type === "text" && b.text).map((b) => b.text).join(`
|
|
12640
|
-
`);
|
|
12641
|
-
}
|
|
12642
|
-
if (!systemText)
|
|
12643
|
-
return;
|
|
12644
|
-
const match2 = systemText.match(/Primary working directory:\s*([^\n<]+)/i);
|
|
12645
|
-
return match2?.[1]?.trim() || undefined;
|
|
12646
|
-
}
|
|
12647
|
-
function extractClaudeCodeSessionId(body) {
|
|
12648
|
-
if (!body || typeof body !== "object")
|
|
12649
|
-
return;
|
|
12650
|
-
const metadata = body.metadata;
|
|
12651
|
-
if (!metadata || typeof metadata !== "object")
|
|
12652
|
-
return;
|
|
12653
|
-
const rawUserId = metadata.user_id;
|
|
12654
|
-
let userMetadata = rawUserId;
|
|
12655
|
-
if (typeof rawUserId === "string") {
|
|
12656
|
-
try {
|
|
12657
|
-
userMetadata = JSON.parse(rawUserId);
|
|
12658
|
-
} catch {
|
|
12659
|
-
return;
|
|
12660
|
-
}
|
|
12661
|
-
}
|
|
12662
|
-
if (!userMetadata || typeof userMetadata !== "object")
|
|
12663
|
-
return;
|
|
12664
|
-
const sessionId = userMetadata.session_id;
|
|
12665
|
-
return typeof sessionId === "string" && sessionId.length > 0 ? sessionId : undefined;
|
|
12666
|
-
}
|
|
12667
|
-
var claudeCodeAdapter = {
|
|
12668
|
-
name: "claude-code",
|
|
12669
|
-
getSessionId(_c, body) {
|
|
12670
|
-
return extractClaudeCodeSessionId(body);
|
|
12671
|
-
},
|
|
12672
|
-
extractWorkingDirectory(_body) {
|
|
12673
|
-
return;
|
|
12674
|
-
},
|
|
12675
|
-
extractClientWorkingDirectory(body) {
|
|
12676
|
-
return extractClaudeCodeClientCwd(body);
|
|
12677
|
-
},
|
|
12678
|
-
normalizeContent(content) {
|
|
12679
|
-
return normalizeContent(content);
|
|
12680
|
-
},
|
|
12681
|
-
getBlockedBuiltinTools() {
|
|
12682
|
-
return BLOCKED_BUILTIN_TOOLS;
|
|
12683
|
-
},
|
|
12684
|
-
getAgentIncompatibleTools() {
|
|
12685
|
-
return CLAUDE_CODE_ONLY_TOOLS;
|
|
12686
|
-
},
|
|
12687
|
-
getMcpServerName() {
|
|
12688
|
-
return MCP_SERVER_NAME;
|
|
12689
|
-
},
|
|
12690
|
-
getAllowedMcpTools() {
|
|
12691
|
-
return ALLOWED_MCP_TOOLS;
|
|
12692
|
-
},
|
|
12693
|
-
getCoreToolNames() {
|
|
12694
|
-
return ["Read", "Write", "Edit", "Bash", "Glob", "Grep"];
|
|
12695
|
-
},
|
|
12696
|
-
usesPassthrough() {
|
|
12697
|
-
return resolvePassthrough(true);
|
|
12698
|
-
},
|
|
12699
|
-
supportsThinking() {
|
|
12700
|
-
return true;
|
|
12701
|
-
},
|
|
12702
|
-
shouldTrackFileChanges() {
|
|
12703
|
-
return false;
|
|
12704
|
-
},
|
|
12705
|
-
extractFileChangesFromToolUse(toolName, toolInput) {
|
|
12706
|
-
const input = toolInput;
|
|
12707
|
-
const filePath = input?.file_path ?? input?.filePath ?? input?.path;
|
|
12708
|
-
const lowerName = toolName.toLowerCase();
|
|
12709
|
-
if (lowerName === "write" && filePath) {
|
|
12710
|
-
return [{ operation: "wrote", path: String(filePath) }];
|
|
12711
|
-
}
|
|
12712
|
-
if ((lowerName === "edit" || lowerName === "multiedit") && filePath) {
|
|
12713
|
-
return [{ operation: "edited", path: String(filePath) }];
|
|
12714
|
-
}
|
|
12715
|
-
if (lowerName === "bash" && input?.command) {
|
|
12716
|
-
return extractFileChangesFromBash(String(input.command));
|
|
12717
|
-
}
|
|
12718
|
-
return [];
|
|
12719
|
-
}
|
|
12720
|
-
};
|
|
12721
|
-
|
|
12722
12722
|
// src/proxy/adapters/openai.ts
|
|
12723
12723
|
var openAiAdapter = {
|
|
12724
12724
|
...openCodeAdapter,
|
|
@@ -18863,6 +18863,43 @@ var codexTransforms = [
|
|
|
18863
18863
|
}
|
|
18864
18864
|
];
|
|
18865
18865
|
|
|
18866
|
+
// src/proxy/transforms/claudecode.ts
|
|
18867
|
+
init_env();
|
|
18868
|
+
var claudeCodeTransforms = [
|
|
18869
|
+
{
|
|
18870
|
+
name: "claudecode-core",
|
|
18871
|
+
adapters: ["claude-code"],
|
|
18872
|
+
onRequest(ctx) {
|
|
18873
|
+
const extractFileChangesFromToolUse = (toolName, toolInput) => {
|
|
18874
|
+
const input = toolInput;
|
|
18875
|
+
const filePath = input?.file_path ?? input?.filePath ?? input?.path;
|
|
18876
|
+
const lowerName = toolName.toLowerCase();
|
|
18877
|
+
if (lowerName === "write" && filePath) {
|
|
18878
|
+
return [{ operation: "wrote", path: String(filePath) }];
|
|
18879
|
+
}
|
|
18880
|
+
if ((lowerName === "edit" || lowerName === "multiedit") && filePath) {
|
|
18881
|
+
return [{ operation: "edited", path: String(filePath) }];
|
|
18882
|
+
}
|
|
18883
|
+
if (lowerName === "bash" && input?.command) {
|
|
18884
|
+
return extractFileChangesFromBash(String(input.command));
|
|
18885
|
+
}
|
|
18886
|
+
return [];
|
|
18887
|
+
};
|
|
18888
|
+
return {
|
|
18889
|
+
...ctx,
|
|
18890
|
+
blockedTools: BLOCKED_BUILTIN_TOOLS,
|
|
18891
|
+
incompatibleTools: CLAUDE_CODE_ONLY_TOOLS,
|
|
18892
|
+
allowedMcpTools: ALLOWED_MCP_TOOLS,
|
|
18893
|
+
coreToolNames: ["Read", "Write", "Edit", "Bash", "Glob", "Grep"],
|
|
18894
|
+
passthrough: resolvePassthrough(true),
|
|
18895
|
+
supportsThinking: true,
|
|
18896
|
+
shouldTrackFileChanges: false,
|
|
18897
|
+
extractFileChangesFromToolUse
|
|
18898
|
+
};
|
|
18899
|
+
}
|
|
18900
|
+
}
|
|
18901
|
+
];
|
|
18902
|
+
|
|
18866
18903
|
// src/proxy/transforms/registry.ts
|
|
18867
18904
|
var ADAPTER_TRANSFORMS = {
|
|
18868
18905
|
opencode: openCodeTransforms,
|
|
@@ -18872,6 +18909,7 @@ var ADAPTER_TRANSFORMS = {
|
|
|
18872
18909
|
forgecode: forgeCodeTransforms,
|
|
18873
18910
|
passthrough: passthroughTransforms,
|
|
18874
18911
|
cherry: cherryTransforms,
|
|
18912
|
+
"claude-code": claudeCodeTransforms,
|
|
18875
18913
|
openai: openCodeTransforms,
|
|
18876
18914
|
codex: [...openCodeTransforms, ...codexTransforms]
|
|
18877
18915
|
};
|
|
@@ -19173,7 +19211,7 @@ var ORCHESTRATION_TAGS = [
|
|
|
19173
19211
|
];
|
|
19174
19212
|
function tagPatterns(tag) {
|
|
19175
19213
|
return [
|
|
19176
|
-
new RegExp(`<${tag}\\b[^>]
|
|
19214
|
+
new RegExp(`<${tag}\\b[^>]*(?<!\\/)>[\\s\\S]*?<\\/${tag}>`, "gi"),
|
|
19177
19215
|
new RegExp(`<${tag}\\b[^>]*\\/>`, "gi")
|
|
19178
19216
|
];
|
|
19179
19217
|
}
|
|
@@ -19192,6 +19230,16 @@ var ALL_PATTERNS = [
|
|
|
19192
19230
|
];
|
|
19193
19231
|
var SYSTEM_REMINDER_PATTERNS = tagPatterns("system-reminder");
|
|
19194
19232
|
var THINKING_TAG_PATTERNS = tagPatterns("thinking");
|
|
19233
|
+
function sanitizeAssistantText(text) {
|
|
19234
|
+
let result = text;
|
|
19235
|
+
for (const pattern of NON_XML_PATTERNS) {
|
|
19236
|
+
pattern.lastIndex = 0;
|
|
19237
|
+
result = result.replace(pattern, "");
|
|
19238
|
+
}
|
|
19239
|
+
return result.replace(/\n{3,}/g, `
|
|
19240
|
+
|
|
19241
|
+
`).trim();
|
|
19242
|
+
}
|
|
19195
19243
|
function sanitizeTextContent(text, opts = {}) {
|
|
19196
19244
|
let result = text;
|
|
19197
19245
|
const patterns = [...ALL_PATTERNS];
|
|
@@ -19828,10 +19876,10 @@ function normalizeStructuredUserContent(content) {
|
|
|
19828
19876
|
}
|
|
19829
19877
|
function flattenAssistantContent(content) {
|
|
19830
19878
|
if (typeof content === "string")
|
|
19831
|
-
return content;
|
|
19879
|
+
return sanitizeAssistantText(content);
|
|
19832
19880
|
if (!Array.isArray(content))
|
|
19833
19881
|
return String(content ?? "");
|
|
19834
|
-
return content.map((b) => b?.type === "text" && b.text ? b.text : "").filter(Boolean).join(`
|
|
19882
|
+
return content.map((b) => b?.type === "text" && b.text ? sanitizeAssistantText(b.text) : "").filter(Boolean).join(`
|
|
19835
19883
|
`);
|
|
19836
19884
|
}
|
|
19837
19885
|
function flattenUserContent(content, sanitizeOpts = {}, toolIndex) {
|
|
@@ -20241,7 +20289,7 @@ data: ${JSON.stringify(lastError)}
|
|
|
20241
20289
|
const envOverrides = explicitModelPin(requestedModel);
|
|
20242
20290
|
const cwdResolution = resolveSdkWorkingDirectory({
|
|
20243
20291
|
envOverride: process.env.MERIDIAN_WORKDIR ?? process.env.CLAUDE_PROXY_WORKDIR,
|
|
20244
|
-
adapterCwd: adapter.extractWorkingDirectory(body),
|
|
20292
|
+
adapterCwd: adapter.extractWorkingDirectory(body) ?? adapter.extractClientWorkingDirectory?.(body),
|
|
20245
20293
|
fallback: process.cwd()
|
|
20246
20294
|
});
|
|
20247
20295
|
const workingDirectory = cwdResolution.workingDirectory;
|
|
@@ -21198,6 +21246,36 @@ Subprocess stderr: ${stderrOutput}`;
|
|
|
21198
21246
|
const streamedToolUseIds = new Set;
|
|
21199
21247
|
const openClientBlocks = new Set;
|
|
21200
21248
|
const resolvePendingStore = passthrough && earlyStopEnabled && !isIndependentSession && profileSessionId ? registerPendingStore(profileSessionId) : () => {};
|
|
21249
|
+
let pendingEarlyStop = false;
|
|
21250
|
+
let pendingEarlyStopAt = 0;
|
|
21251
|
+
const fireEarlyStop = (reason) => {
|
|
21252
|
+
earlyStopFired = true;
|
|
21253
|
+
claudeLog("passthrough.early_stop", {
|
|
21254
|
+
mode: "stream",
|
|
21255
|
+
captured: capturedToolUses.length,
|
|
21256
|
+
drained: awaitingEarlyStopDrain,
|
|
21257
|
+
reason,
|
|
21258
|
+
deferredMs: pendingEarlyStopAt ? Date.now() - pendingEarlyStopAt : 0
|
|
21259
|
+
});
|
|
21260
|
+
pendingEarlyStop = false;
|
|
21261
|
+
flushOpenClientBlocks("early_stop");
|
|
21262
|
+
safeEnqueue(encoder.encode(`event: message_delta
|
|
21263
|
+
data: ${JSON.stringify({ type: "message_delta", delta: { stop_reason: "tool_use", stop_sequence: null }, usage: { output_tokens: lastUsage?.output_tokens ?? 0 } })}
|
|
21264
|
+
|
|
21265
|
+
`), "early_stop");
|
|
21266
|
+
safeEnqueue(encoder.encode(`event: message_stop
|
|
21267
|
+
data: ${JSON.stringify({ type: "message_stop" })}
|
|
21268
|
+
|
|
21269
|
+
`), "early_stop");
|
|
21270
|
+
requestAbort.abort("passthrough turn complete");
|
|
21271
|
+
awaitingEarlyStopDrain = false;
|
|
21272
|
+
if (!streamClosed) {
|
|
21273
|
+
streamClosed = true;
|
|
21274
|
+
try {
|
|
21275
|
+
controller.close();
|
|
21276
|
+
} catch {}
|
|
21277
|
+
}
|
|
21278
|
+
};
|
|
21201
21279
|
const flushOpenClientBlocks = (source) => {
|
|
21202
21280
|
if (openClientBlocks.size === 0)
|
|
21203
21281
|
return;
|
|
@@ -21512,26 +21590,19 @@ data: ${JSON.stringify({ type: "content_block_stop", index: idx })}
|
|
|
21512
21590
|
} else if (message.type === "user") {
|
|
21513
21591
|
noteUserContent(earlyStop, message.message?.content);
|
|
21514
21592
|
if (shouldEarlyStop(earlyStop) && streamedToolUseIds.size > 0) {
|
|
21515
|
-
|
|
21516
|
-
|
|
21517
|
-
|
|
21518
|
-
|
|
21519
|
-
|
|
21520
|
-
|
|
21521
|
-
|
|
21522
|
-
|
|
21523
|
-
|
|
21524
|
-
|
|
21525
|
-
|
|
21526
|
-
|
|
21527
|
-
awaitingEarlyStopDrain = false;
|
|
21528
|
-
if (!streamClosed) {
|
|
21529
|
-
streamClosed = true;
|
|
21530
|
-
try {
|
|
21531
|
-
controller.close();
|
|
21532
|
-
} catch {}
|
|
21593
|
+
if (openClientBlocks.size > 0) {
|
|
21594
|
+
if (!pendingEarlyStop) {
|
|
21595
|
+
pendingEarlyStop = true;
|
|
21596
|
+
pendingEarlyStopAt = Date.now();
|
|
21597
|
+
claudeLog("passthrough.early_stop_deferred", {
|
|
21598
|
+
openBlocks: openClientBlocks.size,
|
|
21599
|
+
captured: capturedToolUses.length
|
|
21600
|
+
});
|
|
21601
|
+
}
|
|
21602
|
+
} else {
|
|
21603
|
+
fireEarlyStop("immediate");
|
|
21604
|
+
break;
|
|
21533
21605
|
}
|
|
21534
|
-
break;
|
|
21535
21606
|
}
|
|
21536
21607
|
}
|
|
21537
21608
|
}
|
|
@@ -21708,6 +21779,10 @@ data: ${JSON.stringify(event)}
|
|
|
21708
21779
|
const idx = event.index;
|
|
21709
21780
|
if (typeof idx === "number")
|
|
21710
21781
|
openClientBlocks.delete(idx);
|
|
21782
|
+
if (pendingEarlyStop && openClientBlocks.size === 0) {
|
|
21783
|
+
fireEarlyStop("blocks_closed");
|
|
21784
|
+
break;
|
|
21785
|
+
}
|
|
21711
21786
|
}
|
|
21712
21787
|
if (passthrough && eventType === "message_delta" && event.delta?.stop_reason === "tool_use" && streamedToolUseIds.size > 0) {
|
|
21713
21788
|
flushOpenClientBlocks("drain_close");
|
package/dist/cli.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi.d.ts","sourceRoot":"","sources":["../../../src/proxy/adapters/pi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"pi.d.ts","sourceRoot":"","sources":["../../../src/proxy/adapters/pi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AA0C9C,eAAO,MAAM,SAAS,EAAE,YAoJvB,CAAA;AAED,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
package/dist/proxy/sanitize.d.ts
CHANGED
|
@@ -31,5 +31,28 @@ export interface SanitizeOptions {
|
|
|
31
31
|
* Designed to be called on individual content blocks (not concatenated
|
|
32
32
|
* prompt strings) to eliminate cross-block regex matching risk.
|
|
33
33
|
*/
|
|
34
|
+
/**
|
|
35
|
+
* Strip only the branded, harness-generated markers from ASSISTANT text.
|
|
36
|
+
*
|
|
37
|
+
* Assistant content is replayed into the prompt as `[Assistant: …]` context and
|
|
38
|
+
* has never been sanitized — the unimplemented half of #167 (see #724). The
|
|
39
|
+
* concrete leak is Meridian's own doing: `server.ts` appends its "Files
|
|
40
|
+
* changed:" summary onto the assistant's last text block, the client echoes
|
|
41
|
+
* that assistant turn back on the next turn, and the summary replays into the
|
|
42
|
+
* model's context verbatim. `NON_XML_PATTERNS` has carried a pattern for it all
|
|
43
|
+
* along, which could never fire because the sanitizer only ran on user text.
|
|
44
|
+
*
|
|
45
|
+
* Deliberately NOT the XML tag allowlist. Assistant text is model OUTPUT, and a
|
|
46
|
+
* model asked about configuration will legitimately write `<env>…</env>` — so
|
|
47
|
+
* stripping the allowlist here would delete the model's own answer, which is
|
|
48
|
+
* exactly the failure #720 was about. `NON_XML_PATTERNS` is safe because every
|
|
49
|
+
* entry is uniquely branded (Meridian's summary, oh-my-opencode's markers, the
|
|
50
|
+
* background-task marker): no model emits them by accident.
|
|
51
|
+
*
|
|
52
|
+
* `tool_result` content is deliberately left alone too — it is tool-generated
|
|
53
|
+
* and can legitimately contain anything, including text that merely looks like
|
|
54
|
+
* a marker. Corrupting real tool output is worse than replaying a wrapper.
|
|
55
|
+
*/
|
|
56
|
+
export declare function sanitizeAssistantText(text: string): string;
|
|
34
57
|
export declare function sanitizeTextContent(text: string, opts?: SanitizeOptions): string;
|
|
35
58
|
//# sourceMappingURL=sanitize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/proxy/sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;
|
|
1
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/proxy/sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA4GH,MAAM,WAAW,eAAe;IAC9B;oCACgC;IAChC,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B;;8CAE0C;IAC1C,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED;;;;;GAKG;AACH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO1D;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,eAAoB,GAAG,MAAM,CAapF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/proxy/server.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACtE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,CAAA;AAGvD,YAAY,EACV,SAAS,EACT,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,WAAW,GACZ,MAAM,aAAa,CAAA;AAKpB,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAkDnG,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EAEpB,KAAK,aAAa,EAGnB,MAAM,mBAAmB,CAAA;AAI1B,OAAO,EAA+B,iBAAiB,EAAE,mBAAmB,EAAsC,MAAM,iBAAiB,CAAA;AAGzI,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAA;AAChE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,CAAA;AACjD,YAAY,EAAE,aAAa,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/proxy/server.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACtE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,CAAA;AAGvD,YAAY,EACV,SAAS,EACT,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,WAAW,GACZ,MAAM,aAAa,CAAA;AAKpB,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAkDnG,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EAEpB,KAAK,aAAa,EAGnB,MAAM,mBAAmB,CAAA;AAI1B,OAAO,EAA+B,iBAAiB,EAAE,mBAAmB,EAAsC,MAAM,iBAAiB,CAAA;AAGzI,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAA;AAChE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,CAAA;AACjD,YAAY,EAAE,aAAa,EAAE,CAAA;AAqR7B,wBAAgB,iBAAiB,CAAC,MAAM,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,WAAW,CA8kIhF;AAWD,wBAAgB,gCAAgC,IAAI,IAAI,CAavD;AAED,wBAAsB,gBAAgB,CAAC,MAAM,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAmGhG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Transform } from "../transform";
|
|
2
|
+
/**
|
|
3
|
+
* Claude Code transform — supplies the SDK tool config at request time.
|
|
4
|
+
*
|
|
5
|
+
* server.ts reads `pipelineCtx.*`, never the adapter methods, so without an
|
|
6
|
+
* entry here a Claude Code client gets the createRequestContext defaults:
|
|
7
|
+
* `blockedTools: []` and `passthrough: undefined`. That means the SDK
|
|
8
|
+
* subprocess runs the client's task with its own built-in Read/Write/Bash on
|
|
9
|
+
* the proxy host while the client executes the same tool calls locally —
|
|
10
|
+
* every side effect happens twice (#546, same failure mode as OpenCode's).
|
|
11
|
+
*
|
|
12
|
+
* Values mirror claudeCodeAdapter (adapters/claudecode.ts); the parity tests
|
|
13
|
+
* hold the two in sync. Core tool names are PascalCase here — Claude Code's
|
|
14
|
+
* toolkit is Read/Write/Edit/Bash/Glob/Grep, not OpenCode's lowercase names.
|
|
15
|
+
*/
|
|
16
|
+
export declare const claudeCodeTransforms: Transform[];
|
|
17
|
+
//# sourceMappingURL=claudecode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claudecode.d.ts","sourceRoot":"","sources":["../../../src/proxy/transforms/claudecode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAkB,MAAM,cAAc,CAAA;AAK7D;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS,EAsC3C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/proxy/transforms/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/proxy/transforms/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAgC7C,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,SAAS,EAAE,CAE9E"}
|
package/dist/server.js
CHANGED
package/package.json
CHANGED