@cursor/july 0.1.40 → 0.1.42
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/AGENTS.md +13 -6
- package/dist/bin/agent-serve.js +28 -9
- package/dist/channels/slack/attachments.d.ts +82 -0
- package/dist/channels/slack/attachments.d.ts.map +1 -0
- package/dist/channels/slack/attachments.js +520 -0
- package/dist/channels/slack/cursor-account.d.ts +7 -1
- package/dist/channels/slack/cursor-account.d.ts.map +1 -1
- package/dist/channels/slack/cursor-account.js +2 -2
- package/dist/channels/slack/dispatch.d.ts +4 -3
- package/dist/channels/slack/dispatch.d.ts.map +1 -1
- package/dist/channels/slack/dispatch.js +84 -21
- package/dist/channels/slack/inbound.d.ts +6 -0
- package/dist/channels/slack/inbound.d.ts.map +1 -1
- package/dist/channels/slack/inbound.js +48 -2
- 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/manifest.d.ts.map +1 -1
- package/dist/channels/slack/manifest.js +1 -0
- package/dist/channels/slack/slack-channel.d.ts.map +1 -1
- package/dist/channels/slack/slack-channel.js +7 -4
- package/dist/channels/slack/types.d.ts +49 -1
- package/dist/channels/slack/types.d.ts.map +1 -1
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +6 -6
- package/dist/docs/assets/{ab.md.6cLOW7--.js → ab.md.hdxsvX5M.js} +2 -2
- package/dist/docs/assets/{app.DpGLSiym.js → app.C4-Gwi7g.js} +1 -1
- package/dist/docs/assets/{building-with-agents.md.txrcGU2B.js → building-with-agents.md.PeZaZA1P.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.BlU3A8EB.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.B11XEMST.js → VPLocalSearchBox.DDoLm843.js} +1 -1
- package/dist/docs/assets/chunks/{theme.iTidHsAx.js → theme.SbjGIiM0.js} +2 -2
- package/dist/docs/assets/{deployment.md.CuK5SNjN.js → deployment.md.BHVjVqRa.js} +4 -4
- package/dist/docs/assets/{deployment.md.CuK5SNjN.lean.js → deployment.md.BHVjVqRa.lean.js} +1 -1
- package/dist/docs/assets/{evals.md.BQXI3rXy.js → evals.md.qeoGgPw0.js} +3 -3
- package/dist/docs/assets/example-agents_index.md.xmJ87d_3.js +2 -0
- package/dist/docs/assets/{guides_webhooks.md.BERuBSJW.js → guides_webhooks.md.DB-r_er9.js} +47 -4
- package/dist/docs/assets/{guides_webhooks.md.BERuBSJW.lean.js → guides_webhooks.md.DB-r_er9.lean.js} +1 -1
- package/dist/docs/assets/index.md.BKpbkCa6.js +24 -0
- package/dist/docs/assets/{index.md.CmhptOmN.lean.js → index.md.BKpbkCa6.lean.js} +1 -1
- package/dist/docs/assets/{quickstart.md.C_b6ESpD.js → quickstart.md.rIbfahJM.js} +4 -4
- package/dist/docs/assets/{reference_cli.md.Byvrg8eu.js → reference_cli.md.DqEqQpGn.js} +5 -5
- package/dist/docs/assets/{reference_cli.md.Byvrg8eu.lean.js → reference_cli.md.DqEqQpGn.lean.js} +1 -1
- package/dist/docs/assets/reference_hooks.md.B40QAG6m.js +14 -0
- package/dist/docs/assets/{reference_hooks.md.BGDw4VLm.lean.js → reference_hooks.md.B40QAG6m.lean.js} +1 -1
- package/dist/docs/assets/{storage.md.mQDtIULc.js → storage.md.DcGSnIxX.js} +10 -4
- package/dist/docs/assets/{storage.md.mQDtIULc.lean.js → storage.md.DcGSnIxX.lean.js} +1 -1
- package/dist/docs/assets/troubleshooting.md.CkgwmVI0.js +1 -0
- package/dist/docs/assets/{troubleshooting.md.B5RVX_tL.lean.js → troubleshooting.md.CkgwmVI0.lean.js} +1 -1
- package/dist/docs/building-with-agents.html +5 -5
- package/dist/docs/concepts.html +3 -3
- package/dist/docs/deployment.html +6 -6
- package/dist/docs/evals.html +7 -7
- 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 +3 -3
- package/dist/docs/example-agents/slack-agent.html +3 -3
- package/dist/docs/example-agents/weather-agent.html +3 -3
- package/dist/docs/guides/agent-to-agent.html +3 -3
- package/dist/docs/guides/cloud-runtime.html +3 -3
- package/dist/docs/guides/github.html +3 -3
- package/dist/docs/guides/human-in-the-loop.html +3 -3
- package/dist/docs/guides/mcp-oauth.html +3 -3
- package/dist/docs/guides/slack.html +3 -3
- package/dist/docs/guides/webhooks.html +49 -6
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +3 -3
- package/dist/docs/index.html +7 -7
- package/dist/docs/quickstart.html +8 -8
- package/dist/docs/reference/agent-config.html +3 -3
- package/dist/docs/reference/artifacts.html +3 -3
- package/dist/docs/reference/channels.html +3 -3
- package/dist/docs/reference/cli.html +8 -8
- package/dist/docs/reference/connections.html +3 -3
- package/dist/docs/reference/hooks.html +9 -7
- 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 +14 -8
- package/dist/docs/troubleshooting.html +5 -5
- package/dist/hooks.d.ts +3 -1
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +3 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/internal/cli-ax.d.ts.map +1 -1
- package/dist/internal/cli-ax.js +22 -2
- package/dist/internal/cli-deploy.d.ts +6 -0
- package/dist/internal/cli-deploy.d.ts.map +1 -1
- package/dist/internal/cli-deploy.js +14 -4
- package/dist/internal/cli-mcp.js +4 -4
- package/dist/internal/deploy-client.js +1 -1
- package/dist/internal/discovery.d.ts.map +1 -1
- package/dist/internal/discovery.js +35 -7
- package/dist/internal/distribution.d.ts.map +1 -1
- package/dist/internal/distribution.js +3 -1
- package/dist/internal/durable-session-store.d.ts +48 -0
- package/dist/internal/durable-session-store.d.ts.map +1 -0
- package/dist/internal/durable-session-store.js +86 -0
- package/dist/internal/hosting.d.ts +1 -1
- package/dist/internal/hosting.js +2 -2
- package/dist/internal/init-project.d.ts +34 -0
- package/dist/internal/init-project.d.ts.map +1 -1
- package/dist/internal/init-project.js +121 -2
- package/dist/internal/ledger-serving.d.ts +101 -0
- package/dist/internal/ledger-serving.d.ts.map +1 -0
- package/dist/internal/ledger-serving.js +174 -0
- package/dist/internal/listen-port.d.ts +22 -0
- package/dist/internal/listen-port.d.ts.map +1 -0
- package/dist/internal/listen-port.js +77 -0
- package/dist/internal/playground/static.d.ts +21 -4
- package/dist/internal/playground/static.d.ts.map +1 -1
- package/dist/internal/playground/static.js +82 -18
- package/dist/internal/sdk-runner.d.ts.map +1 -1
- package/dist/internal/sdk-runner.js +10 -1
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +61 -47
- package/dist/internal/session-engine.d.ts +57 -1
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +118 -28
- package/dist/internal/slack-provision-client.js +1 -1
- package/dist/internal/workspace.d.ts +6 -2
- package/dist/internal/workspace.d.ts.map +1 -1
- package/dist/internal/workspace.js +10 -2
- package/dist/kv/memory-kv.d.ts +23 -0
- package/dist/kv/memory-kv.d.ts.map +1 -0
- package/dist/kv/memory-kv.js +103 -0
- package/dist/kv.d.ts +22 -0
- package/dist/kv.d.ts.map +1 -0
- package/dist/kv.js +20 -0
- package/dist/ledger/session-ledger.d.ts +204 -0
- package/dist/ledger/session-ledger.d.ts.map +1 -0
- package/dist/ledger/session-ledger.js +382 -0
- package/dist/ledger.d.ts +11 -0
- package/dist/ledger.d.ts.map +1 -0
- package/dist/ledger.js +9 -0
- package/dist/playground/assets/index-B3HBneZZ.js +85 -0
- package/dist/playground/assets/index-Bqk9nplh.css +1 -0
- package/dist/playground/index.html +2 -2
- package/dist/storage-backends/cursor-hosted.d.ts +25 -3
- package/dist/storage-backends/cursor-hosted.d.ts.map +1 -1
- package/dist/storage-backends/cursor-hosted.js +50 -2
- package/dist/storage-backends/file-kv.d.ts +5 -2
- package/dist/storage-backends/file-kv.d.ts.map +1 -1
- package/dist/storage-backends/file-kv.js +107 -7
- package/dist/storage.d.ts +60 -5
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +28 -4
- package/dist/types.d.ts +132 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +14 -0
- package/docs/README.md +10 -7
- package/docs/ab.md +2 -2
- package/docs/building-with-agents.md +1 -1
- package/docs/deployment.md +34 -11
- package/docs/evals.md +3 -3
- package/docs/example-agents/index.md +1 -1
- package/docs/guides/webhooks.md +87 -0
- package/docs/quickstart.md +7 -8
- package/docs/reference/cli.md +15 -6
- package/docs/reference/hooks.md +12 -3
- package/docs/storage.md +67 -7
- package/docs/troubleshooting.md +10 -2
- package/package.json +20 -7
- package/skills/create-agent/SKILL.md +1 -1
- package/skills/debug/SKILL.md +4 -0
- package/src/bin/agent-serve.ts +27 -11
- package/src/channels/slack/attachments.ts +635 -0
- package/src/channels/slack/cursor-account.ts +8 -0
- package/src/channels/slack/dispatch.ts +121 -6
- package/src/channels/slack/inbound.ts +60 -0
- package/src/channels/slack/index.ts +1 -0
- package/src/channels/slack/manifest.ts +1 -0
- package/src/channels/slack/slack-channel.ts +7 -0
- package/src/channels/slack/types.ts +47 -1
- package/src/hooks.ts +3 -1
- package/src/index.ts +9 -0
- package/src/internal/cli-ax.ts +25 -1
- package/src/internal/cli-deploy.ts +22 -4
- package/src/internal/cli-mcp.ts +4 -4
- package/src/internal/deploy-client.ts +1 -1
- package/src/internal/discovery.ts +42 -5
- package/src/internal/distribution.ts +3 -1
- package/src/internal/durable-session-store.ts +95 -0
- package/src/internal/hosting.ts +2 -2
- package/src/internal/init-project.ts +151 -2
- package/src/internal/ledger-serving.ts +240 -0
- package/src/internal/listen-port.ts +85 -0
- package/src/internal/playground/static.ts +111 -20
- package/src/internal/sdk-runner.ts +11 -1
- package/src/internal/server.ts +68 -61
- package/src/internal/session-engine.ts +193 -16
- package/src/internal/slack-provision-client.ts +1 -1
- package/src/internal/workspace.ts +14 -3
- package/src/kv/memory-kv.ts +99 -0
- package/src/kv.ts +27 -0
- package/src/ledger/session-ledger.ts +535 -0
- package/src/ledger.ts +29 -0
- package/src/storage-backends/cursor-hosted.ts +108 -3
- package/src/storage-backends/file-kv.ts +128 -12
- package/src/storage.ts +90 -6
- package/src/types.ts +139 -7
- 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.D82_RVtF.js +0 -1
- package/dist/docs/assets/example-agents_index.md.DgGBwckv.js +0 -2
- package/dist/docs/assets/index.md.CmhptOmN.js +0 -24
- package/dist/docs/assets/reference_hooks.md.BGDw4VLm.js +0 -12
- package/dist/docs/assets/troubleshooting.md.B5RVX_tL.js +0 -1
- 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/multi-tenant.d.ts +0 -80
- package/dist/multi-tenant.d.ts.map +0 -1
- package/dist/multi-tenant.js +0 -69
- package/dist/persistence.d.ts +0 -184
- package/dist/persistence.d.ts.map +0 -1
- package/dist/playground/assets/index-BRhBbnd4.css +0 -1
- package/dist/playground/assets/index-Bc1oFgFG.js +0 -85
- package/dist/storage-backends/postgres-kv.d.ts +0 -82
- package/dist/storage-backends/postgres-kv.d.ts.map +0 -1
- package/dist/storage-backends/postgres-kv.js +0 -185
- package/src/storage-backends/postgres-kv.ts +0 -253
- /package/dist/docs/assets/{ab.md.6cLOW7--.lean.js → ab.md.hdxsvX5M.lean.js} +0 -0
- /package/dist/docs/assets/{building-with-agents.md.txrcGU2B.lean.js → building-with-agents.md.PeZaZA1P.lean.js} +0 -0
- /package/dist/docs/assets/{evals.md.BQXI3rXy.lean.js → evals.md.qeoGgPw0.lean.js} +0 -0
- /package/dist/docs/assets/{example-agents_index.md.DgGBwckv.lean.js → example-agents_index.md.xmJ87d_3.lean.js} +0 -0
- /package/dist/docs/assets/{quickstart.md.C_b6ESpD.lean.js → quickstart.md.rIbfahJM.lean.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/internal/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAiBH,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/internal/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAiBH,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EAUrB,KAAK,UAAU,EAuBhB,MAAM,aAAa,CAAC;AA2BrB,MAAM,WAAW,uBAAuB;IACtC,sDAAsD;IACtD,YAAY,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC3E;AAmBD;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,O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export function loadAgentProjects(rootDir_1) {
|
|
|
120
120
|
throw new Error(`No agent projects found directly under ${resolved}. Each agent should be a subdirectory with its own agent/ directory (or flat-layout markers).`);
|
|
121
121
|
}
|
|
122
122
|
const results = [];
|
|
123
|
+
// Storage namespaces (session mirror, host kv, durable-session ledger)
|
|
124
|
+
// key on the project NAME, not the mount slug — two co-hosted agents
|
|
125
|
+
// sharing a name would silently share sessions and coordination state.
|
|
126
|
+
const slugByName = new Map();
|
|
123
127
|
for (const child of children) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
+
const project = yield loadAgentProject(child.dir, options);
|
|
129
|
+
const priorSlug = slugByName.get(project.name);
|
|
130
|
+
if (priorSlug !== undefined) {
|
|
131
|
+
throw new Error(`Duplicate agent name "${project.name}" under ${resolved}: agents "${priorSlug}" and "${child.slug}" both resolve to it (package.json "name", or the directory name when unset). Co-hosted agents must have distinct names — their storage and session namespaces key on the name.`);
|
|
132
|
+
}
|
|
133
|
+
slugByName.set(project.name, child.slug);
|
|
134
|
+
results.push({ slug: child.slug, project });
|
|
128
135
|
}
|
|
129
136
|
return results;
|
|
130
137
|
});
|
|
@@ -306,6 +313,7 @@ function loadAgent(ctx, agentDir, options) {
|
|
|
306
313
|
};
|
|
307
314
|
const hosting = resolveHosting(ctx, agentDir, config === null || config === void 0 ? void 0 : config.hosting);
|
|
308
315
|
const concurrency = resolveConcurrency(ctx, agentDir, config === null || config === void 0 ? void 0 : config.concurrency);
|
|
316
|
+
const serving = resolveServing(ctx, agentDir, config === null || config === void 0 ? void 0 : config.serving);
|
|
309
317
|
if (runtime === "cloud") {
|
|
310
318
|
warnCloudRuntimeLimitations(ctx, agentDir, {
|
|
311
319
|
agentTools: tools.filter((tool) => tool.execution === "agent").length,
|
|
@@ -326,6 +334,7 @@ function loadAgent(ctx, agentDir, options) {
|
|
|
326
334
|
local,
|
|
327
335
|
hosting,
|
|
328
336
|
concurrency,
|
|
337
|
+
serving,
|
|
329
338
|
tools,
|
|
330
339
|
skills,
|
|
331
340
|
connections,
|
|
@@ -334,6 +343,22 @@ function loadAgent(ctx, agentDir, options) {
|
|
|
334
343
|
};
|
|
335
344
|
});
|
|
336
345
|
}
|
|
346
|
+
/**
|
|
347
|
+
* Validate the authored serving mode. An unrecognized value is an error
|
|
348
|
+
* diagnostic and falls back to undefined (resident) — a typo must not
|
|
349
|
+
* silently opt an agent into (or out of) ledger coordination.
|
|
350
|
+
*/
|
|
351
|
+
function resolveServing(ctx, agentDir, serving) {
|
|
352
|
+
if (serving === undefined || serving === "resident" || serving === "ledger") {
|
|
353
|
+
return serving;
|
|
354
|
+
}
|
|
355
|
+
ctx.diagnostics.push({
|
|
356
|
+
severity: "error",
|
|
357
|
+
path: displayPath(ctx, join(agentDir, "agent.ts")),
|
|
358
|
+
message: `serving must be "resident" or "ledger"; got ${JSON.stringify(serving)}.`,
|
|
359
|
+
});
|
|
360
|
+
return undefined;
|
|
361
|
+
}
|
|
337
362
|
/** Absolute harness cwd parent, or undefined when unset / blank. */
|
|
338
363
|
function resolveAgentCwd(ctx, authored) {
|
|
339
364
|
if (authored === undefined) {
|
|
@@ -376,7 +401,7 @@ function resolveHosting(ctx, agentDir, hosting) {
|
|
|
376
401
|
warn(`hosting.secretNames: ${nameError}`);
|
|
377
402
|
}
|
|
378
403
|
else if (isReservedSecretName(name)) {
|
|
379
|
-
warn(`hosting.secretNames: ${JSON.stringify(name)} is platform-managed (CURSOR_* /
|
|
404
|
+
warn(`hosting.secretNames: ${JSON.stringify(name)} is platform-managed (CURSOR_* / reserved hosted-storage names); omit it from secretNames.`);
|
|
380
405
|
}
|
|
381
406
|
}
|
|
382
407
|
return Object.assign(Object.assign({}, (hosting.egressDomains === undefined
|
|
@@ -1525,11 +1550,14 @@ export function projectInfo(project) {
|
|
|
1525
1550
|
})), skills: agent.skills.map((skill) => ({
|
|
1526
1551
|
name: skill.name,
|
|
1527
1552
|
description: skill.description,
|
|
1528
|
-
})), connections: agent.connections.map((connection) => ({
|
|
1553
|
+
})), connections: agent.connections.map((connection) => { var _a; return ({
|
|
1529
1554
|
name: connection.name,
|
|
1530
1555
|
transport: connectionTransportLabel(connection.transport),
|
|
1531
1556
|
hostOnly: connection.hostOnly,
|
|
1532
|
-
|
|
1557
|
+
cursorAccountServers: "cursorAccount" in connection.transport
|
|
1558
|
+
? ((_a = connection.transport.servers) !== null && _a !== void 0 ? _a : "*")
|
|
1559
|
+
: undefined,
|
|
1560
|
+
}); }), subagents: agent.subagents.map((subagent) => ({
|
|
1533
1561
|
name: subagent.name,
|
|
1534
1562
|
description: subagent.description,
|
|
1535
1563
|
model: subagent.model,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distribution.d.ts","sourceRoot":"","sources":["../../src/internal/distribution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,sEAAsE;AACtE,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB,2BAA2B,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,qBAAqB,qBAAqB,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,WAAW,cAAc,CAAC;AACvC,eAAO,MAAM,UAAU,EAAE,MAA2B,CAAC;AACrD,eAAO,MAAM,gBAAgB,EAAE,MAAiC,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAA+B,CAAC;AAc/D;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAGhD;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,kEAAkE;AAClE,wBAAgB,cAAc,IAAI,MAAM,CAOvC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAC/C,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"distribution.d.ts","sourceRoot":"","sources":["../../src/internal/distribution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,sEAAsE;AACtE,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB,2BAA2B,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,qBAAqB,qBAAqB,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,WAAW,cAAc,CAAC;AACvC,eAAO,MAAM,UAAU,EAAE,MAA2B,CAAC;AACrD,eAAO,MAAM,gBAAgB,EAAE,MAAiC,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAA+B,CAAC;AAc/D;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAGhD;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,kEAAkE;AAClE,wBAAgB,cAAc,IAAI,MAAM,CAOvC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAC/C,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAyBzC,CAAC"}
|
|
@@ -92,8 +92,10 @@ export const AUTHORING_ENTRY_FILES = [
|
|
|
92
92
|
["evals/loaders", "evals/loaders.js"],
|
|
93
93
|
["ab", "ab.js"],
|
|
94
94
|
["artifacts", "artifacts.js"],
|
|
95
|
+
["kv", "kv.js"],
|
|
96
|
+
["kv/memory", "kv/memory-kv.js"],
|
|
97
|
+
["ledger", "ledger.js"],
|
|
95
98
|
["storage", "storage.js"],
|
|
96
99
|
["storage/file-kv", "storage-backends/file-kv.js"],
|
|
97
|
-
["storage/postgres-kv", "storage-backends/postgres-kv.js"],
|
|
98
100
|
["storage/cursor-hosted", "storage-backends/cursor-hosted.js"],
|
|
99
101
|
];
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable-session store resolution.
|
|
3
|
+
*
|
|
4
|
+
* Two APIs, one backend: `defineStorage` is the **storage API** (agent
|
|
5
|
+
* state — session records, event chunks, author KV), and the session
|
|
6
|
+
* ledger is the **durable session API** (session identity, leases,
|
|
7
|
+
* fenced commits). The ledger consumes {@link SessionLedgerKv} — exactly
|
|
8
|
+
* the three CAS methods it uses, nothing more; this module adapts a
|
|
9
|
+
* storage backend's `cas` group into that interface, so a deployment's
|
|
10
|
+
* one authored backend serves both APIs by default.
|
|
11
|
+
*
|
|
12
|
+
* Calls go straight at the config's methods — NOT through the
|
|
13
|
+
* StorageCoordinator: the coordinator's queue is bounded, serialized, and
|
|
14
|
+
* at-most-once (mirror semantics), while ledger CAS calls are the
|
|
15
|
+
* correctness path and must observe their own results synchronously.
|
|
16
|
+
*/
|
|
17
|
+
import type { SessionLedgerKv } from "../ledger/session-ledger.js";
|
|
18
|
+
import { type StorageConfig } from "../storage.js";
|
|
19
|
+
export interface StorageCasKvArgs {
|
|
20
|
+
agentName: string;
|
|
21
|
+
projectRoot: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Adapt a storage backend's `cas` group into the ledger's KV interface.
|
|
25
|
+
* Throws when the backend does not implement `cas` — the caller turns
|
|
26
|
+
* that into the fail-fast startup error for `serving: "ledger"`. Every
|
|
27
|
+
* call carries a `reason: "coordination"` {@link StorageContext}.
|
|
28
|
+
*/
|
|
29
|
+
export declare function storageCasKv(config: StorageConfig, args: StorageCasKvArgs): SessionLedgerKv;
|
|
30
|
+
/**
|
|
31
|
+
* The one place the ledger's physical namespace is minted:
|
|
32
|
+
* `agentkit/v1/<agent>/durable-session/` — the {@link STORAGE_KEY_ROOT}
|
|
33
|
+
* conventions with the agent segment encoded like every other
|
|
34
|
+
* caller-controlled segment. The ledger itself never sees this string;
|
|
35
|
+
* it speaks bare `session/…` / `ledger/…` keys against a handle that
|
|
36
|
+
* {@link namespacedKv} has already scoped.
|
|
37
|
+
*/
|
|
38
|
+
export declare function ledgerKeyPrefix(agentName: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Scope a raw store handle under a namespace, prepending it to every
|
|
41
|
+
* key on the way in. Applied exactly once, where the engine constructs
|
|
42
|
+
* the ledger's store handle — the same conceptual boundary where
|
|
43
|
+
* `host.kv` gets its agent scoping. Internal: not part of the public kv
|
|
44
|
+
* interface, and callers (including the explicit `durableSessionStore`
|
|
45
|
+
* override) always supply the raw store — they never write prefixes.
|
|
46
|
+
*/
|
|
47
|
+
export declare function namespacedKv(store: SessionLedgerKv, namespace: string): SessionLedgerKv;
|
|
48
|
+
//# sourceMappingURL=durable-session-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"durable-session-store.d.ts","sourceRoot":"","sources":["../../src/internal/durable-session-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,gBAAgB,GACrB,eAAe,CAuBjB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,eAAe,EACtB,SAAS,EAAE,MAAM,GAChB,eAAe,CAOjB"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable-session store resolution.
|
|
3
|
+
*
|
|
4
|
+
* Two APIs, one backend: `defineStorage` is the **storage API** (agent
|
|
5
|
+
* state — session records, event chunks, author KV), and the session
|
|
6
|
+
* ledger is the **durable session API** (session identity, leases,
|
|
7
|
+
* fenced commits). The ledger consumes {@link SessionLedgerKv} — exactly
|
|
8
|
+
* the three CAS methods it uses, nothing more; this module adapts a
|
|
9
|
+
* storage backend's `cas` group into that interface, so a deployment's
|
|
10
|
+
* one authored backend serves both APIs by default.
|
|
11
|
+
*
|
|
12
|
+
* Calls go straight at the config's methods — NOT through the
|
|
13
|
+
* StorageCoordinator: the coordinator's queue is bounded, serialized, and
|
|
14
|
+
* at-most-once (mirror semantics), while ledger CAS calls are the
|
|
15
|
+
* correctness path and must observe their own results synchronously.
|
|
16
|
+
*/
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
import { keySegment, STORAGE_KEY_ROOT, } from "../storage.js";
|
|
27
|
+
/**
|
|
28
|
+
* Adapt a storage backend's `cas` group into the ledger's KV interface.
|
|
29
|
+
* Throws when the backend does not implement `cas` — the caller turns
|
|
30
|
+
* that into the fail-fast startup error for `serving: "ledger"`. Every
|
|
31
|
+
* call carries a `reason: "coordination"` {@link StorageContext}.
|
|
32
|
+
*/
|
|
33
|
+
export function storageCasKv(config, args) {
|
|
34
|
+
const ctx = {
|
|
35
|
+
agentName: args.agentName,
|
|
36
|
+
projectRoot: args.projectRoot,
|
|
37
|
+
reason: "coordination",
|
|
38
|
+
};
|
|
39
|
+
const { cas } = config;
|
|
40
|
+
if (cas === undefined) {
|
|
41
|
+
throw new Error("storageCasKv: the storage backend does not implement the cas group (conditional writes)");
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
getWithVersion(key) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
return yield cas.getWithVersion(key, ctx);
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
putIfAbsent(key, value) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
return yield cas.putIfAbsent(key, value, ctx);
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
putIfVersion(key, value, expectedVersion) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
return yield cas.putIfVersion(key, value, expectedVersion, ctx);
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The one place the ledger's physical namespace is minted:
|
|
63
|
+
* `agentkit/v1/<agent>/durable-session/` — the {@link STORAGE_KEY_ROOT}
|
|
64
|
+
* conventions with the agent segment encoded like every other
|
|
65
|
+
* caller-controlled segment. The ledger itself never sees this string;
|
|
66
|
+
* it speaks bare `session/…` / `ledger/…` keys against a handle that
|
|
67
|
+
* {@link namespacedKv} has already scoped.
|
|
68
|
+
*/
|
|
69
|
+
export function ledgerKeyPrefix(agentName) {
|
|
70
|
+
return `${STORAGE_KEY_ROOT}/${keySegment(agentName)}/durable-session/`;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Scope a raw store handle under a namespace, prepending it to every
|
|
74
|
+
* key on the way in. Applied exactly once, where the engine constructs
|
|
75
|
+
* the ledger's store handle — the same conceptual boundary where
|
|
76
|
+
* `host.kv` gets its agent scoping. Internal: not part of the public kv
|
|
77
|
+
* interface, and callers (including the explicit `durableSessionStore`
|
|
78
|
+
* override) always supply the raw store — they never write prefixes.
|
|
79
|
+
*/
|
|
80
|
+
export function namespacedKv(store, namespace) {
|
|
81
|
+
return {
|
|
82
|
+
getWithVersion: (key) => store.getWithVersion(namespace + key),
|
|
83
|
+
putIfAbsent: (key, value) => store.putIfAbsent(namespace + key, value),
|
|
84
|
+
putIfVersion: (key, value, expectedVersion) => store.putIfVersion(namespace + key, value, expectedVersion),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
@@ -14,7 +14,7 @@ export declare const MAX_SECRETS = 32;
|
|
|
14
14
|
export declare const MAX_SECRET_VALUE_BYTES = 4096;
|
|
15
15
|
/** Max secret name length. */
|
|
16
16
|
export declare const MAX_SECRET_NAME_LENGTH = 64;
|
|
17
|
-
/** Secret names the platform
|
|
17
|
+
/** Secret names the platform manages; user writes are rejected. */
|
|
18
18
|
export declare const RESERVED_SECRET_NAME_PREFIX = "CURSOR_";
|
|
19
19
|
/**
|
|
20
20
|
* Additional platform-managed env names for Cursor-hosted durable storage
|
package/dist/internal/hosting.js
CHANGED
|
@@ -14,7 +14,7 @@ export const MAX_SECRETS = 32;
|
|
|
14
14
|
export const MAX_SECRET_VALUE_BYTES = 4096;
|
|
15
15
|
/** Max secret name length. */
|
|
16
16
|
export const MAX_SECRET_NAME_LENGTH = 64;
|
|
17
|
-
/** Secret names the platform
|
|
17
|
+
/** Secret names the platform manages; user writes are rejected. */
|
|
18
18
|
export const RESERVED_SECRET_NAME_PREFIX = "CURSOR_";
|
|
19
19
|
/**
|
|
20
20
|
* Additional platform-managed env names for Cursor-hosted durable storage
|
|
@@ -73,7 +73,7 @@ export function validateSettableSecretName(name) {
|
|
|
73
73
|
return nameError;
|
|
74
74
|
}
|
|
75
75
|
if (isReservedSecretName(name)) {
|
|
76
|
-
return `Secret name ${JSON.stringify(name)} is platform-managed;
|
|
76
|
+
return `Secret name ${JSON.stringify(name)} is platform-managed; user secrets cannot claim CURSOR_* or reserved hosted-storage names.`;
|
|
77
77
|
}
|
|
78
78
|
return undefined;
|
|
79
79
|
}
|
|
@@ -52,6 +52,34 @@ export interface InstallScaffoldDependenciesResult {
|
|
|
52
52
|
* `@cursor/july` immediately after `init`.
|
|
53
53
|
*/
|
|
54
54
|
export declare function installScaffoldDependencies(rootDir: string, options?: InstallScaffoldDependenciesOptions): Promise<InstallScaffoldDependenciesResult>;
|
|
55
|
+
export interface LinkCliOntoPathOptions {
|
|
56
|
+
stdio?: "inherit" | "pipe";
|
|
57
|
+
runner?: (args: {
|
|
58
|
+
command: string;
|
|
59
|
+
args: string[];
|
|
60
|
+
cwd: string;
|
|
61
|
+
stdio: "inherit" | "pipe";
|
|
62
|
+
}) => Promise<{
|
|
63
|
+
exitCode: number;
|
|
64
|
+
stderr: string;
|
|
65
|
+
}>;
|
|
66
|
+
/** Test seam — absolute path of the linked CLI when present. */
|
|
67
|
+
whichImpl?: (command: string) => string | undefined | Promise<string | undefined>;
|
|
68
|
+
}
|
|
69
|
+
export interface LinkCliOntoPathResult {
|
|
70
|
+
ok: boolean;
|
|
71
|
+
exitCode: number;
|
|
72
|
+
stderr: string;
|
|
73
|
+
/** Absolute path to the linked `agent-sdk` when it resolves on PATH. */
|
|
74
|
+
resolvedPath?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Put `agent-sdk` on the user PATH by installing the already-downloaded
|
|
78
|
+
* project copy into the npm global prefix. `npx @cursor/july init` only
|
|
79
|
+
* runs the package; this is the install that makes bare `agent-sdk …`
|
|
80
|
+
* work afterward.
|
|
81
|
+
*/
|
|
82
|
+
export declare function linkCliOntoPath(rootDir: string, options?: LinkCliOntoPathOptions): Promise<LinkCliOntoPathResult>;
|
|
55
83
|
export interface InitScaffoldSummaryOptions {
|
|
56
84
|
/** Scaffolded project root (absolute). */
|
|
57
85
|
rootDir: string;
|
|
@@ -70,6 +98,11 @@ export interface InitNextStepsOptions {
|
|
|
70
98
|
* `login` (used for `--json` and when an interactive login attempt failed).
|
|
71
99
|
*/
|
|
72
100
|
signedIn: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* True when `agent-sdk` resolves on PATH after init linked the CLI.
|
|
103
|
+
* When false, next steps include a PATH export for `node_modules/.bin`.
|
|
104
|
+
*/
|
|
105
|
+
cliOnPath: boolean;
|
|
73
106
|
/** Override TTY color detection (tests / `--json` callers). */
|
|
74
107
|
color?: boolean;
|
|
75
108
|
}
|
|
@@ -101,6 +134,7 @@ export declare function initNextCommands(options: {
|
|
|
101
134
|
rootDir: string;
|
|
102
135
|
cwd: string;
|
|
103
136
|
signedIn: boolean;
|
|
137
|
+
cliOnPath: boolean;
|
|
104
138
|
}): string[];
|
|
105
139
|
/**
|
|
106
140
|
* Coding-agent setup guide printed by `agent-serve init`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-project.d.ts","sourceRoot":"","sources":["../../src/internal/init-project.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"init-project.d.ts","sourceRoot":"","sources":["../../src/internal/init-project.ts"],"names":[],"mappings":"AAAA;;GAEG;AAkBH,MAAM,WAAW,kBAAkB;IACjC,gDAAgD;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEhD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,cAAc,CAAC;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,2BAA2B;IAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,qDAAqD;IACrD,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AA2BD,wBAAsB,WAAW,CAC/B,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CAuI5B;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAOhD;AAED,MAAM,WAAW,kCAA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EAAE,CAEX;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAuBrC"}
|
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
});
|
|
12
12
|
};
|
|
13
13
|
import { spawn } from "node:child_process";
|
|
14
|
+
import { existsSync } from "node:fs";
|
|
14
15
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
15
16
|
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
16
17
|
import { CLI_COMMAND_NAME, PACKAGE_NAME, packageVersion, } from "./distribution.js";
|
|
@@ -70,6 +71,7 @@ export function initProject(options) {
|
|
|
70
71
|
description: `agent project: ${name}`,
|
|
71
72
|
scripts: {
|
|
72
73
|
check: "tsc --noEmit",
|
|
74
|
+
dev: "agent-sdk dev",
|
|
73
75
|
},
|
|
74
76
|
dependencies: {
|
|
75
77
|
[PACKAGE_NAME]: `^${packageVersion()}`,
|
|
@@ -176,6 +178,117 @@ export function installScaffoldDependencies(rootDir_1) {
|
|
|
176
178
|
};
|
|
177
179
|
});
|
|
178
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Put `agent-sdk` on the user PATH by installing the already-downloaded
|
|
183
|
+
* project copy into the npm global prefix. `npx @cursor/july init` only
|
|
184
|
+
* runs the package; this is the install that makes bare `agent-sdk …`
|
|
185
|
+
* work afterward.
|
|
186
|
+
*/
|
|
187
|
+
export function linkCliOntoPath(rootDir_1) {
|
|
188
|
+
return __awaiter(this, arguments, void 0, function* (rootDir, options = {}) {
|
|
189
|
+
var _a, _b, _c;
|
|
190
|
+
const packageDir = join(rootDir, "node_modules", PACKAGE_NAME);
|
|
191
|
+
if (!existsSync(packageDir)) {
|
|
192
|
+
return {
|
|
193
|
+
ok: false,
|
|
194
|
+
exitCode: 1,
|
|
195
|
+
stderr: `missing ${PACKAGE_NAME} under ${packageDir} (run npm install first)`,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
const stdio = (_a = options.stdio) !== null && _a !== void 0 ? _a : "inherit";
|
|
199
|
+
const command = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
200
|
+
const args = ["install", "--global", "--no-fund", "--no-audit", packageDir];
|
|
201
|
+
const runner = (_b = options.runner) !== null && _b !== void 0 ? _b : defaultNpmInstallRunner;
|
|
202
|
+
const result = yield runner({ command, args, cwd: rootDir, stdio });
|
|
203
|
+
if (result.exitCode !== 0) {
|
|
204
|
+
return {
|
|
205
|
+
ok: false,
|
|
206
|
+
exitCode: result.exitCode,
|
|
207
|
+
stderr: result.stderr,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
const whichImpl = (_c = options.whichImpl) !== null && _c !== void 0 ? _c : resolveLinkedCli;
|
|
211
|
+
const resolvedPath = yield whichImpl(CLI_COMMAND_NAME);
|
|
212
|
+
return {
|
|
213
|
+
ok: resolvedPath !== undefined,
|
|
214
|
+
exitCode: 0,
|
|
215
|
+
stderr: resolvedPath === undefined
|
|
216
|
+
? `${CLI_COMMAND_NAME} linked into the npm global prefix but is not on PATH; open a new shell or add that bin directory to PATH`
|
|
217
|
+
: "",
|
|
218
|
+
resolvedPath,
|
|
219
|
+
};
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
/** Prefer the npm-global bin; ignore an older `agent-sdk` earlier on PATH. */
|
|
223
|
+
function resolveLinkedCli(commandName) {
|
|
224
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
225
|
+
var _a;
|
|
226
|
+
const prefix = yield npmGlobalPrefix();
|
|
227
|
+
if (prefix === undefined) {
|
|
228
|
+
return whichOnPath(commandName);
|
|
229
|
+
}
|
|
230
|
+
const binDir = process.platform === "win32" ? prefix : join(prefix, "bin");
|
|
231
|
+
const exts = process.platform === "win32"
|
|
232
|
+
? ((_a = process.env.PATHEXT) !== null && _a !== void 0 ? _a : ".EXE;.CMD;.BAT").split(";").filter(Boolean)
|
|
233
|
+
: [""];
|
|
234
|
+
for (const ext of exts) {
|
|
235
|
+
const candidate = join(binDir, `${commandName}${ext}`);
|
|
236
|
+
if (!existsSync(candidate)) {
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
// Only claim PATH success when this linked bin is the first hit.
|
|
240
|
+
const onPath = whichOnPath(commandName);
|
|
241
|
+
return onPath === candidate ? candidate : undefined;
|
|
242
|
+
}
|
|
243
|
+
return undefined;
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
function npmGlobalPrefix() {
|
|
247
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
248
|
+
const command = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
249
|
+
return yield new Promise((resolvePromise) => {
|
|
250
|
+
var _a, _b;
|
|
251
|
+
const child = spawn(command, ["prefix", "-g"], {
|
|
252
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
253
|
+
env: process.env,
|
|
254
|
+
});
|
|
255
|
+
let out = "";
|
|
256
|
+
(_a = child.stdout) === null || _a === void 0 ? void 0 : _a.setEncoding("utf8");
|
|
257
|
+
(_b = child.stdout) === null || _b === void 0 ? void 0 : _b.on("data", (chunk) => {
|
|
258
|
+
out += chunk;
|
|
259
|
+
});
|
|
260
|
+
child.on("error", () => resolvePromise(undefined));
|
|
261
|
+
child.on("close", (code) => {
|
|
262
|
+
if (code !== 0) {
|
|
263
|
+
resolvePromise(undefined);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const prefix = out.trim();
|
|
267
|
+
resolvePromise(prefix === "" ? undefined : prefix);
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
function whichOnPath(commandName) {
|
|
273
|
+
var _a, _b;
|
|
274
|
+
const pathEnv = (_a = process.env.PATH) !== null && _a !== void 0 ? _a : "";
|
|
275
|
+
const sep = process.platform === "win32" ? ";" : ":";
|
|
276
|
+
const exts = process.platform === "win32"
|
|
277
|
+
? ((_b = process.env.PATHEXT) !== null && _b !== void 0 ? _b : ".EXE;.CMD;.BAT").split(";").filter(Boolean)
|
|
278
|
+
: [""];
|
|
279
|
+
for (const dir of pathEnv.split(sep)) {
|
|
280
|
+
if (dir === "") {
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
for (const ext of exts) {
|
|
284
|
+
const candidate = join(dir, `${commandName}${ext}`);
|
|
285
|
+
if (existsSync(candidate)) {
|
|
286
|
+
return candidate;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return undefined;
|
|
291
|
+
}
|
|
179
292
|
function defaultNpmInstallRunner(args) {
|
|
180
293
|
return __awaiter(this, void 0, void 0, function* () {
|
|
181
294
|
return yield new Promise((resolvePromise, reject) => {
|
|
@@ -286,6 +399,12 @@ function initNextStepEntries(options) {
|
|
|
286
399
|
if (cd !== undefined) {
|
|
287
400
|
steps.push({ command: cd });
|
|
288
401
|
}
|
|
402
|
+
if (!options.cliOnPath) {
|
|
403
|
+
steps.push({
|
|
404
|
+
command: 'export PATH="$PWD/node_modules/.bin:$PATH"',
|
|
405
|
+
note: "use the project-local agent-sdk bin",
|
|
406
|
+
});
|
|
407
|
+
}
|
|
289
408
|
if (!options.signedIn) {
|
|
290
409
|
steps.push({
|
|
291
410
|
command: `${CLI_COMMAND_NAME} login`,
|
|
@@ -313,10 +432,10 @@ export function printInitGuide() {
|
|
|
313
432
|
process.stdout.write(`${CLI_COMMAND_NAME} — coding agent setup
|
|
314
433
|
|
|
315
434
|
Scaffold a project, then open the playground:
|
|
316
|
-
${
|
|
435
|
+
npx ${PACKAGE_NAME} init ./my-agent # installs deps + puts agent-sdk on PATH
|
|
317
436
|
cd ./my-agent && ${CLI_COMMAND_NAME} dev
|
|
318
437
|
|
|
319
|
-
Recommended loop once the project exists:
|
|
438
|
+
Recommended loop once the project exists (from the project directory):
|
|
320
439
|
1. Edit agent/ + tools under agent/tools/
|
|
321
440
|
2. ${CLI_COMMAND_NAME} info --dir . --json
|
|
322
441
|
3. ${CLI_COMMAND_NAME} run --dir . --message "..."
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ledger-mode serving seam (`serving: "ledger"` on `defineAgent`):
|
|
3
|
+
* coordination only, no inbox. Every engine `send` acquires the session
|
|
4
|
+
* lease before its turn runs and commits (head+1, lease released) after
|
|
5
|
+
* it completes, so cross-pod mutual exclusion, generation fencing, and
|
|
6
|
+
* the committed head sequence are real.
|
|
7
|
+
*
|
|
8
|
+
* **Durability trade-off (deliberate):** there is no durable mailbox.
|
|
9
|
+
* An event that arrives while the lease is held does NOT park in the
|
|
10
|
+
* store — the delivering pod waits *in-process*: local concurrent sends
|
|
11
|
+
* serialize on a per-session promise chain (no claim spinning), and a
|
|
12
|
+
* lease held by another pod is waited out with bounded claim retries. A
|
|
13
|
+
* crash therefore loses the in-flight event exactly as resident serving
|
|
14
|
+
* does. A dead pod's lease simply expires (~30s TTL); the next delivery
|
|
15
|
+
* claims at generation+1 — no janitor is needed because nothing is
|
|
16
|
+
* parked.
|
|
17
|
+
*
|
|
18
|
+
* Re-entrancy caveat (same shape as resident `waitForCompletion`): a
|
|
19
|
+
* send issued from *inside* a running turn against the same session
|
|
20
|
+
* chains behind that turn's serve, so awaiting its resolution from the
|
|
21
|
+
* turn would deadlock. Fire-and-forget such sends.
|
|
22
|
+
*/
|
|
23
|
+
import type { SessionLedger } from "../ledger/session-ledger.js";
|
|
24
|
+
import type { ChannelSession, SendMessageOptions } from "../types.js";
|
|
25
|
+
/** Wait between claim retries while another holder has the lease. */
|
|
26
|
+
export declare const CLAIM_RETRY_DELAY_MS = 250;
|
|
27
|
+
/**
|
|
28
|
+
* Give up waiting for the lease after this long — two full lease TTLs,
|
|
29
|
+
* so a dead holder's expiry (~30s) is always survived with margin.
|
|
30
|
+
*/
|
|
31
|
+
export declare const CLAIM_WAIT_TIMEOUT_MS: number;
|
|
32
|
+
/** The `send` options a ledger delivery carries to the resident turn. */
|
|
33
|
+
export type LedgerDeliverOptions = SendMessageOptions & {
|
|
34
|
+
mode?: "chat" | "task";
|
|
35
|
+
};
|
|
36
|
+
/** One delivery handed back to the engine's resident path. */
|
|
37
|
+
export interface LedgerTurnRequest {
|
|
38
|
+
channelId: string;
|
|
39
|
+
continuationToken: string;
|
|
40
|
+
message: string;
|
|
41
|
+
options: LedgerDeliverOptions;
|
|
42
|
+
}
|
|
43
|
+
export interface LedgerServingOptions {
|
|
44
|
+
ledger: SessionLedger;
|
|
45
|
+
/**
|
|
46
|
+
* Run one delivery as a resident-path turn (the engine's `send` with
|
|
47
|
+
* the internal ledger-delivery flag). Must resolve once the turn is
|
|
48
|
+
* admitted; the pump awaits `waitForCompletion` itself.
|
|
49
|
+
*/
|
|
50
|
+
deliverTurn: (request: LedgerTurnRequest) => Promise<ChannelSession>;
|
|
51
|
+
logger?: (line: string) => void;
|
|
52
|
+
/** Lease heartbeat cadence while the turn runs (default 10s). */
|
|
53
|
+
heartbeatIntervalMs?: number;
|
|
54
|
+
/** Claim retry cadence while the lease is held (default 250ms). */
|
|
55
|
+
claimRetryDelayMs?: number;
|
|
56
|
+
/** Give-up bound for lease waiting (default 2× lease TTL). */
|
|
57
|
+
claimWaitTimeoutMs?: number;
|
|
58
|
+
clock?: () => number;
|
|
59
|
+
/** Injectable wait (tests use short real delays; keep them tiny). */
|
|
60
|
+
sleep?: (ms: number) => Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
export declare class LedgerServing {
|
|
63
|
+
private readonly ledger;
|
|
64
|
+
private readonly deliverTurn;
|
|
65
|
+
private readonly logger;
|
|
66
|
+
private readonly heartbeatIntervalMs;
|
|
67
|
+
private readonly claimRetryDelayMs;
|
|
68
|
+
private readonly claimWaitTimeoutMs;
|
|
69
|
+
private readonly clock;
|
|
70
|
+
private readonly sleep;
|
|
71
|
+
/**
|
|
72
|
+
* Per-ledger-session in-process serialization: local concurrent sends
|
|
73
|
+
* queue here instead of spinning claim retries against our own lease.
|
|
74
|
+
*/
|
|
75
|
+
private readonly chains;
|
|
76
|
+
constructor(options: LedgerServingOptions);
|
|
77
|
+
/** Settle every queued and in-flight delivery. */
|
|
78
|
+
close(): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Ledger-mode `send`: resolve the session identity, wait for the
|
|
81
|
+
* lease (in-process queue first, then cross-pod claim retries), run
|
|
82
|
+
* the turn, commit. Resolves with the engine session handle after the
|
|
83
|
+
* commit released the lease.
|
|
84
|
+
*/
|
|
85
|
+
deliver(channelId: string, message: string, options: LedgerDeliverOptions): Promise<ChannelSession>;
|
|
86
|
+
/** Chain a delivery behind the session's in-flight ones. */
|
|
87
|
+
private enqueue;
|
|
88
|
+
/** claim (waiting) → resident turn → commit-release. */
|
|
89
|
+
private serveOne;
|
|
90
|
+
/**
|
|
91
|
+
* Claim the lease, waiting out another holder with bounded retries.
|
|
92
|
+
* The common waits are short: our own pod's deliveries never reach
|
|
93
|
+
* here concurrently (the in-process chain serializes them), so a held
|
|
94
|
+
* lease means another pod is serving — usually for one turn — or died
|
|
95
|
+
* (expiry unblocks us at ~30s).
|
|
96
|
+
*/
|
|
97
|
+
private claimWithWait;
|
|
98
|
+
}
|
|
99
|
+
/** Mint the lease holder id for this process. */
|
|
100
|
+
export declare function newLedgerPodId(): string;
|
|
101
|
+
//# sourceMappingURL=ledger-serving.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger-serving.d.ts","sourceRoot":"","sources":["../../src/internal/ledger-serving.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAMjE,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGtE,qEAAqE;AACrE,eAAO,MAAM,oBAAoB,MAAM,CAAC;AACxC;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAyB,CAAC;AAE9D,yEAAyE;AACzE,MAAM,MAAM,oBAAoB,GAAG,kBAAkB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