@cleocode/core 2026.6.4 → 2026.6.6
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/docs/export-document.js +189 -137
- package/dist/docs/export-document.js.map +2 -2
- package/dist/llm/api-mode.d.ts +64 -0
- package/dist/llm/api-mode.d.ts.map +1 -0
- package/dist/llm/api-mode.js +72 -0
- package/dist/llm/api-mode.js.map +1 -0
- package/dist/llm/api.d.ts.map +1 -1
- package/dist/llm/api.js +6 -37
- package/dist/llm/api.js.map +1 -1
- package/dist/llm/auxiliary-fallback.d.ts.map +1 -1
- package/dist/llm/auxiliary-fallback.js +24 -38
- package/dist/llm/auxiliary-fallback.js.map +1 -1
- package/dist/llm/model-runner.d.ts +127 -0
- package/dist/llm/model-runner.d.ts.map +1 -0
- package/dist/llm/model-runner.js +282 -0
- package/dist/llm/model-runner.js.map +1 -0
- package/dist/llm/plugin-facade.js +29391 -1473
- package/dist/llm/plugin-facade.js.map +3 -3
- package/dist/llm/role-executor.d.ts +6 -5
- package/dist/llm/role-executor.d.ts.map +1 -1
- package/dist/llm/role-executor.js +40 -86
- package/dist/llm/role-executor.js.map +1 -1
- package/dist/llm/role-resolver.d.ts +28 -1
- package/dist/llm/role-resolver.d.ts.map +1 -1
- package/dist/llm/role-resolver.js +10 -0
- package/dist/llm/role-resolver.js.map +1 -1
- package/dist/llm/session-factory.d.ts +4 -6
- package/dist/llm/session-factory.d.ts.map +1 -1
- package/dist/llm/session-factory.js +6 -72
- package/dist/llm/session-factory.js.map +1 -1
- package/dist/llm/system-resolver.d.ts.map +1 -1
- package/dist/llm/system-resolver.js +6 -0
- package/dist/llm/system-resolver.js.map +1 -1
- package/dist/llm/tool-loop.d.ts.map +1 -1
- package/dist/llm/tool-loop.js +9 -32
- package/dist/llm/tool-loop.js.map +1 -1
- package/dist/memory/dialectic-evaluator.d.ts +13 -6
- package/dist/memory/dialectic-evaluator.d.ts.map +1 -1
- package/dist/memory/dialectic-evaluator.js +18 -7
- package/dist/memory/dialectic-evaluator.js.map +1 -1
- package/dist/memory/llm-backend-resolver.d.ts +23 -3
- package/dist/memory/llm-backend-resolver.d.ts.map +1 -1
- package/dist/memory/llm-backend-resolver.js +135 -0
- package/dist/memory/llm-backend-resolver.js.map +1 -1
- package/dist/release/reconcile.d.ts +61 -0
- package/dist/release/reconcile.d.ts.map +1 -1
- package/dist/release/reconcile.js +187 -2
- package/dist/release/reconcile.js.map +1 -1
- package/dist/store/exodus/column-transforms.d.ts +248 -0
- package/dist/store/exodus/column-transforms.d.ts.map +1 -0
- package/dist/store/exodus/column-transforms.js +444 -0
- package/dist/store/exodus/column-transforms.js.map +1 -0
- package/dist/store/exodus/migrate.d.ts.map +1 -1
- package/dist/store/exodus/migrate.js +5 -267
- package/dist/store/exodus/migrate.js.map +1 -1
- package/dist/store/exodus/verify-migration.d.ts.map +1 -1
- package/dist/store/exodus/verify-migration.js +61 -3
- package/dist/store/exodus/verify-migration.js.map +1 -1
- package/package.json +12 -12
|
@@ -14,12 +14,16 @@
|
|
|
14
14
|
*
|
|
15
15
|
* ## LLM Integration
|
|
16
16
|
*
|
|
17
|
-
* Uses `resolveLlmBackend('
|
|
18
|
-
* module never imports PSYCHE's `llm/` layer directly.
|
|
17
|
+
* Uses `resolveLlmBackend('warm')` from `llm-backend-resolver.ts` so this
|
|
18
|
+
* module never imports PSYCHE's `llm/` layer directly. Warm tier prefers the
|
|
19
|
+
* unified `extraction`-role profile + local inference (Ollama → transformers)
|
|
20
|
+
* before escalating to cold/anthropic (T11757), which is what keeps the loop
|
|
21
|
+
* running on a local model rather than dormant. The LLM call uses
|
|
19
22
|
* `generateObject()` (Vercel AI SDK) with a Zod schema that maps directly to
|
|
20
23
|
* `DialecticInsights`.
|
|
21
24
|
*
|
|
22
|
-
* When no LLM backend is available (no
|
|
25
|
+
* When no LLM backend is available (no pinned profile, no local Ollama, no
|
|
26
|
+
* `ANTHROPIC_API_KEY`),
|
|
23
27
|
* `evaluateDialectic` returns empty arrays so the caller can continue without
|
|
24
28
|
* failing. Prompt-iteration work is tracked in T1532 (confidence thresholds +
|
|
25
29
|
* few-shot examples) and T1533 (telemetry for missing backend / errors).
|
|
@@ -80,9 +84,12 @@ export declare const PEER_INSIGHT_CONFIDENCE_THRESHOLD: 0.5;
|
|
|
80
84
|
/**
|
|
81
85
|
* Analyse a single conversational turn and extract structured insights.
|
|
82
86
|
*
|
|
83
|
-
* Uses CLEO's existing `resolveLlmBackend('
|
|
84
|
-
* no new network egress paths are introduced
|
|
85
|
-
*
|
|
87
|
+
* Uses CLEO's existing `resolveLlmBackend('warm')` for the LLM call so that
|
|
88
|
+
* no new network egress paths are introduced — warm prefers the unified
|
|
89
|
+
* `extraction` profile and local inference, escalating to cold/anthropic only
|
|
90
|
+
* when no local backend is reachable (T11757). When no LLM backend is
|
|
91
|
+
* available, returns empty `DialecticInsights` so the caller can continue
|
|
92
|
+
* safely.
|
|
86
93
|
*
|
|
87
94
|
* The result is intended to be immediately passed to `applyInsights`.
|
|
88
95
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialectic-evaluator.d.ts","sourceRoot":"","sources":["../../src/memory/dialectic-evaluator.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"dialectic-evaluator.d.ts","sourceRoot":"","sources":["../../src/memory/dialectic-evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAKH,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAIlE,OAAO,KAAK,KAAK,YAAY,MAAM,kCAAkC,CAAC;AACtE,OAAO,KAAK,KAAK,WAAW,MAAM,iCAAiC,CAAC;AAmEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,iCAAiC,EAAG,GAAY,CAAC;AAE9D;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,EAAG,GAAY,CAAC;AAwJ9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAqFvF;AAuED;;;;;;;;GAQG;AACH,wBAAgB,0CAA0C,IAAI,IAAI,CAEjE;AAMD,0DAA0D;AAC1D,KAAK,OAAO,GAAG,kBAAkB,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD,mEAAmE;AACnE,KAAK,OAAO,GAAG,kBAAkB,CAAC,OAAO,YAAY,CAAC,CAAC;AAEvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACrE,OAAO,CAAC,IAAI,CAAC,CA6Df"}
|
|
@@ -14,12 +14,16 @@
|
|
|
14
14
|
*
|
|
15
15
|
* ## LLM Integration
|
|
16
16
|
*
|
|
17
|
-
* Uses `resolveLlmBackend('
|
|
18
|
-
* module never imports PSYCHE's `llm/` layer directly.
|
|
17
|
+
* Uses `resolveLlmBackend('warm')` from `llm-backend-resolver.ts` so this
|
|
18
|
+
* module never imports PSYCHE's `llm/` layer directly. Warm tier prefers the
|
|
19
|
+
* unified `extraction`-role profile + local inference (Ollama → transformers)
|
|
20
|
+
* before escalating to cold/anthropic (T11757), which is what keeps the loop
|
|
21
|
+
* running on a local model rather than dormant. The LLM call uses
|
|
19
22
|
* `generateObject()` (Vercel AI SDK) with a Zod schema that maps directly to
|
|
20
23
|
* `DialecticInsights`.
|
|
21
24
|
*
|
|
22
|
-
* When no LLM backend is available (no
|
|
25
|
+
* When no LLM backend is available (no pinned profile, no local Ollama, no
|
|
26
|
+
* `ANTHROPIC_API_KEY`),
|
|
23
27
|
* `evaluateDialectic` returns empty arrays so the caller can continue without
|
|
24
28
|
* failing. Prompt-iteration work is tracked in T1532 (confidence thresholds +
|
|
25
29
|
* few-shot examples) and T1533 (telemetry for missing backend / errors).
|
|
@@ -283,9 +287,12 @@ higher confidence because it describes a concrete, verifiable result.`;
|
|
|
283
287
|
/**
|
|
284
288
|
* Analyse a single conversational turn and extract structured insights.
|
|
285
289
|
*
|
|
286
|
-
* Uses CLEO's existing `resolveLlmBackend('
|
|
287
|
-
* no new network egress paths are introduced
|
|
288
|
-
*
|
|
290
|
+
* Uses CLEO's existing `resolveLlmBackend('warm')` for the LLM call so that
|
|
291
|
+
* no new network egress paths are introduced — warm prefers the unified
|
|
292
|
+
* `extraction` profile and local inference, escalating to cold/anthropic only
|
|
293
|
+
* when no local backend is reachable (T11757). When no LLM backend is
|
|
294
|
+
* available, returns empty `DialecticInsights` so the caller can continue
|
|
295
|
+
* safely.
|
|
289
296
|
*
|
|
290
297
|
* The result is intended to be immediately passed to `applyInsights`.
|
|
291
298
|
*
|
|
@@ -344,7 +351,11 @@ export async function evaluateDialectic(turn) {
|
|
|
344
351
|
if (!turn.userMessage.trim() && !turn.systemResponse.trim()) {
|
|
345
352
|
return EMPTY;
|
|
346
353
|
}
|
|
347
|
-
|
|
354
|
+
// Warm tier (T11757): prefer the unified `extraction`-role profile + local
|
|
355
|
+
// inference (Ollama → transformers) before escalating to cold/anthropic. This
|
|
356
|
+
// turns the dialectic loop ON wherever a local model or a pinned profile is
|
|
357
|
+
// available, instead of staying dormant whenever ANTHROPIC_API_KEY is absent.
|
|
358
|
+
const backend = await resolveLlmBackend('warm');
|
|
348
359
|
if (!backend || backend.name === 'none') {
|
|
349
360
|
log.warn({
|
|
350
361
|
event: 'dialectic.no_backend',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialectic-evaluator.js","sourceRoot":"","sources":["../../src/memory/dialectic-evaluator.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"dialectic-evaluator.js","sourceRoot":"","sources":["../../src/memory/dialectic-evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,cAAc,EAAE,MAAM,IAAI,CAAC;AAEpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,iEAAiE;AACjE,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;AAEnC,+EAA+E;AAC/E,gDAAgD;AAChD,+EAA+E;AAE/E,kEAAkE;AAClE,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,GAAG,EAAE,CAAC;SACH,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,GAAG,CAAC;SACR,QAAQ,CAAC,6DAA6D,CAAC;IAC1E,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QA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IAAI,OAAO,CAAC,GAAG,KAAK,OAAO,CAAC,KAAK,EAAE;gBACzC,KAAK,EAAE,OAAO,CAAC,GAAG;gBAClB,gEAAgE;gBAChE,eAAe,EAAE,SAAS;gBAC1B,UAAU,EAAE,OAAO;gBACnB,KAAK,EAAE,YAAY;gBACnB,oEAAoE;gBACpE,6EAA6E;gBAC7E,6DAA6D;gBAC7D,gBAAgB,EAAE,OAAO,CAAC,UAAU,IAAI,GAAG,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO;aACvE,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,cAAc;QAChB,CAAC;IACH,CAAC;IAED,4EAA4E;IAC5E,+DAA+D;IAC/D,4EAA4E;IAC5E,IAAI,QAAQ,CAAC,qBAAqB,EAAE,CAAC;QACnC,IAAI,CAAC;YACH,MAAM,oBAAoB,CAAC,SAAS,EAAE,QAAQ,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC;QACrF,CAAC;QAAC,MAAM,CAAC;YACP,cAAc;QAChB,CAAC;IACH,CAAC;IAED,4EAA4E;IAC5E,KAAK,OAAO,CAAC;AACf,CAAC"}
|
|
@@ -6,13 +6,27 @@
|
|
|
6
6
|
* escalating to the cloud (Claude Sonnet). Cold-tier uses Claude Sonnet
|
|
7
7
|
* exclusively (owner-mandated, NOT Haiku).
|
|
8
8
|
*
|
|
9
|
+
* ## Unified resolver convergence (T11757)
|
|
10
|
+
*
|
|
11
|
+
* Before walking the legacy fallback chain, `resolveLlmBackend` FIRST consults
|
|
12
|
+
* the unified role/profile resolver (`resolveLLMForRole('extraction')` in
|
|
13
|
+
* `../llm/role-resolver.ts`). This honours a pinned `extraction`-role profile —
|
|
14
|
+
* e.g. an openai-compatible provider (`openai`/`ollama`, optionally with a
|
|
15
|
+
* `baseUrl` override) or `anthropic` — so the sentient loop uses the SAME
|
|
16
|
+
* provider/credential machinery as the rest of CLEO. When the unified resolver
|
|
17
|
+
* yields nothing usable (no pinned profile, no credential, or a client that
|
|
18
|
+
* cannot be constructed), the call falls through to the legacy warm/cold chain
|
|
19
|
+
* below — no behavioural regression for unconfigured installs.
|
|
20
|
+
*
|
|
9
21
|
* Fallback chain (warm):
|
|
22
|
+
* 0. Unified resolver (`extraction` role profile) — anthropic OR openai-compatible
|
|
10
23
|
* 1. Ollama daemon running at localhost:11434 (gemma4:e4b-it or fallback model)
|
|
11
24
|
* 2. @huggingface/transformers (already installed; ONNX pipeline, zero extra deps)
|
|
12
25
|
* 3. Claude Sonnet via Anthropic API (cold escalation)
|
|
13
26
|
* 4. null — no backend; caller must skip extraction
|
|
14
27
|
*
|
|
15
28
|
* Fallback chain (cold):
|
|
29
|
+
* 0. Unified resolver (`extraction` role profile)
|
|
16
30
|
* 1. Claude Sonnet via Anthropic API (ANTHROPIC_API_KEY required)
|
|
17
31
|
* 2. null — no API key; caller must skip extraction
|
|
18
32
|
*
|
|
@@ -22,6 +36,7 @@
|
|
|
22
36
|
* Spec reference: `docs/specs/memory-architecture-spec.md` §7
|
|
23
37
|
*
|
|
24
38
|
* @task T730
|
|
39
|
+
* @task T11757
|
|
25
40
|
* @epic T726
|
|
26
41
|
*/
|
|
27
42
|
import type { LanguageModel } from 'ai';
|
|
@@ -30,12 +45,17 @@ export type ExtractionTier = 'warm' | 'cold';
|
|
|
30
45
|
/**
|
|
31
46
|
* The resolved backend name. Used for telemetry and logging.
|
|
32
47
|
*
|
|
33
|
-
* - `ollama` — Ollama daemon (local)
|
|
48
|
+
* - `ollama` — Ollama daemon (local), reached via its OpenAI-compatible `/v1` shim
|
|
49
|
+
* - `openai` — an OpenAI-compatible provider resolved from the unified
|
|
50
|
+
* role/profile resolver (T11757) — covers a pinned `openai`
|
|
51
|
+
* profile, including one whose `baseUrl` points at a local
|
|
52
|
+
* server. `ollama` is reported separately when the unified
|
|
53
|
+
* profile provider is literally `ollama`.
|
|
34
54
|
* - `transformers` — @huggingface/transformers ONNX pipeline (local, in-process)
|
|
35
|
-
* - `anthropic` — Claude Sonnet via Anthropic API (cloud)
|
|
55
|
+
* - `anthropic` — Claude (Sonnet) via Anthropic API (cloud)
|
|
36
56
|
* - `none` — No backend available; extraction must be skipped
|
|
37
57
|
*/
|
|
38
|
-
export type ExtractionBackendName = 'ollama' | 'transformers' | 'anthropic' | 'none';
|
|
58
|
+
export type ExtractionBackendName = 'ollama' | 'openai' | 'transformers' | 'anthropic' | 'none';
|
|
39
59
|
/**
|
|
40
60
|
* Resolved backend descriptor returned by `resolveLlmBackend`.
|
|
41
61
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm-backend-resolver.d.ts","sourceRoot":"","sources":["../../src/memory/llm-backend-resolver.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"llm-backend-resolver.d.ts","sourceRoot":"","sources":["../../src/memory/llm-backend-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAExC,uEAAuE;AACvE,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7C;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,QAAQ,GAAG,cAAc,GAAG,WAAW,GAAG,MAAM,CAAC;AAEhG;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,yDAAyD;IACzD,KAAK,EAAE,aAAa,CAAC;IACrB,kCAAkC;IAClC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,2EAA2E;IAC3E,OAAO,EAAE,MAAM,CAAC;CACjB;AAiCD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CA8B7F;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC,CAS1D"}
|
|
@@ -6,13 +6,27 @@
|
|
|
6
6
|
* escalating to the cloud (Claude Sonnet). Cold-tier uses Claude Sonnet
|
|
7
7
|
* exclusively (owner-mandated, NOT Haiku).
|
|
8
8
|
*
|
|
9
|
+
* ## Unified resolver convergence (T11757)
|
|
10
|
+
*
|
|
11
|
+
* Before walking the legacy fallback chain, `resolveLlmBackend` FIRST consults
|
|
12
|
+
* the unified role/profile resolver (`resolveLLMForRole('extraction')` in
|
|
13
|
+
* `../llm/role-resolver.ts`). This honours a pinned `extraction`-role profile —
|
|
14
|
+
* e.g. an openai-compatible provider (`openai`/`ollama`, optionally with a
|
|
15
|
+
* `baseUrl` override) or `anthropic` — so the sentient loop uses the SAME
|
|
16
|
+
* provider/credential machinery as the rest of CLEO. When the unified resolver
|
|
17
|
+
* yields nothing usable (no pinned profile, no credential, or a client that
|
|
18
|
+
* cannot be constructed), the call falls through to the legacy warm/cold chain
|
|
19
|
+
* below — no behavioural regression for unconfigured installs.
|
|
20
|
+
*
|
|
9
21
|
* Fallback chain (warm):
|
|
22
|
+
* 0. Unified resolver (`extraction` role profile) — anthropic OR openai-compatible
|
|
10
23
|
* 1. Ollama daemon running at localhost:11434 (gemma4:e4b-it or fallback model)
|
|
11
24
|
* 2. @huggingface/transformers (already installed; ONNX pipeline, zero extra deps)
|
|
12
25
|
* 3. Claude Sonnet via Anthropic API (cold escalation)
|
|
13
26
|
* 4. null — no backend; caller must skip extraction
|
|
14
27
|
*
|
|
15
28
|
* Fallback chain (cold):
|
|
29
|
+
* 0. Unified resolver (`extraction` role profile)
|
|
16
30
|
* 1. Claude Sonnet via Anthropic API (ANTHROPIC_API_KEY required)
|
|
17
31
|
* 2. null — no API key; caller must skip extraction
|
|
18
32
|
*
|
|
@@ -22,6 +36,7 @@
|
|
|
22
36
|
* Spec reference: `docs/specs/memory-architecture-spec.md` §7
|
|
23
37
|
*
|
|
24
38
|
* @task T730
|
|
39
|
+
* @task T11757
|
|
25
40
|
* @epic T726
|
|
26
41
|
*/
|
|
27
42
|
/**
|
|
@@ -71,6 +86,15 @@ const TRANSFORMERS_FALLBACK_MODEL = 'onnx-community/Qwen2.5-0.5B-Instruct';
|
|
|
71
86
|
* ```
|
|
72
87
|
*/
|
|
73
88
|
export async function resolveLlmBackend(tier) {
|
|
89
|
+
// 0. Unified convergence (T11757): honour a pinned `extraction`-role profile
|
|
90
|
+
// from the unified role/profile resolver before any legacy chain. This is
|
|
91
|
+
// what makes the sentient loop use the SAME provider/credential machinery
|
|
92
|
+
// as every other LLM call-site (so a pinned codex/openai/ollama/anthropic
|
|
93
|
+
// profile is reachable). Returns null when nothing usable is configured —
|
|
94
|
+
// then we fall through to the legacy warm/cold chain below.
|
|
95
|
+
const unifiedBackend = await tryUnifiedResolver();
|
|
96
|
+
if (unifiedBackend)
|
|
97
|
+
return unifiedBackend;
|
|
74
98
|
if (tier === 'warm') {
|
|
75
99
|
// 1. Try Ollama (best local quality, GPU-accelerated if available)
|
|
76
100
|
const ollamaBackend = await tryOllama();
|
|
@@ -220,4 +244,115 @@ async function tryAnthropic(modelId) {
|
|
|
220
244
|
return null;
|
|
221
245
|
}
|
|
222
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* Default OpenAI-compatible base URL for the local Ollama daemon (T11757).
|
|
249
|
+
*
|
|
250
|
+
* Ollama exposes an OpenAI-compatible surface under `/v1`. The provider-registry
|
|
251
|
+
* profile records the bare host (`http://localhost:11434`); the unified backend
|
|
252
|
+
* path appends `/v1` so `createOpenAICompatible` can speak the OpenAI wire shape.
|
|
253
|
+
*/
|
|
254
|
+
const OLLAMA_OPENAI_COMPAT_BASE_URL = 'http://localhost:11434/v1';
|
|
255
|
+
/**
|
|
256
|
+
* Resolve the OpenAI-compatible base URL for a provider resolved by the unified
|
|
257
|
+
* role/profile resolver.
|
|
258
|
+
*
|
|
259
|
+
* Looks up the provider-registry profile (which carries the canonical `baseUrl`)
|
|
260
|
+
* and normalises it for the OpenAI-compatible client. For `ollama` we guarantee
|
|
261
|
+
* the `/v1` shim suffix; other openai-family providers use their registered
|
|
262
|
+
* base URL verbatim (already a `/v1`-style endpoint) and fall back to the OpenAI
|
|
263
|
+
* default when no profile is registered.
|
|
264
|
+
*
|
|
265
|
+
* @param provider - The provider id resolved by the unified resolver.
|
|
266
|
+
* @returns A base URL suitable for `createOpenAICompatible`, or `undefined`
|
|
267
|
+
* when none can be determined (caller skips the openai-compatible path).
|
|
268
|
+
*/
|
|
269
|
+
async function resolveOpenAiCompatibleBaseUrl(provider) {
|
|
270
|
+
if (provider === 'ollama') {
|
|
271
|
+
return OLLAMA_OPENAI_COMPAT_BASE_URL;
|
|
272
|
+
}
|
|
273
|
+
try {
|
|
274
|
+
const { getProviderProfile } = await import('../llm/provider-registry/index.js');
|
|
275
|
+
const profile = await getProviderProfile(provider);
|
|
276
|
+
if (profile?.baseUrl) {
|
|
277
|
+
return profile.baseUrl;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
// Registry lookup failed — fall through to the openai default below.
|
|
282
|
+
}
|
|
283
|
+
if (provider === 'openai') {
|
|
284
|
+
return 'https://api.openai.com/v1';
|
|
285
|
+
}
|
|
286
|
+
return undefined;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Attempt to resolve an extraction backend via the unified role/profile resolver
|
|
290
|
+
* (`resolveLLMForRole('extraction')`) — the T11757 convergence point.
|
|
291
|
+
*
|
|
292
|
+
* This is consulted BEFORE the legacy warm/cold chain so a pinned `extraction`
|
|
293
|
+
* profile (or the unscoped default) drives the sentient loop with the same
|
|
294
|
+
* provider/credential machinery as every other CLEO LLM call-site:
|
|
295
|
+
*
|
|
296
|
+
* - `anthropic` provider → build via `createAnthropic` (returns `name: 'anthropic'`).
|
|
297
|
+
* - `openai` / `ollama` (openai-compatible) → build via `createOpenAICompatible`
|
|
298
|
+
* against the resolved base URL (returns `name: 'ollama'` for ollama, else
|
|
299
|
+
* `name: 'openai'`). An openai-family client whose key later 401s simply
|
|
300
|
+
* fails the downstream `generateObject` call and the caller degrades — it is
|
|
301
|
+
* NOT this resolver's job to validate the credential live.
|
|
302
|
+
*
|
|
303
|
+
* Returns `null` (so the caller falls through to the legacy chain) when:
|
|
304
|
+
* - the resolver throws or yields no usable provider, OR
|
|
305
|
+
* - no credential is reachable for the resolved provider, OR
|
|
306
|
+
* - the provider is not one we can wire here (e.g. a transport-only provider).
|
|
307
|
+
*
|
|
308
|
+
* NOTE: codex's ChatGPT-backend transport is intentionally NOT handled here
|
|
309
|
+
* (tracked separately as T11767). A codex/openai profile resolves through the
|
|
310
|
+
* openai-compatible path; if its client cannot authenticate it falls through to
|
|
311
|
+
* the warm chain rather than crashing.
|
|
312
|
+
*
|
|
313
|
+
* @task T11757
|
|
314
|
+
*/
|
|
315
|
+
async function tryUnifiedResolver() {
|
|
316
|
+
try {
|
|
317
|
+
const { resolveLLMForRole } = await import('../llm/role-resolver.js');
|
|
318
|
+
const resolved = await resolveLLMForRole('extraction');
|
|
319
|
+
// No credential reachable → let the legacy chain try local backends.
|
|
320
|
+
const apiKey = resolved.credential?.apiKey ?? null;
|
|
321
|
+
if (resolved.provider === 'anthropic') {
|
|
322
|
+
if (!apiKey)
|
|
323
|
+
return null;
|
|
324
|
+
const { createAnthropic } = await import('@ai-sdk/anthropic');
|
|
325
|
+
const anthropicProvider = createAnthropic({ apiKey });
|
|
326
|
+
return {
|
|
327
|
+
model: anthropicProvider(resolved.model),
|
|
328
|
+
name: 'anthropic',
|
|
329
|
+
modelId: resolved.model,
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
if (resolved.provider === 'openai' || resolved.provider === 'ollama') {
|
|
333
|
+
const baseURL = await resolveOpenAiCompatibleBaseUrl(resolved.provider);
|
|
334
|
+
if (!baseURL)
|
|
335
|
+
return null;
|
|
336
|
+
// Local Ollama needs no key; remote openai-compatible servers do. Use an
|
|
337
|
+
// empty placeholder when none is configured so the local path still works
|
|
338
|
+
// (mirrors tryOllama, which sends no Authorization for localhost).
|
|
339
|
+
const { createOpenAICompatible } = await import('@ai-sdk/openai-compatible');
|
|
340
|
+
const provider = createOpenAICompatible({
|
|
341
|
+
baseURL,
|
|
342
|
+
name: resolved.provider,
|
|
343
|
+
...(apiKey ? { apiKey } : {}),
|
|
344
|
+
});
|
|
345
|
+
return {
|
|
346
|
+
model: provider(resolved.model),
|
|
347
|
+
name: resolved.provider === 'ollama' ? 'ollama' : 'openai',
|
|
348
|
+
modelId: resolved.model,
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
// Provider not wireable here (transport-only) — fall through to legacy chain.
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
catch {
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
223
358
|
//# sourceMappingURL=llm-backend-resolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm-backend-resolver.js","sourceRoot":"","sources":["../../src/memory/llm-backend-resolver.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"llm-backend-resolver.js","sourceRoot":"","sources":["../../src/memory/llm-backend-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAqCH;;;;;;;;;;;GAWG;AACH,MAAM,qBAAqB,GAAG;IAC5B,eAAe,EAAE,wDAAwD;IACzE,eAAe,EAAE,oDAAoD;IACrE,YAAY,EAAE,6DAA6D;IAC3E,WAAW;IACX,aAAa;IACb,UAAU;CACF,CAAC;AAEX,sEAAsE;AACtE,MAAM,eAAe,GAAG,mBAA4B,CAAC;AAErD,6EAA6E;AAC7E,MAAM,2BAA2B,GAAG,sCAA+C,CAAC;AAEpF,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAoB;IAC1D,6EAA6E;IAC7E,6EAA6E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I,QAAQ,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACrE,MAAM,OAAO,GAAG,MAAM,8BAA8B,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACxE,IAAI,CAAC,OAAO;gBAAE,OAAO,IAAI,CAAC;YAC1B,yEAAyE;YACzE,0EAA0E;YAC1E,mEAAmE;YACnE,MAAM,EAAE,sBAAsB,EAAE,GAAG,MAAM,MAAM,CAAC,2BAA2B,CAAC,CAAC;YAC7E,MAAM,QAAQ,GAAG,sBAAsB,CAAC;gBACtC,OAAO;gBACP,IAAI,EAAE,QAAQ,CAAC,QAAQ;gBACvB,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC9B,CAAC,CAAC;YACH,OAAO;gBACL,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;gBAC/B,IAAI,EAAE,QAAQ,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ;gBAC1D,OAAO,EAAE,QAAQ,CAAC,KAAK;aACxB,CAAC;QACJ,CAAC;QAED,8EAA8E;QAC9E,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
* @spec .cleo/rcasd/T9345/research/SPEC-T9345-release-pipeline-v2.md §4.4, §8
|
|
34
34
|
*/
|
|
35
35
|
import { type EngineResult } from '../engine-result.js';
|
|
36
|
+
import { type DatabaseSync } from '../store/sqlite.js';
|
|
36
37
|
/**
|
|
37
38
|
* Options for {@link releaseReconcileV2}.
|
|
38
39
|
*
|
|
@@ -91,6 +92,14 @@ export interface ReleaseReconcileV2Result {
|
|
|
91
92
|
reReconciled?: boolean;
|
|
92
93
|
/** T#### tokens encountered that did not validate against `tasks.id` (R-331). */
|
|
93
94
|
unknownTokens?: string[];
|
|
95
|
+
/**
|
|
96
|
+
* Task IDs present in the runtime task store but UNRESOLVABLE by the
|
|
97
|
+
* provenance `task_id` foreign keys (their FK parent — the bare `tasks` table
|
|
98
|
+
* on a consolidated cleo.db — has no matching row). Their provenance links
|
|
99
|
+
* were skipped-with-warn or NULLed rather than aborting the reconcile
|
|
100
|
+
* (DHQ-051 · T11659).
|
|
101
|
+
*/
|
|
102
|
+
skippedTaskRefs?: string[];
|
|
94
103
|
/** Total wall-clock duration (filled into envelope `meta.durationMs`). */
|
|
95
104
|
durationMs?: number;
|
|
96
105
|
/** Total inserts performed (filled into envelope `meta.txSize`). */
|
|
@@ -136,6 +145,58 @@ export declare function sanitisePrShasForFk(pr: {
|
|
|
136
145
|
sha: string;
|
|
137
146
|
}[];
|
|
138
147
|
}, insertedShas: ReadonlySet<string>): SanitisedPR;
|
|
148
|
+
/** Result of resolving + reconciling the provenance `task_id` FK parent table. */
|
|
149
|
+
export interface FkParentTaskResolution {
|
|
150
|
+
/** Physical table the provenance `task_id` FK references, or null if absent. */
|
|
151
|
+
parentTable: string | null;
|
|
152
|
+
/**
|
|
153
|
+
* Task IDs the FK can now resolve (FK parent rows present after any
|
|
154
|
+
* FK-ordered shim backfill). A `task_id` reference to an id in this set is
|
|
155
|
+
* safe to INSERT under strict FK enforcement.
|
|
156
|
+
*/
|
|
157
|
+
resolvableIds: Set<string>;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Make the provenance `task_id` foreign keys satisfiable on a consolidated
|
|
161
|
+
* `cleo.db` by inserting any missing FK-parent rows in FK order (parent-before
|
|
162
|
+
* -child), then returning the set of IDs the FK can resolve.
|
|
163
|
+
*
|
|
164
|
+
* ## Background (DHQ-051 · T11659 — same class as DHQ-045)
|
|
165
|
+
*
|
|
166
|
+
* After the dual-scope `cleo.db` cutover (T11578) the runtime task store moved
|
|
167
|
+
* from the bare `tasks` table to the prefixed `tasks_tasks` table. The drizzle
|
|
168
|
+
* `schema.tasks` symbol is shadowed at the barrel (`tasks-schema.ts`) onto
|
|
169
|
+
* `tasks_tasks`, so reconcile's token-validity probe reads the populated
|
|
170
|
+
* prefixed table. BUT the provenance tables (`task_commits`, `pr_tasks`,
|
|
171
|
+
* `releases`, `release_changes`) predate the cutover — their `task_id` /
|
|
172
|
+
* `epic_id` FKs still reference the BARE `tasks` table, which is empty on a
|
|
173
|
+
* consolidated `cleo.db`. A token validated against `tasks_tasks` therefore
|
|
174
|
+
* passes the legacy gate yet violates the FK at INSERT time, aborting the
|
|
175
|
+
* whole reconcile with `E_PROVENANCE_FAILED`.
|
|
176
|
+
*
|
|
177
|
+
* ## Strategy — FK-ordered parent backfill (Strategy 1)
|
|
178
|
+
*
|
|
179
|
+
* For every task referenced by this release we ensure a row exists in the FK
|
|
180
|
+
* parent table BEFORE the child provenance rows are written. The parent table
|
|
181
|
+
* is discovered dynamically via `PRAGMA foreign_key_list('task_commits')` (so
|
|
182
|
+
* the logic tracks whatever the live schema enforces — including a future
|
|
183
|
+
* schema that repoints the FK at `tasks_tasks`, where this becomes a no-op).
|
|
184
|
+
* Missing parent rows are copied from the runtime `tasks_tasks` store via
|
|
185
|
+
* `INSERT OR IGNORE … SELECT` of only the NOT NULL columns, so the copied rows
|
|
186
|
+
* satisfy the parent table's own CHECK/NOT NULL constraints. Tasks that exist
|
|
187
|
+
* in neither table remain unresolvable and are skipped-with-warn by the
|
|
188
|
+
* callers (the row, never the whole reconcile).
|
|
189
|
+
*
|
|
190
|
+
* Idempotent: `INSERT OR IGNORE` never duplicates and never overwrites an
|
|
191
|
+
* existing parent row. Runs inside the reconcile transaction so a later
|
|
192
|
+
* failure rolls the shim rows back too.
|
|
193
|
+
*
|
|
194
|
+
* @param nativeDb - The consolidated `cleo.db` native handle.
|
|
195
|
+
* @param referencedIds - Every task id this reconcile may reference (commit
|
|
196
|
+
* tokens, PR tokens, plan tasks, epic).
|
|
197
|
+
* @returns The FK parent table name + the IDs it can now resolve.
|
|
198
|
+
*/
|
|
199
|
+
export declare function ensureProvenanceTaskFkParents(nativeDb: DatabaseSync, referencedIds: ReadonlySet<string>): FkParentTaskResolution;
|
|
139
200
|
/**
|
|
140
201
|
* Run the v2 `cleo release reconcile` verb.
|
|
141
202
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconcile.d.ts","sourceRoot":"","sources":["../../src/release/reconcile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAUH,OAAO,EAAE,KAAK,YAAY,EAA8B,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"reconcile.d.ts","sourceRoot":"","sources":["../../src/release/reconcile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAUH,OAAO,EAAE,KAAK,YAAY,EAA8B,MAAM,qBAAqB,CAAC;AAIpF,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,oBAAoB,CAAC;AAgB3E;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,yBAAyB;IACxC,4DAA4D;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,yEAAyE;AACzE,MAAM,WAAW,wBAAwB;IACvC,wCAAwC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,GAAG,EAAE,MAAM,CAAC;IACZ,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,WAAW,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAC;IAClB,kFAA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