dsh-model-think-level 1.0.0 → 1.0.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.
@@ -7,6 +7,40 @@
7
7
  export declare const PLUGIN_ID = "dsh-model-think-level";
8
8
  /** Same-origin host route that proxies a provider's RAW /models listing. */
9
9
  export declare const PROBE_PATH = "/dsh-model-think-level/raw-models";
10
+ /** Read-only diagnostics for the request-header takeover. */
11
+ export declare const DIAG_PATH = "/dsh-model-think-level/header-bridge";
12
+ /**
13
+ * Same-origin host route that resolves one provider profile's stored
14
+ * credential, so the API-key field's eye can show a SAVED key.
15
+ *
16
+ * The harness keeps provider keys write-only on purpose: the settings document
17
+ * carries only the profile's `apiKeyEnv` reference, and the credential service
18
+ * reports `{ configured, source, writable }` through `describe()` — never the
19
+ * value. Only the host can read it (`credentials.resolve()`), and it does so
20
+ * for the request adapters; the browser normally never sees a stored key at
21
+ * all. This route is the plugin's deliberate exception: an explicit,
22
+ * user-initiated, same-fence read that answers with the value and is never
23
+ * cached, so the eye can put it back into the official field.
24
+ */
25
+ export declare const PROVIDER_KEY_PATH = "/dsh-model-think-level/provider-key";
26
+ /**
27
+ * Same-origin host route that owns a provider's list of API keys: their
28
+ * references, their labels, and which one is in use.
29
+ *
30
+ * The harness has no notion of "several keys for one provider": a profile names
31
+ * exactly one reference (`apiKeyEnv`) and a credential store holds exactly one
32
+ * value per reference, with no enumeration and no label. Both facts are
33
+ * deliberate — a configuration surface learns which references exist from its
34
+ * settings schema — so a list of keys can only be plugin-owned state. It lives
35
+ * in the harness home (`<DSH_HOME>/dsh-model-think-level/key-index.json`) rather
36
+ * than in the pi-ai profile, so the official add-provider card, which writes the
37
+ * WHOLE profile at `providers.<route>`, cannot drop it.
38
+ *
39
+ * The route both reads and writes: the values themselves still go to the
40
+ * credential store through the host's own `credentials` service, so the browser
41
+ * never needs a new Remote face.
42
+ */
43
+ export declare const KEY_INDEX_PATH = "/dsh-model-think-level/key-index";
10
44
  /**
11
45
  * Same-origin host route that reports this plugin's autofill switches. The
12
46
  * browser half runs the running auto-fill complement, and a `dsh.client`
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Request-level header bridge for the pi-ai-backed Harness adapter.
3
+ *
4
+ * The model-list probe has its own direct fetch path, but conversation requests
5
+ * are assembled inside dsh-llm-pi-ai and then passed to pi-ai's Models service.
6
+ * pi-ai exposes `transformHeaders` exactly after auth and request headers have
7
+ * been merged, so it is the right place to restore the profile values that the
8
+ * Harness attribution layer reserves (most visibly `user-agent`).
9
+ *
10
+ * dsh-llm-pi-ai does not expose its private Models collection through a public
11
+ * plugin API. Its adapter is nevertheless registered in the public llm runtime,
12
+ * and the runtime object keeps that registration in a normal `adapters` Map. The
13
+ * bridge uses a narrow structural adapter of that implementation detail and
14
+ * fails open for other adapters or older runtimes.
15
+ *
16
+ * @module dsh-model-think-level/headers-pi-ai
17
+ */
18
+ import { type HeaderIndex } from './headers-core.js';
19
+ /** A live route index shared with the fetch overlay. */
20
+ export interface PiAiHeaderSource {
21
+ current: HeaderIndex;
22
+ }
23
+ /** Handle returned for one adapter patch. */
24
+ export interface PiAiHeaderTransformHandle {
25
+ readonly active: boolean;
26
+ dispose(): void;
27
+ }
28
+ /** Install the request-level transform on one pi-ai-shaped adapter. */
29
+ export declare function installPiAiHeaderTransform(adapter: unknown, source: PiAiHeaderSource): PiAiHeaderTransformHandle;
30
+ /** Diagnostic snapshot of the bridge's live attach state. */
31
+ export interface PiAiHeaderBridgeState {
32
+ runtimeFound: boolean;
33
+ registerPatched: boolean;
34
+ adaptersInRuntime: number;
35
+ adaptersPatched: number;
36
+ adapters: string[];
37
+ routes: number;
38
+ overrides: number;
39
+ }
40
+ /**
41
+ * Describe what the bridge is currently attached to. Read-only; used by the
42
+ * probe route's `?diag=1` arm to make the request-header takeover observable
43
+ * from the running host instead of only from a test harness.
44
+ */
45
+ export declare function describePiAiHeaderState(llm: unknown, source: PiAiHeaderSource): PiAiHeaderBridgeState;
46
+ /**
47
+ * Install the bridge on every current pi-ai-shaped registration and expose a
48
+ * refresh for the runtime's `llm/adapters-updated` event.
49
+ */
50
+ export interface PiAiHeaderTransformsHandle {
51
+ refresh(): void;
52
+ dispose(): void;
53
+ }
54
+ export declare function installPiAiHeaderTransforms(llm: unknown, source: PiAiHeaderSource): PiAiHeaderTransformsHandle;