@cortexkit/opencode-magic-context 0.49.78 → 0.49.80
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/auto-search-worker.js +2 -2
- package/dist/chunk-embedding-write-worker.js +1 -1
- package/dist/{context-6pxdmpay.js → context-7rkrv5q8.js} +162 -68
- package/dist/{derive-budgets-def8genf.js → derive-budgets-2z6xxm7e.js} +1 -1
- package/dist/{embedding-backfill-rrmzvg7n.js → embedding-backfill-0tvprmrn.js} +1 -1
- package/dist/features/magic-context/dreamer/curate-category-rotation.d.ts +1 -1
- package/dist/features/magic-context/dreamer/curate-category-rotation.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/curate-memory-safety.d.ts +5 -1
- package/dist/features/magic-context/dreamer/curate-memory-safety.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts +2 -0
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-backfill.d.ts +4 -0
- package/dist/features/magic-context/memory/embedding-backfill.d.ts.map +1 -1
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/hooks/magic-context/image-token-estimate.d.ts.map +1 -1
- package/dist/{index-16h5fhem.js → index-177yv84k.js} +4 -6
- package/dist/{index-8mt6vvwx.js → index-2q0t43fy.js} +1 -1
- package/dist/{index-jfs6k0xk.js → index-9554nr2q.js} +6 -6
- package/dist/{index-kn23xzst.js → index-aawwdt26.js} +1 -1
- package/dist/{index-dcdk1thy.js → index-exvsw656.js} +7 -7
- package/dist/{index-7jj5jk78.js → index-ezgeq2z7.js} +5 -5
- package/dist/{index-xkn7vq89.js → index-hpmx99e9.js} +4 -4
- package/dist/{index-c3a833vk.js → index-jhhkb4jv.js} +2 -2
- package/dist/{index-cssarkg7.js → index-m4q6ptgz.js} +4 -4
- package/dist/{index-r865s8hf.js → index-m6rkq3t4.js} +1 -1
- package/dist/{index-1pfjvk89.js → index-mgvj4vkb.js} +7 -7
- package/dist/{index-ngwmx6nt.js → index-tky3j43e.js} +47 -5
- package/dist/{index-k6b1av2m.js → index-twmeey4h.js} +2 -2
- package/dist/{index-enpatj5k.js → index-v0epndb8.js} +7 -7
- package/dist/{index-c7xvvhdd.js → index-xjpemea9.js} +115 -68
- package/dist/{index-rjm4hjyb.js → index-xsdaz3mq.js} +1 -1
- package/dist/{index-bdnak4d0.js → index-y208s7zx.js} +5 -3
- package/dist/{index-72qk8fs8.js → index-zpd4pxnp.js} +13 -8
- package/dist/{index-vr6t0y4w.js → index-zzvd4a9z.js} +1 -1
- package/dist/index.js +21 -21
- package/dist/{message-index-bounded-s0bckzqz.js → message-index-bounded-cfkeyf72.js} +3 -3
- package/dist/migration-worker.js +1 -1
- package/dist/raw-ordinal-warmup-worker.js +4 -4
- package/dist/{read-session-chunk-kqyb1y8c.js → read-session-chunk-s3qac56g.js} +2 -2
- package/dist/{recomp-orchestrator-38ed4yhj.js → recomp-orchestrator-n7h0a0tn.js} +10 -10
- package/dist/{render-8s531gd5.js → render-bjxgkrk6.js} +6 -6
- package/dist/{search-archive-2f1j2dh8.js → search-archive-p3jhx9wc.js} +4 -4
- package/dist/{search-m4r4v4aw.js → search-z56487n8.js} +7 -7
- package/dist/shared/models-dev-cache.d.ts +2 -0
- package/dist/shared/models-dev-cache.d.ts.map +1 -1
- package/dist/shared/subagent-runner.d.ts +9 -0
- package/dist/shared/subagent-runner.d.ts.map +1 -1
- package/dist/{storage-tags-d3nqrva7.js → storage-tags-6e83pvff.js} +1 -1
- package/dist/{store-j5rvve3v.js → store-8trkpmtx.js} +3 -1
- package/dist/{transform-postprocess-phase-ch5fsw7h.js → transform-postprocess-phase-f0wssyce.js} +11 -11
- package/dist/v2/auto-search-worker.js +2 -2
- package/dist/v2/chunk-embedding-write-worker.js +2 -2
- package/dist/v2/{context-h3r9gxrd.js → context-r1swhysg.js} +256 -119
- package/dist/v2/{derive-budgets-z93fdnp7.js → derive-budgets-2eam671q.js} +2 -2
- package/dist/v2/{embedding-backfill-g9scycm5.js → embedding-backfill-qnaswpmb.js} +1 -1
- package/dist/v2/fold/native-replay.d.ts.map +1 -1
- package/dist/v2/fold/owner.d.ts +2 -4
- package/dist/v2/fold/owner.d.ts.map +1 -1
- package/dist/v2/fold/partial-boundary.d.ts +25 -0
- package/dist/v2/fold/partial-boundary.d.ts.map +1 -0
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/{message-index-bounded-vfx2zx9y.js → message-index-bounded-0xy4dn04.js} +3 -3
- package/dist/v2/migration-worker.js +2 -2
- package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
- package/dist/v2/{read-session-chunk-bh402br0.js → read-session-chunk-6mt2t6dy.js} +2 -2
- package/dist/v2/{recomp-orchestrator-43grkr1k.js → recomp-orchestrator-4w2w4kd4.js} +12 -12
- package/dist/v2/{render-90pve6jf.js → render-hwqk0d8t.js} +7 -7
- package/dist/v2/{search-archive-ha08g13n.js → search-archive-mdxzvgpm.js} +4 -4
- package/dist/v2/{search-xr5wb3a3.js → search-eftsvbg7.js} +6 -6
- package/dist/v2/{server-86vydsx9.js → server-0dmzr7f9.js} +2 -2
- package/dist/v2/{server-kmaxv4g3.js → server-25qtxt4d.js} +6 -6
- package/dist/v2/{server-6jxvkyrr.js → server-2gcfmd47.js} +1 -1
- package/dist/v2/{server-wc0bb04b.js → server-34pvhvxt.js} +8 -8
- package/dist/v2/{server-468mya5v.js → server-39bcszk4.js} +47 -1
- package/dist/v2/{server-b8qp1ark.js → server-76v5y7zm.js} +2 -2
- package/dist/v2/{server-9sf3qp02.js → server-bj779zmp.js} +1 -1
- package/dist/v2/{server-gsz7h1zr.js → server-dhdn8mwq.js} +1 -1
- package/dist/v2/{server-92fhew3p.js → server-fqnty3nk.js} +10 -10
- package/dist/v2/{server-qcbxjpkv.js → server-ma9jwnas.js} +4 -4
- package/dist/v2/{server-2adwe0be.js → server-nqdzv8b7.js} +47 -5
- package/dist/v2/{server-65r7p1z4.js → server-pxdpwycq.js} +12 -7
- package/dist/v2/{server-fw2sjpkx.js → server-r00xyx66.js} +1 -1
- package/dist/v2/{server-aewxmvnf.js → server-rp52f40v.js} +1 -1
- package/dist/v2/{server-10af6m7d.js → server-x8ksqcw7.js} +4 -6
- package/dist/v2/{server-cxkb9725.js → server-xdh4r20h.js} +5 -3
- package/dist/v2/{server-fjd90bk0.js → server-zw1e3wq5.js} +2 -2
- package/dist/v2/server.js +4 -4
- package/dist/v2/{storage-tags-j4he6hwe.js → storage-tags-z8j8wq34.js} +1 -1
- package/dist/v2/{store-1fax2zhj.js → store-m3zny7q2.js} +4 -2
- package/dist/v2/{v2-archive-reader-xs0d7yyr.js → v2-archive-reader-p89x05hj.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-ghbsa00k.js → wrapup-orchestrator-0f4nwpbv.js} +12 -12
- package/dist/{v2-archive-reader-maj9xst8.js → v2-archive-reader-vzmzb245.js} +1 -1
- package/dist/{wrapup-orchestrator-q12ejyw9.js → wrapup-orchestrator-5k9hgb3t.js} +11 -11
- package/package.json +1 -1
- package/src/shared/models-dev-cache.test.ts +67 -1
- package/src/shared/models-dev-cache.ts +71 -4
- package/src/shared/subagent-runner.ts +10 -0
|
@@ -105,6 +105,10 @@ const reserveClampLogSeen = new Set<string>();
|
|
|
105
105
|
*/
|
|
106
106
|
let apiCache: Map<string, CachedModelMetadata> | null = null;
|
|
107
107
|
let apiLoadedAt = 0;
|
|
108
|
+
// An OpenCode 2 draft is evidence for that exact model's window, not a new
|
|
109
|
+
// catalog snapshot or evidence about another model's capabilities.
|
|
110
|
+
const v2DraftModelLimits = new Map<string, CachedModelMetadata>();
|
|
111
|
+
const v2DraftModelLimitLogged = new Set<string>();
|
|
108
112
|
|
|
109
113
|
// Persisted last-known-good apiCache (OpenCode). Survives restart so a cold
|
|
110
114
|
// start uses the real limit instantly instead of falling to the disk file or the
|
|
@@ -443,6 +447,7 @@ async function refreshModelLimitsOnce(client: OpencodeClientLike): Promise<boole
|
|
|
443
447
|
|
|
444
448
|
const previousSize = apiCache?.size ?? null;
|
|
445
449
|
apiCache = map;
|
|
450
|
+
v2DraftModelLimits.clear();
|
|
446
451
|
apiLoadedAt = Date.now();
|
|
447
452
|
// Persist the freshly-resolved (sane-filtered) limits so the next process
|
|
448
453
|
// cold-starts with the real values instead of the 128k default.
|
|
@@ -470,6 +475,69 @@ async function refreshModelLimitsOnce(client: OpencodeClientLike): Promise<boole
|
|
|
470
475
|
}
|
|
471
476
|
}
|
|
472
477
|
|
|
478
|
+
/** Supply window metadata for the selected OpenCode 2 model during a catalog failure. */
|
|
479
|
+
export function useV2DraftModelLimits(
|
|
480
|
+
providerID: string,
|
|
481
|
+
modelID: string,
|
|
482
|
+
limit: ModelLimit | undefined,
|
|
483
|
+
): boolean {
|
|
484
|
+
loadPersistedApiCacheOnce();
|
|
485
|
+
const key = `${providerID}/${modelID}`;
|
|
486
|
+
const cached = lookupMetadataWithTagFallback(apiCache, providerID, modelID);
|
|
487
|
+
const valid = (value: number | undefined) =>
|
|
488
|
+
isFinitePositive(value) && value <= MAX_SANE_LIMIT ? value : undefined;
|
|
489
|
+
const draft = {
|
|
490
|
+
context: valid(limit?.context),
|
|
491
|
+
input: valid(limit?.input),
|
|
492
|
+
output: valid(limit?.output),
|
|
493
|
+
};
|
|
494
|
+
const geometry = (raw: ModelLimit) =>
|
|
495
|
+
deriveWindowGeometry(providerID, modelID, raw, {
|
|
496
|
+
outputReserveOverride: resolveOutputReserve(providerID, modelID),
|
|
497
|
+
harness: "opencode",
|
|
498
|
+
})?.usableSoft;
|
|
499
|
+
const draftWindow = geometry(draft);
|
|
500
|
+
const merged: ModelLimit = {
|
|
501
|
+
context: cached?.contextLimit ?? draft.context ?? cached?.limit,
|
|
502
|
+
input: cached?.inputLimit ?? draft.input,
|
|
503
|
+
output: cached?.outputLimit ?? draft.output,
|
|
504
|
+
};
|
|
505
|
+
const window = geometry(merged);
|
|
506
|
+
// Keep authoritative values, but do not admit a turn on a stale window
|
|
507
|
+
// that is wider than the current draft can support.
|
|
508
|
+
if (window === undefined || window <= 0 || (draftWindow !== undefined && window > draftWindow))
|
|
509
|
+
return false;
|
|
510
|
+
|
|
511
|
+
if (
|
|
512
|
+
merged.context !== (cached?.contextLimit ?? cached?.limit) ||
|
|
513
|
+
merged.input !== cached?.inputLimit ||
|
|
514
|
+
merged.output !== cached?.outputLimit
|
|
515
|
+
) {
|
|
516
|
+
v2DraftModelLimits.set(key, {
|
|
517
|
+
contextLimit: merged.context,
|
|
518
|
+
inputLimit: merged.input,
|
|
519
|
+
outputLimit: merged.output,
|
|
520
|
+
});
|
|
521
|
+
} else v2DraftModelLimits.delete(key);
|
|
522
|
+
if (!v2DraftModelLimitLogged.has(key)) {
|
|
523
|
+
v2DraftModelLimitLogged.add(key);
|
|
524
|
+
sessionLog(
|
|
525
|
+
"global",
|
|
526
|
+
`v2 model catalog lookup failed for ${key}; using selected model limits`,
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
return true;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
function windowMetadata(providerID: string, modelID: string): CachedModelMetadata | undefined {
|
|
533
|
+
loadPersistedApiCacheOnce();
|
|
534
|
+
return (
|
|
535
|
+
(getHarness() === "opencode2"
|
|
536
|
+
? v2DraftModelLimits.get(`${providerID}/${modelID}`)
|
|
537
|
+
: undefined) ?? lookupMetadataWithTagFallback(apiCache, providerID, modelID)
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
|
|
473
541
|
/**
|
|
474
542
|
* Resolve a model's prompt limit from OpenCode's SDK (`config.providers()`),
|
|
475
543
|
* the single source of truth: it already merges models.dev + compiled-in
|
|
@@ -499,8 +567,7 @@ export function getSdkWindowGeometry(
|
|
|
499
567
|
harness?: "opencode" | "pi";
|
|
500
568
|
},
|
|
501
569
|
): WindowGeometryResult | undefined {
|
|
502
|
-
|
|
503
|
-
const metadata = lookupMetadataWithTagFallback(apiCache, providerID, modelID);
|
|
570
|
+
const metadata = windowMetadata(providerID, modelID);
|
|
504
571
|
if (!metadata) return undefined;
|
|
505
572
|
const rawContext = metadata.contextLimit ?? metadata.limit;
|
|
506
573
|
const promptOnlyDetected =
|
|
@@ -551,8 +618,7 @@ export function getSdkContextLimit(
|
|
|
551
618
|
detectedLimitProvenance: options?.detectedLimitProvenance,
|
|
552
619
|
})?.usableSoft;
|
|
553
620
|
}
|
|
554
|
-
|
|
555
|
-
const metadata = lookupMetadataWithTagFallback(apiCache, providerID, modelID);
|
|
621
|
+
const metadata = windowMetadata(providerID, modelID);
|
|
556
622
|
if (!metadata) return undefined;
|
|
557
623
|
const rawContext = metadata.contextLimit ?? metadata.limit;
|
|
558
624
|
const promptOnlyDetected =
|
|
@@ -643,6 +709,7 @@ function lookupMetadataWithTagFallback(
|
|
|
643
709
|
/** Clear in-memory caches (for testing and the regression-recovery refetch). */
|
|
644
710
|
export function clearModelsDevCache(): void {
|
|
645
711
|
apiCache = null;
|
|
712
|
+
v2DraftModelLimits.clear();
|
|
646
713
|
apiLoadedAt = 0;
|
|
647
714
|
persistSeedLoaded = false;
|
|
648
715
|
}
|
|
@@ -192,6 +192,14 @@ export interface CompletedSubagentToolCall {
|
|
|
192
192
|
arguments: Record<string, unknown>;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
+
export interface CurateMemoryToolCall {
|
|
196
|
+
id: string;
|
|
197
|
+
name: "ctx_memory";
|
|
198
|
+
arguments: Record<string, unknown>;
|
|
199
|
+
status: "pending" | "completed" | "error";
|
|
200
|
+
output?: string;
|
|
201
|
+
}
|
|
202
|
+
|
|
195
203
|
export type SubagentRunResult =
|
|
196
204
|
| {
|
|
197
205
|
ok: true;
|
|
@@ -209,6 +217,8 @@ export type SubagentRunResult =
|
|
|
209
217
|
/** Completed, non-error tool results preserved by runners that can
|
|
210
218
|
* reconstruct invocation/result pairs from their transcript. */
|
|
211
219
|
completedToolCalls?: CompletedSubagentToolCall[];
|
|
220
|
+
/** Real ctx_memory call outcomes, including refusals and unresolved calls, for curate. */
|
|
221
|
+
curateMemoryToolCalls?: CurateMemoryToolCall[];
|
|
212
222
|
meta?: Record<string, unknown>;
|
|
213
223
|
}
|
|
214
224
|
| {
|