@cortexkit/opencode-magic-context 0.49.14 → 0.49.16

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 (135) hide show
  1. package/dist/auto-search-worker.js +3 -3
  2. package/dist/chunk-embedding-write-worker.js +5 -3
  3. package/dist/config/schema/magic-context.d.ts +65 -65
  4. package/dist/config/schema/magic-context.d.ts.map +1 -1
  5. package/dist/{conflict-warning-hook-mgq17yr3.js → conflict-warning-hook-znry4j76.js} +5 -5
  6. package/dist/{context-cpxqpkzv.js → context-3znk23va.js} +128 -24
  7. package/dist/{embedding-backfill-5e1t5wha.js → embedding-backfill-q4n8dend.js} +8 -6
  8. package/dist/embedding-worker.js +2 -2
  9. package/dist/features/magic-context/dreamer/verify.d.ts +22 -3
  10. package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
  11. package/dist/features/magic-context/message-fts-rowid-map.d.ts +2 -2
  12. package/dist/features/magic-context/message-fts-rowid-map.d.ts.map +1 -1
  13. package/dist/features/magic-context/message-fts-session-filter.d.ts +2 -0
  14. package/dist/features/magic-context/message-fts-session-filter.d.ts.map +1 -1
  15. package/dist/features/magic-context/message-time-backfill.d.ts +2 -2
  16. package/dist/features/magic-context/message-time-backfill.d.ts.map +1 -1
  17. package/dist/features/magic-context/storage-db.d.ts +2 -1
  18. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  19. package/dist/hooks/magic-context/compartment-runner-historian.d.ts +2 -2
  20. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  21. package/dist/hooks/magic-context/compartment-runner-types.d.ts +2 -2
  22. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  23. package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
  24. package/dist/hooks/magic-context/emergency-drop.d.ts.map +1 -1
  25. package/dist/hooks/magic-context/historian-host-runner.d.ts.map +1 -1
  26. package/dist/hooks/magic-context/historian-prompt-fit.d.ts +2 -1
  27. package/dist/hooks/magic-context/historian-prompt-fit.d.ts.map +1 -1
  28. package/dist/hooks/magic-context/historian-prompt.generated.d.ts +1 -1
  29. package/dist/hooks/magic-context/historian-prompt.generated.d.ts.map +1 -1
  30. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts +26 -0
  31. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
  32. package/dist/hooks/magic-context/recomp-orchestrator.d.ts +3 -3
  33. package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
  34. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  35. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  36. package/dist/{index-xn6q9pg6.js → index-4qfy7v57.js} +11 -62
  37. package/dist/{index-e4dsjj1p.js → index-5mwk1nek.js} +1 -1
  38. package/dist/index-6a6dq53h.js +96 -0
  39. package/dist/{index-e20m7284.js → index-7b2cfmaz.js} +1 -1
  40. package/dist/{index-mmfa86mt.js → index-7pa32z07.js} +169 -149
  41. package/dist/{index-3kdm78zp.js → index-9nkg2dzk.js} +3 -3
  42. package/dist/{index-t4q9zbbf.js → index-ayym1x7f.js} +119 -30
  43. package/dist/{index-dgs16axy.js → index-b17m64g9.js} +1 -1
  44. package/dist/{index-yxycg7fs.js → index-cj9g0j7a.js} +22 -14
  45. package/dist/{index-dyvbsvga.js → index-dqe8pq4x.js} +21 -10
  46. package/dist/{index-5591fg8y.js → index-ek1yxvvz.js} +44 -77
  47. package/dist/{index-3kx0kg0f.js → index-hehkf6zm.js} +3 -3
  48. package/dist/{index-944w16m0.js → index-j6zw70pf.js} +4 -4
  49. package/dist/index-kaqs6h31.js +58 -0
  50. package/dist/{index-w900fbhd.js → index-kn4t1haw.js} +15 -12
  51. package/dist/{index-1d289pq2.js → index-mtw9e71a.js} +1 -1
  52. package/dist/{index-mht7bq0z.js → index-nd7m2a5a.js} +7 -5
  53. package/dist/{index-thvnpfsv.js → index-p4vde22c.js} +14 -14
  54. package/dist/{index-y1qysm3q.js → index-qrahzcqv.js} +3 -3
  55. package/dist/{index-kf4epshg.js → index-v63beg1z.js} +3 -3
  56. package/dist/{index-tyckte5c.js → index-v9asb16b.js} +4 -4
  57. package/dist/{index-1sarmj9z.js → index-wgypt3cs.js} +6 -6
  58. package/dist/{index-bxdg2nbt.js → index-wv9n2zcq.js} +1 -1
  59. package/dist/index.js +38 -36
  60. package/dist/message-fts-rowid-map-yvx5a9jw.js +23 -0
  61. package/dist/{message-index-bounded-vtgpq6b4.js → message-index-bounded-6th8djy9.js} +8 -8
  62. package/dist/{message-index-a6gztaqx.js → message-index-t4pz7akd.js} +9 -9
  63. package/dist/{message-time-backfill-qjge9044.js → message-time-backfill-8egzkd3z.js} +4 -4
  64. package/dist/migration-worker.js +4 -2
  65. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  66. package/dist/{project-embedding-registry-x45bv3qr.js → project-embedding-registry-2dea0a77.js} +7 -5
  67. package/dist/raw-ordinal-warmup-worker.js +37 -7
  68. package/dist/{read-session-chunk-3ae3nfdn.js → read-session-chunk-4pwqxm5a.js} +6 -6
  69. package/dist/{read-session-raw-m56hc7v2.js → read-session-raw-5ar8se5v.js} +1 -1
  70. package/dist/{recomp-orchestrator-xqb9gwgm.js → recomp-orchestrator-tjcaj5x7.js} +17 -17
  71. package/dist/search-archive-02jws7hw.js +25 -0
  72. package/dist/{search-deajrd90.js → search-rb01n29x.js} +15 -14
  73. package/dist/{send-session-notification-24r4esbh.js → send-session-notification-2x9edkrp.js} +4 -4
  74. package/dist/shared/model-suggestion-retry.d.ts +2 -0
  75. package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
  76. package/dist/shared/resolve-fallbacks.d.ts +3 -3
  77. package/dist/{storage-tags-s5bg1ahx.js → storage-tags-4z1w27xa.js} +1 -1
  78. package/dist/tools/ctx-expand/search-archive.d.ts +5 -1
  79. package/dist/tools/ctx-expand/search-archive.d.ts.map +1 -1
  80. package/dist/{transform-postprocess-phase-k5t63qm5.js → transform-postprocess-phase-xaw5c3xp.js} +17 -17
  81. package/dist/v2/auto-search-worker.js +3 -3
  82. package/dist/v2/chunk-embedding-write-worker.js +8 -6
  83. package/dist/v2/{context-k4jrq71s.js → context-acw1nhv8.js} +164 -91
  84. package/dist/v2/{embedding-backfill-jmaf8zrr.js → embedding-backfill-jyd6492b.js} +10 -8
  85. package/dist/v2/embedding-worker.js +2 -2
  86. package/dist/v2/hidden-completion.d.ts +20 -1
  87. package/dist/v2/hidden-completion.d.ts.map +1 -1
  88. package/dist/v2/hooks/context.d.ts.map +1 -1
  89. package/dist/v2/hooks/hidden-child.d.ts +19 -0
  90. package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
  91. package/dist/v2/message-fts-rowid-map-8vf0v7cr.js +22 -0
  92. package/dist/v2/{message-index-bounded-rxxznd34.js → message-index-bounded-dsrf49y7.js} +7 -7
  93. package/dist/v2/{message-index-f947qtbz.js → message-index-e6qzw477.js} +8 -8
  94. package/dist/v2/{message-time-backfill-bsteyc4d.js → message-time-backfill-q5pgxf0d.js} +4 -4
  95. package/dist/v2/migration-worker.js +6 -4
  96. package/dist/v2/{project-embedding-registry-0msp56p8.js → project-embedding-registry-rek75aqw.js} +9 -7
  97. package/dist/v2/raw-ordinal-warmup-worker.js +37 -7
  98. package/dist/v2/{read-session-chunk-rq9nx1nn.js → read-session-chunk-7bpygfv2.js} +5 -5
  99. package/dist/v2/{read-session-raw-b3tf6ra1.js → read-session-raw-pw2n1qgc.js} +1 -1
  100. package/dist/v2/{recomp-orchestrator-1j1nqrrr.js → recomp-orchestrator-hzpgg06e.js} +18 -18
  101. package/dist/v2/search-archive-fn4wy8sx.js +24 -0
  102. package/dist/v2/{search-n8wqxb1j.js → search-sf2vg5pk.js} +17 -16
  103. package/dist/v2/{send-session-notification-8ghn9tnv.js → send-session-notification-hmr7q0nt.js} +2 -2
  104. package/dist/v2/{server-k2bzedxk.js → server-00hx04yn.js} +1 -1
  105. package/dist/v2/{server-atbc19ab.js → server-0mzjjw3s.js} +7 -5
  106. package/dist/v2/{server-ehyava47.js → server-1hcbw661.js} +3 -3
  107. package/dist/v2/{server-th4y11y7.js → server-271qxsf5.js} +6 -6
  108. package/dist/v2/{server-prg55b7k.js → server-6714jebr.js} +22 -2
  109. package/dist/v2/{server-fnqxt9j6.js → server-6fyp0v67.js} +120 -31
  110. package/dist/v2/{server-yrvqaswb.js → server-785mb90s.js} +21 -10
  111. package/dist/v2/{server-ef89gdsx.js → server-aavz8pm6.js} +3 -3
  112. package/dist/v2/{server-gvkm8xaj.js → server-e3ftpk7v.js} +1 -1
  113. package/dist/v2/{server-e298hswg.js → server-g59aatsz.js} +14 -14
  114. package/dist/v2/{server-g10mdym6.js → server-gha9x4qq.js} +1 -1
  115. package/dist/v2/{server-4gn3z5an.js → server-hgg55hde.js} +1 -1
  116. package/dist/v2/server-kaqs6h31.js +58 -0
  117. package/dist/v2/{server-qhfvvfxj.js → server-kqpawe1a.js} +3 -3
  118. package/dist/v2/{server-hek6z3w6.js → server-kr2kc9dz.js} +5 -5
  119. package/dist/v2/{server-cfbr1s2x.js → server-n5q841qn.js} +12 -63
  120. package/dist/v2/{server-kmbarfmn.js → server-r9gjxcte.js} +24 -16
  121. package/dist/v2/{server-6cdy4rc0.js → server-vgpab6rd.js} +2 -2
  122. package/dist/v2/{server-zc3e54vy.js → server-y5pznjt9.js} +1 -1
  123. package/dist/v2/server-zyw55ygv.js +96 -0
  124. package/dist/v2/server.js +4 -4
  125. package/dist/v2/{storage-tags-hcc2adpf.js → storage-tags-hkwtbp3g.js} +1 -1
  126. package/dist/v2/store-reader.d.ts +27 -1
  127. package/dist/v2/store-reader.d.ts.map +1 -1
  128. package/dist/v2/{wrapup-orchestrator-hkv8apcc.js → wrapup-orchestrator-x4xj1782.js} +18 -18
  129. package/dist/{wrapup-orchestrator-kxqj4rwh.js → wrapup-orchestrator-vj2tbp22.js} +18 -18
  130. package/package.json +1 -1
  131. package/src/config/schema/magic-context.ts +14 -6
  132. package/src/shared/model-resolution.test.ts +22 -0
  133. package/src/shared/model-suggestion-retry.ts +9 -3
  134. package/src/shared/resolve-fallbacks.test.ts +2 -3
  135. package/src/shared/resolve-fallbacks.ts +3 -3
@@ -1,42 +1,42 @@
1
1
  import {
2
2
  runManagedWrapup2
3
- } from "./index-tyckte5c.js";
4
- import"./index-kf4epshg.js";
5
- import"./index-t4q9zbbf.js";
3
+ } from "./index-v9asb16b.js";
4
+ import"./index-v63beg1z.js";
5
+ import"./index-ayym1x7f.js";
6
6
  import"./index-f71thw8j.js";
7
- import"./index-bxdg2nbt.js";
8
- import"./index-thvnpfsv.js";
7
+ import"./index-wv9n2zcq.js";
8
+ import"./index-p4vde22c.js";
9
9
  import"./index-sd3egckz.js";
10
- import"./index-3kdm78zp.js";
11
- import"./index-y1qysm3q.js";
10
+ import"./index-9nkg2dzk.js";
11
+ import"./index-qrahzcqv.js";
12
12
  import"./index-n78avt2p.js";
13
13
  import"./index-4dhv7mqz.js";
14
14
  import"./index-v10f1rjv.js";
15
- import"./index-dgs16axy.js";
15
+ import"./index-b17m64g9.js";
16
16
  import"./index-qt1qqasc.js";
17
- import"./index-944w16m0.js";
18
- import"./index-mht7bq0z.js";
17
+ import"./index-j6zw70pf.js";
18
+ import"./index-nd7m2a5a.js";
19
19
  import"./index-1zx87sdm.js";
20
- import"./index-1d289pq2.js";
21
- import"./index-mmfa86mt.js";
22
- import"./index-v0p37hm2.js";
20
+ import"./index-mtw9e71a.js";
23
21
  import"./index-x8a7jmkh.js";
24
22
  import"./index-y9f76s3f.js";
25
- import"./index-e20m7284.js";
26
- import"./index-1sarmj9z.js";
23
+ import"./index-7b2cfmaz.js";
24
+ import"./index-wgypt3cs.js";
27
25
  import"./index-saews2s3.js";
28
- import"./index-3kx0kg0f.js";
26
+ import"./index-hehkf6zm.js";
29
27
  import"./index-fkx2qnvw.js";
30
- import"./index-yxycg7fs.js";
28
+ import"./index-cj9g0j7a.js";
31
29
  import"./index-fb3zxn06.js";
32
30
  import"./index-wk0n1cgt.js";
33
31
  import"./index-a8bvhwqs.js";
34
- import"./index-dyvbsvga.js";
32
+ import"./index-dqe8pq4x.js";
35
33
  import"./index-fr0wbhdn.js";
36
34
  import"./index-nj7yykkx.js";
37
35
  import"./index-n6m03s3n.js";
38
36
  import"./index-bp5083x2.js";
39
37
  import"./index-58e3y90n.js";
38
+ import"./index-7pa32z07.js";
39
+ import"./index-v0p37hm2.js";
40
40
  import"./index-k29z4aqh.js";
41
41
  import"./index-hqkczed7.js";
42
42
  import"./index-wafzvyhg.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/opencode-magic-context",
3
- "version": "0.49.14",
3
+ "version": "0.49.16",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",
@@ -205,12 +205,14 @@ export type OmpEntry = z.infer<typeof OmpEntrySchema>;
205
205
  /** Strict model-resolution block used by historian.opencode. */
206
206
  export const OpenCodeHarnessBlockSchema = z
207
207
  .object({
208
- model: OcEntrySchema.optional().describe("Primary OpenCode model entry."),
208
+ model: OcEntrySchema.optional().describe(
209
+ "Primary historian OpenCode model entry. When set, only this model and fallback_models are used; exhaustion reports failure, never the session model. When absent, OpenCode inherits the session model.",
210
+ ),
209
211
  fallback_models: z
210
212
  .array(OcEntrySchema)
211
213
  .optional()
212
214
  .describe(
213
- "Ordered fallback OpenCode entries. New-shape configuration requires an array; legacy singleton values migrate to a one-element array.",
215
+ "Ordered historian fallback OpenCode entries. A configured primary never adds the session model after this list. Requires an array; legacy singleton values migrate to a one-element array.",
214
216
  ),
215
217
  variant: z
216
218
  .string()
@@ -226,12 +228,14 @@ export type OpenCodeHarnessBlock = z.infer<typeof OpenCodeHarnessBlockSchema>;
226
228
  /** Strict model-resolution block used by historian.pi. */
227
229
  export const PiHarnessBlockSchema = z
228
230
  .object({
229
- model: PiEntrySchema.optional().describe("Primary Pi model entry."),
231
+ model: PiEntrySchema.optional().describe(
232
+ "Primary historian Pi model entry. When set, only this model and fallback_models are used; exhaustion reports failure, never the session model. When absent, Pi does not run the historian.",
233
+ ),
230
234
  fallback_models: z
231
235
  .array(PiEntrySchema)
232
236
  .optional()
233
237
  .describe(
234
- "Ordered fallback Pi entries. New-shape configuration requires an array; legacy singleton values migrate to a one-element array.",
238
+ "Ordered historian fallback Pi entries. The session model is never appended. Requires an array; legacy singleton values migrate to a one-element array.",
235
239
  ),
236
240
  thinking_level: PiThinkingLevelSchema.describe(
237
241
  "Pi thinking level for the primary entry when it declares none. Fallback entries declare thinking levels per-entry.",
@@ -244,11 +248,15 @@ export type PiHarnessBlock = z.infer<typeof PiHarnessBlockSchema>;
244
248
  /** Strict model-resolution block used by historian.omp. */
245
249
  export const OmpHarnessBlockSchema = z
246
250
  .object({
247
- model: OmpEntrySchema.optional().describe("Primary OMP model entry."),
251
+ model: OmpEntrySchema.optional().describe(
252
+ "Primary historian OMP model entry. When set, only this model and fallback_models are used; exhaustion reports failure, never the session model. An absent OMP block inherits the Pi block; a selected block without a model does not run the historian.",
253
+ ),
248
254
  fallback_models: z
249
255
  .array(OmpEntrySchema)
250
256
  .optional()
251
- .describe("Ordered fallback OMP entries."),
257
+ .describe(
258
+ "Ordered historian fallback OMP entries. The session model is never appended.",
259
+ ),
252
260
  thinking_level: OmpThinkingLevelSchema.describe(
253
261
  "OMP thinking level for the primary entry when it declares none. Fallback entries declare thinking levels per-entry.",
254
262
  ),
@@ -1,4 +1,5 @@
1
1
  import { describe, expect, test } from "bun:test";
2
+ import { parsePluginConfig } from "../config";
2
3
 
3
4
  import {
4
5
  normalizeModelEntry,
@@ -9,6 +10,27 @@ import {
9
10
  } from "./model-resolution";
10
11
 
11
12
  describe("model-resolution", () => {
13
+ test("loader defaults and historian metadata do not configure a primary model", () => {
14
+ for (const harness of ["opencode", "pi", "omp"] as const) {
15
+ for (const input of [
16
+ {},
17
+ { historian: {} },
18
+ { historian: { temperature: 0, [harness]: {} } },
19
+ ]) {
20
+ expect(
21
+ resolveHistorianModel(parsePluginConfig(input), harness).primary,
22
+ ).toBeUndefined();
23
+ }
24
+ for (const model of [" provider/explicit ", { model: "provider/explicit" }]) {
25
+ expect(
26
+ resolveHistorianModel(
27
+ parsePluginConfig({ historian: { [harness]: { model } } }),
28
+ harness,
29
+ ).primary?.model,
30
+ ).toBe("provider/explicit");
31
+ }
32
+ }
33
+ });
12
34
  test("keeps historian temperature opt-in while preserving explicit overrides", () => {
13
35
  const fixtures = [
14
36
  { temperature: undefined, expected: undefined },
@@ -72,6 +72,8 @@ export interface PromptAttemptInfo {
72
72
  export interface PromptRetryOptions {
73
73
  transport?: PromptTransport;
74
74
  timeoutMs?: number;
75
+ /** False for callers whose configured model chain must not accept provider suggestions. Defaults to true. */
76
+ allowModelSuggestions?: boolean;
75
77
  /** External abort signal — cancels the in-flight LLM prompt immediately when aborted */
76
78
  signal?: AbortSignal;
77
79
  /**
@@ -508,6 +510,7 @@ async function attemptOnce(
508
510
  callContext: string,
509
511
  label: string,
510
512
  transport?: PromptTransport,
513
+ allowModelSuggestions = true,
511
514
  ): Promise<void> {
512
515
  // Keep this snapshot separate from the object passed to the client. A
513
516
  // failed prompt facade may rewrite its request body before rejecting; the
@@ -518,9 +521,9 @@ async function attemptOnce(
518
521
  await promptWithTimeout(client, attemptArgs, timeoutMs, signal, transport);
519
522
  return;
520
523
  } catch (error) {
521
- // If non-retryable (abort, overflow, timeout), bubble up immediately.
522
- // Don't even try suggestion retry — caller needs the original error.
523
- if (isNonRetryable(error, signal)) throw error;
524
+ // Non-retryable failures and callers with model suggestions disabled
525
+ // must surface the original error without accepting a provider suggestion.
526
+ if (isNonRetryable(error, signal) || !allowModelSuggestions) throw error;
524
527
 
525
528
  const suggestion = parseModelSuggestion(error);
526
529
  if (!suggestion || !originalBody.model) {
@@ -596,6 +599,7 @@ export async function promptSyncWithModelSuggestionRetry(
596
599
  callContext,
597
600
  explicitPrimaryLabel,
598
601
  options.transport,
602
+ options.allowModelSuggestions,
599
603
  );
600
604
  return;
601
605
  } catch (error) {
@@ -640,6 +644,7 @@ export async function promptSyncWithModelSuggestionRetry(
640
644
  callContext,
641
645
  label,
642
646
  options.transport,
647
+ options.allowModelSuggestions,
643
648
  );
644
649
  log(
645
650
  `[${callContext}] fallback succeeded with ${label} (attempt ${i + 2}/${fallbacks.length + 1})`,
@@ -685,6 +690,7 @@ async function attemptAndValidate<TOutput, TValidated>(
685
690
  callContext,
686
691
  attempt.label,
687
692
  options.transport,
693
+ options.allowModelSuggestions,
688
694
  );
689
695
  } catch (error) {
690
696
  throw {
@@ -4,9 +4,8 @@ import { modelBodyField, parseProviderModel, resolveFallbackChain } from "./reso
4
4
 
5
5
  describe("resolveFallbackChain", () => {
6
6
  // Policy: user-config-only. There is NO builtin provider-agnostic chain —
7
- // when the user configures no fallback_models the result is EMPTY, and the
8
- // runner's session-model last resort (a model the user actually has) is the
9
- // only fallback. A hardcoded chain named providers the user may not have and
7
+ // when the user configures no fallback_models the result is empty.
8
+ // A hardcoded chain named providers the user may not have and
10
9
  // produced `Model not found` retry storms.
11
10
  test("returns empty when user provides nothing (no builtin chain)", () => {
12
11
  expect(resolveFallbackChain(undefined)).toEqual([]);
@@ -9,9 +9,9 @@ import type { ModelInput, ResolvedModelEntry } from "./model-resolution";
9
9
  * inevitably names providers the user doesn't have (e.g. a metapi-only user got
10
10
  * a chain of google/github-copilot/opencode entries, every one a
11
11
  * `Model not found` retry), which produced confusing errors and wasted
12
- * attempts. If the user configured nothing, this returns an empty list and the
13
- * runner's session-model last resort (the model the user is actually using) is
14
- * the only fallback.
12
+ * attempts. If the user configured no alternates, this returns an empty list.
13
+ * A configured historian never adds the session model to this list; only an
14
+ * unconfigured OpenCode historian inherits the session model.
15
15
  *
16
16
  * The returned list does NOT include the primary model — it's the ordered list
17
17
  * of *alternates* to try after the primary fails. Each entry is