@remnic/core 9.23.0 → 9.23.2
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/access-admin-ops-surface.js +9 -9
- package/dist/access-audit.js +2 -2
- package/dist/access-boundary.js +9 -9
- package/dist/access-cli.js +32 -31
- package/dist/access-cli.js.map +1 -1
- package/dist/access-http.js +16 -16
- package/dist/access-identity-continuity-surface.js +9 -9
- package/dist/access-lcm-surface.js +9 -9
- package/dist/access-mcp.js +13 -13
- package/dist/access-namespace-preflight.js +9 -9
- package/dist/access-observe-write-surface.js +9 -9
- package/dist/access-operations-batch.js +10 -10
- package/dist/access-operations.js +12 -12
- package/dist/access-recall-concurrency.js +9 -9
- package/dist/access-recall-response.js +9 -9
- package/dist/access-recall-surface.js +9 -9
- package/dist/access-schema.js +3 -3
- package/dist/access-service.js +9 -9
- package/dist/adapters/index.js +4 -4
- package/dist/adapters/registry.js +2 -2
- package/dist/{chunk-G2NSSQES.js → chunk-3L5O7SMT.js} +3 -3
- package/dist/{chunk-JVGUY2AU.js → chunk-4PQ4KLLK.js} +2 -2
- package/dist/{chunk-JBPKEARU.js → chunk-AU7Q3LSC.js} +4 -4
- package/dist/{chunk-WS32QRLO.js → chunk-DLKRXYRL.js} +6 -6
- package/dist/{chunk-IU3XJAQM.js → chunk-FGBJBYWP.js} +2 -2
- package/dist/{chunk-A2RFKL3V.js → chunk-GBAJCDTW.js} +2 -2
- package/dist/{chunk-RT4TSR2C.js → chunk-HSSIWAZP.js} +25 -25
- package/dist/{chunk-KQAFEZQX.js → chunk-IPLYGWQF.js} +5 -5
- package/dist/chunk-JUXOTY6J.js +67 -0
- package/dist/chunk-JUXOTY6J.js.map +1 -0
- package/dist/{chunk-ROUL7RZU.js → chunk-KXGE7L62.js} +17 -17
- package/dist/{chunk-OUW4PAY4.js → chunk-M6LJXJ3J.js} +3 -3
- package/dist/{chunk-2PHX3I5C.js → chunk-MAXVH44E.js} +5 -5
- package/dist/{chunk-YWJBAHTY.js → chunk-P2OZKKYP.js} +10 -12
- package/dist/chunk-P2OZKKYP.js.map +1 -0
- package/dist/{chunk-7K5Q6COX.js → chunk-TVVEYCNW.js} +4 -4
- package/dist/{chunk-HBYQAOED.js → chunk-V2XVMCP6.js} +2 -2
- package/dist/{chunk-IIXLB5E7.js → chunk-WZVIB5BK.js} +15 -15
- package/dist/{chunk-KNRG6ZGJ.js → chunk-XGEFGNL5.js} +1 -1
- package/dist/cli.js +21 -21
- package/dist/extraction.js +3 -2
- package/dist/{first-start-migration-BKNGOFED.js → first-start-migration-LEXL3XYL.js} +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +61 -60
- package/dist/lcm/engine.js +2 -2
- package/dist/lcm/index.js +5 -5
- package/dist/local-llm-transport.d.ts +55 -0
- package/dist/local-llm-transport.js +9 -0
- package/dist/local-llm-transport.js.map +1 -0
- package/dist/local-llm.d.ts +1 -0
- package/dist/local-llm.js +2 -1
- package/dist/operator-toolkit.js +1 -1
- package/dist/orchestrator.js +32 -31
- package/dist/schemas.d.ts +22 -22
- package/dist/summarizer.js +3 -2
- package/dist/transfer/autodetect.js +1 -1
- package/dist/transfer/backup.js +1 -1
- package/dist/transfer/capsule-export.js +2 -2
- package/dist/transfer/types.d.ts +12 -12
- package/package.json +3 -2
- package/src/activity/scheduler.test.ts +14 -1
- package/src/local-llm-headers-timeout.test.ts +271 -0
- package/src/local-llm-transport.ts +109 -0
- package/src/local-llm.ts +6 -13
- package/dist/chunk-YWJBAHTY.js.map +0 -1
- /package/dist/{chunk-G2NSSQES.js.map → chunk-3L5O7SMT.js.map} +0 -0
- /package/dist/{chunk-JVGUY2AU.js.map → chunk-4PQ4KLLK.js.map} +0 -0
- /package/dist/{chunk-JBPKEARU.js.map → chunk-AU7Q3LSC.js.map} +0 -0
- /package/dist/{chunk-WS32QRLO.js.map → chunk-DLKRXYRL.js.map} +0 -0
- /package/dist/{chunk-IU3XJAQM.js.map → chunk-FGBJBYWP.js.map} +0 -0
- /package/dist/{chunk-A2RFKL3V.js.map → chunk-GBAJCDTW.js.map} +0 -0
- /package/dist/{chunk-RT4TSR2C.js.map → chunk-HSSIWAZP.js.map} +0 -0
- /package/dist/{chunk-KQAFEZQX.js.map → chunk-IPLYGWQF.js.map} +0 -0
- /package/dist/{chunk-ROUL7RZU.js.map → chunk-KXGE7L62.js.map} +0 -0
- /package/dist/{chunk-OUW4PAY4.js.map → chunk-M6LJXJ3J.js.map} +0 -0
- /package/dist/{chunk-2PHX3I5C.js.map → chunk-MAXVH44E.js.map} +0 -0
- /package/dist/{chunk-7K5Q6COX.js.map → chunk-TVVEYCNW.js.map} +0 -0
- /package/dist/{chunk-HBYQAOED.js.map → chunk-V2XVMCP6.js.map} +0 -0
- /package/dist/{chunk-IIXLB5E7.js.map → chunk-WZVIB5BK.js.map} +0 -0
- /package/dist/{chunk-KNRG6ZGJ.js.map → chunk-XGEFGNL5.js.map} +0 -0
- /package/dist/{first-start-migration-BKNGOFED.js.map → first-start-migration-LEXL3XYL.js.map} +0 -0
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-D24OXEPB.js";
|
|
7
7
|
import {
|
|
8
8
|
validateRequest
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-V2XVMCP6.js";
|
|
10
10
|
import {
|
|
11
11
|
REMNIC_CHATGPT_MEMORY_INSPECTOR_MIME_TYPE,
|
|
12
12
|
REMNIC_CHATGPT_MEMORY_INSPECTOR_TOOL,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
} from "./chunk-TWCOYET2.js";
|
|
23
23
|
import {
|
|
24
24
|
getOperation
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-WZVIB5BK.js";
|
|
26
26
|
import {
|
|
27
27
|
assertOperationAllowed,
|
|
28
28
|
capabilityAllowsOp,
|
|
@@ -3732,4 +3732,4 @@ export {
|
|
|
3732
3732
|
MCP_SUPPORTED_PROTOCOL_VERSIONS,
|
|
3733
3733
|
EngramMcpServer
|
|
3734
3734
|
};
|
|
3735
|
-
//# sourceMappingURL=chunk-
|
|
3735
|
+
//# sourceMappingURL=chunk-M6LJXJ3J.js.map
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ensureLcmStateDir,
|
|
3
|
+
openLcmDatabase
|
|
4
|
+
} from "./chunk-DDA47TES.js";
|
|
1
5
|
import {
|
|
2
6
|
LcmSummarizer
|
|
3
7
|
} from "./chunk-PBGWYM3H.js";
|
|
@@ -13,10 +17,6 @@ import {
|
|
|
13
17
|
import {
|
|
14
18
|
assembleCompressedHistoryWithTrace
|
|
15
19
|
} from "./chunk-UXPUUL3G.js";
|
|
16
|
-
import {
|
|
17
|
-
ensureLcmStateDir,
|
|
18
|
-
openLcmDatabase
|
|
19
|
-
} from "./chunk-DDA47TES.js";
|
|
20
20
|
import {
|
|
21
21
|
log
|
|
22
22
|
} from "./chunk-3WCASNQZ.js";
|
|
@@ -526,4 +526,4 @@ export {
|
|
|
526
526
|
extractLcmConfig,
|
|
527
527
|
LcmEngine
|
|
528
528
|
};
|
|
529
|
-
//# sourceMappingURL=chunk-
|
|
529
|
+
//# sourceMappingURL=chunk-MAXVH44E.js.map
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChatTransport
|
|
3
|
+
} from "./chunk-JUXOTY6J.js";
|
|
1
4
|
import {
|
|
2
5
|
launchProcessSync
|
|
3
6
|
} from "./chunk-O75CRYGF.js";
|
|
@@ -165,6 +168,7 @@ var LocalLlmClient = class _LocalLlmClient {
|
|
|
165
168
|
// 1 minute
|
|
166
169
|
static LMS_CACHE_INTERVAL_MS = 3e4;
|
|
167
170
|
// 30 seconds
|
|
171
|
+
chatTransport = new ChatTransport();
|
|
168
172
|
constructor(config, modelRegistry) {
|
|
169
173
|
this.config = config;
|
|
170
174
|
this.modelRegistry = modelRegistry;
|
|
@@ -748,13 +752,6 @@ var LocalLlmClient = class _LocalLlmClient {
|
|
|
748
752
|
`local LLM: sending request to ${chatUrl} with model ${this.config.localLlmModel}`
|
|
749
753
|
);
|
|
750
754
|
log.debug(`local LLM: request body length=${requestBodyJson.length}`);
|
|
751
|
-
if (this.config.debug) {
|
|
752
|
-
try {
|
|
753
|
-
const { writeFileSync } = await import("fs");
|
|
754
|
-
writeFileSync("/tmp/engram-last-request.json", requestBodyJson);
|
|
755
|
-
} catch {
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
755
|
const effectiveTimeoutMs = typeof options.timeoutMs === "number" ? Math.min(this.config.localLlmTimeoutMs, options.timeoutMs) : this.config.localLlmTimeoutMs;
|
|
759
756
|
const maxAttempts = 1 + Math.max(0, this.config.localLlmRetry5xxCount);
|
|
760
757
|
let response = null;
|
|
@@ -763,13 +760,14 @@ var LocalLlmClient = class _LocalLlmClient {
|
|
|
763
760
|
const attemptAbort = new AbortController();
|
|
764
761
|
const attemptTimeout = setTimeout(() => attemptAbort.abort(), effectiveTimeoutMs);
|
|
765
762
|
try {
|
|
766
|
-
response = await
|
|
767
|
-
|
|
763
|
+
response = await this.chatTransport.post({
|
|
764
|
+
url: chatUrl,
|
|
768
765
|
headers: this.buildRequestHeaders({
|
|
769
766
|
"Content-Type": "application/json"
|
|
770
767
|
}),
|
|
771
|
-
body:
|
|
772
|
-
signal: attemptAbort.signal
|
|
768
|
+
body: requestBodyJson,
|
|
769
|
+
signal: attemptAbort.signal,
|
|
770
|
+
budgetMs: this.config.localLlmTimeoutMs
|
|
773
771
|
});
|
|
774
772
|
} catch (err) {
|
|
775
773
|
if (!this.isAbortError(err)) throw err;
|
|
@@ -1083,4 +1081,4 @@ var LocalLlmClient = class _LocalLlmClient {
|
|
|
1083
1081
|
export {
|
|
1084
1082
|
LocalLlmClient
|
|
1085
1083
|
};
|
|
1086
|
-
//# sourceMappingURL=chunk-
|
|
1084
|
+
//# sourceMappingURL=chunk-P2OZKKYP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/local-llm.ts"],"sourcesContent":["import { log } from \"./logger.js\";\nimport type { PluginConfig } from \"./types.js\";\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport type { ModelRegistry } from \"./model-registry.js\";\nimport { launchProcessSync } from \"./runtime/child-process.js\";\nimport { mergeEnv, readEnvVar } from \"./runtime/env.js\";\nimport { resolveLocalLlmCapabilities } from \"./capabilities.js\";\nimport { resolvePipelineProcessingCapabilities } from \"./capabilities.js\";\nimport { ChatTransport } from \"./local-llm-transport.js\";\n\n/** Trim trailing slash characters without backtracking regex. */\nfunction trimTrailingSlashes(s: string): string {\n let end = s.length;\n while (end > 0 && s[end - 1] === \"/\") end--;\n return s.substring(0, end);\n}\n\nfunction stripTrailingV1Path(s: string): string {\n return s.endsWith(\"/v1\") ? s.slice(0, -3) : s;\n}\n\nfunction explicitPortFromUrl(s: string): number | null {\n try {\n const parsed = new URL(s);\n if (!parsed.port) return null;\n const port = Number(parsed.port);\n return Number.isInteger(port) ? port : null;\n } catch {\n return null;\n }\n}\n\nfunction isObjectRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nfunction isLlamaCppPropsResponse(value: unknown): boolean {\n return (\n isObjectRecord(value) &&\n isObjectRecord(value.default_generation_settings) &&\n typeof value.total_slots === \"number\" &&\n (\n typeof value.model_path === \"string\" ||\n typeof value.chat_template === \"string\" ||\n typeof value.build_info === \"string\"\n )\n );\n}\n\nfunction isLlamaCppModelsResponse(value: unknown): boolean {\n if (!isObjectRecord(value) || !Array.isArray(value.data)) {\n return false;\n }\n return value.data.some((entry) => {\n if (!isObjectRecord(entry)) return false;\n if (entry.owned_by === \"llamacpp\") return true;\n if (typeof entry.id === \"string\" && entry.id.endsWith(\".gguf\")) return true;\n const meta = entry.meta;\n return (\n isObjectRecord(meta) &&\n (\"n_ctx_train\" in meta || \"n_params\" in meta || \"vocab_type\" in meta)\n );\n });\n}\n\nfunction isLmStudioApiV1ModelsResponse(value: unknown): boolean {\n if (!isObjectRecord(value) || !Array.isArray(value.models)) {\n return false;\n }\n return value.models.some((entry) => {\n if (!isObjectRecord(entry)) return false;\n return (\n typeof entry.key === \"string\" &&\n typeof entry.display_name === \"string\" &&\n (\n typeof entry.format === \"string\" ||\n typeof entry.max_context_length === \"number\" ||\n Array.isArray(entry.loaded_instances)\n )\n );\n });\n}\n\nfunction isLmStudioApiV0ModelsResponse(value: unknown): boolean {\n if (!isObjectRecord(value) || !Array.isArray(value.data)) {\n return false;\n }\n return value.data.some((entry) => {\n if (!isObjectRecord(entry)) return false;\n return (\n typeof entry.id === \"string\" &&\n typeof entry.publisher === \"string\" &&\n (\n typeof entry.compatibility_type === \"string\" ||\n typeof entry.max_context_length === \"number\" ||\n typeof entry.state === \"string\"\n )\n );\n });\n}\n\nfunction isLmStudioNativeModelsResponse(value: unknown): boolean {\n return isLmStudioApiV1ModelsResponse(value) || isLmStudioApiV0ModelsResponse(value);\n}\n\n/**\n * Local LLM client for OpenAI-compatible endpoints (LM Studio, Ollama, MLX, etc.)\n *\n * Based on openclaw-tactician's provider detection patterns for consistency.\n * Provides privacy-preserving, cost-effective LLM operations with\n * graceful fallback to cloud providers when local LLM is unavailable.\n */\nexport type LocalLlmType = \"lmstudio\" | \"ollama\" | \"mlx\" | \"vllm\" | \"llamacpp\" | \"generic\";\n\n/**\n * Backends known to honor `chat_template_kwargs: { enable_thinking: false }`\n * on OpenAI-compatible `/v1/chat/completions`. LM Studio, vLLM, and\n * llama.cpp forward this field to the jinja chat template, where thinking-capable\n * models (Qwen 3.5, Gemma 4, DeepSeek) suppress reasoning tokens.\n *\n * Strict OpenAI-compatible backends (standard OpenAI, Azure OpenAI, some\n * proxies) reject unknown request fields with 400 — which trips the\n * `localLlm400*` cooldown path. `LocalLlmClient` therefore only injects\n * the kwarg when the detected backend is in this set; unknown / `generic`\n * / `ollama` / `mlx` fail open (no injection, no 400 risk). Issue #548.\n */\nconst THINKING_COMPATIBLE_BACKENDS: ReadonlySet<LocalLlmType> = new Set([\n \"lmstudio\",\n \"vllm\",\n \"llamacpp\",\n]);\n\nconst THINKING_SUPPRESSED_OPERATIONS: ReadonlySet<string> = new Set([\n \"extraction\",\n \"extraction-judge\",\n \"extraction-faithfulness\",\n \"contradiction-judge\",\n \"contradiction_verification\",\n \"link_suggestion\",\n \"memory_summarization\",\n \"proactive_extraction\",\n \"lcm-summarize\",\n \"day_summary\",\n \"hourly_summary\",\n \"hourly_summary_extended\",\n]);\n\ninterface LocalServerConfig {\n type: LocalLlmType;\n defaultPort: number;\n healthEndpoint: string;\n modelsEndpoint: string;\n detectFn: (response: unknown) => boolean;\n}\n\nconst LOCAL_SERVERS: LocalServerConfig[] = [\n {\n type: \"ollama\",\n defaultPort: 11434,\n healthEndpoint: \"/\",\n modelsEndpoint: \"/api/tags\",\n detectFn: (resp) => typeof resp === \"string\" && resp.includes(\"Ollama\"),\n },\n {\n type: \"llamacpp\",\n defaultPort: 8080,\n healthEndpoint: \"/health\",\n modelsEndpoint: \"/v1/models\",\n detectFn: (resp) => isObjectRecord(resp) && resp.status === \"ok\",\n },\n {\n type: \"mlx\",\n defaultPort: 8080,\n healthEndpoint: \"/v1/models\",\n modelsEndpoint: \"/v1/models\",\n detectFn: (resp) => isObjectRecord(resp) && Array.isArray(resp.data),\n },\n {\n type: \"lmstudio\",\n defaultPort: 1234,\n healthEndpoint: \"/v1/models\",\n modelsEndpoint: \"/v1/models\",\n detectFn: (resp) => isObjectRecord(resp) && Array.isArray(resp.data),\n },\n {\n type: \"vllm\",\n defaultPort: 8000,\n healthEndpoint: \"/health\",\n modelsEndpoint: \"/v1/models\",\n detectFn: (resp) => resp === \"\" || (isObjectRecord(resp) && !(\"status\" in resp)),\n },\n];\n\nfunction orderedLocalServers(configuredBaseUrl: string): LocalServerConfig[] {\n const configuredPort = explicitPortFromUrl(configuredBaseUrl);\n if (configuredPort === null) return LOCAL_SERVERS;\n const matching = LOCAL_SERVERS.filter(\n (serverConfig) => serverConfig.defaultPort === configuredPort,\n );\n if (matching.length === 0) return LOCAL_SERVERS;\n const matchingTypes = new Set(matching.map((serverConfig) => serverConfig.type));\n return [\n ...matching,\n ...LOCAL_SERVERS.filter((serverConfig) => !matchingTypes.has(serverConfig.type)),\n ];\n}\n\nexport interface LocalModelInfo {\n id: string;\n contextWindow?: number;\n maxTokens?: number;\n}\n\nexport type LocalLlmRequestPriority = \"recall-critical\" | \"background\";\n\ninterface LocalLlmChatCompletionOptions {\n temperature?: number;\n maxTokens?: number;\n responseFormat?: { type: string };\n timeoutMs?: number;\n operation?: string;\n forceDisableThinking?: boolean;\n disableThinking?: boolean;\n priority?: LocalLlmRequestPriority;\n}\n\ninterface LocalLlmQueuedRequest {\n messages: Array<{ role: string; content: string }>;\n options: LocalLlmChatCompletionOptions;\n priority: LocalLlmRequestPriority;\n enqueuedAtMs: number;\n resolve: (value: LocalLlmChatCompletionResult | null) => void;\n}\n\ninterface LocalLlmChatCompletionResult {\n content: string;\n usage?: { promptTokens: number; completionTokens: number; totalTokens: number };\n}\n\nconst LOCAL_LLM_GLOBAL_BACKEND_STATE = \"__openclawEngramLocalLlmBackendState\";\n\ntype LocalLlmBackendState = {\n untilMs: number;\n reason: string;\n};\nexport class LocalLlmClient {\n private config: PluginConfig;\n private isAvailable: boolean | null = null;\n private lastHealthCheck: number = 0;\n private detectedType: LocalLlmType | null = null;\n private cachedModelInfo: LocalModelInfo | null = null;\n private cachedLmsContext: number | null = null;\n private lastLmsCheck: number = 0;\n private consecutive400s: number = 0;\n private cooldownUntilMs: number = 0;\n private modelRegistry?: ModelRegistry;\n private _disableThinking: boolean = false;\n private readonly requestQueues: Record<LocalLlmRequestPriority, LocalLlmQueuedRequest[]> = {\n \"recall-critical\": [],\n background: [],\n };\n private readonly queueProcessing = new Set<LocalLlmRequestPriority>();\n private queueDrainScheduled: boolean = false;\n private static readonly HEALTH_CHECK_INTERVAL_MS = 60000; // 1 minute\n private static readonly LMS_CACHE_INTERVAL_MS = 30000; // 30 seconds\n private readonly chatTransport = new ChatTransport();\n\n constructor(config: PluginConfig, modelRegistry?: ModelRegistry) {\n this.config = config;\n this.modelRegistry = modelRegistry;\n }\n\n /**\n * Request thinking/reasoning suppression on the next chat completion.\n *\n * When `true`, the client will inject\n * `chat_template_kwargs: { enable_thinking: false }` into the request\n * body — **but only when the detected backend is known to support it**\n * (LM Studio, vLLM; see `THINKING_COMPATIBLE_BACKENDS`). Strict\n * OpenAI-compat backends reject unknown fields with 400; on those the\n * client fails open (thinking runs normally). This is the safe\n * default for Remnic extraction-style operations: measurable latency\n * win on thinking-capable backends, zero risk on others. Consolidation\n * operations keep thinking enabled unless explicitly added to\n * `THINKING_SUPPRESSED_OPERATIONS`. Issues #548 and #979.\n */\n set disableThinking(value: boolean) {\n this._disableThinking = value;\n }\n\n private resolveHomeDir(): string {\n return this.config.localLlmHomeDir || readEnvVar(\"HOME\") || os.homedir();\n }\n\n private buildRequestHeaders(base: Record<string, string> = {}): Record<string, string> {\n const headers: Record<string, string> = {\n ...base,\n ...(this.config.localLlmHeaders ?? {}),\n };\n if (this.config.localLlmApiKey && this.config.localLlmAuthHeader !== false) {\n headers.Authorization = `Bearer ${this.config.localLlmApiKey}`;\n }\n return headers;\n }\n\n private isAbortError(err: unknown): boolean {\n if (!err || typeof err !== \"object\") return false;\n const maybe = err as { name?: string; message?: string };\n return (\n maybe.name === \"AbortError\" ||\n maybe.message === \"This operation was aborted\" ||\n maybe.message === \"The operation was aborted\"\n );\n }\n\n /**\n * Set the ModelRegistry for caching detected capabilities\n */\n setModelRegistry(registry: ModelRegistry): void {\n this.modelRegistry = registry;\n }\n\n /**\n * Get the detected server type (null if not detected)\n */\n getDetectedType(): LocalLlmType | null {\n return this.detectedType;\n }\n\n private getBackendKey(): string {\n return trimTrailingSlashes(\n this.config.localLlmUrl.replace(\"localhost\", \"127.0.0.1\"),\n ).replace(/\\/v1$/, \"\");\n }\n\n private getGlobalBackendState(): Map<string, LocalLlmBackendState> {\n const globalAny = globalThis as typeof globalThis & {\n [LOCAL_LLM_GLOBAL_BACKEND_STATE]?: Map<string, LocalLlmBackendState>;\n };\n if (!globalAny[LOCAL_LLM_GLOBAL_BACKEND_STATE]) {\n globalAny[LOCAL_LLM_GLOBAL_BACKEND_STATE] = new Map();\n }\n return globalAny[LOCAL_LLM_GLOBAL_BACKEND_STATE];\n }\n\n private getTrippedBackendState(now: number): LocalLlmBackendState | null {\n const state = this.getGlobalBackendState().get(this.getBackendKey()) ?? null;\n if (!state) return null;\n if (state.untilMs <= now) {\n this.getGlobalBackendState().delete(this.getBackendKey());\n this.lastHealthCheck = 0;\n return null;\n }\n return state;\n }\n\n private markBackendUnavailable(reason: string, durationMs: number): void {\n const normalizedReason = this.normalizeBackendTripReason(reason);\n if (durationMs > 0) {\n const untilMs = Date.now() + durationMs;\n this.getGlobalBackendState().set(this.getBackendKey(), { untilMs, reason: normalizedReason });\n } else {\n this.getGlobalBackendState().delete(this.getBackendKey());\n }\n this.isAvailable = false;\n this.lastHealthCheck = 0;\n log.warn(\n `local LLM backend unavailable for ${durationMs}ms: model=${this.config.localLlmModel} reason=${normalizedReason}`,\n );\n }\n\n private extractNonRecoverableBackendReason(reason: string): string | null {\n const match = reason.match(\n /Failed to load model|Library not loaded|different Team IDs|code signature|llm_engine_mlx_amphibian/i,\n );\n return match?.[0] ?? null;\n }\n\n private extractNonRecoverableBackendReasonFromErrorText(errorText: string): string | null {\n const directReason = this.extractNonRecoverableBackendReason(errorText);\n if (directReason) return directReason;\n try {\n const parsed = JSON.parse(errorText) as { error?: { message?: string } };\n return this.extractNonRecoverableBackendReason(parsed?.error?.message ?? \"\");\n } catch {\n return null;\n }\n }\n\n private normalizeBackendTripReason(reason: string): string {\n const cleaned = reason.replace(/\\s+/g, \" \").replace(/^[-:–—\\s]+/, \"\").trim();\n if (!cleaned) return \"unknown local backend failure\";\n return cleaned.length > 160 ? `${cleaned.slice(0, 157)}...` : cleaned;\n }\n\n /**\n * Fetch with timeout for health checks\n */\n private async fetchWithTimeout(\n url: string,\n timeoutMs: number = 2000,\n headers?: Record<string, string>,\n ): Promise<{ ok: boolean; data: unknown; status: number | null }> {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), timeoutMs);\n\n try {\n const response = await fetch(url, {\n signal: controller.signal,\n headers: this.buildRequestHeaders({ Accept: \"application/json\", ...(headers ?? {}) }),\n });\n clearTimeout(timeout);\n\n if (!response.ok) {\n return { ok: false, data: null, status: response.status };\n }\n\n const contentType = response.headers.get(\"content-type\");\n if (contentType?.includes(\"application/json\")) {\n return { ok: true, data: await response.json(), status: response.status };\n } else {\n return { ok: true, data: await response.text(), status: response.status };\n }\n } catch (err) {\n clearTimeout(timeout);\n return { ok: false, data: null, status: null };\n }\n }\n\n private async probeLmStudioNativeModels(\n probeBaseUrl: string,\n ): Promise<{ matched: boolean; unauthorized: boolean }> {\n let unauthorized = false;\n for (const endpoint of [\"/api/v1/models\", \"/api/v0/models\"]) {\n const probe = await this.fetchWithTimeout(`${probeBaseUrl}${endpoint}`);\n if (probe.ok && isLmStudioNativeModelsResponse(probe.data)) {\n return { matched: true, unauthorized };\n }\n if (probe.status === 401 || probe.status === 403) {\n unauthorized = true;\n }\n }\n return { matched: false, unauthorized };\n }\n\n /**\n * Check if local LLM is available\n * Uses 127.0.0.1 instead of localhost to avoid DNS issues (consistent with tactician)\n */\n async checkAvailability(): Promise<boolean> {\n // Cache health check results for 1 minute\n const now = Date.now();\n const trippedState = this.getTrippedBackendState(now);\n if (trippedState) {\n this.isAvailable = false;\n this.lastHealthCheck = 0;\n log.info(\n `local LLM availability: backend circuit open for ${Math.max(0, trippedState.untilMs - now)}ms (${trippedState.reason})`,\n );\n return false;\n }\n if (this.isAvailable !== null && now - this.lastHealthCheck < LocalLlmClient.HEALTH_CHECK_INTERVAL_MS) {\n return this.isAvailable;\n }\n\n // Normalize URL - replace localhost with 127.0.0.1, remove trailing slashes.\n // Probe server-native endpoints from the server root even when users configure\n // the OpenAI-compatible `/v1` base URL for chat completions.\n const configuredBaseUrl = trimTrailingSlashes(\n this.config.localLlmUrl.replace(\"localhost\", \"127.0.0.1\"),\n );\n const probeBaseUrl = stripTrailingV1Path(configuredBaseUrl);\n let sawUnauthorizedProbe = false;\n\n // Try to detect which server type is running\n for (const serverConfig of orderedLocalServers(configuredBaseUrl)) {\n const healthUrl = `${probeBaseUrl}${serverConfig.healthEndpoint}`;\n log.debug(`checking ${serverConfig.type} at ${healthUrl}`);\n\n const result = await this.fetchWithTimeout(healthUrl);\n if (result.ok && serverConfig.detectFn(result.data)) {\n if (serverConfig.type === \"mlx\") {\n const lmStudioProbe = await this.probeLmStudioNativeModels(probeBaseUrl);\n if (lmStudioProbe.unauthorized) {\n sawUnauthorizedProbe = true;\n }\n if (lmStudioProbe.matched) {\n this.isAvailable = true;\n this.detectedType = \"lmstudio\";\n this.lastHealthCheck = now;\n log.info(`detected lmstudio at ${configuredBaseUrl}`);\n return true;\n }\n }\n if (serverConfig.type === \"llamacpp\") {\n let sawLlamaCppSignal = false;\n const propsProbe = await this.fetchWithTimeout(`${probeBaseUrl}/props`);\n if (propsProbe.ok && isLlamaCppPropsResponse(propsProbe.data)) {\n sawLlamaCppSignal = true;\n }\n if (propsProbe.status === 401 || propsProbe.status === 403) {\n sawUnauthorizedProbe = true;\n }\n\n const modelsUrl = `${probeBaseUrl}${serverConfig.modelsEndpoint}`;\n const modelsProbe = await this.fetchWithTimeout(modelsUrl);\n if (modelsProbe.ok && isLlamaCppModelsResponse(modelsProbe.data)) {\n sawLlamaCppSignal = true;\n }\n if (modelsProbe.status === 401 || modelsProbe.status === 403) {\n sawUnauthorizedProbe = true;\n continue;\n }\n\n const authConfigured =\n Boolean(this.config.localLlmApiKey) &&\n this.config.localLlmAuthHeader !== false;\n if (!sawLlamaCppSignal || (authConfigured && !modelsProbe.ok)) {\n continue;\n }\n }\n this.isAvailable = true;\n this.detectedType = serverConfig.type;\n this.lastHealthCheck = now;\n log.info(`detected ${serverConfig.type} at ${configuredBaseUrl}`);\n return true;\n }\n if (result.status === 401 || result.status === 403) {\n sawUnauthorizedProbe = true;\n }\n }\n\n // Generic check if specific detection failed\n try {\n const modelsUrl = `${probeBaseUrl}/v1/models`;\n const result = await this.fetchWithTimeout(modelsUrl);\n if (result.ok) {\n this.isAvailable = true;\n this.detectedType = \"generic\";\n this.lastHealthCheck = now;\n log.info(`detected generic OpenAI-compatible server at ${configuredBaseUrl}`);\n return true;\n }\n if (result.status === 401 || result.status === 403) {\n sawUnauthorizedProbe = true;\n }\n } catch {\n // Fall through to unavailable\n }\n\n this.isAvailable = false;\n this.detectedType = null;\n this.lastHealthCheck = now;\n if (sawUnauthorizedProbe) {\n log.warn(\n `local LLM availability probe was unauthorized at ${configuredBaseUrl}; verify localLlmApiKey and localLlmAuthHeader settings`,\n );\n }\n log.debug(\"local LLM not available at\", configuredBaseUrl);\n return false;\n }\n\n /**\n * Try to get context window from LM Studio settings.json as fallback.\n * This reads the defaultContextLength setting which is what LM Studio uses\n * when loading models without explicit context configuration.\n */\n private getContextFromLmStudioSettings(): number | null {\n try {\n const homeDir = this.resolveHomeDir();\n const settingsPath = `${homeDir}/.cache/lm-studio/settings.json`;\n\n if (!fs.existsSync(settingsPath)) {\n log.debug(`LM Studio settings: file not found at ${settingsPath}`);\n return null;\n }\n\n const content = fs.readFileSync(settingsPath, \"utf-8\");\n const settings = JSON.parse(content) as {\n defaultContextLength?: {\n type?: string;\n value?: number;\n };\n };\n\n if (settings.defaultContextLength?.value) {\n const contextWindow = settings.defaultContextLength.value;\n log.debug(`LM Studio settings: found default context length: ${contextWindow}`);\n return contextWindow;\n }\n\n return null;\n } catch (err) {\n const errorMsg = err instanceof Error ? err.message : String(err);\n log.debug(`LM Studio settings: failed to read - ${errorMsg}`);\n return null;\n }\n }\n\n /**\n * Try to get context window from LMS CLI (LM Studio specific).\n * Uses --json flag for reliable parsing.\n * Returns null if LMS CLI is not available or model not found.\n */\n private getContextFromLmsCli(modelId: string): number | null {\n try {\n // Check if lms CLI exists in common locations.\n // HOME may be absent in launchd environments, so prefer the resolved helper.\n const homeDir = this.resolveHomeDir();\n const lmsPaths = [\n this.config.localLmsCliPath || \"\",\n `${homeDir}/.cache/lm-studio/bin/lms`,\n \"/usr/local/bin/lms\",\n \"/opt/homebrew/bin/lms\",\n ];\n\n const lmsPath = lmsPaths.find((p) => p.length > 0 && fs.existsSync(p));\n if (!lmsPath) {\n log.debug(`LMS CLI: not found in standard locations (checked: ${lmsPaths.join(\", \")})`);\n return null;\n }\n\n // Run lms ps --json to get loaded models with context\n // Use spawnSync with shell and explicit PATH to ensure lms can find its dependencies\n log.debug(`LMS CLI: running: ${lmsPath} ps --json`);\n const existingPath = readEnvVar(\"PATH\") || \"\";\n const result = launchProcessSync(lmsPath, [\"ps\", \"--json\"], {\n encoding: \"utf-8\",\n timeout: 5000,\n shell: false, // Don't use shell for JSON output - more reliable\n env: mergeEnv({\n PATH: `${this.config.localLmsBinDir || `${homeDir}/.cache/lm-studio/bin`}:/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin:${existingPath}`,\n HOME: homeDir,\n }),\n });\n\n if (result.error) {\n log.debug(`LMS CLI: spawn error - ${result.error.message}`);\n return null;\n }\n\n if (result.stderr && result.stderr.trim()) {\n log.debug(`LMS CLI: stderr - ${result.stderr.slice(0, 200)}`);\n }\n\n const output = result.stdout || \"\";\n if (!output.trim()) {\n log.debug(\"LMS CLI: empty output - LM Studio may not be running or no models loaded\");\n return null;\n }\n\n // Parse JSON output\n let models: Array<{\n identifier?: string;\n modelKey?: string;\n contextLength?: number;\n maxContextLength?: number;\n }>;\n\n try {\n models = JSON.parse(output) as typeof models;\n } catch (parseErr) {\n log.debug(`LMS CLI: JSON parse error - ${parseErr}`);\n return null;\n }\n\n if (!Array.isArray(models) || models.length === 0) {\n log.debug(\"LMS CLI: no models loaded\");\n return null;\n }\n\n // Find the model matching our configured model ID\n const model = models.find((m) =>\n m.identifier === modelId ||\n m.modelKey === modelId ||\n (m.identifier?.includes(modelId.replace(/@\\d+bit$/, \"\")))\n );\n\n if (!model) {\n log.debug(`LMS CLI: model \"${modelId}\" not found in loaded models: ${models.map(m => m.identifier).join(\", \")}`);\n return null;\n }\n\n // Use contextLength (actual configured) or fall back to maxContextLength (model max)\n const contextWindow = model.contextLength || model.maxContextLength;\n\n if (contextWindow) {\n log.info(`LMS CLI detected context window: ${contextWindow} for ${modelId} (max: ${model.maxContextLength})`);\n return contextWindow;\n }\n\n return null;\n } catch (err) {\n // LMS CLI not available or failed\n const errorMsg = err instanceof Error ? err.message : String(err);\n log.debug(`LMS CLI: failed - ${errorMsg}`);\n return null;\n }\n }\n\n /**\n * Get full model info from LMS CLI including context length and max context length.\n * Returns null if LMS CLI is unavailable or model not found.\n */\n private getLmsModelInfo(modelId: string): { contextLength: number; maxContextLength: number; identifier: string } | null {\n try {\n const result = launchProcessSync(\"lms\", [\"ps\", \"--json\"], {\n encoding: \"utf-8\",\n timeout: 5000,\n shell: false,\n });\n\n if (result.error) {\n return null;\n }\n\n const output = result.stdout || \"\";\n if (!output.trim()) {\n return null;\n }\n\n let models: Array<{\n identifier?: string;\n modelKey?: string;\n contextLength?: number;\n maxContextLength?: number;\n }>;\n\n try {\n models = JSON.parse(output) as typeof models;\n } catch {\n return null;\n }\n\n if (!Array.isArray(models) || models.length === 0) {\n return null;\n }\n\n const model = models.find((m) =>\n m.identifier === modelId ||\n m.modelKey === modelId ||\n (m.identifier?.includes(modelId.replace(/@\\d+bit$/, \"\")))\n );\n\n if (!model || !model.contextLength) {\n return null;\n }\n\n return {\n contextLength: model.contextLength,\n maxContextLength: model.maxContextLength || model.contextLength,\n identifier: model.identifier || modelId,\n };\n } catch {\n return null;\n }\n }\n\n /**\n * Get context window for the configured model, using cache if available.\n * This method caches the result to avoid repeated LMS CLI calls.\n * Order: ModelRegistry (persistent) -> memory cache -> LMS CLI -> settings.json\n */\n getCachedContextWindow(modelId: string): number | null {\n const now = Date.now();\n\n // 1. Check ModelRegistry for persisted context window\n if (this.modelRegistry) {\n const caps = this.modelRegistry.getCapabilities(modelId);\n if (caps.source === \"lmstudio\" && caps.contextWindow) {\n log.debug(`ModelRegistry: using persisted LM Studio context: ${caps.contextWindow}`);\n // Also update memory cache\n this.cachedLmsContext = caps.contextWindow;\n this.lastLmsCheck = now;\n return caps.contextWindow;\n }\n }\n\n // 2. Return in-memory cached value if still valid\n if (this.cachedLmsContext && now - this.lastLmsCheck < LocalLlmClient.LMS_CACHE_INTERVAL_MS) {\n log.debug(`LMS CLI: returning in-memory cached context: ${this.cachedLmsContext}`);\n return this.cachedLmsContext;\n }\n\n // 3. Try LMS CLI (authoritative source)\n const lmsInfo = this.getLmsModelInfo(modelId);\n if (lmsInfo?.contextLength) {\n this.cachedLmsContext = lmsInfo.contextLength;\n this.lastLmsCheck = now;\n // Calculate appropriate output tokens based on context size\n // Use 12.5% of context window, capped at 16K (generous but safe)\n const calculatedOutputTokens = Math.min(Math.floor(lmsInfo.contextLength / 8), 16384);\n const outputTokens = Math.max(calculatedOutputTokens, 4096); // Minimum 4K\n // Persist to ModelRegistry with detected capabilities\n if (this.modelRegistry) {\n this.modelRegistry.setCapabilities(modelId, {\n maxPositionEmbeddings: lmsInfo.maxContextLength || lmsInfo.contextLength,\n contextWindow: lmsInfo.contextLength,\n supportsExtendedContext: (lmsInfo.maxContextLength || lmsInfo.contextLength) > 65536,\n typicalOutputTokens: outputTokens,\n source: \"lmstudio\",\n });\n log.info(`LMS CLI: Stored capabilities for ${modelId}: ${lmsInfo.contextLength} context, ${outputTokens} output tokens`);\n }\n return lmsInfo.contextLength;\n }\n\n // Legacy: Try LMS CLI context only (fallback)\n const legacyContext = this.getContextFromLmsCli(modelId);\n if (legacyContext) {\n this.cachedLmsContext = legacyContext;\n this.lastLmsCheck = now;\n // Persist to ModelRegistry with calculated output tokens\n if (this.modelRegistry) {\n const calculatedOutputTokens = Math.min(Math.floor(legacyContext / 8), 16384);\n const outputTokens = Math.max(calculatedOutputTokens, 4096);\n this.modelRegistry.setCapabilities(modelId, {\n maxPositionEmbeddings: legacyContext,\n contextWindow: legacyContext,\n supportsExtendedContext: false,\n typicalOutputTokens: outputTokens,\n source: \"lmstudio\",\n });\n }\n return legacyContext;\n }\n\n // 4. Fall back to LM Studio settings.json\n const settingsContext = this.getContextFromLmStudioSettings();\n if (settingsContext) {\n log.info(`LM Studio settings: using default context: ${settingsContext}`);\n this.cachedLmsContext = settingsContext;\n this.lastLmsCheck = now;\n return settingsContext;\n }\n\n return null;\n }\n\n /**\n * Clear the LMS context cache. Call this when the model changes.\n */\n clearContextCache(): void {\n this.cachedLmsContext = null;\n this.lastLmsCheck = 0;\n log.debug(\"LMS CLI: context cache cleared\");\n }\n\n private remainingCooldownMs(now: number = Date.now()): number {\n return Math.max(0, this.cooldownUntilMs - now);\n }\n\n private scheduleQueueDrain(): void {\n if (this.queueDrainScheduled) return;\n this.queueDrainScheduled = true;\n\n queueMicrotask(() => {\n this.queueDrainScheduled = false;\n this.startAvailableQueuedRequests();\n });\n }\n\n /** True when a background-priority request occupies or awaits this client's local lane (issue #2011). */\n isBackgroundLaneContended(): boolean {\n return this.queueProcessing.has(\"background\") || this.requestQueues.background.length > 0;\n }\n\n private dequeueQueuedRequest(priority: LocalLlmRequestPriority): LocalLlmQueuedRequest | null {\n const next = this.requestQueues[priority].shift();\n return next ?? null;\n }\n\n private failOpenQueuedRequestsForCooldown(): number {\n let dropped = 0;\n for (const priority of [\"recall-critical\", \"background\"] as const) {\n while (this.requestQueues[priority].length > 0) {\n const queued = this.requestQueues[priority].shift();\n queued?.resolve(null);\n dropped += 1;\n }\n }\n return dropped;\n }\n\n private startAvailableQueuedRequests(): void {\n if (!this.queueProcessing.has(\"recall-critical\")) {\n const nextCritical = this.dequeueQueuedRequest(\"recall-critical\");\n if (nextCritical) {\n this.queueProcessing.add(\"recall-critical\");\n void this.runQueuedRequest(nextCritical);\n }\n }\n\n if (!this.queueProcessing.has(\"background\")) {\n const nextBackground = this.dequeueQueuedRequest(\"background\");\n if (nextBackground) {\n this.queueProcessing.add(\"background\");\n void this.runQueuedRequest(nextBackground);\n }\n }\n }\n\n private async runQueuedRequest(next: LocalLlmQueuedRequest): Promise<void> {\n try {\n const remainingCooldownMs = this.remainingCooldownMs();\n if (remainingCooldownMs > 0) {\n const additionalDropped = this.failOpenQueuedRequestsForCooldown();\n log.warn(\n `local LLM: cooldown active (${remainingCooldownMs}ms remaining), dropping ${additionalDropped + 1} queued request(s) fail-open`,\n );\n next.resolve(null);\n return;\n }\n\n let result: LocalLlmChatCompletionResult | null = null;\n try {\n result = await this.runChatCompletionRequest(next.messages, next.options, {\n priority: next.priority,\n enqueuedAtMs: next.enqueuedAtMs,\n });\n } catch (err) {\n log.warn(`local LLM queue drain failed open: ${err instanceof Error ? err.message : String(err)}`);\n }\n next.resolve(result);\n } finally {\n this.queueProcessing.delete(next.priority);\n if (this.requestQueues[\"recall-critical\"].length > 0 || this.requestQueues.background.length > 0) {\n this.scheduleQueueDrain();\n }\n }\n }\n\n private async runChatCompletionRequest(\n messages: Array<{ role: string; content: string }>,\n options: LocalLlmChatCompletionOptions,\n queueMeta?: { priority: LocalLlmRequestPriority; enqueuedAtMs: number },\n ): Promise<LocalLlmChatCompletionResult | null> {\n log.debug(\n `local LLM chatCompletion: localLlmEnabled=${resolveLocalLlmCapabilities(this.config).localLlm}, model=${this.config.localLlmModel}`,\n );\n\n const operation = options.operation ?? \"unspecified\";\n const startedAtMs = Date.now();\n if (queueMeta) {\n log.debug(\n `local LLM queue start: priority=${queueMeta.priority} waitMs=${startedAtMs - queueMeta.enqueuedAtMs} op=${operation}`,\n );\n }\n\n try {\n const isAvailable = await this.checkAvailability();\n if (!isAvailable) {\n log.debug(\n `local LLM: checkAvailability returned false for ${this.config.localLlmUrl}`,\n );\n return null;\n }\n\n const promptChars = messages.reduce((sum, m) => sum + (m.content?.length ?? 0), 0);\n const requestBody: Record<string, unknown> = {\n model: this.config.localLlmModel,\n messages,\n temperature: options.temperature ?? 0.7,\n // Use max_tokens consistent with cloud models\n max_tokens: options.maxTokens ?? 4096,\n };\n\n // Skip response_format for local LLMs - they don't support json_object type\n // The prompts already instruct the model to output JSON\n // Only send if it's json_schema type which some local LLMs support\n if (options.responseFormat?.type === \"json_schema\") {\n requestBody.response_format = options.responseFormat;\n }\n\n // Suppress thinking/reasoning for operations that benefit from terse,\n // structured output. Thinking-capable models (Qwen 3.5, Gemma 4,\n // DeepSeek) default to thinking-on via their chat template; sending\n // `chat_template_kwargs: { enable_thinking: false }` tells the template\n // to skip reasoning tokens. Consolidation operations on the main client\n // intentionally keep thinking enabled so entity resolution and\n // deduplication can use the model's reasoning path. Fast-tier callers can\n // still force suppression per request to preserve their low-latency\n // contract.\n //\n // Gate the injection on detected backend support (issue #548,\n // Codex P1 on PR #550): `chat_template_kwargs` is an LM Studio /\n // vLLM / llama.cpp extension, not part of standard OpenAI chat\n // completions. Strict OpenAI-compatible backends reject\n // unknown fields with 400, which trips the 400-cooldown path and\n // can effectively disable local extraction. Fail open when the\n // backend hasn't been positively identified as thinking-capable.\n const shouldSuppressThinking =\n options.forceDisableThinking === true ||\n ((options.disableThinking ?? this._disableThinking) &&\n THINKING_SUPPRESSED_OPERATIONS.has(operation));\n if (\n shouldSuppressThinking &&\n this.detectedType !== null &&\n THINKING_COMPATIBLE_BACKENDS.has(this.detectedType)\n ) {\n requestBody.chat_template_kwargs = { enable_thinking: false };\n } else if (shouldSuppressThinking && this.detectedType === \"ollama\") {\n // Ollama's /v1 endpoint silently drops `chat_template_kwargs` AND\n // `enable_thinking` — the ONLY field it maps to think-off is\n // `reasoning_effort` (\"none\" → ThinkValue{false} in openai.go;\n // verified against Ollama 0.32.0 source and live probes,\n // issue #1996). Without this, thinking-capable models (Gemma 4,\n // Qwen 3.5+) burn 1,700-2,000 reasoning tokens per extraction on\n // Ollama, exceed the client timeout, and retry forever. The effort\n // is configurable via `localLlmReasoningEffort` (default \"none\");\n // an empty value disables injection (pre-#1996 behavior).\n const effort = this.config.localLlmReasoningEffort;\n if (effort) {\n requestBody.reasoning_effort = effort;\n }\n }\n\n // Normalize URL (use 127.0.0.1 instead of localhost)\n const baseUrl = trimTrailingSlashes(\n this.config.localLlmUrl.replace(\"localhost\", \"127.0.0.1\"),\n );\n const chatUrl = baseUrl.endsWith(\"/v1\")\n ? `${baseUrl}/chat/completions`\n : `${baseUrl}/v1/chat/completions`;\n\n const requestBodyJson = JSON.stringify(requestBody);\n log.debug(\n `local LLM: sending request to ${chatUrl} with model ${this.config.localLlmModel}`,\n );\n // Avoid logging request bodies by default (can contain sensitive user content).\n log.debug(`local LLM: request body length=${requestBodyJson.length}`);\n\n const effectiveTimeoutMs =\n typeof options.timeoutMs === \"number\"\n ? Math.min(this.config.localLlmTimeoutMs, options.timeoutMs)\n : this.config.localLlmTimeoutMs;\n const maxAttempts = 1 + Math.max(0, this.config.localLlmRetry5xxCount);\n let response: Response | null = null;\n let lastAbortError: Error | null = null;\n for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {\n const attemptAbort = new AbortController();\n const attemptTimeout = setTimeout(() => attemptAbort.abort(), effectiveTimeoutMs);\n try {\n response = await this.chatTransport.post({\n url: chatUrl,\n headers: this.buildRequestHeaders({\n \"Content-Type\": \"application/json\",\n }),\n body: requestBodyJson,\n signal: attemptAbort.signal,\n budgetMs: this.config.localLlmTimeoutMs,\n });\n } catch (err) {\n if (!this.isAbortError(err)) throw err;\n lastAbortError = err instanceof Error ? err : new Error(String(err));\n if (attempt < maxAttempts) {\n const backoffMs = this.config.localLlmRetryBackoffMs * attempt;\n log.warn(\n `local LLM request aborted: op=${operation} attempt=${attempt}/${maxAttempts} timeoutMs=${effectiveTimeoutMs} model=${this.config.localLlmModel}; retrying after ${backoffMs}ms`,\n );\n await new Promise((resolve) => setTimeout(resolve, backoffMs));\n continue;\n }\n break;\n } finally {\n clearTimeout(attemptTimeout);\n }\n\n if (response.ok) break;\n if (response.status >= 500 && attempt < maxAttempts) {\n try {\n const errorText = await response.clone().text();\n const nonRecoverableReason =\n this.extractNonRecoverableBackendReasonFromErrorText(errorText);\n if (nonRecoverableReason) {\n this.markBackendUnavailable(\n nonRecoverableReason,\n this.config.localLlm400CooldownMs,\n );\n this.consecutive400s = 0;\n return null;\n }\n } catch (e) {\n log.debug(`local LLM failed to inspect retryable error body: ${e}`);\n }\n }\n if (response.status < 500 || attempt >= maxAttempts) break;\n\n const backoffMs = this.config.localLlmRetryBackoffMs * attempt;\n log.warn(\n `local LLM request got ${response.status}; retrying (attempt ${attempt + 1}/${maxAttempts}) after ${backoffMs}ms`,\n );\n await new Promise((resolve) => setTimeout(resolve, backoffMs));\n }\n log.debug(\n `local LLM: received response, status=${response?.status}, ok=${response?.ok}`,\n );\n\n if (!response) {\n if (lastAbortError) {\n log.warn(\n `local LLM request aborted after ${maxAttempts} attempt(s): op=${operation} timeoutMs=${effectiveTimeoutMs} model=${this.config.localLlmModel} promptChars=${promptChars} durationMs=${Date.now() - startedAtMs}`,\n );\n } else {\n log.warn(\n `local LLM request failed: no response object (op=${operation} model=${this.config.localLlmModel} durationMs=${Date.now() - startedAtMs})`,\n );\n }\n return null;\n }\n\n if (!response.ok) {\n let reason = \"\";\n let errorText = \"\";\n try {\n errorText = await response.text();\n // Try to extract a stable error message without logging content.\n try {\n const parsed = JSON.parse(errorText) as { error?: { message?: string } };\n reason = parsed?.error?.message ? ` — ${parsed.error.message}` : \"\";\n } catch {\n // Keep a short preview in debug only.\n log.debug(`local LLM error body: ${errorText.slice(0, 500)}`);\n }\n } catch (e) {\n log.debug(`local LLM failed to read error body: ${e}`);\n }\n log.warn(\n `local LLM request failed: ${response.status} ${response.statusText}${reason} ` +\n `(op=${operation}, model=${this.config.localLlmModel}, url=${chatUrl}, promptChars=${promptChars}, maxTokens=${requestBody.max_tokens as number})`,\n );\n const nonRecoverableReason =\n this.extractNonRecoverableBackendReason(reason) ??\n this.extractNonRecoverableBackendReasonFromErrorText(errorText);\n if (nonRecoverableReason) {\n this.markBackendUnavailable(\n nonRecoverableReason,\n this.config.localLlm400CooldownMs,\n );\n this.consecutive400s = 0;\n return null;\n }\n if (response.status === 400) {\n this.consecutive400s += 1;\n if (this.consecutive400s >= this.config.localLlm400TripThreshold) {\n this.cooldownUntilMs = Date.now() + this.config.localLlm400CooldownMs;\n log.warn(\n `local LLM: entering cooldown for ${this.config.localLlm400CooldownMs}ms ` +\n `after ${this.consecutive400s} consecutive 400 responses`,\n );\n this.consecutive400s = 0;\n }\n } else {\n this.consecutive400s = 0;\n }\n return null;\n }\n this.consecutive400s = 0;\n\n const data = (await response.json()) as {\n choices?: Array<{\n message?: { content?: string; reasoning_content?: string };\n }>;\n usage?: {\n prompt_tokens?: number;\n completion_tokens?: number;\n total_tokens?: number;\n };\n };\n\n log.debug(\n `local LLM response: choices=${data.choices?.length}, usage=${JSON.stringify(data.usage)}`,\n );\n\n // Thinking models (e.g. Qwen 3.5) may put their response in\n // `reasoning_content` and leave `content` empty. Fall back to\n // reasoning_content so engram still gets a usable result.\n const msg = data.choices?.[0]?.message;\n const content = msg?.content || msg?.reasoning_content || \"\";\n if (!content) {\n log.warn(`local LLM returned empty content. choices=${JSON.stringify(data.choices)?.slice(0, 200)}`);\n return null;\n }\n\n // Estimate tokens if not provided by local LLM\n const usage = data.usage\n ? {\n promptTokens: data.usage.prompt_tokens ?? 0,\n completionTokens: data.usage.completion_tokens ?? 0,\n totalTokens: data.usage.total_tokens ?? 0,\n }\n : this.estimateTokens(messages, content);\n\n const durationMs = Date.now() - startedAtMs;\n if (resolvePipelineProcessingCapabilities(this.config).slowLog && durationMs >= this.config.slowLogThresholdMs) {\n const promptChars = messages.reduce((sum, m) => sum + (m.content?.length ?? 0), 0);\n const op = options.operation ? ` op=${options.operation}` : \"\";\n log.warn(\n `SLOW local LLM:${op} durationMs=${durationMs} model=${this.config.localLlmModel} url=${chatUrl} promptChars=${promptChars} outputTokens=${usage.completionTokens} totalTokens=${usage.totalTokens}`,\n );\n }\n\n log.debug(\"local LLM: request succeeded, tokens:\", usage.totalTokens);\n return { content, usage };\n } catch (err) {\n const errMsg = err instanceof Error ? err.message : String(err);\n const durationMs = Date.now() - startedAtMs;\n if (this.isAbortError(err)) {\n log.warn(\n `local LLM request aborted: op=${operation} timeoutMs=${options.timeoutMs ?? this.config.localLlmTimeoutMs} model=${this.config.localLlmModel} durationMs=${durationMs} error=${errMsg}`,\n );\n return null;\n }\n log.warn(`local LLM request error: op=${operation} error=${errMsg}`);\n this.isAvailable = false; // Mark as unavailable on non-abort errors\n const nonRecoverableReason = this.extractNonRecoverableBackendReason(errMsg);\n if (nonRecoverableReason) {\n this.markBackendUnavailable(\n nonRecoverableReason,\n this.config.localLlm400CooldownMs,\n );\n }\n return null;\n } finally {\n if (queueMeta) {\n const finishedAtMs = Date.now();\n const waitMs = startedAtMs - queueMeta.enqueuedAtMs;\n log.debug(\n `local LLM queue finish: priority=${queueMeta.priority} waitMs=${waitMs} runMs=${finishedAtMs - startedAtMs} totalMs=${finishedAtMs - queueMeta.enqueuedAtMs} op=${operation}`,\n );\n }\n }\n }\n\n /**\n * Query the local LLM server for loaded model information.\n * Returns null if unavailable or if the model is not found.\n */\n async getLoadedModelInfo(): Promise<LocalModelInfo | null> {\n const baseUrl = trimTrailingSlashes(\n this.config.localLlmUrl.replace(\"localhost\", \"127.0.0.1\"),\n );\n\n // Handle URL construction - localLlmUrl may already include /v1\n const modelsUrl = baseUrl.endsWith(\"/v1\")\n ? `${baseUrl}/models`\n : `${baseUrl}/v1/models`;\n log.debug(`Fetching model info from ${modelsUrl}`);\n\n try {\n const result = await this.fetchWithTimeout(modelsUrl, 3000);\n if (!result.ok) {\n if (result.status === 401 || result.status === 403) {\n log.warn(\n `Local LLM: unauthorized while fetching models from ${modelsUrl}; verify localLlmApiKey and localLlmAuthHeader settings`,\n );\n }\n log.warn(`Local LLM: Failed to fetch models from ${modelsUrl} - server returned error`);\n return null;\n }\n if (!result.data) {\n log.warn(`Local LLM: No data returned from ${modelsUrl}`);\n return null;\n }\n\n const data = result.data as {\n data?: Array<{\n id?: string;\n object?: string;\n owned_by?: string;\n // LM Studio specific fields\n max_context_length?: number;\n max_tokens?: number;\n // Ollama specific\n name?: string;\n details?: {\n parameter_size?: string;\n family?: string;\n };\n }>;\n };\n\n if (!Array.isArray(data.data) || data.data.length === 0) {\n log.warn(\"Local LLM returned no models\");\n return null;\n }\n\n // Verbose model listings are noisy on every gateway restart. Keep it debug-only.\n const modelIds = data.data.map((m) => m.id).filter(Boolean);\n log.debug(\n `Local LLM: Found ${modelIds.length} model(s). First 10: ${modelIds.slice(0, 10).join(\", \")}`,\n );\n\n // Find the model matching our configured model ID\n const configuredModel = this.config.localLlmModel;\n let model = data.data.find((m) => m.id === configuredModel);\n\n // If not found by exact match, try partial match (handle suffixes like @4bit)\n if (!model) {\n model = data.data.find((m) =>\n configuredModel.includes(m.id || \"\") ||\n (m.id || \"\").includes(configuredModel.replace(/@\\d+bit$/, \"\"))\n );\n }\n\n // If still not found, use the first loaded model and warn\n if (!model) {\n model = data.data[0];\n const availablePreview = data.data\n .map((m) => m.id)\n .filter(Boolean)\n .slice(0, 10)\n .join(\", \");\n log.warn(\n `Configured model \"${configuredModel}\" not found in local LLM. ` +\n `Using \"${model.id}\" instead. Available (first 10): ${availablePreview}`\n );\n }\n\n // Extract context window - try multiple field names\n let contextWindow = model.max_context_length || model.max_tokens;\n\n // If API doesn't report context window, try LMS CLI (LM Studio specific)\n if (!contextWindow) {\n log.info(\"Local LLM: API did not report context window, trying LMS CLI...\");\n const lmsContext = this.getCachedContextWindow(model.id || \"\");\n if (lmsContext) {\n contextWindow = lmsContext;\n }\n }\n\n this.cachedModelInfo = {\n id: model.id || \"unknown\",\n contextWindow: contextWindow,\n maxTokens: model.max_tokens,\n };\n\n log.info(\n `Local LLM model detected: ${this.cachedModelInfo.id}, ` +\n `context window: ${contextWindow?.toLocaleString() || \"unknown (may use default)\"}`\n );\n\n return this.cachedModelInfo;\n } catch (err) {\n log.warn(`Failed to fetch model info: ${err}`);\n return null;\n }\n }\n\n /**\n * Check if the configured model is available and get its actual context window.\n * Warns if there's a mismatch between expected and actual context.\n */\n async validateModelConfig(expectedContextWindow?: number): Promise<{\n available: boolean;\n actualContextWindow?: number;\n warnings: string[];\n }> {\n const warnings: string[] = [];\n\n const modelInfo = await this.getLoadedModelInfo();\n if (!modelInfo) {\n return { available: false, warnings: [\"Could not query local LLM for model info\"] };\n }\n\n // If we have expected context and the server reports one, check for mismatch\n if (expectedContextWindow && modelInfo.contextWindow) {\n if (modelInfo.contextWindow < expectedContextWindow) {\n warnings.push(\n `Context window mismatch: Model ${modelInfo.id} supports ${modelInfo.contextWindow.toLocaleString()} tokens, ` +\n `but engram is configured for ${expectedContextWindow.toLocaleString()}. ` +\n `Set localLlmMaxContext: ${modelInfo.contextWindow} in config to avoid errors.`\n );\n }\n }\n\n // Warn if server doesn't report context window (common with some local LLM setups)\n if (!modelInfo.contextWindow) {\n warnings.push(\n `Local LLM server did not report context window for ${modelInfo.id}. ` +\n `If you get \"context length exceeded\" errors, set localLlmMaxContext in config.`\n );\n }\n\n return {\n available: true,\n actualContextWindow: modelInfo.contextWindow,\n warnings,\n };\n }\n\n /**\n * Make a chat completion request to local LLM\n */\n async chatCompletion(\n messages: Array<{ role: string; content: string }>,\n options: LocalLlmChatCompletionOptions = {},\n ): Promise<LocalLlmChatCompletionResult | null> {\n if (!resolveLocalLlmCapabilities(this.config).localLlm) {\n log.debug(\"local LLM: disabled, returning null\");\n return null;\n }\n\n const remainingMs = this.remainingCooldownMs();\n if (remainingMs > 0) {\n log.debug(`local LLM: cooldown active (${remainingMs}ms remaining), skipping request`);\n return null;\n }\n if (options.priority) {\n const priority = options.priority;\n return await new Promise<LocalLlmChatCompletionResult | null>((resolve) => {\n this.requestQueues[priority].push({\n messages,\n options,\n priority,\n enqueuedAtMs: Date.now(),\n resolve,\n });\n this.scheduleQueueDrain();\n });\n }\n\n return await this.runChatCompletionRequest(messages, options);\n }\n\n /**\n * Estimate tokens when local LLM doesn't return usage stats\n * Rough estimate: 1 token ≈ 4 characters\n */\n private estimateTokens(\n messages: Array<{ role: string; content: string }>,\n response: string\n ): { promptTokens: number; completionTokens: number; totalTokens: number } {\n const promptChars = messages.reduce((sum, m) => sum + m.content.length, 0);\n const promptTokens = Math.ceil(promptChars / 4);\n const completionTokens = Math.ceil(response.length / 4);\n\n return {\n promptTokens,\n completionTokens,\n totalTokens: promptTokens + completionTokens,\n };\n }\n\n /**\n * Try local LLM first, fallback to cloud provider if configured\n */\n async withFallback<T>(\n localOperation: () => Promise<T | null>,\n fallbackOperation: () => Promise<T>,\n operationName: string\n ): Promise<T> {\n // Try local LLM first if enabled\n if (resolveLocalLlmCapabilities(this.config).localLlm) {\n const localResult = await localOperation();\n if (localResult !== null) {\n log.debug(`${operationName}: used local LLM`);\n return localResult;\n }\n\n // Local failed or unavailable\n if (this.config.localLlmFallback) {\n log.info(`${operationName}: local LLM unavailable, falling back to cloud`);\n } else {\n throw new Error(`${operationName}: local LLM unavailable and fallback disabled`);\n }\n }\n\n // Use fallback (cloud provider)\n return fallbackOperation();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAEA,OAAO,QAAQ;AACf,OAAO,QAAQ;AASf,SAAS,oBAAoB,GAAmB;AAC9C,MAAI,MAAM,EAAE;AACZ,SAAO,MAAM,KAAK,EAAE,MAAM,CAAC,MAAM,IAAK;AACtC,SAAO,EAAE,UAAU,GAAG,GAAG;AAC3B;AAEA,SAAS,oBAAoB,GAAmB;AAC9C,SAAO,EAAE,SAAS,KAAK,IAAI,EAAE,MAAM,GAAG,EAAE,IAAI;AAC9C;AAEA,SAAS,oBAAoB,GAA0B;AACrD,MAAI;AACF,UAAM,SAAS,IAAI,IAAI,CAAC;AACxB,QAAI,CAAC,OAAO,KAAM,QAAO;AACzB,UAAM,OAAO,OAAO,OAAO,IAAI;AAC/B,WAAO,OAAO,UAAU,IAAI,IAAI,OAAO;AAAA,EACzC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,SAAS,eAAe,OAAkD;AACxE,SA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,MAAM;AACxB,YAAI,MAAM,GAAG,aAAa,kBAAkB;AAC5C,eAAO;AAAA,MACT;AAGA,UAAI,KAAK,OAAO,kBAAkB;AAChC,YAAI,KAAK,GAAG,aAAa,gDAAgD;AAAA,MAC3E,OAAO;AACL,cAAM,IAAI,MAAM,GAAG,aAAa,+CAA+C;AAAA,MACjF;AAAA,IACF;AAGA,WAAO,kBAAkB;AAAA,EAC3B;AACF;","names":["backoffMs","promptChars"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
appendRecallAuditEntry
|
|
3
|
-
} from "./chunk-LBLXEFWK.js";
|
|
4
1
|
import {
|
|
5
2
|
detectRecallAnomalies
|
|
6
3
|
} from "./chunk-RFYAYKTD.js";
|
|
4
|
+
import {
|
|
5
|
+
appendRecallAuditEntry
|
|
6
|
+
} from "./chunk-LBLXEFWK.js";
|
|
7
7
|
|
|
8
8
|
// src/access-audit.ts
|
|
9
9
|
var AccessAuditAdapter = class {
|
|
@@ -62,4 +62,4 @@ var AccessAuditAdapter = class {
|
|
|
62
62
|
export {
|
|
63
63
|
AccessAuditAdapter
|
|
64
64
|
};
|
|
65
|
-
//# sourceMappingURL=chunk-
|
|
65
|
+
//# sourceMappingURL=chunk-TVVEYCNW.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isValidCapsuleSince
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IPLYGWQF.js";
|
|
4
4
|
import {
|
|
5
5
|
CAPSULE_ID_PATTERN
|
|
6
6
|
} from "./chunk-WEHSQBFR.js";
|
|
@@ -441,4 +441,4 @@ export {
|
|
|
441
441
|
actionConfidenceRequestSchema,
|
|
442
442
|
validateRequest
|
|
443
443
|
};
|
|
444
|
-
//# sourceMappingURL=chunk-
|
|
444
|
+
//# sourceMappingURL=chunk-V2XVMCP6.js.map
|
|
@@ -12,12 +12,6 @@ import {
|
|
|
12
12
|
import {
|
|
13
13
|
WriteQuarantineStore
|
|
14
14
|
} from "./chunk-PJSK6OJM.js";
|
|
15
|
-
import {
|
|
16
|
-
trustResultFor
|
|
17
|
-
} from "./chunk-GNVZQ5JN.js";
|
|
18
|
-
import {
|
|
19
|
-
renderEpistemicHedge
|
|
20
|
-
} from "./chunk-YN2UN7N3.js";
|
|
21
15
|
import {
|
|
22
16
|
getTrustZoneStoreStatus,
|
|
23
17
|
isTrustZoneName,
|
|
@@ -27,6 +21,12 @@ import {
|
|
|
27
21
|
seedTrustZoneDemoDataset,
|
|
28
22
|
summarizeTrustZonePromotionReadiness
|
|
29
23
|
} from "./chunk-JGSKJHF7.js";
|
|
24
|
+
import {
|
|
25
|
+
trustResultFor
|
|
26
|
+
} from "./chunk-GNVZQ5JN.js";
|
|
27
|
+
import {
|
|
28
|
+
renderEpistemicHedge
|
|
29
|
+
} from "./chunk-YN2UN7N3.js";
|
|
30
30
|
import {
|
|
31
31
|
planSessionTranscriptMigration
|
|
32
32
|
} from "./chunk-P5FPO2BR.js";
|
|
@@ -39,6 +39,12 @@ import {
|
|
|
39
39
|
import {
|
|
40
40
|
estimateRecallTokens
|
|
41
41
|
} from "./chunk-3NAHZQU3.js";
|
|
42
|
+
import {
|
|
43
|
+
recordObjectiveStateSnapshotsFromObservedMessages
|
|
44
|
+
} from "./chunk-ICP53SKG.js";
|
|
45
|
+
import {
|
|
46
|
+
objectiveStateStoreOverrideForNamespace
|
|
47
|
+
} from "./chunk-6HMYUWXR.js";
|
|
42
48
|
import {
|
|
43
49
|
offlineSyncStorageForSnapshot
|
|
44
50
|
} from "./chunk-UGH6VPPO.js";
|
|
@@ -70,12 +76,6 @@ import {
|
|
|
70
76
|
import {
|
|
71
77
|
recordMemoryOutcome
|
|
72
78
|
} from "./chunk-EIR5VLIH.js";
|
|
73
|
-
import {
|
|
74
|
-
recordObjectiveStateSnapshotsFromObservedMessages
|
|
75
|
-
} from "./chunk-ICP53SKG.js";
|
|
76
|
-
import {
|
|
77
|
-
objectiveStateStoreOverrideForNamespace
|
|
78
|
-
} from "./chunk-6HMYUWXR.js";
|
|
79
79
|
import {
|
|
80
80
|
buildGraphSnapshot
|
|
81
81
|
} from "./chunk-JYIFGGEM.js";
|
|
@@ -171,7 +171,7 @@ import {
|
|
|
171
171
|
} from "./chunk-W5H6ZRPT.js";
|
|
172
172
|
import {
|
|
173
173
|
exportCapsule
|
|
174
|
-
} from "./chunk-
|
|
174
|
+
} from "./chunk-IPLYGWQF.js";
|
|
175
175
|
import {
|
|
176
176
|
assertFleetWideOperationAllowed,
|
|
177
177
|
assertOperationAllowed,
|
|
@@ -258,7 +258,7 @@ import {
|
|
|
258
258
|
} from "./chunk-PVGDJXVK.js";
|
|
259
259
|
import {
|
|
260
260
|
AccessAuditAdapter
|
|
261
|
-
} from "./chunk-
|
|
261
|
+
} from "./chunk-TVVEYCNW.js";
|
|
262
262
|
import {
|
|
263
263
|
decodeCitationNamespace
|
|
264
264
|
} from "./chunk-3PDOVUHC.js";
|
|
@@ -12441,4 +12441,4 @@ export {
|
|
|
12441
12441
|
EngramAccessService,
|
|
12442
12442
|
AccessAdminOpsSurface
|
|
12443
12443
|
};
|
|
12444
|
-
//# sourceMappingURL=chunk-
|
|
12444
|
+
//# sourceMappingURL=chunk-WZVIB5BK.js.map
|
package/dist/cli.js
CHANGED
|
@@ -90,10 +90,10 @@ import {
|
|
|
90
90
|
runWorkProductStatusCliCommand,
|
|
91
91
|
runWorkProjectCliCommand,
|
|
92
92
|
runWorkTaskCliCommand
|
|
93
|
-
} from "./chunk-
|
|
93
|
+
} from "./chunk-KXGE7L62.js";
|
|
94
|
+
import "./chunk-MMACM5G2.js";
|
|
94
95
|
import "./chunk-54BGIBCR.js";
|
|
95
96
|
import "./chunk-H4CKS5B2.js";
|
|
96
|
-
import "./chunk-MMACM5G2.js";
|
|
97
97
|
import "./chunk-FXZTL7F7.js";
|
|
98
98
|
import "./chunk-UP6MOYCB.js";
|
|
99
99
|
import "./chunk-BV2TIZ4F.js";
|
|
@@ -117,9 +117,9 @@ import "./chunk-MC6XO7T4.js";
|
|
|
117
117
|
import "./chunk-KJTKLXTH.js";
|
|
118
118
|
import "./chunk-MNB5RMAY.js";
|
|
119
119
|
import "./chunk-P65YJEEL.js";
|
|
120
|
+
import "./chunk-GQL52GQ5.js";
|
|
120
121
|
import "./chunk-HSSERO3E.js";
|
|
121
122
|
import "./chunk-NOUJNHWG.js";
|
|
122
|
-
import "./chunk-GQL52GQ5.js";
|
|
123
123
|
import "./chunk-2F6NP3NT.js";
|
|
124
124
|
import "./chunk-TERNBNJB.js";
|
|
125
125
|
import "./chunk-ATEAL5EI.js";
|
|
@@ -129,11 +129,11 @@ import "./chunk-CUUY5CC4.js";
|
|
|
129
129
|
import "./chunk-AYAROCWD.js";
|
|
130
130
|
import "./chunk-ZRWB5D4H.js";
|
|
131
131
|
import "./chunk-HYQJQGD3.js";
|
|
132
|
-
import "./chunk-TGQ2NTWH.js";
|
|
133
132
|
import "./chunk-5CPI2QWG.js";
|
|
133
|
+
import "./chunk-TGQ2NTWH.js";
|
|
134
134
|
import "./chunk-3T74IZB3.js";
|
|
135
135
|
import "./chunk-33JBK2XP.js";
|
|
136
|
-
import "./chunk-
|
|
136
|
+
import "./chunk-XGEFGNL5.js";
|
|
137
137
|
import "./chunk-P2BLHUL2.js";
|
|
138
138
|
import "./chunk-7I7AYIUQ.js";
|
|
139
139
|
import "./chunk-GD3QOBMB.js";
|
|
@@ -171,22 +171,22 @@ import "./chunk-OO42R444.js";
|
|
|
171
171
|
import "./chunk-K6MV3TRQ.js";
|
|
172
172
|
import "./chunk-PIG4WJFQ.js";
|
|
173
173
|
import "./chunk-KFZY2OFH.js";
|
|
174
|
-
import "./chunk-
|
|
174
|
+
import "./chunk-DLKRXYRL.js";
|
|
175
175
|
import "./chunk-V7IZKJI3.js";
|
|
176
176
|
import "./chunk-SEDEKFYQ.js";
|
|
177
|
-
import "./chunk-
|
|
177
|
+
import "./chunk-AU7Q3LSC.js";
|
|
178
|
+
import "./chunk-42NQ7AVG.js";
|
|
178
179
|
import "./chunk-TMSXWOBZ.js";
|
|
179
180
|
import "./chunk-MKQBXQKU.js";
|
|
180
181
|
import "./chunk-J64TK33U.js";
|
|
181
182
|
import "./chunk-RSUYKGGZ.js";
|
|
182
|
-
import "./chunk-42NQ7AVG.js";
|
|
183
183
|
import "./chunk-7RXCMVFQ.js";
|
|
184
|
-
import "./chunk-
|
|
184
|
+
import "./chunk-M6LJXJ3J.js";
|
|
185
185
|
import "./chunk-57QKLRBV.js";
|
|
186
186
|
import "./chunk-D24OXEPB.js";
|
|
187
|
-
import "./chunk-
|
|
188
|
-
import "./chunk-
|
|
189
|
-
import "./chunk-
|
|
187
|
+
import "./chunk-3L5O7SMT.js";
|
|
188
|
+
import "./chunk-V2XVMCP6.js";
|
|
189
|
+
import "./chunk-4PQ4KLLK.js";
|
|
190
190
|
import "./chunk-EQWEIIKQ.js";
|
|
191
191
|
import "./chunk-HNZKVLAN.js";
|
|
192
192
|
import "./chunk-BJJAX3IZ.js";
|
|
@@ -197,21 +197,24 @@ import "./chunk-T4WDJPEZ.js";
|
|
|
197
197
|
import "./chunk-56BSXSHC.js";
|
|
198
198
|
import "./chunk-TWCOYET2.js";
|
|
199
199
|
import "./chunk-OADWQ5CR.js";
|
|
200
|
-
import "./chunk-
|
|
200
|
+
import "./chunk-WZVIB5BK.js";
|
|
201
201
|
import "./chunk-GDASG7NC.js";
|
|
202
202
|
import "./chunk-GDB4J2H3.js";
|
|
203
203
|
import "./chunk-7CPOZH6Y.js";
|
|
204
204
|
import "./chunk-VQ7B2Q6M.js";
|
|
205
205
|
import "./chunk-PJSK6OJM.js";
|
|
206
|
+
import "./chunk-JGSKJHF7.js";
|
|
206
207
|
import "./chunk-GNVZQ5JN.js";
|
|
207
208
|
import "./chunk-YN2UN7N3.js";
|
|
208
|
-
import "./chunk-JGSKJHF7.js";
|
|
209
209
|
import "./chunk-P5FPO2BR.js";
|
|
210
210
|
import "./chunk-S4DDLTPX.js";
|
|
211
211
|
import "./chunk-H7XKCNR6.js";
|
|
212
212
|
import "./chunk-MMTG3SCJ.js";
|
|
213
213
|
import "./chunk-SOBJ6NEY.js";
|
|
214
214
|
import "./chunk-3NAHZQU3.js";
|
|
215
|
+
import "./chunk-ICP53SKG.js";
|
|
216
|
+
import "./chunk-AQEJKOKI.js";
|
|
217
|
+
import "./chunk-6HMYUWXR.js";
|
|
215
218
|
import "./chunk-UGH6VPPO.js";
|
|
216
219
|
import "./chunk-R6YJI3HE.js";
|
|
217
220
|
import "./chunk-ZN4UZWMT.js";
|
|
@@ -235,9 +238,6 @@ import "./chunk-64UDOIMI.js";
|
|
|
235
238
|
import "./chunk-IUM3VSHI.js";
|
|
236
239
|
import "./chunk-MQVINOJQ.js";
|
|
237
240
|
import "./chunk-EIR5VLIH.js";
|
|
238
|
-
import "./chunk-ICP53SKG.js";
|
|
239
|
-
import "./chunk-AQEJKOKI.js";
|
|
240
|
-
import "./chunk-6HMYUWXR.js";
|
|
241
241
|
import "./chunk-IISBCCWR.js";
|
|
242
242
|
import "./chunk-JYIFGGEM.js";
|
|
243
243
|
import "./chunk-EI6V5UXY.js";
|
|
@@ -293,10 +293,10 @@ import "./chunk-L2EXJQJP.js";
|
|
|
293
293
|
import "./chunk-45GF7Y3V.js";
|
|
294
294
|
import "./chunk-RGMVMVMF.js";
|
|
295
295
|
import "./chunk-N7RWREIQ.js";
|
|
296
|
-
import "./chunk-
|
|
296
|
+
import "./chunk-IPLYGWQF.js";
|
|
297
|
+
import "./chunk-J4EB7DNW.js";
|
|
297
298
|
import "./chunk-WEHSQBFR.js";
|
|
298
299
|
import "./chunk-X7Y7WX73.js";
|
|
299
|
-
import "./chunk-J4EB7DNW.js";
|
|
300
300
|
import "./chunk-BJMBJZ2Y.js";
|
|
301
301
|
import "./chunk-UKJAGEXH.js";
|
|
302
302
|
import "./chunk-FP2373TW.js";
|
|
@@ -328,9 +328,9 @@ import "./chunk-VFUEZZBS.js";
|
|
|
328
328
|
import "./chunk-PVGDJXVK.js";
|
|
329
329
|
import "./chunk-A2IYSXDQ.js";
|
|
330
330
|
import "./chunk-LPSF4OQH.js";
|
|
331
|
-
import "./chunk-
|
|
332
|
-
import "./chunk-LBLXEFWK.js";
|
|
331
|
+
import "./chunk-TVVEYCNW.js";
|
|
333
332
|
import "./chunk-RFYAYKTD.js";
|
|
333
|
+
import "./chunk-LBLXEFWK.js";
|
|
334
334
|
import "./chunk-3PDOVUHC.js";
|
|
335
335
|
import "./chunk-FF4KLI5W.js";
|
|
336
336
|
import "./chunk-AIK5W3IW.js";
|
package/dist/extraction.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ExtractionEngine,
|
|
3
3
|
shouldEnableLocalExtractionThinking
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-GBAJCDTW.js";
|
|
5
5
|
import "./chunk-4RA3C3EV.js";
|
|
6
6
|
import "./chunk-5GSUBCZM.js";
|
|
7
7
|
import "./chunk-54V4BZWP.js";
|
|
8
8
|
import "./chunk-2CGLBUW3.js";
|
|
9
9
|
import "./chunk-WLZYGLJ4.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-P2OZKKYP.js";
|
|
11
|
+
import "./chunk-JUXOTY6J.js";
|
|
11
12
|
import {
|
|
12
13
|
classifyExtractionThrownError,
|
|
13
14
|
classifyFallbackParseFailure
|
|
@@ -2,12 +2,12 @@ import {
|
|
|
2
2
|
applyUtilityPromotionRuntimePolicy,
|
|
3
3
|
loadUtilityRuntimeValues
|
|
4
4
|
} from "./chunk-LXOM6IQU.js";
|
|
5
|
-
import {
|
|
6
|
-
decideTierTransition
|
|
7
|
-
} from "./chunk-S75M5ZRK.js";
|
|
8
5
|
import {
|
|
9
6
|
TierMigrationExecutor
|
|
10
7
|
} from "./chunk-VOUOLGIP.js";
|
|
8
|
+
import {
|
|
9
|
+
decideTierTransition
|
|
10
|
+
} from "./chunk-S75M5ZRK.js";
|
|
11
11
|
import "./chunk-2F6NP3NT.js";
|
|
12
12
|
import "./chunk-TERNBNJB.js";
|
|
13
13
|
import "./chunk-TBBDFYXW.js";
|
|
@@ -266,4 +266,4 @@ export {
|
|
|
266
266
|
LIFECYCLE_INIT_DONE_MARKER,
|
|
267
267
|
runFirstStartMigration
|
|
268
268
|
};
|
|
269
|
-
//# sourceMappingURL=first-start-migration-
|
|
269
|
+
//# sourceMappingURL=first-start-migration-LEXL3XYL.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -4237,8 +4237,8 @@ declare const RelayMissionEventSchema: z.ZodObject<{
|
|
|
4237
4237
|
}[] | undefined;
|
|
4238
4238
|
}>;
|
|
4239
4239
|
}, "strict", z.ZodTypeAny, {
|
|
4240
|
-
recordedAt: string;
|
|
4241
4240
|
schemaVersion: "1";
|
|
4241
|
+
recordedAt: string;
|
|
4242
4242
|
payload: {
|
|
4243
4243
|
kind: "mission_started";
|
|
4244
4244
|
title: string;
|
|
@@ -4416,8 +4416,8 @@ declare const RelayMissionEventSchema: z.ZodObject<{
|
|
|
4416
4416
|
authenticatedPrincipal?: string | undefined;
|
|
4417
4417
|
idempotencyKey?: string | undefined;
|
|
4418
4418
|
}, {
|
|
4419
|
-
recordedAt: string;
|
|
4420
4419
|
schemaVersion: "1";
|
|
4420
|
+
recordedAt: string;
|
|
4421
4421
|
payload: {
|
|
4422
4422
|
kind: "mission_started";
|
|
4423
4423
|
title: string;
|