@botiverse/oar 0.105.0 → 0.106.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.
Files changed (54) hide show
  1. package/README.md +20 -12
  2. package/assets/brands/NOTICE.md +5 -5
  3. package/assets/brands/devin.svg +1 -0
  4. package/dist/brands.d.ts +4 -0
  5. package/dist/brands.d.ts.map +1 -1
  6. package/dist/brands.js +4 -0
  7. package/dist/brands.js.map +1 -1
  8. package/dist/index.d.ts +4 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +6 -0
  11. package/dist/index.js.map +1 -1
  12. package/dist/runtimes/devin/auth.d.ts +11 -0
  13. package/dist/runtimes/devin/auth.d.ts.map +1 -0
  14. package/dist/runtimes/devin/auth.js +126 -0
  15. package/dist/runtimes/devin/auth.js.map +1 -0
  16. package/dist/runtimes/devin/index.d.ts +26 -0
  17. package/dist/runtimes/devin/index.d.ts.map +1 -0
  18. package/dist/runtimes/devin/index.js +33 -0
  19. package/dist/runtimes/devin/index.js.map +1 -0
  20. package/dist/runtimes/devin/install.d.ts +10 -0
  21. package/dist/runtimes/devin/install.d.ts.map +1 -0
  22. package/dist/runtimes/devin/install.js +69 -0
  23. package/dist/runtimes/devin/install.js.map +1 -0
  24. package/dist/runtimes/devin/installation.d.ts +6 -0
  25. package/dist/runtimes/devin/installation.d.ts.map +1 -0
  26. package/dist/runtimes/devin/installation.js +19 -0
  27. package/dist/runtimes/devin/installation.js.map +1 -0
  28. package/dist/runtimes/devin/list-models.d.ts +5 -0
  29. package/dist/runtimes/devin/list-models.d.ts.map +1 -0
  30. package/dist/runtimes/devin/list-models.js +132 -0
  31. package/dist/runtimes/devin/list-models.js.map +1 -0
  32. package/dist/runtimes/devin/options.d.ts +3 -0
  33. package/dist/runtimes/devin/options.d.ts.map +1 -0
  34. package/dist/runtimes/devin/options.js +14 -0
  35. package/dist/runtimes/devin/options.js.map +1 -0
  36. package/dist/runtimes/devin/session.d.ts +14 -0
  37. package/dist/runtimes/devin/session.d.ts.map +1 -0
  38. package/dist/runtimes/devin/session.js +52 -0
  39. package/dist/runtimes/devin/session.js.map +1 -0
  40. package/dist/runtimes/devin/update.d.ts +12 -0
  41. package/dist/runtimes/devin/update.d.ts.map +1 -0
  42. package/dist/runtimes/devin/update.js +59 -0
  43. package/dist/runtimes/devin/update.js.map +1 -0
  44. package/dist/shared/acp/failure.d.ts +6 -3
  45. package/dist/shared/acp/failure.d.ts.map +1 -1
  46. package/dist/shared/acp/failure.js +9 -5
  47. package/dist/shared/acp/failure.js.map +1 -1
  48. package/dist/shared/acp/profile.d.ts +6 -8
  49. package/dist/shared/acp/profile.d.ts.map +1 -1
  50. package/dist/shared/acp/profile.js +4 -4
  51. package/dist/shared/acp/profile.js.map +1 -1
  52. package/dist/shared/acp/shared-session.js +1 -1
  53. package/dist/shared/acp/shared-session.js.map +1 -1
  54. package/package.json +1 -1
@@ -0,0 +1,69 @@
1
+ import { lstatSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import path from "node:path";
4
+ import { environmentHome } from "../../shared/environment-home.js";
5
+ import { environmentValue } from "../../shared/environment.js";
6
+ import { defaultInstallHost, installDir, planInstaller, scriptInstallPlan, } from "../../shared/install.js";
7
+ import { devinInstallation, devinInstalledExecutableCandidates } from "./installation.js";
8
+ /** The official Devin CLI installer places the binary in XDG_DATA_HOME/devin and links ~/.local/bin/devin. */
9
+ export const devinInstallMethod = {
10
+ source: "https://docs.devin.ai/cli",
11
+ line: "curl -fsSL https://cli.devin.ai/install.sh | bash",
12
+ tools: ["curl", "bash"],
13
+ writes: () => {
14
+ const home = homedir();
15
+ const dataHome = installDir(process.env.XDG_DATA_HOME, path.join(home, ".local", "share"));
16
+ return [path.join(home, ".local", "bin"), path.join(dataHome, "devin"), path.join(dataHome, "man", "man1")];
17
+ },
18
+ windows: "Cognition documents, in PowerShell: irm https://static.devin.ai/cli/setup.ps1 | iex",
19
+ };
20
+ /** Create a Devin CLI install planner for a specific host, preserving base unsupported plans before local checks. */
21
+ export function createDevinInstallPlan(host = defaultInstallHost) {
22
+ const nativePlan = scriptInstallPlan(devinInstallMethod, host);
23
+ return async (options) => {
24
+ const planned = await nativePlan(options);
25
+ if (options?.line !== undefined || planned.kind !== "plan") {
26
+ return planned;
27
+ }
28
+ const pinned = environmentValue(process.env, "OAR_DEVIN_BIN", host.platform);
29
+ const official = devinInstalledExecutableCandidates(host.platform, environmentHome(process.env), process.env)[0];
30
+ if (host.platform !== "win32" && (pinned === undefined || pinned === "") && official !== undefined) {
31
+ try {
32
+ const stat = lstatSync(official);
33
+ if (!stat.isSymbolicLink() && stat.isFile()) {
34
+ return {
35
+ kind: "unsupported",
36
+ reason: "configuration",
37
+ detail: `${official} exists and is not a symlink; the official Devin installer refuses to overwrite regular files.`,
38
+ };
39
+ }
40
+ }
41
+ catch {
42
+ // Destination does not exist yet; continue with installation probing.
43
+ }
44
+ }
45
+ const existing = await devinInstallation();
46
+ const destination = existing.kind === "unsupported" && (pinned === undefined || pinned === "") && official !== undefined
47
+ ? await devinInstallation({ env: { OAR_DEVIN_BIN: official } })
48
+ : existing;
49
+ if (existing.kind === "unsupported" && ((pinned !== undefined && pinned !== "") || destination.kind === "unsupported")) {
50
+ return {
51
+ kind: "unsupported",
52
+ reason: "configuration",
53
+ detail: `${existing.reason}. The installer does not upgrade this existing selection; update it or change the override before installing.`,
54
+ };
55
+ }
56
+ if (existing.kind === "not_found" && pinned !== undefined && pinned !== "") {
57
+ return {
58
+ kind: "unsupported",
59
+ reason: "configuration",
60
+ detail: `OAR_DEVIN_BIN selects ${pinned}, which was not found. The installer cannot change this override; correct or unset it before installing.`,
61
+ };
62
+ }
63
+ return planned;
64
+ };
65
+ }
66
+ /** Plan a standalone Devin CLI installation, refusing unsupported overrides and non-symlink regular files. */
67
+ export const devinInstallPlan = createDevinInstallPlan();
68
+ export const devinInstall = planInstaller(devinInstallation, devinInstallPlan);
69
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1 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,EAAE,GAAG,EAAE,EAAE,aAAa,EAAE,QAAQ,EAAE,EAAE,CAAC;YAC/D,CAAC,CAAC,QAAQ,CAAC;QACb,IAAI,QAAQ,CAAC,IAAI,KAAK,aAAa,IAAI,CAAC,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,EAAE,CAAC,IAAI,WAAW,CAAC,IAAI,KAAK,aAAa,CAAC,EAAE,CAAC;YACvH,OAAO;gBACL,IAAI,EAAE,aAAa;gBACnB,MAAM,EAAE,eAAe;gBACvB,MAAM,EAAE,GAAG,QAAQ,CAAC,MAAM,+GAA+G;aAC1I,CAAC;QACJ,CAAC;QACD,IAAI,QAAQ,CAAC,IAAI,KAAK,WAAW,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,EAAE,EAAE,CAAC;YAC3E,OAAO;gBACL,IAAI,EAAE,aAAa;gBACnB,MAAM,EAAE,eAAe;gBACvB,MAAM,EAAE,yBAAyB,MAAM,0GAA0G;aAClJ,CAAC;QACJ,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC;AAED,8GAA8G;AAC9G,MAAM,CAAC,MAAM,gBAAgB,GAAmB,sBAAsB,EAAE,CAAC;AAEzE,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /** `devin --version` prints `devin <semver>` optionally followed by a short commit hash in parentheses. */
2
+ export declare function readDevinVersion(stdout: string): string | undefined;
3
+ /** Official installer locations, including GUI hosts whose PATH omits them. */
4
+ export declare function devinInstalledExecutableCandidates(platform: NodeJS.Platform, home: string, env: Readonly<NodeJS.ProcessEnv>): readonly string[];
5
+ export declare const devinInstallation: import("../../browser.js").InstallationProbe;
6
+ //# sourceMappingURL=installation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installation.d.ts","sources":["../../../src/runtimes/devin/installation.ts"],"names":[],"mappings":"AAKA,2GAA2G;AAC3G,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEnE;AAED,+EAA+E;AAC/E,wBAAgB,kCAAkC,CAChD,QAAQ,EAAE,MAAM,CAAC,QAAQ,EACzB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,GAC/B,SAAS,MAAM,EAAE,CAOnB;AAED,eAAO,MAAM,iBAAiB,8CAM7B,CAAC"}
@@ -0,0 +1,19 @@
1
+ import path from "node:path";
2
+ import { environmentValue } from "../../shared/environment.js";
3
+ import { environmentHome } from "../../shared/environment-home.js";
4
+ import { executableInstallation } from "../../shared/installation.js";
5
+ /** `devin --version` prints `devin <semver>` optionally followed by a short commit hash in parentheses. */
6
+ export function readDevinVersion(stdout) {
7
+ return /^devin\s+(\d+\.\d+\.\d+(?:-[A-Za-z\d.-]+)?)(?:\s+\([0-9a-f]+\))?$/u.exec(stdout.trim())?.[1];
8
+ }
9
+ /** Official installer locations, including GUI hosts whose PATH omits them. */
10
+ export function devinInstalledExecutableCandidates(platform, home, env) {
11
+ if (platform === "win32") {
12
+ const configured = environmentValue(env, "LOCALAPPDATA", platform);
13
+ const local = configured === undefined || configured.length === 0 ? path.win32.join(home, "AppData", "Local") : configured;
14
+ return [path.win32.join(local, "devin", "cli", "bin", "devin.exe")];
15
+ }
16
+ return [path.posix.join(home, ".local", "bin", "devin")];
17
+ }
18
+ export const devinInstallation = executableInstallation("OAR_DEVIN_BIN", "devin", (env) => devinInstalledExecutableCandidates(process.platform, environmentHome(env), env), ["acp", "--help"], { versionTimeoutMs: 30_000, readVersion: readDevinVersion });
19
+ //# sourceMappingURL=installation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installation.js","sources":["../../../src/runtimes/devin/installation.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6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,EAAE,CAC5D,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { ModelEntry, ModelLister } from "../../contracts/list-models.js";
2
+ /** Project a `session/new` response's `model` and `thought_level` config options into model catalog entries. */
3
+ export declare function projectDevinModels(response: unknown): ModelEntry[] | undefined;
4
+ export declare const devinListModels: ModelLister;
5
+ //# sourceMappingURL=list-models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-models.d.ts","sources":["../../../src/runtimes/devin/list-models.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAsB9E,gHAAgH;AAChH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,UAAU,EAAE,GAAG,SAAS,CA4B9E;AAkED,eAAO,MAAM,eAAe,EAAE,WAiD7B,CAAC"}
@@ -0,0 +1,132 @@
1
+ /* oxlint-disable import/max-dependencies, typescript/promise-function-async -- Model listing wires ACP session probing, shared deadlines and auth status fallback; deadline callbacks return native SDK promises. */
2
+ import { client as createClient, methods, PROTOCOL_VERSION, RequestError, } from "@agentclientprotocol/sdk";
3
+ import { acpThoughtLevelOption } from "../../shared/acp/model.js";
4
+ import { startAcpProcess, withAcpDeadline } from "../../shared/acp/process.js";
5
+ import { hasAcpCapability } from "../../shared/acp/profile.js";
6
+ import { remainingMs } from "../../shared/deadline.js";
7
+ import { sessionEnvironment } from "../../shared/environment.js";
8
+ import { withQueryDeadline } from "../../shared/executable/query.js";
9
+ import { asRecord, asRecordList } from "../../shared/json.js";
10
+ import { listingCwd } from "../../shared/listing-cwd.js";
11
+ import { readDevinAuthStatus } from "./auth.js";
12
+ import { devinAcpArgs } from "./session.js";
13
+ const LISTING = "Devin model listing";
14
+ function text(value) {
15
+ if (typeof value !== "string") {
16
+ return undefined;
17
+ }
18
+ const trimmed = value.trim();
19
+ return trimmed.length > 0 ? trimmed : undefined;
20
+ }
21
+ /** Project a `session/new` response's `model` and `thought_level` config options into model catalog entries. */
22
+ export function projectDevinModels(response) {
23
+ const root = asRecord(response);
24
+ const modelOption = asRecordList(root?.configOptions).find((option) => option.id === "model");
25
+ if (modelOption === undefined) {
26
+ return undefined;
27
+ }
28
+ const current = text(modelOption.currentValue);
29
+ const thinking = acpThoughtLevelOption(root);
30
+ const effortLevels = asRecordList(thinking?.options)
31
+ .map((option) => text(option.value))
32
+ .filter((value) => value !== undefined);
33
+ const defaultEffort = text(thinking?.currentValue);
34
+ const entries = [];
35
+ for (const model of asRecordList(modelOption.options)) {
36
+ const id = text(model.value);
37
+ if (id === undefined) {
38
+ continue;
39
+ }
40
+ const displayName = text(model.name);
41
+ entries.push({
42
+ id,
43
+ ...(displayName === undefined || displayName === id ? {} : { displayName }),
44
+ ...(id === current ? { default: true } : {}),
45
+ ...(id === current && effortLevels.length > 0 ? { effortLevels } : {}),
46
+ ...(id === current && defaultEffort !== undefined ? { defaultEffort } : {}),
47
+ });
48
+ }
49
+ return entries;
50
+ }
51
+ async function readNewSession(command, cwd, deadline, signal, env) {
52
+ const runtime = startAcpProcess(command, devinAcpArgs(), createClient({ name: "oar" }), { cwd, env });
53
+ const stop = () => { runtime.kill(); };
54
+ signal.addEventListener("abort", stop, { once: true });
55
+ if (signal.aborted) {
56
+ stop();
57
+ }
58
+ try {
59
+ const initialize = methods.agent.initialize;
60
+ const initialized = asRecord(await withAcpDeadline(runtime, initialize, remainingMs(deadline, LISTING), (requestOptions) => runtime.connection.agent.request(initialize, {
61
+ protocolVersion: PROTOCOL_VERSION,
62
+ clientCapabilities: {
63
+ fs: { readTextFile: false, writeTextFile: false },
64
+ terminal: false,
65
+ },
66
+ clientInfo: { name: "oar", version: "0.0.0" },
67
+ }, requestOptions)));
68
+ signal.throwIfAborted();
69
+ const newSession = methods.agent.session.new;
70
+ const response = await withAcpDeadline(runtime, newSession, remainingMs(deadline, LISTING), (requestOptions) => runtime.connection.agent.request(newSession, { cwd, mcpServers: [] }, requestOptions));
71
+ signal.throwIfAborted();
72
+ const capabilities = asRecord(asRecord(initialized?.agentCapabilities)?.sessionCapabilities);
73
+ const cleanupMethod = hasAcpCapability(capabilities?.delete)
74
+ ? methods.agent.session.delete
75
+ : (hasAcpCapability(capabilities?.close) ? methods.agent.session.close : undefined);
76
+ const cleanupMs = Math.min(2000, Math.max(0, deadline - Date.now()));
77
+ if (typeof response.sessionId === "string" && cleanupMethod !== undefined && cleanupMs > 0) {
78
+ await withAcpDeadline(runtime, cleanupMethod, cleanupMs, (requestOptions) => runtime.connection.agent.request(cleanupMethod, { sessionId: response.sessionId }, requestOptions)).catch(() => { });
79
+ }
80
+ return asRecord(response) ?? {};
81
+ }
82
+ finally {
83
+ signal.removeEventListener("abort", stop);
84
+ runtime.kill();
85
+ if (!signal.aborted) {
86
+ await runtime.exited;
87
+ }
88
+ }
89
+ }
90
+ export const devinListModels = async (installation, options = {}) => {
91
+ if (installation.via !== "executable") {
92
+ return { kind: "unsupported", reason: "devin model listing requires the devin CLI executable" };
93
+ }
94
+ try {
95
+ const timeoutMs = options.timeoutMs ?? 30_000;
96
+ const deadline = Date.now() + timeoutMs;
97
+ return await withQueryDeadline(LISTING, timeoutMs, async (signal) => {
98
+ const response = await readNewSession(installation.command, listingCwd(options), deadline, signal, sessionEnvironment(options.env));
99
+ const models = projectDevinModels(response);
100
+ if (models === undefined) {
101
+ return { kind: "unsupported", reason: "this devin CLI build returns no model config option on session/new" };
102
+ }
103
+ if (models.length === 0) {
104
+ const status = await readDevinAuthStatus(installation, {
105
+ ...(options.env === undefined ? {} : { env: options.env }),
106
+ timeoutMs: remainingMs(deadline, LISTING),
107
+ signal,
108
+ });
109
+ if (status.kind === "logged_out") {
110
+ return { kind: "unauthenticated", detail: status.detail ?? "Not logged in. Run `devin auth login` to authenticate." };
111
+ }
112
+ if (status.kind === "unknown") {
113
+ if (status.configured !== undefined) {
114
+ return {
115
+ kind: "unsupported",
116
+ reason: status.detail ?? "Devin returned an empty model catalog while authentication status is unknown",
117
+ };
118
+ }
119
+ throw new Error(status.detail ?? "Failed to verify Devin authentication for empty model catalog");
120
+ }
121
+ }
122
+ return { kind: "ok", models };
123
+ });
124
+ }
125
+ catch (error) {
126
+ if (error instanceof RequestError && (error.code === -32_000 || /auth(?:entication)?|not logged in|invalid api key/iu.test(error.message))) {
127
+ return { kind: "unauthenticated", detail: error.message };
128
+ }
129
+ throw new Error(error instanceof Error ? `Failed to list Devin models: ${error.message}` : "Failed to list Devin models", { cause: error });
130
+ }
131
+ };
132
+ //# sourceMappingURL=list-models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-models.js","sources":["../../../src/runtimes/devin/list-models.ts"],"names":[],"mappings":"AAAA,qNAAqN;AACrN,OAAO,EACL,MAAM,IAAI,YAAY,EACtB,OAAO,EACP,gBAAgB,EAChB,YAAY,GACb,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAmB,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,OAAO,GAAG,qBAAqB,CAAC;AAEtC,SAAS,IAAI,CAAC,KAAc;IAC1B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM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IAAI,+DAA+D,CAAC,CAAC;gBACpG,CAAC;YACH,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,YAAY,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,qDAAqD,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;YAC3I,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;QAC5D,CAAC;QACD,MAAM,IAAI,KAAK,CACb,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,gCAAgC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,6BAA6B,EACxG,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { RefusedSessionOptions } from "../../contracts/runtime.js";
2
+ export declare const devinRefusedSessionOptions: RefusedSessionOptions;
3
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sources":["../../../src/runtimes/devin/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAIxE,eAAO,MAAM,0BAA0B,EAAE,qBAWxC,CAAC"}
@@ -0,0 +1,14 @@
1
+ /* Declared refusals, apart from the session code so the runtime entry loads no ACP SDK until a session opens. */
2
+ export const devinRefusedSessionOptions = {
3
+ additionalDirectories: "Devin ACP advertises sessionCapabilities.additionalDirectories, and OAR has not verified that primary cwd and tool scope honor it",
4
+ appendSystemPrompt: "Devin ACP exposes no verified system prompt append channel",
5
+ disallowedTools: "Devin ACP exposes no verified tool-denial channel",
6
+ endTurnProcessesOnAbort: "OAR has not verified reading and ending one aborted Devin turn's processes while its session stays usable",
7
+ goals: "This runtime interface exposes no structured native goal controls",
8
+ name: "Devin exposes no verified session name setting",
9
+ outputSchema: "Devin ACP and launch configuration expose no final-output schema channel",
10
+ serviceTier: "Devin exposes no verified per-session service-tier setting and readback",
11
+ systemPrompt: "Devin ACP exposes no verified system prompt replacement channel",
12
+ userConfiguration: "Devin has no verified separation of user configuration from its native login",
13
+ };
14
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sources":["../../../src/runtimes/devin/options.ts"],"names":[],"mappings":"AAEA,iHAAiH;AAEjH,MAAM,CAAC,MAAM,0BAA0B,GAA0B;IAC/D,qBAAqB,EAAE,mIAAmI;IAC1J,kBAAkB,EAAE,4DAA4D;IAChF,eAAe,EAAE,mDAAmD;IACpE,uBAAuB,EAAE,2GAA2G;IACpI,KAAK,EAAE,mEAAmE;IAC1E,IAAI,EAAE,gDAAgD;IACtD,YAAY,EAAE,0EAA0E;IACxF,WAAW,EAAE,yEAAyE;IACtF,YAAY,EAAE,iEAAiE;IAC/E,iBAAiB,EAAE,8EAA8E;CAClG,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { type AcpFailureReader, type AcpOpenFailureReader } from "../../shared/acp/failure.js";
2
+ import { type AcpSessionProfile } from "../../shared/acp/session.js";
3
+ import { type JsonRecord } from "../../shared/json.js";
4
+ /** Map Devin JSON-RPC sign-in failures during open or model selection to `RuntimeFailureError("auth")`. */
5
+ export declare const devinOpenFailure: AcpOpenFailureReader;
6
+ /** Map Devin JSON-RPC sign-in failures on `session/prompt` to `failure: "auth"`. */
7
+ export declare const devinFailureOutcome: AcpFailureReader;
8
+ /** Native Devin CLI ACP launch arguments. */
9
+ export declare const devinAcpArgs: () => readonly string[];
10
+ /** Whether the session handshake advertises the `bypass` permission mode. */
11
+ export declare function supportsDevinBypass(response: JsonRecord): boolean;
12
+ export declare const devinAcpProfile: AcpSessionProfile;
13
+ export declare const devinSession: import("../../browser.js").StartSession;
14
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sources":["../../../src/runtimes/devin/session.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,KAAK,gBAAgB,EAAE,KAAK,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAC7H,OAAO,EAAc,KAAK,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACjF,OAAO,EAAY,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAUjE,2GAA2G;AAC3G,eAAO,MAAM,gBAAgB,EAAE,oBAGrB,CAAC;AAEX,oFAAoF;AACpF,eAAO,MAAM,mBAAmB,EAAE,gBAGxB,CAAC;AAEX,6CAA6C;AAC7C,eAAO,MAAM,YAAY,QAAO,SAAS,MAAM,EAAa,CAAC;AAE7D,6EAA6E;AAC7E,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,UAAU,GAAG,OAAO,CAUjE;AAED,eAAO,MAAM,eAAe,EAAE,iBAkB7B,CAAC;AAEF,eAAO,MAAM,YAAY,yCAA8B,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { RuntimeFailureError } from "../../contracts/runtime-failure-error.js";
2
+ import { acpErrorReason, rpcErrorCode } from "../../shared/acp/failure.js";
3
+ import { acpSession } from "../../shared/acp/session.js";
4
+ import { asRecord } from "../../shared/json.js";
5
+ import { refuseSessionOptions } from "../../shared/session-options.js";
6
+ import { devinRefusedSessionOptions } from "./options.js";
7
+ const DEVIN_AUTH_ERROR = /authentication required|invalid api key|not logged in/iu;
8
+ function isDevinAuthRpcError(error) {
9
+ return error instanceof Error && rpcErrorCode(error) !== null && DEVIN_AUTH_ERROR.test(error.message);
10
+ }
11
+ /** Map Devin JSON-RPC sign-in failures during open or model selection to `RuntimeFailureError("auth")`. */
12
+ export const devinOpenFailure = (error) => isDevinAuthRpcError(error)
13
+ ? new RuntimeFailureError("auth", error.message, { cause: error.cause ?? error })
14
+ : null;
15
+ /** Map Devin JSON-RPC sign-in failures on `session/prompt` to `failure: "auth"`. */
16
+ export const devinFailureOutcome = (error) => isDevinAuthRpcError(error)
17
+ ? { kind: "failed", reason: acpErrorReason(error), failure: "auth" }
18
+ : null;
19
+ /** Native Devin CLI ACP launch arguments. */
20
+ export const devinAcpArgs = () => ["acp"];
21
+ /** Whether the session handshake advertises the `bypass` permission mode. */
22
+ export function supportsDevinBypass(response) {
23
+ const modes = asRecord(response.modes);
24
+ const availableModes = Array.isArray(modes?.availableModes) ? modes.availableModes : [];
25
+ if (availableModes.map((mode) => asRecord(mode)).some((mode) => mode?.id === "bypass")) {
26
+ return true;
27
+ }
28
+ const options = Array.isArray(response.configOptions) ? response.configOptions : [];
29
+ const mode = options.map((option) => asRecord(option)).find((option) => option?.id === "mode");
30
+ const values = Array.isArray(mode?.options) ? mode.options : [];
31
+ return values.map((value) => asRecord(value)).some((option) => option?.value === "bypass");
32
+ }
33
+ export const devinAcpProfile = {
34
+ args: () => devinAcpArgs(),
35
+ resumeKeepsSessionCwd: true,
36
+ isResumeNotFound: (native) => native.code === -32_016 && asRecord(native.data)?.["cognition.ai/errorKind"] === "session_not_found",
37
+ capabilities: { queue: { durable: false }, attribution: "opaque" },
38
+ requestTimeoutMs: 30_000,
39
+ validateOptions: (options) => {
40
+ refuseSessionOptions(devinRefusedSessionOptions, options);
41
+ },
42
+ modelViaConfigOption: true,
43
+ openFailure: devinOpenFailure,
44
+ failureOutcome: devinFailureOutcome,
45
+ configureSession: async ({ request, sessionId, response }) => {
46
+ if (supportsDevinBypass(response)) {
47
+ await request("session/set_mode", { sessionId, modeId: "bypass" });
48
+ }
49
+ },
50
+ };
51
+ export const devinSession = acpSession(devinAcpProfile);
52
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sources":["../../../src/runtimes/devin/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAA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I,KAAK,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,wBAAwB,CAAC,KAAK,mBAAmB;IACtG,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE;IAClE,gBAAgB,EAAE,MAAM;IACxB,eAAe,EAAE,CAAC,OAAO,EAAE,EAAE;QAC3B,oBAAoB,CAAC,0BAA0B,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;IACD,oBAAoB,EAAE,IAAI;IAC1B,WAAW,EAAE,gBAAgB;IAC7B,cAAc,EAAE,mBAAmB;IACnC,gBAAgB,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC3D,IAAI,mBAAmB,CAAC,QAAQ,CAAC,EAAE,CAAC;YAClC,MAAM,OAAO,CAAC,kBAAkB,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { UpdateChecker } from "../../contracts/update.js";
2
+ /** Release manifest URL for a standalone Devin CLI `distribution` marker. */
3
+ export declare function devinReleaseSource(distribution: string | undefined): string | undefined;
4
+ /** Read the standalone installer's `distribution` marker next to the resolved binary's parent directory. */
5
+ export declare function readDevinDistribution(command: string): string | undefined;
6
+ /** Check for Devin CLI updates using the standalone installer's release manifest. */
7
+ export declare function devinUpdateCheck(options?: {
8
+ readonly manifestUrl?: string;
9
+ readonly readDistribution?: (command: string) => string | undefined;
10
+ }): UpdateChecker;
11
+ export declare const devinCheckUpdate: UpdateChecker;
12
+ //# sourceMappingURL=update.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.d.ts","sources":["../../../src/runtimes/devin/update.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAmC,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAahG,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAKvF;AAED,4GAA4G;AAC5G,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQzE;AAED,qFAAqF;AACrF,wBAAgB,gBAAgB,CAC9B,OAAO,GAAE;IAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAA;CAAO,GACnH,aAAa,CAyBf;AAED,eAAO,MAAM,gBAAgB,eAAqB,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { readFileSync, realpathSync } from "node:fs";
2
+ import path from "node:path";
3
+ import { asRecord, parseJson } from "../../shared/json.js";
4
+ import { CHECK_TIMEOUT_MS, comparedCheck, executableUpdate, readReleaseSource, versionAtLeast } from "../../shared/update.js";
5
+ const RELEASE_SOURCES = {
6
+ "curl-bash": "https://static.devin.ai/cli/current/manifest.json",
7
+ "irm-iex": "https://static.devin.ai/cli/current/manifest.json",
8
+ "curl-bash-enterprise": "https://static.devinenterprise.com/cli/current/manifest-enterprise.json",
9
+ "irm-iex-enterprise": "https://static.devinenterprise.com/cli/current/manifest-enterprise.json",
10
+ "curl-bash-windsurfcom": "https://static.devin.ai/cli/current/manifest-windsurfcom.json",
11
+ "irm-iex-windsurfcom": "https://static.devin.ai/cli/current/manifest-windsurfcom.json",
12
+ };
13
+ /** Release manifest URL for a standalone Devin CLI `distribution` marker. */
14
+ export function devinReleaseSource(distribution) {
15
+ if (distribution === undefined) {
16
+ return undefined;
17
+ }
18
+ return Object.hasOwn(RELEASE_SOURCES, distribution) ? RELEASE_SOURCES[distribution] : undefined;
19
+ }
20
+ /** Read the standalone installer's `distribution` marker next to the resolved binary's parent directory. */
21
+ export function readDevinDistribution(command) {
22
+ try {
23
+ const real = realpathSync(command);
24
+ const trimmed = readFileSync(path.resolve(path.dirname(real), "..", "distribution"), "utf8").trim();
25
+ return trimmed.length > 0 ? trimmed : undefined;
26
+ }
27
+ catch {
28
+ return undefined;
29
+ }
30
+ }
31
+ /** Check for Devin CLI updates using the standalone installer's release manifest. */
32
+ export function devinUpdateCheck(options = {}) {
33
+ const readDistribution = options.readDistribution ?? readDevinDistribution;
34
+ return async (installation, checkOptions = {}) => {
35
+ const update = executableUpdate(installation);
36
+ if (update.kind === "unavailable") {
37
+ return update.check;
38
+ }
39
+ const registry = options.manifestUrl ?? devinReleaseSource(readDistribution(update.installation.command));
40
+ if (registry === undefined) {
41
+ return {
42
+ kind: "unavailable",
43
+ reason: "unsupported_installation",
44
+ detail: "Devin CLI update checks require a standalone installer marker (distribution); Homebrew, Desktop-bundled, and portal builds update through their host channel.",
45
+ };
46
+ }
47
+ const read = await readReleaseSource(registry, checkOptions.timeoutMs ?? CHECK_TIMEOUT_MS);
48
+ if (!read.ok) {
49
+ return read.check;
50
+ }
51
+ const version = asRecord(parseJson(read.text))?.version;
52
+ const check = comparedCheck(update.installed, typeof version === "string" ? version : "", registry);
53
+ return check.kind === "ok" && check.updateAvailable
54
+ ? { ...check, updateAvailable: !versionAtLeast(check.installed, check.latest) }
55
+ : check;
56
+ };
57
+ }
58
+ export const devinCheckUpdate = devinUpdateCheck();
59
+ //# sourceMappingURL=update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.js","sources":["../../../src/runtimes/devin/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE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1
1
  import { type JsonRecord } from "../json.js";
2
+ import { RuntimeFailureError } from "../../contracts/runtime-failure-error.js";
2
3
  import type { FrameBody, TurnOutcome } from "../../contracts/session.js";
3
4
  /** The JSON-RPC error code an ACP request was answered with, if it was. */
4
5
  export declare function rpcErrorCode(error: unknown): number | null;
6
+ /** Reads a failed open or model switch the generic rules do not: vendor-specific auth or model codes. */
7
+ export type AcpOpenFailureReader = (error: unknown, step: "open" | "model") => RuntimeFailureError | null;
5
8
  /** An open step's error, as `session()` rejects with it: a refused login or model becomes a `RuntimeFailureError`. */
6
- export declare function acpOpenFailure(error: unknown, step: "open" | "model"): unknown;
9
+ export declare function acpOpenFailure(error: unknown, step: "open" | "model", reader?: AcpOpenFailureReader): unknown;
7
10
  /** A failed native resume/load call, under its runtime's missing-target rule. */
8
- export declare function acpResumeFailure(error: unknown, method: string, sessionId: string, isNotFound: (native: JsonRecord) => boolean): unknown;
11
+ export declare function acpResumeFailure(error: unknown, method: string, sessionId: string, isNotFound: (native: JsonRecord) => boolean, openFailure?: AcpOpenFailureReader): unknown;
9
12
  /** `step` rejecting as `session()` does: through `acpOpenFailure`. */
10
- export declare function acpOpenStep<T>(step: Promise<T>, kind: "open" | "model"): Promise<T>;
13
+ export declare function acpOpenStep<T>(step: Promise<T>, kind: "open" | "model", reader?: AcpOpenFailureReader): Promise<T>;
11
14
  /** Reads a failed prompt the generic rules do not: grok's codes and its retry notifications. */
12
15
  export type AcpFailureReader = (error: unknown, turnFrames: readonly FrameBody[]) => TurnOutcome | null;
13
16
  /** An RPC error's words: its message, and its `data` when that is text (grok puts the provider's answer there). */
@@ -1 +1 @@
1
- {"version":3,"file":"failure.d.ts","sources":["../../../src/shared/acp/failure.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAgBzE,2EAA2E;AAC3E,wBAAgB,YA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zG,MAAM,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,KAAK,mBAAmB,GAAG,IAAI,CAAC;AAE1G,sHAAsH;AACtH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,MAAM,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAgB7G;AAED,iFAAiF;AACjF,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,EAC3C,WAAW,CAAC,EAAE,oBAAoB,GACjC,OAAO,CAUT;AAED,sEAAsE;AACtE,wBAAsB,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,MAAM,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,CAAC,CAAC,CAMxH;AAED,gGAAgG;AAChG,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,SAAS,EAAE,KAAK,WAAW,GAAG,IAAI,CAAC;AAExG,mHAAmH;AACnH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAMrD;AAED,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,GAAE,SAAS,SAAS,EAAO,EAAE,MAAM,CAAC,EAAE,gBAAgB,GAAG,WAAW,CAS/H"}
@@ -21,7 +21,7 @@ export function rpcErrorCode(error) {
21
21
  return typeof error.code === "number" ? error.code : null;
22
22
  }
23
23
  /** An open step's error, as `session()` rejects with it: a refused login or model becomes a `RuntimeFailureError`. */
24
- export function acpOpenFailure(error, step) {
24
+ export function acpOpenFailure(error, step, reader) {
25
25
  const code = rpcErrorCode(error);
26
26
  if (!(error instanceof Error) || code === null) {
27
27
  return error;
@@ -32,12 +32,16 @@ export function acpOpenFailure(error, step) {
32
32
  if (step === "model" && code === INVALID_PARAMS) {
33
33
  return new RuntimeFailureError("model_unavailable", error.message, { cause: error.cause ?? error });
34
34
  }
35
+ const mapped = reader?.(error, step) ?? null;
36
+ if (mapped !== null) {
37
+ return mapped;
38
+ }
35
39
  return error;
36
40
  }
37
41
  /** A failed native resume/load call, under its runtime's missing-target rule. */
38
- export function acpResumeFailure(error, method, sessionId, isNotFound) {
42
+ export function acpResumeFailure(error, method, sessionId, isNotFound, openFailure) {
39
43
  // Auth refusals retain their type even if a list was empty.
40
- const failure = acpOpenFailure(error, "open");
44
+ const failure = acpOpenFailure(error, "open", openFailure);
41
45
  if (failure !== error) {
42
46
  return failure;
43
47
  }
@@ -49,12 +53,12 @@ export function acpResumeFailure(error, method, sessionId, isNotFound) {
49
53
  return error;
50
54
  }
51
55
  /** `step` rejecting as `session()` does: through `acpOpenFailure`. */
52
- export async function acpOpenStep(step, kind) {
56
+ export async function acpOpenStep(step, kind, reader) {
53
57
  try {
54
58
  return await step;
55
59
  }
56
60
  catch (error) {
57
- throw acpOpenFailure(error, kind);
61
+ throw acpOpenFailure(error, kind, reader);
58
62
  }
59
63
  }
60
64
  /** An RPC error's words: its message, and its `data` when that is text (grok puts the provider's answer there). */
@@ -1 +1 @@
1
- {"version":3,"file":"failure.js","sources":["../../../src/shared/acp/failure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,QAAQ,EAAmB,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAE/E,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;;;;;;GAOG;AAEH,MAAM,aA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,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5G,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;AACrE,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,iBAAiB,CAAC,KAAc,EAAE,UAAU,GAAyB,EAAE,EAAE,MAAyB;IAChH,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IACrC,IAAI,KAAK,YAAY,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;QACjE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC/D,CAAC;IACD,IAAI,YAAY,CAAC,KAAK,CAAC,KAAK,aAAa,EAAE,CAAC;QAC1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IACrD,CAAC;IACD,OAAO,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;AACrG,CAAC"}
@@ -5,7 +5,7 @@ import { type JsonRecord } from "../json.js";
5
5
  import type { AcpDerivedSessionHooks } from "./derived-sessions.js";
6
6
  import type { AcpSteerRequestHooks } from "./steer-request.js";
7
7
  import type { AcpConfigUpdates } from "./config-updates.js";
8
- import { type AcpFailureReader } from "./failure.js";
8
+ import { type AcpFailureReader, type AcpOpenFailureReader } from "./failure.js";
9
9
  import { type AcpProcess } from "./process.js";
10
10
  export { promptAcp } from "./prompt.js";
11
11
  export { createUsageUpdateGate, type UsageUpdateGate } from "./usage-wait.js";
@@ -101,16 +101,14 @@ export interface AcpSessionProfile extends AcpDerivedSessionHooks, AcpSteerReque
101
101
  readonly replayed?: boolean;
102
102
  } | null;
103
103
  readonly promptOutcome?: (response: JsonRecord) => TurnOutcome | null;
104
+ /** Classify a rejected open or model-selection RPC; null leaves it to the generic rules (failure.ts). */
105
+ readonly openFailure?: AcpOpenFailureReader;
104
106
  /** Classify a prompt the agent answered with an error, from the error and the turn's frames; null leaves it to the generic rules (failure.ts). */
105
107
  readonly failureOutcome?: AcpFailureReader;
106
108
  /**
107
- * The agent answers `session/prompt` BEFORE it pushes the turn's
108
- * `usage_update` (kimi-code f9ca33376 packages/acp-server/src/session.ts:
109
- * `onTurnEnded` resolves the prompt driver, then `void emitUsageUpdate()`
110
- * awaits `listModels` + `getContext` and only then notifies, or skips the
111
- * push when the catalog has no size for the model). When true, the session
112
- * holds the prompt-answer event back until that update lands, bounded by
113
- * `usageUpdateTimeoutMs`; on timeout it records the answer as-is.
109
+ * Hold the `session/prompt` answer back until a trailing `usage_update` lands
110
+ * (kimi-code f9ca33376 resolves the prompt before `void emitUsageUpdate()`),
111
+ * bounded by `usageUpdateTimeoutMs`; on timeout record the answer as-is.
114
112
  */
115
113
  readonly usageUpdateAfterPrompt?: boolean;
116
114
  /** Bound for `usageUpdateAfterPrompt`; default 500 ms. */