dsh-model-think-level 2.6.5 → 2.6.6
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.
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Make a wire-protocol switch and its compat cleanup ONE write, at the seam
|
|
3
|
+
* the official card's own Save goes through.
|
|
4
|
+
*
|
|
5
|
+
* The kernel validates the whole settings document INSIDE the write
|
|
6
|
+
* (`dsh-llm-pi-ai`'s `internal/config` hook -> `assertServiceable` ->
|
|
7
|
+
* `resolveModelCompat`): a model that still carries a switch its NEW protocol
|
|
8
|
+
* does not take fails resolution, and the write is rejected outright --
|
|
9
|
+
*
|
|
10
|
+
* provider "free" model "gpt-6.1-sol" sets compat "supportsReasoningEffort",
|
|
11
|
+
* but its api is "openai-responses", which does not take it; that switch
|
|
12
|
+
* exists on openai-completions
|
|
13
|
+
*
|
|
14
|
+
* -- so switching a route's protocol from the Models card bounces, and the user
|
|
15
|
+
* is left to hand-edit `cordis.patch.yml`. The boot sweep and the idle guard
|
|
16
|
+
* heal that state afterwards, which is too late: the rejection already
|
|
17
|
+
* happened, and the document is left exactly as it was.
|
|
18
|
+
*
|
|
19
|
+
* The repair therefore has to land INSIDE the same mutate call:
|
|
20
|
+
*
|
|
21
|
+
* - a separate write BEFORE the Save bumps the revision, so the card's own
|
|
22
|
+
* frozen `expectedRevision` (issue #7) no longer matches and the user gets
|
|
23
|
+
* `settings/conflict` instead of a saved switch;
|
|
24
|
+
* - a separate write AFTER it cannot help: the Save was already refused.
|
|
25
|
+
*
|
|
26
|
+
* And the write to repair is the OFFICIAL card's, not this plugin's, so the seam
|
|
27
|
+
* must sit on the `remote.settings` SERVICE — the one object every settings
|
|
28
|
+
* writer ends up calling. (`ctx.remote` is a Cordis traceable proxy: reading
|
|
29
|
+
* `remote.settings` short-circuits to the service registry, so replacing that
|
|
30
|
+
* member would never be observed.) The gateway installs `mutate` as a
|
|
31
|
+
* configurable own accessor per Remote method, so this module redefines that
|
|
32
|
+
* property the same reference-counted way `headers-pi-ai` patches
|
|
33
|
+
* `registerAdapter`, and restores the original descriptor on dispose.
|
|
34
|
+
*
|
|
35
|
+
* The wrapper is a Proxy over the live method, not a captured copy: it is
|
|
36
|
+
* transparent to a test double (vitest's `_isMockFunction`/`mock`/`mock*` all
|
|
37
|
+
* forward to the real function, so existing assertions keep meaning the same
|
|
38
|
+
* traffic), and it re-reads the underlying method on every call so a gateway
|
|
39
|
+
* re-install — which replaces the method records, invalidating old closures —
|
|
40
|
+
* is followed rather than dispatched through a withdrawn token.
|
|
41
|
+
*
|
|
42
|
+
* Cost on the ordinary path is one path inspection: only an op that NAMES a
|
|
43
|
+
* protocol pays for the document read the cleanup needs.
|
|
44
|
+
*
|
|
45
|
+
* @module dsh-model-think-level/client/injection/compat-write-seam
|
|
46
|
+
*/
|
|
47
|
+
/** The seam's face. */
|
|
48
|
+
export interface CompatWriteSeam {
|
|
49
|
+
/** Whether this patch is the one currently installed. */
|
|
50
|
+
readonly active: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Re-assert the patch if something replaced it, adopting the replacement as
|
|
53
|
+
* the new method underneath.
|
|
54
|
+
*
|
|
55
|
+
* The gateway installs `mutate` as an accessor, and a re-install (a
|
|
56
|
+
* reconnect, an HMR cycle of the gateway itself) replaces that property
|
|
57
|
+
* wholesale, quietly retiring this seam. There is no event to observe, so the
|
|
58
|
+
* caller re-asserts on its idle pass: one property read while nothing has
|
|
59
|
+
* changed, a repair when something has.
|
|
60
|
+
*/
|
|
61
|
+
ensure: () => void;
|
|
62
|
+
/** Release this activation's hold; the last one restores the original. */
|
|
63
|
+
dispose: () => void;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The user-layer providers dict of one describe answer.
|
|
67
|
+
*
|
|
68
|
+
* The USER layer on purpose (never the resolved `value`): the cleanup rebuilds
|
|
69
|
+
* stored rows, and a resolved read materializes schema defaults into the
|
|
70
|
+
* document — the same rule the boot sweep and the idle fill follow.
|
|
71
|
+
* @param value - the `settings.describe()` value.
|
|
72
|
+
* @returns the raw user-layer providers dict, when there is one.
|
|
73
|
+
*/
|
|
74
|
+
export declare function userProvidersOfDescribe(value: unknown): unknown;
|
|
75
|
+
/**
|
|
76
|
+
* Patch the shared settings service so a protocol switch cleans the compat
|
|
77
|
+
* switches its new protocol cannot take, in the same write.
|
|
78
|
+
*
|
|
79
|
+
* Idempotent and reference-counted: a second activation (HMR, a double apply,
|
|
80
|
+
* two plugin instances) joins the existing patch instead of wrapping twice, and
|
|
81
|
+
* the last release restores the exact descriptor that was there before.
|
|
82
|
+
*
|
|
83
|
+
* @param service - `ctx.remote.settings`, the service every settings writer
|
|
84
|
+
* (the official Models card included) calls.
|
|
85
|
+
* @returns the seam's {@link CompatWriteSeam} face, or undefined when the
|
|
86
|
+
* service carries no `mutate` to patch.
|
|
87
|
+
*/
|
|
88
|
+
export declare function installCompatWriteSeam(service: unknown): CompatWriteSeam | undefined;
|