@oh-my-pi/pi-catalog 18.14.0 → 18.14.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/CHANGELOG.md +22 -0
- package/dist/types/discovery/cursor-proto.d.ts +8 -0
- package/dist/types/model-manager.d.ts +11 -1
- package/dist/types/model-thinking.d.ts +4 -0
- package/dist/types/types.d.ts +3 -14
- package/package.json +4 -4
- package/src/compat/axes.ts +16 -7
- package/src/compat/resolve.ts +0 -3
- package/src/compat/rules/README.md +1 -1
- package/src/compat/rules/classes/anthropic.kdl +5 -0
- package/src/compat/rules/classes/deepseek.kdl +1 -1
- package/src/compat/rules/classes/gemini.kdl +1 -1
- package/src/compat/rules/classes/xai.kdl +1 -1
- package/src/compat/rules/providers/anthropic.kdl +8 -4
- package/src/compat/rules/providers/cursor.kdl +10 -0
- package/src/compat/rules/providers/deepseek.kdl +2 -2
- package/src/compat/rules/providers/openai-codex.kdl +1 -1
- package/src/compat/rules.json +1 -1
- package/src/discovery/cursor-proto.ts +12 -1
- package/src/model-manager.ts +58 -22
- package/src/model-thinking.ts +10 -0
- package/src/models.json +1 -1
- package/src/types.ts +0 -14
|
@@ -3662,7 +3662,8 @@ export interface InteractionUpdate extends ProtoMessage {
|
|
|
3662
3662
|
| { case: "heartbeat"; value: HeartbeatUpdate }
|
|
3663
3663
|
| { case: "turnEnded"; value: TurnEndedUpdate }
|
|
3664
3664
|
| { case: "stepStarted"; value: StepStartedUpdate }
|
|
3665
|
-
| { case: "stepCompleted"; value: StepCompletedUpdate }
|
|
3665
|
+
| { case: "stepCompleted"; value: StepCompletedUpdate }
|
|
3666
|
+
| { case: "toolRequestsListed"; value: ToolRequestsListedUpdate };
|
|
3666
3667
|
}
|
|
3667
3668
|
|
|
3668
3669
|
export const InteractionUpdateSchema: MessageCodec<InteractionUpdate> = pb<InteractionUpdate>("agent.v1.InteractionUpdate", [
|
|
@@ -3687,6 +3688,7 @@ export const InteractionUpdateSchema: MessageCodec<InteractionUpdate> = pb<Inter
|
|
|
3687
3688
|
{ no: 14, name: "turnEnded", kind: "message", T: () => TurnEndedUpdateSchema },
|
|
3688
3689
|
{ no: 16, name: "stepStarted", kind: "message", T: () => StepStartedUpdateSchema },
|
|
3689
3690
|
{ no: 17, name: "stepCompleted", kind: "message", T: () => StepCompletedUpdateSchema },
|
|
3691
|
+
{ no: 27, name: "toolRequestsListed", kind: "message", T: () => ToolRequestsListedUpdateSchema },
|
|
3690
3692
|
],
|
|
3691
3693
|
},
|
|
3692
3694
|
]);
|
|
@@ -8251,6 +8253,15 @@ export const ToolCallStartedUpdateSchema: MessageCodec<ToolCallStartedUpdate> =
|
|
|
8251
8253
|
{ no: 3, name: "modelCallId", kind: "string" },
|
|
8252
8254
|
]);
|
|
8253
8255
|
|
|
8256
|
+
/** Cursor agent message agent.v1.ToolRequestsListedUpdate. */
|
|
8257
|
+
export interface ToolRequestsListedUpdate extends ProtoMessage {
|
|
8258
|
+
callCount: number;
|
|
8259
|
+
}
|
|
8260
|
+
|
|
8261
|
+
export const ToolRequestsListedUpdateSchema: MessageCodec<ToolRequestsListedUpdate> = pb<ToolRequestsListedUpdate>("agent.v1.ToolRequestsListedUpdate", [
|
|
8262
|
+
{ no: 1, name: "callCount", kind: "uint32" },
|
|
8263
|
+
]);
|
|
8264
|
+
|
|
8254
8265
|
/** Cursor agent message agent.v1.TruncatedToolCall. */
|
|
8255
8266
|
export interface TruncatedToolCall extends ProtoMessage {
|
|
8256
8267
|
originalStepBlobId: Uint8Array;
|
package/src/model-manager.ts
CHANGED
|
@@ -267,7 +267,6 @@ export async function resolveProviderModels<TApi extends Api = Api, TModelsDevPa
|
|
|
267
267
|
const cache = readModelCache<TApi>(cacheProviderId, ttlMs, now, dbPath);
|
|
268
268
|
const dynamicModelsAuthoritative = options.dynamicModelsAuthoritative ?? false;
|
|
269
269
|
const isAuthoritativeDynamicCache = dynamicModelsAuthoritative && (cache?.payloadAuthoritative ?? false);
|
|
270
|
-
const cacheAdditiveStaticModelIds = isAuthoritativeDynamicCache ? undefined : modelsDevAdditiveStaticModelIds;
|
|
271
270
|
const restoredCache = restoreCachedModelHeaders(
|
|
272
271
|
cache?.models ?? [],
|
|
273
272
|
staticModels,
|
|
@@ -286,7 +285,12 @@ export async function resolveProviderModels<TApi extends Api = Api, TModelsDevPa
|
|
|
286
285
|
staticNames: options.keepStaticNames ? new Map(staticModels.map(model => [model.id, model.name])) : undefined,
|
|
287
286
|
};
|
|
288
287
|
const cacheDropIds = options.dropCachedModelIdsOnStaticMismatch;
|
|
289
|
-
|
|
288
|
+
// Additive mode is cache identity: a snapshot written while shared-catalog
|
|
289
|
+
// rows could replace bundled metadata must not match an additive resolver.
|
|
290
|
+
const staticCatalogFingerprint = fingerprintStaticModels(staticModels, {
|
|
291
|
+
authoritative: dynamicModelsAuthoritative,
|
|
292
|
+
additive: modelsDevAdditiveStaticModelIds !== undefined,
|
|
293
|
+
});
|
|
290
294
|
// Endpoint-migration policy is cache identity: adding an id must invalidate
|
|
291
295
|
// matching-static-catalog caches written by the prior resolver.
|
|
292
296
|
const staticFingerprint =
|
|
@@ -294,6 +298,13 @@ export async function resolveProviderModels<TApi extends Api = Api, TModelsDevPa
|
|
|
294
298
|
? `${staticCatalogFingerprint}:drop:${Bun.hash(cacheDropIds.join("\0")).toString(36)}`
|
|
295
299
|
: staticCatalogFingerprint;
|
|
296
300
|
const cacheFingerprintMatches = cache?.staticFingerprint === staticFingerprint && staticFingerprint.length > 0;
|
|
301
|
+
// A matching cache was written against this static catalog under the same
|
|
302
|
+
// additive policy, so its same-id rows are live discovery merged over the
|
|
303
|
+
// bundled rows, never shared-catalog overrides (#17481). Strip them only on
|
|
304
|
+
// a mismatch: a static-catalog upgrade or a cache written before additive
|
|
305
|
+
// semantics were enabled.
|
|
306
|
+
const cacheAdditiveStaticModelIds =
|
|
307
|
+
isAuthoritativeDynamicCache || cacheFingerprintMatches ? undefined : modelsDevAdditiveStaticModelIds;
|
|
297
308
|
const cacheNeedsModelMigration =
|
|
298
309
|
!cacheFingerprintMatches &&
|
|
299
310
|
cacheDropIds !== undefined &&
|
|
@@ -315,8 +326,8 @@ export async function resolveProviderModels<TApi extends Api = Api, TModelsDevPa
|
|
|
315
326
|
// Cold-start fast path: when a fresh, authoritative cache exists, the network
|
|
316
327
|
// fetch is skipped, AND the static catalog slice is byte-identical to what
|
|
317
328
|
// was merged in last time, the cache row IS the authoritative merge result.
|
|
318
|
-
//
|
|
319
|
-
//
|
|
329
|
+
// A mismatched additive cache never reaches here; its same-id rows are
|
|
330
|
+
// stripped below.
|
|
320
331
|
if (
|
|
321
332
|
!shouldFetchFromNetwork &&
|
|
322
333
|
cache?.fresh &&
|
|
@@ -324,18 +335,9 @@ export async function resolveProviderModels<TApi extends Api = Api, TModelsDevPa
|
|
|
324
335
|
cacheFingerprintMatches &&
|
|
325
336
|
!cacheHasUnresolvedHeaders
|
|
326
337
|
) {
|
|
327
|
-
const
|
|
328
|
-
? restoredCache.models.filter(model => !cacheAdditiveStaticModelIds.has(model.id))
|
|
329
|
-
: restoredCache.models;
|
|
330
|
-
const cachedModels = cacheAdditiveStaticModelIds
|
|
331
|
-
? mergeCatalogMetrics(
|
|
332
|
-
mergeDynamicModels(staticModels, cacheContribution, mergeAuthority),
|
|
333
|
-
restoredCache.models,
|
|
334
|
-
)
|
|
335
|
-
: restoredCache.models;
|
|
336
|
-
const source: ModelResolutionSource = cacheContribution.length > 0 ? "cache" : "bundled";
|
|
338
|
+
const source: ModelResolutionSource = restoredCache.models.length > 0 ? "cache" : "bundled";
|
|
337
339
|
return {
|
|
338
|
-
models: collapseBuiltVariants(
|
|
340
|
+
models: collapseBuiltVariants(restoredCache.models),
|
|
339
341
|
stale: false,
|
|
340
342
|
source,
|
|
341
343
|
...(source === "cache" ? { updatedAt: cache.updatedAt } : {}),
|
|
@@ -382,7 +384,10 @@ export async function resolveProviderModels<TApi extends Api = Api, TModelsDevPa
|
|
|
382
384
|
dynamicModels.length > 0 &&
|
|
383
385
|
(dynamicModelsAuthoritative || !hasModelsDevFetcher || modelsDevFetchSucceeded)
|
|
384
386
|
: modelsDevFetchSucceeded;
|
|
385
|
-
const mergedWithCache =
|
|
387
|
+
const mergedWithCache = mergeCachedModels(staticModels, cacheModels, {
|
|
388
|
+
authority: mergeAuthority,
|
|
389
|
+
matchesStatic: cacheFingerprintMatches,
|
|
390
|
+
});
|
|
386
391
|
const mergedWithModelsDev = mergeDynamicModels(
|
|
387
392
|
mergedWithCache,
|
|
388
393
|
modelsDevModels,
|
|
@@ -455,7 +460,10 @@ export async function resolveProviderModels<TApi extends Api = Api, TModelsDevPa
|
|
|
455
460
|
? preparedLatestCacheModels.filter(model => !cacheAdditiveStaticModelIds.has(model.id))
|
|
456
461
|
: preparedLatestCacheModels;
|
|
457
462
|
const mergedFallbackModels = mergeDynamicModels(
|
|
458
|
-
|
|
463
|
+
mergeCachedModels(staticModels, latestCacheModels, {
|
|
464
|
+
authority: mergeAuthority,
|
|
465
|
+
matchesStatic: cacheFingerprintMatches,
|
|
466
|
+
}),
|
|
459
467
|
modelsDevModels,
|
|
460
468
|
mergeAuthority,
|
|
461
469
|
);
|
|
@@ -631,6 +639,24 @@ function mergeDynamicModels<TApi extends Api>(
|
|
|
631
639
|
return Array.from(merged.values());
|
|
632
640
|
}
|
|
633
641
|
|
|
642
|
+
/**
|
|
643
|
+
* Lays cached rows over the static catalog. A snapshot written against this
|
|
644
|
+
* static catalog (`matchesStatic`) is already that catalog merged with live
|
|
645
|
+
* discovery, so its rows replace same-id static rows verbatim; re-merging would
|
|
646
|
+
* only rebuild them and churn the persisted payload. A snapshot from another
|
|
647
|
+
* static catalog re-merges so upgraded bundled metadata applies.
|
|
648
|
+
*/
|
|
649
|
+
function mergeCachedModels<TApi extends Api>(
|
|
650
|
+
staticModels: readonly Model<TApi>[],
|
|
651
|
+
cacheModels: readonly Model<TApi>[],
|
|
652
|
+
options: { authority: DynamicMergeAuthority; matchesStatic: boolean },
|
|
653
|
+
): Model<TApi>[] {
|
|
654
|
+
if (!options.matchesStatic) return mergeDynamicModels(staticModels, cacheModels, options.authority);
|
|
655
|
+
const merged = new Map<string, Model<TApi>>(staticModels.map(model => [model.id, model]));
|
|
656
|
+
for (const cachedModel of cacheModels) merged.set(cachedModel.id, cachedModel);
|
|
657
|
+
return Array.from(merged.values());
|
|
658
|
+
}
|
|
659
|
+
|
|
634
660
|
function retainModelIds<TApi extends Api>(
|
|
635
661
|
models: readonly Model<TApi>[],
|
|
636
662
|
retainedModels: readonly Model<TApi>[],
|
|
@@ -642,6 +668,17 @@ function retainModelIds<TApi extends Api>(
|
|
|
642
668
|
|
|
643
669
|
const MODEL_CACHE_FINGERPRINT_VERSION = `merge-v5:${VERSION}`;
|
|
644
670
|
|
|
671
|
+
/**
|
|
672
|
+
* Merge policy that is part of a cache's identity in
|
|
673
|
+
* {@link fingerprintStaticModels}: `authoritative` when dynamic discovery owns
|
|
674
|
+
* the catalog, `additive` when the shared catalog may only add ids. The flags
|
|
675
|
+
* compose; snapshots written under different policies never match.
|
|
676
|
+
*/
|
|
677
|
+
export interface StaticFingerprintPolicy {
|
|
678
|
+
authoritative?: boolean;
|
|
679
|
+
additive?: boolean;
|
|
680
|
+
}
|
|
681
|
+
|
|
645
682
|
/**
|
|
646
683
|
* Return the versioned content identity for a static provider slice. Callers
|
|
647
684
|
* may mutate or freeze their arrays, so every call observes current content
|
|
@@ -649,12 +686,11 @@ const MODEL_CACHE_FINGERPRINT_VERSION = `merge-v5:${VERSION}`;
|
|
|
649
686
|
*/
|
|
650
687
|
export function fingerprintStaticModels<TApi extends Api>(
|
|
651
688
|
models: readonly (ModelSpec<TApi> | Model<TApi>)[],
|
|
652
|
-
|
|
689
|
+
policy: StaticFingerprintPolicy = {},
|
|
653
690
|
): string {
|
|
654
|
-
|
|
655
|
-
if (
|
|
656
|
-
|
|
657
|
-
return `${MODEL_CACHE_FINGERPRINT_VERSION}:${Bun.hash(JSON.stringify(models)).toString(36)}`;
|
|
691
|
+
const policyKey = `${policy.authoritative ? ":authoritative" : ""}${policy.additive ? ":additive" : ""}`;
|
|
692
|
+
if (models.length === 0) return `${MODEL_CACHE_FINGERPRINT_VERSION}${policyKey}:empty`;
|
|
693
|
+
return `${MODEL_CACHE_FINGERPRINT_VERSION}${policyKey}:${Bun.hash(JSON.stringify(models)).toString(36)}`;
|
|
658
694
|
}
|
|
659
695
|
|
|
660
696
|
function mergeDynamicModel<TApi extends Api>(
|
package/src/model-thinking.ts
CHANGED
|
@@ -42,6 +42,10 @@ export function withoutUnverifiedThinking<T extends { reasoning: boolean; thinki
|
|
|
42
42
|
/**
|
|
43
43
|
* Clamps a requested thinking level against explicit model metadata.
|
|
44
44
|
*
|
|
45
|
+
* An unserved level first follows `thinking.effortMap` when the map sends it to
|
|
46
|
+
* a served tier that reaches the wire unchanged (a gateway answering `medium`
|
|
47
|
+
* as `high`); otherwise it climbs down to the nearest lower tier.
|
|
48
|
+
*
|
|
45
49
|
* Non-reasoning models always resolve to `undefined`.
|
|
46
50
|
*/
|
|
47
51
|
export function clampThinkingLevelForModel<TApi extends Api>(
|
|
@@ -60,6 +64,12 @@ export function clampThinkingLevelForModel<TApi extends Api>(
|
|
|
60
64
|
return requested;
|
|
61
65
|
}
|
|
62
66
|
|
|
67
|
+
const effortMap = model.thinking?.effortMap;
|
|
68
|
+
const aliased = effortMap?.[requested] as Effort | undefined;
|
|
69
|
+
if (aliased !== undefined && levels.includes(aliased) && (effortMap![aliased] ?? aliased) === aliased) {
|
|
70
|
+
return aliased;
|
|
71
|
+
}
|
|
72
|
+
|
|
63
73
|
const requestedIndex = THINKING_EFFORTS.indexOf(requested);
|
|
64
74
|
if (requestedIndex === -1) {
|
|
65
75
|
return undefined;
|