dsh-llm-omp-transports 0.2.2 → 0.2.4
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/lib/adapter.d.ts +15 -0
- package/lib/adapter.js +18 -11
- package/lib/adapter.js.map +1 -1
- package/lib/index.d.ts +116 -7
- package/lib/index.js +36 -4
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/adapter.d.ts
CHANGED
|
@@ -41,6 +41,17 @@ export interface OmpCursorAdapterConfig {
|
|
|
41
41
|
* `lib/omp/cursor.mjs`. The seam tests drive it with recorded event scripts.
|
|
42
42
|
*/
|
|
43
43
|
transport: OmpCursorTransport;
|
|
44
|
+
/**
|
|
45
|
+
* Read the configured allow-list of catalog ids.
|
|
46
|
+
*
|
|
47
|
+
* @remarks
|
|
48
|
+
* A getter because the profile is a volatile setting: a save updates the
|
|
49
|
+
* running config reference without re-running the plugin, so a captured
|
|
50
|
+
* array would go stale. An absent or empty list advertises the full catalog,
|
|
51
|
+
* so the schema default (`providers.cursor.models: []`) is today's behavior;
|
|
52
|
+
* a non-empty list narrows the advertised models and the accepted ids.
|
|
53
|
+
*/
|
|
54
|
+
models?: () => readonly string[] | undefined;
|
|
44
55
|
}
|
|
45
56
|
/** The DSH llm adapter for every route this plugin's omp transport serves. */
|
|
46
57
|
export declare class OmpCursorAdapter extends LlmAdapter {
|
|
@@ -60,5 +71,9 @@ export declare class OmpCursorAdapter extends LlmAdapter {
|
|
|
60
71
|
listModels(provider: string): Promise<readonly LlmModelInfo[]>;
|
|
61
72
|
resolveModel(provider: string, model: string): Promise<LlmResolvedModelInfo>;
|
|
62
73
|
stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
|
|
74
|
+
/** The configured ids, or undefined when the route advertises the full catalog. */
|
|
75
|
+
private allowed;
|
|
76
|
+
/** Resolve one catalog row, refusing ids the configured allow-list excludes. */
|
|
77
|
+
private rowFor;
|
|
63
78
|
private call;
|
|
64
79
|
}
|
package/lib/adapter.js
CHANGED
|
@@ -68,7 +68,8 @@ export class OmpCursorAdapter extends LlmAdapter {
|
|
|
68
68
|
}
|
|
69
69
|
async listModels(provider) {
|
|
70
70
|
assertRoute(provider);
|
|
71
|
-
|
|
71
|
+
const allowed = this.allowed();
|
|
72
|
+
return CURSOR_MODELS.filter(row => allowed === undefined || allowed.has(row.id)).map(row => ({
|
|
72
73
|
provider,
|
|
73
74
|
id: row.id,
|
|
74
75
|
name: row.name,
|
|
@@ -77,11 +78,25 @@ export class OmpCursorAdapter extends LlmAdapter {
|
|
|
77
78
|
}
|
|
78
79
|
async resolveModel(provider, model) {
|
|
79
80
|
assertRoute(provider);
|
|
80
|
-
return modelInfo(provider, rowFor(model));
|
|
81
|
+
return modelInfo(provider, this.rowFor(model));
|
|
81
82
|
}
|
|
82
83
|
stream(options) {
|
|
83
84
|
return this.call(options);
|
|
84
85
|
}
|
|
86
|
+
/** The configured ids, or undefined when the route advertises the full catalog. */
|
|
87
|
+
allowed() {
|
|
88
|
+
const models = this.config.models?.();
|
|
89
|
+
return models === undefined || models.length === 0 ? undefined : new Set(models);
|
|
90
|
+
}
|
|
91
|
+
/** Resolve one catalog row, refusing ids the configured allow-list excludes. */
|
|
92
|
+
rowFor(model) {
|
|
93
|
+
const row = MODELS_BY_ID.get(model);
|
|
94
|
+
const allowed = this.allowed();
|
|
95
|
+
if (row === undefined || (allowed !== undefined && !allowed.has(row.id))) {
|
|
96
|
+
throw new LlmError(`llm-omp-transports: the cursor route has no model "${model}"`, UNKNOWN_MODEL);
|
|
97
|
+
}
|
|
98
|
+
return row;
|
|
99
|
+
}
|
|
85
100
|
async *call(options) {
|
|
86
101
|
// Read the live signal each time: it can abort while the credential is read.
|
|
87
102
|
const aborted = () => options.signal?.aborted === true;
|
|
@@ -91,7 +106,7 @@ export class OmpCursorAdapter extends LlmAdapter {
|
|
|
91
106
|
yield abortedFinish();
|
|
92
107
|
return;
|
|
93
108
|
}
|
|
94
|
-
const row = rowFor(options.model);
|
|
109
|
+
const row = this.rowFor(options.model);
|
|
95
110
|
// Validate and project before touching the credential: a refused request
|
|
96
111
|
// must not pay a credential read (nor, once the resolver refreshes, a CAS
|
|
97
112
|
// write). Only a request that can be served resolves `access` and carries
|
|
@@ -119,14 +134,6 @@ export class OmpCursorAdapter extends LlmAdapter {
|
|
|
119
134
|
yield* projectEvents(this.config.transport(request.model, request.context, transportOptions), options.signal);
|
|
120
135
|
}
|
|
121
136
|
}
|
|
122
|
-
/** Resolve one catalog row, refusing ids the pinned catalog does not serve. */
|
|
123
|
-
function rowFor(model) {
|
|
124
|
-
const row = MODELS_BY_ID.get(model);
|
|
125
|
-
if (row === undefined) {
|
|
126
|
-
throw new LlmError(`llm-omp-transports: the cursor route has no model "${model}"`, UNKNOWN_MODEL);
|
|
127
|
-
}
|
|
128
|
-
return row;
|
|
129
|
-
}
|
|
130
137
|
/** Refuse routes this adapter does not own instead of describing another provider's models. */
|
|
131
138
|
function assertRoute(provider) {
|
|
132
139
|
if (provider !== CURSOR_ROUTE) {
|
package/lib/adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAUlG,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAG9E,4CAA4C;AAC5C,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAA;AAEpC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAA;AAC5C,qEAAqE;AACrE,MAAM,CAAC,MAAM,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,aAAa,EAAE,GAAG,CAAC,aAAa,EAAE;QAC7C,4EAA4E;QAC5E,wEAAwE;QACxE,mEAAmE;QACnE,2EAA2E;QAC3E,6EAA6E;QAC7E,oCAAoC;QACpC,2EAA2E;QAC3E,2EAA2E;QAC3E,4EAA4E;QAC5E,qBAAqB;QACrB,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;YACpB,CAAC,CAAC;gBACE,SAAS,EAAE;oBACT,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;wBAC9B,EAAE,EAAE,iBAAiB,CAAC,MAAM,CAAC;wBAC7B,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI,MAAM;qBACrC,CAAC,CAAC;iBACJ;aACF;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAA;AACH,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -27,19 +27,128 @@ import type { CursorFetch } from './cursor/auth.js';
|
|
|
27
27
|
import type { CredentialRecordsLike } from './cursor/credentials.js';
|
|
28
28
|
/** Machine code for a transport artifact that cannot be loaded. */
|
|
29
29
|
export declare const TRANSPORT_UNAVAILABLE = "TRANSPORT_UNAVAILABLE";
|
|
30
|
+
/** One model row the Cursor route can advertise. */
|
|
31
|
+
export interface TransportCatalogModel {
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
}
|
|
35
|
+
/** One configured model row beneath `providers.cursor.models`. */
|
|
36
|
+
export type TransportModelProfile = TransportCatalogModel;
|
|
37
|
+
/** The configured profile of one transport route. */
|
|
38
|
+
export interface TransportProviderProfile {
|
|
39
|
+
models: TransportModelProfile[];
|
|
40
|
+
}
|
|
41
|
+
/** The `providers` profile a volatile config reference snapshots. */
|
|
42
|
+
export interface TransportProvidersProfile {
|
|
43
|
+
cursor?: TransportProviderProfile;
|
|
44
|
+
}
|
|
45
|
+
/** A live config reference (cosmokit `Volatile`) a volatile schema node resolves to. */
|
|
46
|
+
export interface ConfigReference<T> {
|
|
47
|
+
get(): T;
|
|
48
|
+
}
|
|
30
49
|
/**
|
|
31
50
|
* Plugin configuration.
|
|
32
51
|
*
|
|
33
52
|
* @remarks
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
53
|
+
* `providers.cursor` is the route's entry in the configurable-provider
|
|
54
|
+
* directory (`CURSOR_PROVIDER.settingsPath`). Consumers that list *configured*
|
|
55
|
+
* providers decide by that settings path, so the entry must resolve with no
|
|
56
|
+
* user write; the node is `.volatile()` because `settings.describe` only
|
|
57
|
+
* projects declared fields below a volatile ancestor. A volatile node arrives
|
|
58
|
+
* as a live reference, not a plain object: a settings save updates it in place
|
|
59
|
+
* without re-running `apply`.
|
|
38
60
|
*/
|
|
39
61
|
export interface Config {
|
|
62
|
+
providers?: ConfigReference<TransportProvidersProfile>;
|
|
40
63
|
}
|
|
41
64
|
/** Runtime schema for {@link Config}. */
|
|
42
|
-
export declare const Config: z<Schemastery.ObjectS<
|
|
65
|
+
export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
66
|
+
providers: z<NoInfer<Schemastery.ObjectS<NoInfer<{
|
|
67
|
+
cursor: z<Schemastery.ObjectS<NoInfer<{
|
|
68
|
+
models: z<({
|
|
69
|
+
id?: string | null | undefined;
|
|
70
|
+
name?: string | null | undefined;
|
|
71
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
72
|
+
id: z<string, string, "plain">;
|
|
73
|
+
name: z<string, string, "plain">;
|
|
74
|
+
}>>[], "defined">;
|
|
75
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
76
|
+
models: z<({
|
|
77
|
+
id?: string | null | undefined;
|
|
78
|
+
name?: string | null | undefined;
|
|
79
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
80
|
+
id: z<string, string, "plain">;
|
|
81
|
+
name: z<string, string, "plain">;
|
|
82
|
+
}>>[], "defined">;
|
|
83
|
+
}>>, "plain">;
|
|
84
|
+
}>>>, NoInfer<Schemastery.ObjectT<NoInfer<{
|
|
85
|
+
cursor: z<Schemastery.ObjectS<NoInfer<{
|
|
86
|
+
models: z<({
|
|
87
|
+
id?: string | null | undefined;
|
|
88
|
+
name?: string | null | undefined;
|
|
89
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
90
|
+
id: z<string, string, "plain">;
|
|
91
|
+
name: z<string, string, "plain">;
|
|
92
|
+
}>>[], "defined">;
|
|
93
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
94
|
+
models: z<({
|
|
95
|
+
id?: string | null | undefined;
|
|
96
|
+
name?: string | null | undefined;
|
|
97
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
98
|
+
id: z<string, string, "plain">;
|
|
99
|
+
name: z<string, string, "plain">;
|
|
100
|
+
}>>[], "defined">;
|
|
101
|
+
}>>, "plain">;
|
|
102
|
+
}>>>, "volatile-defined">;
|
|
103
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
104
|
+
providers: z<NoInfer<Schemastery.ObjectS<NoInfer<{
|
|
105
|
+
cursor: z<Schemastery.ObjectS<NoInfer<{
|
|
106
|
+
models: z<({
|
|
107
|
+
id?: string | null | undefined;
|
|
108
|
+
name?: string | null | undefined;
|
|
109
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
110
|
+
id: z<string, string, "plain">;
|
|
111
|
+
name: z<string, string, "plain">;
|
|
112
|
+
}>>[], "defined">;
|
|
113
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
114
|
+
models: z<({
|
|
115
|
+
id?: string | null | undefined;
|
|
116
|
+
name?: string | null | undefined;
|
|
117
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
118
|
+
id: z<string, string, "plain">;
|
|
119
|
+
name: z<string, string, "plain">;
|
|
120
|
+
}>>[], "defined">;
|
|
121
|
+
}>>, "plain">;
|
|
122
|
+
}>>>, NoInfer<Schemastery.ObjectT<NoInfer<{
|
|
123
|
+
cursor: z<Schemastery.ObjectS<NoInfer<{
|
|
124
|
+
models: z<({
|
|
125
|
+
id?: string | null | undefined;
|
|
126
|
+
name?: string | null | undefined;
|
|
127
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
128
|
+
id: z<string, string, "plain">;
|
|
129
|
+
name: z<string, string, "plain">;
|
|
130
|
+
}>>[], "defined">;
|
|
131
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
132
|
+
models: z<({
|
|
133
|
+
id?: string | null | undefined;
|
|
134
|
+
name?: string | null | undefined;
|
|
135
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<NoInfer<{
|
|
136
|
+
id: z<string, string, "plain">;
|
|
137
|
+
name: z<string, string, "plain">;
|
|
138
|
+
}>>[], "defined">;
|
|
139
|
+
}>>, "plain">;
|
|
140
|
+
}>>>, "volatile-defined">;
|
|
141
|
+
}>>, "plain">;
|
|
142
|
+
/**
|
|
143
|
+
* The full Cursor catalog, projected for host-side configuration surfaces.
|
|
144
|
+
*
|
|
145
|
+
* @remarks
|
|
146
|
+
* `listModels` answers with the configured allow-list, so a picker cannot
|
|
147
|
+
* discover the models a narrowed route could still advertise. The transport
|
|
148
|
+
* package exports the unfiltered projection instead of adding a service or a
|
|
149
|
+
* package subpath.
|
|
150
|
+
*/
|
|
151
|
+
export declare function cursorCatalogModels(): TransportCatalogModel[];
|
|
43
152
|
export declare const name = "llm-omp-transports";
|
|
44
153
|
/**
|
|
45
154
|
* Sibling services this plugin reads. `llm` owns the route, `credentials` the
|
|
@@ -129,7 +238,7 @@ export declare function beginCursorSignIn(ctx: Context, interaction: CursorSignI
|
|
|
129
238
|
* credential store. The transport is the bundled artifact, still loaded only on
|
|
130
239
|
* the first request.
|
|
131
240
|
*/
|
|
132
|
-
export declare function createCursorAdapter(credentials: CredentialRecordsLike): OmpCursorAdapter;
|
|
133
|
-
export declare function apply(ctx: Context,
|
|
241
|
+
export declare function createCursorAdapter(credentials: CredentialRecordsLike, models?: () => readonly string[] | undefined): OmpCursorAdapter;
|
|
242
|
+
export declare function apply(ctx: Context, config?: Config): void;
|
|
134
243
|
export { CURSOR_ROUTE } from './adapter.js';
|
|
135
244
|
export { CURSOR_CREDENTIAL_KEY } from './cursor/credentials.js';
|
package/lib/index.js
CHANGED
|
@@ -1,12 +1,39 @@
|
|
|
1
1
|
import { LlmError } from '@deepseek-ai/dsh-llm';
|
|
2
2
|
import z from '@deepseek-ai/schemastery';
|
|
3
3
|
import { CURSOR_ROUTE, OmpCursorAdapter } from './adapter.js';
|
|
4
|
+
import { CURSOR_MODELS } from './catalog/cursor.js';
|
|
4
5
|
import { loginCursor } from './cursor/auth.js';
|
|
5
6
|
import { CURSOR_CREDENTIAL_KEY, createCursorAccess } from './cursor/credentials.js';
|
|
6
7
|
/** Machine code for a transport artifact that cannot be loaded. */
|
|
7
8
|
export const TRANSPORT_UNAVAILABLE = 'TRANSPORT_UNAVAILABLE';
|
|
8
9
|
/** Runtime schema for {@link Config}. */
|
|
9
|
-
export const Config = z.object({
|
|
10
|
+
export const Config = z.object({
|
|
11
|
+
providers: z
|
|
12
|
+
.object({
|
|
13
|
+
cursor: z.object({
|
|
14
|
+
models: z
|
|
15
|
+
.array(z.object({
|
|
16
|
+
id: z.string(),
|
|
17
|
+
name: z.string(),
|
|
18
|
+
}))
|
|
19
|
+
.default([]),
|
|
20
|
+
}),
|
|
21
|
+
})
|
|
22
|
+
.default({ cursor: { models: [] } })
|
|
23
|
+
.volatile(),
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* The full Cursor catalog, projected for host-side configuration surfaces.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* `listModels` answers with the configured allow-list, so a picker cannot
|
|
30
|
+
* discover the models a narrowed route could still advertise. The transport
|
|
31
|
+
* package exports the unfiltered projection instead of adding a service or a
|
|
32
|
+
* package subpath.
|
|
33
|
+
*/
|
|
34
|
+
export function cursorCatalogModels() {
|
|
35
|
+
return CURSOR_MODELS.map(row => ({ id: row.id, name: row.name }));
|
|
36
|
+
}
|
|
10
37
|
export const name = 'llm-omp-transports';
|
|
11
38
|
/**
|
|
12
39
|
* Sibling services this plugin reads. `llm` owns the route, `credentials` the
|
|
@@ -101,15 +128,20 @@ function bundledCursorTransport() {
|
|
|
101
128
|
* credential store. The transport is the bundled artifact, still loaded only on
|
|
102
129
|
* the first request.
|
|
103
130
|
*/
|
|
104
|
-
export function createCursorAdapter(credentials) {
|
|
131
|
+
export function createCursorAdapter(credentials, models) {
|
|
105
132
|
return new OmpCursorAdapter({
|
|
106
133
|
access: createCursorAccess(credentials),
|
|
107
134
|
transport: bundledCursorTransport(),
|
|
135
|
+
...(models === undefined ? {} : { models }),
|
|
108
136
|
});
|
|
109
137
|
}
|
|
110
|
-
export function apply(ctx,
|
|
138
|
+
export function apply(ctx, config = {}) {
|
|
111
139
|
const host = ctx;
|
|
112
|
-
|
|
140
|
+
const providers = config.providers;
|
|
141
|
+
// A settings file is user input: drop a malformed row instead of throwing
|
|
142
|
+
// from `listModels`/`stream`, which would take the whole route down.
|
|
143
|
+
const models = () => providers?.get().cursor?.models?.flatMap(row => (typeof row?.id === 'string' ? [row.id] : []));
|
|
144
|
+
ctx.llm.registerAdapter([CURSOR_ROUTE], createCursorAdapter(host.credentials, models));
|
|
113
145
|
ctx.llm.registerConfigurableProviders([CURSOR_PROVIDER]);
|
|
114
146
|
host.authorization.registerFlow(cursorAuthorizationFlow());
|
|
115
147
|
}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,QAAQ,EAAE,MAAM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B,EAAE,CAAC,CAAA;AAC5D,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-llm-omp-transports",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "DSH transport plugin: serves providers whose wire protocols only oh-my-pi's own transport code can speak (Cursor first), by registering its own routes on the dsh-llm seam.",
|
|
6
6
|
"keywords": [
|