opencode-devin 0.2.11 → 2.0.0-beta.0
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 +56 -0
- package/LICENSE +1 -1
- package/README.md +118 -228
- package/SECURITY.md +81 -0
- package/package.json +52 -58
- package/scripts/dump-log.ts +22 -0
- package/scripts/login.ts +46 -0
- package/src/index.ts +5 -0
- package/src/plugin.ts +293 -0
- package/src/provider/auth.ts +339 -0
- package/src/provider/cascade.ts +469 -0
- package/src/provider/index.ts +321 -0
- package/src/provider/log.ts +99 -0
- package/src/provider/package.json +6 -0
- package/src/provider/paths.ts +33 -0
- package/src/provider/proto.ts +197 -0
- package/dist/catalog.d.ts +0 -22
- package/dist/catalog.js +0 -111
- package/dist/constants.d.ts +0 -19
- package/dist/constants.js +0 -19
- package/dist/credentials.d.ts +0 -23
- package/dist/credentials.js +0 -57
- package/dist/index.d.ts +0 -17
- package/dist/index.js +0 -135
- package/dist/protocol/model.d.ts +0 -68
- package/dist/protocol/model.js +0 -738
- package/dist/provider.d.ts +0 -43
- package/dist/provider.js +0 -30
package/dist/catalog.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Model catalog from Cognition's Cascade gRPC API.
|
|
3
|
-
*
|
|
4
|
-
* The live catalog comes from the per-account `GetCascadeModelConfigs` RPC
|
|
5
|
-
* (via ai-sdk-devin) — every model UID the subscription can use, with pricing
|
|
6
|
-
* and context windows. This is the same source the Devin CLI uses
|
|
7
|
-
* (`GetCliModelConfigs`); the REST gateway (`/api/v1/models`) is not
|
|
8
|
-
* provisioned for most accounts.
|
|
9
|
-
*
|
|
10
|
-
* Upstream lists one UID per reasoning effort. They are published as one model
|
|
11
|
-
* per family with the efforts as variants, so the effort is picked with the
|
|
12
|
-
* variant switcher instead of by choosing a different model.
|
|
13
|
-
*
|
|
14
|
-
* The per-effort UIDs stay published as deprecated models. opencode leaves
|
|
15
|
-
* those out of the model picker but still resolves them, so a config, a
|
|
16
|
-
* favourite or a session that names `devin/claude-opus-5-5-high` keeps working.
|
|
17
|
-
*/
|
|
18
|
-
import { getCachedCatalog } from "devin-core";
|
|
19
|
-
import { defaultMember, EFFORT_LEVELS, toEffortLevel } from "devin-core";
|
|
20
|
-
import { Model, Provider } from "@opencode/plugin";
|
|
21
|
-
import { DEFAULT_RELEASED_MS, PROVIDER_ID } from "./constants.js";
|
|
22
|
-
export async function fetchModels(apiKey, apiServerUrl) {
|
|
23
|
-
const catalog = await getCachedCatalog(apiKey, apiServerUrl || undefined);
|
|
24
|
-
if (!catalog)
|
|
25
|
-
return [];
|
|
26
|
-
return toModelInfos(Array.from(catalog.byUid.values()));
|
|
27
|
-
}
|
|
28
|
-
/** Exported for tests. */
|
|
29
|
-
export function toModelInfos(entries) {
|
|
30
|
-
const families = new Map();
|
|
31
|
-
for (const entry of entries) {
|
|
32
|
-
if (entry.disabled)
|
|
33
|
-
continue;
|
|
34
|
-
const key = entry.baseModelUid ?? entry.modelUid;
|
|
35
|
-
const family = families.get(key);
|
|
36
|
-
if (family)
|
|
37
|
-
family.push(entry);
|
|
38
|
-
else
|
|
39
|
-
families.set(key, [entry]);
|
|
40
|
-
}
|
|
41
|
-
const models = [];
|
|
42
|
-
for (const [baseModelUid, family] of families) {
|
|
43
|
-
// Members carrying a resolvable effort (suffix or capability) are the
|
|
44
|
-
// variant candidates; members without one are bare uids. A bare uid whose
|
|
45
|
-
// modelUid equals the family key is the family's default member — the
|
|
46
|
-
// model the picker shows. Any other bare uid is a distinct model (e.g.
|
|
47
|
-
// `-fast` speed variants sit in their own family key, so this is rare).
|
|
48
|
-
const effortful = family.filter((entry) => toEffortLevel(entry.effortLevel) !== undefined);
|
|
49
|
-
const distinctEfforts = new Set(effortful.map((entry) => toEffortLevel(entry.effortLevel)));
|
|
50
|
-
// Merge when every effortful member maps to a distinct effort. The old
|
|
51
|
-
// rule also required zero bare members — but the bare uid IS the default
|
|
52
|
-
// variant, so a family of bare+effortful must merge too, not explode into
|
|
53
|
-
// one model per uid. Only a family with more than one unresolvable bare
|
|
54
|
-
// member (ambiguous default) falls back to one-model-per-uid.
|
|
55
|
-
const bareCount = family.length - effortful.length;
|
|
56
|
-
if (effortful.length > 0 && distinctEfforts.size === effortful.length && bareCount <= 1) {
|
|
57
|
-
const primary = defaultMember(family);
|
|
58
|
-
models.push(toModelInfo(primary, baseModelUid, effortful));
|
|
59
|
-
for (const entry of family) {
|
|
60
|
-
if (entry.modelUid !== baseModelUid)
|
|
61
|
-
models.push(toModelInfo(entry, entry.modelUid, [], "deprecated"));
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
for (const entry of family)
|
|
66
|
-
models.push(toModelInfo(entry, entry.modelUid, []));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return models;
|
|
70
|
-
}
|
|
71
|
-
/** "Claude Opus 5.5 High Fast" and "GPT-6 Sol No Thinking" without the effort. */
|
|
72
|
-
function familyName(label) {
|
|
73
|
-
const efforts = EFFORT_LEVELS.join("|");
|
|
74
|
-
const stripped = label
|
|
75
|
-
.replace(/\s+No Thinking\b/i, "")
|
|
76
|
-
.replace(new RegExp(`\\s+(?:${efforts})(?:\\s+Thinking)?(?=\\s|$)(?!.*\\s(?:${efforts})(?:\\s|$))`, "i"), "")
|
|
77
|
-
.trim();
|
|
78
|
-
return stripped || label;
|
|
79
|
-
}
|
|
80
|
-
function toModelInfo(entry, id, family, status = "active") {
|
|
81
|
-
const { pricing } = entry;
|
|
82
|
-
const base = Model.Info.default(Provider.ID.make(PROVIDER_ID), Model.ID.make(id));
|
|
83
|
-
const rank = (candidate) => EFFORT_LEVELS.indexOf(toEffortLevel(candidate.effortLevel));
|
|
84
|
-
return {
|
|
85
|
-
...base,
|
|
86
|
-
name: family.length > 0 ? familyName(entry.label || id) : entry.label || id,
|
|
87
|
-
enabled: !entry.disabled,
|
|
88
|
-
status,
|
|
89
|
-
capabilities: {
|
|
90
|
-
tools: true,
|
|
91
|
-
input: ["text", "image"],
|
|
92
|
-
output: ["text"],
|
|
93
|
-
},
|
|
94
|
-
// Read by the provider as `providerOptions.devin.reasoningEffort`.
|
|
95
|
-
variants: [...family]
|
|
96
|
-
.sort((a, b) => rank(a) - rank(b))
|
|
97
|
-
.map((member) => ({ id: member.effortLevel, settings: { reasoningEffort: member.effortLevel } })),
|
|
98
|
-
cost: [
|
|
99
|
-
{
|
|
100
|
-
input: pricing?.input ?? 0,
|
|
101
|
-
output: pricing?.output ?? 0,
|
|
102
|
-
cache: { read: pricing?.cachedInput ?? 0, write: 0 },
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
limit: {
|
|
106
|
-
context: entry.contextWindow || 256_000,
|
|
107
|
-
output: 128_000,
|
|
108
|
-
},
|
|
109
|
-
time: { released: DEFAULT_RELEASED_MS },
|
|
110
|
-
};
|
|
111
|
-
}
|
package/dist/constants.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/** Shared constants for the opencode-devin plugin. */
|
|
2
|
-
/** OpenCode provider and integration ID. Models appear as `devin/<uid>`. */
|
|
3
|
-
export declare const PROVIDER_ID = "devin";
|
|
4
|
-
/** Environment variable holding a Devin session token (`devin-session-token$...`). */
|
|
5
|
-
export declare const LLM_ENV_VAR = "DEVIN_LLM_API_KEY";
|
|
6
|
-
/** Devin webapp — hosts the CLI login page (`/auth/cli/continue`). */
|
|
7
|
-
export declare const WEBAPP_URL = "https://app.devin.ai";
|
|
8
|
-
/** Devin auth API — exchanges the PKCE code for a session token. */
|
|
9
|
-
export declare const AUTH_API_URL = "https://api.devin.ai";
|
|
10
|
-
/** Default Codeium API server (Cascade gRPC) when no tenant host is known. */
|
|
11
|
-
export declare const DEFAULT_API_SERVER = "https://server.codeium.com";
|
|
12
|
-
/** Prefix the Devin CLI puts in front of the session JWT. */
|
|
13
|
-
export declare const TOKEN_PREFIX = "devin-session-token$";
|
|
14
|
-
/** Loopback callback path required by the webapp's safe-redirect check. */
|
|
15
|
-
export declare const CALLBACK_PATH = "/callback";
|
|
16
|
-
/** Credential lifetime reported to opencode (the token itself is long-lived). */
|
|
17
|
-
export declare const CREDENTIAL_TTL_MS: number;
|
|
18
|
-
/** Fallback release date for catalog models that do not expose one (epoch ms). */
|
|
19
|
-
export declare const DEFAULT_RELEASED_MS: number;
|
package/dist/constants.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/** Shared constants for the opencode-devin plugin. */
|
|
2
|
-
/** OpenCode provider and integration ID. Models appear as `devin/<uid>`. */
|
|
3
|
-
export const PROVIDER_ID = "devin";
|
|
4
|
-
/** Environment variable holding a Devin session token (`devin-session-token$...`). */
|
|
5
|
-
export const LLM_ENV_VAR = "DEVIN_LLM_API_KEY";
|
|
6
|
-
/** Devin webapp — hosts the CLI login page (`/auth/cli/continue`). */
|
|
7
|
-
export const WEBAPP_URL = "https://app.devin.ai";
|
|
8
|
-
/** Devin auth API — exchanges the PKCE code for a session token. */
|
|
9
|
-
export const AUTH_API_URL = "https://api.devin.ai";
|
|
10
|
-
/** Default Codeium API server (Cascade gRPC) when no tenant host is known. */
|
|
11
|
-
export const DEFAULT_API_SERVER = "https://server.codeium.com";
|
|
12
|
-
/** Prefix the Devin CLI puts in front of the session JWT. */
|
|
13
|
-
export const TOKEN_PREFIX = "devin-session-token$";
|
|
14
|
-
/** Loopback callback path required by the webapp's safe-redirect check. */
|
|
15
|
-
export const CALLBACK_PATH = "/callback";
|
|
16
|
-
/** Credential lifetime reported to opencode (the token itself is long-lived). */
|
|
17
|
-
export const CREDENTIAL_TTL_MS = 365 * 24 * 60 * 60 * 1000;
|
|
18
|
-
/** Fallback release date for catalog models that do not expose one (epoch ms). */
|
|
19
|
-
export const DEFAULT_RELEASED_MS = Date.parse("2025-01-01T00:00:00Z");
|
package/dist/credentials.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Devin credential resolution.
|
|
3
|
-
*
|
|
4
|
-
* The chat credential is a long-lived session token
|
|
5
|
-
* (`devin-session-token$<JWT>`), issued either by the Devin CLI login flow
|
|
6
|
-
* (PKCE) or by Windsurf OAuth. Sources, in priority order:
|
|
7
|
-
*
|
|
8
|
-
* 1. `DEVIN_LLM_API_KEY` environment variable
|
|
9
|
-
* 2. the credential stored by opencode's `/connect` (this plugin's integration)
|
|
10
|
-
*/
|
|
11
|
-
import type { Plugin } from "@opencode/plugin";
|
|
12
|
-
import { Credential } from "@opencode/plugin";
|
|
13
|
-
export interface DevinCredentials {
|
|
14
|
-
apiKey: string;
|
|
15
|
-
name: string;
|
|
16
|
-
/** Tenant-scoped inference host; empty means the default Codeium server. */
|
|
17
|
-
apiServerUrl?: string;
|
|
18
|
-
}
|
|
19
|
-
export type PluginContext = Parameters<Parameters<typeof Plugin.define>[0]["setup"]>[0];
|
|
20
|
-
/** Resolve the active Devin credentials, or `undefined` when not connected. */
|
|
21
|
-
export declare function resolveCredentials(ctx: PluginContext): Promise<DevinCredentials | undefined>;
|
|
22
|
-
/** Build the opencode credential object stored by `/connect`. */
|
|
23
|
-
export declare function toStoredCredential(apiKey: string, name?: string, apiServerUrl?: string): Credential.OAuth;
|
package/dist/credentials.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Devin credential resolution.
|
|
3
|
-
*
|
|
4
|
-
* The chat credential is a long-lived session token
|
|
5
|
-
* (`devin-session-token$<JWT>`), issued either by the Devin CLI login flow
|
|
6
|
-
* (PKCE) or by Windsurf OAuth. Sources, in priority order:
|
|
7
|
-
*
|
|
8
|
-
* 1. `DEVIN_LLM_API_KEY` environment variable
|
|
9
|
-
* 2. the credential stored by opencode's `/connect` (this plugin's integration)
|
|
10
|
-
*/
|
|
11
|
-
import { Credential } from "@opencode/plugin";
|
|
12
|
-
import { CREDENTIAL_TTL_MS, DEFAULT_API_SERVER, LLM_ENV_VAR, PROVIDER_ID, TOKEN_PREFIX } from "./constants.js";
|
|
13
|
-
function fromEnv() {
|
|
14
|
-
const apiKey = process.env[LLM_ENV_VAR];
|
|
15
|
-
if (!apiKey?.startsWith(TOKEN_PREFIX))
|
|
16
|
-
return undefined;
|
|
17
|
-
return { apiKey, name: "env" };
|
|
18
|
-
}
|
|
19
|
-
async function fromStoredConnection(ctx) {
|
|
20
|
-
try {
|
|
21
|
-
const connection = await ctx.integration.connection.active(PROVIDER_ID);
|
|
22
|
-
if (!connection)
|
|
23
|
-
return undefined;
|
|
24
|
-
const value = await ctx.integration.connection.resolve(connection);
|
|
25
|
-
const access = value?.type === "oauth" ? value.access : value?.type === "key" ? value.key : undefined;
|
|
26
|
-
if (!access?.startsWith(TOKEN_PREFIX))
|
|
27
|
-
return undefined;
|
|
28
|
-
const metadata = value?.type === "oauth" ? value.metadata : undefined;
|
|
29
|
-
return {
|
|
30
|
-
apiKey: access,
|
|
31
|
-
name: typeof metadata?.name === "string" ? metadata.name : "opencode",
|
|
32
|
-
apiServerUrl: typeof metadata?.apiServerUrl === "string" ? metadata.apiServerUrl : undefined,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
// An absent connection is normal and returns above without logging. An
|
|
37
|
-
// exception here is not: the visible symptom is "no devin models", so the
|
|
38
|
-
// reason has to reach the log somewhere.
|
|
39
|
-
console.warn("[opencode-devin] could not resolve the stored credential:", error);
|
|
40
|
-
return undefined;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/** Resolve the active Devin credentials, or `undefined` when not connected. */
|
|
44
|
-
export async function resolveCredentials(ctx) {
|
|
45
|
-
return (await fromEnv()) ?? (await fromStoredConnection(ctx));
|
|
46
|
-
}
|
|
47
|
-
/** Build the opencode credential object stored by `/connect`. */
|
|
48
|
-
export function toStoredCredential(apiKey, name = "opencode", apiServerUrl) {
|
|
49
|
-
return {
|
|
50
|
-
type: "oauth",
|
|
51
|
-
methodID: "devin",
|
|
52
|
-
refresh: "",
|
|
53
|
-
access: apiKey,
|
|
54
|
-
expires: Date.now() + CREDENTIAL_TTL_MS,
|
|
55
|
-
metadata: apiServerUrl ? { name, apiServerUrl } : { name },
|
|
56
|
-
};
|
|
57
|
-
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OpenCode v2 plugin: Devin / Cognition.
|
|
3
|
-
*
|
|
4
|
-
* - Integration `devin` with the Devin CLI login flow (PKCE, same as chisel)
|
|
5
|
-
* so `/connect` stores the credential natively: automated browser flow and
|
|
6
|
-
* a paste-code fallback for headless machines.
|
|
7
|
-
* - Provider `devin` streaming chat through Cognition's Cascade protocol
|
|
8
|
-
* (src/protocol/), with the live per-account catalog published as
|
|
9
|
-
* `devin/*` models.
|
|
10
|
-
*
|
|
11
|
-
* The provider inventory re-publishes automatically whenever a credential is
|
|
12
|
-
* connected, switched, or removed.
|
|
13
|
-
*/
|
|
14
|
-
import { Plugin } from "@opencode/plugin";
|
|
15
|
-
export { createDevinProvider } from "./provider.ts";
|
|
16
|
-
declare const _default: Plugin.Plugin;
|
|
17
|
-
export default _default;
|
package/dist/index.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OpenCode v2 plugin: Devin / Cognition.
|
|
3
|
-
*
|
|
4
|
-
* - Integration `devin` with the Devin CLI login flow (PKCE, same as chisel)
|
|
5
|
-
* so `/connect` stores the credential natively: automated browser flow and
|
|
6
|
-
* a paste-code fallback for headless machines.
|
|
7
|
-
* - Provider `devin` streaming chat through Cognition's Cascade protocol
|
|
8
|
-
* (src/protocol/), with the live per-account catalog published as
|
|
9
|
-
* `devin/*` models.
|
|
10
|
-
*
|
|
11
|
-
* The provider inventory re-publishes automatically whenever a credential is
|
|
12
|
-
* connected, switched, or removed.
|
|
13
|
-
*/
|
|
14
|
-
import { Plugin, Provider } from "@opencode/plugin";
|
|
15
|
-
import { DEFAULT_API_SERVER, LLM_ENV_VAR, PROVIDER_ID } from "./constants.js";
|
|
16
|
-
import { resolveCredentials, toStoredCredential } from "./credentials.js";
|
|
17
|
-
import { openBrowser } from "devin-core";
|
|
18
|
-
import { loginAuto, loginManual } from "devin-core";
|
|
19
|
-
import { fetchModels } from "./catalog.js";
|
|
20
|
-
export { createDevinProvider } from "./provider.js";
|
|
21
|
-
/**
|
|
22
|
-
* Plugin options accepted under the object form of a `plugins` entry:
|
|
23
|
-
*
|
|
24
|
-
* ```jsonc
|
|
25
|
-
* { "plugins": [{ "package": "opencode-devin", "options": { "mode": "uncensored" } }] }
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* They are forwarded verbatim into the published provider settings, where the
|
|
29
|
-
* provider package reads them (see `DevinProviderSettings`). A manual
|
|
30
|
-
* `provider.devin.options` entry in the user config still wins — opencode
|
|
31
|
-
* merges user settings over the published ones — but the plugin-options form
|
|
32
|
-
* is the documented path: it does not masquerade as a provider declaration.
|
|
33
|
-
*/
|
|
34
|
-
const PLUGIN_OPTION_KEYS = [
|
|
35
|
-
"mode",
|
|
36
|
-
"guardChars",
|
|
37
|
-
"guardFull",
|
|
38
|
-
"maxRetries",
|
|
39
|
-
"retryTemps",
|
|
40
|
-
"overrideFile",
|
|
41
|
-
"keepClientSystem",
|
|
42
|
-
"planPreamble",
|
|
43
|
-
"maxInputTokens",
|
|
44
|
-
"pruneKeepTurns",
|
|
45
|
-
];
|
|
46
|
-
export default Plugin.define({
|
|
47
|
-
id: PROVIDER_ID,
|
|
48
|
-
async setup(ctx) {
|
|
49
|
-
const pluginSettings = {};
|
|
50
|
-
for (const key of PLUGIN_OPTION_KEYS) {
|
|
51
|
-
const value = ctx.options?.[key];
|
|
52
|
-
if (value !== undefined)
|
|
53
|
-
pluginSettings[key] = value;
|
|
54
|
-
}
|
|
55
|
-
const publish = async () => {
|
|
56
|
-
const credentials = await resolveCredentials(ctx);
|
|
57
|
-
if (!credentials)
|
|
58
|
-
return;
|
|
59
|
-
const models = await fetchModels(credentials.apiKey, credentials.apiServerUrl);
|
|
60
|
-
await ctx.provider.transform((editor) => {
|
|
61
|
-
editor.add({
|
|
62
|
-
info: {
|
|
63
|
-
...Provider.Info.empty(Provider.ID.make(PROVIDER_ID)),
|
|
64
|
-
name: "Devin",
|
|
65
|
-
activation: "enabled",
|
|
66
|
-
// `aisdk:` routes through opencode's dynamic AI-SDK provider
|
|
67
|
-
// loader. The specifier self-references this package's own
|
|
68
|
-
// location: the repo checkout during development, or the plugin's
|
|
69
|
-
// npm cache copy once installed — either way the loader imports
|
|
70
|
-
// it directly, with no registry round-trip.
|
|
71
|
-
package: `aisdk:${new URL("..", import.meta.url).href}`,
|
|
72
|
-
settings: {
|
|
73
|
-
apiKey: credentials.apiKey,
|
|
74
|
-
baseURL: credentials.apiServerUrl ?? DEFAULT_API_SERVER,
|
|
75
|
-
...pluginSettings,
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
models,
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
await ctx.integration.transform((editor) => {
|
|
83
|
-
editor.update(PROVIDER_ID, (integration) => {
|
|
84
|
-
integration.name = "Devin";
|
|
85
|
-
});
|
|
86
|
-
editor.method.update({
|
|
87
|
-
integrationID: PROVIDER_ID,
|
|
88
|
-
method: { id: "devin", type: "oauth", label: "Log in with Devin (browser)" },
|
|
89
|
-
authorize: async () => {
|
|
90
|
-
const flow = await loginAuto();
|
|
91
|
-
openBrowser(flow.url);
|
|
92
|
-
return {
|
|
93
|
-
url: flow.url,
|
|
94
|
-
instructions: `Log in to Devin in the opened browser tab. If it did not open, go to: ${flow.url}`,
|
|
95
|
-
mode: "auto",
|
|
96
|
-
callback: flow.finish().then(toStoredCredential),
|
|
97
|
-
};
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
editor.method.update({
|
|
101
|
-
integrationID: PROVIDER_ID,
|
|
102
|
-
method: { id: "code", type: "oauth", label: "Paste code (headless)" },
|
|
103
|
-
authorize: async () => {
|
|
104
|
-
const flow = await loginManual();
|
|
105
|
-
return {
|
|
106
|
-
url: flow.url,
|
|
107
|
-
instructions: "Open the URL, sign in to Devin, and copy the code shown on the page, then paste it here.",
|
|
108
|
-
mode: "code",
|
|
109
|
-
callback: async (code) => toStoredCredential(await flow.finish(code)),
|
|
110
|
-
};
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
editor.method.update({
|
|
114
|
-
integrationID: PROVIDER_ID,
|
|
115
|
-
method: { type: "env", names: [LLM_ENV_VAR] },
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
await publish().catch((error) => {
|
|
119
|
-
console.error("[opencode-devin] initial load failed:", error);
|
|
120
|
-
});
|
|
121
|
-
const controller = new AbortController();
|
|
122
|
-
void (async () => {
|
|
123
|
-
for await (const event of ctx.event.subscribe({ signal: controller.signal })) {
|
|
124
|
-
if (event.type === "credential.updated" || event.type === "credential.switched") {
|
|
125
|
-
// Not swallowed: a re-publish that fails leaves `/models` stale or
|
|
126
|
-
// empty, and that is otherwise indistinguishable from "no models".
|
|
127
|
-
await publish().catch((error) => {
|
|
128
|
-
console.error(`[opencode-devin] republish after ${event.type} failed:`, error);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
})();
|
|
133
|
-
return () => controller.abort();
|
|
134
|
-
},
|
|
135
|
-
});
|
package/dist/protocol/model.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AI SDK `LanguageModelV3` facade over the Cascade chat stream.
|
|
3
|
-
*
|
|
4
|
-
* Models are discovered dynamically from the per-account catalog
|
|
5
|
-
* (GetCascadeModelConfigs). Auth: the long-lived session token
|
|
6
|
-
* (`devin-session-token$<JWT>`) as `apiKey`; a short-lived `user_jwt` is
|
|
7
|
-
* minted automatically per session.
|
|
8
|
-
*
|
|
9
|
-
* Originally ported from ai-sdk-devin / pi-devin-auth (MIT).
|
|
10
|
-
*/
|
|
11
|
-
import type { LanguageModelV3, LanguageModelV3Prompt, LanguageModelV3StreamPart, LanguageModelV3Usage, SharedV3Warning } from "@ai-sdk/provider";
|
|
12
|
-
import { type ChatEvent, type ChatHistoryItem } from "devin-core";
|
|
13
|
-
import { type ModelCatalogEntry } from "devin-core";
|
|
14
|
-
/**
|
|
15
|
-
* Resolve the model UID to send upstream.
|
|
16
|
-
*
|
|
17
|
-
* A model is published once per family, under its UID without the effort, and
|
|
18
|
-
* the effort arrives as `providerOptions.devin.reasoningEffort` from the
|
|
19
|
-
* variant the user picked. Upstream has no effort parameter: each effort is a
|
|
20
|
-
* separate UID, so the choice is made here.
|
|
21
|
-
*
|
|
22
|
-
* Exported for tests: this is what the catalog lookup exists for, so it needs
|
|
23
|
-
* to stay covered independently of the network.
|
|
24
|
-
*/
|
|
25
|
-
export declare function resolveEffortUid(modelId: string, catalog: readonly ModelCatalogEntry[] | undefined, requestedEffort: unknown): string;
|
|
26
|
-
/** Exported for tests. */
|
|
27
|
-
export declare function convertPrompt(prompt: LanguageModelV3Prompt): {
|
|
28
|
-
messages: ChatHistoryItem[];
|
|
29
|
-
warnings: SharedV3Warning[];
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Exported for tests: the Cascade event -> AI SDK stream translation is pure,
|
|
33
|
-
* and interleaved parallel tool calls are the case most likely to regress.
|
|
34
|
-
*/
|
|
35
|
-
export declare function convertStreamEvents(events: AsyncGenerator<ChatEvent>, generateId: () => string, warnings?: SharedV3Warning[]): AsyncGenerator<LanguageModelV3StreamPart>;
|
|
36
|
-
interface CollectedResult {
|
|
37
|
-
text: string;
|
|
38
|
-
reasoning: string;
|
|
39
|
-
toolCalls: {
|
|
40
|
-
id: string;
|
|
41
|
-
name: string;
|
|
42
|
-
args: string;
|
|
43
|
-
}[];
|
|
44
|
-
finishReason: string;
|
|
45
|
-
usage?: LanguageModelV3Usage;
|
|
46
|
-
}
|
|
47
|
-
/** Exported for tests; mirrors `convertStreamEvents` for the non-streaming path. */
|
|
48
|
-
export declare function collectEvents(events: AsyncGenerator<ChatEvent>): Promise<CollectedResult>;
|
|
49
|
-
export interface DevinProviderOptions {
|
|
50
|
-
apiKey: string;
|
|
51
|
-
baseURL?: string;
|
|
52
|
-
/** Pipeline mode — see DevinProviderSettings in ../provider.ts. */
|
|
53
|
-
mode?: "normal" | "uncensored";
|
|
54
|
-
guardChars?: number;
|
|
55
|
-
guardFull?: boolean;
|
|
56
|
-
maxRetries?: number;
|
|
57
|
-
retryTemps?: string;
|
|
58
|
-
overrideFile?: string;
|
|
59
|
-
keepClientSystem?: boolean;
|
|
60
|
-
planPreamble?: boolean;
|
|
61
|
-
maxInputTokens?: number;
|
|
62
|
-
pruneKeepTurns?: number;
|
|
63
|
-
}
|
|
64
|
-
export interface DevinProvider {
|
|
65
|
-
languageModel(modelId: string): LanguageModelV3;
|
|
66
|
-
}
|
|
67
|
-
export declare function createDevin(options: DevinProviderOptions): DevinProvider;
|
|
68
|
-
export {};
|