@cursor/july 0.1.89 → 0.1.90
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 +95 -94
- package/dist/ab.d.ts +1 -1
- package/dist/ab.js +1 -1
- package/dist/artifacts.d.ts +1 -1
- package/dist/artifacts.js +1 -1
- package/dist/bin/agent-serve.js +20 -7
- package/dist/channels.d.ts +1 -1
- package/dist/channels.js +1 -1
- package/dist/connections.d.ts +1 -1
- package/dist/connections.js +1 -1
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +3 -3
- package/dist/docs/assets/{app.DUOPbN18.js → app.wiNkt6G7.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.FV0R6kOb.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.CmWbGcGk.js → VPLocalSearchBox.ByhUGu47.js} +1 -1
- package/dist/docs/assets/chunks/{theme.S57OeOLA.js → theme.Dx7j_-0n.js} +2 -2
- package/dist/docs/assets/{concepts.md.BXAm6G-C.js → concepts.md.2NfkGjqM.js} +1 -1
- package/dist/docs/assets/{reference_project-layout.md.D3MdHM2z.js → reference_project-layout.md.CueaKpjr.js} +5 -20
- package/dist/docs/assets/reference_project-layout.md.CueaKpjr.lean.js +1 -0
- package/dist/docs/assets/{reference_tools.md.DTg_kEsx.js → reference_tools.md.XmeFP_3d.js} +23 -2
- package/dist/docs/assets/{reference_tools.md.DTg_kEsx.lean.js → reference_tools.md.XmeFP_3d.lean.js} +1 -1
- package/dist/docs/assets/{scaffolding-agents.md.CiGsJ1aw.js → scaffolding-agents.md.BpMFXv2J.js} +1 -1
- package/dist/docs/building-with-agents.html +3 -3
- package/dist/docs/concepts.html +5 -5
- package/dist/docs/deployment.html +3 -3
- package/dist/docs/evals.html +3 -3
- package/dist/docs/example-agents/approval-buddy.html +3 -3
- package/dist/docs/example-agents/benny.html +3 -3
- package/dist/docs/example-agents/bugbot.html +3 -3
- package/dist/docs/example-agents/codebase-wiki.html +3 -3
- package/dist/docs/example-agents/codeowners-review.html +3 -3
- package/dist/docs/example-agents/concierge.html +3 -3
- package/dist/docs/example-agents/fsd.html +3 -3
- package/dist/docs/example-agents/index.html +3 -3
- package/dist/docs/example-agents/knowledge-base.html +3 -3
- package/dist/docs/example-agents/oncall.html +3 -3
- package/dist/docs/example-agents/security-reviewer.html +3 -3
- package/dist/docs/example-agents/slack-agent.html +3 -3
- package/dist/docs/example-agents/weather-agent.html +3 -3
- package/dist/docs/guides/agent-to-agent.html +3 -3
- package/dist/docs/guides/cloud-runtime.html +3 -3
- package/dist/docs/guides/convert-automation.html +3 -3
- package/dist/docs/guides/github.html +3 -3
- package/dist/docs/guides/human-in-the-loop.html +3 -3
- package/dist/docs/guides/mcp-oauth.html +3 -3
- package/dist/docs/guides/opentelemetry.html +3 -3
- package/dist/docs/guides/slack.html +3 -3
- package/dist/docs/guides/webhooks.html +3 -3
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +3 -3
- package/dist/docs/index.html +3 -3
- package/dist/docs/quickstart.html +3 -3
- package/dist/docs/reference/agent-config.html +3 -3
- package/dist/docs/reference/artifacts.html +3 -3
- package/dist/docs/reference/channels.html +3 -3
- package/dist/docs/reference/cli.html +3 -3
- package/dist/docs/reference/connections.html +3 -3
- package/dist/docs/reference/hooks.html +3 -3
- package/dist/docs/reference/http-api.html +3 -3
- package/dist/docs/reference/instructions.html +3 -3
- package/dist/docs/reference/playground.html +3 -3
- package/dist/docs/reference/project-layout.html +8 -23
- package/dist/docs/reference/prompt.html +3 -3
- package/dist/docs/reference/schedules.html +3 -3
- package/dist/docs/reference/sessions.html +3 -3
- package/dist/docs/reference/skills.html +3 -3
- package/dist/docs/reference/subagents.html +3 -3
- package/dist/docs/reference/tools.html +27 -6
- package/dist/docs/scaffolding-agents.html +5 -5
- package/dist/docs/storage.html +3 -3
- package/dist/docs/templates/agentic-owners.html +3 -3
- package/dist/docs/templates/demo.html +3 -3
- package/dist/docs/templates/pr-autofixer.html +3 -3
- package/dist/docs/templates/security-reviewer.html +3 -3
- package/dist/docs/templates/triage.html +3 -3
- package/dist/docs/troubleshooting.html +3 -3
- package/dist/evals.d.ts +1 -1
- package/dist/evals.js +1 -1
- package/dist/hooks.d.ts +1 -1
- package/dist/hooks.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/internal/cli-convert-automation.d.ts +1 -1
- package/dist/internal/cli-convert-automation.js +1 -1
- package/dist/internal/cli-cursor.d.ts +12 -4
- package/dist/internal/cli-cursor.d.ts.map +1 -1
- package/dist/internal/cli-cursor.js +11 -4
- package/dist/internal/convert-automation/convert-workflow.d.ts +1 -1
- package/dist/internal/convert-automation/convert-workflow.js +9 -9
- package/dist/internal/convert-automation/types.d.ts +1 -1
- package/dist/internal/convert-automation/types.js +1 -1
- package/dist/internal/cursor/backend-client.d.ts +9 -1
- package/dist/internal/cursor/backend-client.d.ts.map +1 -1
- package/dist/internal/cursor/backend-client.js +19 -6
- package/dist/internal/cursor/credentials.d.ts +35 -9
- package/dist/internal/cursor/credentials.d.ts.map +1 -1
- package/dist/internal/cursor/credentials.js +92 -39
- package/dist/internal/discovery.js +1 -1
- package/dist/internal/distribution.d.ts +18 -0
- package/dist/internal/distribution.d.ts.map +1 -1
- package/dist/internal/distribution.js +19 -0
- package/dist/internal/eval-runner.js +1 -1
- package/dist/internal/grokbot/runner.d.ts +5 -2
- package/dist/internal/grokbot/runner.d.ts.map +1 -1
- package/dist/internal/grokbot/runner.js +10 -6
- package/dist/internal/init-project.d.ts.map +1 -1
- package/dist/internal/init-project.js +8 -1
- package/dist/internal/sdk-runner.d.ts +5 -0
- package/dist/internal/sdk-runner.d.ts.map +1 -1
- package/dist/internal/sdk-runner.js +10 -5
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +80 -36
- package/dist/playground/assets/index-BpVS-paP.css +1 -0
- package/dist/playground/index.html +2 -2
- package/dist/reminders.d.ts +1 -1
- package/dist/reminders.js +1 -1
- package/dist/schedules.d.ts +1 -1
- package/dist/schedules.js +1 -1
- package/dist/skills.d.ts +1 -1
- package/dist/skills.js +1 -1
- package/dist/storage.d.ts +1 -1
- package/dist/storage.js +1 -1
- package/dist/tools.d.ts +1 -1
- package/dist/tools.js +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/docs/concepts.md +2 -1
- package/docs/reference/project-layout.md +5 -20
- package/docs/reference/tools.md +53 -3
- package/docs/scaffolding-agents.md +2 -0
- package/package.json +2 -1
- package/src/ab.ts +1 -1
- package/src/artifacts.ts +1 -1
- package/src/bin/agent-serve.ts +20 -6
- package/src/channels.ts +1 -1
- package/src/connections.ts +1 -1
- package/src/evals.ts +1 -1
- package/src/hooks.ts +1 -1
- package/src/index.ts +2 -2
- package/src/internal/cli-convert-automation.ts +1 -1
- package/src/internal/cli-cursor.ts +18 -5
- package/src/internal/convert-automation/convert-workflow.ts +9 -9
- package/src/internal/convert-automation/types.ts +1 -1
- package/src/internal/cursor/backend-client.ts +29 -4
- package/src/internal/cursor/credentials.ts +87 -24
- package/src/internal/discovery.ts +1 -1
- package/src/internal/distribution.ts +31 -0
- package/src/internal/eval-runner.ts +1 -1
- package/src/internal/grokbot/runner.ts +15 -6
- package/src/internal/init-project.ts +11 -1
- package/src/internal/sdk-runner.ts +10 -4
- package/src/internal/server.ts +95 -33
- package/src/reminders.ts +1 -1
- package/src/schedules.ts +1 -1
- package/src/skills.ts +1 -1
- package/src/storage.ts +1 -1
- package/src/tools.ts +1 -1
- package/src/types.ts +2 -2
- package/dist/docs/assets/chunks/@localSearchIndexroot.CxCtxfDE.js +0 -1
- package/dist/docs/assets/reference_project-layout.md.D3MdHM2z.lean.js +0 -1
- package/dist/playground/assets/index-DQGZnAI0.css +0 -1
- /package/dist/docs/assets/{concepts.md.BXAm6G-C.lean.js → concepts.md.2NfkGjqM.lean.js} +0 -0
- /package/dist/docs/assets/{scaffolding-agents.md.CiGsJ1aw.lean.js → scaffolding-agents.md.BpMFXv2J.lean.js} +0 -0
- /package/dist/playground/assets/{index-BmiIjFlM.js → index-DxapiDj_.js} +0 -0
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
* dashboard-revocable user API key — only the key is stored.
|
|
10
10
|
* - `CURSOR_API_KEY` (or `serve({ apiKey })`) wins over the stored key, so
|
|
11
11
|
* CI and hosted deployments stay env-driven.
|
|
12
|
+
* - `CURSOR_API_KEY_FILE` (or the hosted default path) is next: freeze bind
|
|
13
|
+
* drops the key at task time without restarting July.
|
|
14
|
+
* - Stored `july login` is last. Same order for hosted and self-hosted:
|
|
15
|
+
* option → env → file → login.
|
|
12
16
|
*
|
|
13
17
|
* There is deliberately no session-token storage, refresh-token rotation, or
|
|
14
18
|
* cross-tool credential sharing here: short-lived access tokens are minted
|
|
@@ -27,10 +31,11 @@ export declare const DEFAULT_CURSOR_EXTERNAL_API_URL = "https://api.cursor.com";
|
|
|
27
31
|
export declare function cursorBackendUrl(): string;
|
|
28
32
|
/**
|
|
29
33
|
* External API base URL for routes served only by the external-api
|
|
30
|
-
* microlith (`/internal/agent-serve/*`, engine aliases).
|
|
31
|
-
* these are mounted on api.cursor.com and 404 on
|
|
32
|
-
* deploy surface needs its own default.
|
|
33
|
-
* overrides everything for local dev, where
|
|
34
|
+
* microlith (`/internal/agent-serve/*`, `/v0/grokbot/*`, engine aliases).
|
|
35
|
+
* In production these are mounted on api.cursor.com and 404 on
|
|
36
|
+
* api2.cursor.sh, so the deploy surface needs its own default.
|
|
37
|
+
* `CURSOR_API_BASE_URL` still overrides everything for local dev, where
|
|
38
|
+
* one server mounts all routes.
|
|
34
39
|
*/
|
|
35
40
|
export declare function cursorExternalApiUrl(): string;
|
|
36
41
|
/** Website base URL for the login deep link (`CURSOR_WEBSITE_URL` override). */
|
|
@@ -48,20 +53,41 @@ export type StoredCredentials = z.infer<typeof storedCredentialsSchema>;
|
|
|
48
53
|
export declare function configDirPath(): string;
|
|
49
54
|
/** `<configDir>/credentials.json` (0600). */
|
|
50
55
|
export declare function credentialsFilePath(): string;
|
|
56
|
+
export declare function readStoredCredentialsSync(): StoredCredentials | undefined;
|
|
51
57
|
export declare function readStoredCredentials(): Promise<StoredCredentials | undefined>;
|
|
52
58
|
export declare function writeStoredCredentials(credentials: StoredCredentials): Promise<void>;
|
|
53
59
|
export declare function clearStoredCredentials(): Promise<boolean>;
|
|
54
|
-
export type ApiKeySource = "option" | "env" | "login";
|
|
60
|
+
export type ApiKeySource = "option" | "env" | "file" | "login";
|
|
55
61
|
export interface ResolvedApiKey {
|
|
56
62
|
apiKey: string;
|
|
57
63
|
source: ApiKeySource;
|
|
58
64
|
backendUrl: string;
|
|
59
65
|
}
|
|
60
66
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
67
|
+
* Hosted task-bind path. Not a secret: the snapshot may name this path.
|
|
68
|
+
* The binder writes the key here after restore; July re-reads on each use.
|
|
69
|
+
* Override with `CURSOR_API_KEY_FILE`. A missing file is unsigned — self-hosted
|
|
70
|
+
* then uses `CURSOR_API_KEY` or stored login.
|
|
71
|
+
*/
|
|
72
|
+
export declare const DEFAULT_CURSOR_API_KEY_FILE: string;
|
|
73
|
+
/**
|
|
74
|
+
* Read `CURSOR_API_KEY_FILE` (or {@link DEFAULT_CURSOR_API_KEY_FILE} when
|
|
75
|
+
* unset). Missing/empty files are unsigned, not an error — freeze bake
|
|
76
|
+
* listens before the binder drops the key; self-hosted falls through to
|
|
77
|
+
* env or login.
|
|
78
|
+
*/
|
|
79
|
+
export declare function readApiKeyFromFile(filePath?: string): string | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* First present source wins. We define the order; operators do not.
|
|
82
|
+
* `--api-key` / `serve({ apiKey })` → `CURSOR_API_KEY` → `CURSOR_API_KEY_FILE`
|
|
83
|
+
* (hosted default path if unset) → stored `july login`.
|
|
84
|
+
*/
|
|
85
|
+
export declare function resolveApiKeySync(options?: {
|
|
86
|
+
apiKey?: string;
|
|
87
|
+
backendUrl?: string;
|
|
88
|
+
}): ResolvedApiKey | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* {@link resolveApiKeySync} as a Promise for call sites that already await.
|
|
65
91
|
*/
|
|
66
92
|
export declare function resolveApiKey(options?: {
|
|
67
93
|
apiKey?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../src/internal/cursor/credentials.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../src/internal/cursor/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAOH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,0BAA0B,2BAA2B,CAAC;AACnE,eAAO,MAAM,+BAA+B,2BAA2B,CAAC;AAGxE;;;;;;GAMG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAMzC;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAI7C;AAED,gFAAgF;AAChF,wBAAgB,gBAAgB,IAAI,MAAM,CAIzC;AAUD,QAAA,MAAM,uBAAuB,EAAE,CAAC,CAAC,SAAS,CACxC;IAAE,UAAU,EAAE,CAAC,CAAC,SAAS,CAAC;IAAC,MAAM,EAAE,CAAC,CAAC,SAAS,CAAA;CAAE,EAChD,OAAO,CAKP,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAQtC;AAED,6CAA6C;AAC7C,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAqBD,wBAAgB,yBAAyB,IAAI,iBAAiB,GAAG,SAAS,CAQzE;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CACpD,iBAAiB,GAA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AM,CAAA;CAAE,GAC5C;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,GACvB;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,GACvB;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1C;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,2CAA2C;IAC3C,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,uEAAuE;IACvE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,eAAe,CAAC,CAmG3B"}
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
* dashboard-revocable user API key — only the key is stored.
|
|
10
10
|
* - `CURSOR_API_KEY` (or `serve({ apiKey })`) wins over the stored key, so
|
|
11
11
|
* CI and hosted deployments stay env-driven.
|
|
12
|
+
* - `CURSOR_API_KEY_FILE` (or the hosted default path) is next: freeze bind
|
|
13
|
+
* drops the key at task time without restarting July.
|
|
14
|
+
* - Stored `july login` is last. Same order for hosted and self-hosted:
|
|
15
|
+
* option → env → file → login.
|
|
12
16
|
*
|
|
13
17
|
* There is deliberately no session-token storage, refresh-token rotation, or
|
|
14
18
|
* cross-tool credential sharing here: short-lived access tokens are minted
|
|
@@ -24,6 +28,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
24
28
|
});
|
|
25
29
|
};
|
|
26
30
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
31
|
+
import { readFileSync } from "node:fs";
|
|
27
32
|
import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
28
33
|
import { homedir } from "node:os";
|
|
29
34
|
import { dirname, join } from "node:path";
|
|
@@ -45,10 +50,11 @@ export function cursorBackendUrl() {
|
|
|
45
50
|
}
|
|
46
51
|
/**
|
|
47
52
|
* External API base URL for routes served only by the external-api
|
|
48
|
-
* microlith (`/internal/agent-serve/*`, engine aliases).
|
|
49
|
-
* these are mounted on api.cursor.com and 404 on
|
|
50
|
-
* deploy surface needs its own default.
|
|
51
|
-
* overrides everything for local dev, where
|
|
53
|
+
* microlith (`/internal/agent-serve/*`, `/v0/grokbot/*`, engine aliases).
|
|
54
|
+
* In production these are mounted on api.cursor.com and 404 on
|
|
55
|
+
* api2.cursor.sh, so the deploy surface needs its own default.
|
|
56
|
+
* `CURSOR_API_BASE_URL` still overrides everything for local dev, where
|
|
57
|
+
* one server mounts all routes.
|
|
52
58
|
*/
|
|
53
59
|
export function cursorExternalApiUrl() {
|
|
54
60
|
var _a;
|
|
@@ -83,6 +89,33 @@ export function configDirPath() {
|
|
|
83
89
|
export function credentialsFilePath() {
|
|
84
90
|
return join(configDirPath(), "credentials.json");
|
|
85
91
|
}
|
|
92
|
+
function parseStoredCredentialsJson(raw) {
|
|
93
|
+
let parsed;
|
|
94
|
+
try {
|
|
95
|
+
parsed = JSON.parse(raw);
|
|
96
|
+
}
|
|
97
|
+
catch (_a) {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
const credentials = storedCredentialsSchema.safeParse(parsed);
|
|
101
|
+
if (!credentials.success) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
backendUrl: trimTrailingSlash(credentials.data.backendUrl),
|
|
106
|
+
apiKey: credentials.data.apiKey,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export function readStoredCredentialsSync() {
|
|
110
|
+
let raw;
|
|
111
|
+
try {
|
|
112
|
+
raw = readFileSync(credentialsFilePath(), "utf8");
|
|
113
|
+
}
|
|
114
|
+
catch (_a) {
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
return parseStoredCredentialsJson(raw);
|
|
118
|
+
}
|
|
86
119
|
export function readStoredCredentials() {
|
|
87
120
|
return __awaiter(this, void 0, void 0, function* () {
|
|
88
121
|
let raw;
|
|
@@ -92,22 +125,7 @@ export function readStoredCredentials() {
|
|
|
92
125
|
catch (_a) {
|
|
93
126
|
return undefined;
|
|
94
127
|
}
|
|
95
|
-
|
|
96
|
-
try {
|
|
97
|
-
parsed = JSON.parse(raw);
|
|
98
|
-
}
|
|
99
|
-
catch (_b) {
|
|
100
|
-
// Corrupt file — treat as signed out; login rewrites it.
|
|
101
|
-
return undefined;
|
|
102
|
-
}
|
|
103
|
-
const credentials = storedCredentialsSchema.safeParse(parsed);
|
|
104
|
-
if (!credentials.success) {
|
|
105
|
-
return undefined;
|
|
106
|
-
}
|
|
107
|
-
return {
|
|
108
|
-
backendUrl: trimTrailingSlash(credentials.data.backendUrl),
|
|
109
|
-
apiKey: credentials.data.apiKey,
|
|
110
|
-
};
|
|
128
|
+
return parseStoredCredentialsJson(raw);
|
|
111
129
|
});
|
|
112
130
|
}
|
|
113
131
|
export function writeStoredCredentials(credentials) {
|
|
@@ -133,31 +151,66 @@ export function clearStoredCredentials() {
|
|
|
133
151
|
});
|
|
134
152
|
}
|
|
135
153
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
154
|
+
* Hosted task-bind path. Not a secret: the snapshot may name this path.
|
|
155
|
+
* The binder writes the key here after restore; July re-reads on each use.
|
|
156
|
+
* Override with `CURSOR_API_KEY_FILE`. A missing file is unsigned — self-hosted
|
|
157
|
+
* then uses `CURSOR_API_KEY` or stored login.
|
|
158
|
+
*/
|
|
159
|
+
export const DEFAULT_CURSOR_API_KEY_FILE = "/run/cursor/secrets/CURSOR_API_KEY";
|
|
160
|
+
/**
|
|
161
|
+
* Read `CURSOR_API_KEY_FILE` (or {@link DEFAULT_CURSOR_API_KEY_FILE} when
|
|
162
|
+
* unset). Missing/empty files are unsigned, not an error — freeze bake
|
|
163
|
+
* listens before the binder drops the key; self-hosted falls through to
|
|
164
|
+
* env or login.
|
|
165
|
+
*/
|
|
166
|
+
export function readApiKeyFromFile(filePath) {
|
|
167
|
+
const configured = filePath !== null && filePath !== void 0 ? filePath : process.env.CURSOR_API_KEY_FILE;
|
|
168
|
+
const path = configured !== undefined && configured.trim() !== ""
|
|
169
|
+
? configured.trim()
|
|
170
|
+
: DEFAULT_CURSOR_API_KEY_FILE;
|
|
171
|
+
try {
|
|
172
|
+
const raw = readFileSync(path, "utf8").trim();
|
|
173
|
+
return raw === "" ? undefined : raw;
|
|
174
|
+
}
|
|
175
|
+
catch (_a) {
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* First present source wins. We define the order; operators do not.
|
|
181
|
+
* `--api-key` / `serve({ apiKey })` → `CURSOR_API_KEY` → `CURSOR_API_KEY_FILE`
|
|
182
|
+
* (hosted default path if unset) → stored `july login`.
|
|
183
|
+
*/
|
|
184
|
+
export function resolveApiKeySync(options) {
|
|
185
|
+
var _a;
|
|
186
|
+
const backendUrl = (_a = options === null || options === void 0 ? void 0 : options.backendUrl) !== null && _a !== void 0 ? _a : cursorBackendUrl();
|
|
187
|
+
if ((options === null || options === void 0 ? void 0 : options.apiKey) !== undefined && options.apiKey.trim() !== "") {
|
|
188
|
+
return { apiKey: options.apiKey.trim(), source: "option", backendUrl };
|
|
189
|
+
}
|
|
190
|
+
const envKey = process.env.CURSOR_API_KEY;
|
|
191
|
+
if (envKey !== undefined && envKey.trim() !== "") {
|
|
192
|
+
return { apiKey: envKey.trim(), source: "env", backendUrl };
|
|
193
|
+
}
|
|
194
|
+
const fileKey = readApiKeyFromFile();
|
|
195
|
+
if (fileKey !== undefined) {
|
|
196
|
+
return { apiKey: fileKey, source: "file", backendUrl };
|
|
197
|
+
}
|
|
198
|
+
const stored = readStoredCredentialsSync();
|
|
199
|
+
if (stored !== undefined && stored.backendUrl === backendUrl) {
|
|
200
|
+
return { apiKey: stored.apiKey, source: "login", backendUrl };
|
|
201
|
+
}
|
|
202
|
+
return undefined;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* {@link resolveApiKeySync} as a Promise for call sites that already await.
|
|
140
206
|
*/
|
|
141
207
|
export function resolveApiKey(options) {
|
|
142
208
|
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
-
|
|
144
|
-
const backendUrl = (_a = options === null || options === void 0 ? void 0 : options.backendUrl) !== null && _a !== void 0 ? _a : cursorBackendUrl();
|
|
145
|
-
if ((options === null || options === void 0 ? void 0 : options.apiKey) !== undefined && options.apiKey.trim() !== "") {
|
|
146
|
-
return { apiKey: options.apiKey.trim(), source: "option", backendUrl };
|
|
147
|
-
}
|
|
148
|
-
const envKey = process.env.CURSOR_API_KEY;
|
|
149
|
-
if (envKey !== undefined && envKey.trim() !== "") {
|
|
150
|
-
return { apiKey: envKey.trim(), source: "env", backendUrl };
|
|
151
|
-
}
|
|
152
|
-
const stored = yield readStoredCredentials();
|
|
153
|
-
if (stored !== undefined && stored.backendUrl === backendUrl) {
|
|
154
|
-
return { apiKey: stored.apiKey, source: "login", backendUrl };
|
|
155
|
-
}
|
|
156
|
-
return undefined;
|
|
209
|
+
return resolveApiKeySync(options);
|
|
157
210
|
});
|
|
158
211
|
}
|
|
159
212
|
/** One-line hint for "no credentials" errors, shared across surfaces. */
|
|
160
|
-
export const SIGN_IN_HINT = `Run \`${CLI_COMMAND_NAME} login\` (or set CURSOR_API_KEY / pass serve({ apiKey })).`;
|
|
213
|
+
export const SIGN_IN_HINT = `Run \`${CLI_COMMAND_NAME} login\` (or set CURSOR_API_KEY / CURSOR_API_KEY_FILE / pass serve({ apiKey })).`;
|
|
161
214
|
// ============================================================================
|
|
162
215
|
// PKCE browser login (mirrors cursor-agent / Sand)
|
|
163
216
|
// ============================================================================
|
|
@@ -1620,7 +1620,7 @@ function loadABConfig(ctx, agentDir) {
|
|
|
1620
1620
|
ctx.diagnostics.push({
|
|
1621
1621
|
severity: "error",
|
|
1622
1622
|
path: displayPath(ctx, path),
|
|
1623
|
-
message: "ab.config.ts must default-export defineABConfig({ ... }) from @
|
|
1623
|
+
message: "ab.config.ts must default-export defineABConfig({ ... }) from @cursor/july/ab.",
|
|
1624
1624
|
});
|
|
1625
1625
|
return undefined;
|
|
1626
1626
|
}
|
|
@@ -44,6 +44,24 @@ export declare function isCompiledDistribution(): boolean;
|
|
|
44
44
|
export declare function packageRootDir(): string;
|
|
45
45
|
/** Version of the running package (from its own package.json). */
|
|
46
46
|
export declare function packageVersion(): string;
|
|
47
|
+
/** Facts `agent-sdk version` / `--version` print. */
|
|
48
|
+
export interface CliVersionInfo {
|
|
49
|
+
/** Published npm name (`@cursor/july`). */
|
|
50
|
+
name: string;
|
|
51
|
+
/** `package.json` version of this install. */
|
|
52
|
+
version: string;
|
|
53
|
+
/** Bin the process was invoked as (`agent-sdk` / `agent-serve`). */
|
|
54
|
+
cli: string;
|
|
55
|
+
}
|
|
56
|
+
export declare function cliVersionInfo(): CliVersionInfo;
|
|
57
|
+
/**
|
|
58
|
+
* Text or JSON for `version` / `--version` / `-V`.
|
|
59
|
+
* Text is the bare `package.json` version (npm-style). `--json` is the
|
|
60
|
+
* complete `{ name, version, cli }` payload.
|
|
61
|
+
*/
|
|
62
|
+
export declare function formatCliVersion(options?: {
|
|
63
|
+
json?: boolean;
|
|
64
|
+
}): string;
|
|
47
65
|
/**
|
|
48
66
|
* Authoring entry subpaths and their dist-relative output files — the
|
|
49
67
|
* runtime mirror of the package `exports` map (the source of truth;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distribution.d.ts","sourceRoot":"","sources":["../../src/internal/distribution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,sEAAsE;AACtE,eAAO,MAAM,YAAY,iBAAiB,CAAC;AA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AAM,CAOvC;AAED,qDAAqD;AACrD,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,cAAc,IAAI,cAAc,CAM/C;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAMrE;AAED;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAC/C,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CA2BzC,CAAC"}
|
|
@@ -67,6 +67,25 @@ export function packageVersion() {
|
|
|
67
67
|
const parsed = JSON.parse(raw);
|
|
68
68
|
return typeof parsed.version === "string" ? parsed.version : "0.0.0";
|
|
69
69
|
}
|
|
70
|
+
export function cliVersionInfo() {
|
|
71
|
+
return {
|
|
72
|
+
name: PACKAGE_NAME,
|
|
73
|
+
version: packageVersion(),
|
|
74
|
+
cli: CLI_COMMAND_NAME,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Text or JSON for `version` / `--version` / `-V`.
|
|
79
|
+
* Text is the bare `package.json` version (npm-style). `--json` is the
|
|
80
|
+
* complete `{ name, version, cli }` payload.
|
|
81
|
+
*/
|
|
82
|
+
export function formatCliVersion(options) {
|
|
83
|
+
const info = cliVersionInfo();
|
|
84
|
+
if ((options === null || options === void 0 ? void 0 : options.json) === true) {
|
|
85
|
+
return `${JSON.stringify(info, null, 2)}\n`;
|
|
86
|
+
}
|
|
87
|
+
return `${info.version}\n`;
|
|
88
|
+
}
|
|
70
89
|
/**
|
|
71
90
|
* Authoring entry subpaths and their dist-relative output files — the
|
|
72
91
|
* runtime mirror of the package `exports` map (the source of truth;
|
|
@@ -324,7 +324,7 @@ export function groupEvalsForIterationSchedule(evals) {
|
|
|
324
324
|
function resolveEvalMaxConcurrency(config) {
|
|
325
325
|
if (config.maxConcurrency === undefined) {
|
|
326
326
|
throw new Error(`evals/evals.config.ts must define maxConcurrency (1–${EVAL_MAX_CONCURRENCY_LIMIT}; hard limit is due to model provider request limits). Example:\n` +
|
|
327
|
-
` import { defineEvalConfig } from "@
|
|
327
|
+
` import { defineEvalConfig } from "@cursor/july/evals";\n` +
|
|
328
328
|
` export default defineEvalConfig({ maxConcurrency: 20 });`);
|
|
329
329
|
}
|
|
330
330
|
return normalizeEvalMaxConcurrency(config.maxConcurrency);
|
|
@@ -13,11 +13,14 @@
|
|
|
13
13
|
import type { RunnerTurnRequest, TurnOutcome } from "../../types.js";
|
|
14
14
|
import type { AgentRunner } from "./../sdk-runner.js";
|
|
15
15
|
export interface GrokBotRunnerOptions {
|
|
16
|
-
/** Cursor API key.
|
|
16
|
+
/** Cursor API key. Resolved as option → env → file → stored login. */
|
|
17
17
|
apiKey?: string;
|
|
18
18
|
/** Test seam. Defaults to global fetch. */
|
|
19
19
|
fetchImpl?: typeof fetch;
|
|
20
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Test seam. Defaults to {@link cursorExternalApiUrl} (`api.cursor.com`).
|
|
22
|
+
* `/v0/grokbot` is an external-api microlith route — it 404s on api2.
|
|
23
|
+
*/
|
|
21
24
|
backendUrl?: string;
|
|
22
25
|
/** Test seam. Poll interval while a turn runs. */
|
|
23
26
|
pollIntervalMs?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../src/internal/grokbot/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../src/internal/grokbot/runner.ts"],"names":[],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
20
|
});
|
|
21
21
|
};
|
|
22
22
|
import { randomUUID } from "node:crypto";
|
|
23
|
-
import {
|
|
23
|
+
import { cursorExternalApiUrl, resolveApiKeySync, } from "../cursor/credentials.js";
|
|
24
24
|
const DEFAULT_POLL_INTERVAL_MS = 750;
|
|
25
25
|
const DEFAULT_TURN_TIMEOUT_MS = 20 * 60 * 1000;
|
|
26
26
|
/**
|
|
@@ -40,12 +40,16 @@ class GrokBotApiError extends Error {
|
|
|
40
40
|
/** Minimal `/v0/grokbot` client: bearer API key, JSON in/out. */
|
|
41
41
|
class GrokBotApiClient {
|
|
42
42
|
constructor(options) {
|
|
43
|
-
var _a
|
|
44
|
-
|
|
45
|
-
this.
|
|
46
|
-
|
|
43
|
+
var _a;
|
|
44
|
+
var _b, _c;
|
|
45
|
+
this.fetchImpl = (_b = options.fetchImpl) !== null && _b !== void 0 ? _b : fetch;
|
|
46
|
+
this.baseUrl = ((_c = options.backendUrl) !== null && _c !== void 0 ? _c : cursorExternalApiUrl()).replace(/\/$/, "");
|
|
47
|
+
const apiKey = (_a = resolveApiKeySync({
|
|
48
|
+
apiKey: options.apiKey,
|
|
49
|
+
backendUrl: options.backendUrl,
|
|
50
|
+
})) === null || _a === void 0 ? void 0 : _a.apiKey;
|
|
47
51
|
if (apiKey === undefined || apiKey === "") {
|
|
48
|
-
throw new Error('runtime: "grokbot" needs a Cursor API key (CURSOR_API_KEY or agent-sdk login) to reach the hosted Grok Bot harness.');
|
|
52
|
+
throw new Error('runtime: "grokbot" needs a Cursor API key (CURSOR_API_KEY, CURSOR_API_KEY_FILE, or agent-sdk login) to reach the hosted Grok Bot harness.');
|
|
49
53
|
}
|
|
50
54
|
this.apiKey = apiKey;
|
|
51
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-project.d.ts","sourceRoot":"","sources":["../../src/internal/init-project.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"init-project.d.ts","sourceRoot":"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GG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAgBzE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,CAErE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,SAAS,CAQpB;AA8BD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;CACpB,GAAG,MAAM,EAAE,CAEX;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAgCrC"}
|
|
@@ -14,6 +14,7 @@ import { spawn } from "node:child_process";
|
|
|
14
14
|
import { existsSync } from "node:fs";
|
|
15
15
|
import { mkdir, readdir, readFile, writeFile } from "node:fs/promises";
|
|
16
16
|
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
17
|
+
import { runfiles } from "@bazel/runfiles";
|
|
17
18
|
import { canonicalTemplateName, isTemplateName, readCursorAgentTemplate, } from "./cursor-agent-template.js";
|
|
18
19
|
import { CLI_COMMAND_NAME, PACKAGE_NAME, packageRootDir, packageVersion, } from "./distribution.js";
|
|
19
20
|
import { applyInitReplacements, isTemplateMetaPath, loadTemplateInitSpec, posixRel, templateFileHasReplacements, } from "./init-interview.js";
|
|
@@ -45,7 +46,7 @@ export function resolveTemplate(name) {
|
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
48
|
const entry = TEMPLATES[resolved];
|
|
48
|
-
const dir =
|
|
49
|
+
const dir = resolvePackagePath("templates", entry.dir);
|
|
49
50
|
return {
|
|
50
51
|
ok: true,
|
|
51
52
|
name: resolved,
|
|
@@ -55,6 +56,12 @@ export function resolveTemplate(name) {
|
|
|
55
56
|
: join(dir, "overlays", entry.overlay),
|
|
56
57
|
};
|
|
57
58
|
}
|
|
59
|
+
function resolvePackagePath(...segments) {
|
|
60
|
+
if (runfiles.workspace !== undefined) {
|
|
61
|
+
return runfiles.resolveWorkspaceRelative(["packages", "agent-serve", ...segments].join("/"));
|
|
62
|
+
}
|
|
63
|
+
return join(packageRootDir(), ...segments);
|
|
64
|
+
}
|
|
58
65
|
/**
|
|
59
66
|
* Re-init must keep the mode the project was scaffolded with: template
|
|
60
67
|
* scaffolds stamp `cursorAgentTemplate` into package.json, and a mismatch
|
|
@@ -95,6 +95,11 @@ export declare class CursorSdkRunner implements AgentRunner {
|
|
|
95
95
|
*/
|
|
96
96
|
private evictAgent;
|
|
97
97
|
private log;
|
|
98
|
+
/**
|
|
99
|
+
* Re-resolve on every turn. Hosted freeze snapshots listen unsigned; the
|
|
100
|
+
* binder drops `CURSOR_API_KEY` / `CURSOR_API_KEY_FILE` at task time into
|
|
101
|
+
* the already-running process, which must not have closed over `undefined`.
|
|
102
|
+
*/
|
|
98
103
|
private requireApiKey;
|
|
99
104
|
private buildSharedOptions;
|
|
100
105
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-runner.d.ts","sourceRoot":"","sources":["../../src/internal/sdk-runner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAOL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,SAAS,EAEf,MAAM,aAAa,CAAC;AAErB,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAEjB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk-runner.d.ts","sourceRoot":"","sources":["../../src/internal/sdk-runner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAOL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,SAAS,EAEf,MAAM,aAAa,CAAC;AAErB,OAAO,EAEL,KAAK,Y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19
19
|
import { SqliteLocalAgentStore } from "@cursor/sdk/sqlite";
|
|
20
20
|
import { DEFAULT_MODEL, } from "../types.js";
|
|
21
21
|
import { mapSdkTokenUsage, usageTokenSum } from "./cloud-turn-cost.js";
|
|
22
|
+
import { resolveApiKeySync } from "./cursor/credentials.js";
|
|
22
23
|
/**
|
|
23
24
|
* How long a non-`--dev` serve holds workspace scans (rules, skills,
|
|
24
25
|
* `AGENTS.md`, ignore files). The SDK default is 20s for an editor whose
|
|
@@ -306,13 +307,17 @@ export class CursorSdkRunner {
|
|
|
306
307
|
var _a;
|
|
307
308
|
((_a = this.options.logger) !== null && _a !== void 0 ? _a : (() => { }))(line);
|
|
308
309
|
}
|
|
310
|
+
/**
|
|
311
|
+
* Re-resolve on every turn. Hosted freeze snapshots listen unsigned; the
|
|
312
|
+
* binder drops `CURSOR_API_KEY` / `CURSOR_API_KEY_FILE` at task time into
|
|
313
|
+
* the already-running process, which must not have closed over `undefined`.
|
|
314
|
+
*/
|
|
309
315
|
requireApiKey() {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
throw new Error("The Cursor SDK runner requires a Cursor credential: run `agent-serve login`, set CURSOR_API_KEY, or pass serve({ apiKey }).");
|
|
316
|
+
const resolved = resolveApiKeySync({ apiKey: this.options.apiKey });
|
|
317
|
+
if (resolved === undefined) {
|
|
318
|
+
throw new Error("The Cursor SDK runner requires a Cursor credential: run `agent-serve login`, set CURSOR_API_KEY or CURSOR_API_KEY_FILE, or pass serve({ apiKey }).");
|
|
314
319
|
}
|
|
315
|
-
return apiKey;
|
|
320
|
+
return resolved.apiKey;
|
|
316
321
|
}
|
|
317
322
|
buildSharedOptions(request) {
|
|
318
323
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/internal/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA0CH,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAOhB,YAAY,EACb,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/internal/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA0CH,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAOhB,YAAY,EACb,MAAM,aAAa,CAAC;AA4HrB,OAAO,EAAE,KAAK,WAAW,EAAmB,MAAM,iBAAiB,CAAC;AAwBpE,8EAA8E;AAC9E,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,CAAC;CACvB;AAmCD,6EAA6E;AAC7E,MAAM,WAAW,0BAA0B;IACzC,oEAAoE;IACpE,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,UAAU,EAAE,EACpB,OAAO,GAAE,YAAY,GAAG,0BAA+B,GACtD,OAAO,CAAC,gBAAgB,CAAC,CAo8B3B"}
|