@cortexkit/opencode-magic-context 0.38.1 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/README.md +57 -4
  2. package/dist/config/index.d.ts.map +1 -1
  3. package/dist/config/profiles.d.ts +22 -0
  4. package/dist/config/profiles.d.ts.map +1 -0
  5. package/dist/config/project-security.d.ts +14 -6
  6. package/dist/config/project-security.d.ts.map +1 -1
  7. package/dist/config/raw-loader.d.ts +42 -0
  8. package/dist/config/raw-loader.d.ts.map +1 -0
  9. package/dist/config/schema/magic-context.d.ts +966 -531
  10. package/dist/config/schema/magic-context.d.ts.map +1 -1
  11. package/dist/features/magic-context/dreamer/classify.d.ts +3 -2
  12. package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
  13. package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts +9 -2
  14. package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts.map +1 -1
  15. package/dist/features/magic-context/dreamer/map-memories-prompt.d.ts +4 -2
  16. package/dist/features/magic-context/dreamer/map-memories-prompt.d.ts.map +1 -1
  17. package/dist/features/magic-context/dreamer/map-memories.d.ts +21 -5
  18. package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
  19. package/dist/features/magic-context/dreamer/refresh-primers.d.ts +3 -2
  20. package/dist/features/magic-context/dreamer/refresh-primers.d.ts.map +1 -1
  21. package/dist/features/magic-context/dreamer/task-config.d.ts +2 -1
  22. package/dist/features/magic-context/dreamer/task-config.d.ts.map +1 -1
  23. package/dist/features/magic-context/dreamer/task-executor.d.ts +0 -1
  24. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  25. package/dist/features/magic-context/dreamer/task-scheduler.d.ts +3 -2
  26. package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
  27. package/dist/features/magic-context/dreamer/verify-prompt.d.ts +5 -2
  28. package/dist/features/magic-context/dreamer/verify-prompt.d.ts.map +1 -1
  29. package/dist/features/magic-context/dreamer/verify.d.ts +6 -3
  30. package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
  31. package/dist/features/magic-context/fail-closed-block.d.ts +11 -1
  32. package/dist/features/magic-context/fail-closed-block.d.ts.map +1 -1
  33. package/dist/features/magic-context/memory/embedding-failure.d.ts +11 -0
  34. package/dist/features/magic-context/memory/embedding-failure.d.ts.map +1 -0
  35. package/dist/features/magic-context/memory/embedding-openai.d.ts +5 -0
  36. package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
  37. package/dist/features/magic-context/memory/embedding-provider.d.ts +3 -0
  38. package/dist/features/magic-context/memory/embedding-provider.d.ts.map +1 -1
  39. package/dist/features/magic-context/migrations.d.ts.map +1 -1
  40. package/dist/features/magic-context/mural/compress-cues.d.ts +3 -2
  41. package/dist/features/magic-context/mural/compress-cues.d.ts.map +1 -1
  42. package/dist/features/magic-context/project-embedding-registry.d.ts +2 -0
  43. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  44. package/dist/features/magic-context/smart-notes/compiler.d.ts +3 -2
  45. package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
  46. package/dist/features/magic-context/smart-notes/condition-compiler.d.ts +2 -0
  47. package/dist/features/magic-context/smart-notes/condition-compiler.d.ts.map +1 -1
  48. package/dist/features/magic-context/smart-notes/sandbox-runner.d.ts.map +1 -1
  49. package/dist/features/magic-context/storage-db.d.ts +2 -2
  50. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  51. package/dist/features/magic-context/storage-meta-persisted.d.ts +7 -2
  52. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  53. package/dist/features/magic-context/storage-meta-shared.d.ts +1 -0
  54. package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -1
  55. package/dist/features/magic-context/storage-meta.d.ts +1 -1
  56. package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
  57. package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
  58. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  59. package/dist/features/magic-context/storage.d.ts +1 -1
  60. package/dist/features/magic-context/storage.d.ts.map +1 -1
  61. package/dist/features/magic-context/tool-definition-tokens.d.ts +10 -0
  62. package/dist/features/magic-context/tool-definition-tokens.d.ts.map +1 -1
  63. package/dist/features/magic-context/transform-decision-log.d.ts +11 -0
  64. package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
  65. package/dist/features/magic-context/user-memory/review-user-memories.d.ts +3 -2
  66. package/dist/features/magic-context/user-memory/review-user-memories.d.ts.map +1 -1
  67. package/dist/hooks/magic-context/channel2-delivery.d.ts +3 -1
  68. package/dist/hooks/magic-context/channel2-delivery.d.ts.map +1 -1
  69. package/dist/hooks/magic-context/command-handler.d.ts +4 -0
  70. package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
  71. package/dist/hooks/magic-context/compartment-runner-historian.d.ts +4 -1
  72. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
  73. package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts.map +1 -1
  74. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  75. package/dist/hooks/magic-context/compartment-runner-types.d.ts +4 -1
  76. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  77. package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts +14 -2
  78. package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts.map +1 -1
  79. package/dist/hooks/magic-context/emergency-fail-closed.d.ts +7 -0
  80. package/dist/hooks/magic-context/emergency-fail-closed.d.ts.map +1 -1
  81. package/dist/hooks/magic-context/format-embed-failure.d.ts +3 -0
  82. package/dist/hooks/magic-context/format-embed-failure.d.ts.map +1 -0
  83. package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
  84. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  85. package/dist/hooks/magic-context/inject-compartments.d.ts +13 -1
  86. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  87. package/dist/hooks/magic-context/lkg-persist.d.ts +14 -0
  88. package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -0
  89. package/dist/hooks/magic-context/lkg-slot.d.ts +13 -0
  90. package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
  91. package/dist/hooks/magic-context/module-state-sync.d.ts +1 -0
  92. package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
  93. package/dist/hooks/magic-context/module-transport.d.ts +12 -0
  94. package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
  95. package/dist/hooks/magic-context/raw-fallback-context-limit.d.ts.map +1 -1
  96. package/dist/hooks/magic-context/recomp-orchestrator.d.ts +4 -1
  97. package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
  98. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  99. package/dist/hooks/magic-context/strip-content.d.ts +6 -0
  100. package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
  101. package/dist/hooks/magic-context/tail-hygiene-walk.d.ts +12 -0
  102. package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
  103. package/dist/hooks/magic-context/transform-compartment-phase.d.ts +3 -1
  104. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  105. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +5 -0
  106. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  107. package/dist/hooks/magic-context/transform.d.ts +9 -1
  108. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  109. package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
  110. package/dist/{index-2y0ybv5x.js → index-3dkzzh0t.js} +15 -17
  111. package/dist/{index-5znjkjws.js → index-axpym70t.js} +879 -170
  112. package/dist/index-ehpzdy0v.js +126 -0
  113. package/dist/{index-22mw8km4.js → index-rw0qrkvq.js} +4 -2
  114. package/dist/index.d.ts.map +1 -1
  115. package/dist/index.js +18466 -16177
  116. package/dist/model-resolution-r9jbcz86.js +15 -0
  117. package/dist/plugin/dream-timer.d.ts +3 -0
  118. package/dist/plugin/dream-timer.d.ts.map +1 -1
  119. package/dist/plugin/hooks/create-session-hooks.d.ts +2 -0
  120. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  121. package/dist/plugin/messages-transform.d.ts +14 -6
  122. package/dist/plugin/messages-transform.d.ts.map +1 -1
  123. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  124. package/dist/{recomp-orchestrator-p030kxtc.js → recomp-orchestrator-dmyvqekw.js} +2 -3
  125. package/dist/shared/jsonc-edit.d.ts +6 -1
  126. package/dist/shared/jsonc-edit.d.ts.map +1 -1
  127. package/dist/shared/model-resolution.d.ts +53 -0
  128. package/dist/shared/model-resolution.d.ts.map +1 -0
  129. package/dist/shared/model-suggestion-retry.d.ts +4 -1
  130. package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
  131. package/dist/shared/resolve-fallbacks.d.ts +5 -1
  132. package/dist/shared/resolve-fallbacks.d.ts.map +1 -1
  133. package/dist/shared/rpc-types.d.ts +2 -0
  134. package/dist/shared/rpc-types.d.ts.map +1 -1
  135. package/dist/shared/rpc-utils.d.ts +12 -1
  136. package/dist/shared/rpc-utils.d.ts.map +1 -1
  137. package/dist/shared/status-detail-text.d.ts +4 -0
  138. package/dist/shared/status-detail-text.d.ts.map +1 -0
  139. package/dist/shared/subagent-runner.d.ts +2 -1
  140. package/dist/shared/subagent-runner.d.ts.map +1 -1
  141. package/dist/{storage-meta-session-2306t3j7.js → storage-meta-session-yvtbaw7c.js} +1 -1
  142. package/dist/{task-config-at3adc59.js → task-config-a1qmj9bx.js} +2 -2
  143. package/dist/tui/data/context-db.d.ts.map +1 -1
  144. package/dist/tui-compiled/data/context-db.d.ts.map +1 -1
  145. package/package.json +4 -2
  146. package/src/config/index.test.ts +434 -19
  147. package/src/config/index.ts +67 -33
  148. package/src/config/profiles.ts +106 -0
  149. package/src/config/project-security.hostile-matrix.test.ts +480 -0
  150. package/src/config/project-security.test.ts +43 -5
  151. package/src/config/project-security.ts +151 -22
  152. package/src/config/raw-loader.test.ts +424 -0
  153. package/src/config/raw-loader.ts +490 -0
  154. package/src/config/schema/magic-context.test.ts +272 -2
  155. package/src/config/schema/magic-context.ts +342 -49
  156. package/src/shared/jsonc-edit.ts +74 -1
  157. package/src/shared/model-resolution.test.ts +170 -0
  158. package/src/shared/model-resolution.ts +227 -0
  159. package/src/shared/model-suggestion-retry.test.ts +27 -0
  160. package/src/shared/model-suggestion-retry.ts +19 -10
  161. package/src/shared/resolve-fallbacks.test.ts +13 -1
  162. package/src/shared/resolve-fallbacks.ts +19 -4
  163. package/src/shared/rpc-types.ts +2 -0
  164. package/src/shared/rpc-utils.test.ts +32 -0
  165. package/src/shared/rpc-utils.ts +38 -13
  166. package/src/shared/status-detail-text.test.ts +82 -0
  167. package/src/shared/status-detail-text.ts +57 -0
  168. package/src/shared/subagent-runner.ts +3 -1
  169. package/src/tui/data/context-db.ts +1 -0
  170. package/src/tui-compiled/data/context-db.ts +1 -0
  171. package/dist/index-td9depx5.js +0 -46
  172. package/dist/resolve-fallbacks-qf0ekmz9.js +0 -11
@@ -5,6 +5,14 @@ import { join } from "node:path";
5
5
 
6
6
  export type ProcessKind = "OpenCode server" | "OpenCode instance (TUI/CLI)" | "Pi" | "process";
7
7
 
8
+ /** Best-effort process details captured while validating a migration blocker. */
9
+ export interface ProcessProbeEvidence {
10
+ /** Epoch milliseconds, or null when the platform/probe cannot provide it. */
11
+ startTime: number | null;
12
+ /** The raw command line, or null when the platform/probe cannot provide it. */
13
+ commandLine: string | null;
14
+ }
15
+
8
16
  export interface RpcPortFileRecord {
9
17
  port: number;
10
18
  pid: number;
@@ -143,6 +151,24 @@ function readPsProcessStartTime(pid: number): number | null {
143
151
  }
144
152
  }
145
153
 
154
+ /** Read a process start time without changing the guard's liveness decision. */
155
+ export function readProcessStartTime(pid: number): number | null {
156
+ if (!Number.isInteger(pid) || pid <= 0) return null;
157
+ return rpcIdentityPlatform === "linux"
158
+ ? readLinuxProcessStartTime(pid)
159
+ : rpcIdentityPlatform === "win32"
160
+ ? null
161
+ : readPsProcessStartTime(pid);
162
+ }
163
+
164
+ /** Capture the command and start-time probes used to explain a blocker. */
165
+ export function readProcessProbeEvidence(pid: number): ProcessProbeEvidence {
166
+ return {
167
+ startTime: readProcessStartTime(pid),
168
+ commandLine: readProcessCommand(pid),
169
+ };
170
+ }
171
+
146
172
  interface ProcessListEntry {
147
173
  pid: number;
148
174
  command: string;
@@ -319,28 +345,27 @@ function commandLooksLikeOpenCode(command: string): boolean {
319
345
  */
320
346
  export type PidIdentityPlausibility = "plausible" | "implausible" | "inconclusive";
321
347
 
322
- export function isPidIdentityPlausible(record: RpcPortFileRecord): PidIdentityPlausibility {
348
+ export function isPidIdentityPlausible(
349
+ record: RpcPortFileRecord,
350
+ evidence?: ProcessProbeEvidence,
351
+ ): PidIdentityPlausibility {
323
352
  if (!Number.isInteger(record.pid) || record.pid <= 0) return "implausible";
324
353
 
325
354
  if (Number.isFinite(record.started_at) && record.started_at > 0) {
326
- const processStartTime =
327
- rpcIdentityPlatform === "linux"
328
- ? readLinuxProcessStartTime(record.pid)
329
- : rpcIdentityPlatform === "win32"
330
- ? null
331
- : readPsProcessStartTime(record.pid);
355
+ const processStartTime = evidence ? evidence.startTime : readProcessStartTime(record.pid);
332
356
  if (processStartTime === null) return "inconclusive";
333
357
  return processStartTime <= record.started_at + RPC_IDENTITY_SKEW_TOLERANCE_MS
334
358
  ? "plausible"
335
359
  : "implausible";
336
360
  }
337
361
 
338
- const command =
339
- rpcIdentityPlatform === "linux"
340
- ? readLinuxProcessCommand(record.pid)
341
- : rpcIdentityPlatform === "win32"
342
- ? (readWindowsProcess(record.pid).command ?? null)
343
- : readPsProcessCommand(record.pid);
362
+ const command = evidence
363
+ ? evidence.commandLine
364
+ : rpcIdentityPlatform === "linux"
365
+ ? readLinuxProcessCommand(record.pid)
366
+ : rpcIdentityPlatform === "win32"
367
+ ? (readWindowsProcess(record.pid).command ?? null)
368
+ : readPsProcessCommand(record.pid);
344
369
  if (command === null) return "inconclusive";
345
370
  return commandLooksLikeOpenCode(command) ? "plausible" : "implausible";
346
371
  }
@@ -0,0 +1,82 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import type { StatusDetail } from "./rpc-types";
3
+ import { formatStatusDetailMarkdown } from "./status-detail-text";
4
+
5
+ const STATUS_FIXTURE: StatusDetail = {
6
+ sessionId: "ses_status",
7
+ activeProfile: "work",
8
+ usagePercentage: 75,
9
+ inputTokens: 96_000,
10
+ contextLimit: 128_000,
11
+ systemPromptTokens: 4_000,
12
+ compartmentCount: 12,
13
+ memoryCount: 8,
14
+ memoryBlockCount: 3,
15
+ pendingOpsCount: 2,
16
+ historianRunning: true,
17
+ compartmentInProgress: true,
18
+ sessionNoteCount: 1,
19
+ readySmartNoteCount: 2,
20
+ cacheTtl: "5m",
21
+ lastTransformError: null,
22
+ lastDreamerRunAt: null,
23
+ projectIdentity: "/repo",
24
+ compartmentTokens: 22_000,
25
+ factTokens: 0,
26
+ memoryTokens: 1_200,
27
+ docsTokens: 500,
28
+ profileTokens: 100,
29
+ conversationTokens: 62_000,
30
+ toolCallTokens: 3_000,
31
+ toolDefinitionTokens: 3_200,
32
+ executeThreshold: 65,
33
+ executeThresholdClamped: false,
34
+ boundaryPresent: true,
35
+ coverageOrdinal: 12,
36
+ newWorkTokens: 1_000,
37
+ totalInputTokens: 96_000,
38
+ recompProgress: null,
39
+ tagCounter: 5,
40
+ activeTags: 4,
41
+ droppedTags: 1,
42
+ totalTags: 5,
43
+ activeBytes: 2_048,
44
+ lastResponseTime: 1,
45
+ lastNudgeTokens: 80_000,
46
+ pendingOps: [],
47
+ cacheTtlMs: 300_000,
48
+ cacheRemainingMs: 42_000,
49
+ cacheExpired: false,
50
+ cacheNeverExpires: false,
51
+ executeThresholdMode: "percentage",
52
+ protectedTagCount: 20,
53
+ historyBudgetPercentage: 0.15,
54
+ historyBlockTokens: 22_000,
55
+ compressionBudget: 12_480,
56
+ compressionUsage: "176%",
57
+ toastDurationMs: 5_000,
58
+ loggerDiagnostics: {
59
+ swallowedWriteCount: 0,
60
+ lastErrorMessage: null,
61
+ lastErrorTime: null,
62
+ },
63
+ storage_versions: {
64
+ context_db_schema_version: 79,
65
+ plugin_supported_version: 79,
66
+ },
67
+ };
68
+
69
+ describe("formatStatusDetailMarkdown", () => {
70
+ test("renders the fixed TUI status payload as compact markdown", () => {
71
+ expect(formatStatusDetailMarkdown(STATUS_FIXTURE)).toBe(`## Magic Context Status
72
+
73
+ - **Mode:** Magic Context compaction
74
+ - **Active profile:** work
75
+ - **Usage:** 75.0% (96,000 / 128,000 usable tokens)
76
+ - **Cache lane:** live (42s remaining); TTL 5m
77
+ - **Historian:** running; boundary present; coverage 12
78
+ - **Memory:** 8 active; 3 injected
79
+ - **Tags:** 4 active, 1 dropped; 2 pending drops
80
+ - **Execute threshold:** 65.0%`);
81
+ });
82
+ });
@@ -0,0 +1,57 @@
1
+ import type { StatusDetail } from "./rpc-types";
2
+
3
+ function formatCount(value: number): string {
4
+ return Math.round(value).toLocaleString();
5
+ }
6
+
7
+ function formatCacheLane(detail: StatusDetail): string {
8
+ if (detail.cacheNeverExpires) return `never expires; TTL ${detail.cacheTtl}`;
9
+ if (detail.lastResponseTime <= 0) return `waiting for first response; TTL ${detail.cacheTtl}`;
10
+ if (detail.cacheExpired) return `expired; TTL ${detail.cacheTtl}`;
11
+ return `live (${Math.round(detail.cacheRemainingMs / 1000)}s remaining); TTL ${detail.cacheTtl}`;
12
+ }
13
+
14
+ /** Render the same StatusDetail payload that powers the TUI dialog for chat-only clients. */
15
+ export function formatStatusDetailMarkdown(detail: StatusDetail): string {
16
+ const usableLimit =
17
+ detail.contextLimit > 0
18
+ ? `${formatCount(detail.contextLimit)} usable tokens`
19
+ : "? usable tokens";
20
+ const historianState = detail.historianRunning ? "running" : "idle";
21
+ const historianDetails = [
22
+ detail.boundaryPresent === undefined
23
+ ? undefined
24
+ : `boundary ${detail.boundaryPresent ? "present" : "absent"}`,
25
+ detail.coverageOrdinal === undefined
26
+ ? undefined
27
+ : `coverage ${detail.coverageOrdinal === null ? "none" : detail.coverageOrdinal}`,
28
+ ].filter((value): value is string => value !== undefined);
29
+ const mode =
30
+ detail.compaction_enabled === false
31
+ ? "native compaction (Magic Context history compaction disabled)"
32
+ : "Magic Context compaction";
33
+
34
+ const lines = [
35
+ "## Magic Context Status",
36
+ "",
37
+ `- **Mode:** ${mode}`,
38
+ `- **Active profile:** ${detail.activeProfile ?? "none"}`,
39
+ `- **Usage:** ${detail.usagePercentage.toFixed(1)}% (${formatCount(detail.inputTokens)} / ${usableLimit})`,
40
+ `- **Cache lane:** ${formatCacheLane(detail)}`,
41
+ `- **Historian:** ${[historianState, ...historianDetails].join("; ")}`,
42
+ `- **Memory:** ${formatCount(detail.memoryCount)} active; ${formatCount(detail.memoryBlockCount)} injected`,
43
+ `- **Tags:** ${formatCount(detail.activeTags)} active, ${formatCount(detail.droppedTags)} dropped; ${formatCount(detail.pendingOpsCount)} pending drops`,
44
+ `- **Execute threshold:** ${detail.executeThreshold.toFixed(1)}%${detail.executeThresholdClamped ? " (clamped)" : ""}`,
45
+ ];
46
+
47
+ if (detail.recompProgress?.phase === "recomp") {
48
+ lines.push(
49
+ `- **${detail.recompProgress.kind === "embed" ? "Embed" : "Historian"} progress:** ${formatCount(detail.recompProgress.processedMessages)} / ${formatCount(detail.recompProgress.totalMessages)}`,
50
+ );
51
+ }
52
+ if (detail.lastTransformError) {
53
+ lines.push(`- **Last transform error:** ${detail.lastTransformError}`);
54
+ }
55
+
56
+ return lines.join("\n");
57
+ }
@@ -29,6 +29,8 @@
29
29
  * the runner contract is purely additive on the OpenCode side.
30
30
  */
31
31
 
32
+ import type { ModelInput } from "./model-resolution";
33
+
32
34
  /**
33
35
  * Configuration for one subagent invocation.
34
36
  *
@@ -63,7 +65,7 @@ export interface SubagentRunOptions {
63
65
  systemPrompt: string;
64
66
  userMessage: string;
65
67
  model?: string | undefined;
66
- fallbackModels?: readonly string[];
68
+ fallbackModels?: readonly ModelInput[];
67
69
  timeoutMs?: number | undefined;
68
70
  cwd?: string | undefined;
69
71
  signal?: AbortSignal | undefined;
@@ -181,6 +181,7 @@ export async function loadStatusDetail(
181
181
  const emptyDetail: StatusDetail = {
182
182
  ...EMPTY_SNAPSHOT,
183
183
  sessionId,
184
+ activeProfile: null,
184
185
  tagCounter: 0,
185
186
  activeTags: 0,
186
187
  droppedTags: 0,
@@ -181,6 +181,7 @@ export async function loadStatusDetail(
181
181
  const emptyDetail: StatusDetail = {
182
182
  ...EMPTY_SNAPSHOT,
183
183
  sessionId,
184
+ activeProfile: null,
184
185
  tagCounter: 0,
185
186
  activeTags: 0,
186
187
  droppedTags: 0,
@@ -1,46 +0,0 @@
1
- // src/shared/resolve-fallbacks.ts
2
- function resolveFallbackChain(userFallbacks) {
3
- const userList = normalizeUserFallbacks(userFallbacks);
4
- return dedupe(userList.filter(isValidModelSpec));
5
- }
6
- function normalizeUserFallbacks(userFallbacks) {
7
- if (!userFallbacks)
8
- return [];
9
- if (typeof userFallbacks === "string") {
10
- const trimmed = userFallbacks.trim();
11
- return trimmed ? [trimmed] : [];
12
- }
13
- return userFallbacks.map((s) => s.trim()).filter((s) => s.length > 0);
14
- }
15
- function isValidModelSpec(spec) {
16
- const slash = spec.indexOf("/");
17
- return slash > 0 && slash < spec.length - 1;
18
- }
19
- function dedupe(list) {
20
- const seen = new Set;
21
- const out = [];
22
- for (const item of list) {
23
- if (seen.has(item))
24
- continue;
25
- seen.add(item);
26
- out.push(item);
27
- }
28
- return out;
29
- }
30
- function parseProviderModel(spec) {
31
- const slash = spec.indexOf("/");
32
- if (slash < 1 || slash >= spec.length - 1)
33
- return null;
34
- return {
35
- providerID: spec.slice(0, slash).trim(),
36
- modelID: spec.slice(slash + 1).trim()
37
- };
38
- }
39
- function modelBodyField(spec) {
40
- if (!spec)
41
- return {};
42
- const parsed = parseProviderModel(spec);
43
- return parsed ? { model: parsed } : {};
44
- }
45
-
46
- export { resolveFallbackChain, parseProviderModel, modelBodyField };
@@ -1,11 +0,0 @@
1
- import {
2
- modelBodyField,
3
- parseProviderModel,
4
- resolveFallbackChain
5
- } from "./index-td9depx5.js";
6
- import"./index-1yh8g550.js";
7
- export {
8
- modelBodyField,
9
- parseProviderModel,
10
- resolveFallbackChain
11
- };