@botiverse/oar 0.99.0 → 0.101.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/README.md +17 -17
- package/dist/contracts/login.d.ts +7 -1
- package/dist/contracts/login.d.ts.map +1 -1
- package/dist/contracts/provider-auth.d.ts +8 -4
- package/dist/contracts/provider-auth.d.ts.map +1 -1
- package/dist/contracts/session-options.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/runtimes/antigravity/logout.d.ts.map +1 -1
- package/dist/runtimes/antigravity/logout.js +3 -2
- package/dist/runtimes/antigravity/logout.js.map +1 -1
- package/dist/runtimes/claude/logout.d.ts.map +1 -1
- package/dist/runtimes/claude/logout.js +3 -2
- package/dist/runtimes/claude/logout.js.map +1 -1
- package/dist/runtimes/codebuddy/index.d.ts +1 -0
- package/dist/runtimes/codebuddy/index.d.ts.map +1 -1
- package/dist/runtimes/codebuddy/index.js +1 -0
- package/dist/runtimes/codebuddy/index.js.map +1 -1
- package/dist/runtimes/codebuddy/logout.d.ts +5 -0
- package/dist/runtimes/codebuddy/logout.d.ts.map +1 -0
- package/dist/runtimes/codebuddy/logout.js +57 -0
- package/dist/runtimes/codebuddy/logout.js.map +1 -0
- package/dist/runtimes/codex/installation-candidates.d.ts +31 -0
- package/dist/runtimes/codex/installation-candidates.d.ts.map +1 -0
- package/dist/runtimes/codex/installation-candidates.js +92 -0
- package/dist/runtimes/codex/installation-candidates.js.map +1 -0
- package/dist/runtimes/codex/installation.d.ts +1 -19
- package/dist/runtimes/codex/installation.d.ts.map +1 -1
- package/dist/runtimes/codex/installation.js +2 -49
- package/dist/runtimes/codex/installation.js.map +1 -1
- package/dist/runtimes/codex/logout.d.ts.map +1 -1
- package/dist/runtimes/codex/logout.js +3 -2
- package/dist/runtimes/codex/logout.js.map +1 -1
- package/dist/runtimes/cursor/access.d.ts +68 -0
- package/dist/runtimes/cursor/access.d.ts.map +1 -0
- package/dist/runtimes/cursor/access.js +77 -0
- package/dist/runtimes/cursor/access.js.map +1 -0
- package/dist/runtimes/cursor/auth-status.d.ts +4 -3
- package/dist/runtimes/cursor/auth-status.d.ts.map +1 -1
- package/dist/runtimes/cursor/auth-status.js +20 -18
- package/dist/runtimes/cursor/auth-status.js.map +1 -1
- package/dist/runtimes/cursor/index.d.ts +50 -10
- package/dist/runtimes/cursor/index.d.ts.map +1 -1
- package/dist/runtimes/cursor/index.js +40 -21
- package/dist/runtimes/cursor/index.js.map +1 -1
- package/dist/runtimes/cursor/installation.d.ts +1 -1
- package/dist/runtimes/cursor/installation.d.ts.map +1 -1
- package/dist/runtimes/cursor/installation.js +5 -2
- package/dist/runtimes/cursor/installation.js.map +1 -1
- package/dist/runtimes/cursor/list-models.d.ts +4 -2
- package/dist/runtimes/cursor/list-models.d.ts.map +1 -1
- package/dist/runtimes/cursor/list-models.js +31 -14
- package/dist/runtimes/cursor/list-models.js.map +1 -1
- package/dist/runtimes/cursor/login.d.ts +8 -3
- package/dist/runtimes/cursor/login.d.ts.map +1 -1
- package/dist/runtimes/cursor/login.js +29 -22
- package/dist/runtimes/cursor/login.js.map +1 -1
- package/dist/runtimes/cursor/logout.d.ts +3 -3
- package/dist/runtimes/cursor/logout.d.ts.map +1 -1
- package/dist/runtimes/cursor/logout.js +19 -18
- package/dist/runtimes/cursor/logout.js.map +1 -1
- package/dist/runtimes/cursor/model.d.ts +5 -0
- package/dist/runtimes/cursor/model.d.ts.map +1 -1
- package/dist/runtimes/cursor/model.js +10 -1
- package/dist/runtimes/cursor/model.js.map +1 -1
- package/dist/runtimes/cursor/sdk.d.ts +0 -4
- package/dist/runtimes/cursor/sdk.d.ts.map +1 -1
- package/dist/runtimes/cursor/sdk.js +5 -11
- package/dist/runtimes/cursor/sdk.js.map +1 -1
- package/dist/runtimes/cursor/session-process.d.ts +31 -0
- package/dist/runtimes/cursor/session-process.d.ts.map +1 -0
- package/dist/runtimes/cursor/session-process.js +80 -0
- package/dist/runtimes/cursor/session-process.js.map +1 -0
- package/dist/runtimes/cursor/session.d.ts +2 -2
- package/dist/runtimes/cursor/session.d.ts.map +1 -1
- package/dist/runtimes/cursor/session.js +10 -10
- package/dist/runtimes/cursor/session.js.map +1 -1
- package/dist/runtimes/cursor/subprocess/channel.d.ts +37 -0
- package/dist/runtimes/cursor/subprocess/channel.d.ts.map +1 -0
- package/dist/runtimes/cursor/subprocess/channel.js +170 -0
- package/dist/runtimes/cursor/subprocess/channel.js.map +1 -0
- package/dist/runtimes/cursor/subprocess/child-script.d.ts +12 -0
- package/dist/runtimes/cursor/subprocess/child-script.d.ts.map +1 -0
- package/dist/runtimes/cursor/subprocess/child-script.js +257 -0
- package/dist/runtimes/cursor/subprocess/child-script.js.map +1 -0
- package/dist/runtimes/cursor/subprocess/proxy.d.ts +11 -0
- package/dist/runtimes/cursor/subprocess/proxy.d.ts.map +1 -0
- package/dist/runtimes/cursor/subprocess/proxy.js +242 -0
- package/dist/runtimes/cursor/subprocess/proxy.js.map +1 -0
- package/dist/runtimes/grok/auth.d.ts.map +1 -1
- package/dist/runtimes/grok/auth.js +3 -2
- package/dist/runtimes/grok/auth.js.map +1 -1
- package/dist/runtimes/kimi/logout.d.ts.map +1 -1
- package/dist/runtimes/kimi/logout.js +3 -2
- package/dist/runtimes/kimi/logout.js.map +1 -1
- package/dist/runtimes/opencode/index.d.ts +2 -0
- package/dist/runtimes/opencode/index.d.ts.map +1 -1
- package/dist/runtimes/opencode/index.js +1 -0
- package/dist/runtimes/opencode/index.js.map +1 -1
- package/dist/runtimes/opencode/provider-auth-error.d.ts +25 -0
- package/dist/runtimes/opencode/provider-auth-error.d.ts.map +1 -0
- package/dist/runtimes/opencode/provider-auth-error.js +13 -0
- package/dist/runtimes/opencode/provider-auth-error.js.map +1 -0
- package/dist/runtimes/opencode/provider-auth-facade.d.ts +28 -0
- package/dist/runtimes/opencode/provider-auth-facade.d.ts.map +1 -0
- package/dist/runtimes/opencode/provider-auth-facade.js +178 -0
- package/dist/runtimes/opencode/provider-auth-facade.js.map +1 -0
- package/dist/runtimes/opencode/provider-auth-oauth.d.ts +24 -0
- package/dist/runtimes/opencode/provider-auth-oauth.d.ts.map +1 -0
- package/dist/runtimes/opencode/provider-auth-oauth.js +189 -0
- package/dist/runtimes/opencode/provider-auth-oauth.js.map +1 -0
- package/dist/runtimes/opencode/provider-auth-prompts.d.ts +16 -0
- package/dist/runtimes/opencode/provider-auth-prompts.d.ts.map +1 -0
- package/dist/runtimes/opencode/provider-auth-prompts.js +91 -0
- package/dist/runtimes/opencode/provider-auth-prompts.js.map +1 -0
- package/dist/runtimes/opencode/provider-auth-registry.d.ts +79 -0
- package/dist/runtimes/opencode/provider-auth-registry.d.ts.map +1 -0
- package/dist/runtimes/opencode/provider-auth-registry.js +146 -0
- package/dist/runtimes/opencode/provider-auth-registry.js.map +1 -0
- package/dist/runtimes/opencode/provider-auth-server.d.ts +38 -0
- package/dist/runtimes/opencode/provider-auth-server.d.ts.map +1 -0
- package/dist/runtimes/opencode/provider-auth-server.js +221 -0
- package/dist/runtimes/opencode/provider-auth-server.js.map +1 -0
- package/dist/runtimes/opencode/provider-auth.d.ts +49 -0
- package/dist/runtimes/opencode/provider-auth.d.ts.map +1 -0
- package/dist/runtimes/opencode/provider-auth.js +39 -0
- package/dist/runtimes/opencode/provider-auth.js.map +1 -0
- package/dist/shared/acp/session.js +4 -1
- package/dist/shared/acp/session.js.map +1 -1
- package/dist/shared/acp/turn-terminals.d.ts +2 -1
- package/dist/shared/acp/turn-terminals.d.ts.map +1 -1
- package/dist/shared/acp/turn-terminals.js +47 -23
- package/dist/shared/acp/turn-terminals.js.map +1 -1
- package/dist/shared/executable/environment-marker.d.ts +21 -0
- package/dist/shared/executable/environment-marker.d.ts.map +1 -0
- package/dist/shared/executable/environment-marker.js +137 -0
- package/dist/shared/executable/environment-marker.js.map +1 -0
- package/dist/shared/executable/host-watchdog.d.ts +22 -0
- package/dist/shared/executable/host-watchdog.d.ts.map +1 -0
- package/dist/shared/executable/host-watchdog.js +79 -0
- package/dist/shared/executable/host-watchdog.js.map +1 -0
- package/dist/shared/executable/node-eval.d.ts +10 -0
- package/dist/shared/executable/node-eval.d.ts.map +1 -0
- package/dist/shared/executable/node-eval.js +17 -0
- package/dist/shared/executable/node-eval.js.map +1 -0
- package/dist/shared/executable/node-script.d.ts +53 -0
- package/dist/shared/executable/node-script.d.ts.map +1 -0
- package/dist/shared/executable/node-script.js +131 -0
- package/dist/shared/executable/node-script.js.map +1 -0
- package/dist/shared/login.d.ts +9 -4
- package/dist/shared/login.d.ts.map +1 -1
- package/dist/shared/login.js +15 -7
- package/dist/shared/login.js.map +1 -1
- package/dist/shared/logout.d.ts +8 -0
- package/dist/shared/logout.d.ts.map +1 -1
- package/dist/shared/logout.js +13 -0
- package/dist/shared/logout.js.map +1 -1
- package/dist/shared/shell-environment.d.ts.map +1 -1
- package/dist/shared/shell-environment.js +6 -13
- package/dist/shared/shell-environment.js.map +1 -1
- package/package.json +5 -1
|
@@ -1,54 +1,7 @@
|
|
|
1
1
|
import { environmentHome } from "../../shared/environment-home.js";
|
|
2
|
-
import { environmentValue } from "../../shared/environment.js";
|
|
3
|
-
import { homedir } from "node:os";
|
|
4
|
-
import path from "node:path";
|
|
5
2
|
import { executableInstallation } from "../../shared/installation.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* CLI instead of putting it on PATH; OpenAI relocated the app from Codex.app
|
|
9
|
-
* to ChatGPT.app, so the new bundle is tried before the legacy one, and
|
|
10
|
-
* system installs before per-user installs. Then the standalone installer's
|
|
11
|
-
* launcher (https://chatgpt.com/codex/install.sh: `$CODEX_INSTALL_DIR/codex`,
|
|
12
|
-
* by default `~/.local/bin/codex`, a link into
|
|
13
|
-
* `$CODEX_HOME/packages/standalone/current`), which it adds to PATH only in
|
|
14
|
-
* shell profiles.
|
|
15
|
-
*
|
|
16
|
-
* On Windows (none of them on PATH): npm's global `codex.cmd` shim in its
|
|
17
|
-
* default prefix (`%APPDATA%\npm`; OAR runs the shim's Node script without
|
|
18
|
-
* cmd.exe, windows-shim.ts), then the Codex Desktop app's CLI
|
|
19
|
-
* (`%LOCALAPPDATA%\Programs\OpenAI\Codex\bin\codex.exe`, or without
|
|
20
|
-
* `Programs` for a per-user install). Locations as Raft's own Codex driver
|
|
21
|
-
* resolves them; the `codex-command-runner` sandbox helper beside them is
|
|
22
|
-
* never a candidate.
|
|
23
|
-
*/
|
|
24
|
-
export function codexInstalledExecutableCandidates(platform = process.platform, home = homedir(), env = process.env) {
|
|
25
|
-
if (platform === "win32") {
|
|
26
|
-
const win = path.win32;
|
|
27
|
-
// Windows variable names are case-insensitive (`AppData` is `APPDATA`).
|
|
28
|
-
const folder = (name, fallback) => {
|
|
29
|
-
const value = environmentValue(env, name, platform);
|
|
30
|
-
return value === undefined || value === "" ? fallback : value;
|
|
31
|
-
};
|
|
32
|
-
const roaming = folder("APPDATA", win.join(home, "AppData", "Roaming"));
|
|
33
|
-
const local = folder("LOCALAPPDATA", win.join(home, "AppData", "Local"));
|
|
34
|
-
return [
|
|
35
|
-
win.join(roaming, "npm", "codex.cmd"),
|
|
36
|
-
win.join(local, "Programs", "OpenAI", "Codex", "bin", "codex.exe"),
|
|
37
|
-
win.join(local, "OpenAI", "Codex", "bin", "codex.exe"),
|
|
38
|
-
];
|
|
39
|
-
}
|
|
40
|
-
const paths = path.posix;
|
|
41
|
-
const bundles = platform === "darwin"
|
|
42
|
-
? [
|
|
43
|
-
"/Applications/ChatGPT.app/Contents/Resources/codex",
|
|
44
|
-
"/Applications/Codex.app/Contents/Resources/codex",
|
|
45
|
-
paths.join(home, "Applications", "ChatGPT.app", "Contents", "Resources", "codex"),
|
|
46
|
-
paths.join(home, "Applications", "Codex.app", "Contents", "Resources", "codex"),
|
|
47
|
-
]
|
|
48
|
-
: [];
|
|
49
|
-
const installDir = env.CODEX_INSTALL_DIR === undefined || env.CODEX_INSTALL_DIR === "" ? [] : [paths.join(env.CODEX_INSTALL_DIR, "codex")];
|
|
50
|
-
return [...bundles, ...installDir, paths.join(home, ".local", "bin", "codex")];
|
|
51
|
-
}
|
|
3
|
+
import { codexInstalledExecutableCandidates } from "./installation-candidates.js";
|
|
4
|
+
export { codexInstalledExecutableCandidates, desktopBuildExecutables } from "./installation-candidates.js";
|
|
52
5
|
// OAR drives Codex through its app-server surface; a codex without it is unsupported.
|
|
53
6
|
export const codexInstallation = executableInstallation("OAR_CODEX_BIN", "codex", (env) => codexInstalledExecutableCandidates(process.platform, environmentHome(env), env), ["app-server", "--help"]);
|
|
54
7
|
//# sourceMappingURL=installation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installation.js","sources":["../../../src/runtimes/codex/installation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"installation.js","sources":["../../../src/runtimes/codex/installation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,kCAAkC,EAAE,MAAM,8BAA8B,CAAC;AAElF,OAAO,EAAE,kCAAkC,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAE3G,sFAAsF;AACtF,MAAM,CAAC,MAAM,iBAAiB,GAAG,sBAAsB,CACrD,eAAe,EACf,OAAO,EACP,CAAC,GAAG,EAAE,EAAE,CAAC,kCAAkC,CAAC,OAAO,CAAC,QAAQ,EAAE,eAAe,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EACxF,CAAC,YAAY,EAAE,QAAQ,CAAC,CACzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.d.ts","sources":["../../../src/runtimes/codex/logout.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAyB5E,yEAAyE;AACzE,wBAAsB,WAAW,CAAC,YAAY,EAAE,qBAAqB,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sources":["../../../src/runtimes/codex/logout.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAyB5E,yEAAyE;AACzE,wBAAsB,WAAW,CAAC,YAAY,EAAE,qBAAqB,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,CAazH"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { sessionEnvironment } from "../../shared/environment.js";
|
|
2
2
|
import { loginExecutable } from "../../shared/login.js";
|
|
3
|
-
import { commandLogout, confirmedLogout, runLogoutCommand } from "../../shared/logout.js";
|
|
3
|
+
import { commandLogout, confirmedLogout, runLogoutCommand, statusAfterLogout } from "../../shared/logout.js";
|
|
4
4
|
import { readCodexAuthStatus } from "./login.js";
|
|
5
5
|
/*
|
|
6
6
|
* `codex logout` (0.160.1, read in openai/codex `rust-v0.160.1`:
|
|
@@ -23,6 +23,7 @@ const LOGOUT_COMMAND = "codex logout";
|
|
|
23
23
|
const LOGOUT_TIMEOUT_MS = 60_000;
|
|
24
24
|
/** Signs codex out with `codex logout`; `codex login status` decides. */
|
|
25
25
|
export async function codexLogout(installation, options = {}) {
|
|
26
|
+
const startedAt = Date.now();
|
|
26
27
|
const target = loginExecutable(installation, "codex", LOGOUT_FLOOR, sessionEnvironment(options.env));
|
|
27
28
|
if (target.kind === "settled") {
|
|
28
29
|
return target.result;
|
|
@@ -33,6 +34,6 @@ export async function codexLogout(installation, options = {}) {
|
|
|
33
34
|
return { kind: "failed", reason: "process_failed", detail: end.detail };
|
|
34
35
|
}
|
|
35
36
|
const native = commandLogout(end, LOGOUT_COMMAND, timeoutMs);
|
|
36
|
-
return confirmedLogout(native, await readCodexAuthStatus(installation, { env: options.env }), LOGOUT_COMMAND);
|
|
37
|
+
return confirmedLogout(native, await readCodexAuthStatus(installation, { env: options.env, ...statusAfterLogout(startedAt, options.timeoutMs) }), LOGOUT_COMMAND);
|
|
37
38
|
}
|
|
38
39
|
//# sourceMappingURL=logout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.js","sources":["../../../src/runtimes/codex/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGjE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"logout.js","sources":["../../../src/runtimes/codex/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGjE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC7G,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;;;;;;;;;;GAcG;AACH,MAAM,YAAY,GAAG,QAAQ,CAAC;AAC9B,MAAM,cAAc,GAAG,cAAc,CAAC;AACtC,2BAA2B;AAC3B,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEjC,yEAAyE;AACzE,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,YAAmC,EAAE,OAAO,GAAkB,EAAE;IAChG,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAG,eAAe,CAAC,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IACrG,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC,MAAM,CAAC;IACvB,CAAC;IACD,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,iBAAiB,CAAC;IACzD,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;IACxH,IAAI,GAAG,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;QAC/B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;IAC1E,CAAC;IACD,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;IAC7D,OAAO,eAAe,CAAC,MAAM,EAAE,MAAM,mBAAmB,CAAC,YAAY,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,GAAG,iBAAiB,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,cAAc,CAAC,CAAC;AACpK,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { RefusedSessionOptions } from "../../contracts/runtime.js";
|
|
2
|
+
import type { SessionOptions } from "../../contracts/session.js";
|
|
3
|
+
import { type CursorSdk } from "./sdk.js";
|
|
4
|
+
import { type CursorChildExit } from "./subprocess/channel.js";
|
|
5
|
+
/** The SDK for one session or one call, and what reaching it started. */
|
|
6
|
+
export interface CursorSdkLease {
|
|
7
|
+
readonly sdk: CursorSdk;
|
|
8
|
+
/** The environment the SDK and its tools run with. */
|
|
9
|
+
readonly env: Readonly<NodeJS.ProcessEnv>;
|
|
10
|
+
/** In subprocess mode, the child: its exit, observed once. Null in process. */
|
|
11
|
+
readonly child: {
|
|
12
|
+
onExit(listener: (exit: CursorChildExit) => void): void;
|
|
13
|
+
stopping(): boolean;
|
|
14
|
+
} | null;
|
|
15
|
+
/** Ends what the lease started (the child and its tree), with its exit; null in process. */
|
|
16
|
+
release(): Promise<CursorChildExit | null>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* How the adapter reaches `@cursor/sdk`. `in_process`: the host's loaded
|
|
20
|
+
* SDK, shared by every session and call, in the host's environment.
|
|
21
|
+
* `subprocess`: a fresh Node child per session or call, which imports the
|
|
22
|
+
* SDK itself, with its own environment (subprocess/).
|
|
23
|
+
*/
|
|
24
|
+
export interface CursorSdkAccess {
|
|
25
|
+
readonly execution: "in_process" | "subprocess";
|
|
26
|
+
/** The session options this mode refuses. */
|
|
27
|
+
readonly refusedSessionOptions: RefusedSessionOptions;
|
|
28
|
+
/** The environment a lease with `env` runs in, without opening one. */
|
|
29
|
+
environment(env: SessionOptions["env"]): Readonly<NodeJS.ProcessEnv>;
|
|
30
|
+
/**
|
|
31
|
+
* An SDK with `env` over the host's environment; rejects when the SDK
|
|
32
|
+
* cannot be loaded. `session`: the lease is a session's, whose tools the
|
|
33
|
+
* host ends after the child (one-shot calls run no tools).
|
|
34
|
+
*/
|
|
35
|
+
lease(env: SessionOptions["env"], use?: "session" | "call"): Promise<CursorSdkLease>;
|
|
36
|
+
}
|
|
37
|
+
/** Why the in-process mode refuses a nonempty `env` for login, logout and the status. */
|
|
38
|
+
export declare const IN_PROCESS_ENV = "Cursor authentication runs in the host process and cannot isolate env; configure the host environment before loading the SDK, or use the subprocess execution mode.";
|
|
39
|
+
/** The host's loaded SDK, or a whole access. A plain loader is the in-process mode. */
|
|
40
|
+
export type CursorSdkSource = (() => Promise<CursorSdk>) | CursorSdkAccess;
|
|
41
|
+
/**
|
|
42
|
+
* The SDK in this process, through the host's loader. `loadOnce` wraps it
|
|
43
|
+
* in `cursorSdkLoader` (one load, retried after a failure); tests that hand
|
|
44
|
+
* over a loader of their own pass false. Callers refuse a nonempty `env` first.
|
|
45
|
+
*/
|
|
46
|
+
export declare function inProcessAccess(loader: () => Promise<CursorSdk>, loadOnce?: boolean): CursorSdkAccess;
|
|
47
|
+
/**
|
|
48
|
+
* One child per lease, importing `sdkModule`. Its environment is `env` over
|
|
49
|
+
* the host's (`inherit`), or `env`'s string entries alone (`clean`); the
|
|
50
|
+
* child adds only what it needs to run the SDK (subprocess/child-script.ts).
|
|
51
|
+
* `CURSOR_API_KEY` is taken out of that environment (every letter case on
|
|
52
|
+
* Windows) and handed to the SDK as `apiKey` instead (subprocess/proxy.ts),
|
|
53
|
+
* so the agent's tools neither inherit it nor can read it from the child's
|
|
54
|
+
* `/proc/<pid>/environ`.
|
|
55
|
+
*/
|
|
56
|
+
export declare function subprocessAccess(sdkModule: string, envBase?: "inherit" | "clean"): CursorSdkAccess;
|
|
57
|
+
export declare function cursorSdkAccess(source: CursorSdkSource): CursorSdkAccess;
|
|
58
|
+
/**
|
|
59
|
+
* Redaction for one model listing, login, logout or status call: the
|
|
60
|
+
* credentials in that call's `env` (`CURSOR_API_KEY` among them, whatever
|
|
61
|
+
* its shape), the same rules sessions apply to `SessionOptions.env`.
|
|
62
|
+
*/
|
|
63
|
+
export declare function callRedaction(env: SessionOptions["env"]): <T>(value: T) => T;
|
|
64
|
+
/** Use a lease and release it; a lease that cannot be had is `{ failed }` with its reason. */
|
|
65
|
+
export declare function withLease<T>(access: CursorSdkAccess, env: SessionOptions["env"], use: (sdk: CursorSdk, lease: CursorSdkLease) => Promise<T>): Promise<T | {
|
|
66
|
+
readonly failed: string;
|
|
67
|
+
}>;
|
|
68
|
+
//# sourceMappingURL=access.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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MAAM,MAAM,eAAe,GAAG,CAAC,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,eAAe,CAAC;AAE3E;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,EAAE,QAAQ,UAAQ,GAAG,eAAe,CAWnG;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,SAAS,GAAG,OAAmB,GAAG,eAAe,CAc7G;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,CAExE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,CAE5E;AAED,8FAA8F;AAC9F,wBAAsB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAY5L"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { sessionCredentialRedactor } from "../../shared/credential-redactor.js";
|
|
2
|
+
import { environmentValue, sessionEnvironment } from "../../shared/environment.js";
|
|
3
|
+
import { cursorRefusedSessionOptions, cursorSubprocessRefusedSessionOptions } from "./model.js";
|
|
4
|
+
import { cursorSdkLoader } from "./sdk.js";
|
|
5
|
+
import { openCursorChannel } from "./subprocess/channel.js";
|
|
6
|
+
import { proxySdk } from "./subprocess/proxy.js";
|
|
7
|
+
/** Why the in-process mode refuses a nonempty `env` for login, logout and the status. */
|
|
8
|
+
export const IN_PROCESS_ENV = "Cursor authentication runs in the host process and cannot isolate env; configure the host environment before loading the SDK, or use the subprocess execution mode.";
|
|
9
|
+
/**
|
|
10
|
+
* The SDK in this process, through the host's loader. `loadOnce` wraps it
|
|
11
|
+
* in `cursorSdkLoader` (one load, retried after a failure); tests that hand
|
|
12
|
+
* over a loader of their own pass false. Callers refuse a nonempty `env` first.
|
|
13
|
+
*/
|
|
14
|
+
export function inProcessAccess(loader, loadOnce = false) {
|
|
15
|
+
const load = loadOnce ? cursorSdkLoader(loader) : loader;
|
|
16
|
+
return {
|
|
17
|
+
execution: "in_process",
|
|
18
|
+
refusedSessionOptions: cursorRefusedSessionOptions,
|
|
19
|
+
environment: () => process.env,
|
|
20
|
+
async lease() {
|
|
21
|
+
const sdk = await load();
|
|
22
|
+
return { sdk, env: process.env, child: null, release: async () => { await Promise.resolve(); return null; } };
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* One child per lease, importing `sdkModule`. Its environment is `env` over
|
|
28
|
+
* the host's (`inherit`), or `env`'s string entries alone (`clean`); the
|
|
29
|
+
* child adds only what it needs to run the SDK (subprocess/child-script.ts).
|
|
30
|
+
* `CURSOR_API_KEY` is taken out of that environment (every letter case on
|
|
31
|
+
* Windows) and handed to the SDK as `apiKey` instead (subprocess/proxy.ts),
|
|
32
|
+
* so the agent's tools neither inherit it nor can read it from the child's
|
|
33
|
+
* `/proc/<pid>/environ`.
|
|
34
|
+
*/
|
|
35
|
+
export function subprocessAccess(sdkModule, envBase = "inherit") {
|
|
36
|
+
const environment = (overlay) => (envBase === "clean" ? sessionEnvironment(overlay, {}) : sessionEnvironment(overlay));
|
|
37
|
+
return {
|
|
38
|
+
execution: "subprocess",
|
|
39
|
+
refusedSessionOptions: cursorSubprocessRefusedSessionOptions,
|
|
40
|
+
environment,
|
|
41
|
+
async lease(overlay, use = "call") {
|
|
42
|
+
const env = environment(overlay);
|
|
43
|
+
const apiKey = environmentValue(env, "CURSOR_API_KEY");
|
|
44
|
+
const childEnv = apiKey === undefined ? env : sessionEnvironment({ CURSOR_API_KEY: null }, env);
|
|
45
|
+
const channel = await openCursorChannel(sdkModule, childEnv, use === "session");
|
|
46
|
+
return { sdk: proxySdk(channel, apiKey), env, child: channel, release: async () => { const exit = await channel.stop(); return exit; } };
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export function cursorSdkAccess(source) {
|
|
51
|
+
return typeof source === "function" ? inProcessAccess(source) : source;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Redaction for one model listing, login, logout or status call: the
|
|
55
|
+
* credentials in that call's `env` (`CURSOR_API_KEY` among them, whatever
|
|
56
|
+
* its shape), the same rules sessions apply to `SessionOptions.env`.
|
|
57
|
+
*/
|
|
58
|
+
export function callRedaction(env) {
|
|
59
|
+
return sessionCredentialRedactor(env === undefined ? {} : { env }).redactValue;
|
|
60
|
+
}
|
|
61
|
+
/** Use a lease and release it; a lease that cannot be had is `{ failed }` with its reason. */
|
|
62
|
+
export async function withLease(access, env, use) {
|
|
63
|
+
let lease = null;
|
|
64
|
+
try {
|
|
65
|
+
lease = await access.lease(env);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
return { failed: error instanceof Error ? error.message : String(error) };
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
return await use(lease.sdk, lease);
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
await lease.release();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=access.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access.js","sources":["../../../src/runtimes/cursor/access.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACnF,OAAO,EAAE,2BAA2B,EAAE,qCAAqC,EAAE,MAA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AAK,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IAC5E,CAAC;IACD,IAAI,CAAC;QACH,OAAO,MAAM,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;YAAS,CAAC;QACT,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AuthStatus, AuthStatusReader } from "../../contracts/login.js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type CursorSdkSource } from "./access.js";
|
|
3
|
+
import type { CursorAuth } from "./sdk.js";
|
|
3
4
|
/**
|
|
4
5
|
* `Cursor.auth.status()` (SDK 1.3.1) reads the stored login
|
|
5
6
|
* (`~/.cursor/sdk/auth.json`) and answers `{ status: "logged-out" }`, also
|
|
@@ -10,6 +11,6 @@ import { type CursorAuth, type CursorSdk } from "./sdk.js";
|
|
|
10
11
|
export declare function projectCursorAuthStatus(status: unknown): AuthStatus;
|
|
11
12
|
/** `Cursor.auth.status()` within `timeoutMs`; a failure, or no answer in time, is `unknown`. */
|
|
12
13
|
export declare function readCursorAuthStatus(auth: CursorAuth, timeoutMs?: number): Promise<AuthStatus>;
|
|
13
|
-
/** Read only: asks the SDK's `Cursor.auth.status`, never a login flow, and returns no key. */
|
|
14
|
-
export declare function cursorAuthStatusWith(
|
|
14
|
+
/** Read only: asks the SDK's `Cursor.auth.status`, never a login flow, and returns no key. In subprocess mode it asks in a child with `env`. */
|
|
15
|
+
export declare function cursorAuthStatusWith(source: CursorSdkSource): AuthStatusReader;
|
|
15
16
|
//# sourceMappingURL=auth-status.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-status.d.ts","sources":["../../../src/runtimes/cursor/auth-status.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAgB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"auth-status.d.ts","sources":["../../../src/runtimes/cursor/auth-status.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAgB,MAAM,0BAA0B,CAAC;AAK3F,OAAO,EAA6D,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAS3C;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,OAAO,GAAG,UAAU,CAmBnE;AAED,gGAAgG;AAChG,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,SAAoB,GAAG,OAAO,CAAC,UAAU,CAAC,CAc/G;AAED,gJAAgJ;AAChJ,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,GAAG,gBAAgB,CA6B9E"}
|
|
@@ -3,7 +3,8 @@ import { UnsupportedOptionError } from "../../contracts/errors.js";
|
|
|
3
3
|
import { utcInstantFromDate } from "../../shared/instant.js";
|
|
4
4
|
import { asNumber, asRecord } from "../../shared/json.js";
|
|
5
5
|
import { errorMessage, LoginSecrets } from "../../shared/login.js";
|
|
6
|
-
import {
|
|
6
|
+
import { environmentValue } from "../../shared/environment.js";
|
|
7
|
+
import { callRedaction, cursorSdkAccess, IN_PROCESS_ENV, withLease } from "./access.js";
|
|
7
8
|
const STATUS_TIMEOUT_MS = 20_000;
|
|
8
9
|
const STATUS_SOURCE = "Cursor.auth.status";
|
|
9
10
|
function text(value) {
|
|
@@ -54,32 +55,33 @@ export async function readCursorAuthStatus(auth, timeoutMs = STATUS_TIMEOUT_MS)
|
|
|
54
55
|
clearTimeout(timer);
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
|
-
/** Read only: asks the SDK's `Cursor.auth.status`, never a login flow, and returns no key. */
|
|
58
|
-
export function cursorAuthStatusWith(
|
|
58
|
+
/** Read only: asks the SDK's `Cursor.auth.status`, never a login flow, and returns no key. In subprocess mode it asks in a child with `env`. */
|
|
59
|
+
export function cursorAuthStatusWith(source) {
|
|
60
|
+
const access = cursorSdkAccess(source);
|
|
59
61
|
const reader = async (installation, options = {}) => {
|
|
60
|
-
if (options.env !== undefined && Object.keys(options.env).length > 0) {
|
|
61
|
-
throw new UnsupportedOptionError("env",
|
|
62
|
+
if (access.execution === "in_process" && options.env !== undefined && Object.keys(options.env).length > 0) {
|
|
63
|
+
throw new UnsupportedOptionError("env", IN_PROCESS_ENV);
|
|
62
64
|
}
|
|
63
65
|
if (installation.via !== "bundled") {
|
|
64
66
|
return { kind: "unknown", detail: "cursor's sign-in status needs the bundled @cursor/sdk" };
|
|
65
67
|
}
|
|
66
|
-
if (
|
|
68
|
+
if (environmentValue(access.environment(options.env), "CURSOR_API_KEY") !== undefined) {
|
|
67
69
|
return { kind: "unknown", configured: ["environment: CURSOR_API_KEY"], detail: "Sessions use CURSOR_API_KEY from the environment; Cursor.auth.status neither reads nor validates that key.", source: STATUS_SOURCE };
|
|
68
70
|
}
|
|
69
71
|
const result = await withQueryDeadline("Cursor auth status", options.timeoutMs ?? STATUS_TIMEOUT_MS, async (signal) => {
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return status;
|
|
72
|
+
const status = await withLease(access, options.env, async (sdk) => {
|
|
73
|
+
signal.throwIfAborted();
|
|
74
|
+
const { auth } = sdk.Cursor;
|
|
75
|
+
if (auth === undefined) {
|
|
76
|
+
return { kind: "unknown", detail: "this @cursor/sdk has no Cursor.auth; OAR needs 1.3.1" };
|
|
77
|
+
}
|
|
78
|
+
const read = await readCursorAuthStatus(auth, options.timeoutMs);
|
|
79
|
+
return read;
|
|
80
|
+
});
|
|
81
|
+
return "failed" in status ? { kind: "unknown", detail: new LoginSecrets().line(status.failed) } : status;
|
|
81
82
|
}, { kind: "unknown", source: STATUS_SOURCE, detail: `Cursor.auth.status did not answer within ${String(options.timeoutMs ?? STATUS_TIMEOUT_MS)} ms` });
|
|
82
|
-
|
|
83
|
+
// Details can carry the SDK's or the child's words: redacted with the call's credentials too.
|
|
84
|
+
return callRedaction(options.env)(result);
|
|
83
85
|
};
|
|
84
86
|
// With no status options, the official SDK uses only its local file store.
|
|
85
87
|
return Object.assign(reader, { localOnly: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-status.js","sources":["../../../src/runtimes/cursor/auth-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"auth-status.js","sources":["../../../src/runtimes/cursor/auth-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA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EAAE,SAAS,EAAE,MAAM,EAAE,sDAAsD,EAAE,CAAC;gBAC7F,CAAC;gBACD,MAAM,IAAI,GAAG,MAAM,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;gBACjE,OAAO,IAAI,CAAC;YACd,CAAC,CAAC,CAAC;YACH,OAAO,QAAQ,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,YAAY,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;QAC3G,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,4CAA4C,MAAM,CAAC,OAAO,CAAC,SAAS,IAAI,iBAAiB,CAAC,KAAK,EAAE,CAAC,CAAC;QACxJ,8FAA8F;QAC9F,OAAO,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC,CAAC;IACF,2EAA2E;IAC3E,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAa,EAAE,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type Runtime } from "../../contracts/runtime.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import type { CursorSdk } from "./sdk.js";
|
|
3
|
+
/** The default mode: the SDK runs in the host process. */
|
|
4
|
+
export interface CursorInProcessOptions {
|
|
5
|
+
readonly execution?: "in_process";
|
|
4
6
|
/**
|
|
5
7
|
* Loads `@cursor/sdk` 1.3.1, which the host installs (an optional peer
|
|
6
8
|
* dependency of OAR): `() => import("@cursor/sdk")`. Written in the host's
|
|
@@ -10,18 +12,56 @@ export interface CursorRuntimeOptions {
|
|
|
10
12
|
* retried by the next call.
|
|
11
13
|
*/
|
|
12
14
|
readonly sdk: () => Promise<CursorSdk>;
|
|
15
|
+
/** Subprocess mode only: in process, the SDK's tools always see the host's environment. */
|
|
16
|
+
readonly envBase?: never;
|
|
13
17
|
}
|
|
18
|
+
/** Each session, and each model listing, login, logout and status call, runs the SDK in a Node child process of its own. */
|
|
19
|
+
export interface CursorSubprocessOptions {
|
|
20
|
+
readonly execution: "subprocess";
|
|
21
|
+
/**
|
|
22
|
+
* What the child passes to `import()` to load `@cursor/sdk` 1.3.1: a file
|
|
23
|
+
* URL, e.g. `import.meta.resolve("@cursor/sdk")` in the host's own code.
|
|
24
|
+
* The host never loads the SDK itself in this mode, so nothing checks the
|
|
25
|
+
* module's types against `CursorSdk` at compile time.
|
|
26
|
+
*/
|
|
27
|
+
readonly sdkModule: string;
|
|
28
|
+
/**
|
|
29
|
+
* What a child's environment starts from before the session's or call's
|
|
30
|
+
* `env` is applied. `inherit` (the default): the host's whole
|
|
31
|
+
* `process.env`, as for process runtimes. `clean`: nothing; the child gets
|
|
32
|
+
* only the string entries of `env`, plus what OAR adds to run the SDK
|
|
33
|
+
* (docs/runtimes/cursor.md#child-environment). A host that wants an
|
|
34
|
+
* allowlist uses `clean` and passes what Node and the SDK need, such as
|
|
35
|
+
* PATH and HOME.
|
|
36
|
+
*/
|
|
37
|
+
readonly envBase?: "inherit" | "clean";
|
|
38
|
+
}
|
|
39
|
+
export type CursorRuntimeOptions = CursorInProcessOptions | CursorSubprocessOptions;
|
|
14
40
|
/** A cursor runtime: its probe, model listing, login, logout, status and refusals are always there. */
|
|
15
41
|
export type CursorRuntime = Runtime & Required<Pick<Runtime, "installation" | "listModels" | "login" | "logout" | "authStatus" | "refusedSessionOptions">>;
|
|
16
42
|
/**
|
|
17
|
-
* Cursor, embedded through its official SDK (`@cursor/sdk`)
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
43
|
+
* Cursor, embedded through its official SDK (`@cursor/sdk`). It is not in
|
|
44
|
+
* `defaultRuntimes`, because the SDK is the host's to install and hand over;
|
|
45
|
+
* a host that wants cursor adds `createCursorRuntime(...)` to its own
|
|
46
|
+
* registry (docs/design/capabilities.md#a-runtimes-own-settings).
|
|
47
|
+
*
|
|
48
|
+
* Two execution modes (docs/runtimes/cursor.md#execution-modes):
|
|
49
|
+
* - `{ sdk }` (the default, `execution: "in_process"`): the agent runs in
|
|
50
|
+
* this process, the way pi does. Its tools inherit the host's whole
|
|
51
|
+
* environment, so `SessionOptions.env` is refused, and an SDK crash is the
|
|
52
|
+
* host's crash.
|
|
53
|
+
* - `{ execution: "subprocess", sdkModule }`: each session runs the SDK in
|
|
54
|
+
* its own Node child (`process.execPath`), whose environment is
|
|
55
|
+
* `SessionOptions.env` over the host's (`envBase: "inherit"`, the default)
|
|
56
|
+
* or over nothing (`envBase: "clean"`); a child that exits is recorded as
|
|
57
|
+
* `exited`, and a child whose host is gone, SIGKILL included, ends itself
|
|
58
|
+
* and what it started, as far as docs/runtimes/cursor.md#execution-modes
|
|
59
|
+
* says per platform. Model listing, login, logout and the status each run in a
|
|
60
|
+
* one-shot child and take `env` the same way.
|
|
61
|
+
*
|
|
62
|
+
* Account usage is absent: the SDK's usage call is not available to every
|
|
63
|
+
* account (`feature_unavailable`, probed 2026-10-03), and each run reports
|
|
64
|
+
* its own tokens anyway. Login, logout and the status are the SDK's own
|
|
25
65
|
* `Cursor.auth`.
|
|
26
66
|
*/
|
|
27
67
|
export declare function createCursorRuntime(options: CursorRuntimeOptions): CursorRuntime;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sources":["../../../src/runtimes/cursor/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAOzE,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":["../../../src/runtimes/cursor/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAOzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C,0DAA0D;AAC1D,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,SAAS,CAAC,EAAE,YAAY,CAAC;IAClC;;;;;;;OAOG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;IACvC,2FAA2F;IAC3F,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC;CAC1B;AAED,4HAA4H;AAC5H,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;IACjC;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;;;;;;;OAQG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;CACxC;AAED,MAAM,MAAM,oBAAoB,GAAG,sBAAsB,GAAG,uBAAuB,CAAC;AAEpF,uGAAuG;AACvG,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,YAAY,GAAG,uBAAuB,CAAC,CAAC,CAAC;AAE3J;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAKhF;AAkBD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -1,38 +1,57 @@
|
|
|
1
1
|
import { runtimeBrands } from "../../brands.js";
|
|
2
2
|
import { defineRuntime } from "../../contracts/runtime.js";
|
|
3
|
+
import { inProcessAccess, subprocessAccess } from "./access.js";
|
|
3
4
|
import { cursorAuthStatusWith } from "./auth-status.js";
|
|
4
|
-
import {
|
|
5
|
+
import { cursorInstallationFor } from "./installation.js";
|
|
5
6
|
import { cursorListModelsWith } from "./list-models.js";
|
|
6
7
|
import { cursorLoginWith } from "./login.js";
|
|
7
8
|
import { cursorLogoutWith } from "./logout.js";
|
|
8
|
-
import { cursorRefusedSessionOptions } from "./model.js";
|
|
9
|
-
import { cursorSdkLoader } from "./sdk.js";
|
|
10
9
|
import { cursorSessionWith } from "./session.js";
|
|
11
10
|
/**
|
|
12
|
-
* Cursor, embedded through its official SDK (`@cursor/sdk`)
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
11
|
+
* Cursor, embedded through its official SDK (`@cursor/sdk`). It is not in
|
|
12
|
+
* `defaultRuntimes`, because the SDK is the host's to install and hand over;
|
|
13
|
+
* a host that wants cursor adds `createCursorRuntime(...)` to its own
|
|
14
|
+
* registry (docs/design/capabilities.md#a-runtimes-own-settings).
|
|
15
|
+
*
|
|
16
|
+
* Two execution modes (docs/runtimes/cursor.md#execution-modes):
|
|
17
|
+
* - `{ sdk }` (the default, `execution: "in_process"`): the agent runs in
|
|
18
|
+
* this process, the way pi does. Its tools inherit the host's whole
|
|
19
|
+
* environment, so `SessionOptions.env` is refused, and an SDK crash is the
|
|
20
|
+
* host's crash.
|
|
21
|
+
* - `{ execution: "subprocess", sdkModule }`: each session runs the SDK in
|
|
22
|
+
* its own Node child (`process.execPath`), whose environment is
|
|
23
|
+
* `SessionOptions.env` over the host's (`envBase: "inherit"`, the default)
|
|
24
|
+
* or over nothing (`envBase: "clean"`); a child that exits is recorded as
|
|
25
|
+
* `exited`, and a child whose host is gone, SIGKILL included, ends itself
|
|
26
|
+
* and what it started, as far as docs/runtimes/cursor.md#execution-modes
|
|
27
|
+
* says per platform. Model listing, login, logout and the status each run in a
|
|
28
|
+
* one-shot child and take `env` the same way.
|
|
29
|
+
*
|
|
30
|
+
* Account usage is absent: the SDK's usage call is not available to every
|
|
31
|
+
* account (`feature_unavailable`, probed 2026-10-03), and each run reports
|
|
32
|
+
* its own tokens anyway. Login, logout and the status are the SDK's own
|
|
20
33
|
* `Cursor.auth`.
|
|
21
34
|
*/
|
|
22
35
|
export function createCursorRuntime(options) {
|
|
23
|
-
|
|
24
|
-
|
|
36
|
+
if (options.execution === "subprocess") {
|
|
37
|
+
return cursorRuntime(subprocessAccess(options.sdkModule, options.envBase));
|
|
38
|
+
}
|
|
39
|
+
return cursorRuntime(inProcessAccess(options.sdk, true));
|
|
40
|
+
}
|
|
41
|
+
function cursorRuntime(access) {
|
|
42
|
+
const definition = {
|
|
25
43
|
id: "cursor",
|
|
44
|
+
refusedSessionOptions: access.refusedSessionOptions,
|
|
26
45
|
brand: runtimeBrands.cursor,
|
|
27
46
|
manualCompaction: { kind: "supported", activeTurn: "reject" },
|
|
28
|
-
installation:
|
|
29
|
-
listModels: cursorListModelsWith(
|
|
30
|
-
login: cursorLoginWith(
|
|
31
|
-
logout: cursorLogoutWith(
|
|
32
|
-
authStatus: cursorAuthStatusWith(
|
|
33
|
-
session: cursorSessionWith(
|
|
34
|
-
|
|
35
|
-
|
|
47
|
+
installation: cursorInstallationFor(process.platform, process.arch, access.execution),
|
|
48
|
+
listModels: cursorListModelsWith(access),
|
|
49
|
+
login: cursorLoginWith(access),
|
|
50
|
+
logout: cursorLogoutWith(access),
|
|
51
|
+
authStatus: cursorAuthStatusWith(access),
|
|
52
|
+
session: cursorSessionWith(access),
|
|
53
|
+
};
|
|
54
|
+
return defineRuntime(definition, access.execution === "subprocess" ? { execution: "process" } : { execution: "in_process" });
|
|
36
55
|
}
|
|
37
56
|
export { projectCursorModels } from "./list-models.js";
|
|
38
57
|
export { cursorNativeEnvironment } from "./native-environment.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/runtimes/cursor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;A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EAAE,QAAQ,EAAE;QAC7D,YAAY,EAAE,qBAAqB,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC;QACrF,UAAU,EAAE,oBAAoB,CAAC,MAAM,CAAC;QACxC,KAAK,EAAE,eAAe,CAAC,MAAM,CAAC;QAC9B,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC;QAChC,UAAU,EAAE,oBAAoB,CAAC,MAAM,CAAC;QACxC,OAAO,EAAE,iBAAiB,CAAC,MAAM,CAAC;KAC1B,CAAC;IACX,OAAO,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAC;AAC/H,CAAC;AAED,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -9,6 +9,6 @@ import type { InstallationProbe } from "../../contracts/installation.js";
|
|
|
9
9
|
* needs its native companion package, which exists only for the platforms in
|
|
10
10
|
* `PLATFORMS`.
|
|
11
11
|
*/
|
|
12
|
-
export declare function cursorInstallationFor(platform: string, arch: string): InstallationProbe;
|
|
12
|
+
export declare function cursorInstallationFor(platform: string, arch: string, execution?: "in_process" | "subprocess"): InstallationProbe;
|
|
13
13
|
export declare const cursorInstallation: InstallationProbe;
|
|
14
14
|
//# sourceMappingURL=installation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installation.d.ts","sources":["../../../src/runtimes/cursor/installation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAwB,MAAM,iCAAiC,CAAC;AAK/F;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,iBAAiB,
|
|
1
|
+
{"version":3,"file":"installation.d.ts","sources":["../../../src/runtimes/cursor/installation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAwB,MAAM,iCAAiC,CAAC;AAK/F;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,YAAY,GAAG,YAA2B,GAAG,iBAAiB,CAU9I;AAED,eAAO,MAAM,kBAAkB,EAAE,iBAAyE,CAAC"}
|
|
@@ -11,12 +11,15 @@ const PLATFORMS = new Set(["darwin-arm64", "darwin-x64", "linux-arm64", "linux-x
|
|
|
11
11
|
* needs its native companion package, which exists only for the platforms in
|
|
12
12
|
* `PLATFORMS`.
|
|
13
13
|
*/
|
|
14
|
-
export function cursorInstallationFor(platform, arch) {
|
|
14
|
+
export function cursorInstallationFor(platform, arch, execution = "in_process") {
|
|
15
15
|
const snapshot = PLATFORMS.has(`${platform}-${arch}`)
|
|
16
16
|
? { kind: "available", via: "bundled" }
|
|
17
17
|
: { kind: "unsupported", reason: `@cursor/sdk has no native package for ${platform}-${arch}` };
|
|
18
18
|
return async (options = {}) => {
|
|
19
|
-
|
|
19
|
+
// In subprocess mode a session's environment is the child's; this probe reads none either way.
|
|
20
|
+
if (execution === "in_process") {
|
|
21
|
+
refuseReaderEnvironment(options.env, "Cursor installation probes the host SDK");
|
|
22
|
+
}
|
|
20
23
|
await Promise.resolve();
|
|
21
24
|
return snapshot;
|
|
22
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installation.js","sources":["../../../src/runtimes/cursor/installation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAG7E,+EAA+E;AAC/E,MAAM,SAAS,GAAwB,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE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