dsh-llm-omp-transports 0.4.2 → 0.4.3

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/README.md CHANGED
@@ -59,15 +59,19 @@ package imports nothing from `@oh-my-pi/*` or `bun:*` at runtime.
59
59
  the call, finishes the turn `toolUse`, and DSH executes it; the result is
60
60
  replayed from history on the next request. Unlike Cursor, no call is
61
61
  transport-resolved, so nothing is filtered from the handoff.
62
- - **Sign-in** — yes, by pasting the callback. The pinned omp login is a
63
- declarative `oauth-code` rule whose loopback listener is Bun-only; this
64
- package registers the `llm-omp-transports/devin` flow, opens the authorize
65
- page, and asks for the address the browser landed on (or just the code).
66
- There is **no refresh** (`refresh "none"`): an expired grant demands a new
67
- sign-in.
68
- - **Models** — from the pinned catalog: the Devin slice of
69
- `@oh-my-pi/pi-catalog@18.18.8` (2 rows: `swe-1-6`, `swe-1-6-fast`) is
70
- generated into `src/catalog/devin.ts` and served without a network call.
62
+ - **Sign-in** — two methods. Either paste the callback: the pinned omp login is
63
+ a declarative `oauth-code` rule whose loopback listener is Bun-only, so this
64
+ package opens the authorize page and asks for the address the browser landed
65
+ on (or just the code). Or import the seat key the official Devin CLI already
66
+ stores (`devin auth login` → `credentials.toml`), which is offline and needs
67
+ no browser. There is **no refresh** (`refresh "none"`): an expired grant
68
+ demands a new sign-in, and an imported key is a static bearer.
69
+ - **Models** — the committed table is the pinned catalog's one-row seed
70
+ (`swe-1-6`); Devin's roster is credential-scoped, so a signed-in route
71
+ replaces it with `GetCliModelConfigs` for that account. The answer is served
72
+ for five minutes (a failure included); a failed read keeps that account's last
73
+ good roster, and a signed-out route or a switched account serves the seed
74
+ rather than the previous account's rows.
71
75
  - **Route** — `devin`, declared configurable so the Models page has a
72
76
  `providers.devin` profile with an allow-list.
73
77
  - **Images** — not yet, same as Cursor: text-only input, image blocks refused
package/lib/adapter.d.ts CHANGED
@@ -146,7 +146,7 @@ export declare const GITLAB_DUO_AGENT_CREDENTIAL_KEY: "llm-omp-transports/gitlab
146
146
  */
147
147
  export declare const GITLAB_DUO_AGENT_TRANSPORT_ROUTE: TransportRoute<GitLabDuoAgentModelRow, OmpGitLabDuoAgentModel, OmpGitLabDuoWorkflowOptions>;
148
148
  /** What an adapter needs from its host plugin. */
149
- export interface OmpAdapterOptions<Model, Options extends TransportOptions> {
149
+ export interface OmpAdapterOptions<Model, Options extends TransportOptions, Row = never> {
150
150
  /**
151
151
  * Resolve the route's bearer token for one request.
152
152
  *
@@ -182,9 +182,20 @@ export interface OmpAdapterOptions<Model, Options extends TransportOptions> {
182
182
  * the design chose over a route-specific adapter subclass.
183
183
  */
184
184
  identity?: () => Promise<Readonly<Record<string, unknown>> | undefined>;
185
+ /**
186
+ * The route's live catalog, for a route whose roster is credential-scoped.
187
+ *
188
+ * @remarks
189
+ * Devin's model table is per account: the committed table only carries the
190
+ * seed, and the real roster comes from an RPC the adapter cannot make before
191
+ * a grant exists. A route that supplies this is served from the returned rows
192
+ * on every call (the source applies its own cache); every other route keeps
193
+ * its static table.
194
+ */
195
+ rows?: () => Promise<readonly Row[]>;
185
196
  }
186
197
  /** The adapter configuration for one concrete route. */
187
- interface OmpRouteAdapterConfig<Row extends TransportRow, Model, Options extends TransportOptions> extends OmpAdapterOptions<Model, Options> {
198
+ interface OmpRouteAdapterConfig<Row extends TransportRow, Model, Options extends TransportOptions> extends OmpAdapterOptions<Model, Options, Row> {
188
199
  readonly route: TransportRoute<Row, Model, Options>;
189
200
  }
190
201
  /**
@@ -202,6 +213,15 @@ declare abstract class OmpTransportAdapter<Row extends TransportRow, Model, Opti
202
213
  protected constructor(config: OmpRouteAdapterConfig<Row, Model, Options>);
203
214
  /** The configured ids, or undefined when the route advertises the full catalog. */
204
215
  private allowed;
216
+ /**
217
+ * The rows this route serves now: its static table, or the live one.
218
+ *
219
+ * @remarks
220
+ * A static route answers its committed table. A credential-scoped route
221
+ * (`rows`) answers what its source holds — the source caches, so this is
222
+ * cheap enough to call per request.
223
+ */
224
+ private catalog;
205
225
  /** Resolve one catalog row, refusing ids the configured allow-list excludes. */
206
226
  private rowFor;
207
227
  /**
@@ -226,19 +246,19 @@ declare abstract class OmpTransportAdapter<Row extends TransportRow, Model, Opti
226
246
  private modelInfo;
227
247
  }
228
248
  /** The DSH llm adapter configuration for the Cursor route. */
229
- export type OmpCursorAdapterConfig = OmpAdapterOptions<OmpCursorModel, OmpCursorOptions>;
249
+ export type OmpCursorAdapterConfig = OmpAdapterOptions<OmpCursorModel, OmpCursorOptions, CursorModelRow>;
230
250
  /** The Cursor adapter: the bundled `streamCursor` over the generated Cursor catalog. */
231
251
  export declare class OmpCursorAdapter extends OmpTransportAdapter<CursorModelRow, OmpCursorModel, OmpCursorOptions> {
232
252
  constructor(options: OmpCursorAdapterConfig);
233
253
  }
234
254
  /** The DSH llm adapter configuration for the Devin route. */
235
- export type OmpDevinAdapterConfig = OmpAdapterOptions<OmpDevinModel, OmpDevinOptions>;
255
+ export type OmpDevinAdapterConfig = OmpAdapterOptions<OmpDevinModel, OmpDevinOptions, DevinModelRow>;
236
256
  /** The Devin adapter: the bundled `streamDevin` over the generated Devin catalog. */
237
257
  export declare class OmpDevinAdapter extends OmpTransportAdapter<DevinModelRow, OmpDevinModel, OmpDevinOptions> {
238
258
  constructor(options: OmpDevinAdapterConfig);
239
259
  }
240
260
  /** The DSH llm adapter configuration for a Google route. */
241
- export type OmpGoogleAdapterConfig = OmpAdapterOptions<OmpGoogleModel, OmpGoogleOptions>;
261
+ export type OmpGoogleAdapterConfig = OmpAdapterOptions<OmpGoogleModel, OmpGoogleOptions, GoogleModelRow>;
242
262
  /** The Gemini CLI adapter: the bundled `streamGoogleGeminiCli` over the Gemini CLI catalog. */
243
263
  export declare class OmpGoogleGeminiCliAdapter extends OmpTransportAdapter<GoogleModelRow, OmpGoogleModel, OmpGoogleOptions> {
244
264
  constructor(options: OmpGoogleAdapterConfig);
@@ -248,7 +268,7 @@ export declare class OmpAntigravityCliAdapter extends OmpTransportAdapter<Google
248
268
  constructor(options: OmpAdapterOptions<OmpAntigravityCliModel, OmpAntigravityCliOptions>);
249
269
  }
250
270
  /** The DSH llm adapter configuration for the Factory Droid route. */
251
- export type OmpFactoryDroidAdapterConfig = OmpAdapterOptions<OmpFactoryDroidModel, OmpFactoryDroidOptions>;
271
+ export type OmpFactoryDroidAdapterConfig = OmpAdapterOptions<OmpFactoryDroidModel, OmpFactoryDroidOptions, FactoryDroidModelRow>;
252
272
  /** The Factory Droid adapter: the bundled `streamFactoryDroid` over the registry seed catalog. */
253
273
  export declare class OmpFactoryDroidAdapter extends OmpTransportAdapter<FactoryDroidModelRow, OmpFactoryDroidModel, OmpFactoryDroidOptions> {
254
274
  constructor(options: OmpFactoryDroidAdapterConfig);
package/lib/adapter.js CHANGED
@@ -222,9 +222,22 @@ class OmpTransportAdapter extends LlmAdapter {
222
222
  const models = this.config.models?.();
223
223
  return models === undefined || models.length === 0 ? undefined : new Set(models);
224
224
  }
225
+ /**
226
+ * The rows this route serves now: its static table, or the live one.
227
+ *
228
+ * @remarks
229
+ * A static route answers its committed table. A credential-scoped route
230
+ * (`rows`) answers what its source holds — the source caches, so this is
231
+ * cheap enough to call per request.
232
+ */
233
+ async catalog() {
234
+ return this.config.rows === undefined ? this.config.route.models : await this.config.rows();
235
+ }
225
236
  /** Resolve one catalog row, refusing ids the configured allow-list excludes. */
226
- rowFor(model) {
227
- const row = this.rows.get(model);
237
+ async rowFor(model) {
238
+ const row = this.config.rows === undefined
239
+ ? this.rows.get(model)
240
+ : (await this.catalog()).find(candidate => candidate.id === model);
228
241
  const allowed = this.allowed();
229
242
  if (row === undefined || (allowed !== undefined && !allowed.has(row.id))) {
230
243
  throw new LlmError(`llm-omp-transports: the ${this.config.route.id} route has no model "${model}"`, UNKNOWN_MODEL);
@@ -249,7 +262,7 @@ class OmpTransportAdapter extends LlmAdapter {
249
262
  async listModels(provider) {
250
263
  this.assertRoute(provider);
251
264
  const allowed = this.allowed();
252
- return this.config.route.models
265
+ return (await this.catalog())
253
266
  .filter(row => allowed === undefined || allowed.has(row.id))
254
267
  .map(row => ({
255
268
  provider,
@@ -260,7 +273,7 @@ class OmpTransportAdapter extends LlmAdapter {
260
273
  }
261
274
  async resolveModel(provider, model) {
262
275
  this.assertRoute(provider);
263
- return this.modelInfo(provider, this.rowFor(model));
276
+ return this.modelInfo(provider, await this.rowFor(model));
264
277
  }
265
278
  stream(options) {
266
279
  return this.call(options);
@@ -283,7 +296,7 @@ class OmpTransportAdapter extends LlmAdapter {
283
296
  yield abortedFinish();
284
297
  return;
285
298
  }
286
- const row = this.rowFor(options.model);
299
+ const row = await this.rowFor(options.model);
287
300
  // Validate and project before touching the credential: a refused request
288
301
  // must not pay a credential read. Only a request that can be served
289
302
  // resolves `access` and carries its token into the transport options.
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;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,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAA;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAA;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,aAAa,EACb,qBAAqB,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AA6F;AAC7F,MAAM,OAAO,wBAAyB,SAAQ,mBAI7C;IACC,YAAY,OAAuC;QACjD,KAAK,CAAC,EAAE,KAAK,EAAE,gCAAgC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAA;IAChE,CAAC;CACF;AAKD,mFAAmF;AACnF,MAAM,OAAO,mBAAoB,SAAQ,mBAIxC;IACC,YAAY,OAAkC;QAC5C,KAAK,CAAC,EAAE,KAAK,EAAE,0BAA0B,EAAE,GAAG,OAAO,EAAE,CAAC,CAAA;IAC1D,CAAC;CACF"}
@@ -0,0 +1,28 @@
1
+ /** A sign-in step that failed in a way the flow reports as `AUTH_FAILED`. */
2
+ export declare class DevinCliCredentialsError extends Error {
3
+ constructor(message: string);
4
+ }
5
+ /** Where `devin auth login` may have written `credentials.toml`, in probe order. */
6
+ export declare function devinCliCredentialPaths(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform, home?: string): string[];
7
+ /**
8
+ * The seat key in one `credentials.toml` body.
9
+ *
10
+ * The file is a flat TOML document of `key = "value"` lines; only two keys are
11
+ * read, so no TOML parser is pulled in for it.
12
+ *
13
+ * shortcut: flat `key = "value"` TOML only, upgrade if Devin ever nests the key.
14
+ *
15
+ * @param text - the file's contents.
16
+ * @param file - the path, for error messages.
17
+ * @returns the raw seat key.
18
+ * @throws DevinCliCredentialsError when the file carries no usable key.
19
+ */
20
+ export declare function parseDevinCliCredentials(text: string, file: string): string;
21
+ /**
22
+ * Read the seat key from the first candidate file that exists.
23
+ *
24
+ * @param paths - candidates in probe order.
25
+ * @returns the raw seat key.
26
+ * @throws DevinCliCredentialsError when no candidate exists or none is usable.
27
+ */
28
+ export declare function readDevinCliCredentials(paths?: readonly string[]): Promise<string>;
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Import the seat key the official Devin CLI already stores.
3
+ *
4
+ * The twin of omp's `devin-cli` login hook (`pi-ai/src/registry/oauth/devin-cli.ts`,
5
+ * `login "custom" hook="devin-cli"`): `devin auth login` leaves a
6
+ * `windsurf_api_key` in `credentials.toml`, and that raw seat key is the same
7
+ * credential the Cascade API accepts. Nothing here touches the network and
8
+ * nothing prompts — a human who already signed in with the CLI should not have
9
+ * to sign in again.
10
+ *
11
+ * The plugin may not import `@oh-my-pi/*` at runtime, so the probe order, the
12
+ * field name and the accepted API hosts are copied from that hook. The key is
13
+ * only for the default host: a CLI bound to another `api_server_url` was issued
14
+ * a key this route's requests would not authenticate with, so it is refused
15
+ * instead of adopted.
16
+ *
17
+ * @module dsh-llm-omp-transports/devin/cli-credentials
18
+ */
19
+ import { readFile } from 'node:fs/promises';
20
+ import { homedir } from 'node:os';
21
+ import { posix, win32 } from 'node:path';
22
+ /** Hosts verified to accept the same raw seat key (the pinned hook's list). */
23
+ const KNOWN_API_HOSTS = ['server.codeium.com', 'server.enterprise.windsurf.com'];
24
+ /** A sign-in step that failed in a way the flow reports as `AUTH_FAILED`. */
25
+ export class DevinCliCredentialsError extends Error {
26
+ constructor(message) {
27
+ super(message);
28
+ this.name = 'DevinCliCredentialsError';
29
+ }
30
+ }
31
+ /** Where `devin auth login` may have written `credentials.toml`, in probe order. */
32
+ export function devinCliCredentialPaths(env = process.env, platform = process.platform, home = homedir()) {
33
+ const windows = platform === 'win32';
34
+ // The paths follow the platform, not the host, so a test can pin both.
35
+ const p = windows ? win32 : posix;
36
+ const dataDirs = [
37
+ windows ? env.APPDATA : undefined,
38
+ env.XDG_DATA_HOME,
39
+ p.join(home, '.local', 'share'),
40
+ // The Devin CLI documents macOS as XDG-only; the Library path is probed
41
+ // because that is where a Library-using build writes (omp probes it too).
42
+ windows ? undefined : p.join(home, 'Library', 'Application Support'),
43
+ ];
44
+ const files = dataDirs
45
+ .filter((dir) => dir !== undefined && dir !== '')
46
+ .map(dir => p.join(dir, 'devin', 'credentials.toml'));
47
+ return [...new Set(files)];
48
+ }
49
+ /**
50
+ * The seat key in one `credentials.toml` body.
51
+ *
52
+ * The file is a flat TOML document of `key = "value"` lines; only two keys are
53
+ * read, so no TOML parser is pulled in for it.
54
+ *
55
+ * shortcut: flat `key = "value"` TOML only, upgrade if Devin ever nests the key.
56
+ *
57
+ * @param text - the file's contents.
58
+ * @param file - the path, for error messages.
59
+ * @returns the raw seat key.
60
+ * @throws DevinCliCredentialsError when the file carries no usable key.
61
+ */
62
+ export function parseDevinCliCredentials(text, file) {
63
+ const fields = {};
64
+ for (const line of text.split(/\r?\n/)) {
65
+ const match = /^\s*([A-Za-z0-9_.-]+)\s*=\s*"((?:[^"\\]|\\.)*)"\s*(?:#.*)?$/.exec(line);
66
+ if (match !== null)
67
+ fields[match[1]] = match[2].replace(/\\(.)/g, '$1');
68
+ }
69
+ const key = fields.windsurf_api_key?.trim() ?? '';
70
+ if (key === '') {
71
+ throw new DevinCliCredentialsError(`the Devin CLI credentials at ${file} carry no windsurf_api_key; run \`devin auth login\`, then retry`);
72
+ }
73
+ const serverUrl = fields.api_server_url;
74
+ if (serverUrl !== undefined && serverUrl !== '') {
75
+ let host;
76
+ try {
77
+ host = new URL(serverUrl).host;
78
+ }
79
+ catch {
80
+ host = undefined;
81
+ }
82
+ if (host === undefined || !KNOWN_API_HOSTS.includes(host)) {
83
+ throw new DevinCliCredentialsError(`the Devin CLI credentials at ${file} point at unsupported API server "${serverUrl}" (supported: ${KNOWN_API_HOSTS.join(', ')})`);
84
+ }
85
+ }
86
+ return key;
87
+ }
88
+ /**
89
+ * Read the seat key from the first candidate file that exists.
90
+ *
91
+ * @param paths - candidates in probe order.
92
+ * @returns the raw seat key.
93
+ * @throws DevinCliCredentialsError when no candidate exists or none is usable.
94
+ */
95
+ export async function readDevinCliCredentials(paths = devinCliCredentialPaths()) {
96
+ for (const file of paths) {
97
+ let text;
98
+ try {
99
+ text = await readFile(file, 'utf8');
100
+ }
101
+ catch (cause) {
102
+ if (cause.code === 'ENOENT')
103
+ continue;
104
+ throw new DevinCliCredentialsError(`the Devin CLI credentials at ${file} could not be read: ${cause instanceof Error ? cause.message : String(cause)}`);
105
+ }
106
+ return parseDevinCliCredentials(text, file);
107
+ }
108
+ throw new DevinCliCredentialsError(`no Devin CLI credentials were found (probed: ${paths.join(', ')}); run \`devin auth login\`, then retry`);
109
+ }
110
+ //# sourceMappingURL=cli-credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-credentials.js","sourceRoot":"","sources":["../../src/devin/cli-credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAExC,+EAA+E;AAC/E,MAAM,eAAe,GAAG,CAAC,oBAAoB,EAAE,gCAAgC,CAAC,CAAA;AAEhF,6EAA6E;AAC7E,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACjD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAA;IACxC,CAAC;CACF;AAED,oFAAoF;AACpF,MAAM,UAAU,uBAAuB,CACrC,MAAyB,OAAO,CAAC,GAAG,EACpC,WAA4B,OAAO,CAAC,QAAQ,EAC5C,OAAe,OAAO,EAAE;IAExB,MAAM,OAAO,GAAG,QAAQ,KAAK,OAAO,CAAA;IACpC,uEAAuE;IACvE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAA;IACjC,MAAM,QAAQ,GAAG;QACf,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;QACjC,GAAG,CAAC,aAAa;QACjB,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC;QAC/B,wEAAwE;QACxE,0EAA0E;QAC1E,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CA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I,CAAA;QAChC,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,GAAG,SAAS,CAAA;QAClB,CAAC;QACD,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1D,MAAM,IAAI,wBAAwB,CAChC,gCAAgC,IAAI,qCAAqC,SAAS,iBAAiB,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACjI,CAAA;QACH,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,QAA2B,uBAAuB,EAAE;IAEpD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAY,CAAA;QAChB,IAAI,CAAC;YACH,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QACrC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;gBAAE,SAAQ;YAChE,MAAM,IAAI,wBAAwB,CAChC,gCAAgC,IAAI,uBAAuB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACpH,CAAA;QACH,CAAC;QACD,OAAO,wBAAwB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAC7C,CAAC;IACD,MAAM,IAAI,wBAAwB,CAChC,gDAAgD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,yCAAyC,CAC1G,CAAA;AACH,CAAC"}
@@ -0,0 +1,44 @@
1
+ import type { DevinModelRow, OmpDevinDiscoveredModel, OmpDevinDiscoveryOptions } from '../omp.js';
2
+ import type { CredentialRecordsLike } from '../cursor/credentials.js';
3
+ /** The discovery half of the bundled artifact (also the tests' seam). */
4
+ export type DiscoverDevinModels = (options: OmpDevinDiscoveryOptions) => Promise<readonly OmpDevinDiscoveredModel[] | null>;
5
+ /** Test seams for {@link refreshDevinRows}; the plugin uses the real network and clock. */
6
+ export interface DevinCatalogOptions {
7
+ readonly fetch?: typeof fetch;
8
+ readonly timeoutMs?: number;
9
+ readonly signal?: AbortSignal;
10
+ readonly now?: () => number;
11
+ /** The discovery implementation; defaults to the bundled artifact. */
12
+ readonly discover?: DiscoverDevinModels;
13
+ }
14
+ /** The rows this route serves right now: a discovery result, or the seed. */
15
+ export declare function currentDevinRows(): readonly DevinModelRow[];
16
+ /**
17
+ * Read the grant and refresh the roster, publishing or recording the outcome.
18
+ *
19
+ * The forced re-read: unlike {@link devinRows} it ignores the TTL and reports a
20
+ * failure instead of absorbing it. The routine path (adapter reads, the model
21
+ * picker) goes through `devinRows`; this entry point exists for a caller that
22
+ * wants to know whether a read works, and the test suite drives it.
23
+ *
24
+ * @param credentials - the record half of the credentials seam, for the grant.
25
+ * @param options - fetch/timeout/clock seams.
26
+ * @returns the roster now served (the seed when there is no usable grant).
27
+ * @throws when the read fails, so a forced refresh can report it; callers that
28
+ * must not fail ({@link devinRows}) swallow it and serve what the route already
29
+ * has.
30
+ */
31
+ export declare function refreshDevinRows(credentials: CredentialRecordsLike, options?: DevinCatalogOptions): Promise<readonly DevinModelRow[]>;
32
+ /**
33
+ * The route's roster, read at most once per {@link TTL_MS} per account.
34
+ *
35
+ * Never rejects: a failed read leaves what the route already serves (the same
36
+ * account's last good roster, else the seed) in service for the rest of the TTL,
37
+ * so an endpoint that is down costs one attempt per window instead of one per
38
+ * turn.
39
+ *
40
+ * @param credentials - the record half of the credentials seam.
41
+ * @param options - fetch/timeout/clock seams, forwarded to the refresh.
42
+ * @returns the rows to serve.
43
+ */
44
+ export declare function devinRows(credentials: CredentialRecordsLike, options?: DevinCatalogOptions): Promise<readonly DevinModelRow[]>;
@@ -0,0 +1,220 @@
1
+ /**
2
+ * The Devin route's live model catalog.
3
+ *
4
+ * Devin's roster is credential-scoped: the pinned catalog deliberately ships a
5
+ * single seed row (`swe-1-6`) because baking one account's entitlement into a
6
+ * shared table would misstate every other account's. omp therefore marks the
7
+ * provider `dynamic-models-authoritative` and replaces the seed with the result
8
+ * of `GetCliModelConfigs` at runtime; this module does the same for the plugin,
9
+ * reading that RPC through the bundled artifact (the published package may not
10
+ * import `@oh-my-pi/*` at runtime).
11
+ *
12
+ * The discovered rows live in one module-level slot keyed by the account they
13
+ * were read for, so the adapter's `listModels` and the keys-manager's model
14
+ * picker see the same roster without the host routing it through a service.
15
+ * The fallback is the same account's last good roster, else the committed seed —
16
+ * never another account's rows: a signed-out route and a switched account answer
17
+ * the seed. A failed read is not retried before the TTL expires (a dead endpoint
18
+ * must not cost one doomed RPC per turn).
19
+ *
20
+ * @module dsh-llm-omp-transports/devin/discovery
21
+ */
22
+ import { createHash } from 'node:crypto';
23
+ import { DEVIN_MODELS } from '../catalog/devin.js';
24
+ import { DEVIN_CREDENTIAL_KEY, readDevinGrant } from './credentials.js';
25
+ /** How long a discovered roster — or a failed read — is trusted before the next ask. */
26
+ const TTL_MS = 5 * 60 * 1000;
27
+ /** The roster a successful read published, and the account it belongs to. */
28
+ let served;
29
+ /** When the last read for an account failed, so the TTL bounds a dead endpoint too. */
30
+ let failed;
31
+ /** The read in flight, keyed by account, so concurrent callers share one RPC. */
32
+ let inFlight;
33
+ /**
34
+ * An opaque per-account cache key.
35
+ *
36
+ * A digest, not the token: the slot has to recognize "the same account" across
37
+ * turns without keeping a second copy of a live credential around.
38
+ */
39
+ function accountKey(access) {
40
+ return createHash('sha256').update(access).digest('hex').slice(0, 16);
41
+ }
42
+ /** The rows this route serves right now: a discovery result, or the seed. */
43
+ export function currentDevinRows() {
44
+ return served === undefined ? DEVIN_MODELS : served.rows;
45
+ }
46
+ /** Forget the published roster and the failure mark (sign-out, account switch). */
47
+ function forget() {
48
+ served = undefined;
49
+ failed = undefined;
50
+ }
51
+ /**
52
+ * Load the discovery half of the bundled artifact on first use.
53
+ *
54
+ * As lazy as `bundledTransport`: a source checkout without `pnpm build` keeps
55
+ * serving the seed instead of failing the route at import time.
56
+ */
57
+ async function loadDiscovery() {
58
+ const loaded = (await import(new URL('../omp/devin.mjs', import.meta.url).href));
59
+ const candidate = loaded.fetchDevinModels;
60
+ if (typeof candidate !== 'function')
61
+ throw new Error('the bundled devin artifact exports no fetchDevinModels');
62
+ return candidate;
63
+ }
64
+ /** omp's fallbacks for a server row that states neither limit. */
65
+ const DEFAULT_CONTEXT_WINDOW = 200_000;
66
+ const DEFAULT_MAX_TOKENS = 64_000;
67
+ /** One discovered spec as the generated row shape the adapter serves. */
68
+ function toRow(spec) {
69
+ return {
70
+ id: spec.id,
71
+ name: spec.name,
72
+ baseUrl: spec.baseUrl,
73
+ contextWindow: spec.contextWindow ?? DEFAULT_CONTEXT_WINDOW,
74
+ maxTokens: spec.maxTokens ?? DEFAULT_MAX_TOKENS,
75
+ input: [...spec.input],
76
+ cost: { ...spec.cost },
77
+ reasoning: spec.reasoning === true,
78
+ compat: {
79
+ // The provider rule pins `on-api "devin-agent" trust-explicit-thinking-only
80
+ // #true`; the discovery spec only ever names the two optional flags.
81
+ trustExplicitThinkingOnly: spec.compat?.trustExplicitThinkingOnly ?? true,
82
+ modelRouter: spec.compat?.modelRouter === true,
83
+ supportsParallelToolCalls: spec.compat?.supportsParallelToolCalls === true,
84
+ },
85
+ ...(spec.requestModelId === undefined ? {} : { requestModelId: spec.requestModelId }),
86
+ };
87
+ }
88
+ /**
89
+ * The grant the route may discover with, or `undefined` when there is none.
90
+ *
91
+ * An absent, corrupt or expired record is not a failure: there is nothing to ask
92
+ * with, and the route still serves its seed.
93
+ */
94
+ function usableGrant(record, now) {
95
+ const grant = readDevinGrant(record);
96
+ if (grant === undefined || grant.expiresInvalid === true)
97
+ return undefined;
98
+ if (grant.expires !== undefined && grant.expires <= now)
99
+ return undefined;
100
+ return { access: grant.access, account: accountKey(grant.access) };
101
+ }
102
+ /**
103
+ * Ask Devin for one account's models and publish the answer.
104
+ *
105
+ * Every failure — a rejected fetch, a timeout, an unloadable artifact, an empty
106
+ * catalog — is recorded against the account before it propagates, so the TTL
107
+ * bounds it exactly like a success. A caller's own abort is not a failure and is
108
+ * left unrecorded.
109
+ *
110
+ * @param grant - the account to ask for.
111
+ * @param options - fetch/timeout/clock seams.
112
+ * @returns the published rows.
113
+ * @throws when the read fails.
114
+ */
115
+ async function discoverRows(grant, options, now) {
116
+ let specs;
117
+ try {
118
+ const discover = options.discover ?? await loadDiscovery();
119
+ specs = await discover({
120
+ apiKey: grant.access,
121
+ ...(options.fetch === undefined ? {} : { fetch: options.fetch }),
122
+ ...(options.timeoutMs === undefined ? {} : { timeoutMs: options.timeoutMs }),
123
+ ...(options.signal === undefined ? {} : { signal: options.signal }),
124
+ });
125
+ if (specs === null || specs.length === 0) {
126
+ throw new Error('llm-omp-transports: Devin returned no model catalog for this account');
127
+ }
128
+ }
129
+ catch (cause) {
130
+ // The caller withdrawing the read is not the endpoint's fault.
131
+ if (options.signal?.aborted !== true)
132
+ failed = { at: now(), account: grant.account };
133
+ throw cause;
134
+ }
135
+ const rows = specs.map(toRow).sort((a, b) => a.id.localeCompare(b.id));
136
+ served = { rows, at: now(), account: grant.account };
137
+ failed = undefined;
138
+ return rows;
139
+ }
140
+ /**
141
+ * Read the grant and refresh the roster, publishing or recording the outcome.
142
+ *
143
+ * The forced re-read: unlike {@link devinRows} it ignores the TTL and reports a
144
+ * failure instead of absorbing it. The routine path (adapter reads, the model
145
+ * picker) goes through `devinRows`; this entry point exists for a caller that
146
+ * wants to know whether a read works, and the test suite drives it.
147
+ *
148
+ * @param credentials - the record half of the credentials seam, for the grant.
149
+ * @param options - fetch/timeout/clock seams.
150
+ * @returns the roster now served (the seed when there is no usable grant).
151
+ * @throws when the read fails, so a forced refresh can report it; callers that
152
+ * must not fail ({@link devinRows}) swallow it and serve what the route already
153
+ * has.
154
+ */
155
+ export async function refreshDevinRows(credentials, options = {}) {
156
+ const now = options.now ?? Date.now;
157
+ const grant = usableGrant(await credentials.readRecord(DEVIN_CREDENTIAL_KEY), now());
158
+ if (grant === undefined) {
159
+ // Signed out (or the record is unusable): the previous account's roster is
160
+ // not this route's to serve, and there is nothing to ask with.
161
+ forget();
162
+ return currentDevinRows();
163
+ }
164
+ if (served !== undefined && served.account !== grant.account)
165
+ forget();
166
+ return discoverRows(grant, options, now);
167
+ }
168
+ /**
169
+ * The route's roster, read at most once per {@link TTL_MS} per account.
170
+ *
171
+ * Never rejects: a failed read leaves what the route already serves (the same
172
+ * account's last good roster, else the seed) in service for the rest of the TTL,
173
+ * so an endpoint that is down costs one attempt per window instead of one per
174
+ * turn.
175
+ *
176
+ * @param credentials - the record half of the credentials seam.
177
+ * @param options - fetch/timeout/clock seams, forwarded to the refresh.
178
+ * @returns the rows to serve.
179
+ */
180
+ export async function devinRows(credentials, options = {}) {
181
+ const now = (options.now ?? Date.now)();
182
+ let grant;
183
+ try {
184
+ grant = usableGrant(await credentials.readRecord(DEVIN_CREDENTIAL_KEY), now);
185
+ }
186
+ catch {
187
+ // The store cannot say whose roster the slot holds, and the invariant is
188
+ // "this account or the seed": an unreadable store proves neither, so the
189
+ // published rows are dropped rather than attributed to whoever asks next.
190
+ forget();
191
+ return currentDevinRows();
192
+ }
193
+ // The picker and the adapter both reach here, so the account check happens on
194
+ // every call: a signed-out or switched route must not keep serving the old
195
+ // account's rows while the same module slot survives.
196
+ if (served !== undefined && (grant === undefined || served.account !== grant.account))
197
+ forget();
198
+ if (grant === undefined)
199
+ return currentDevinRows();
200
+ if (served !== undefined && served.account === grant.account && now - served.at < TTL_MS)
201
+ return served.rows;
202
+ if (failed !== undefined && failed.account === grant.account && now - failed.at < TTL_MS)
203
+ return currentDevinRows();
204
+ // Only the same account's read is worth sharing; a different account's
205
+ // in-flight answer would publish its roster here.
206
+ if (inFlight !== undefined) {
207
+ return inFlight.account === grant.account ? inFlight.promise : currentDevinRows();
208
+ }
209
+ // The grant is already resolved: the refresh below must not read the store a
210
+ // second time (and cannot reject from that read).
211
+ const run = discoverRows(grant, options, options.now ?? Date.now)
212
+ .catch(() => currentDevinRows())
213
+ .finally(() => {
214
+ if (inFlight?.promise === run)
215
+ inFlight = undefined;
216
+ });
217
+ inFlight = { account: grant.account, promise: run };
218
+ return run;
219
+ }
220
+ //# sourceMappingURL=discovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery.js","sourceRoot":"","sources":["../../src/devin/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAElD,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAGvE,wFAAwF;AACxF,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAA;AAiB5B,6EAA6E;AAC7E,IAAI,MAA8G,CAAA;AAClH,uFAAuF;AACvF,IAAI,MAAqE,CAAA;AACzE,iFAAiF;AACjF,IAAI,QAAuG,CAAA;AAE3G;;;;;GAKG;AACH,SAAS,UAAU,CAAC,MAAc;IAChC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACvE,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,gBAAgB;IAC9B,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAA;AAC1D,CAAC;AAED,mFAAmF;AACnF,SAAS,MAAM;IACb,MAAM,GAAG,SAAS,CAAA;IAClB,MAAM,GAAG,SAAS,CAAA;AACpB,CAAC;AAED;;;;;GAKG;AACH,KAAK,UAAU,aAAa;IAC1B,MAAM,MAAM,GAAG,CAAC,MAAM,MAA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