agent-lyceum 0.42.2 → 0.44.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/dist/quota.js CHANGED
@@ -1,4 +1,15 @@
1
- import { spawn } from "node:child_process";
1
+ import { execFile, spawn } from "node:child_process";
2
+ import fs from "node:fs";
3
+ import { createRequire } from "node:module";
4
+ import os from "node:os";
5
+ import path from "node:path";
6
+ import { cursorConfigDir } from "./adapters/cursor.js";
7
+ /** Run a short local lookup without blocking the web server's event loop (5 s cap). */
8
+ function execText(cmd, args) {
9
+ return new Promise((resolve, reject) => {
10
+ execFile(cmd, args, { encoding: "utf8", timeout: 5_000 }, (error, stdout) => (error ? reject(error) : resolve(stdout)));
11
+ });
12
+ }
2
13
  export function parseClaudeUsage(text) {
3
14
  const session = text.match(/Current session:\s*(\d+(?:\.\d+)?)%\s*used\s*·\s*resets\s+(.+)/);
4
15
  const week = text.match(/Current week(?: \([^)]*\))?:\s*(\d+(?:\.\d+)?)%\s*used\s*·\s*resets\s+(.+)/);
@@ -14,7 +25,7 @@ export function codexWindows(limits) {
14
25
  if (!window || window.usedPercent === undefined)
15
26
  return [];
16
27
  const mins = window.windowDurationMins ?? 0;
17
- const resets = window.resetsAt ? new Date(window.resetsAt * 1000).toLocaleString("zh-Hant", { month: "numeric", day: "numeric", hour: "2-digit", minute: "2-digit" }) : "時間不明";
28
+ const resets = window.resetsAt ? formatResets(window.resetsAt * 1000) : "時間不明";
18
29
  return [windowOf(durationLabel(mins), window.usedPercent, resets)];
19
30
  });
20
31
  }
@@ -29,6 +40,9 @@ function durationLabel(mins) {
29
40
  return `${mins / 60} 小時`;
30
41
  return mins > 0 ? `${mins} 分鐘` : "用量";
31
42
  }
43
+ function formatResets(ms) {
44
+ return new Date(ms).toLocaleString("zh-Hant", { month: "numeric", day: "numeric", hour: "2-digit", minute: "2-digit" });
45
+ }
32
46
  function windowOf(label, used, resets) {
33
47
  const usedPercent = roundPercent(used);
34
48
  return { label, used_percent: usedPercent, remaining_percent: roundPercent(Math.max(0, 100 - used)), resets };
@@ -61,6 +75,265 @@ export async function codexQuota(signal) {
61
75
  return { runtime: "codex", windows: [], error: missing("codex", error) };
62
76
  }
63
77
  }
78
+ /** Map DashboardService/GetCurrentPeriodUsage into the shared QuotaWindow shape. */
79
+ export function parseCursorUsage(data) {
80
+ const used = usedPercentOf(data.planUsage);
81
+ if (used === undefined)
82
+ return [];
83
+ const endMs = millis(data.billingCycleEnd);
84
+ const startMs = millis(data.billingCycleStart);
85
+ const resets = endMs === undefined ? "時間不明" : formatResets(endMs);
86
+ return [windowOf(cycleLabel(startMs, endMs), used, resets)];
87
+ }
88
+ /**
89
+ * Candidate tokens, most specific login first: the CLI login (auth.json, then the macOS keychain),
90
+ * CURSOR_API_KEY, then the Cursor IDE session. Read lazily, so a working CLI token never touches the IDE database.
91
+ */
92
+ export async function* cursorAccessTokens(readers = {}) {
93
+ const sources = [
94
+ readers.readCliToken ?? defaultReadCliToken,
95
+ async () => (readers.readEnvApiKey ?? (() => process.env.CURSOR_API_KEY))(),
96
+ readers.readIdeToken ?? defaultReadIdeToken,
97
+ ];
98
+ const seen = new Set();
99
+ for (const read of sources) {
100
+ const token = (await read())?.trim();
101
+ if (!token || seen.has(token))
102
+ continue;
103
+ seen.add(token);
104
+ yield token;
105
+ }
106
+ }
107
+ /** A token the dashboard API refused (401/403): try the next login source instead of giving up. */
108
+ class CursorAuthRejected extends Error {
109
+ }
110
+ export async function cursorQuota(signal, deps = {}) {
111
+ try {
112
+ const fetchUsage = deps.fetchUsage ?? fetchCursorPeriodUsage;
113
+ let rejected;
114
+ for await (const token of (deps.tokens ?? (() => cursorAccessTokens()))()) {
115
+ let data;
116
+ try {
117
+ data = await fetchUsage(token, signal);
118
+ }
119
+ catch (error) {
120
+ if (error instanceof CursorAuthRejected) {
121
+ rejected = error.message;
122
+ continue;
123
+ }
124
+ throw error;
125
+ }
126
+ const windows = parseCursorUsage(data);
127
+ if (windows.length === 0)
128
+ return { runtime: "cursor", windows: [], error: "cursor 沒有回傳額度。" };
129
+ return { runtime: "cursor", windows };
130
+ }
131
+ return {
132
+ runtime: "cursor",
133
+ windows: [],
134
+ error: rejected
135
+ ? `${rejected}:Cursor 登入已失效。請重新執行 agent login。`
136
+ : "Cursor 未登入。請先執行 agent login,或設定 CURSOR_API_KEY。",
137
+ };
138
+ }
139
+ catch (error) {
140
+ if (isAbort(error))
141
+ throw error;
142
+ return { runtime: "cursor", windows: [], error: error.message || "cursor 沒有回傳額度。" };
143
+ }
144
+ }
145
+ function usedPercentOf(plan) {
146
+ if (!plan)
147
+ return undefined;
148
+ if (typeof plan.totalPercentUsed === "number" && Number.isFinite(plan.totalPercentUsed))
149
+ return clampPercent(plan.totalPercentUsed);
150
+ const limit = plan.limit;
151
+ const remaining = plan.remaining;
152
+ if (typeof limit === "number" && limit > 0 && typeof remaining === "number" && Number.isFinite(remaining)) {
153
+ return clampPercent(((limit - remaining) / limit) * 100);
154
+ }
155
+ return undefined;
156
+ }
157
+ /** Bonus credit can push `remaining` above `limit`; overage can push it below 0. */
158
+ function clampPercent(n) {
159
+ return Math.min(100, Math.max(0, n));
160
+ }
161
+ function cycleLabel(startMs, endMs) {
162
+ if (startMs === undefined || endMs === undefined || endMs <= startMs)
163
+ return "計費週期";
164
+ const days = (endMs - startMs) / 86_400_000;
165
+ if (days >= 6 && days <= 8)
166
+ return "本週";
167
+ if (days >= 27 && days <= 32)
168
+ return "本月";
169
+ return "計費週期";
170
+ }
171
+ function millis(value) {
172
+ if (value === undefined || value === null || value === "")
173
+ return undefined;
174
+ const n = typeof value === "number" ? value : Number(value);
175
+ return Number.isFinite(n) ? n : undefined;
176
+ }
177
+ async function defaultReadCliToken() {
178
+ for (const file of cursorAuthJsonPaths()) {
179
+ const token = readAccessTokenFromJsonFile(file);
180
+ if (token)
181
+ return token;
182
+ }
183
+ return readCursorKeychainToken();
184
+ }
185
+ function cursorAuthJsonPaths() {
186
+ const home = os.homedir();
187
+ const paths = [path.join(cursorConfigDir(process.env), "auth.json")];
188
+ if (process.platform === "linux" || process.env.XDG_CONFIG_HOME) {
189
+ paths.push(path.join(process.env.XDG_CONFIG_HOME || path.join(home, ".config"), "cursor", "auth.json"));
190
+ }
191
+ if (process.platform === "win32") {
192
+ const appData = process.env.APPDATA || path.join(home, "AppData", "Roaming");
193
+ paths.push(path.join(appData, "Cursor", "auth.json"));
194
+ }
195
+ return [...new Set(paths)];
196
+ }
197
+ function readAccessTokenFromJsonFile(file) {
198
+ try {
199
+ const raw = JSON.parse(fs.readFileSync(file, "utf8"));
200
+ return typeof raw.accessToken === "string" ? raw.accessToken : undefined;
201
+ }
202
+ catch {
203
+ return undefined;
204
+ }
205
+ }
206
+ /** Cursor Agent CLI stores the session JWT in the macOS keychain as cursor-access-token. */
207
+ async function readCursorKeychainToken() {
208
+ if (process.platform !== "darwin")
209
+ return undefined;
210
+ try {
211
+ const stdout = await execText("security", ["find-generic-password", "-s", "cursor-access-token", "-a", "cursor-user", "-w"]);
212
+ return stdout.trim() || undefined;
213
+ }
214
+ catch {
215
+ return undefined;
216
+ }
217
+ }
218
+ async function defaultReadIdeToken() {
219
+ const dbPath = cursorIdeStateDbPath();
220
+ if (!dbPath || !fs.existsSync(dbPath))
221
+ return undefined;
222
+ const fromNode = readIdeTokenViaNodeSqlite(dbPath);
223
+ if (fromNode)
224
+ return fromNode;
225
+ return readIdeTokenViaSqliteCli(dbPath);
226
+ }
227
+ function cursorIdeStateDbPath() {
228
+ const home = os.homedir();
229
+ if (process.platform === "darwin") {
230
+ return path.join(home, "Library", "Application Support", "Cursor", "User", "globalStorage", "state.vscdb");
231
+ }
232
+ if (process.platform === "win32") {
233
+ const appData = process.env.APPDATA || path.join(home, "AppData", "Roaming");
234
+ return path.join(appData, "Cursor", "User", "globalStorage", "state.vscdb");
235
+ }
236
+ const config = process.env.XDG_CONFIG_HOME || path.join(home, ".config");
237
+ return path.join(config, "Cursor", "User", "globalStorage", "state.vscdb");
238
+ }
239
+ function readIdeTokenViaNodeSqlite(dbPath) {
240
+ try {
241
+ const require = createRequire(import.meta.url);
242
+ const { DatabaseSync } = require("node:sqlite");
243
+ const db = new DatabaseSync(dbPath, { readOnly: true });
244
+ try {
245
+ const row = db.prepare("SELECT value FROM ItemTable WHERE key = ?").get("cursorAuth/accessToken");
246
+ return normalizeSqliteText(row?.value);
247
+ }
248
+ finally {
249
+ db.close();
250
+ }
251
+ }
252
+ catch {
253
+ return undefined;
254
+ }
255
+ }
256
+ async function readIdeTokenViaSqliteCli(dbPath) {
257
+ try {
258
+ const stdout = await execText("sqlite3", ["-readonly", dbPath, "SELECT value FROM ItemTable WHERE key = 'cursorAuth/accessToken';"]);
259
+ return normalizeSqliteText(stdout.trim());
260
+ }
261
+ catch {
262
+ return undefined;
263
+ }
264
+ }
265
+ function normalizeSqliteText(value) {
266
+ if (typeof value !== "string")
267
+ return undefined;
268
+ const trimmed = value.trim();
269
+ if (!trimmed)
270
+ return undefined;
271
+ if (trimmed.startsWith('"') && trimmed.endsWith('"')) {
272
+ try {
273
+ const parsed = JSON.parse(trimmed);
274
+ return typeof parsed === "string" ? parsed : trimmed.slice(1, -1);
275
+ }
276
+ catch {
277
+ return trimmed.slice(1, -1);
278
+ }
279
+ }
280
+ return trimmed;
281
+ }
282
+ const CURSOR_API_DEFAULT = "https://api2.cursor.sh";
283
+ /** CURSOR_API_ENDPOINT may only point at another https Cursor host: the request carries the user's session token. */
284
+ export function cursorApiBase(env = process.env) {
285
+ const raw = env.CURSOR_API_ENDPOINT?.trim();
286
+ if (!raw)
287
+ return CURSOR_API_DEFAULT;
288
+ try {
289
+ const url = new URL(raw);
290
+ const host = url.hostname;
291
+ if (url.protocol === "https:" && (host === "cursor.sh" || host.endsWith(".cursor.sh")))
292
+ return url.origin;
293
+ }
294
+ catch {
295
+ // Not a URL: fall through to the default.
296
+ }
297
+ return CURSOR_API_DEFAULT;
298
+ }
299
+ export async function fetchCursorPeriodUsage(token, signal, timeoutMs = 20_000) {
300
+ // Combined by hand: AbortSignal.any needs Node 20.3, engines allows 20.0.
301
+ const controller = new AbortController();
302
+ const onAbort = () => controller.abort();
303
+ const timer = setTimeout(onAbort, timeoutMs);
304
+ signal?.addEventListener("abort", onAbort, { once: true });
305
+ if (signal?.aborted)
306
+ controller.abort();
307
+ try {
308
+ const response = await fetch(`${cursorApiBase()}/aiserver.v1.DashboardService/GetCurrentPeriodUsage`, {
309
+ method: "POST",
310
+ headers: {
311
+ Authorization: `Bearer ${token}`,
312
+ "Content-Type": "application/json",
313
+ "Connect-Protocol-Version": "1",
314
+ },
315
+ body: "{}",
316
+ signal: controller.signal,
317
+ });
318
+ if (response.status === 401 || response.status === 403)
319
+ throw new CursorAuthRejected(`cursor 額度 API HTTP ${response.status}`);
320
+ if (!response.ok)
321
+ throw new Error(`cursor 額度 API HTTP ${response.status}`);
322
+ return await response.json();
323
+ }
324
+ catch (error) {
325
+ // Hub aborts → AbortError (discard). Own timeout → plain Error (report, keep Claude/Codex).
326
+ if (signal?.aborted)
327
+ throw Object.assign(new Error("The operation was aborted"), { name: "AbortError" });
328
+ if (controller.signal.aborted)
329
+ throw new Error(`cursor 超過 ${Math.round(timeoutMs / 1000)} 秒沒有回應。`);
330
+ throw error;
331
+ }
332
+ finally {
333
+ clearTimeout(timer);
334
+ signal?.removeEventListener("abort", onAbort);
335
+ }
336
+ }
64
337
  /** An aborted quota read is a cancelled request, not a report: callers (the hub) discard it. */
65
338
  function isAbort(error) {
66
339
  return error.name === "AbortError";
@@ -2,6 +2,7 @@ import { execFileSync } from "node:child_process";
2
2
  import fs from "node:fs";
3
3
  import os from "node:os";
4
4
  import path from "node:path";
5
+ import { cursorConfigDir } from "./adapters/cursor.js";
5
6
  import { canonicalPath } from "./paths.js";
6
7
  /**
7
8
  * `canonicalPath` for the sandbox check: a path that is missing (ENOENT/ENOTDIR) falls back to its nearest existing ancestor as
@@ -66,6 +67,7 @@ export function protectedPathsFor(project, agent, deep) {
66
67
  add(project.dir, "project directory");
67
68
  add(path.join(os.homedir(), ".claude"), "Claude Code settings");
68
69
  add(process.env.CODEX_HOME || path.join(os.homedir(), ".codex"), "Codex settings");
70
+ add(cursorConfigDir(), "Cursor settings and login");
69
71
  for (const a of Object.values(project.agents)) {
70
72
  add(a.agentMd, `AGENT.md of ${a.name}`);
71
73
  for (const m of memoryDirs(a))
@@ -142,6 +144,9 @@ export function sandboxRefusal(input, base) {
142
144
  return undefined;
143
145
  }
144
146
  function applied(agent) {
147
+ // Cursor is never OS-sandboxed per path (see enforcementFor): Write rules only, and no network/binding/socket setting is emitted.
148
+ if (agent.runtime === "cursor")
149
+ return { write: "tool-rules", network: "unrestricted", local_binding: "unrestricted", unix_sockets: "unrestricted" };
145
150
  const caps = sandboxCaps(agent);
146
151
  const osOn = osSandboxAvailable();
147
152
  if (!osOn)
package/dist/schema.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import { z } from "zod";
2
- export declare const RUNTIMES: readonly ["claude-code", "codex"];
2
+ export declare const RUNTIMES: readonly ["claude-code", "codex", "cursor"];
3
3
  export type Runtime = (typeof RUNTIMES)[number];
4
4
  /** Union of both runtimes' levels; `validate` rejects the ones a given runtime does not accept. */
5
5
  export declare const EFFORTS: readonly ["minimal", "low", "medium", "high", "xhigh", "max"];
6
6
  export type Effort = (typeof EFFORTS)[number];
7
7
  /** Levels each runtime's CLI accepts (`claude --effort`, codex `model_reasoning_effort`). */
8
8
  export declare const RUNTIME_EFFORTS: Record<Runtime, readonly Effort[]>;
9
+ export declare function isGrokModel(model: string | undefined): boolean;
9
10
  /** Guess the runtime from a model name: Claude aliases/IDs -> claude-code, GPT/o-series/codex names -> codex. */
10
11
  export declare function inferRuntime(model: string | undefined): Runtime | undefined;
11
12
  /** How much of the web an agent may use: nothing, search only, or search plus fetching pages. Unset leaves each runtime's own default alone. */
@@ -25,6 +26,7 @@ export declare const FallbackEntryPartial: z.ZodObject<{
25
26
  runtime: z.ZodOptional<z.ZodEnum<{
26
27
  "claude-code": "claude-code";
27
28
  codex: "codex";
29
+ cursor: "cursor";
28
30
  }>>;
29
31
  model: z.ZodOptional<z.ZodString>;
30
32
  effort: z.ZodOptional<z.ZodEnum<{
@@ -55,6 +57,7 @@ export declare const AgentPartial: z.ZodObject<{
55
57
  runtime: z.ZodOptional<z.ZodEnum<{
56
58
  "claude-code": "claude-code";
57
59
  codex: "codex";
60
+ cursor: "cursor";
58
61
  }>>;
59
62
  model: z.ZodOptional<z.ZodString>;
60
63
  effort: z.ZodOptional<z.ZodEnum<{
@@ -83,6 +86,7 @@ export declare const AgentPartial: z.ZodObject<{
83
86
  runtime: z.ZodOptional<z.ZodEnum<{
84
87
  "claude-code": "claude-code";
85
88
  codex: "codex";
89
+ cursor: "cursor";
86
90
  }>>;
87
91
  model: z.ZodOptional<z.ZodString>;
88
92
  effort: z.ZodOptional<z.ZodEnum<{
@@ -120,6 +124,7 @@ export declare const DispatcherPartial: z.ZodObject<{
120
124
  runtime: z.ZodOptional<z.ZodEnum<{
121
125
  "claude-code": "claude-code";
122
126
  codex: "codex";
127
+ cursor: "cursor";
123
128
  }>>;
124
129
  model: z.ZodOptional<z.ZodString>;
125
130
  effort: z.ZodOptional<z.ZodEnum<{
@@ -141,6 +146,7 @@ export declare const REMOVED_AGENT_KEYS: readonly ["owns"];
141
146
  export declare const ModelTiersPartial: z.ZodObject<{
142
147
  "claude-code": z.ZodOptional<z.ZodArray<z.ZodString>>;
143
148
  codex: z.ZodOptional<z.ZodArray<z.ZodString>>;
149
+ cursor: z.ZodOptional<z.ZodArray<z.ZodString>>;
144
150
  }, z.core.$strict>;
145
151
  export declare const TIERS: readonly ["low", "mid", "high"];
146
152
  export type Tier = (typeof TIERS)[number];
@@ -148,11 +154,13 @@ export declare const GlobalConfig: z.ZodObject<{
148
154
  model_tiers: z.ZodOptional<z.ZodObject<{
149
155
  "claude-code": z.ZodOptional<z.ZodArray<z.ZodString>>;
150
156
  codex: z.ZodOptional<z.ZodArray<z.ZodString>>;
157
+ cursor: z.ZodOptional<z.ZodArray<z.ZodString>>;
151
158
  }, z.core.$strict>>;
152
159
  agents: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
153
160
  runtime: z.ZodOptional<z.ZodEnum<{
154
161
  "claude-code": "claude-code";
155
162
  codex: "codex";
163
+ cursor: "cursor";
156
164
  }>>;
157
165
  model: z.ZodOptional<z.ZodString>;
158
166
  effort: z.ZodOptional<z.ZodEnum<{
@@ -181,6 +189,7 @@ export declare const GlobalConfig: z.ZodObject<{
181
189
  runtime: z.ZodOptional<z.ZodEnum<{
182
190
  "claude-code": "claude-code";
183
191
  codex: "codex";
192
+ cursor: "cursor";
184
193
  }>>;
185
194
  model: z.ZodOptional<z.ZodString>;
186
195
  effort: z.ZodOptional<z.ZodEnum<{
@@ -239,6 +248,7 @@ export declare const ProjectConfig: z.ZodObject<{
239
248
  model_tiers: z.ZodOptional<z.ZodObject<{
240
249
  "claude-code": z.ZodOptional<z.ZodArray<z.ZodString>>;
241
250
  codex: z.ZodOptional<z.ZodArray<z.ZodString>>;
251
+ cursor: z.ZodOptional<z.ZodArray<z.ZodString>>;
242
252
  }, z.core.$strict>>;
243
253
  verify: z.ZodOptional<z.ZodObject<{
244
254
  max_rejections: z.ZodOptional<z.ZodNumber>;
@@ -261,6 +271,7 @@ export declare const ProjectConfig: z.ZodObject<{
261
271
  runtime: z.ZodOptional<z.ZodEnum<{
262
272
  "claude-code": "claude-code";
263
273
  codex: "codex";
274
+ cursor: "cursor";
264
275
  }>>;
265
276
  model: z.ZodOptional<z.ZodString>;
266
277
  effort: z.ZodOptional<z.ZodEnum<{
@@ -279,6 +290,7 @@ export declare const ProjectConfig: z.ZodObject<{
279
290
  runtime: z.ZodOptional<z.ZodEnum<{
280
291
  "claude-code": "claude-code";
281
292
  codex: "codex";
293
+ cursor: "cursor";
282
294
  }>>;
283
295
  model: z.ZodOptional<z.ZodString>;
284
296
  effort: z.ZodOptional<z.ZodEnum<{
@@ -307,6 +319,7 @@ export declare const ProjectConfig: z.ZodObject<{
307
319
  runtime: z.ZodOptional<z.ZodEnum<{
308
320
  "claude-code": "claude-code";
309
321
  codex: "codex";
322
+ cursor: "cursor";
310
323
  }>>;
311
324
  model: z.ZodOptional<z.ZodString>;
312
325
  effort: z.ZodOptional<z.ZodEnum<{
package/dist/schema.js CHANGED
@@ -1,12 +1,16 @@
1
1
  import { z } from "zod";
2
- export const RUNTIMES = ["claude-code", "codex"];
2
+ export const RUNTIMES = ["claude-code", "codex", "cursor"];
3
3
  /** Union of both runtimes' levels; `validate` rejects the ones a given runtime does not accept. */
4
4
  export const EFFORTS = ["minimal", "low", "medium", "high", "xhigh", "max"];
5
5
  /** Levels each runtime's CLI accepts (`claude --effort`, codex `model_reasoning_effort`). */
6
6
  export const RUNTIME_EFFORTS = {
7
7
  "claude-code": ["low", "medium", "high", "xhigh", "max"],
8
8
  codex: ["minimal", "low", "medium", "high", "xhigh"],
9
+ cursor: [],
9
10
  };
11
+ export function isGrokModel(model) {
12
+ return !!model && model.trim().toLowerCase().startsWith("grok");
13
+ }
10
14
  /** Guess the runtime from a model name: Claude aliases/IDs -> claude-code, GPT/o-series/codex names -> codex. */
11
15
  export function inferRuntime(model) {
12
16
  if (!model)
@@ -16,6 +20,8 @@ export function inferRuntime(model) {
16
20
  return "claude-code";
17
21
  if (/^(gpt|codex|o\d)/.test(m) || m.includes("codex"))
18
22
  return "codex";
23
+ if (isGrokModel(m))
24
+ return "cursor";
19
25
  return undefined;
20
26
  }
21
27
  /** How much of the web an agent may use: nothing, search only, or search plus fetching pages. Unset leaves each runtime's own default alone. */
@@ -102,6 +108,7 @@ export const ModelTiersPartial = z
102
108
  .object({
103
109
  "claude-code": z.array(z.string().trim().min(1)).optional(),
104
110
  codex: z.array(z.string().trim().min(1)).optional(),
111
+ cursor: z.array(z.string().trim().min(1)).optional(),
105
112
  })
106
113
  .strict();
107
114
  export const TIERS = ["low", "mid", "high"];
@@ -26,17 +26,17 @@ export declare function shipTotalTimeoutSec(commands: ShipCommand[]): number;
26
26
  export declare function shipCliArgv(): string[];
27
27
  export declare function shellQuote(s: string): string;
28
28
  /**
29
- * Write a per-wake ship session (root / commands / deny) for Claude Code and Codex.
29
+ * Write a per-wake ship session (root / commands / deny) for Claude Code, Codex and Cursor.
30
30
  * Returns undefined when ship is off or verify cannot be resolved.
31
31
  */
32
32
  export declare function writeShipSession(project: ResolvedProject, agent: ResolvedAgent, workDir: string): ShipWakeInfo | undefined;
33
33
  export declare function readShipSession(file: string): ShipSession;
34
34
  import type { WakeInput } from "./adapters/types.js";
35
- /** Prompt block for both Claude Code and Codex (exact CLI; no MCP). */
35
+ /** Prompt block for Claude Code, Codex and Cursor (exact CLI; no MCP). */
36
36
  export declare function formatShipPrompt(shellCommand: string, sessionPath: string, totalTimeoutSec: number): string;
37
37
  /**
38
38
  * For Claude Code and Codex wakes: write the session and append the exact CLI to the system prompt.
39
- * Policy wakes (tidy, etc.) skip ship. Call from both adapters.
39
+ * Policy wakes (tidy, etc.) skip ship. Call from every adapter.
40
40
  */
41
41
  export declare function applyShipToWake(input: WakeInput): {
42
42
  input: WakeInput;
package/dist/ship-wire.js CHANGED
@@ -39,7 +39,7 @@ export function shellQuote(s) {
39
39
  return `'${s.replace(/'/g, `'\\''`)}'`;
40
40
  }
41
41
  /**
42
- * Write a per-wake ship session (root / commands / deny) for Claude Code and Codex.
42
+ * Write a per-wake ship session (root / commands / deny) for Claude Code, Codex and Cursor.
43
43
  * Returns undefined when ship is off or verify cannot be resolved.
44
44
  */
45
45
  export function writeShipSession(project, agent, workDir) {
@@ -94,7 +94,7 @@ function readCommands(o) {
94
94
  const t = typeof o.timeoutSec === "number" && Number.isInteger(o.timeoutSec) && o.timeoutSec > 0 ? o.timeoutSec : SHIP_DEFAULT_TIMEOUT_SEC;
95
95
  return [{ name: "verify", run: o.verify.trim(), timeout_sec: t }];
96
96
  }
97
- /** Prompt block for both Claude Code and Codex (exact CLI; no MCP). */
97
+ /** Prompt block for Claude Code, Codex and Cursor (exact CLI; no MCP). */
98
98
  export function formatShipPrompt(shellCommand, sessionPath, totalTimeoutSec) {
99
99
  return [
100
100
  "## Ship (tested edits)",
@@ -116,7 +116,7 @@ export function formatShipPrompt(shellCommand, sessionPath, totalTimeoutSec) {
116
116
  }
117
117
  /**
118
118
  * For Claude Code and Codex wakes: write the session and append the exact CLI to the system prompt.
119
- * Policy wakes (tidy, etc.) skip ship. Call from both adapters.
119
+ * Policy wakes (tidy, etc.) skip ship. Call from every adapter.
120
120
  */
121
121
  export function applyShipToWake(input) {
122
122
  if (input.policy)
package/dist/validate.js CHANGED
@@ -3,7 +3,7 @@ import { enforcementFor, memoryDirs } from "./policy.js";
3
3
  import { describeConflict, fallbackCapExcess, sandboxConflictsOf } from "./sandbox-invocation.js";
4
4
  import { isInside } from "./paths.js";
5
5
  import { shipCommands, shipEnabled } from "./ship-wire.js";
6
- import { inferRuntime, RUNTIME_EFFORTS, RUNTIMES } from "./schema.js";
6
+ import { inferRuntime, isGrokModel, RUNTIME_EFFORTS, RUNTIMES } from "./schema.js";
7
7
  import { ladderIndex } from "./tiers.js";
8
8
  import { must } from "./assert.js";
9
9
  export function validateProject(project) {
@@ -43,13 +43,19 @@ export function validateProject(project) {
43
43
  }
44
44
  }
45
45
  if (!a.runtime)
46
- err(`Agent "${a.name}" has no runtime (set runtime, or a recognizable model such as opus/sonnet/haiku/claude-* or gpt-*/codex-*).`);
46
+ err(`Agent "${a.name}" has no runtime (set runtime, or a recognizable model such as opus/sonnet/haiku/claude-*, gpt-*/codex-* or grok-*).`);
47
+ if (a.runtime === "cursor") {
48
+ if (!a.model?.trim())
49
+ err(`Agent "${a.name}": runtime cursor requires a grok-* model.`);
50
+ else if (!isGrokModel(a.model))
51
+ err(`Agent "${a.name}": runtime cursor only allows grok-* models (got "${a.model}").`);
52
+ }
47
53
  const modelRuntime = inferRuntime(a.model);
48
54
  if (a.runtime && modelRuntime && modelRuntime !== a.runtime) {
49
55
  warn(`Agent "${a.name}": model "${a.model}" looks like a ${modelRuntime} model but runtime is ${a.runtime}.`);
50
56
  }
51
57
  if (a.effort && a.runtime && !RUNTIME_EFFORTS[a.runtime].includes(a.effort)) {
52
- err(`Agent "${a.name}": effort "${a.effort}" is not supported by ${a.runtime} (use ${RUNTIME_EFFORTS[a.runtime].join(", ")}).`);
58
+ err(`Agent "${a.name}": effort "${a.effort}" is not supported by ${a.runtime}${effortHint(a.runtime)}.`);
53
59
  }
54
60
  validateFallback(project, a, err);
55
61
  for (const c of sandboxConflictsOf(project, a, false))
@@ -115,6 +121,8 @@ export function validateProject(project) {
115
121
  }
116
122
  const PARITY_FIELDS = ["memory", "agentMd", "otherContext", "shared", "repoInstructions"];
117
123
  const norm = (m) => (m ?? "").trim().toLowerCase();
124
+ /** " (use a, b)" for runtimes with an effort list; empty for runtimes that accept none (cursor). */
125
+ const effortHint = (rt) => (RUNTIME_EFFORTS[rt].length ? ` (use ${RUNTIME_EFFORTS[rt].join(", ")})` : "");
118
126
  /** Load-time (fail closed) checks of one agent's fallback chain: well-formed, not a no-op, and no weaker at write-scope than the primary. */
119
127
  function validateFallback(project, a, err) {
120
128
  for (const bad of a.fallbackInvalid) {
@@ -132,7 +140,10 @@ function validateFallback(project, a, err) {
132
140
  continue;
133
141
  }
134
142
  if (f.effort && !RUNTIME_EFFORTS[f.runtime].includes(f.effort)) {
135
- err(`agent ${a.name}: fallback ${label}: effort "${f.effort}" is not supported by ${f.runtime} (use ${RUNTIME_EFFORTS[f.runtime].join(", ")}).`);
143
+ err(`agent ${a.name}: fallback ${label}: effort "${f.effort}" is not supported by ${f.runtime}${effortHint(f.runtime)}.`);
144
+ }
145
+ if (f.runtime === "cursor" && !isGrokModel(f.model)) {
146
+ err(`agent ${a.name}: fallback ${label} needs a grok-* model (runtime cursor only allows grok-* models).`);
136
147
  }
137
148
  if (!primary)
138
149
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-lyceum",
3
- "version": "0.42.2",
3
+ "version": "0.44.0",
4
4
  "description": "Config + dispatcher for teams of Claude Code / Codex agents with scoped context and file-based mailboxes",
5
5
  "keywords": [
6
6
  "ai",