@rynfar/meridian 1.34.0 → 1.34.1

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.
@@ -8109,6 +8109,9 @@ var piAdapter = {
8109
8109
  buildSdkAgents(_body, _mcpToolNames) {
8110
8110
  return {};
8111
8111
  },
8112
+ supportsThinking() {
8113
+ return true;
8114
+ },
8112
8115
  buildSdkHooks(_body, _sdkAgents) {
8113
8116
  return;
8114
8117
  },
@@ -14126,6 +14129,49 @@ function formatUsageSummary(usage) {
14126
14129
  return `${parts.join(" ")}${cacheTag}`;
14127
14130
  }
14128
14131
 
14132
+ // src/proxy/sanitize.ts
14133
+ var ORCHESTRATION_TAGS = [
14134
+ "system-reminder",
14135
+ "env",
14136
+ "system_information",
14137
+ "current_working_directory",
14138
+ "operating_system",
14139
+ "default_shell",
14140
+ "home_directory",
14141
+ "task_metadata",
14142
+ "tool_exec",
14143
+ "tool_output",
14144
+ "skill_content",
14145
+ "skill_files",
14146
+ "directories",
14147
+ "available_skills",
14148
+ "thinking"
14149
+ ];
14150
+ var PAIRED_TAG_PATTERNS = ORCHESTRATION_TAGS.map((tag) => new RegExp(`<${tag}\\b[^>]*>[\\s\\S]*?<\\/${tag}>`, "gi"));
14151
+ var SELF_CLOSING_TAG_PATTERNS = ORCHESTRATION_TAGS.map((tag) => new RegExp(`<${tag}\\b[^>]*\\/>`, "gi"));
14152
+ var NON_XML_PATTERNS = [
14153
+ /<!--\s*OMO_INTERNAL_INITIATOR\s*-->/gi,
14154
+ /\[SYSTEM DIRECTIVE: OH-MY-OPENCODE[^\]]*\]/gi,
14155
+ /⚙\s*background_output\s*\[task_id=[^\]]*\]\n?/g,
14156
+ /\n?---\nFiles changed:[^\n]*(?:\n(?: [-•*] [^\n]*))*\n?/g
14157
+ ];
14158
+ var ALL_PATTERNS = [
14159
+ ...PAIRED_TAG_PATTERNS,
14160
+ ...SELF_CLOSING_TAG_PATTERNS,
14161
+ ...NON_XML_PATTERNS
14162
+ ];
14163
+ function sanitizeTextContent(text) {
14164
+ let result = text;
14165
+ for (const pattern of ALL_PATTERNS) {
14166
+ pattern.lastIndex = 0;
14167
+ result = result.replace(pattern, "");
14168
+ }
14169
+ result = result.replace(/\n{3,}/g, `
14170
+
14171
+ `);
14172
+ return result.trim();
14173
+ }
14174
+
14129
14175
  // src/proxy/session/lineage.ts
14130
14176
  import { createHash as createHash2 } from "crypto";
14131
14177
  var MIN_SUFFIX_FOR_COMPACTION = 2;
@@ -14777,11 +14823,11 @@ function buildFreshPrompt(messages, stripCacheControl) {
14777
14823
  const role = m.role === "assistant" ? "Assistant" : "Human";
14778
14824
  let content;
14779
14825
  if (typeof m.content === "string") {
14780
- content = m.content;
14826
+ content = sanitizeTextContent(m.content);
14781
14827
  } else if (Array.isArray(m.content)) {
14782
14828
  content = m.content.map((block) => {
14783
14829
  if (block.type === "text" && block.text)
14784
- return block.text;
14830
+ return sanitizeTextContent(block.text);
14785
14831
  if (block.type === "tool_use")
14786
14832
  return `[Tool Use: ${block.name}(${JSON.stringify(block.input)})]`;
14787
14833
  if (block.type === "tool_result")
@@ -15081,11 +15127,11 @@ function createProxyServer(config = {}) {
15081
15127
  const role = m.role === "assistant" ? "Assistant" : "Human";
15082
15128
  let content;
15083
15129
  if (typeof m.content === "string") {
15084
- content = m.content;
15130
+ content = sanitizeTextContent(m.content);
15085
15131
  } else if (Array.isArray(m.content)) {
15086
15132
  content = m.content.map((block) => {
15087
15133
  if (block.type === "text" && block.text)
15088
- return block.text;
15134
+ return sanitizeTextContent(block.text);
15089
15135
  if (block.type === "tool_use")
15090
15136
  return `[Tool Use: ${block.name}(${JSON.stringify(block.input)})]`;
15091
15137
  if (block.type === "tool_result")
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  startProxyServer
4
- } from "./cli-1qv75efv.js";
4
+ } from "./cli-bwchvbfb.js";
5
5
  import"./cli-g9ypdz51.js";
6
6
  import"./cli-rtab0qa6.js";
7
7
  import"./cli-m9pfb7h9.js";
@@ -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;AAwC9C,eAAO,MAAM,SAAS,EAAE,YA+FvB,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;AAwC9C,eAAO,MAAM,SAAS,EAAE,YAsGvB,CAAA"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Per-block content sanitizer for orchestration wrapper leakage.
3
+ *
4
+ * Agent harnesses (OpenCode, Droid, ForgeCode, oh-my-opencode, etc.) inject
5
+ * internal markup into message content — `<system-reminder>`, `<env>`,
6
+ * `<task_metadata>`, and similar tags. When the proxy flattens messages into
7
+ * a text prompt for the Agent SDK, these tags become model-visible text that
8
+ * can confuse the model or cause it to echo them back ("talking to itself").
9
+ *
10
+ * This module strips known orchestration tags from **individual text blocks**
11
+ * before flattening — not from the final concatenated string. Operating
12
+ * per-block eliminates the cross-message regex risk that makes full-string
13
+ * sanitization fragile.
14
+ *
15
+ * Pure module — no I/O, no imports from server.ts or session/.
16
+ *
17
+ * Fixes: https://github.com/rynfar/meridian/issues/167
18
+ */
19
+ /**
20
+ * Strip orchestration wrappers from a single text string.
21
+ *
22
+ * Designed to be called on individual content blocks (not concatenated
23
+ * prompt strings) to eliminate cross-block regex matching risk.
24
+ */
25
+ export declare function sanitizeTextContent(text: string): string;
26
+ //# sourceMappingURL=sanitize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/proxy/sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA6DH;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAUxD"}
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/proxy/server.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACtE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,CAAA;AAwBvD,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACpB,KAAK,aAAa,EAEnB,MAAM,mBAAmB,CAAA;AAG1B,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;AAkJ7B,wBAAgB,iBAAiB,CAAC,MAAM,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,WAAW,CAqwDhF;AAED,wBAAsB,gBAAgB,CAAC,MAAM,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAiEhG"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/proxy/server.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACtE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,CAAA;AAyBvD,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACpB,KAAK,aAAa,EAEnB,MAAM,mBAAmB,CAAA;AAG1B,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;AAkJ7B,wBAAgB,iBAAiB,CAAC,MAAM,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,WAAW,CAwwDhF;AAED,wBAAsB,gBAAgB,CAAC,MAAM,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAiEhG"}
package/dist/server.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  getMaxSessionsLimit,
7
7
  hashMessage,
8
8
  startProxyServer
9
- } from "./cli-1qv75efv.js";
9
+ } from "./cli-bwchvbfb.js";
10
10
  import"./cli-g9ypdz51.js";
11
11
  import"./cli-rtab0qa6.js";
12
12
  import"./cli-m9pfb7h9.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rynfar/meridian",
3
- "version": "1.34.0",
3
+ "version": "1.34.1",
4
4
  "description": "Local Anthropic API powered by your Claude Max subscription. One subscription, every agent.",
5
5
  "type": "module",
6
6
  "main": "./dist/server.js",
@@ -44,9 +44,12 @@ const MeridianPlugin: Plugin = async () => {
44
44
  output.headers["x-opencode-agent-mode"] = typeof agent === "object"
45
45
  ? (agent.mode ?? "primary")
46
46
  : "primary"
47
- output.headers["x-opencode-agent-name"] = typeof agent === "object"
47
+ const rawName = typeof agent === "object"
48
48
  ? (agent.name ?? "unknown")
49
49
  : String(agent)
50
+ // Strip non-ASCII characters (e.g. zero-width spaces) that cause
51
+ // "Header has invalid value" errors in Node.js / undici.
52
+ output.headers["x-opencode-agent-name"] = rawName.replace(/[^\x20-\x7E]/g, "").trim() || "unknown"
50
53
  },
51
54
  }
52
55
  }