dsh-harness-reflex 0.1.0 → 0.3.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.
Files changed (124) hide show
  1. package/README.md +20 -6
  2. package/client.js +3511 -185
  3. package/dist/attribution.d.ts +266 -0
  4. package/dist/attribution.js +238 -0
  5. package/dist/attribution.js.map +1 -0
  6. package/dist/bridge.d.ts +311 -13
  7. package/dist/bridge.js +714 -42
  8. package/dist/bridge.js.map +1 -1
  9. package/dist/client-bundle.js +4 -1
  10. package/dist/client-bundle.js.map +1 -1
  11. package/dist/command.js +10 -0
  12. package/dist/command.js.map +1 -1
  13. package/dist/config.d.ts +530 -22
  14. package/dist/config.js +808 -27
  15. package/dist/config.js.map +1 -1
  16. package/dist/delegation-dispatch.d.ts +132 -0
  17. package/dist/delegation-dispatch.js +186 -0
  18. package/dist/delegation-dispatch.js.map +1 -0
  19. package/dist/delegation-health.d.ts +131 -0
  20. package/dist/delegation-health.js +97 -0
  21. package/dist/delegation-health.js.map +1 -0
  22. package/dist/delegation.d.ts +148 -0
  23. package/dist/delegation.js +186 -0
  24. package/dist/delegation.js.map +1 -0
  25. package/dist/effort-delegation.d.ts +144 -0
  26. package/dist/effort-delegation.js +280 -0
  27. package/dist/effort-delegation.js.map +1 -0
  28. package/dist/effort.d.ts +141 -0
  29. package/dist/effort.js +251 -9
  30. package/dist/effort.js.map +1 -1
  31. package/dist/host-patch.d.ts +156 -0
  32. package/dist/host-patch.js +534 -0
  33. package/dist/host-patch.js.map +1 -0
  34. package/dist/index.d.ts +12 -3
  35. package/dist/index.js +99 -7
  36. package/dist/index.js.map +1 -1
  37. package/dist/interventions.d.ts +98 -373
  38. package/dist/interventions.js +442 -1702
  39. package/dist/interventions.js.map +1 -1
  40. package/dist/panel-api.d.ts +328 -4
  41. package/dist/panel-api.js +322 -15
  42. package/dist/panel-api.js.map +1 -1
  43. package/dist/panel-mount.d.ts +81 -22
  44. package/dist/panel-mount.js +228 -7
  45. package/dist/panel-mount.js.map +1 -1
  46. package/dist/routing.d.ts +23 -18
  47. package/dist/routing.js +471 -153
  48. package/dist/routing.js.map +1 -1
  49. package/dist/session-audit.d.ts +70 -0
  50. package/dist/session-audit.js +73 -0
  51. package/dist/session-audit.js.map +1 -1
  52. package/dist/systemone-probe.d.ts +114 -0
  53. package/dist/systemone-probe.js +383 -0
  54. package/dist/systemone-probe.js.map +1 -0
  55. package/dist/testing.d.ts +212 -7
  56. package/dist/testing.js +333 -27
  57. package/dist/testing.js.map +1 -1
  58. package/dist/tools.d.ts +109 -3
  59. package/dist/tools.js +103 -4
  60. package/dist/tools.js.map +1 -1
  61. package/dist/unconfigured-backend.d.ts +72 -0
  62. package/dist/unconfigured-backend.js +94 -0
  63. package/dist/unconfigured-backend.js.map +1 -0
  64. package/dist/vendor/harness-reflex/backend/factory.d.ts +31 -1
  65. package/dist/vendor/harness-reflex/backend/factory.js +18 -3
  66. package/dist/vendor/harness-reflex/backend/factory.js.map +1 -1
  67. package/dist/vendor/harness-reflex/backend/jev.d.ts +20 -0
  68. package/dist/vendor/harness-reflex/backend/jev.js +11 -4
  69. package/dist/vendor/harness-reflex/backend/jev.js.map +1 -1
  70. package/dist/vendor/harness-reflex/backend/simple-jev.d.ts +16 -0
  71. package/dist/vendor/harness-reflex/backend/simple-jev.js +17 -6
  72. package/dist/vendor/harness-reflex/backend/simple-jev.js.map +1 -1
  73. package/dist/vendor/harness-reflex/core/closing.d.ts +90 -0
  74. package/dist/vendor/harness-reflex/core/closing.js +111 -0
  75. package/dist/vendor/harness-reflex/core/closing.js.map +1 -0
  76. package/dist/vendor/harness-reflex/core/evidence.d.ts +119 -0
  77. package/dist/vendor/harness-reflex/core/evidence.js +209 -0
  78. package/dist/vendor/harness-reflex/core/evidence.js.map +1 -0
  79. package/dist/vendor/harness-reflex/core/judge.d.ts +221 -0
  80. package/dist/vendor/harness-reflex/core/judge.js +251 -0
  81. package/dist/vendor/harness-reflex/core/judge.js.map +1 -0
  82. package/dist/vendor/harness-reflex/core/orchestrate-closing.d.ts +237 -0
  83. package/dist/vendor/harness-reflex/core/orchestrate-closing.js +250 -0
  84. package/dist/vendor/harness-reflex/core/orchestrate-closing.js.map +1 -0
  85. package/dist/vendor/harness-reflex/core/orchestrate-correction.d.ts +209 -0
  86. package/dist/vendor/harness-reflex/core/orchestrate-correction.js +141 -0
  87. package/dist/vendor/harness-reflex/core/orchestrate-correction.js.map +1 -0
  88. package/dist/vendor/harness-reflex/core/orchestrate-host.d.ts +225 -0
  89. package/dist/vendor/harness-reflex/core/orchestrate-host.js +80 -0
  90. package/dist/vendor/harness-reflex/core/orchestrate-host.js.map +1 -0
  91. package/dist/vendor/harness-reflex/core/orchestrate-stagnation.d.ts +259 -0
  92. package/dist/vendor/harness-reflex/core/orchestrate-stagnation.js +270 -0
  93. package/dist/vendor/harness-reflex/core/orchestrate-stagnation.js.map +1 -0
  94. package/dist/vendor/harness-reflex/core/orchestrate.d.ts +357 -0
  95. package/dist/vendor/harness-reflex/core/orchestrate.js +418 -0
  96. package/dist/vendor/harness-reflex/core/orchestrate.js.map +1 -0
  97. package/dist/vendor/harness-reflex/core/policy.d.ts +122 -0
  98. package/dist/vendor/harness-reflex/core/policy.js +102 -0
  99. package/dist/vendor/harness-reflex/core/policy.js.map +1 -0
  100. package/dist/vendor/harness-reflex/core/prune-plan.d.ts +141 -0
  101. package/dist/vendor/harness-reflex/core/prune-plan.js +390 -0
  102. package/dist/vendor/harness-reflex/core/prune-plan.js.map +1 -0
  103. package/dist/vendor/harness-reflex/core/text.d.ts +36 -0
  104. package/dist/vendor/harness-reflex/core/text.js +66 -0
  105. package/dist/vendor/harness-reflex/core/text.js.map +1 -0
  106. package/dist/vendor/harness-reflex/ports/audit.d.ts +18 -0
  107. package/dist/vendor/harness-reflex/ports/audit.js +11 -0
  108. package/dist/vendor/harness-reflex/ports/audit.js.map +1 -0
  109. package/dist/vendor/harness-reflex/ports/clock.d.ts +14 -0
  110. package/dist/vendor/harness-reflex/ports/clock.js +11 -0
  111. package/dist/vendor/harness-reflex/ports/clock.js.map +1 -0
  112. package/dist/vendor/harness-reflex/ports/decision.d.ts +75 -0
  113. package/dist/vendor/harness-reflex/ports/decision.js +2 -0
  114. package/dist/vendor/harness-reflex/ports/decision.js.map +1 -0
  115. package/dist/vendor/harness-reflex/ports/index.d.ts +14 -0
  116. package/dist/vendor/harness-reflex/ports/index.js +2 -0
  117. package/dist/vendor/harness-reflex/ports/index.js.map +1 -0
  118. package/dist/vendor/harness-reflex/ports/log.d.ts +22 -0
  119. package/dist/vendor/harness-reflex/ports/log.js +12 -0
  120. package/dist/vendor/harness-reflex/ports/log.js.map +1 -0
  121. package/dist/vendor/harness-reflex/ports/state.d.ts +46 -0
  122. package/dist/vendor/harness-reflex/ports/state.js +13 -0
  123. package/dist/vendor/harness-reflex/ports/state.js.map +1 -0
  124. package/package.json +25 -13
@@ -1,4 +1,29 @@
1
1
  import { SystemOneBackend } from './types.js';
2
+ /**
3
+ * A credential the caller has already resolved (g-059).
4
+ *
5
+ * The plugin resolves the key exactly once, through
6
+ * `resolveApiKeyWithSource`, so that the panel and the transport can never
7
+ * disagree. Passing the outcome here keeps the factory's *provider selection*
8
+ * (which still reads the environment) while removing its *key lookup* from the
9
+ * decision: without the override, an empty `SYSTEM_ONE_API_KEY` would make the
10
+ * Jev branch read `JEV_API_KEY` behind the caller's back.
11
+ *
12
+ * **Plugin-only extension.** The vendored backends are a manual port verified by
13
+ * behaviour (`vendor-contract.test.ts`), not a generated mirror; the root
14
+ * factory has no such parameter and is not changed by this goal. Consolidating
15
+ * the two copies is g-060.
16
+ */
17
+ export interface ResolvedKeyOverride {
18
+ /**
19
+ * The caller resolved the credential: `apiKey` is used verbatim — including
20
+ * "absent", which means no credential at all. The constructed backend then
21
+ * never consults the environment for a key.
22
+ */
23
+ apiKeyResolved?: boolean;
24
+ /** The resolved key; empty or omitted means there is none. */
25
+ apiKey?: string;
26
+ }
2
27
  /**
3
28
  * Factory to create System One Decision Backend
4
29
  *
@@ -6,6 +31,11 @@ import { SystemOneBackend } from './types.js';
6
31
  * - 'jev': Official Jev System One Gateway
7
32
  * - 'vllm' / 'simple-jev' / 'logits': Next-token logits scoring on standard LLMs
8
33
  * - 'mock' / 'heuristic': Fast deterministic local baseline
34
+ *
35
+ * @param override - a credential the caller already resolved. Omitted (the MCP
36
+ * server, the CLI, a bare import) the factory behaves exactly as before and
37
+ * reads the key from the environment itself.
38
+ * @returns the provider the environment selects.
9
39
  */
10
- export declare function createSystemOneBackend(): SystemOneBackend;
40
+ export declare function createSystemOneBackend(override?: ResolvedKeyOverride): SystemOneBackend;
11
41
  export declare const createDecisionBackend: typeof createSystemOneBackend;
@@ -8,15 +8,30 @@ import { SimpleJevDecisionBackend } from './simple-jev.js';
8
8
  * - 'jev': Official Jev System One Gateway
9
9
  * - 'vllm' / 'simple-jev' / 'logits': Next-token logits scoring on standard LLMs
10
10
  * - 'mock' / 'heuristic': Fast deterministic local baseline
11
+ *
12
+ * @param override - a credential the caller already resolved. Omitted (the MCP
13
+ * server, the CLI, a bare import) the factory behaves exactly as before and
14
+ * reads the key from the environment itself.
15
+ * @returns the provider the environment selects.
11
16
  */
12
- export function createSystemOneBackend() {
17
+ export function createSystemOneBackend(override) {
13
18
  const backendType = (process.env.SYSTEM_ONE_BACKEND ||
14
19
  process.env.REFLEX_BACKEND ||
15
20
  '').toLowerCase();
21
+ // Provider *selection* is deliberately untouched by the override: which
22
+ // backend to build is a deployment question, and only the credential changes.
23
+ const keyFor = (envChain) => override?.apiKeyResolved === true
24
+ ? // Verbatim, empty included: `apiKeyResolved` on the backend class makes
25
+ // an empty value final, so no environment read can resurrect a key the
26
+ // caller decided not to send.
27
+ { apiKey: override.apiKey ?? '', apiKeyResolved: true }
28
+ : envChain === undefined
29
+ ? {}
30
+ : { apiKey: envChain };
16
31
  // 1. Jev Provider
17
32
  if (backendType === 'jev' || (!backendType && (process.env.SYSTEM_ONE_API_KEY || process.env.JEV_API_KEY))) {
18
33
  return new JevDecisionBackend({
19
- apiKey: process.env.SYSTEM_ONE_API_KEY || process.env.JEV_API_KEY,
34
+ ...keyFor(process.env.SYSTEM_ONE_API_KEY || process.env.JEV_API_KEY),
20
35
  baseUrl: process.env.SYSTEM_ONE_BASE_URL || process.env.JEV_BASE_URL,
21
36
  model: process.env.SYSTEM_ONE_MODEL || process.env.JEV_MODEL
22
37
  });
@@ -28,7 +43,7 @@ export function createSystemOneBackend() {
28
43
  (!backendType && (process.env.VLLM_BASE_URL || process.env.OPENAI_BASE_URL))) {
29
44
  return new SimpleJevDecisionBackend({
30
45
  vllmBaseUrl: process.env.SYSTEM_ONE_BASE_URL || process.env.VLLM_BASE_URL,
31
- apiKey: process.env.SYSTEM_ONE_API_KEY || process.env.VLLM_API_KEY,
46
+ ...keyFor(process.env.SYSTEM_ONE_API_KEY || process.env.VLLM_API_KEY),
32
47
  model: process.env.SYSTEM_ONE_MODEL || process.env.VLLM_MODEL
33
48
  });
34
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../src/vendor/harness-reflex/backend/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE3D;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB;IACpC,MAAM,WAAW,GAAG,CAClB,OAAO,CAAC,GAAG,CAAC,kBAAkB;QAC9B,OAAO,CAAC,GAAG,CAAC,cAAc;QAC1B,EAAE,CACH,CAAC,WAAW,EAAE,CAAC;IAEhB,kBAAkB;IAClB,IAAI,WAAW,KAAK,KAAK,IAAI,CAAC,CAAC,WAAW,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;QAC3G,OAAO,IAAI,kBAAkB,CAAC;YAC5B,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW;YACjE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY;YACpE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS;SAC7D,CAAC,CAAC;IACL,CAAC;IAED,gDAAgD;IAChD,IACE,WAAW,KAAK,MAAM;QACtB,WAAW,KAAK,YAAY;QAC5B,WAAW,KAAK,QAAQ;QACxB,CAAC,CAAC,WAAW,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,EAC5E,CAAC;QACD,OAAO,IAAI,wBAAwB,CAAC;YAClC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa;YACzE,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY;YAClE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU;SAC9D,CAAC,CAAC;IACL,CAAC;IAED,8CAA8C;IAC9C,OAAO,IAAI,mBAAmB,EAAE,CAAC;AACnC,CAAC;AAED,4BAA4B;AAC5B,MAAM,CAAC,MAAM,qBAAqB,GAAG,sBAAsB,CAAC","sourcesContent":["import { DecisionBackend, SystemOneBackend } from './types.js';\nimport { MockDecisionBackend } from './mock.js';\nimport { JevDecisionBackend } from './jev.js';\nimport { SimpleJevDecisionBackend } from './simple-jev.js';\n\n/**\n * Factory to create System One Decision Backend\n *\n * Supported providers:\n * - 'jev': Official Jev System One Gateway\n * - 'vllm' / 'simple-jev' / 'logits': Next-token logits scoring on standard LLMs\n * - 'mock' / 'heuristic': Fast deterministic local baseline\n */\nexport function createSystemOneBackend(): SystemOneBackend {\n const backendType = (\n process.env.SYSTEM_ONE_BACKEND ||\n process.env.REFLEX_BACKEND ||\n ''\n ).toLowerCase();\n\n // 1. Jev Provider\n if (backendType === 'jev' || (!backendType && (process.env.SYSTEM_ONE_API_KEY || process.env.JEV_API_KEY))) {\n return new JevDecisionBackend({\n apiKey: process.env.SYSTEM_ONE_API_KEY || process.env.JEV_API_KEY,\n baseUrl: process.env.SYSTEM_ONE_BASE_URL || process.env.JEV_BASE_URL,\n model: process.env.SYSTEM_ONE_MODEL || process.env.JEV_MODEL\n });\n }\n\n // 2. Open LLM / vLLM Next-Token Logits Provider\n if (\n backendType === 'vllm' ||\n backendType === 'simple-jev' ||\n backendType === 'logits' ||\n (!backendType && (process.env.VLLM_BASE_URL || process.env.OPENAI_BASE_URL))\n ) {\n return new SimpleJevDecisionBackend({\n vllmBaseUrl: process.env.SYSTEM_ONE_BASE_URL || process.env.VLLM_BASE_URL,\n apiKey: process.env.SYSTEM_ONE_API_KEY || process.env.VLLM_API_KEY,\n model: process.env.SYSTEM_ONE_MODEL || process.env.VLLM_MODEL\n });\n }\n\n // 3. Default: Local Mock / Heuristic Provider\n return new MockDecisionBackend();\n}\n\n// Backward-compatible alias\nexport const createDecisionBackend = createSystemOneBackend;\n"]}
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../src/vendor/harness-reflex/backend/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AA4B3D;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAA8B;IACnE,MAAM,WAAW,GAAG,CAClB,OAAO,CAAC,GAAG,CAAC,kBAAkB;QAC9B,OAAO,CAAC,GAAG,CAAC,cAAc;QAC1B,EAAE,CACH,CAAC,WAAW,EAAE,CAAC;IAEhB,wEAAwE;IACxE,8EAA8E;IAC9E,MAAM,MAAM,GAAG,CAAC,QAA4B,EAAiD,EAAE,CAC7F,QAAQ,EAAE,cAAc,KAAK,IAAI;QAC/B,CAAC,CAAC,wEAAwE;YACxE,uEAAuE;YACvE,8BAA8B;YAC9B,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,IAAI,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE;QACzD,CAAC,CAAC,QAAQ,KAAK,SAAS;YACtB,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IAE7B,kBAAkB;IAClB,IAAI,WAAW,KAAK,KAAK,IAAI,CAAC,CAAC,WAAW,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;QAC3G,OAAO,IAAI,kBAAkB,CAAC;YAC5B,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;YACpE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY;YACpE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS;SAC7D,CAAC,CAAC;IACL,CAAC;IAED,gDAAgD;IAChD,IACE,WAAW,KAAK,MAAM;QACtB,WAAW,KAAK,YAAY;QAC5B,WAAW,KAAK,QAAQ;QACxB,CAAC,CAAC,WAAW,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,EAC5E,CAAC;QACD,OAAO,IAAI,wBAAwB,CAAC;YAClC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa;YACzE,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;YACrE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU;SAC9D,CAAC,CAAC;IACL,CAAC;IAED,8CAA8C;IAC9C,OAAO,IAAI,mBAAmB,EAAE,CAAC;AACnC,CAAC;AAED,4BAA4B;AAC5B,MAAM,CAAC,MAAM,qBAAqB,GAAG,sBAAsB,CAAC","sourcesContent":["import { DecisionBackend, SystemOneBackend } from './types.js';\nimport { MockDecisionBackend } from './mock.js';\nimport { JevDecisionBackend } from './jev.js';\nimport { SimpleJevDecisionBackend } from './simple-jev.js';\n\n/**\n * A credential the caller has already resolved (g-059).\n *\n * The plugin resolves the key exactly once, through\n * `resolveApiKeyWithSource`, so that the panel and the transport can never\n * disagree. Passing the outcome here keeps the factory's *provider selection*\n * (which still reads the environment) while removing its *key lookup* from the\n * decision: without the override, an empty `SYSTEM_ONE_API_KEY` would make the\n * Jev branch read `JEV_API_KEY` behind the caller's back.\n *\n * **Plugin-only extension.** The vendored backends are a manual port verified by\n * behaviour (`vendor-contract.test.ts`), not a generated mirror; the root\n * factory has no such parameter and is not changed by this goal. Consolidating\n * the two copies is g-060.\n */\nexport interface ResolvedKeyOverride {\n /**\n * The caller resolved the credential: `apiKey` is used verbatim — including\n * \"absent\", which means no credential at all. The constructed backend then\n * never consults the environment for a key.\n */\n apiKeyResolved?: boolean;\n /** The resolved key; empty or omitted means there is none. */\n apiKey?: string;\n}\n\n/**\n * Factory to create System One Decision Backend\n *\n * Supported providers:\n * - 'jev': Official Jev System One Gateway\n * - 'vllm' / 'simple-jev' / 'logits': Next-token logits scoring on standard LLMs\n * - 'mock' / 'heuristic': Fast deterministic local baseline\n *\n * @param override - a credential the caller already resolved. Omitted (the MCP\n * server, the CLI, a bare import) the factory behaves exactly as before and\n * reads the key from the environment itself.\n * @returns the provider the environment selects.\n */\nexport function createSystemOneBackend(override?: ResolvedKeyOverride): SystemOneBackend {\n const backendType = (\n process.env.SYSTEM_ONE_BACKEND ||\n process.env.REFLEX_BACKEND ||\n ''\n ).toLowerCase();\n\n // Provider *selection* is deliberately untouched by the override: which\n // backend to build is a deployment question, and only the credential changes.\n const keyFor = (envChain: string | undefined): { apiKey?: string; apiKeyResolved?: boolean } =>\n override?.apiKeyResolved === true\n ? // Verbatim, empty included: `apiKeyResolved` on the backend class makes\n // an empty value final, so no environment read can resurrect a key the\n // caller decided not to send.\n { apiKey: override.apiKey ?? '', apiKeyResolved: true }\n : envChain === undefined\n ? {}\n : { apiKey: envChain };\n\n // 1. Jev Provider\n if (backendType === 'jev' || (!backendType && (process.env.SYSTEM_ONE_API_KEY || process.env.JEV_API_KEY))) {\n return new JevDecisionBackend({\n ...keyFor(process.env.SYSTEM_ONE_API_KEY || process.env.JEV_API_KEY),\n baseUrl: process.env.SYSTEM_ONE_BASE_URL || process.env.JEV_BASE_URL,\n model: process.env.SYSTEM_ONE_MODEL || process.env.JEV_MODEL\n });\n }\n\n // 2. Open LLM / vLLM Next-Token Logits Provider\n if (\n backendType === 'vllm' ||\n backendType === 'simple-jev' ||\n backendType === 'logits' ||\n (!backendType && (process.env.VLLM_BASE_URL || process.env.OPENAI_BASE_URL))\n ) {\n return new SimpleJevDecisionBackend({\n vllmBaseUrl: process.env.SYSTEM_ONE_BASE_URL || process.env.VLLM_BASE_URL,\n ...keyFor(process.env.SYSTEM_ONE_API_KEY || process.env.VLLM_API_KEY),\n model: process.env.SYSTEM_ONE_MODEL || process.env.VLLM_MODEL\n });\n }\n\n // 3. Default: Local Mock / Heuristic Provider\n return new MockDecisionBackend();\n}\n\n// Backward-compatible alias\nexport const createDecisionBackend = createSystemOneBackend;\n"]}
@@ -2,6 +2,26 @@ import { ActionStep, BackendHealth, ChoiceOption, ChoiceRequest, ChoiceResponse,
2
2
  export interface JevBackendConfig {
3
3
  baseUrl?: string;
4
4
  apiKey?: string;
5
+ /**
6
+ * The caller has already resolved the credential (g-059).
7
+ *
8
+ * `true` means `apiKey` is used **verbatim**, including "absent": an omitted
9
+ * or empty key means requests go out with no `Authorization` header at all,
10
+ * and this class never consults `SYSTEM_ONE_API_KEY` / `JEV_API_KEY` itself.
11
+ * Without this bit a caller that resolved "no key" (a naming that locks onto an
12
+ * empty variable) would be silently served by the environment read below — the
13
+ * panel would say the key is empty while requests actually authenticated,
14
+ * which is the divergence `g-058` removed, pointing the other way.
15
+ *
16
+ * Default `false`: the environment chain stays exactly as it was for every
17
+ * bare construction.
18
+ *
19
+ * **Plugin-only extension.** The vendored backends are a manual port verified
20
+ * by behaviour (`vendor-contract.test.ts`), not a generated mirror, so this
21
+ * field lives here first; the root adapter does not have it yet and is not
22
+ * changed by this goal. Consolidating the two copies is g-060.
23
+ */
24
+ apiKeyResolved?: boolean;
5
25
  model?: string;
6
26
  timeoutMs?: number;
7
27
  /**
@@ -940,11 +940,18 @@ export class JevDecisionBackend {
940
940
  process.env.JEV_BASE_URL ||
941
941
  process.env.JEV_API_BASE ||
942
942
  DEFAULT_SYSTEMONE_ENDPOINT);
943
+ // A caller that resolved the credential owns the answer, empty included
944
+ // (g-059): reading the environment here would resurrect a key that caller
945
+ // deliberately decided not to send. See `JevBackendConfig.apiKeyResolved`.
946
+ // `=== true` rather than truthiness: only an explicit opt-in may change the
947
+ // historical chain, so any other value (including a stray `'false'`) keeps it.
943
948
  this.apiKey =
944
- config?.apiKey ||
945
- process.env.SYSTEM_ONE_API_KEY ||
946
- process.env.JEV_API_KEY ||
947
- '';
949
+ config?.apiKeyResolved === true
950
+ ? config.apiKey ?? ''
951
+ : config?.apiKey ||
952
+ process.env.SYSTEM_ONE_API_KEY ||
953
+ process.env.JEV_API_KEY ||
954
+ '';
948
955
  this.model =
949
956
  config?.model ||
950
957
  process.env.SYSTEM_ONE_MODEL ||