@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
|
@@ -0,0 +1,174 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
24
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
25
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
26
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
27
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
28
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
29
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
import { randomBytes, randomUUID } from "node:crypto";
|
|
33
|
+
import { HEARTBEAT_INTERVAL_MS, LEASE_TTL_MS, LedgerFencedError, } from "../ledger/session-ledger.js";
|
|
34
|
+
import { newContinuationKey } from "./ids.js";
|
|
35
|
+
/** Wait between claim retries while another holder has the lease. */
|
|
36
|
+
export const CLAIM_RETRY_DELAY_MS = 250;
|
|
37
|
+
/**
|
|
38
|
+
* Give up waiting for the lease after this long — two full lease TTLs,
|
|
39
|
+
* so a dead holder's expiry (~30s) is always survived with margin.
|
|
40
|
+
*/
|
|
41
|
+
export const CLAIM_WAIT_TIMEOUT_MS = 2 * LEASE_TTL_MS;
|
|
42
|
+
export class LedgerServing {
|
|
43
|
+
constructor(options) {
|
|
44
|
+
var _a, _b, _c, _d, _e, _f;
|
|
45
|
+
/**
|
|
46
|
+
* Per-ledger-session in-process serialization: local concurrent sends
|
|
47
|
+
* queue here instead of spinning claim retries against our own lease.
|
|
48
|
+
*/
|
|
49
|
+
this.chains = new Map();
|
|
50
|
+
this.ledger = options.ledger;
|
|
51
|
+
this.deliverTurn = options.deliverTurn;
|
|
52
|
+
this.logger = (_a = options.logger) !== null && _a !== void 0 ? _a : (() => { });
|
|
53
|
+
this.heartbeatIntervalMs = (_b = options.heartbeatIntervalMs) !== null && _b !== void 0 ? _b : HEARTBEAT_INTERVAL_MS;
|
|
54
|
+
this.claimRetryDelayMs = (_c = options.claimRetryDelayMs) !== null && _c !== void 0 ? _c : CLAIM_RETRY_DELAY_MS;
|
|
55
|
+
this.claimWaitTimeoutMs = (_d = options.claimWaitTimeoutMs) !== null && _d !== void 0 ? _d : CLAIM_WAIT_TIMEOUT_MS;
|
|
56
|
+
this.clock = (_e = options.clock) !== null && _e !== void 0 ? _e : Date.now;
|
|
57
|
+
this.sleep = (_f = options.sleep) !== null && _f !== void 0 ? _f : ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
58
|
+
}
|
|
59
|
+
/** Settle every queued and in-flight delivery. */
|
|
60
|
+
close() {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
yield Promise.allSettled([...this.chains.values()]);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Ledger-mode `send`: resolve the session identity, wait for the
|
|
67
|
+
* lease (in-process queue first, then cross-pod claim retries), run
|
|
68
|
+
* the turn, commit. Resolves with the engine session handle after the
|
|
69
|
+
* commit released the lease.
|
|
70
|
+
*/
|
|
71
|
+
deliver(channelId, message, options) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
var _a;
|
|
74
|
+
const continuationToken = (_a = options.continuationToken) !== null && _a !== void 0 ? _a : newContinuationKey();
|
|
75
|
+
const ensured = yield this.ledger.ensureSession(`${channelId}/${continuationToken}`);
|
|
76
|
+
return this.enqueue(ensured.session.sessionId, () => this.serveOne(ensured.session.sessionId, {
|
|
77
|
+
channelId,
|
|
78
|
+
continuationToken,
|
|
79
|
+
message,
|
|
80
|
+
options,
|
|
81
|
+
}));
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/** Chain a delivery behind the session's in-flight ones. */
|
|
85
|
+
enqueue(ledgerSessionId, run) {
|
|
86
|
+
var _a;
|
|
87
|
+
const prior = (_a = this.chains.get(ledgerSessionId)) !== null && _a !== void 0 ? _a : Promise.resolve();
|
|
88
|
+
const next = prior.then(() => run(), () => run());
|
|
89
|
+
this.chains.set(ledgerSessionId, next);
|
|
90
|
+
void next
|
|
91
|
+
.catch(() => { })
|
|
92
|
+
.finally(() => {
|
|
93
|
+
if (this.chains.get(ledgerSessionId) === next) {
|
|
94
|
+
this.chains.delete(ledgerSessionId);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return next;
|
|
98
|
+
}
|
|
99
|
+
/** claim (waiting) → resident turn → commit-release. */
|
|
100
|
+
serveOne(ledgerSessionId, request) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
var _a;
|
|
103
|
+
const lease = yield this.claimWithWait(ledgerSessionId);
|
|
104
|
+
let fenced = false;
|
|
105
|
+
const heartbeat = setInterval(() => {
|
|
106
|
+
this.ledger.heartbeat(ledgerSessionId, lease.generation).then((result) => {
|
|
107
|
+
if (!result.ok) {
|
|
108
|
+
fenced = true;
|
|
109
|
+
}
|
|
110
|
+
}, () => {
|
|
111
|
+
// Transient KV failure: the next beat retries within the TTL.
|
|
112
|
+
});
|
|
113
|
+
}, this.heartbeatIntervalMs);
|
|
114
|
+
(_a = heartbeat.unref) === null || _a === void 0 ? void 0 : _a.call(heartbeat);
|
|
115
|
+
try {
|
|
116
|
+
let handle;
|
|
117
|
+
try {
|
|
118
|
+
handle = yield this.deliverTurn(request);
|
|
119
|
+
yield handle.waitForCompletion();
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
// The turn never committed; free the session for the next
|
|
123
|
+
// delivery instead of making it wait out the TTL. A fenced
|
|
124
|
+
// holder's release is a no-op.
|
|
125
|
+
yield this.ledger
|
|
126
|
+
.release(ledgerSessionId, lease.generation)
|
|
127
|
+
.catch(() => { });
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
if (fenced) {
|
|
131
|
+
// A new holder took over mid-turn (our lease lapsed). Discard:
|
|
132
|
+
// committing would fence anyway, and warm state is now stale.
|
|
133
|
+
this.logger(`[ledger] session ${ledgerSessionId} fenced mid-turn (generation ${lease.generation}); discarding without commit`);
|
|
134
|
+
throw new LedgerFencedError(`deliver(${ledgerSessionId}): fenced mid-turn at generation ${lease.generation}`);
|
|
135
|
+
}
|
|
136
|
+
yield this.ledger.commit(ledgerSessionId, {
|
|
137
|
+
generation: lease.generation,
|
|
138
|
+
expectedHead: lease.head,
|
|
139
|
+
commitId: randomUUID(),
|
|
140
|
+
});
|
|
141
|
+
return handle;
|
|
142
|
+
}
|
|
143
|
+
finally {
|
|
144
|
+
clearInterval(heartbeat);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Claim the lease, waiting out another holder with bounded retries.
|
|
150
|
+
* The common waits are short: our own pod's deliveries never reach
|
|
151
|
+
* here concurrently (the in-process chain serializes them), so a held
|
|
152
|
+
* lease means another pod is serving — usually for one turn — or died
|
|
153
|
+
* (expiry unblocks us at ~30s).
|
|
154
|
+
*/
|
|
155
|
+
claimWithWait(ledgerSessionId) {
|
|
156
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
+
const start = this.clock();
|
|
158
|
+
for (;;) {
|
|
159
|
+
const claim = yield this.ledger.claim(ledgerSessionId);
|
|
160
|
+
if (claim.claimed) {
|
|
161
|
+
return { generation: claim.lease.generation, head: claim.head };
|
|
162
|
+
}
|
|
163
|
+
if (this.clock() - start >= this.claimWaitTimeoutMs) {
|
|
164
|
+
throw new Error(`ledger serving: session ${ledgerSessionId} is still leased by ${claim.holder} after ${this.claimWaitTimeoutMs}ms; giving up on this delivery`);
|
|
165
|
+
}
|
|
166
|
+
yield this.sleep(this.claimRetryDelayMs);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/** Mint the lease holder id for this process. */
|
|
172
|
+
export function newLedgerPodId() {
|
|
173
|
+
return `pod_${randomBytes(6).toString("hex")}`;
|
|
174
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bind an HTTP server to a port, with a clear next-port path when 3000 (or
|
|
3
|
+
* whatever was requested) is already taken — a common onboarding failure.
|
|
4
|
+
*/
|
|
5
|
+
import type { Server } from "node:http";
|
|
6
|
+
/** Default listen port for `serve` / `dev` when `--port` is omitted. */
|
|
7
|
+
export declare const DEFAULT_SERVE_PORT = 3000;
|
|
8
|
+
export declare function isAddrInUse(error: unknown): boolean;
|
|
9
|
+
export declare function formatPortInUseHint(port: number): string;
|
|
10
|
+
/**
|
|
11
|
+
* `server.listen` with fallback when the caller used the default port.
|
|
12
|
+
* Explicit `--port N` (including `0`) fails immediately with a next-port hint.
|
|
13
|
+
*/
|
|
14
|
+
export declare function listenHttpServer(args: {
|
|
15
|
+
server: Server;
|
|
16
|
+
host: string;
|
|
17
|
+
port: number;
|
|
18
|
+
/** True when the caller passed `port` (including 0); skip fallback. */
|
|
19
|
+
portWasExplicit: boolean;
|
|
20
|
+
logger: (line: string) => void;
|
|
21
|
+
}): Promise<number>;
|
|
22
|
+
//# sourceMappingURL=listen-port.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listen-port.d.ts","sourceRoot":"","sources":["../../src/internal/listen-port.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGxC,wEAAwE;AACxE,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAKvC,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAOnD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMxD;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,eAAe,EAAE,OAAO,CAAC;IACzB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC,GAAG,OAAO,CAAC,MAAM,CAAC,CAyClB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bind an HTTP server to a port, with a clear next-port path when 3000 (or
|
|
3
|
+
* whatever was requested) is already taken — a common onboarding failure.
|
|
4
|
+
*/
|
|
5
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
import { once } from "node:events";
|
|
15
|
+
import { CLI_COMMAND_NAME } from "./distribution.js";
|
|
16
|
+
/** Default listen port for `serve` / `dev` when `--port` is omitted. */
|
|
17
|
+
export const DEFAULT_SERVE_PORT = 3000;
|
|
18
|
+
/** How many ports above the default to try when the default is taken. */
|
|
19
|
+
const DEFAULT_PORT_FALLBACK_SPAN = 20;
|
|
20
|
+
export function isAddrInUse(error) {
|
|
21
|
+
return (typeof error === "object" &&
|
|
22
|
+
error !== null &&
|
|
23
|
+
"code" in error &&
|
|
24
|
+
error.code === "EADDRINUSE");
|
|
25
|
+
}
|
|
26
|
+
export function formatPortInUseHint(port) {
|
|
27
|
+
const next = port === 0 ? 3001 : port + 1;
|
|
28
|
+
return (`port ${port} is already in use. ` +
|
|
29
|
+
`Try \`${CLI_COMMAND_NAME} dev --port ${next}\` or \`--port 0\` for any free port.`);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* `server.listen` with fallback when the caller used the default port.
|
|
33
|
+
* Explicit `--port N` (including `0`) fails immediately with a next-port hint.
|
|
34
|
+
*/
|
|
35
|
+
export function listenHttpServer(args) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const { server, host, logger } = args;
|
|
38
|
+
const startPort = args.port;
|
|
39
|
+
if (args.portWasExplicit || startPort === 0) {
|
|
40
|
+
try {
|
|
41
|
+
server.listen(startPort, host);
|
|
42
|
+
yield once(server, "listening");
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
if (isAddrInUse(error)) {
|
|
46
|
+
throw new Error(formatPortInUseHint(startPort));
|
|
47
|
+
}
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
const address = server.address();
|
|
51
|
+
if (address === null || typeof address === "string") {
|
|
52
|
+
throw new Error("server listening without an address");
|
|
53
|
+
}
|
|
54
|
+
return address.port;
|
|
55
|
+
}
|
|
56
|
+
const last = startPort + DEFAULT_PORT_FALLBACK_SPAN;
|
|
57
|
+
for (let port = startPort; port <= last; port++) {
|
|
58
|
+
try {
|
|
59
|
+
server.listen(port, host);
|
|
60
|
+
yield once(server, "listening");
|
|
61
|
+
if (port !== startPort) {
|
|
62
|
+
logger(`[agent-sdk] port ${startPort} in use; listening on ${port} instead (pass --port to pick)`);
|
|
63
|
+
}
|
|
64
|
+
return port;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (!isAddrInUse(error)) {
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
if (port === last) {
|
|
71
|
+
throw new Error(formatPortInUseHint(port));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
throw new Error(formatPortInUseHint(last));
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Serves the built Vite playground SPA and the
|
|
2
|
+
* Serves the built Vite playground SPA and the host home page.
|
|
3
3
|
*
|
|
4
4
|
* The playground is a Vite + React app (see `playground/`). `serve` auto-builds
|
|
5
5
|
* `dist/playground/` when the local vite toolchain is present (see
|
|
@@ -25,14 +25,31 @@ export declare function playgroundBundleExists(): boolean;
|
|
|
25
25
|
export declare function renderPlaygroundIndexHtml(baseHref: string): string;
|
|
26
26
|
/** Serve one built asset from `dist/playground/assets/` by filename. */
|
|
27
27
|
export declare function renderPlaygroundAsset(file: string): Response;
|
|
28
|
-
/**
|
|
28
|
+
/** Slack surface summary for the host home / `GET /v1/agents`. */
|
|
29
|
+
export type AgentIndexSlack = {
|
|
30
|
+
kind: "cursor-account";
|
|
31
|
+
handle: string;
|
|
32
|
+
} | {
|
|
33
|
+
kind: "socket";
|
|
34
|
+
};
|
|
35
|
+
/** One row on the host home page and `GET /v1/agents`. */
|
|
29
36
|
export interface AgentIndexEntry {
|
|
30
37
|
slug: string;
|
|
31
38
|
name: string;
|
|
32
39
|
model: string;
|
|
33
40
|
tools: number;
|
|
34
41
|
channels: number;
|
|
42
|
+
slack?: AgentIndexSlack;
|
|
35
43
|
}
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
export interface HostHomeOptions {
|
|
45
|
+
/** When false, omit `/docs` from the route list. Default true. */
|
|
46
|
+
docs?: boolean;
|
|
47
|
+
/** Same as the serve host's `multi` — mounts `/v1/agents` + host `/v1/health`. */
|
|
48
|
+
multi?: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Orienting `/` page: mounted agents (playground links) plus live host routes.
|
|
52
|
+
* Used for both single-agent (empty slug) and multi-agent mounts.
|
|
53
|
+
*/
|
|
54
|
+
export declare function renderAgentsIndexHtml(agents: AgentIndexEntry[], options?: HostHomeOptions): string;
|
|
38
55
|
//# sourceMappingURL=static.d.ts.map
|
|
@@ -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;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAUlE;AAED,wEAAwE;AACxE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAsB5D;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,kEAAkE;AAClE,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEvB,0DAA0D;AAC1D,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;IACjB,KAAK,CAAC,EAAE,eAAe,CAAC;CACzB;AAED,MAAM,WAAW,eAAe;IAC9B,kEAAkE;IAClE,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,kFAAkF;IAClF,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,eAAe,EAAE,EACzB,OAAO,GAAE,eAAoB,GAC5B,MAAM,CAgCR"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Serves the built Vite playground SPA and the
|
|
2
|
+
* Serves the built Vite playground SPA and the host home page.
|
|
3
3
|
*
|
|
4
4
|
* The playground is a Vite + React app (see `playground/`). `serve` auto-builds
|
|
5
5
|
* `dist/playground/` when the local vite toolchain is present (see
|
|
@@ -83,19 +83,70 @@ export function renderPlaygroundAsset(file) {
|
|
|
83
83
|
},
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
|
-
/**
|
|
87
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Orienting `/` page: mounted agents (playground links) plus live host routes.
|
|
88
|
+
* Used for both single-agent (empty slug) and multi-agent mounts.
|
|
89
|
+
*/
|
|
90
|
+
export function renderAgentsIndexHtml(agents, options = {}) {
|
|
91
|
+
const docs = options.docs !== false;
|
|
92
|
+
const multi = options.multi === true;
|
|
88
93
|
const cards = agents
|
|
89
94
|
.map((agent) => {
|
|
95
|
+
const playground = agent.slug === "" ? "/playground" : `/${agent.slug}/playground`;
|
|
96
|
+
const slugLabel = agent.slug === "" ? "/" : `/${agent.slug}`;
|
|
90
97
|
const meta = `${agent.model || "—"} · ${agent.tools} tool${agent.tools === 1 ? "" : "s"} · ${agent.channels} channel${agent.channels === 1 ? "" : "s"}`;
|
|
91
|
-
return ` <a class="card" href="
|
|
98
|
+
return ` <a class="card" href="${escapeHtml(playground)}">
|
|
92
99
|
<div class="card-name">${escapeHtml(agent.name)}</div>
|
|
93
|
-
<div class="card-slug"
|
|
100
|
+
<div class="card-slug">${escapeHtml(slugLabel)} → playground</div>
|
|
94
101
|
<div class="card-meta">${escapeHtml(meta)}</div>
|
|
95
102
|
</a>`;
|
|
96
103
|
})
|
|
97
104
|
.join("\n");
|
|
98
|
-
|
|
105
|
+
const routes = hostRouteRows(agents, docs, multi)
|
|
106
|
+
.map((row) => ` <tr><td><a href="${escapeHtml(row.href)}"><code>${escapeHtml(row.path)}</code></a></td><td>${escapeHtml(row.blurb)}</td></tr>`)
|
|
107
|
+
.join("\n");
|
|
108
|
+
return HOST_HOME_TEMPLATE.replace("<!--CARDS-->", cards || ' <div class="card-meta">No agents mounted.</div>')
|
|
109
|
+
.replace("<!--COUNT-->", String(agents.length))
|
|
110
|
+
.replace("<!--ROUTES-->", routes);
|
|
111
|
+
}
|
|
112
|
+
function hostRouteRows(agents, docs, multi) {
|
|
113
|
+
const rows = [
|
|
114
|
+
{ path: "/", href: "/", blurb: "This page" },
|
|
115
|
+
];
|
|
116
|
+
for (const agent of agents) {
|
|
117
|
+
const base = agent.slug === "" ? "" : `/${agent.slug}`;
|
|
118
|
+
const label = agent.slug === "" ? agent.name : agent.slug;
|
|
119
|
+
rows.push({
|
|
120
|
+
path: `${base}/playground`,
|
|
121
|
+
href: `${base}/playground`,
|
|
122
|
+
blurb: `Playground — ${label}`,
|
|
123
|
+
});
|
|
124
|
+
rows.push({
|
|
125
|
+
path: `${base}/v1/health`,
|
|
126
|
+
href: `${base}/v1/health`,
|
|
127
|
+
blurb: `Health — ${label}`,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
if (multi) {
|
|
131
|
+
rows.push({
|
|
132
|
+
path: "/v1/agents",
|
|
133
|
+
href: "/v1/agents",
|
|
134
|
+
blurb: "JSON index of mounted agents",
|
|
135
|
+
});
|
|
136
|
+
rows.push({
|
|
137
|
+
path: "/v1/health",
|
|
138
|
+
href: "/v1/health",
|
|
139
|
+
blurb: "Host liveness",
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
if (docs) {
|
|
143
|
+
rows.push({
|
|
144
|
+
path: "/docs",
|
|
145
|
+
href: "/docs/",
|
|
146
|
+
blurb: "Agent SDK documentation",
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return rows;
|
|
99
150
|
}
|
|
100
151
|
function escapeHtml(value) {
|
|
101
152
|
return value
|
|
@@ -111,7 +162,7 @@ function fallbackHtml(baseHref) {
|
|
|
111
162
|
<base href="${escapeHtml(baseHref)}" />
|
|
112
163
|
<meta charset="utf-8" />
|
|
113
164
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
114
|
-
<title>agent-
|
|
165
|
+
<title>agent-sdk playground</title>
|
|
115
166
|
<style>
|
|
116
167
|
body { margin: 0; background: #0e1116; color: #e6edf3; font: 14px/1.6 ui-sans-serif, system-ui, sans-serif; }
|
|
117
168
|
.box { max-width: 640px; margin: 64px auto; padding: 0 24px; }
|
|
@@ -124,7 +175,7 @@ function fallbackHtml(baseHref) {
|
|
|
124
175
|
<div class="box">
|
|
125
176
|
<h1>Playground bundle not built</h1>
|
|
126
177
|
<p>
|
|
127
|
-
The Vite playground has not been built yet. <code>agent-
|
|
178
|
+
The Vite playground has not been built yet. <code>agent-sdk serve</code>
|
|
128
179
|
auto-builds it when the local vite toolchain is available; otherwise run
|
|
129
180
|
<code>pnpm run build:playground</code> from <code>packages/agent-serve</code>,
|
|
130
181
|
or <code>pnpm run dev:playground</code> for Vite HMR.
|
|
@@ -133,33 +184,46 @@ function fallbackHtml(baseHref) {
|
|
|
133
184
|
</body>
|
|
134
185
|
</html>`;
|
|
135
186
|
}
|
|
136
|
-
const
|
|
187
|
+
const HOST_HOME_TEMPLATE = `<!doctype html>
|
|
137
188
|
<html lang="en">
|
|
138
189
|
<head>
|
|
139
190
|
<meta charset="utf-8" />
|
|
140
191
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
141
|
-
<title>
|
|
192
|
+
<title>Agent SDK</title>
|
|
142
193
|
<style>
|
|
143
194
|
:root { color-scheme: dark; }
|
|
144
195
|
body { margin: 0; background: #0e1116; color: #e6edf3; font: 14px/1.6 ui-sans-serif, system-ui, -apple-system, sans-serif; }
|
|
145
|
-
.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
.
|
|
196
|
+
.wrap { max-width: 880px; margin: 0 auto; padding: 48px 24px; }
|
|
197
|
+
h1 { font-size: 20px; font-weight: 650; margin: 0 0 2px; }
|
|
198
|
+
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: #8b949e; margin: 36px 0 12px; }
|
|
199
|
+
.sub { color: #8b949e; font-size: 13px; margin-bottom: 28px; }
|
|
200
|
+
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
|
|
149
201
|
.card { display: block; text-decoration: none; color: inherit; background: #161b22; border: 1px solid #30363d; border-radius: 12px; padding: 16px 18px; transition: border-color 0.12s; }
|
|
150
202
|
.card:hover { border-color: #6cb6ff; }
|
|
151
203
|
.card-name { font-size: 15px; font-weight: 600; }
|
|
152
204
|
.card-slug { font-family: ui-monospace, monospace; font-size: 12px; color: #6cb6ff; margin-top: 2px; }
|
|
153
205
|
.card-meta { color: #6e7681; font-size: 12px; margin-top: 10px; }
|
|
206
|
+
table.routes { width: 100%; border-collapse: collapse; font-size: 13px; }
|
|
207
|
+
table.routes td { padding: 8px 0; border-bottom: 1px solid #21262d; vertical-align: top; }
|
|
208
|
+
table.routes td:first-child { width: 42%; padding-right: 16px; }
|
|
209
|
+
table.routes code { font-family: ui-monospace, monospace; font-size: 12px; color: #6cb6ff; }
|
|
210
|
+
table.routes a { text-decoration: none; }
|
|
211
|
+
table.routes a:hover code { text-decoration: underline; }
|
|
212
|
+
.muted { color: #8b949e; }
|
|
154
213
|
</style>
|
|
155
214
|
</head>
|
|
156
215
|
<body>
|
|
157
|
-
<div class="
|
|
158
|
-
<h1>
|
|
159
|
-
<div class="sub"><!--COUNT-->
|
|
160
|
-
<
|
|
216
|
+
<div class="wrap">
|
|
217
|
+
<h1>Agent SDK</h1>
|
|
218
|
+
<div class="sub"><!--COUNT--> agent(s) on this host. Open a playground or use a route below.</div>
|
|
219
|
+
<h2>Agents</h2>
|
|
220
|
+
<div class="grid">
|
|
161
221
|
<!--CARDS-->
|
|
162
222
|
</div>
|
|
223
|
+
<h2>Routes</h2>
|
|
224
|
+
<table class="routes">
|
|
225
|
+
<!--ROUTES-->
|
|
226
|
+
</table>
|
|
163
227
|
</div>
|
|
164
228
|
</body>
|
|
165
229
|
</html>`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-runner.d.ts","sourceRoot":"","sources":["../../src/internal/sdk-runner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAOL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,SAAS,EAEf,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAEjB,MAAM,aAAa,CAAC;AAGrB,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,MAAM,MAAM,cAAc,GACtB;IAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAcxD,MAAM,WAAW,sBAAsB;IACrC,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAwBD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAKvE;AAED,qBAAa,eAAgB,YAAW,WAAW;IAKrC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;IAC/D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA+C;IACtE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkC;IAElE,YAA6B,OAAO,GAAE,sBAA2B,EAAI;IAE/D,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,CAkC9D;YAEa,cAAc;
|
|
1
|
+
{"version":3,"file":"sdk-runner.d.ts","sourceRoot":"","sources":["../../src/internal/sdk-runner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAOL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,SAAS,EAEf,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAEjB,MAAM,aAAa,CAAC;AAGrB,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,MAAM,MAAM,cAAc,GACtB;IAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAcxD,MAAM,WAAW,sBAAsB;IACrC,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAwBD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAKvE;AAED,qBAAa,eAAgB,YAAW,WAAW;IAKrC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;IAC/D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA+C;IACtE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkC;IAElE,YAA6B,OAAO,GAAE,sBAA2B,EAAI;IAE/D,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,CAkC9D;YAEa,cAAc;IA6F5B;;;;OAIG;IACG,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC,CAepE;IAEK,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAY7B;IAED,OAAO,CAAC,QAAQ;IA0BhB;;;;OAIG;IACH,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,GAAG;IAIX,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,kBAAkB;IAc1B;;;OAGG;YACW,iBAAiB;YAkBjB,SAAS;YAOT,cAAc;YA6Bd,cAAc;IA6C5B,OAAO,CAAC,QAAQ;CAUjB;AAED,4EAA4E;AAC5E,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,MAAM,GACd,OAAO,CAMT;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,YAAY,GAAG,cAAc,CAQpE;AAwGD,wBAAgB,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,MAAM,CAExE"}
|
|
@@ -90,7 +90,16 @@ export class CursorSdkRunner {
|
|
|
90
90
|
const agentPromise = this.getAgent(request);
|
|
91
91
|
try {
|
|
92
92
|
const agent = yield agentPromise;
|
|
93
|
-
const
|
|
93
|
+
const sendMessage = request.images !== undefined && request.images.length > 0
|
|
94
|
+
? {
|
|
95
|
+
text: request.prompt,
|
|
96
|
+
images: request.images.map((image) => ({
|
|
97
|
+
data: image.data,
|
|
98
|
+
mimeType: image.mimeType,
|
|
99
|
+
})),
|
|
100
|
+
}
|
|
101
|
+
: request.prompt;
|
|
102
|
+
const run = yield agent.send(sendMessage, Object.assign({ onDelta: (_a) => __awaiter(this, [_a], void 0, function* ({ update }) {
|
|
94
103
|
try {
|
|
95
104
|
yield request.onUpdate(update);
|
|
96
105
|
}
|
|
@@ -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;
|
|
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;AAqGrB,OAAO,EAAE,KAAK,WAAW,EAAmB,MAAM,iBAAiB,CAAC;AAiBpE,8EAA8E;AAC9E,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,CAAC;CACvB;AAaD,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,CAgtB3B"}
|