@cursor/july 0.1.15 → 0.1.17
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 +9 -4
- package/dist/bin/agent-serve.js +60 -2
- package/dist/channels/slack/api.d.ts.map +1 -1
- package/dist/channels/slack/api.js +13 -3
- package/dist/channels/slack/auth.d.ts +7 -1
- package/dist/channels/slack/auth.d.ts.map +1 -1
- package/dist/channels/slack/auth.js +14 -0
- package/dist/channels/slack/blocks.d.ts +61 -0
- package/dist/channels/slack/blocks.d.ts.map +1 -0
- package/dist/channels/slack/blocks.js +90 -0
- package/dist/channels/slack/defaults.d.ts +2 -0
- package/dist/channels/slack/defaults.d.ts.map +1 -1
- package/dist/channels/slack/defaults.js +29 -3
- package/dist/channels/slack/dispatch.d.ts +3 -17
- package/dist/channels/slack/dispatch.d.ts.map +1 -1
- package/dist/channels/slack/index.d.ts +1 -0
- package/dist/channels/slack/index.d.ts.map +1 -1
- package/dist/channels/slack/index.js +1 -0
- package/dist/channels/slack/interactive.d.ts +39 -3
- package/dist/channels/slack/interactive.d.ts.map +1 -1
- package/dist/channels/slack/interactive.js +152 -7
- package/dist/channels/slack/manifest.d.ts +3 -0
- package/dist/channels/slack/manifest.d.ts.map +1 -1
- package/dist/channels/slack/manifest.js +3 -0
- package/dist/channels/slack/setup.d.ts +4 -1
- package/dist/channels/slack/setup.d.ts.map +1 -1
- package/dist/channels/slack/setup.js +16 -2
- package/dist/channels/slack/slack-channel.d.ts.map +1 -1
- package/dist/channels/slack/slack-channel.js +24 -3
- package/dist/channels/slack/types.d.ts +77 -0
- package/dist/channels/slack/types.d.ts.map +1 -1
- package/dist/connections.d.ts +4 -1
- package/dist/connections.d.ts.map +1 -1
- package/dist/connections.js +4 -1
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +3 -3
- package/dist/docs/assets/{app.DpdGZTLe.js → app.BbEXr2KO.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.DCBsrfwP.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.IB-0QqIT.js → VPLocalSearchBox.DBEi4HDp.js} +1 -1
- package/dist/docs/assets/chunks/{theme.-fYBoNtR.js → theme.DGfptcHw.js} +2 -2
- package/dist/docs/assets/{example-agents_index.md.BPXjUtRB.js → example-agents_index.md.D2PEVSXl.js} +2 -2
- package/dist/docs/assets/{example-agents_index.md.BPXjUtRB.lean.js → example-agents_index.md.D2PEVSXl.lean.js} +1 -1
- package/dist/docs/assets/example-agents_security-reviewer.md.BZSNycMf.js +19 -0
- package/dist/docs/assets/{example-agents_security-reviewer.md.CE9v-aKm.lean.js → example-agents_security-reviewer.md.BZSNycMf.lean.js} +1 -1
- package/dist/docs/assets/{guides_mcp-oauth.md.DqmEOQY1.js → guides_mcp-oauth.md.Dd8EgSem.js} +3 -2
- package/dist/docs/assets/{guides_mcp-oauth.md.DqmEOQY1.lean.js → guides_mcp-oauth.md.Dd8EgSem.lean.js} +1 -1
- package/dist/docs/assets/{guides_slack.md.FWale6Ip.js → guides_slack.md.D_xFKlnF.js} +1 -1
- package/dist/docs/assets/{reference_connections.md.CsSr3rDz.js → reference_connections.md.B9Q3TOve.js} +12 -5
- package/dist/docs/assets/{reference_connections.md.CsSr3rDz.lean.js → reference_connections.md.B9Q3TOve.lean.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/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 +5 -5
- 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 +14 -14
- 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/github.html +3 -3
- package/dist/docs/guides/human-in-the-loop.html +3 -3
- package/dist/docs/guides/mcp-oauth.html +6 -5
- package/dist/docs/guides/slack.html +5 -5
- 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/channels.html +3 -3
- package/dist/docs/reference/cli.html +3 -3
- package/dist/docs/reference/connections.html +14 -7
- 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/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 +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/evals/assertions.d.ts +190 -0
- package/dist/evals/assertions.d.ts.map +1 -0
- package/dist/evals/assertions.js +461 -0
- package/dist/evals/expect.d.ts +95 -0
- package/dist/evals/expect.d.ts.map +1 -0
- package/dist/evals/expect.js +194 -0
- package/dist/evals/judge.d.ts +133 -0
- package/dist/evals/judge.d.ts.map +1 -0
- package/dist/evals/judge.js +228 -0
- package/dist/evals/loaders.d.ts +51 -0
- package/dist/evals/loaders.d.ts.map +1 -0
- package/dist/evals/loaders.js +124 -0
- package/dist/evals/matchers.d.ts +95 -0
- package/dist/evals/matchers.d.ts.map +1 -0
- package/dist/evals/matchers.js +145 -0
- package/dist/evals/reporters.d.ts +70 -0
- package/dist/evals/reporters.d.ts.map +1 -0
- package/dist/evals/reporters.js +221 -0
- package/dist/evals/results.d.ts +103 -0
- package/dist/evals/results.d.ts.map +1 -0
- package/dist/evals/results.js +28 -0
- package/dist/evals/run-facts.d.ts +77 -0
- package/dist/evals/run-facts.d.ts.map +1 -0
- package/dist/evals/run-facts.js +187 -0
- package/dist/evals.d.ts +136 -31
- package/dist/evals.d.ts.map +1 -1
- package/dist/evals.js +76 -12
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/cli-ax.d.ts +27 -0
- package/dist/internal/cli-ax.d.ts.map +1 -1
- package/dist/internal/cli-ax.js +90 -12
- package/dist/internal/cli-mcp.d.ts +8 -0
- package/dist/internal/cli-mcp.d.ts.map +1 -1
- package/dist/internal/cli-mcp.js +98 -0
- package/dist/internal/cli-slack.d.ts +29 -1
- package/dist/internal/cli-slack.d.ts.map +1 -1
- package/dist/internal/cli-slack.js +777 -12
- package/dist/internal/deploy-client.d.ts +7 -0
- package/dist/internal/deploy-client.d.ts.map +1 -1
- package/dist/internal/deploy-client.js +9 -0
- package/dist/internal/discovery.d.ts.map +1 -1
- package/dist/internal/discovery.js +29 -9
- package/dist/internal/distribution.d.ts.map +1 -1
- package/dist/internal/distribution.js +2 -0
- package/dist/internal/eval-judge-model.d.ts +59 -0
- package/dist/internal/eval-judge-model.d.ts.map +1 -0
- package/dist/internal/eval-judge-model.js +131 -0
- package/dist/internal/eval-run-store.d.ts.map +1 -1
- package/dist/internal/eval-run-store.js +12 -20
- package/dist/internal/eval-runner.d.ts +31 -25
- package/dist/internal/eval-runner.d.ts.map +1 -1
- package/dist/internal/eval-runner.js +332 -128
- package/dist/internal/evals-client.d.ts.map +1 -1
- package/dist/internal/evals-client.js +7 -3
- package/dist/internal/local-env.d.ts +8 -0
- package/dist/internal/local-env.d.ts.map +1 -0
- package/dist/internal/local-env.js +47 -0
- package/dist/internal/playground/static.d.ts +3 -0
- package/dist/internal/playground/static.d.ts.map +1 -1
- package/dist/internal/playground/static.js +3 -0
- package/dist/internal/run-client.d.ts +15 -0
- package/dist/internal/run-client.d.ts.map +1 -1
- package/dist/internal/run-client.js +3 -2
- package/dist/internal/sdk-runner.d.ts +36 -1
- package/dist/internal/sdk-runner.d.ts.map +1 -1
- package/dist/internal/sdk-runner.js +65 -25
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +10 -1
- package/dist/internal/session-engine.d.ts +18 -5
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +72 -19
- package/dist/internal/slack-provision-client.d.ts +130 -0
- package/dist/internal/slack-provision-client.d.ts.map +1 -0
- package/dist/internal/slack-provision-client.js +284 -0
- package/dist/playground/assets/cursor-icons-16-f_W_ogc-.woff2 +0 -0
- package/dist/playground/assets/index-CidizGZv.css +1 -0
- package/dist/playground/assets/index-DNqirsrK.js +85 -0
- package/dist/playground/index.html +2 -2
- package/dist/types.d.ts +70 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +26 -0
- package/docs/example-agents/index.md +1 -1
- package/docs/example-agents/security-reviewer.md +23 -21
- package/docs/guides/mcp-oauth.md +10 -5
- package/docs/guides/slack.md +3 -2
- package/docs/reference/connections.md +28 -18
- package/package.json +20 -2
- package/skills/create-agent/SKILL.md +15 -7
- package/skills/debug/SKILL.md +3 -1
- package/skills/mcp-auth/SKILL.md +1 -1
- package/skills/setup-slack/SKILL.md +173 -11
- package/src/bin/agent-serve.ts +63 -2
- package/src/channels/slack/api.ts +16 -3
- package/src/channels/slack/auth.ts +16 -1
- package/src/channels/slack/blocks.ts +139 -0
- package/src/channels/slack/defaults.ts +32 -4
- package/src/channels/slack/dispatch.ts +3 -18
- package/src/channels/slack/index.ts +1 -0
- package/src/channels/slack/interactive.ts +183 -19
- package/src/channels/slack/manifest.ts +3 -0
- package/src/channels/slack/setup.ts +16 -2
- package/src/channels/slack/slack-channel.ts +37 -6
- package/src/channels/slack/types.ts +89 -0
- package/src/connections.ts +4 -1
- package/src/evals/assertions.ts +704 -0
- package/src/evals/expect.ts +272 -0
- package/src/evals/judge.ts +346 -0
- package/src/evals/loaders.ts +113 -0
- package/src/evals/matchers.ts +246 -0
- package/src/evals/reporters.ts +274 -0
- package/src/evals/results.ts +132 -0
- package/src/evals/run-facts.ts +274 -0
- package/src/evals.ts +249 -42
- package/src/index.ts +2 -0
- package/src/internal/cli-ax.ts +134 -15
- package/src/internal/cli-mcp.ts +118 -5
- package/src/internal/cli-slack.ts +993 -15
- package/src/internal/deploy-client.ts +10 -0
- package/src/internal/discovery.ts +31 -5
- package/src/internal/distribution.ts +2 -0
- package/src/internal/eval-judge-model.ts +148 -0
- package/src/internal/eval-run-store.ts +10 -14
- package/src/internal/eval-runner.ts +466 -215
- package/src/internal/evals-client.ts +14 -2
- package/src/internal/local-env.ts +53 -0
- package/src/internal/playground/static.ts +3 -0
- package/src/internal/run-client.ts +17 -1
- package/src/internal/sdk-runner.ts +103 -22
- package/src/internal/server.ts +10 -0
- package/src/internal/session-engine.ts +89 -21
- package/src/internal/slack-provision-client.ts +438 -0
- package/src/types.ts +92 -4
- package/dist/channels/slack/post-update-delivery.d.ts +0 -85
- package/dist/channels/slack/post-update-delivery.d.ts.map +0 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.D2d8CfFS.js +0 -1
- package/dist/docs/assets/example-agents_security-reviewer.md.CE9v-aKm.js +0 -19
- package/dist/internal/json-dir-store.d.ts +0 -32
- package/dist/internal/json-dir-store.d.ts.map +0 -1
- package/dist/internal/persistence-coordinator.d.ts +0 -127
- package/dist/internal/persistence-coordinator.d.ts.map +0 -1
- package/dist/persistence.d.ts +0 -184
- package/dist/persistence.d.ts.map +0 -1
- package/dist/playground/assets/cursor-icons-16-CQ50JpfO.woff2 +0 -0
- package/dist/playground/assets/index-BVMOoiek.js +0 -86
- package/dist/playground/assets/index-DYmP4b--.css +0 -1
- /package/dist/docs/assets/{guides_slack.md.FWale6Ip.lean.js → guides_slack.md.D_xFKlnF.lean.js} +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads an agent directory's `.env.local` (and each immediate child's,
|
|
3
|
+
* for multi-agent hosts) into process.env. Real env always wins —
|
|
4
|
+
* `process.loadEnvFile` never overrides. Values a previous call loaded are
|
|
5
|
+
* refreshed, so a reload picks up edits made since.
|
|
6
|
+
*/
|
|
7
|
+
export declare function loadAgentLocalEnv(dir: string): string[];
|
|
8
|
+
//# sourceMappingURL=local-env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-env.d.ts","sourceRoot":"","sources":["../../src/internal/local-env.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAsCvD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads an agent directory's `.env.local` (and each immediate child's,
|
|
3
|
+
* for multi-agent hosts) into process.env. Real env always wins —
|
|
4
|
+
* `process.loadEnvFile` never overrides. Values a previous call loaded are
|
|
5
|
+
* refreshed, so a reload picks up edits made since.
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
// Not real env, so a reload has to clear them first: loadEnvFile skips
|
|
10
|
+
// anything already in process.env, which would pin the first-boot values.
|
|
11
|
+
let fileLoadedKeys = new Set();
|
|
12
|
+
export function loadAgentLocalEnv(dir) {
|
|
13
|
+
for (const key of fileLoadedKeys) {
|
|
14
|
+
delete process.env[key];
|
|
15
|
+
}
|
|
16
|
+
const realKeys = new Set(Object.keys(process.env));
|
|
17
|
+
const loaded = [];
|
|
18
|
+
const tryLoad = (path) => {
|
|
19
|
+
if (!existsSync(path)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
process.loadEnvFile(path);
|
|
23
|
+
loaded.push(path);
|
|
24
|
+
};
|
|
25
|
+
const trackLoadedKeys = () => {
|
|
26
|
+
fileLoadedKeys = new Set(Object.keys(process.env).filter((key) => !realKeys.has(key)));
|
|
27
|
+
};
|
|
28
|
+
tryLoad(join(dir, ".env.local"));
|
|
29
|
+
let children;
|
|
30
|
+
try {
|
|
31
|
+
children = readdirSync(dir, { withFileTypes: true })
|
|
32
|
+
.filter((entry) => entry.isDirectory() && !entry.name.startsWith("."))
|
|
33
|
+
.map((entry) => entry.name);
|
|
34
|
+
}
|
|
35
|
+
catch (_a) {
|
|
36
|
+
trackLoadedKeys();
|
|
37
|
+
return loaded;
|
|
38
|
+
}
|
|
39
|
+
for (const child of children) {
|
|
40
|
+
if (child === "node_modules") {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
tryLoad(join(dir, child, ".env.local"));
|
|
44
|
+
}
|
|
45
|
+
trackLoadedKeys();
|
|
46
|
+
return loaded;
|
|
47
|
+
}
|
|
@@ -18,6 +18,9 @@ export declare function playgroundBundleExists(): boolean;
|
|
|
18
18
|
* The SPA `index.html` with a `<base href>` injected so its relative asset
|
|
19
19
|
* URLs resolve under the mount point (`/playground/` or `/<slug>/playground/`).
|
|
20
20
|
* Falls back to a helpful placeholder page when the bundle is missing.
|
|
21
|
+
* The hosted alias performs the same injection for its central copy
|
|
22
|
+
* (`backend/server/src/agentServe/aliasPlaygroundShell.ts`) — keep them
|
|
23
|
+
* behaviorally aligned.
|
|
21
24
|
*/
|
|
22
25
|
export declare function renderPlaygroundIndexHtml(baseHref: string): string;
|
|
23
26
|
/** Serve one built asset from `dist/playground/assets/` by filename. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../../../src/internal/playground/static.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAcH,iFAAiF;AACjF,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAiBvD,CAAC;AAEF,uEAAuE;AACvE,wBAAgB,sBAAsB,IAAI,OAAO,CAEhD;AAED
|
|
1
|
+
{"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../../../src/internal/playground/static.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAcH,iFAAiF;AACjF,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAiBvD,CAAC;AAEF,uEAAuE;AACvE,wBAAgB,sBAAsB,IAAI,OAAO,CAEhD;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAUlE;AAED,wEAAwE;AACxE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAsB5D;AAED,6CAA6C;AAC7C,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,+EAA+E;AAC/E,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,CAiBvE"}
|
|
@@ -45,6 +45,9 @@ export function playgroundBundleExists() {
|
|
|
45
45
|
* The SPA `index.html` with a `<base href>` injected so its relative asset
|
|
46
46
|
* URLs resolve under the mount point (`/playground/` or `/<slug>/playground/`).
|
|
47
47
|
* Falls back to a helpful placeholder page when the bundle is missing.
|
|
48
|
+
* The hosted alias performs the same injection for its central copy
|
|
49
|
+
* (`backend/server/src/agentServe/aliasPlaygroundShell.ts`) — keep them
|
|
50
|
+
* behaviorally aligned.
|
|
48
51
|
*/
|
|
49
52
|
export function renderPlaygroundIndexHtml(baseHref) {
|
|
50
53
|
if (!playgroundBundleExists()) {
|
|
@@ -34,6 +34,11 @@ export interface RunSessionResult {
|
|
|
34
34
|
events: SessionEvent[];
|
|
35
35
|
trajectory: Trajectory;
|
|
36
36
|
ok: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Index to pass as `startIndex` on the next call for this session. Undefined
|
|
39
|
+
* when the turn streamed nothing, in which case reuse the previous value.
|
|
40
|
+
*/
|
|
41
|
+
nextEventIndex?: number;
|
|
37
42
|
}
|
|
38
43
|
/**
|
|
39
44
|
* Run one or more messages against a live agent-serve base URL
|
|
@@ -43,6 +48,16 @@ export declare function runSession(options: RunClientOptions & {
|
|
|
43
48
|
messages: string[];
|
|
44
49
|
sessionId?: string;
|
|
45
50
|
continuationToken?: string;
|
|
51
|
+
/**
|
|
52
|
+
* First event index to read when resuming an existing session.
|
|
53
|
+
*
|
|
54
|
+
* The stream replays from `startIndex` and this client stops at the first
|
|
55
|
+
* terminal event, so a caller that sends several turns across separate
|
|
56
|
+
* `runSession` calls **must** pass the index after its last consumed event
|
|
57
|
+
* (see {@link RunSessionResult.nextEventIndex}). Omitting it replays the
|
|
58
|
+
* earlier turn and returns those stale events instead of the new turn's.
|
|
59
|
+
*/
|
|
60
|
+
startIndex?: number;
|
|
46
61
|
/** Applied only when creating a new session (first message). */
|
|
47
62
|
workspaceDir?: string;
|
|
48
63
|
/** Applied only when creating a new session (first message). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-client.d.ts","sourceRoot":"","sources":["../../src/internal/run-client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEnE,6EAA6E;AAC7E,qBAAa,sBAAuB,SAAQ,KAAK;IAG7C,QAAQ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AAW,CAAC;IACrB,qEAAqE;IACrE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACxC;;;OAGG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,EAAE,EAAE,OAAO,CAAC;IACZ;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAQD;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,gBAAgB,GAAG;IAC1B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gEAAgE;IAChE,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,gEAAgE;IAChE,KAAK,CAAC,EAAE,iBAAiB,CAAC;CAC3B,GACA,OAAO,CAAC,gBAAgB,CAAC,CA0D3B"}
|
|
@@ -35,6 +35,7 @@ const TERMINAL_TYPES = new Set([
|
|
|
35
35
|
*/
|
|
36
36
|
export function runSession(options) {
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
var _a;
|
|
38
39
|
if (options.messages.length === 0) {
|
|
39
40
|
throw new Error("runSession requires at least one message");
|
|
40
41
|
}
|
|
@@ -42,7 +43,7 @@ export function runSession(options) {
|
|
|
42
43
|
let sessionId = options.sessionId;
|
|
43
44
|
let continuationToken = options.continuationToken;
|
|
44
45
|
const allEvents = [];
|
|
45
|
-
let nextEventIndex = 0;
|
|
46
|
+
let nextEventIndex = (_a = options.startIndex) !== null && _a !== void 0 ? _a : 0;
|
|
46
47
|
const auth = {
|
|
47
48
|
bearerToken: options.bearerToken,
|
|
48
49
|
headers: options.headers,
|
|
@@ -78,7 +79,7 @@ export function runSession(options) {
|
|
|
78
79
|
throw new Error("server did not return a session id");
|
|
79
80
|
}
|
|
80
81
|
const trajectory = buildTrajectory(allEvents);
|
|
81
|
-
return Object.assign(Object.assign({ sessionId }, (continuationToken === undefined ? {} : { continuationToken })), { baseUrl, events: allEvents, trajectory, ok: trajectory.ok });
|
|
82
|
+
return Object.assign(Object.assign({ sessionId }, (continuationToken === undefined ? {} : { continuationToken })), { baseUrl, events: allEvents, trajectory, ok: trajectory.ok, nextEventIndex: allEvents.length === 0 ? undefined : nextEventIndex });
|
|
82
83
|
});
|
|
83
84
|
}
|
|
84
85
|
function runOneTurn(args) {
|
|
@@ -5,13 +5,33 @@
|
|
|
5
5
|
* settings; cloud agents use Cursor cloud (`bc-…` ids) with optional
|
|
6
6
|
* `cloud` options from `defineAgent`.
|
|
7
7
|
*/
|
|
8
|
-
import { type LocalAgentStore, type ModelSelection } from "@cursor/sdk";
|
|
8
|
+
import { type LocalAgentStore, type ModelSelection, type RunResult } from "@cursor/sdk";
|
|
9
9
|
import { type ModelSetting, type RunnerTurnRequest, type TurnOutcome } from "../types.js";
|
|
10
10
|
/** Internal seam between the session engine and the Cursor SDK harness. */
|
|
11
11
|
export interface AgentRunner {
|
|
12
12
|
runTurn(request: RunnerTurnRequest): Promise<TurnOutcome>;
|
|
13
|
+
/**
|
|
14
|
+
* Resolve a local workspace before any session needs it, so the first turn
|
|
15
|
+
* is not the one that pays for it. Best effort, hence the reported outcome:
|
|
16
|
+
* a runner that cannot warm must say so rather than let a caller log
|
|
17
|
+
* success over a workspace that was never touched.
|
|
18
|
+
*/
|
|
19
|
+
prewarm?(request: RunnerPrewarmRequest): Promise<PrewarmOutcome>;
|
|
13
20
|
dispose?(): Promise<void>;
|
|
14
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* The parts of a turn that decide which local executor it runs on. Must stay
|
|
24
|
+
* a subset of {@link RunnerTurnRequest} — anything that disagrees warms an
|
|
25
|
+
* executor no turn will ask for.
|
|
26
|
+
*/
|
|
27
|
+
export type RunnerPrewarmRequest = Pick<RunnerTurnRequest, "workspaceDir" | "runnerStateDir" | "sandbox" | "mcpServers" | "subagents" | "model">;
|
|
28
|
+
/** Whether a workspace was actually resolved, and why not when it wasn't. */
|
|
29
|
+
export type PrewarmOutcome = {
|
|
30
|
+
readonly warmed: true;
|
|
31
|
+
} | {
|
|
32
|
+
readonly warmed: false;
|
|
33
|
+
readonly reason: string;
|
|
34
|
+
};
|
|
15
35
|
export interface CursorSdkRunnerOptions {
|
|
16
36
|
/** Cursor API key. Defaults to the `CURSOR_API_KEY` environment variable. */
|
|
17
37
|
apiKey?: string;
|
|
@@ -28,10 +48,24 @@ export declare class CursorSdkRunner implements AgentRunner {
|
|
|
28
48
|
private readonly options;
|
|
29
49
|
private readonly agents;
|
|
30
50
|
private readonly stores;
|
|
51
|
+
private readonly prewarmReleases;
|
|
31
52
|
constructor(options?: CursorSdkRunnerOptions);
|
|
32
53
|
runTurn(request: RunnerTurnRequest): Promise<TurnOutcome>;
|
|
54
|
+
/**
|
|
55
|
+
* Build the local executor for a workspace before any session asks for it.
|
|
56
|
+
* The warmed executor is reference counted, so the lease is held until
|
|
57
|
+
* {@link dispose}; dropping it early would tear the workspace back down.
|
|
58
|
+
*/
|
|
59
|
+
prewarm(request: RunnerPrewarmRequest): Promise<PrewarmOutcome>;
|
|
33
60
|
dispose(): Promise<void>;
|
|
34
61
|
private getAgent;
|
|
62
|
+
private requireApiKey;
|
|
63
|
+
private buildSharedOptions;
|
|
64
|
+
/**
|
|
65
|
+
* The options that decide which local executor a turn runs on. Prewarming
|
|
66
|
+
* goes through here too, so a warmed workspace is the one turns land on.
|
|
67
|
+
*/
|
|
68
|
+
private buildLocalOptions;
|
|
35
69
|
private openAgent;
|
|
36
70
|
private openLocalAgent;
|
|
37
71
|
private openCloudAgent;
|
|
@@ -47,4 +81,5 @@ export declare function isServerMintedCloudAgentId(id: string): boolean;
|
|
|
47
81
|
*/
|
|
48
82
|
export declare function isLocalAgentNotFoundError(error: unknown, agentId: string): boolean;
|
|
49
83
|
export declare function toModelSelection(model: ModelSetting): ModelSelection;
|
|
84
|
+
export declare function runErrorMessage(result: Pick<RunResult, "error">): string;
|
|
50
85
|
//# sourceMappingURL=sdk-runner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-runner.d.ts","sourceRoot":"","sources":["../../src/internal/sdk-runner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,
|
|
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;AACrB,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAEjB,MAAM,aAAa,CAAC;AAErB,2EAA2E;AAC3E,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAC1D;;;;;OAKG;IACH,OAAO,CAAC,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IACjE,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAED;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CACrC,iBAAiB,EACf,cAAc,GACd,gBAAgB,GAChB,SAAS,GACT,YAAY,GACZ,WAAW,GACX,OAAO,CACV,CAAC;AAEF,6EAA6E;AAC7E,M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gBAAgB,CAAC,KAAK,EAAE,YAAY,GAAG,cAAc,CAQpE;AAmED,wBAAgB,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,MAAM,CAExE"}
|
|
@@ -15,13 +15,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
17
|
import { mkdir } from "node:fs/promises";
|
|
18
|
-
import { Agent, JsonlLocalAgentStore, } from "@cursor/sdk";
|
|
18
|
+
import { Agent, createAgentPlatform, JsonlLocalAgentStore, } from "@cursor/sdk";
|
|
19
19
|
import { DEFAULT_MODEL, } from "../types.js";
|
|
20
20
|
export class CursorSdkRunner {
|
|
21
21
|
constructor(options = {}) {
|
|
22
22
|
this.options = options;
|
|
23
23
|
this.agents = new Map();
|
|
24
24
|
this.stores = new Map();
|
|
25
|
+
this.prewarmReleases = [];
|
|
25
26
|
}
|
|
26
27
|
runTurn(request) {
|
|
27
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -79,8 +80,30 @@ export class CursorSdkRunner {
|
|
|
79
80
|
}
|
|
80
81
|
});
|
|
81
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Build the local executor for a workspace before any session asks for it.
|
|
85
|
+
* The warmed executor is reference counted, so the lease is held until
|
|
86
|
+
* {@link dispose}; dropping it early would tear the workspace back down.
|
|
87
|
+
*/
|
|
88
|
+
prewarm(request) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
const platform = (yield createAgentPlatform());
|
|
91
|
+
if (typeof platform.prewarmLocalWorkspace !== "function") {
|
|
92
|
+
// Older @cursor/sdk. Turns still work; they just pay on the first one.
|
|
93
|
+
return {
|
|
94
|
+
warmed: false,
|
|
95
|
+
reason: "the installed @cursor/sdk has no prewarmLocalWorkspace; upgrade it to warm the workspace before the first turn",
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
const release = yield platform.prewarmLocalWorkspace(yield this.buildLocalOptions(request));
|
|
99
|
+
this.prewarmReleases.push(release);
|
|
100
|
+
return { warmed: true };
|
|
101
|
+
});
|
|
102
|
+
}
|
|
82
103
|
dispose() {
|
|
83
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
const releases = this.prewarmReleases.splice(0);
|
|
106
|
+
yield Promise.allSettled(releases.map((release) => release()));
|
|
84
107
|
const agents = yield Promise.allSettled([...this.agents.values()]);
|
|
85
108
|
this.agents.clear();
|
|
86
109
|
for (const settled of agents) {
|
|
@@ -101,37 +124,50 @@ export class CursorSdkRunner {
|
|
|
101
124
|
}
|
|
102
125
|
return agentPromise;
|
|
103
126
|
}
|
|
127
|
+
requireApiKey() {
|
|
128
|
+
var _a;
|
|
129
|
+
const apiKey = (_a = this.options.apiKey) !== null && _a !== void 0 ? _a : process.env.CURSOR_API_KEY;
|
|
130
|
+
if (apiKey === undefined || apiKey.trim() === "") {
|
|
131
|
+
throw new Error("The Cursor SDK runner requires a Cursor credential: run `agent-serve login`, set CURSOR_API_KEY, or pass serve({ apiKey }).");
|
|
132
|
+
}
|
|
133
|
+
return apiKey;
|
|
134
|
+
}
|
|
135
|
+
buildSharedOptions(request) {
|
|
136
|
+
var _a;
|
|
137
|
+
const subagents = toAgentDefinitions(request.subagents);
|
|
138
|
+
return Object.assign(Object.assign({ model: toModelSelection((_a = request.model) !== null && _a !== void 0 ? _a : DEFAULT_MODEL), apiKey: this.requireApiKey() }, (Object.keys(request.mcpServers).length > 0
|
|
139
|
+
? { mcpServers: request.mcpServers }
|
|
140
|
+
: {})), (subagents === undefined ? {} : { agents: subagents }));
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The options that decide which local executor a turn runs on. Prewarming
|
|
144
|
+
* goes through here too, so a warmed workspace is the one turns land on.
|
|
145
|
+
*/
|
|
146
|
+
buildLocalOptions(request) {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
var _a;
|
|
149
|
+
const store = (_a = this.options.store) !== null && _a !== void 0 ? _a : (yield this.getStore(request.runnerStateDir));
|
|
150
|
+
return Object.assign(Object.assign({}, this.buildSharedOptions(request)), { local: Object.assign({ cwd: request.workspaceDir, settingSources: ["project"], store }, (request.sandbox === true
|
|
151
|
+
? { sandboxOptions: { enabled: true } }
|
|
152
|
+
: {})) });
|
|
153
|
+
});
|
|
154
|
+
}
|
|
104
155
|
openAgent(request) {
|
|
105
156
|
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
var _a, _b;
|
|
107
|
-
const apiKey = (_a = this.options.apiKey) !== null && _a !== void 0 ? _a : process.env.CURSOR_API_KEY;
|
|
108
|
-
if (apiKey === undefined || apiKey.trim() === "") {
|
|
109
|
-
throw new Error("The Cursor SDK runner requires a Cursor credential: run `agent-serve login`, set CURSOR_API_KEY, or pass serve({ apiKey }).");
|
|
110
|
-
}
|
|
111
|
-
const model = (_b = request.model) !== null && _b !== void 0 ? _b : DEFAULT_MODEL;
|
|
112
|
-
const subagents = toAgentDefinitions(request.subagents);
|
|
113
|
-
const shared = Object.assign(Object.assign({ model: toModelSelection(model), apiKey }, (Object.keys(request.mcpServers).length > 0
|
|
114
|
-
? { mcpServers: request.mcpServers }
|
|
115
|
-
: {})), (subagents === undefined ? {} : { agents: subagents }));
|
|
116
157
|
if (request.runtime === "cloud") {
|
|
117
|
-
return this.openCloudAgent(request,
|
|
158
|
+
return this.openCloudAgent(request, this.buildSharedOptions(request));
|
|
118
159
|
}
|
|
119
|
-
return this.openLocalAgent(request
|
|
160
|
+
return this.openLocalAgent(request);
|
|
120
161
|
});
|
|
121
162
|
}
|
|
122
|
-
openLocalAgent(request
|
|
163
|
+
openLocalAgent(request) {
|
|
123
164
|
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
var _a, _b, _c
|
|
125
|
-
const
|
|
126
|
-
const options = Object.assign(Object.assign({}, shared), { local: {
|
|
127
|
-
cwd: request.workspaceDir,
|
|
128
|
-
settingSources: ["project"],
|
|
129
|
-
store,
|
|
130
|
-
} });
|
|
165
|
+
var _a, _b, _c;
|
|
166
|
+
const options = yield this.buildLocalOptions(request);
|
|
131
167
|
if (request.isFirstTurn || request.sdkAgentId === undefined) {
|
|
132
|
-
return Agent.create(Object.assign(Object.assign({}, options), { agentId: (
|
|
168
|
+
return Agent.create(Object.assign(Object.assign({}, options), { agentId: (_a = request.sdkAgentId) !== null && _a !== void 0 ? _a : request.sessionId }));
|
|
133
169
|
}
|
|
134
|
-
const agentId = (
|
|
170
|
+
const agentId = (_b = request.sdkAgentId) !== null && _b !== void 0 ? _b : request.sessionId;
|
|
135
171
|
try {
|
|
136
172
|
return yield Agent.resume(agentId, options);
|
|
137
173
|
}
|
|
@@ -144,7 +180,7 @@ export class CursorSdkRunner {
|
|
|
144
180
|
// conversation under the same id beats failing this thread's turns
|
|
145
181
|
// forever ("Agent … not found" on every follow-up). The channel's
|
|
146
182
|
// warm-turn prompt context re-hydrates the thread history.
|
|
147
|
-
((
|
|
183
|
+
((_c = this.options.logger) !== null && _c !== void 0 ? _c : (() => { }))(`[agentkit] no stored conversation for ${agentId} on this host; starting a fresh one`);
|
|
148
184
|
return Agent.create(Object.assign(Object.assign({}, options), { agentId }));
|
|
149
185
|
}
|
|
150
186
|
});
|
|
@@ -242,6 +278,10 @@ function toTurnOutcome(result) {
|
|
|
242
278
|
? {}
|
|
243
279
|
: { reasoningTokens: result.usage.reasoningTokens }));
|
|
244
280
|
return Object.assign(Object.assign(Object.assign({ status: result.status }, (result.result === undefined ? {} : { result: result.result })), (result.status === "error"
|
|
245
|
-
? { errorMessage:
|
|
281
|
+
? { errorMessage: runErrorMessage(result) }
|
|
246
282
|
: {})), (usage === undefined ? {} : { usage }));
|
|
247
283
|
}
|
|
284
|
+
export function runErrorMessage(result) {
|
|
285
|
+
var _a, _b;
|
|
286
|
+
return ((_b = (_a = result.error) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.trim()) || "The Cursor agent run failed";
|
|
287
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/internal/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA4BH,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAOhB,YAAY,EACb,MAAM,aAAa,CAAC;AAqFrB,OAAO,EAAE,KAAK,WAAW,EAAmB,MAAM,iBAAiB,CAAC;AAapE,8EAA8E;AAC9E,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,CAAC;CACvB;AAYD,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,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/internal/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA4BH,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAOhB,YAAY,EACb,MAAM,aAAa,CAAC;AAqFrB,OAAO,EAAE,KAAK,WAAW,EAAmB,MAAM,iBAAiB,CAAC;AAapE,8EAA8E;AAC9E,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,CAAC;CACvB;AAYD,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,CAypB3B"}
|
package/dist/internal/server.js
CHANGED
|
@@ -241,6 +241,11 @@ export function startServer(mounts_1) {
|
|
|
241
241
|
// Rehydrate sessions from the authored storage sink before any
|
|
242
242
|
// channel or route can address them (continuation tokens must resolve).
|
|
243
243
|
yield engine.restoreStoredSessions();
|
|
244
|
+
// Resolve a shared harness workspace in the background: on a large repo
|
|
245
|
+
// that takes seconds, and a deployment coming online should absorb it
|
|
246
|
+
// rather than whoever sends the first message. No-op unless the agent
|
|
247
|
+
// pins `local.workspaceDir`.
|
|
248
|
+
void engine.prewarmSharedWorkspace();
|
|
244
249
|
if (!githubAuthWarmed) {
|
|
245
250
|
// Soft ambient GitHub auth check before channel onStart (which may call
|
|
246
251
|
// host.github). Missing auth is a warning only — serve still starts.
|
|
@@ -687,7 +692,11 @@ function mountAgentRoutes(router, runtime, args) {
|
|
|
687
692
|
method: "GET",
|
|
688
693
|
pattern: `${base}/v1/meta`,
|
|
689
694
|
auth: "none",
|
|
690
|
-
handler: () => jsonResponse(Object.assign({ name: project.name, dev, basePath: base
|
|
695
|
+
handler: () => jsonResponse(Object.assign({ name: project.name, dev, basePath: base,
|
|
696
|
+
// Framework version, for SPA/engine skew observability now that the
|
|
697
|
+
// hosted playground shell is served centrally (backend deploys)
|
|
698
|
+
// while engines stay on their install-time version.
|
|
699
|
+
version: packageVersion() }, (multi ? { indexPath: "/" } : {}))),
|
|
691
700
|
});
|
|
692
701
|
router.add({
|
|
693
702
|
method: "GET",
|
|
@@ -227,15 +227,28 @@ export declare class SessionEngine {
|
|
|
227
227
|
getContinuationLastBotMessageTs(channelId: string, continuationToken: string): Promise<string | undefined>;
|
|
228
228
|
interruptContinuation(channelId: string, continuationToken: string): Promise<boolean>;
|
|
229
229
|
/**
|
|
230
|
-
* Local harness cwd for a session: per-send override, else
|
|
231
|
-
* `<agent.local.cwd>/<sessionId>`, else
|
|
230
|
+
* Local harness cwd for a session: per-send override, else the shared
|
|
231
|
+
* `agent.local.workspaceDir`, else `<agent.local.cwd>/<sessionId>`, else
|
|
232
|
+
* the durable session workspace.
|
|
232
233
|
*/
|
|
233
234
|
harnessCwd(record: SessionRecord): string;
|
|
234
235
|
/**
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
236
|
+
* True when the harness cwd is a directory the session does not own — a
|
|
237
|
+
* per-send override (e.g. a PR worktree) or a workspace shared by every
|
|
238
|
+
* session. Agent scaffold has to stay out of those, so it lands in the
|
|
239
|
+
* durable session workspace and the instructions travel inline instead.
|
|
238
240
|
*/
|
|
241
|
+
private hasBorrowedWorkspace;
|
|
242
|
+
/**
|
|
243
|
+
* Resolve the shared harness workspace during startup, so the first session
|
|
244
|
+
* is not the one that waits for it. Only possible with
|
|
245
|
+
* `local.workspaceDir`: every other layout gives a session its own cwd,
|
|
246
|
+
* which is unknowable until that session exists.
|
|
247
|
+
*
|
|
248
|
+
* Best effort — warming is an optimization, and a turn rebuilds on its own.
|
|
249
|
+
*/
|
|
250
|
+
prewarmSharedWorkspace(): Promise<void>;
|
|
251
|
+
/** Directory that receives AGENTS.md / skills / agent tools. */
|
|
239
252
|
private scaffoldDir;
|
|
240
253
|
private executeTurn;
|
|
241
254
|
private buildTurnRequest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-engine.d.ts","sourceRoot":"","sources":["../../src/internal/session-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAYH,OAAO,EACL,mBAAmB,EACnB,eAAe,EAChB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EAEtB,KAAK,cAAc,EAInB,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAG1B,KAAK,eAAe,EACpB,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"session-engine.d.ts","sourceRoot":"","sources":["../../src/internal/session-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAYH,OAAO,EACL,mBAAmB,EACnB,e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AC,CAU3B;CACF"}
|
|
@@ -666,27 +666,72 @@ export class SessionEngine {
|
|
|
666
666
|
});
|
|
667
667
|
}
|
|
668
668
|
/**
|
|
669
|
-
* Local harness cwd for a session: per-send override, else
|
|
670
|
-
* `<agent.local.cwd>/<sessionId>`, else
|
|
669
|
+
* Local harness cwd for a session: per-send override, else the shared
|
|
670
|
+
* `agent.local.workspaceDir`, else `<agent.local.cwd>/<sessionId>`, else
|
|
671
|
+
* the durable session workspace.
|
|
671
672
|
*/
|
|
672
673
|
harnessCwd(record) {
|
|
673
|
-
var _a;
|
|
674
|
+
var _a, _b;
|
|
674
675
|
if (record.workspaceOverride !== undefined) {
|
|
675
676
|
return record.workspaceOverride;
|
|
676
677
|
}
|
|
677
|
-
const
|
|
678
|
+
const shared = (_a = this.project.agent.local) === null || _a === void 0 ? void 0 : _a.workspaceDir;
|
|
679
|
+
if (shared !== undefined) {
|
|
680
|
+
return shared;
|
|
681
|
+
}
|
|
682
|
+
const agentCwd = (_b = this.project.agent.local) === null || _b === void 0 ? void 0 : _b.cwd;
|
|
678
683
|
if (agentCwd !== undefined) {
|
|
679
684
|
return join(agentCwd, record.sessionId);
|
|
680
685
|
}
|
|
681
686
|
return this.sessions.workspaceDir(record.sessionId);
|
|
682
687
|
}
|
|
683
688
|
/**
|
|
684
|
-
*
|
|
685
|
-
*
|
|
686
|
-
*
|
|
689
|
+
* True when the harness cwd is a directory the session does not own — a
|
|
690
|
+
* per-send override (e.g. a PR worktree) or a workspace shared by every
|
|
691
|
+
* session. Agent scaffold has to stay out of those, so it lands in the
|
|
692
|
+
* durable session workspace and the instructions travel inline instead.
|
|
693
|
+
*/
|
|
694
|
+
hasBorrowedWorkspace(record) {
|
|
695
|
+
var _a;
|
|
696
|
+
return (record.workspaceOverride !== undefined ||
|
|
697
|
+
((_a = this.project.agent.local) === null || _a === void 0 ? void 0 : _a.workspaceDir) !== undefined);
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Resolve the shared harness workspace during startup, so the first session
|
|
701
|
+
* is not the one that waits for it. Only possible with
|
|
702
|
+
* `local.workspaceDir`: every other layout gives a session its own cwd,
|
|
703
|
+
* which is unknowable until that session exists.
|
|
704
|
+
*
|
|
705
|
+
* Best effort — warming is an optimization, and a turn rebuilds on its own.
|
|
687
706
|
*/
|
|
707
|
+
prewarmSharedWorkspace() {
|
|
708
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
709
|
+
var _a, _b;
|
|
710
|
+
const agent = this.project.agent;
|
|
711
|
+
const workspaceDir = (_a = agent.local) === null || _a === void 0 ? void 0 : _a.workspaceDir;
|
|
712
|
+
if (workspaceDir === undefined ||
|
|
713
|
+
agent.runtime !== "local" ||
|
|
714
|
+
this.runner.prewarm === undefined) {
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
const startedAt = Date.now();
|
|
718
|
+
try {
|
|
719
|
+
const outcome = yield this.runner.prewarm(Object.assign({ workspaceDir, runnerStateDir: join(this.stateRoot, "runner"), sandbox: ((_b = agent.local) === null || _b === void 0 ? void 0 : _b.sandbox) === true, mcpServers: this.buildMcpServers("local"), subagents: buildRunnerSubagents(agent) }, (agent.model === undefined ? {} : { model: agent.model })));
|
|
720
|
+
// Report what happened rather than that the call returned: a runner
|
|
721
|
+
// that cannot warm resolves cleanly, and logging success there would
|
|
722
|
+
// tell an operator the workspace is hot when nothing touched it.
|
|
723
|
+
this.logger(outcome.warmed
|
|
724
|
+
? `[agentkit] warmed ${workspaceDir} in ${Date.now() - startedAt}ms`
|
|
725
|
+
: `[agentkit] did not warm ${workspaceDir}: ${outcome.reason}`);
|
|
726
|
+
}
|
|
727
|
+
catch (error) {
|
|
728
|
+
this.logger(`[agentkit] could not warm ${workspaceDir}: ${describeError(error)}`);
|
|
729
|
+
}
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
/** Directory that receives AGENTS.md / skills / agent tools. */
|
|
688
733
|
scaffoldDir(record) {
|
|
689
|
-
if (record
|
|
734
|
+
if (this.hasBorrowedWorkspace(record)) {
|
|
690
735
|
return this.sessions.workspaceDir(record.sessionId);
|
|
691
736
|
}
|
|
692
737
|
return this.harnessCwd(record);
|
|
@@ -752,12 +797,12 @@ export class SessionEngine {
|
|
|
752
797
|
});
|
|
753
798
|
}
|
|
754
799
|
// The harness only loads the scaffolded AGENTS.md when the session
|
|
755
|
-
// workspace is its own project root.
|
|
756
|
-
// (PR worktree) the scaffold lands elsewhere, and a
|
|
757
|
-
// inside a git repo re-roots harness rules at that
|
|
758
|
-
// cases deliver instructions inline on the first turn
|
|
800
|
+
// workspace is its own project root. When the harness cwd is borrowed
|
|
801
|
+
// (PR worktree, shared checkout) the scaffold lands elsewhere, and a
|
|
802
|
+
// workspace nested inside a git repo re-roots harness rules at that
|
|
803
|
+
// repo — in both cases deliver instructions inline on the first turn.
|
|
759
804
|
const instructionsInvisibleToHarness = isFirstTurn &&
|
|
760
|
-
(record
|
|
805
|
+
(this.hasBorrowedWorkspace(record) ||
|
|
761
806
|
(yield isNestedInGitRepo(harnessCwd)));
|
|
762
807
|
const request = this.buildTurnRequest(record, agent, turnId, message, isFirstTurn, instructionsInvisibleToHarness, emit, (update) => __awaiter(this, void 0, void 0, function* () {
|
|
763
808
|
mapper.handleUpdate(update);
|
|
@@ -833,7 +878,7 @@ export class SessionEngine {
|
|
|
833
878
|
});
|
|
834
879
|
}
|
|
835
880
|
buildTurnRequest(record, agent, turnId, prompt, isFirstTurn, instructionsInvisibleToHarness, emit, onUpdate, signal) {
|
|
836
|
-
var _a, _b;
|
|
881
|
+
var _a, _b, _c;
|
|
837
882
|
// Per-session cloud attach (channel/tool handoff) forces cloud runtime
|
|
838
883
|
// even when the agent defaults to local for chat server tools.
|
|
839
884
|
const runtime = resolveSessionRuntime({
|
|
@@ -865,17 +910,17 @@ export class SessionEngine {
|
|
|
865
910
|
}
|
|
866
911
|
else if (instructionsInvisibleToHarness) {
|
|
867
912
|
// Local workspace whose AGENTS.md the harness will not load. With a
|
|
868
|
-
//
|
|
869
|
-
//
|
|
870
|
-
//
|
|
871
|
-
const includeScripts = record
|
|
913
|
+
// borrowed harness cwd, agent tool scripts live only in the durable
|
|
914
|
+
// scaffold dir — embed bodies like cloud. Otherwise the catalog can
|
|
915
|
+
// reference on-disk paths under the harness cwd.
|
|
916
|
+
const includeScripts = this.hasBorrowedWorkspace(record);
|
|
872
917
|
const preamble = buildAgentsMdContent(agent, { includeScripts });
|
|
873
918
|
turnPrompt = `${preamble}\n\n${turnPrompt}`;
|
|
874
919
|
}
|
|
875
920
|
}
|
|
876
921
|
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ sessionId: record.sessionId }, (record.sdkAgentId === undefined
|
|
877
922
|
? {}
|
|
878
|
-
: { sdkAgentId: record.sdkAgentId })), { workspaceDir: this.harnessCwd(record), runnerStateDir: join(this.stateRoot, "runner"), prompt: turnPrompt, isFirstTurn }), (agent.model === undefined ? {} : { model: agent.model })), { runtime }), (mergedCloud === undefined ? {} : { cloud: mergedCloud })), { customTools: runtime === "local" ? this.buildCustomTools(record, turnId, emit) : {}, mcpServers: this.buildMcpServers(runtime), subagents: agent
|
|
923
|
+
: { sdkAgentId: record.sdkAgentId })), { workspaceDir: this.harnessCwd(record), sandbox: ((_c = this.project.agent.local) === null || _c === void 0 ? void 0 : _c.sandbox) === true, runnerStateDir: join(this.stateRoot, "runner"), prompt: turnPrompt, isFirstTurn }), (agent.model === undefined ? {} : { model: agent.model })), { runtime }), (mergedCloud === undefined ? {} : { cloud: mergedCloud })), { customTools: runtime === "local" ? this.buildCustomTools(record, turnId, emit) : {}, mcpServers: this.buildMcpServers(runtime), subagents: buildRunnerSubagents(agent), onUpdate,
|
|
879
924
|
signal,
|
|
880
925
|
// Local follow-ups expire any lingering active run so a preempted turn
|
|
881
926
|
// (or one orphaned by a crashed process) never blocks this send.
|
|
@@ -1897,6 +1942,14 @@ function subagentPrompt(subagent) {
|
|
|
1897
1942
|
}
|
|
1898
1943
|
return (_a = subagent.description) !== null && _a !== void 0 ? _a : subagent.name;
|
|
1899
1944
|
}
|
|
1945
|
+
/**
|
|
1946
|
+
* Subagents as the runner takes them. Shared by turns and by workspace
|
|
1947
|
+
* warming, which has to describe the same agent a turn would to reach the
|
|
1948
|
+
* executor that turn will run on.
|
|
1949
|
+
*/
|
|
1950
|
+
function buildRunnerSubagents(agent) {
|
|
1951
|
+
return agent.subagents.map((subagent) => { var _a; return (Object.assign({ name: subagent.name, description: (_a = subagent.description) !== null && _a !== void 0 ? _a : subagent.name, prompt: subagentPrompt(subagent) }, (subagent.model === undefined ? {} : { model: subagent.model }))); });
|
|
1952
|
+
}
|
|
1900
1953
|
function describeError(error) {
|
|
1901
1954
|
return error instanceof Error ? error.message : String(error);
|
|
1902
1955
|
}
|