@cursor/july 0.1.3 → 0.1.4
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/bin/agent-serve.d.ts +1 -1
- package/dist/bin/agent-serve.js +40 -16
- package/dist/channels/slack/log.d.ts +1 -1
- package/dist/channels/slack/log.d.ts.map +1 -1
- package/dist/channels/slack/log.js +4 -5
- package/dist/channels/slack/setup.js +1 -1
- package/dist/channels/slack/socket-mode.d.ts.map +1 -1
- package/dist/channels/slack/socket-mode.js +10 -9
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +3 -3
- package/dist/docs/assets/{app.BR0RbIdx.js → app.DF-Yx4OP.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.0XrheBv2.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.qjsVTneI.js → VPLocalSearchBox.DSeJSudL.js} +1 -1
- package/dist/docs/assets/chunks/{theme.2Kg8jIp_.js → theme.DZVLTXOC.js} +2 -2
- package/dist/docs/assets/{index.md.m81y7TY7.js → index.md.Cylk70gg.js} +1 -1
- package/dist/docs/building-with-agents.html +3 -3
- package/dist/docs/concepts.html +3 -3
- package/dist/docs/deployment.html +3 -3
- package/dist/docs/evals.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/github.html +3 -3
- package/dist/docs/guides/human-in-the-loop.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 +5 -5
- package/dist/docs/quickstart.html +3 -3
- package/dist/docs/reference/agent-config.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 +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 +3 -3
- package/dist/docs/scaffolding-agents.html +3 -3
- package/dist/docs/storage.html +3 -3
- package/dist/docs/troubleshooting.html +3 -3
- package/dist/internal/ab-collector.js +3 -3
- package/dist/internal/ab-fold.js +1 -1
- package/dist/internal/cli-ax.d.ts +13 -5
- package/dist/internal/cli-ax.d.ts.map +1 -1
- package/dist/internal/cli-ax.js +41 -15
- package/dist/internal/cli-github.js +13 -13
- package/dist/internal/cursor/account-mcp.js +3 -3
- package/dist/internal/cursor/backend-client.js +1 -1
- package/dist/internal/cursor/credentials.d.ts +5 -3
- package/dist/internal/cursor/credentials.d.ts.map +1 -1
- package/dist/internal/cursor/credentials.js +9 -6
- package/dist/internal/cursor/github-credentials.js +3 -3
- package/dist/internal/cursor-event-relay.js +1 -1
- package/dist/internal/cursor-relay-core.d.ts +1 -1
- package/dist/internal/cursor-relay-core.d.ts.map +1 -1
- package/dist/internal/cursor-relay-core.js +2 -1
- package/dist/internal/cursor-slack-relay.js +1 -1
- package/dist/internal/distribution.d.ts +7 -0
- package/dist/internal/distribution.d.ts.map +1 -1
- package/dist/internal/distribution.js +7 -0
- package/dist/internal/docs-site.js +3 -3
- package/dist/internal/eval-run-store.d.ts.map +1 -1
- package/dist/internal/eval-run-store.js +8 -8
- package/dist/internal/github-fanout.js +2 -2
- package/dist/internal/host-platforms.js +5 -5
- package/dist/internal/mcp-endpoint.d.ts.map +1 -1
- package/dist/internal/mcp-endpoint.js +1 -1
- package/dist/internal/playground/toolchain.js +6 -6
- package/dist/internal/reminder-runner.d.ts.map +1 -1
- package/dist/internal/reminder-runner.js +11 -11
- package/dist/internal/resolve-prod-target.d.ts +2 -0
- package/dist/internal/resolve-prod-target.d.ts.map +1 -1
- package/dist/internal/resolve-prod-target.js +44 -21
- package/dist/internal/resolved-connections.js +5 -5
- package/dist/internal/schedule-runner.js +1 -1
- package/dist/internal/server.js +14 -14
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +13 -13
- package/dist/internal/sessions-client.d.ts +13 -0
- package/dist/internal/sessions-client.d.ts.map +1 -1
- package/dist/internal/sessions-client.js +25 -0
- package/dist/internal/storage-coordinator.js +6 -6
- package/dist/internal/update-check.d.ts +93 -0
- package/dist/internal/update-check.d.ts.map +1 -0
- package/dist/internal/update-check.js +431 -0
- package/dist/playground/assets/{index-D-vo2lV_.css → index-Ct_Usdm8.css} +1 -1
- package/dist/playground/assets/index-Dsyb-Vaj.js +319 -0
- package/dist/playground/index.html +2 -2
- package/dist/types.d.ts +3 -1
- package/dist/types.d.ts.map +1 -1
- package/docs/README.md +0 -1
- package/package.json +2 -1
- package/skills/setup-slack/SKILL.md +1 -1
- package/src/bin/agent-serve.ts +42 -16
- package/src/channels/slack/log.ts +5 -5
- package/src/channels/slack/setup.ts +1 -1
- package/src/channels/slack/socket-mode.ts +11 -9
- package/src/internal/ab-collector.ts +3 -3
- package/src/internal/ab-fold.ts +1 -1
- package/src/internal/cli-ax.ts +55 -16
- package/src/internal/cli-github.ts +13 -15
- package/src/internal/cursor/account-mcp.ts +3 -3
- package/src/internal/cursor/backend-client.ts +1 -1
- package/src/internal/cursor/credentials.ts +12 -7
- package/src/internal/cursor/github-credentials.ts +3 -3
- package/src/internal/cursor-event-relay.ts +1 -1
- package/src/internal/cursor-relay-core.ts +4 -2
- package/src/internal/cursor-slack-relay.ts +1 -1
- package/src/internal/distribution.ts +8 -0
- package/src/internal/docs-site.ts +3 -3
- package/src/internal/eval-run-store.ts +8 -10
- package/src/internal/github-fanout.ts +2 -2
- package/src/internal/host-platforms.ts +5 -5
- package/src/internal/mcp-endpoint.ts +1 -3
- package/src/internal/playground/toolchain.ts +6 -6
- package/src/internal/reminder-runner.ts +11 -17
- package/src/internal/resolve-prod-target.ts +55 -23
- package/src/internal/resolved-connections.ts +5 -5
- package/src/internal/schedule-runner.ts +1 -1
- package/src/internal/server.ts +14 -14
- package/src/internal/session-engine.ts +13 -15
- package/src/internal/sessions-client.ts +34 -0
- package/src/internal/storage-coordinator.ts +6 -6
- package/src/internal/update-check.ts +552 -0
- package/src/types.ts +3 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.DtIOQzGj.js +0 -1
- package/dist/playground/assets/index-x60b9q2j.js +0 -312
- /package/dist/docs/assets/{index.md.m81y7TY7.lean.js → index.md.Cylk70gg.lean.js} +0 -0
package/src/internal/cli-ax.ts
CHANGED
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
fetchSessionEvents,
|
|
42
42
|
formatSessionsTable,
|
|
43
43
|
listSessions,
|
|
44
|
+
resolvePreviousSessionId,
|
|
44
45
|
} from "./sessions-client.js";
|
|
45
46
|
import { createStreamProgress } from "./stream-progress.js";
|
|
46
47
|
import {
|
|
@@ -118,6 +119,11 @@ export interface AxCliOptions {
|
|
|
118
119
|
* (CLI flag `--print`.)
|
|
119
120
|
*/
|
|
120
121
|
print?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* `chat --resume` / `resume` with no session id: reattach the most
|
|
124
|
+
* recently updated followable session from `/v1/sessions`.
|
|
125
|
+
*/
|
|
126
|
+
resume?: boolean;
|
|
121
127
|
/** Abort signal (tests / programmatic stop of `playground` proxy). */
|
|
122
128
|
signal?: AbortSignal;
|
|
123
129
|
}
|
|
@@ -310,26 +316,30 @@ export async function cmdInit(options: AxCliOptions): Promise<number> {
|
|
|
310
316
|
* prints a trajectory instead of the interactive UI.
|
|
311
317
|
*/
|
|
312
318
|
/**
|
|
313
|
-
* `resume
|
|
314
|
-
* session
|
|
315
|
-
*
|
|
316
|
-
*
|
|
319
|
+
* `resume [sessionId]` — reattach the interactive chat REPL to an existing
|
|
320
|
+
* session. When the id is omitted, picks the most recently updated
|
|
321
|
+
* followable session from `/v1/sessions` (same as `chat --resume`).
|
|
322
|
+
* Looks up the continuation token via `/v1/sessions` when
|
|
323
|
+
* `--continuation-token` is omitted. Same flags as `chat` (`--prod`,
|
|
324
|
+
* `--message`, `--json`, …). `--session` is accepted as a redundant
|
|
325
|
+
* alias for the positional id.
|
|
317
326
|
*/
|
|
318
327
|
export async function cmdResume(
|
|
319
328
|
sessionId: string | undefined,
|
|
320
329
|
options: AxCliOptions
|
|
321
330
|
): Promise<number> {
|
|
322
331
|
const resolved = trimNonEmpty(sessionId) ?? trimNonEmpty(options.sessionId);
|
|
323
|
-
if (resolved
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
332
|
+
if (resolved !== undefined) {
|
|
333
|
+
return cmdChat({
|
|
334
|
+
...options,
|
|
335
|
+
sessionId: resolved,
|
|
336
|
+
resume: false,
|
|
337
|
+
});
|
|
329
338
|
}
|
|
330
339
|
return cmdChat({
|
|
331
340
|
...options,
|
|
332
|
-
sessionId:
|
|
341
|
+
sessionId: undefined,
|
|
342
|
+
resume: true,
|
|
333
343
|
});
|
|
334
344
|
}
|
|
335
345
|
|
|
@@ -352,6 +362,35 @@ export async function cmdChat(options: AxCliOptions): Promise<number> {
|
|
|
352
362
|
: (options.url ?? "http://127.0.0.1:3000"),
|
|
353
363
|
});
|
|
354
364
|
|
|
365
|
+
let sessionId = trimNonEmpty(options.sessionId);
|
|
366
|
+
// `--resume` without an id → most recently updated followable session.
|
|
367
|
+
// An explicit `--session` / positional id always wins.
|
|
368
|
+
if (options.resume === true && sessionId === undefined) {
|
|
369
|
+
try {
|
|
370
|
+
const previous = await resolvePreviousSessionId({
|
|
371
|
+
baseUrl: target.agentUrl,
|
|
372
|
+
auth: {
|
|
373
|
+
bearerToken: options.bearerToken,
|
|
374
|
+
headers: target.headers,
|
|
375
|
+
},
|
|
376
|
+
fetchImpl: options.fetchImpl,
|
|
377
|
+
});
|
|
378
|
+
if (previous === undefined) {
|
|
379
|
+
process.stderr.write(
|
|
380
|
+
"No previous followable session found. Start one with " +
|
|
381
|
+
`\`${CLI_COMMAND_NAME} chat\` or pass a session id.\n`
|
|
382
|
+
);
|
|
383
|
+
return 1;
|
|
384
|
+
}
|
|
385
|
+
sessionId = previous;
|
|
386
|
+
} catch (error) {
|
|
387
|
+
process.stderr.write(
|
|
388
|
+
`${error instanceof Error ? error.message : String(error)}\n`
|
|
389
|
+
);
|
|
390
|
+
return 1;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
355
394
|
if (options.json) {
|
|
356
395
|
if (message === undefined) {
|
|
357
396
|
process.stderr.write("chat --json requires --message\n");
|
|
@@ -359,13 +398,13 @@ export async function cmdChat(options: AxCliOptions): Promise<number> {
|
|
|
359
398
|
}
|
|
360
399
|
let continuationToken = options.continuationToken;
|
|
361
400
|
if (
|
|
362
|
-
|
|
401
|
+
sessionId !== undefined &&
|
|
363
402
|
(continuationToken === undefined || continuationToken === "")
|
|
364
403
|
) {
|
|
365
404
|
try {
|
|
366
405
|
continuationToken = await lookupSessionContinuation({
|
|
367
406
|
baseUrl: target.agentUrl,
|
|
368
|
-
sessionId
|
|
407
|
+
sessionId,
|
|
369
408
|
auth: {
|
|
370
409
|
bearerToken: options.bearerToken,
|
|
371
410
|
headers: target.headers,
|
|
@@ -381,7 +420,7 @@ export async function cmdChat(options: AxCliOptions): Promise<number> {
|
|
|
381
420
|
const result = await runSession({
|
|
382
421
|
baseUrl: target.agentUrl,
|
|
383
422
|
messages: [message],
|
|
384
|
-
sessionId
|
|
423
|
+
sessionId,
|
|
385
424
|
continuationToken,
|
|
386
425
|
bearerToken: options.bearerToken,
|
|
387
426
|
headers: target.headers,
|
|
@@ -409,7 +448,7 @@ export async function cmdChat(options: AxCliOptions): Promise<number> {
|
|
|
409
448
|
await runChat({
|
|
410
449
|
baseUrl: target.agentUrl,
|
|
411
450
|
message,
|
|
412
|
-
sessionId
|
|
451
|
+
sessionId,
|
|
413
452
|
continuationToken: options.continuationToken,
|
|
414
453
|
bearerToken: options.bearerToken,
|
|
415
454
|
headers: target.headers,
|
|
@@ -892,7 +931,7 @@ export async function cmdSessions(options: AxCliOptions): Promise<number> {
|
|
|
892
931
|
/**
|
|
893
932
|
* `session <id>` — view a full session (trajectory text by default).
|
|
894
933
|
* `--json` → trajectory JSON; `--events` (`rawEvents`) → raw event list.
|
|
895
|
-
* Interactive reattach: `resume
|
|
934
|
+
* Interactive reattach: `resume [id]` / `chat --resume` (or `chat --session`).
|
|
896
935
|
*/
|
|
897
936
|
export async function cmdSession(
|
|
898
937
|
sessionId: string | undefined,
|
|
@@ -196,7 +196,7 @@ async function cmdGithubForward(options: GithubCliOptions): Promise<number> {
|
|
|
196
196
|
);
|
|
197
197
|
return 1;
|
|
198
198
|
}
|
|
199
|
-
process.stderr.write(`[
|
|
199
|
+
process.stderr.write(`[agentkit] inferred --repo ${repo}\n`);
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
const secret = options.secret ?? process.env.GITHUB_WEBHOOK_SECRET;
|
|
@@ -219,30 +219,30 @@ async function cmdGithubForward(options: GithubCliOptions): Promise<number> {
|
|
|
219
219
|
});
|
|
220
220
|
|
|
221
221
|
process.stderr.write(
|
|
222
|
-
`[
|
|
222
|
+
`[agentkit] forwarding ${org !== undefined ? `org ${org}` : `repo ${repo}`} to ${targets.length} channel${targets.length === 1 ? "" : "s"}:\n`
|
|
223
223
|
);
|
|
224
224
|
for (const target of targets) {
|
|
225
225
|
process.stderr.write(
|
|
226
|
-
`[
|
|
226
|
+
`[agentkit] → ${targetLabel(target)} ${target.url} (${target.events.join(", ")})\n`
|
|
227
227
|
);
|
|
228
228
|
}
|
|
229
229
|
if (fanout) {
|
|
230
230
|
process.stderr.write(
|
|
231
|
-
`[
|
|
231
|
+
`[agentkit] fan-out proxy on ${forwardUrl} (union events: ${events.join(", ")})\n`
|
|
232
232
|
);
|
|
233
233
|
}
|
|
234
234
|
if (secret === undefined || secret === "") {
|
|
235
235
|
process.stderr.write(
|
|
236
|
-
"[
|
|
236
|
+
"[agentkit] no signing secret — deliveries are unsigned. A `serve --dev` github channel accepts them; set GITHUB_WEBHOOK_SECRET on both sides to verify signatures (required for a non-dev target).\n"
|
|
237
237
|
);
|
|
238
238
|
}
|
|
239
239
|
const envToken = detectGitHubEnvTokenOverride();
|
|
240
240
|
if (envToken !== undefined) {
|
|
241
241
|
process.stderr.write(
|
|
242
|
-
`[
|
|
242
|
+
`[agentkit] warning: ${githubEnvTokenHint(envToken)}\n`
|
|
243
243
|
);
|
|
244
244
|
}
|
|
245
|
-
process.stderr.write(`[
|
|
245
|
+
process.stderr.write(`[agentkit] running: gh ${redact(args)}\n`);
|
|
246
246
|
|
|
247
247
|
try {
|
|
248
248
|
return await spawnGh(args);
|
|
@@ -318,7 +318,7 @@ async function cmdGithubReplay(options: GithubCliOptions): Promise<number> {
|
|
|
318
318
|
);
|
|
319
319
|
if (unsupported.length > 0) {
|
|
320
320
|
process.stderr.write(
|
|
321
|
-
`[
|
|
321
|
+
`[agentkit] cannot synthesize (skipped): ${unsupported.join(", ")}\n`
|
|
322
322
|
);
|
|
323
323
|
}
|
|
324
324
|
if (eventsToReplay.length === 0) {
|
|
@@ -364,9 +364,7 @@ async function cmdGithubReplay(options: GithubCliOptions): Promise<number> {
|
|
|
364
364
|
check,
|
|
365
365
|
});
|
|
366
366
|
if ("error" in result) {
|
|
367
|
-
process.stderr.write(
|
|
368
|
-
`[agent-serve] skipping ${event}: ${result.error}\n`
|
|
369
|
-
);
|
|
367
|
+
process.stderr.write(`[agentkit] skipping ${event}: ${result.error}\n`);
|
|
370
368
|
continue;
|
|
371
369
|
}
|
|
372
370
|
synthesized.push(result);
|
|
@@ -378,7 +376,7 @@ async function cmdGithubReplay(options: GithubCliOptions): Promise<number> {
|
|
|
378
376
|
|
|
379
377
|
const secret = options.secret ?? process.env.GITHUB_WEBHOOK_SECRET;
|
|
380
378
|
process.stderr.write(
|
|
381
|
-
`[
|
|
379
|
+
`[agentkit] replaying ${ref.label} (${synthesized
|
|
382
380
|
.map((s) => s.eventName)
|
|
383
381
|
.join(
|
|
384
382
|
", "
|
|
@@ -401,7 +399,7 @@ async function cmdGithubReplay(options: GithubCliOptions): Promise<number> {
|
|
|
401
399
|
|
|
402
400
|
if (options.out !== undefined) {
|
|
403
401
|
const file = await writeReplayFixture(options.out, event);
|
|
404
|
-
process.stderr.write(`[
|
|
402
|
+
process.stderr.write(`[agentkit] wrote ${file}\n`);
|
|
405
403
|
}
|
|
406
404
|
|
|
407
405
|
const label = eventLabel(event);
|
|
@@ -436,7 +434,7 @@ async function cmdGithubReplay(options: GithubCliOptions): Promise<number> {
|
|
|
436
434
|
`${delivery.label} ${delivery.status || "ERR"}${delivery.ok ? "" : " (rejected)"}`
|
|
437
435
|
)
|
|
438
436
|
.join(", ") || "(no matching channel)";
|
|
439
|
-
process.stderr.write(`[
|
|
437
|
+
process.stderr.write(`[agentkit] ${label} → ${summary}\n`);
|
|
440
438
|
}
|
|
441
439
|
}
|
|
442
440
|
|
|
@@ -747,7 +745,7 @@ async function ensureWebhookExtension(
|
|
|
747
745
|
};
|
|
748
746
|
}
|
|
749
747
|
process.stderr.write(
|
|
750
|
-
`[
|
|
748
|
+
`[agentkit] installing ${GITHUB_WEBHOOK_EXTENSION}@${GITHUB_WEBHOOK_EXTENSION_PIN}…\n`
|
|
751
749
|
);
|
|
752
750
|
if (
|
|
753
751
|
(await tryExec({
|
|
@@ -231,7 +231,7 @@ export class CursorAccountMcpBridge {
|
|
|
231
231
|
)
|
|
232
232
|
.join(", ");
|
|
233
233
|
this.logger(
|
|
234
|
-
`[
|
|
234
|
+
`[agentkit] Cursor account MCP connection "${ref.name}": ${
|
|
235
235
|
catalog.servers.length === 0
|
|
236
236
|
? "no matching connectors on this account — connect servers in Cursor (dashboard → MCP) or fix the `servers` filter"
|
|
237
237
|
: summary
|
|
@@ -242,7 +242,7 @@ export class CursorAccountMcpBridge {
|
|
|
242
242
|
);
|
|
243
243
|
if (needsAuth.length > 0) {
|
|
244
244
|
this.logger(
|
|
245
|
-
`[
|
|
245
|
+
`[agentkit] Cursor account MCP connection "${ref.name}": ${needsAuth
|
|
246
246
|
.map((server) => server.serverIdentifier)
|
|
247
247
|
.join(
|
|
248
248
|
", "
|
|
@@ -252,7 +252,7 @@ export class CursorAccountMcpBridge {
|
|
|
252
252
|
})
|
|
253
253
|
.catch((error: unknown) => {
|
|
254
254
|
this.logger(
|
|
255
|
-
`[
|
|
255
|
+
`[agentkit] Cursor account MCP connection "${ref.name}" preflight failed: ${describeError(error)}`
|
|
256
256
|
);
|
|
257
257
|
});
|
|
258
258
|
}
|
|
@@ -445,7 +445,7 @@ export class CursorBackendClient {
|
|
|
445
445
|
value: body.data.accessToken,
|
|
446
446
|
expiresAtMs: jwtExpiryMs(body.data.accessToken),
|
|
447
447
|
};
|
|
448
|
-
this.logger("[
|
|
448
|
+
this.logger("[agentkit] cursor account: minted a fresh access token");
|
|
449
449
|
return body.data.accessToken;
|
|
450
450
|
}
|
|
451
451
|
}
|
|
@@ -73,18 +73,23 @@ const storedCredentialsSchema: z.ZodObject<
|
|
|
73
73
|
export type StoredCredentials = z.infer<typeof storedCredentialsSchema>;
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
|
-
* `~/.config/agent-serve
|
|
77
|
-
*
|
|
78
|
-
* (tests, containers).
|
|
76
|
+
* `~/.config/agent-serve/` (honoring `XDG_CONFIG_HOME`), the host-level
|
|
77
|
+
* config directory for credentials and the update-check cache.
|
|
78
|
+
* `AGENT_SERVE_CONFIG_DIR` pins the directory outright (tests, containers).
|
|
79
79
|
*/
|
|
80
|
-
export function
|
|
81
|
-
|
|
80
|
+
export function configDirPath(): string {
|
|
81
|
+
return (
|
|
82
82
|
process.env.AGENT_SERVE_CONFIG_DIR ??
|
|
83
83
|
join(
|
|
84
84
|
process.env.XDG_CONFIG_HOME ?? join(homedir(), ".config"),
|
|
85
85
|
"agent-serve"
|
|
86
|
-
)
|
|
87
|
-
|
|
86
|
+
)
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** `<configDir>/credentials.json` (0600). */
|
|
91
|
+
export function credentialsFilePath(): string {
|
|
92
|
+
return join(configDirPath(), "credentials.json");
|
|
88
93
|
}
|
|
89
94
|
|
|
90
95
|
export async function readStoredCredentials(): Promise<
|
|
@@ -148,14 +148,14 @@ export class CursorGithubCredentialProvider {
|
|
|
148
148
|
this.scheduleRefresh();
|
|
149
149
|
}
|
|
150
150
|
this.logger(
|
|
151
|
-
`[
|
|
151
|
+
`[agentkit] GitHub auth: refreshed Cursor account credential for ${this.repos.length} repo(s)`
|
|
152
152
|
);
|
|
153
153
|
return result.token;
|
|
154
154
|
} catch (error) {
|
|
155
155
|
const message = error instanceof Error ? error.message : String(error);
|
|
156
156
|
if (this.cached !== undefined && this.now() < this.cached.expiresAtMs) {
|
|
157
157
|
this.logger(
|
|
158
|
-
`[
|
|
158
|
+
`[agentkit] GitHub auth: Cursor account credential refresh failed; using the current lease: ${message}`
|
|
159
159
|
);
|
|
160
160
|
this.cached.refreshAtMs = Math.min(
|
|
161
161
|
this.cached.expiresAtMs,
|
|
@@ -207,7 +207,7 @@ export class CursorGithubCredentialProvider {
|
|
|
207
207
|
this.refreshTimer = setTimeout(() => {
|
|
208
208
|
void this.getToken().catch((error: unknown) => {
|
|
209
209
|
this.logger(
|
|
210
|
-
`[
|
|
210
|
+
`[agentkit] GitHub auth: Cursor account credential refresh failed: ${
|
|
211
211
|
error instanceof Error ? error.message : String(error)
|
|
212
212
|
}`
|
|
213
213
|
);
|
|
@@ -263,7 +263,7 @@ export class CursorEventRelay {
|
|
|
263
263
|
if (!this.loggedSkippedRepos.has(event.repo)) {
|
|
264
264
|
this.loggedSkippedRepos.add(event.repo);
|
|
265
265
|
this.options.logger(
|
|
266
|
-
`[
|
|
266
|
+
`[agentkit] cursor-events: skipping events for ${event.repo}: not in this host's subscription (another consumer of this API key likely subscribed it)`
|
|
267
267
|
);
|
|
268
268
|
}
|
|
269
269
|
return false;
|
|
@@ -12,6 +12,8 @@ import { randomUUID } from "node:crypto";
|
|
|
12
12
|
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
13
13
|
import { join } from "node:path";
|
|
14
14
|
|
|
15
|
+
import { LOG_PREFIX } from "./distribution.js";
|
|
16
|
+
|
|
15
17
|
const OFFSET_SNAPSHOT_VERSION = 1 as const;
|
|
16
18
|
const DEFAULT_POLL_WAIT_MS = 25_000;
|
|
17
19
|
const DEFAULT_POLL_LIMIT = 100;
|
|
@@ -98,7 +100,7 @@ interface PollResponse<TEvent> {
|
|
|
98
100
|
* anchor/poll/dedupe/offset loop, and backoff — is shared.
|
|
99
101
|
*/
|
|
100
102
|
export interface RelayAdapter<TEvent extends { offset: string }> {
|
|
101
|
-
/** Log fragment, e.g. `cursor-events` → `[
|
|
103
|
+
/** Log fragment, e.g. `cursor-events` → `[agentkit] cursor-events: …`. */
|
|
102
104
|
readonly logPrefix: string;
|
|
103
105
|
/** Subscription registration path, e.g. `/v0/scm-events/subscriptions`. */
|
|
104
106
|
readonly subscribePath: string;
|
|
@@ -231,7 +233,7 @@ export class CursorRelayCore<TEvent extends { offset: string }> {
|
|
|
231
233
|
|
|
232
234
|
private log(line: string): void {
|
|
233
235
|
this.options.logger(
|
|
234
|
-
|
|
236
|
+
`${LOG_PREFIX} ${this.options.adapter.logPrefix}: ${line}`
|
|
235
237
|
);
|
|
236
238
|
}
|
|
237
239
|
|
|
@@ -122,7 +122,7 @@ export function createCursorSlackApiCaller(args: {
|
|
|
122
122
|
};
|
|
123
123
|
} catch (error) {
|
|
124
124
|
args.logger?.(
|
|
125
|
-
`[
|
|
125
|
+
`[agentkit] cursor-slack: ${method} proxy call failed: ${describeRelayError(error)}`
|
|
126
126
|
);
|
|
127
127
|
return { ok: false, error: "cursor_backend_unreachable" };
|
|
128
128
|
}
|
|
@@ -25,6 +25,14 @@ export const LEGACY_PACKAGE_NAME = "@anysphere/agent-serve";
|
|
|
25
25
|
*/
|
|
26
26
|
export const AGENTKIT_PACKAGE_NAME = "@cursor/agentkit";
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Bracketed product tag for stderr / ServeOptions.logger lines
|
|
30
|
+
* (`[agentkit] …`, `[agentkit/slack] …`).
|
|
31
|
+
*/
|
|
32
|
+
export const LOG_PRODUCT = "agentkit";
|
|
33
|
+
export const LOG_PREFIX: string = `[${LOG_PRODUCT}]`;
|
|
34
|
+
export const SLACK_LOG_PREFIX: string = `[${LOG_PRODUCT}/slack]`;
|
|
35
|
+
|
|
28
36
|
/**
|
|
29
37
|
* Command name this CLI was invoked as. Both bins point at the same entry;
|
|
30
38
|
* keep help text and hints copy-pasteable for whichever the user typed.
|
|
@@ -109,11 +109,11 @@ export async function ensureDocsSiteBundle(
|
|
|
109
109
|
const toolchain = resolveDocsToolchain();
|
|
110
110
|
if (toolchain === undefined) {
|
|
111
111
|
logger(
|
|
112
|
-
"[
|
|
112
|
+
"[agentkit] docs site missing and vitepress toolchain unavailable; /docs will show a build hint"
|
|
113
113
|
);
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
|
-
logger("[
|
|
116
|
+
logger("[agentkit] building docs site (vitepress)...");
|
|
117
117
|
const code = await new Promise<number>((resolve, reject) => {
|
|
118
118
|
const child = spawn(
|
|
119
119
|
process.execPath,
|
|
@@ -131,7 +131,7 @@ export async function ensureDocsSiteBundle(
|
|
|
131
131
|
"docs vitepress build finished but dist/docs/index.html is missing"
|
|
132
132
|
);
|
|
133
133
|
}
|
|
134
|
-
logger("[
|
|
134
|
+
logger("[agentkit] docs site build complete");
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
interface DocsToolchain {
|
|
@@ -185,7 +185,7 @@ export class EvalRunStore {
|
|
|
185
185
|
await this.pruneOldRuns(config);
|
|
186
186
|
await this.enqueuePersist(snapshot, this.resolvePersist(config));
|
|
187
187
|
this.logger(
|
|
188
|
-
`[
|
|
188
|
+
`[agentkit] eval run ${runId}: starting ${cases.length} case(s)`
|
|
189
189
|
);
|
|
190
190
|
|
|
191
191
|
void this.execute(runId, {
|
|
@@ -235,7 +235,7 @@ export class EvalRunStore {
|
|
|
235
235
|
const loaded = await persist.load({ projectRoot: this.projectRoot });
|
|
236
236
|
if (!Array.isArray(loaded)) {
|
|
237
237
|
this.logger(
|
|
238
|
-
"[
|
|
238
|
+
"[agentkit] eval persistRuns.load() did not return an array; ignoring"
|
|
239
239
|
);
|
|
240
240
|
this.hydrated = true;
|
|
241
241
|
return;
|
|
@@ -262,12 +262,12 @@ export class EvalRunStore {
|
|
|
262
262
|
}
|
|
263
263
|
await this.pruneOldRuns(config);
|
|
264
264
|
this.logger(
|
|
265
|
-
`[
|
|
265
|
+
`[agentkit] hydrated ${this.runs.size} playground eval run(s) from persistRuns`
|
|
266
266
|
);
|
|
267
267
|
} catch (error) {
|
|
268
268
|
const message = error instanceof Error ? error.message : String(error);
|
|
269
269
|
this.logger(
|
|
270
|
-
`[
|
|
270
|
+
`[agentkit] failed to hydrate playground eval runs: ${message}`
|
|
271
271
|
);
|
|
272
272
|
} finally {
|
|
273
273
|
this.hydrated = true;
|
|
@@ -319,7 +319,7 @@ export class EvalRunStore {
|
|
|
319
319
|
} catch (error) {
|
|
320
320
|
const message = error instanceof Error ? error.message : String(error);
|
|
321
321
|
this.logger(
|
|
322
|
-
`[
|
|
322
|
+
`[agentkit] persistRuns.save(${run.runId}) failed: ${message}`
|
|
323
323
|
);
|
|
324
324
|
}
|
|
325
325
|
}
|
|
@@ -335,9 +335,7 @@ export class EvalRunStore {
|
|
|
335
335
|
await persist.delete(runId, { projectRoot: this.projectRoot });
|
|
336
336
|
} catch (error) {
|
|
337
337
|
const message = error instanceof Error ? error.message : String(error);
|
|
338
|
-
this.logger(
|
|
339
|
-
`[agent-serve] persistRuns.delete(${runId}) failed: ${message}`
|
|
340
|
-
);
|
|
338
|
+
this.logger(`[agentkit] persistRuns.delete(${runId}) failed: ${message}`);
|
|
341
339
|
}
|
|
342
340
|
}
|
|
343
341
|
|
|
@@ -422,7 +420,7 @@ export class EvalRunStore {
|
|
|
422
420
|
run.finishedAt = new Date().toISOString();
|
|
423
421
|
await this.enqueuePersist(run, this.resolvePersist(opts.config));
|
|
424
422
|
this.logger(
|
|
425
|
-
`[
|
|
423
|
+
`[agentkit] eval run ${runId}: done — ${run.summary.passed} passed, ${run.summary.failed} failed`
|
|
426
424
|
);
|
|
427
425
|
} catch (error) {
|
|
428
426
|
const run = this.runs.get(runId);
|
|
@@ -433,7 +431,7 @@ export class EvalRunStore {
|
|
|
433
431
|
run.finishedAt = new Date().toISOString();
|
|
434
432
|
run.error = error instanceof Error ? error.message : String(error);
|
|
435
433
|
await this.enqueuePersist(run, this.resolvePersist(opts.config));
|
|
436
|
-
this.logger(`[
|
|
434
|
+
this.logger(`[agentkit] eval run ${runId}: failed — ${run.error}`);
|
|
437
435
|
} finally {
|
|
438
436
|
if (this.activeRunId === runId) {
|
|
439
437
|
this.activeRunId = undefined;
|
|
@@ -136,14 +136,14 @@ export async function fanoutDelivery(
|
|
|
136
136
|
});
|
|
137
137
|
if (!response.ok) {
|
|
138
138
|
log(
|
|
139
|
-
`[
|
|
139
|
+
`[agentkit] delivery to ${label} failed: HTTP ${response.status}\n`
|
|
140
140
|
);
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
143
|
delivered.push(label);
|
|
144
144
|
} catch (error) {
|
|
145
145
|
log(
|
|
146
|
-
`[
|
|
146
|
+
`[agentkit] delivery to ${label} failed: ${
|
|
147
147
|
error instanceof Error ? error.message : String(error)
|
|
148
148
|
}\n`
|
|
149
149
|
);
|
|
@@ -114,7 +114,7 @@ export async function warmupHostGitHubAuth(options: {
|
|
|
114
114
|
const source = options.authSource ?? (await resolveHostGitHubAuthSource());
|
|
115
115
|
if (source === "unavailable") {
|
|
116
116
|
options.logger(
|
|
117
|
-
"[
|
|
117
|
+
"[agentkit] GitHub auth: unavailable (set GITHUB_APP_ID + GITHUB_APP_PRIVATE_KEY + GITHUB_APP_INSTALLATION_ID, or GITHUB_TOKEN / GH_TOKEN, or run `gh auth login`)"
|
|
118
118
|
);
|
|
119
119
|
return source;
|
|
120
120
|
}
|
|
@@ -125,7 +125,7 @@ export async function warmupHostGitHubAuth(options: {
|
|
|
125
125
|
exportedGhToken = await ensureGhCliTokenEnv();
|
|
126
126
|
} catch (error) {
|
|
127
127
|
options.logger(
|
|
128
|
-
`[
|
|
128
|
+
`[agentkit] GitHub auth: failed to export GH_TOKEN for gh CLI: ${
|
|
129
129
|
error instanceof Error ? error.message : String(error)
|
|
130
130
|
}`
|
|
131
131
|
);
|
|
@@ -143,16 +143,16 @@ export async function warmupHostGitHubAuth(options: {
|
|
|
143
143
|
? "GITHUB_TOKEN/GH_TOKEN"
|
|
144
144
|
: "gh auth token";
|
|
145
145
|
if (options.github === undefined) {
|
|
146
|
-
options.logger(`[
|
|
146
|
+
options.logger(`[agentkit] GitHub auth: ${label}`);
|
|
147
147
|
return source;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
try {
|
|
151
151
|
await options.github.getOctokit();
|
|
152
|
-
options.logger(`[
|
|
152
|
+
options.logger(`[agentkit] GitHub auth: ${label}`);
|
|
153
153
|
} catch (error) {
|
|
154
154
|
options.logger(
|
|
155
|
-
`[
|
|
155
|
+
`[agentkit] GitHub auth: ${label} resolved but Octokit warmup failed: ${
|
|
156
156
|
error instanceof Error ? error.message : String(error)
|
|
157
157
|
}`
|
|
158
158
|
);
|
|
@@ -106,9 +106,7 @@ export async function handleStatelessMcpRequest(args: {
|
|
|
106
106
|
// so closing in `finally` never truncates a streamed response.
|
|
107
107
|
return await transport.handleRequest(args.request);
|
|
108
108
|
} catch (error) {
|
|
109
|
-
logger(
|
|
110
|
-
`[agent-serve] ${args.label} request failed: ${describeError(error)}`
|
|
111
|
-
);
|
|
109
|
+
logger(`[agentkit] ${args.label} request failed: ${describeError(error)}`);
|
|
112
110
|
return new Response(
|
|
113
111
|
JSON.stringify({
|
|
114
112
|
jsonrpc: "2.0",
|
|
@@ -121,7 +121,7 @@ export async function runPlaygroundBuild(
|
|
|
121
121
|
"playground vite toolchain unavailable (need playground/ sources and the vite package)"
|
|
122
122
|
);
|
|
123
123
|
}
|
|
124
|
-
logger("[
|
|
124
|
+
logger("[agentkit] building playground (vite)...");
|
|
125
125
|
const code = await spawnVite(toolchain, ["build", "--config", VITE_CONFIG], {
|
|
126
126
|
env: process.env,
|
|
127
127
|
});
|
|
@@ -133,7 +133,7 @@ export async function runPlaygroundBuild(
|
|
|
133
133
|
"playground vite build finished but dist/playground/index.html is missing"
|
|
134
134
|
);
|
|
135
135
|
}
|
|
136
|
-
logger("[
|
|
136
|
+
logger("[agentkit] playground build complete");
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
/**
|
|
@@ -149,7 +149,7 @@ export async function ensurePlaygroundBundle(
|
|
|
149
149
|
}
|
|
150
150
|
if (resolvePlaygroundToolchain() === undefined) {
|
|
151
151
|
logger(
|
|
152
|
-
"[
|
|
152
|
+
"[agentkit] playground bundle missing and vite toolchain unavailable; /playground will show a build hint"
|
|
153
153
|
);
|
|
154
154
|
return;
|
|
155
155
|
}
|
|
@@ -215,7 +215,7 @@ export function startPlaygroundDevServer(options: {
|
|
|
215
215
|
child.stderr?.on("data", (chunk: Buffer) => {
|
|
216
216
|
const text = chunk.toString().trimEnd();
|
|
217
217
|
if (text !== "") {
|
|
218
|
-
logger(`[
|
|
218
|
+
logger(`[agentkit] playground: ${text}`);
|
|
219
219
|
}
|
|
220
220
|
});
|
|
221
221
|
|
|
@@ -225,7 +225,7 @@ export function startPlaygroundDevServer(options: {
|
|
|
225
225
|
return;
|
|
226
226
|
}
|
|
227
227
|
logger(
|
|
228
|
-
`[
|
|
228
|
+
`[agentkit] playground spawn failed: ${err.message} — static /playground still served when built`
|
|
229
229
|
);
|
|
230
230
|
});
|
|
231
231
|
child.on("exit", (code, signal) => {
|
|
@@ -234,7 +234,7 @@ export function startPlaygroundDevServer(options: {
|
|
|
234
234
|
}
|
|
235
235
|
if (code !== 0 && code !== null) {
|
|
236
236
|
logger(
|
|
237
|
-
`[
|
|
237
|
+
`[agentkit] playground exited (code ${code}${
|
|
238
238
|
signal ? `, signal ${signal}` : ""
|
|
239
239
|
}) — static /playground still served when built`
|
|
240
240
|
);
|