@kontextmind/kxm 0.7.93 → 0.7.94

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.
@@ -11,7 +11,7 @@
11
11
  "name": "kxm",
12
12
  "source": "./plugins/kxm",
13
13
  "description": "Durable workflows, peer agents, and kxm tui",
14
- "version": "0.7.93",
14
+ "version": "0.7.94",
15
15
  "category": "development",
16
16
  "tags": ["kxm", "multi-agent", "workflows", "mcp"]
17
17
  }
package/README.md CHANGED
@@ -154,7 +154,7 @@ $coordinatorTools = @(
154
154
  "kxm_workflow_get", "kxm_workflow_checkpoint", "kxm_workflow_wait",
155
155
  "kxm_workflow_record", "kxm_improvement_report"
156
156
  ) -join ","
157
- kxm agent worker --name coordinator --project product --model xai/grok-4.6 `
157
+ kxm agent worker --name coordinator --project product --model openrouter/qwen/qwen3-coder-plus `
158
158
  --fallback-models antigravity/gemini-3.1-pro --tools $coordinatorTools `
159
159
  --session-isolation workflow --fresh-start
160
160
  ```
@@ -277,11 +277,13 @@ $coordinatorTools = @(
277
277
  "kxm_workflow_record", "kxm_improvement_report"
278
278
  ) -join ","
279
279
  kxm agent worker --name coordinator --project product `
280
- --model antigravity/claude-sonnet-4-6 `
281
- --fallback-models xai/grok-4.6 --tools $coordinatorTools `
280
+ --model antigravity/gemini-3.8-flash-high `
281
+ --fallback-models openrouter/qwen/qwen3-coder-plus --tools $coordinatorTools `
282
282
  --session-isolation workflow --fresh-start
283
283
  ```
284
284
 
285
+ The worker is Pi-only, so the primary model and every fallback pass the same native-vendor brake as assignment before Pi starts: a model whose vendor has its own harness (Anthropic, OpenAI, xAI, Moonshot, Google, DeepSeek) is refused with `pi_native_impersonation_blocked` whether it is named directly (`xai/…`), through that vendor's own Pi provider (`openai-codex/…`, `kimi-coding/…`, `claude-bridge/…`), or behind an aggregator (`openrouter/x-ai/…`). The one Google exception is the decided `antigravity/gemini-*` route. Which routes are *admitted* is still Tracking's call; the brake only refuses.
286
+
285
287
  With workflow isolation enabled, the hub stamps every internal workflow prompt, callback resume, timeout notification, and authorized peer-evidence request with a canonical `workflowRunId`. Before acknowledging a queued message, the Pi extension compares that hub-owned binding with the active worker scope. A mismatch is left `queued`; the extension atomically requests a route change and shuts down cleanly. Only after the child closes does the supervisor start one replacement Pi RPC child with `--session-dir .kxm/state/pi-sessions/<workerKey>/default` or `.../runs/<runId>`. This gives the stable default work and each `{agent, workflowRunId}` an independent Pi JSONL history without concurrent writers. Correlation IDs alone never select a workflow session. Binding manifests and requests are identity-, supervisor-generation-, child-incarnation-, timestamp-, and schema-checked, and malformed manifests are quarantined before a safe default binding is created.
286
288
 
287
289
  Explicit extension code runs with the worker's repository, network, and model credentials, and skills supply privileged instructions. These are trusted service-administrator settings: never derive them from a webhook or workflow payload. Absolute and parent-relative paths outside `KXM_WORKDIR` are intentionally supported for reviewed provider extensions. Review and protect every configured resource like an executable dependency. A fast `--continue` failure writes a collision-safe `.kxm/state/worker-recovery-<project>-<agent>-<identity>.json` envelope and retries once without `--continue`; the reader can consume an exact-name legacy envelope during migration.
@@ -91,20 +91,20 @@ Use `kxm hub view --json` instead when a machine-readable result is required.
91
91
 
92
92
  ## Real multi-Pi release smoke
93
93
 
94
- The opt-in release smoke requires two distinct models that already pass `pi auth check`. It creates a temporary workspace, launches two real Pi RPC workers, and verifies discovery, request/reply, fanout, durable identity plus a post-restart exchange, journal persistence, checkpoint completion, and cleanup.
94
+ The opt-in release smoke requires two distinct models that already pass `pi auth check`. Both run as long-lived Pi workers, so both must pass the native-vendor brake: a model whose vendor has its own harness (for example `xai/…` or `anthropic/…`) is refused before Pi starts. It creates a temporary workspace, launches two real Pi RPC workers, and verifies discovery, request/reply, fanout, durable identity plus a post-restart exchange, journal persistence, checkpoint completion, and cleanup.
95
95
 
96
96
  PowerShell:
97
97
 
98
98
  ```powershell
99
99
  $env:KXM_SMOKE = "1"
100
- $env:KXM_SMOKE_MODELS = "xai/grok-4.6,anthropic/claude-sonnet-4-5"
100
+ $env:KXM_SMOKE_MODELS = "openrouter/qwen/qwen3-coder-plus,openrouter/z-ai/glm-5.3-flash"
101
101
  node scripts/smoke-multi-pi.mjs
102
102
  ```
103
103
 
104
104
  POSIX shell:
105
105
 
106
106
  ```bash
107
- KXM_SMOKE=1 KXM_SMOKE_MODELS='xai/grok-4.6,anthropic/claude-sonnet-4-5' node scripts/smoke-multi-pi.mjs
107
+ KXM_SMOKE=1 KXM_SMOKE_MODELS='openrouter/qwen/qwen3-coder-plus,openrouter/z-ai/glm-5.3-flash' node scripts/smoke-multi-pi.mjs
108
108
  ```
109
109
 
110
110
  For GitHub Actions, smoke runs on the ARC scale set `kontextmind-doks`. Set
@@ -138,10 +138,14 @@ before starting the workflow:
138
138
  ```powershell
139
139
  $env:KXM_AUTH_TOKEN = "replace-with-the-project-token"
140
140
  kxm agent worker --name coordinator --project provenance-demo --session-isolation workflow
141
- kxm agent worker --name reviewer-claude --project provenance-demo --model anthropic/claude-opus-4-6 --session-isolation workflow
142
- kxm agent worker --name reviewer-grok --project provenance-demo --model xai/grok-4.6 --session-isolation workflow
141
+ kxm agent worker --name reviewer-claude --project provenance-demo --model openrouter/qwen/qwen3-coder-plus --session-isolation workflow
142
+ kxm agent worker --name reviewer-grok --project provenance-demo --model openrouter/z-ai/glm-5.3-flash --session-isolation workflow
143
143
  ```
144
144
 
145
+ The reviewer ids are names, not routes. Workers are Pi, and Pi may not run a model whose
146
+ vendor has its own harness, so these two independent reviewers use admitted Pi routes from
147
+ different vendors rather than Claude and Grok.
148
+
145
149
  In an operator terminal, supply the workflow-start secret and create a run:
146
150
 
147
151
  ```powershell
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kontextmind/kxm",
3
- "version": "0.7.93",
3
+ "version": "0.7.94",
4
4
  "description": "KXM local-first multi-agent orchestration and operator dashboard",
5
5
  "type": "module",
6
6
  "author": "KontextMind",
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json",
3
3
  "name": "kxm",
4
4
  "displayName": "KXM",
5
- "version": "0.7.93",
5
+ "version": "0.7.94",
6
6
  "description": "Headless multi-agent orchestration, durable workflows, and a live operator dashboard for Pi and Claude Code",
7
7
  "author": {
8
8
  "name": "KontextMind",
@@ -21409,6 +21409,23 @@ var PI_NATIVE_BRAKE_PROVIDERS = Object.freeze([
21409
21409
  "google",
21410
21410
  "deepseek"
21411
21411
  ]);
21412
+ var PI_VENDOR_OWNED_PROVIDERS = Object.freeze({
21413
+ "openai-codex": "openai",
21414
+ moonshotai: "moonshot",
21415
+ "moonshotai-cn": "moonshot",
21416
+ "kimi-coding": "moonshot",
21417
+ "google-vertex": "google",
21418
+ // Claude subscription via the Agent SDK: experiment-only, never a product route.
21419
+ "claude-bridge": "anthropic",
21420
+ // The decided Google route, for Gemini ids only (see PI_ANTIGRAVITY_MODEL_ID).
21421
+ antigravity: "google"
21422
+ });
21423
+ var PI_VENDOR_SEGMENT_ALIASES = Object.freeze({
21424
+ "x-ai": "xai",
21425
+ moonshotai: "moonshot",
21426
+ "google-ai": "google"
21427
+ });
21428
+ var PI_ANTIGRAVITY_MODEL_ID = /^gemini-[a-z0-9.-]+$/;
21412
21429
  function reportedModelId(value) {
21413
21430
  return typeof value === "string" && /^[a-z0-9][a-z0-9._:/-]{0,199}$/i.test(value) ? value : void 0;
21414
21431
  }
@@ -22151,19 +22168,25 @@ function validateHarnessModelPair(harnessId, modelSpec) {
22151
22168
  return { valid: true };
22152
22169
  }
22153
22170
  if (harnessId === "pi") {
22154
- if (provider && PI_NATIVE_BRAKE_PROVIDERS.includes(provider)) {
22155
- return {
22156
- valid: false,
22157
- issue: "pi_native_impersonation_blocked",
22158
- message: `pi must not impersonate native provider ${provider}; use the native harness`
22159
- };
22160
- }
22161
- if (!provider && model && PI_NATIVE_BRAKE_PROVIDERS.some((p) => model.toLowerCase().startsWith(`${p}/`))) {
22162
- return {
22163
- valid: false,
22164
- issue: "pi_native_impersonation_blocked",
22165
- message: `pi must not impersonate native model ${model}; use the native harness`
22166
- };
22171
+ if (!provider && model?.includes("/")) {
22172
+ const idx = model.indexOf("/");
22173
+ provider = model.slice(0, idx).toLowerCase();
22174
+ model = model.slice(idx + 1);
22175
+ }
22176
+ if (!provider) return { valid: true };
22177
+ const blocked = (message) => ({ valid: false, issue: "pi_native_impersonation_blocked", message });
22178
+ if (PI_NATIVE_BRAKE_PROVIDERS.includes(provider)) {
22179
+ return blocked(`pi must not impersonate native provider ${provider}; use the native harness`);
22180
+ }
22181
+ if (provider === "antigravity" && model && PI_ANTIGRAVITY_MODEL_ID.test(model)) return { valid: true };
22182
+ const owned = Object.hasOwn(PI_VENDOR_OWNED_PROVIDERS, provider) ? PI_VENDOR_OWNED_PROVIDERS[provider] : void 0;
22183
+ if (owned) {
22184
+ return blocked(`pi provider ${provider} bills native vendor ${owned} for ${model ?? "this model"}; use the native harness`);
22185
+ }
22186
+ const segment = model?.includes("/") ? model.slice(0, model.indexOf("/")).toLowerCase() : void 0;
22187
+ const vendor = segment && Object.hasOwn(PI_VENDOR_SEGMENT_ALIASES, segment) ? PI_VENDOR_SEGMENT_ALIASES[segment] : segment;
22188
+ if (vendor && PI_NATIVE_BRAKE_PROVIDERS.includes(vendor)) {
22189
+ return blocked(`pi must not bill native vendor ${vendor} through ${provider}; use the native harness`);
22167
22190
  }
22168
22191
  return { valid: true };
22169
22192
  }
@@ -26678,8 +26701,8 @@ function generateRoutingReport(records, options = {}) {
26678
26701
  if (a.reworkRate !== b2.reworkRate) {
26679
26702
  return a.reworkRate - b2.reworkRate;
26680
26703
  }
26681
- const aCostUnknown = a.costPerAcceptedUsd === null && a.unknownCostAttempts > 0 && a.meteredCostUsd === 0;
26682
- const bCostUnknown = b2.costPerAcceptedUsd === null && b2.unknownCostAttempts > 0 && b2.meteredCostUsd === 0;
26704
+ const aCostUnknown = a.unknownCostAttempts > 0;
26705
+ const bCostUnknown = b2.unknownCostAttempts > 0;
26683
26706
  if (aCostUnknown && !bCostUnknown) return 1;
26684
26707
  if (!aCostUnknown && bCostUnknown) return -1;
26685
26708
  if (a.costPerAcceptedUsd !== null && b2.costPerAcceptedUsd !== null) {
@@ -710,8 +710,8 @@ function generateRoutingReport(records, options = {}) {
710
710
  if (a.reworkRate !== b.reworkRate) {
711
711
  return a.reworkRate - b.reworkRate;
712
712
  }
713
- const aCostUnknown = a.costPerAcceptedUsd === null && a.unknownCostAttempts > 0 && a.meteredCostUsd === 0;
714
- const bCostUnknown = b.costPerAcceptedUsd === null && b.unknownCostAttempts > 0 && b.meteredCostUsd === 0;
713
+ const aCostUnknown = a.unknownCostAttempts > 0;
714
+ const bCostUnknown = b.unknownCostAttempts > 0;
715
715
  if (aCostUnknown && !bCostUnknown) return 1;
716
716
  if (!aCostUnknown && bCostUnknown) return -1;
717
717
  if (a.costPerAcceptedUsd !== null && b.costPerAcceptedUsd !== null) {
@@ -17285,7 +17285,7 @@ function sessionTokenFixHint(policy) {
17285
17285
  }
17286
17286
 
17287
17287
  // plugins/kxm/src/mcp-server.ts
17288
- var VERSION = "0.7.93";
17288
+ var VERSION = "0.7.94";
17289
17289
  var CONFIGURE_PLUGIN = "/plugin configure kxm@kxm";
17290
17290
  var inbox = /* @__PURE__ */ new Map();
17291
17291
  var notifiedInbox = /* @__PURE__ */ new Set();
@@ -15328,6 +15328,23 @@ var PI_NATIVE_BRAKE_PROVIDERS = Object.freeze([
15328
15328
  "google",
15329
15329
  "deepseek"
15330
15330
  ]);
15331
+ var PI_VENDOR_OWNED_PROVIDERS = Object.freeze({
15332
+ "openai-codex": "openai",
15333
+ moonshotai: "moonshot",
15334
+ "moonshotai-cn": "moonshot",
15335
+ "kimi-coding": "moonshot",
15336
+ "google-vertex": "google",
15337
+ // Claude subscription via the Agent SDK: experiment-only, never a product route.
15338
+ "claude-bridge": "anthropic",
15339
+ // The decided Google route, for Gemini ids only (see PI_ANTIGRAVITY_MODEL_ID).
15340
+ antigravity: "google"
15341
+ });
15342
+ var PI_VENDOR_SEGMENT_ALIASES = Object.freeze({
15343
+ "x-ai": "xai",
15344
+ moonshotai: "moonshot",
15345
+ "google-ai": "google"
15346
+ });
15347
+ var PI_ANTIGRAVITY_MODEL_ID = /^gemini-[a-z0-9.-]+$/;
15331
15348
  function reportedModelId(value) {
15332
15349
  return typeof value === "string" && /^[a-z0-9][a-z0-9._:/-]{0,199}$/i.test(value) ? value : void 0;
15333
15350
  }
@@ -16049,19 +16066,25 @@ function validateHarnessModelPair(harnessId, modelSpec) {
16049
16066
  return { valid: true };
16050
16067
  }
16051
16068
  if (harnessId === "pi") {
16052
- if (provider && PI_NATIVE_BRAKE_PROVIDERS.includes(provider)) {
16053
- return {
16054
- valid: false,
16055
- issue: "pi_native_impersonation_blocked",
16056
- message: `pi must not impersonate native provider ${provider}; use the native harness`
16057
- };
16058
- }
16059
- if (!provider && model && PI_NATIVE_BRAKE_PROVIDERS.some((p) => model.toLowerCase().startsWith(`${p}/`))) {
16060
- return {
16061
- valid: false,
16062
- issue: "pi_native_impersonation_blocked",
16063
- message: `pi must not impersonate native model ${model}; use the native harness`
16064
- };
16069
+ if (!provider && model?.includes("/")) {
16070
+ const idx = model.indexOf("/");
16071
+ provider = model.slice(0, idx).toLowerCase();
16072
+ model = model.slice(idx + 1);
16073
+ }
16074
+ if (!provider) return { valid: true };
16075
+ const blocked = (message) => ({ valid: false, issue: "pi_native_impersonation_blocked", message });
16076
+ if (PI_NATIVE_BRAKE_PROVIDERS.includes(provider)) {
16077
+ return blocked(`pi must not impersonate native provider ${provider}; use the native harness`);
16078
+ }
16079
+ if (provider === "antigravity" && model && PI_ANTIGRAVITY_MODEL_ID.test(model)) return { valid: true };
16080
+ const owned = Object.hasOwn(PI_VENDOR_OWNED_PROVIDERS, provider) ? PI_VENDOR_OWNED_PROVIDERS[provider] : void 0;
16081
+ if (owned) {
16082
+ return blocked(`pi provider ${provider} bills native vendor ${owned} for ${model ?? "this model"}; use the native harness`);
16083
+ }
16084
+ const segment = model?.includes("/") ? model.slice(0, model.indexOf("/")).toLowerCase() : void 0;
16085
+ const vendor = segment && Object.hasOwn(PI_VENDOR_SEGMENT_ALIASES, segment) ? PI_VENDOR_SEGMENT_ALIASES[segment] : segment;
16086
+ if (vendor && PI_NATIVE_BRAKE_PROVIDERS.includes(vendor)) {
16087
+ return blocked(`pi must not bill native vendor ${vendor} through ${provider}; use the native harness`);
16065
16088
  }
16066
16089
  return { valid: true };
16067
16090
  }
@@ -15325,6 +15325,23 @@ var PI_NATIVE_BRAKE_PROVIDERS = Object.freeze([
15325
15325
  "google",
15326
15326
  "deepseek"
15327
15327
  ]);
15328
+ var PI_VENDOR_OWNED_PROVIDERS = Object.freeze({
15329
+ "openai-codex": "openai",
15330
+ moonshotai: "moonshot",
15331
+ "moonshotai-cn": "moonshot",
15332
+ "kimi-coding": "moonshot",
15333
+ "google-vertex": "google",
15334
+ // Claude subscription via the Agent SDK: experiment-only, never a product route.
15335
+ "claude-bridge": "anthropic",
15336
+ // The decided Google route, for Gemini ids only (see PI_ANTIGRAVITY_MODEL_ID).
15337
+ antigravity: "google"
15338
+ });
15339
+ var PI_VENDOR_SEGMENT_ALIASES = Object.freeze({
15340
+ "x-ai": "xai",
15341
+ moonshotai: "moonshot",
15342
+ "google-ai": "google"
15343
+ });
15344
+ var PI_ANTIGRAVITY_MODEL_ID = /^gemini-[a-z0-9.-]+$/;
15328
15345
  function reportedModelId(value) {
15329
15346
  return typeof value === "string" && /^[a-z0-9][a-z0-9._:/-]{0,199}$/i.test(value) ? value : void 0;
15330
15347
  }
@@ -16072,19 +16089,25 @@ function validateHarnessModelPair(harnessId, modelSpec) {
16072
16089
  return { valid: true };
16073
16090
  }
16074
16091
  if (harnessId === "pi") {
16075
- if (provider && PI_NATIVE_BRAKE_PROVIDERS.includes(provider)) {
16076
- return {
16077
- valid: false,
16078
- issue: "pi_native_impersonation_blocked",
16079
- message: `pi must not impersonate native provider ${provider}; use the native harness`
16080
- };
16081
- }
16082
- if (!provider && model && PI_NATIVE_BRAKE_PROVIDERS.some((p) => model.toLowerCase().startsWith(`${p}/`))) {
16083
- return {
16084
- valid: false,
16085
- issue: "pi_native_impersonation_blocked",
16086
- message: `pi must not impersonate native model ${model}; use the native harness`
16087
- };
16092
+ if (!provider && model?.includes("/")) {
16093
+ const idx = model.indexOf("/");
16094
+ provider = model.slice(0, idx).toLowerCase();
16095
+ model = model.slice(idx + 1);
16096
+ }
16097
+ if (!provider) return { valid: true };
16098
+ const blocked = (message) => ({ valid: false, issue: "pi_native_impersonation_blocked", message });
16099
+ if (PI_NATIVE_BRAKE_PROVIDERS.includes(provider)) {
16100
+ return blocked(`pi must not impersonate native provider ${provider}; use the native harness`);
16101
+ }
16102
+ if (provider === "antigravity" && model && PI_ANTIGRAVITY_MODEL_ID.test(model)) return { valid: true };
16103
+ const owned = Object.hasOwn(PI_VENDOR_OWNED_PROVIDERS, provider) ? PI_VENDOR_OWNED_PROVIDERS[provider] : void 0;
16104
+ if (owned) {
16105
+ return blocked(`pi provider ${provider} bills native vendor ${owned} for ${model ?? "this model"}; use the native harness`);
16106
+ }
16107
+ const segment = model?.includes("/") ? model.slice(0, model.indexOf("/")).toLowerCase() : void 0;
16108
+ const vendor = segment && Object.hasOwn(PI_VENDOR_SEGMENT_ALIASES, segment) ? PI_VENDOR_SEGMENT_ALIASES[segment] : segment;
16109
+ if (vendor && PI_NATIVE_BRAKE_PROVIDERS.includes(vendor)) {
16110
+ return blocked(`pi must not bill native vendor ${vendor} through ${provider}; use the native harness`);
16088
16111
  }
16089
16112
  return { valid: true };
16090
16113
  }
@@ -14996,6 +14996,22 @@ var PI_NATIVE_BRAKE_PROVIDERS = Object.freeze([
14996
14996
  "google",
14997
14997
  "deepseek"
14998
14998
  ]);
14999
+ var PI_VENDOR_OWNED_PROVIDERS = Object.freeze({
15000
+ "openai-codex": "openai",
15001
+ moonshotai: "moonshot",
15002
+ "moonshotai-cn": "moonshot",
15003
+ "kimi-coding": "moonshot",
15004
+ "google-vertex": "google",
15005
+ // Claude subscription via the Agent SDK: experiment-only, never a product route.
15006
+ "claude-bridge": "anthropic",
15007
+ // The decided Google route, for Gemini ids only (see PI_ANTIGRAVITY_MODEL_ID).
15008
+ antigravity: "google"
15009
+ });
15010
+ var PI_VENDOR_SEGMENT_ALIASES = Object.freeze({
15011
+ "x-ai": "xai",
15012
+ moonshotai: "moonshot",
15013
+ "google-ai": "google"
15014
+ });
14999
15015
  function reportedModelId(value) {
15000
15016
  return typeof value === "string" && /^[a-z0-9][a-z0-9._:/-]{0,199}$/i.test(value) ? value : void 0;
15001
15017
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-plugin",
3
- "version": "0.7.93",
3
+ "version": "0.7.94",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "engines": {
@@ -126,7 +126,7 @@ export const PI_ALLOWED_PROVIDERS: readonly string[] = Object.freeze([
126
126
  "nous-proxy",
127
127
  ]);
128
128
 
129
- /** Native providers Pi must not impersonate directly unless allowlisted aggregator prefix is used. */
129
+ /** Vendors with a native harness rule. Pi must not run their models under any provider id. */
130
130
  export const PI_NATIVE_BRAKE_PROVIDERS: readonly string[] = Object.freeze([
131
131
  "anthropic",
132
132
  "openai",
@@ -136,6 +136,28 @@ export const PI_NATIVE_BRAKE_PROVIDERS: readonly string[] = Object.freeze([
136
136
  "deepseek",
137
137
  ]);
138
138
 
139
+ /** Pi provider ids that are a braked vendor's own API or subscription under another name. */
140
+ const PI_VENDOR_OWNED_PROVIDERS: Readonly<Record<string, string>> = Object.freeze({
141
+ "openai-codex": "openai",
142
+ moonshotai: "moonshot",
143
+ "moonshotai-cn": "moonshot",
144
+ "kimi-coding": "moonshot",
145
+ "google-vertex": "google",
146
+ // Claude subscription via the Agent SDK: experiment-only, never a product route.
147
+ "claude-bridge": "anthropic",
148
+ // The decided Google route, for Gemini ids only (see PI_ANTIGRAVITY_MODEL_ID).
149
+ antigravity: "google",
150
+ });
151
+
152
+ /** Aggregator spellings of braked vendors in `provider/vendor/model` ids (roster policy aliases). */
153
+ const PI_VENDOR_SEGMENT_ALIASES: Readonly<Record<string, string>> = Object.freeze({
154
+ "x-ai": "xai",
155
+ moonshotai: "moonshot",
156
+ "google-ai": "google",
157
+ });
158
+
159
+ const PI_ANTIGRAVITY_MODEL_ID = /^gemini-[a-z0-9.-]+$/;
160
+
139
161
  export interface HarnessModelSpec {
140
162
  provider?: string | undefined;
141
163
  model?: string | undefined;
@@ -1067,19 +1089,25 @@ export function validateHarnessModelPair(
1067
1089
  }
1068
1090
 
1069
1091
  if (harnessId === "pi") {
1070
- if (provider && PI_NATIVE_BRAKE_PROVIDERS.includes(provider)) {
1071
- return {
1072
- valid: false,
1073
- issue: "pi_native_impersonation_blocked",
1074
- message: `pi must not impersonate native provider ${provider}; use the native harness`,
1075
- };
1092
+ if (!provider && model?.includes("/")) {
1093
+ const idx = model.indexOf("/");
1094
+ provider = model.slice(0, idx).toLowerCase();
1095
+ model = model.slice(idx + 1);
1076
1096
  }
1077
- if (!provider && model && PI_NATIVE_BRAKE_PROVIDERS.some((p) => model!.toLowerCase().startsWith(`${p}/`))) {
1078
- return {
1079
- valid: false,
1080
- issue: "pi_native_impersonation_blocked",
1081
- message: `pi must not impersonate native model ${model}; use the native harness`,
1082
- };
1097
+ if (!provider) return { valid: true };
1098
+ const blocked = (message: string): HarnessModelValidation => ({ valid: false, issue: "pi_native_impersonation_blocked", message });
1099
+ if (PI_NATIVE_BRAKE_PROVIDERS.includes(provider)) {
1100
+ return blocked(`pi must not impersonate native provider ${provider}; use the native harness`);
1101
+ }
1102
+ if (provider === "antigravity" && model && PI_ANTIGRAVITY_MODEL_ID.test(model)) return { valid: true };
1103
+ const owned = Object.hasOwn(PI_VENDOR_OWNED_PROVIDERS, provider) ? PI_VENDOR_OWNED_PROVIDERS[provider] : undefined;
1104
+ if (owned) {
1105
+ return blocked(`pi provider ${provider} bills native vendor ${owned} for ${model ?? "this model"}; use the native harness`);
1106
+ }
1107
+ const segment = model?.includes("/") ? model.slice(0, model.indexOf("/")).toLowerCase() : undefined;
1108
+ const vendor = segment && Object.hasOwn(PI_VENDOR_SEGMENT_ALIASES, segment) ? PI_VENDOR_SEGMENT_ALIASES[segment] : segment;
1109
+ if (vendor && PI_NATIVE_BRAKE_PROVIDERS.includes(vendor)) {
1110
+ return blocked(`pi must not bill native vendor ${vendor} through ${provider}; use the native harness`);
1083
1111
  }
1084
1112
  return { valid: true };
1085
1113
  }
@@ -11,7 +11,7 @@ import { deliverInboxNotification } from "./inbox.ts";
11
11
  import type { HubEvent, MessageRecord } from "./protocol.ts";
12
12
  import { sessionTokenFixHint } from "./session-token-hint.ts";
13
13
 
14
- const VERSION = "0.7.93";
14
+ const VERSION = "0.7.94";
15
15
  const CONFIGURE_PLUGIN = "/plugin configure kxm@kxm";
16
16
  const inbox = new Map<string, MessageRecord>();
17
17
  const notifiedInbox = new Set<string>();
@@ -817,9 +817,10 @@ export function generateRoutingReport(
817
817
  return a.reworkRate - b.reworkRate;
818
818
  }
819
819
 
820
- // 2. Cost: unknown is never ranked cheapest
821
- const aCostUnknown = a.costPerAcceptedUsd === null && a.unknownCostAttempts > 0 && a.meteredCostUsd === 0;
822
- const bCostUnknown = b.costPerAcceptedUsd === null && b.unknownCostAttempts > 0 && b.meteredCostUsd === 0;
820
+ // 2. Cost: unknown is never ranked cheapest. Any unknown-cost attempt makes the
821
+ // route's cost a lower bound (unmetered or metered attempts beside it do not price it).
822
+ const aCostUnknown = a.unknownCostAttempts > 0;
823
+ const bCostUnknown = b.unknownCostAttempts > 0;
823
824
  if (aCostUnknown && !bCostUnknown) return 1;
824
825
  if (!aCostUnknown && bCostUnknown) return -1;
825
826
 
@@ -78,6 +78,9 @@ export const PI_ALLOWED_PROVIDERS = Object.freeze(["openrouter", "nous-portal",
78
78
  /** Native-vendor Pi providers own one braked vendor. Aggregators are not listed here. */
79
79
  export const PI_NATIVE_VENDOR_PROVIDERS = Object.freeze({ antigravity: "google" });
80
80
 
81
+ /** Aggregator spellings of braked vendors in `provider/vendor/model` ids (roster policy aliases). */
82
+ const PI_VENDOR_SEGMENT_ALIASES = Object.freeze({ "x-ai": "xai", moonshotai: "moonshot", "google-ai": "google" });
83
+
81
84
  /** Gemini kebab ids for antigravity two-segment models (`antigravity/gemini-...`). */
82
85
  export const PI_ANTIGRAVITY_MODEL_ID = /^gemini-[a-z0-9.-]+$/;
83
86
 
@@ -1551,6 +1554,11 @@ export function preflightRequest(request) {
1551
1554
  if (request.role === "writer" && (request.model !== PI_ADMITTED_WRITER || request.permission !== "edit")) {
1552
1555
  throw failClosed("pi writer refuses unsupported route; allows only authenticated openrouter/qwen/qwen3-coder-plus with edit permission; other models need reviewed route admission");
1553
1556
  }
1557
+ const segment = piProviderOf(piModelId(request.model));
1558
+ const vendor = segment && Object.hasOwn(PI_VENDOR_SEGMENT_ALIASES, segment) ? PI_VENDOR_SEGMENT_ALIASES[segment] : segment;
1559
+ if (vendor && NATIVE_PI_BRAKE_PROVIDERS.includes(vendor)) {
1560
+ throw failClosed(`pi brake: ${vendor} has a native harness; refusing to bill it through ${provider}`);
1561
+ }
1554
1562
  }
1555
1563
  if (harness === "claude") {
1556
1564
  if (request.hooks === true) {
@@ -4,6 +4,7 @@ import { createHash, randomUUID } from "node:crypto";
4
4
  import { closeSync, createWriteStream, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
5
5
  import { delimiter, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
6
6
  import { StringDecoder } from "node:string_decoder";
7
+ import { validateHarnessModelPair } from "../plugins/kxm/dist/runtime.js";
7
8
 
8
9
  const name = process.env.KXM_AGENT_NAME?.trim();
9
10
  const project = process.env.KXM_PROJECT?.trim();
@@ -36,6 +37,12 @@ const modelCandidates = [...new Set([
36
37
  ...(primaryModel ? [validateModelSelector(primaryModel, "KXM_WORKER_MODEL")] : []),
37
38
  ...fallbackModels,
38
39
  ])];
40
+ // The worker is Pi-only, so every candidate — fallbacks included — passes the native-vendor
41
+ // brake before Pi can bill a vendor whose own harness must run it.
42
+ for (const selector of modelCandidates) {
43
+ const brake = validateHarnessModelPair("pi", selector);
44
+ if (!brake.valid) throw new Error(`${brake.issue}: ${brake.message}`);
45
+ }
39
46
  let modelIndex = 0;
40
47
 
41
48
  function resolveToolAllowlist() {