@cleocode/core 2026.6.3 → 2026.6.5
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 +626 -310
- package/dist/docs/export-document.js.map +3 -3
- package/dist/llm/catalog-cache.d.ts +3 -0
- package/dist/llm/catalog-cache.d.ts.map +1 -1
- package/dist/llm/catalog-cache.js.map +1 -1
- package/dist/llm/catalog-model-resolver.d.ts +89 -0
- package/dist/llm/catalog-model-resolver.d.ts.map +1 -0
- package/dist/llm/catalog-model-resolver.js +158 -0
- package/dist/llm/catalog-model-resolver.js.map +1 -0
- package/dist/llm/cli-ops.d.ts +14 -0
- package/dist/llm/cli-ops.d.ts.map +1 -1
- package/dist/llm/cli-ops.js +35 -0
- package/dist/llm/cli-ops.js.map +1 -1
- package/dist/llm/index.d.ts +3 -0
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +3 -0
- package/dist/llm/index.js.map +1 -1
- package/dist/llm/oauth/pkce.js +27 -5
- package/dist/llm/oauth/pkce.js.map +1 -1
- package/dist/llm/plugin-facade.js +613 -325
- package/dist/llm/plugin-facade.js.map +3 -3
- package/dist/llm/provider-registry/builtin/openai.d.ts +11 -2
- package/dist/llm/provider-registry/builtin/openai.d.ts.map +1 -1
- package/dist/llm/provider-registry/builtin/openai.js +15 -3
- package/dist/llm/provider-registry/builtin/openai.js.map +1 -1
- package/dist/llm/system-resolver.d.ts +94 -0
- package/dist/llm/system-resolver.d.ts.map +1 -0
- package/dist/llm/system-resolver.js +165 -0
- package/dist/llm/system-resolver.js.map +1 -0
- 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/store/dual-scope-db.d.ts +20 -2
- package/dist/store/dual-scope-db.d.ts.map +1 -1
- package/dist/store/dual-scope-db.js +74 -7
- package/dist/store/dual-scope-db.js.map +1 -1
- package/dist/store/exodus/archive.d.ts +216 -0
- package/dist/store/exodus/archive.d.ts.map +1 -0
- package/dist/store/exodus/archive.js +314 -0
- package/dist/store/exodus/archive.js.map +1 -0
- package/dist/store/exodus/index.d.ts +1 -0
- package/dist/store/exodus/index.d.ts.map +1 -1
- package/dist/store/exodus/index.js +1 -0
- package/dist/store/exodus/index.js.map +1 -1
- package/dist/store/exodus/migrate.d.ts.map +1 -1
- package/dist/store/exodus/migrate.js +118 -24
- package/dist/store/exodus/migrate.js.map +1 -1
- package/dist/store/exodus/on-open.d.ts.map +1 -1
- package/dist/store/exodus/on-open.js +95 -34
- package/dist/store/exodus/on-open.js.map +1 -1
- package/dist/store/exodus/types.d.ts +10 -1
- package/dist/store/exodus/types.d.ts.map +1 -1
- package/dist/store/exodus/types.js.map +1 -1
- package/dist/store/exodus/verify-migration.d.ts.map +1 -1
- package/dist/store/exodus/verify-migration.js +12 -1
- package/dist/store/exodus/verify-migration.js.map +1 -1
- package/dist/store/sqlite.d.ts +16 -0
- package/dist/store/sqlite.d.ts.map +1 -1
- package/dist/store/sqlite.js +160 -39
- package/dist/store/sqlite.js.map +1 -1
- package/dist/validation/doctor/checks.d.ts +22 -0
- package/dist/validation/doctor/checks.d.ts.map +1 -1
- package/dist/validation/doctor/checks.js +67 -0
- package/dist/validation/doctor/checks.js.map +1 -1
- package/dist/validation/doctor/index.d.ts +1 -1
- package/dist/validation/doctor/index.d.ts.map +1 -1
- package/dist/validation/doctor/index.js +1 -1
- package/dist/validation/doctor/index.js.map +1 -1
- package/package.json +12 -12
|
@@ -28,8 +28,17 @@ export declare const OPENAI_CODEX_OAUTH_CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hran
|
|
|
28
28
|
/**
|
|
29
29
|
* OpenAI / Codex provider profile.
|
|
30
30
|
*
|
|
31
|
-
* `defaultModel` is
|
|
32
|
-
*
|
|
31
|
+
* `defaultModel` is a static FALLBACK used when no live catalog snapshot is
|
|
32
|
+
* available (i.e. before `cleo llm refresh-catalog` has been run). At runtime,
|
|
33
|
+
* `cleo llm use openai` / `cleo llm profile <role> openai` derive the default
|
|
34
|
+
* from the live catalog via `resolveProviderDefaultModel` and validate any
|
|
35
|
+
* explicit `--model` against `validateModelForProvider` (T11773 · E8).
|
|
36
|
+
*
|
|
37
|
+
* Override per-credential:
|
|
38
|
+
* `cleo llm use openai --model <m>`
|
|
39
|
+
* `cleo llm profile <role> openai --model <m>`
|
|
40
|
+
*
|
|
41
|
+
* @task T11773
|
|
33
42
|
*/
|
|
34
43
|
export declare const openaiProfile: ProviderProfile;
|
|
35
44
|
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../../src/llm/provider-registry/builtin/openai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D;;;GAGG;AACH,eAAO,MAAM,4BAA4B,iCAAiC,CAAC;AA6B3E
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../../src/llm/provider-registry/builtin/openai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D;;;GAGG;AACH,eAAO,MAAM,4BAA4B,iCAAiC,CAAC;AA6B3E;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,EAAE,eAW3B,CAAC"}
|
|
@@ -52,15 +52,27 @@ const OPENAI_CODEX_OAUTH = {
|
|
|
52
52
|
/**
|
|
53
53
|
* OpenAI / Codex provider profile.
|
|
54
54
|
*
|
|
55
|
-
* `defaultModel` is
|
|
56
|
-
*
|
|
55
|
+
* `defaultModel` is a static FALLBACK used when no live catalog snapshot is
|
|
56
|
+
* available (i.e. before `cleo llm refresh-catalog` has been run). At runtime,
|
|
57
|
+
* `cleo llm use openai` / `cleo llm profile <role> openai` derive the default
|
|
58
|
+
* from the live catalog via `resolveProviderDefaultModel` and validate any
|
|
59
|
+
* explicit `--model` against `validateModelForProvider` (T11773 · E8).
|
|
60
|
+
*
|
|
61
|
+
* Override per-credential:
|
|
62
|
+
* `cleo llm use openai --model <m>`
|
|
63
|
+
* `cleo llm profile <role> openai --model <m>`
|
|
64
|
+
*
|
|
65
|
+
* @task T11773
|
|
57
66
|
*/
|
|
58
67
|
export const openaiProfile = {
|
|
59
68
|
name: 'openai',
|
|
60
69
|
displayName: 'OpenAI Codex (ChatGPT)',
|
|
61
70
|
authTypes: ['api_key', 'oauth'],
|
|
62
71
|
baseUrl: 'https://api.openai.com/v1',
|
|
63
|
-
|
|
72
|
+
// Static fallback — catalog-driven resolver replaces this at runtime when a
|
|
73
|
+
// disk snapshot is available (T11773 · E8). Updated from stale 'gpt-5-codex'
|
|
74
|
+
// to the confirmed latest OpenAI model (catalog release_date 2026-04-23).
|
|
75
|
+
defaultModel: 'gpt-5.5',
|
|
64
76
|
aliases: ['codex', 'chatgpt', 'openai-codex'],
|
|
65
77
|
oauth: OPENAI_CODEX_OAUTH,
|
|
66
78
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../../../src/llm/provider-registry/builtin/openai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAKH;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,8BAA8B,CAAC;AAE3E,6EAA6E;AAC7E,SAAS,qBAAqB;IAC5B,OAAO,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,IAAI,4BAA4B,CAAC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,EAAE,SAAS;IACvB,OAAO,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,cAAc,CAAC;IAC7C,KAAK,EAAE,kBAAkB;CAC1B,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `resolveLLMForSystem` — the single DRY chokepoint for all LLM resolution (E9).
|
|
3
|
+
*
|
|
4
|
+
* ## Purpose
|
|
5
|
+
*
|
|
6
|
+
* CLEO previously had a 4-resolver / 3-picker sprawl: `resolveLLMForRole`,
|
|
7
|
+
* `resolveAnthropicForRole`, `resolveCredentials`, and several inline `pickX`
|
|
8
|
+
* helpers each duplicated the implicit fallback model literal or called different
|
|
9
|
+
* tiers of the resolution chain independently.
|
|
10
|
+
*
|
|
11
|
+
* `resolveLLMForSystem` is the ONE chokepoint that:
|
|
12
|
+
*
|
|
13
|
+
* 1. Accepts a semantic "system of use" label (e.g. `'sentient'`, `'memory'`)
|
|
14
|
+
* instead of raw role names — insulating call-sites from config vocabulary.
|
|
15
|
+
* 2. Maps the system label to the canonical {@link RoleName} via
|
|
16
|
+
* {@link SYSTEM_ROLE_MAP} (overridable by `opts.roleOverride`).
|
|
17
|
+
* 3. Delegates to `resolveLLMForRole` for the full 5-tier config +
|
|
18
|
+
* CredentialPool resolution chain — no duplication.
|
|
19
|
+
* 4. When resolution lands on `implicit-fallback`, replaces the hardcoded
|
|
20
|
+
* haiku literal with the SSoT default model from the provider registry
|
|
21
|
+
* (`getProviderProfile(provider).defaultModel`) — satisfying the
|
|
22
|
+
* "not hardcoded" acceptance criterion.
|
|
23
|
+
*
|
|
24
|
+
* ## What this is NOT
|
|
25
|
+
*
|
|
26
|
+
* - A replacement for `resolveLLMForRole`. Existing callers of
|
|
27
|
+
* `resolveLLMForRole` continue to work unchanged; T11757 will migrate them
|
|
28
|
+
* to this chokepoint incrementally.
|
|
29
|
+
* - A new credential store or provider registry. All credential I/O goes
|
|
30
|
+
* through the existing CredentialPool (E3 pool) inside `resolveLLMForRole`.
|
|
31
|
+
*
|
|
32
|
+
* @module llm/system-resolver
|
|
33
|
+
* @task T11749
|
|
34
|
+
* @epic T11745
|
|
35
|
+
*/
|
|
36
|
+
import type { ResolveLLMForSystemOptions, RoleName, SystemOfUse } from '@cleocode/contracts';
|
|
37
|
+
import { type ResolvedLLM } from './role-resolver.js';
|
|
38
|
+
/**
|
|
39
|
+
* Result of {@link resolveLLMForSystem}.
|
|
40
|
+
*
|
|
41
|
+
* Extends {@link ResolvedLLM} with the resolved `system` label so callers
|
|
42
|
+
* can log/audit which system triggered the resolution without passing it
|
|
43
|
+
* separately.
|
|
44
|
+
*
|
|
45
|
+
* @task T11749
|
|
46
|
+
*/
|
|
47
|
+
export interface ResolvedLLMForSystem extends ResolvedLLM {
|
|
48
|
+
/**
|
|
49
|
+
* The {@link SystemOfUse} label that initiated this resolution.
|
|
50
|
+
*
|
|
51
|
+
* Preserved verbatim from the call argument — not normalised or remapped.
|
|
52
|
+
*/
|
|
53
|
+
system: SystemOfUse;
|
|
54
|
+
/**
|
|
55
|
+
* The {@link RoleName} that was actually used for config lookup.
|
|
56
|
+
*
|
|
57
|
+
* `null` when `system === 'default'` and no role override was supplied
|
|
58
|
+
* (the global LLM default path was used instead of a per-role entry).
|
|
59
|
+
*/
|
|
60
|
+
resolvedRole: RoleName | null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Resolve the LLM client + credential for a semantic system-of-use label.
|
|
64
|
+
*
|
|
65
|
+
* This is the single DRY chokepoint for all LLM resolution in CLEO (E9 ·
|
|
66
|
+
* T11745). It wraps `resolveLLMForRole` with:
|
|
67
|
+
*
|
|
68
|
+
* - System label → role mapping (via {@link SYSTEM_ROLE_MAP}).
|
|
69
|
+
* - SSoT default model from the provider registry when `implicit-fallback`
|
|
70
|
+
* is reached (the hardcoded haiku literal is NOT used as the final model).
|
|
71
|
+
* - Full CredentialPool (E3) binding via `resolveLLMForRole` delegation.
|
|
72
|
+
*
|
|
73
|
+
* Like `resolveLLMForRole`, this function **never throws**: when no credential
|
|
74
|
+
* is reachable the caller receives `{ credential: null, client: null, … }` and
|
|
75
|
+
* is responsible for its own graceful-degradation path.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* const resolved = await resolveLLMForSystem('sentient', { projectRoot });
|
|
80
|
+
* if (!resolved.credential?.apiKey || !resolved.client) {
|
|
81
|
+
* return null; // graceful no-op — no credential available
|
|
82
|
+
* }
|
|
83
|
+
* // Use resolved.model, resolved.client, resolved.credential
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @param system - Semantic label for the subsystem requesting an LLM client.
|
|
87
|
+
* @param opts - Optional overrides (project root, role override, skipCatalogDefault).
|
|
88
|
+
* @returns A {@link ResolvedLLMForSystem} envelope; never throws.
|
|
89
|
+
*
|
|
90
|
+
* @task T11749
|
|
91
|
+
* @epic T11745
|
|
92
|
+
*/
|
|
93
|
+
export declare function resolveLLMForSystem(system: SystemOfUse, opts?: ResolveLLMForSystemOptions): Promise<ResolvedLLMForSystem>;
|
|
94
|
+
//# sourceMappingURL=system-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-resolver.d.ts","sourceRoot":"","sources":["../../src/llm/system-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,KAAK,EAAE,0BAA0B,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAG7F,OAAO,EAEL,KAAK,WAAW,EAEjB,MAAM,oBAAoB,CAAC;AAI5B;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD;;;;OAIG;IACH,MAAM,EAAE,WAAW,CAAC;IAEpB;;;;;OAKG;IACH,YAAY,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC/B;AAqED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,WAAW,EACnB,IAAI,CAAC,EAAE,0BAA0B,GAChC,OAAO,CAAC,oBAAoB,CAAC,CAyC/B"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `resolveLLMForSystem` — the single DRY chokepoint for all LLM resolution (E9).
|
|
3
|
+
*
|
|
4
|
+
* ## Purpose
|
|
5
|
+
*
|
|
6
|
+
* CLEO previously had a 4-resolver / 3-picker sprawl: `resolveLLMForRole`,
|
|
7
|
+
* `resolveAnthropicForRole`, `resolveCredentials`, and several inline `pickX`
|
|
8
|
+
* helpers each duplicated the implicit fallback model literal or called different
|
|
9
|
+
* tiers of the resolution chain independently.
|
|
10
|
+
*
|
|
11
|
+
* `resolveLLMForSystem` is the ONE chokepoint that:
|
|
12
|
+
*
|
|
13
|
+
* 1. Accepts a semantic "system of use" label (e.g. `'sentient'`, `'memory'`)
|
|
14
|
+
* instead of raw role names — insulating call-sites from config vocabulary.
|
|
15
|
+
* 2. Maps the system label to the canonical {@link RoleName} via
|
|
16
|
+
* {@link SYSTEM_ROLE_MAP} (overridable by `opts.roleOverride`).
|
|
17
|
+
* 3. Delegates to `resolveLLMForRole` for the full 5-tier config +
|
|
18
|
+
* CredentialPool resolution chain — no duplication.
|
|
19
|
+
* 4. When resolution lands on `implicit-fallback`, replaces the hardcoded
|
|
20
|
+
* haiku literal with the SSoT default model from the provider registry
|
|
21
|
+
* (`getProviderProfile(provider).defaultModel`) — satisfying the
|
|
22
|
+
* "not hardcoded" acceptance criterion.
|
|
23
|
+
*
|
|
24
|
+
* ## What this is NOT
|
|
25
|
+
*
|
|
26
|
+
* - A replacement for `resolveLLMForRole`. Existing callers of
|
|
27
|
+
* `resolveLLMForRole` continue to work unchanged; T11757 will migrate them
|
|
28
|
+
* to this chokepoint incrementally.
|
|
29
|
+
* - A new credential store or provider registry. All credential I/O goes
|
|
30
|
+
* through the existing CredentialPool (E3 pool) inside `resolveLLMForRole`.
|
|
31
|
+
*
|
|
32
|
+
* @module llm/system-resolver
|
|
33
|
+
* @task T11749
|
|
34
|
+
* @epic T11745
|
|
35
|
+
*/
|
|
36
|
+
import { SYSTEM_ROLE_MAP } from '@cleocode/contracts';
|
|
37
|
+
import { getLogger } from '../logger.js';
|
|
38
|
+
import { IMPLICIT_FALLBACK_PROVIDER, resolveLLMForRole, } from './role-resolver.js';
|
|
39
|
+
const logger = getLogger('llm-system-resolver');
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// Internal helpers
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
/**
|
|
44
|
+
* Map a {@link SystemOfUse} to the {@link RoleName} that `resolveLLMForRole`
|
|
45
|
+
* will use for config lookup.
|
|
46
|
+
*
|
|
47
|
+
* Priority:
|
|
48
|
+
* 1. `opts.roleOverride` — explicit caller override.
|
|
49
|
+
* 2. {@link SYSTEM_ROLE_MAP} — static default for the system label.
|
|
50
|
+
*
|
|
51
|
+
* Returns `null` when the system maps to the global default (no role entry).
|
|
52
|
+
*/
|
|
53
|
+
function deriveRole(system, opts) {
|
|
54
|
+
if (opts?.roleOverride)
|
|
55
|
+
return opts.roleOverride;
|
|
56
|
+
return SYSTEM_ROLE_MAP[system] ?? null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* When `resolveLLMForRole` returns `source === 'implicit-fallback'`, the
|
|
60
|
+
* model is the hardcoded `IMPLICIT_FALLBACK_MODEL` literal. This function
|
|
61
|
+
* replaces it with the SSoT `defaultModel` from the provider registry so
|
|
62
|
+
* the resolved model tracks catalog updates rather than a frozen constant.
|
|
63
|
+
*
|
|
64
|
+
* On any lookup error the original `resolved` envelope is returned unchanged
|
|
65
|
+
* so the caller is never blocked — graceful degradation is preserved.
|
|
66
|
+
*
|
|
67
|
+
* @param resolved - The envelope returned by `resolveLLMForRole`.
|
|
68
|
+
* @returns The same envelope, possibly with `model` replaced from the registry.
|
|
69
|
+
*/
|
|
70
|
+
async function upgradeCatalogDefault(resolved) {
|
|
71
|
+
if (resolved.source !== 'implicit-fallback') {
|
|
72
|
+
// Not a fallback — the user explicitly configured a model; respect it.
|
|
73
|
+
return resolved;
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
// Lazy import to avoid pulling the full registry chain at module-init time.
|
|
77
|
+
const { getProviderProfile } = await import('./provider-registry/index.js');
|
|
78
|
+
const profile = await getProviderProfile(resolved.provider);
|
|
79
|
+
if (!profile?.defaultModel) {
|
|
80
|
+
// Registry has no default for this provider — fall back to the existing model.
|
|
81
|
+
return resolved;
|
|
82
|
+
}
|
|
83
|
+
if (profile.defaultModel === resolved.model) {
|
|
84
|
+
// Already the same — no mutation needed.
|
|
85
|
+
return resolved;
|
|
86
|
+
}
|
|
87
|
+
logger.debug({ provider: resolved.provider, from: resolved.model, to: profile.defaultModel }, 'system-resolver: upgrading implicit-fallback model to catalog default');
|
|
88
|
+
return { ...resolved, model: profile.defaultModel };
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
logger.warn({ err: err instanceof Error ? err.message : String(err) }, 'system-resolver: catalog default lookup failed; keeping existing fallback model');
|
|
92
|
+
return resolved;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
// Public API
|
|
97
|
+
// ---------------------------------------------------------------------------
|
|
98
|
+
/**
|
|
99
|
+
* Resolve the LLM client + credential for a semantic system-of-use label.
|
|
100
|
+
*
|
|
101
|
+
* This is the single DRY chokepoint for all LLM resolution in CLEO (E9 ·
|
|
102
|
+
* T11745). It wraps `resolveLLMForRole` with:
|
|
103
|
+
*
|
|
104
|
+
* - System label → role mapping (via {@link SYSTEM_ROLE_MAP}).
|
|
105
|
+
* - SSoT default model from the provider registry when `implicit-fallback`
|
|
106
|
+
* is reached (the hardcoded haiku literal is NOT used as the final model).
|
|
107
|
+
* - Full CredentialPool (E3) binding via `resolveLLMForRole` delegation.
|
|
108
|
+
*
|
|
109
|
+
* Like `resolveLLMForRole`, this function **never throws**: when no credential
|
|
110
|
+
* is reachable the caller receives `{ credential: null, client: null, … }` and
|
|
111
|
+
* is responsible for its own graceful-degradation path.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* const resolved = await resolveLLMForSystem('sentient', { projectRoot });
|
|
116
|
+
* if (!resolved.credential?.apiKey || !resolved.client) {
|
|
117
|
+
* return null; // graceful no-op — no credential available
|
|
118
|
+
* }
|
|
119
|
+
* // Use resolved.model, resolved.client, resolved.credential
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* @param system - Semantic label for the subsystem requesting an LLM client.
|
|
123
|
+
* @param opts - Optional overrides (project root, role override, skipCatalogDefault).
|
|
124
|
+
* @returns A {@link ResolvedLLMForSystem} envelope; never throws.
|
|
125
|
+
*
|
|
126
|
+
* @task T11749
|
|
127
|
+
* @epic T11745
|
|
128
|
+
*/
|
|
129
|
+
export async function resolveLLMForSystem(system, opts) {
|
|
130
|
+
const resolvedRole = deriveRole(system, opts);
|
|
131
|
+
// When the role is null (system === 'default'), fall back to treating it as
|
|
132
|
+
// the 'consolidation' role — this exercises the same config tiers as all
|
|
133
|
+
// other roles (roles[role] → default → defaultProfile → implicit-fallback)
|
|
134
|
+
// and avoids a special code path. If `config.llm.roles['consolidation']` is
|
|
135
|
+
// not set, resolution cascades to `config.llm.default` and then the catalog
|
|
136
|
+
// default exactly as desired.
|
|
137
|
+
const roleForResolution = resolvedRole ?? 'consolidation';
|
|
138
|
+
let base;
|
|
139
|
+
try {
|
|
140
|
+
base = await resolveLLMForRole(roleForResolution, {
|
|
141
|
+
projectRoot: opts?.projectRoot,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
// Mirror role-resolver's never-throw contract: return a null-credential
|
|
146
|
+
// envelope on unexpected failure.
|
|
147
|
+
logger.warn({ err: err instanceof Error ? err.message : String(err), system, role: roleForResolution }, 'system-resolver: resolveLLMForRole threw unexpectedly; returning null-credential envelope');
|
|
148
|
+
base = {
|
|
149
|
+
provider: IMPLICIT_FALLBACK_PROVIDER,
|
|
150
|
+
model: 'unknown',
|
|
151
|
+
client: null,
|
|
152
|
+
credential: null,
|
|
153
|
+
source: 'implicit-fallback',
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
// Upgrade the implicit-fallback model to the SSoT catalog default unless
|
|
157
|
+
// the caller asked to skip the catalog lookup (e.g., in tests).
|
|
158
|
+
const upgraded = opts?.skipCatalogDefault ? base : await upgradeCatalogDefault(base);
|
|
159
|
+
return {
|
|
160
|
+
...upgraded,
|
|
161
|
+
system,
|
|
162
|
+
resolvedRole,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=system-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-resolver.js","sourceRoot":"","sources":["../../src/llm/system-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EACL,0BAA0B,EAE1B,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,GAAG,SAAS,CAAC,qBAAqB,CAAC,CAAC;AA4BhD,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E;;;;;;;;;GASG;AACH,SAAS,UAAU,CAAC,MAAmB,EAAE,IAAiC;IACxE,IAAI,IAAI,EAAE,YAAY;QAAE,OAAO,IAAI,CAAC,YAAY,CAAC;IACjD,OAAO,eAAe,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;AACzC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,KAAK,UAAU,qBAAqB,CAAC,QAAqB;IACxD,IAAI,QAAQ,CAAC,MAAM,K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EAA4E;IAC5E,yEAAyE;IACzE,2EAA2E;IAC3E,4EAA4E;IAC5E,4EAA4E;IAC5E,8BAA8B;IAC9B,MAAM,iBAAiB,GAAa,YAAY,IAAI,eAAe,CAAC;IAEpE,IAAI,IAAiB,CAAC;IACtB,IAAI,CAAC;QACH,IAAI,GAAG,MAAM,iBAAiB,CAAC,iBAAiB,EAAE;YAChD,WAAW,EAAE,IAAI,EAAE,WAAW;SAC/B,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,wEAAwE;QACxE,kCAAkC;QAClC,MAAM,CAAC,IAAI,CACT,EAAE,GAAG,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,EAC1F,2FAA2F,CAC5F,CAAC;QACF,IAAI,GAAG;YACL,QAAQ,EAAE,0BAA0B;YACpC,KAAK,EAAE,SAAS;YAChB,MAAM,EAAE,IAAI;YACZ,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,mBAAmB;SAC5B,CAAC;IACJ,CAAC;IAED,yEAAyE;IACzE,gEAAgE;IAChE,MAAM,QAAQ,GAAG,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAErF,OAAO;QACL,GAAG,QAAQ;QACX,MAAM;QACN,YAAY;KACb,CAAC;AACJ,CAAC"}
|
|
@@ -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;;;;;;;;;;;;;;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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+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ACpB,gBAAgB,EAAE,GAAG;gBACrB,kBAAkB,EAAE,CAAC;gBACrB,YAAY,EAAE,IAAI;aACnB,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,gEAAgE;QAClE,CAAC;IACH,CAAC;IAED,4EAA4E;IAC5E,oEAAoE;IACpE,4EAA4E;IAC5E,KAAK,MAAM,OAAO,IAAI,QAAQ,CAAC,YAAY,EAAE,CAAC;QAC5C,IAAI,CAAC;YACH,MAAM,YAAY,CAAC,WAAW,EAAE;gBAC9B,IAAI,EAAE,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"}
|