@cursor/july 0.1.1 → 0.1.3
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 +40 -7
- package/README.md +33 -24
- package/dist/bin/agent-serve.d.ts +3 -1
- package/dist/bin/agent-serve.d.ts.map +1 -1
- package/dist/bin/agent-serve.js +466 -140
- package/dist/channels/github/api.d.ts.map +1 -1
- package/dist/channels/github/api.js +31 -14
- package/dist/channels/github/cursor-account.d.ts +43 -0
- package/dist/channels/github/cursor-account.d.ts.map +1 -0
- package/dist/channels/github/cursor-account.js +95 -0
- package/dist/channels/github/github-channel.d.ts.map +1 -1
- package/dist/channels/github/github-channel.js +46 -9
- package/dist/channels/github/index.d.ts +2 -2
- package/dist/channels/github/index.js +2 -2
- package/dist/channels/github/types.d.ts +17 -0
- package/dist/channels/github/types.d.ts.map +1 -1
- package/dist/channels/slack/slack-channel.d.ts +8 -2
- package/dist/channels/slack/slack-channel.d.ts.map +1 -1
- package/dist/channels/slack/slack-channel.js +8 -0
- package/dist/channels/slack/types.d.ts +24 -3
- package/dist/channels/slack/types.d.ts.map +1 -1
- package/dist/channels/slack/types.js +15 -1
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +8 -8
- package/dist/docs/assets/{ab.md.COdXkces.js → ab.md.BMCZ6Hd7.js} +3 -3
- package/dist/docs/assets/{ab.md.COdXkces.lean.js → ab.md.BMCZ6Hd7.lean.js} +1 -1
- package/dist/docs/assets/{app.DqfFEmJd.js → app.BR0RbIdx.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.DtIOQzGj.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.BaLEdS15.js → VPLocalSearchBox.qjsVTneI.js} +1 -1
- package/dist/docs/assets/chunks/{theme.CZRvu_0q.js → theme.2Kg8jIp_.js} +2 -2
- package/dist/docs/assets/{deployment.md.Dx1TYNk5.js → deployment.md.DTKwE15Z.js} +3 -3
- package/dist/docs/assets/{deployment.md.Dx1TYNk5.lean.js → deployment.md.DTKwE15Z.lean.js} +1 -1
- package/dist/docs/assets/{evals.md.DPZ_MAnI.js → evals.md.DAgEc_hL.js} +3 -3
- package/dist/docs/assets/{guides_agent-to-agent.md.CrtrsySy.js → guides_agent-to-agent.md.Bpzgq2Pq.js} +1 -1
- package/dist/docs/assets/{guides_cloud-runtime.md.CYlNMTNp.js → guides_cloud-runtime.md.gVzabdQL.js} +1 -1
- package/dist/docs/assets/{guides_github.md.DwbKhCeS.js → guides_github.md.DOOCpqsW.js} +11 -4
- package/dist/docs/assets/{guides_github.md.DwbKhCeS.lean.js → guides_github.md.DOOCpqsW.lean.js} +1 -1
- package/dist/docs/assets/{guides_human-in-the-loop.md.Dvuctx7s.js → guides_human-in-the-loop.md.DlUqsp1S.js} +2 -2
- package/dist/docs/assets/{guides_slack.md.bv41fHfW.js → guides_slack.md.CCwqHvSV.js} +4 -4
- package/dist/docs/assets/{guides_slack.md.bv41fHfW.lean.js → guides_slack.md.CCwqHvSV.lean.js} +1 -1
- package/dist/docs/assets/{guides_webhooks.md.hFTik3lf.js → guides_webhooks.md.B1EswtUu.js} +2 -2
- package/dist/docs/assets/index.md.m81y7TY7.js +20 -0
- package/dist/docs/assets/{index.md.BPKcj5AI.lean.js → index.md.m81y7TY7.lean.js} +1 -1
- package/dist/docs/assets/quickstart.md.BU6Iwi_9.js +204 -0
- package/dist/docs/assets/quickstart.md.BU6Iwi_9.lean.js +1 -0
- package/dist/docs/assets/{reference_agent-config.md.Bpd7HQwf.js → reference_agent-config.md.DrW2JUM8.js} +4 -4
- package/dist/docs/assets/{reference_agent-config.md.Bpd7HQwf.lean.js → reference_agent-config.md.DrW2JUM8.lean.js} +1 -1
- package/dist/docs/assets/{reference_channels.md.D7JTR03W.js → reference_channels.md.DdmiKgqf.js} +4 -4
- package/dist/docs/assets/{reference_channels.md.D7JTR03W.lean.js → reference_channels.md.DdmiKgqf.lean.js} +1 -1
- package/dist/docs/assets/{reference_cli.md.DA730zCu.js → reference_cli.md.Bv6pOxcF.js} +11 -6
- package/dist/docs/assets/{reference_cli.md.DA730zCu.lean.js → reference_cli.md.Bv6pOxcF.lean.js} +1 -1
- package/dist/docs/assets/{reference_connections.md.C3vNH_DE.js → reference_connections.md.zaEYCLHT.js} +1 -1
- package/dist/docs/assets/{reference_hooks.md.BCEc3MyM.js → reference_hooks.md.DyLVfE1O.js} +1 -1
- package/dist/docs/assets/{reference_hooks.md.BCEc3MyM.lean.js → reference_hooks.md.DyLVfE1O.lean.js} +1 -1
- package/dist/docs/assets/{reference_http-api.md.DBAahtdz.js → reference_http-api.md.Dx_nmDG6.js} +1 -1
- package/dist/docs/assets/{reference_instructions.md.BC05LEQ8.js → reference_instructions.md.CgoV-YEb.js} +9 -7
- package/dist/docs/assets/{reference_instructions.md.BC05LEQ8.lean.js → reference_instructions.md.CgoV-YEb.lean.js} +1 -1
- package/dist/docs/assets/{reference_schedules.md.D7qijxLk.js → reference_schedules.md.w_F2mXB6.js} +2 -2
- package/dist/docs/assets/{reference_skills.md.VQnlBT3Q.js → reference_skills.md.B_jHN7JL.js} +3 -3
- package/dist/docs/assets/{reference_skills.md.VQnlBT3Q.lean.js → reference_skills.md.B_jHN7JL.lean.js} +1 -1
- package/dist/docs/assets/{reference_subagents.md.CIRAVcPK.js → reference_subagents.md.zWAMNfi1.js} +1 -1
- package/dist/docs/assets/{reference_tools.md.DF5kwlt0.js → reference_tools.md.CqgJroI0.js} +2 -2
- package/dist/docs/assets/scaffolding-agents.md.C3pTrmoE.js +1 -0
- package/dist/docs/assets/scaffolding-agents.md.C3pTrmoE.lean.js +1 -0
- package/dist/docs/assets/storage.md.CVnInNiN.js +17 -0
- package/dist/docs/assets/storage.md.CVnInNiN.lean.js +1 -0
- package/dist/docs/building-with-agents.html +4 -4
- package/dist/docs/concepts.html +4 -4
- package/dist/docs/deployment.html +7 -7
- package/dist/docs/evals.html +7 -7
- package/dist/docs/guides/agent-to-agent.html +6 -6
- package/dist/docs/guides/cloud-runtime.html +5 -5
- package/dist/docs/guides/github.html +14 -7
- package/dist/docs/guides/human-in-the-loop.html +6 -6
- package/dist/docs/guides/slack.html +8 -8
- package/dist/docs/guides/webhooks.html +6 -6
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +5 -5
- package/dist/docs/index.html +7 -7
- package/dist/docs/quickstart.html +195 -26
- package/dist/docs/reference/agent-config.html +7 -7
- package/dist/docs/reference/channels.html +8 -8
- package/dist/docs/reference/cli.html +14 -9
- package/dist/docs/reference/connections.html +5 -5
- package/dist/docs/reference/hooks.html +5 -5
- package/dist/docs/reference/http-api.html +6 -6
- package/dist/docs/reference/instructions.html +13 -11
- package/dist/docs/reference/playground.html +4 -4
- package/dist/docs/reference/project-layout.html +4 -4
- package/dist/docs/reference/schedules.html +7 -7
- package/dist/docs/reference/sessions.html +4 -4
- package/dist/docs/reference/skills.html +6 -6
- package/dist/docs/reference/subagents.html +6 -6
- package/dist/docs/reference/tools.html +7 -7
- package/dist/docs/scaffolding-agents.html +5 -5
- package/dist/docs/storage.html +41 -0
- package/dist/docs/troubleshooting.html +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/internal/chat-client.d.ts +29 -3
- package/dist/internal/chat-client.d.ts.map +1 -1
- package/dist/internal/chat-client.js +180 -27
- package/dist/internal/cli-ax.d.ts +75 -2
- package/dist/internal/cli-ax.d.ts.map +1 -1
- package/dist/internal/cli-ax.js +600 -52
- package/dist/internal/cli-cursor.d.ts.map +1 -1
- package/dist/internal/cli-cursor.js +8 -36
- package/dist/internal/cli-deploy.d.ts +108 -0
- package/dist/internal/cli-deploy.d.ts.map +1 -0
- package/dist/internal/cli-deploy.js +1009 -0
- package/dist/internal/cursor/backend-client.d.ts +10 -1
- package/dist/internal/cursor/backend-client.d.ts.map +1 -1
- package/dist/internal/cursor/backend-client.js +79 -1
- package/dist/internal/cursor/credentials.d.ts +9 -0
- package/dist/internal/cursor/credentials.d.ts.map +1 -1
- package/dist/internal/cursor/credentials.js +12 -0
- package/dist/internal/cursor/github-credentials.d.ts +44 -0
- package/dist/internal/cursor/github-credentials.d.ts.map +1 -0
- package/dist/internal/cursor/github-credentials.js +195 -0
- package/dist/internal/deploy-client.d.ts +184 -0
- package/dist/internal/deploy-client.d.ts.map +1 -0
- package/dist/internal/deploy-client.js +395 -0
- package/dist/internal/deploy-source.d.ts +35 -0
- package/dist/internal/deploy-source.d.ts.map +1 -0
- package/dist/internal/deploy-source.js +118 -0
- package/dist/internal/discovery.d.ts +11 -0
- package/dist/internal/discovery.d.ts.map +1 -1
- package/dist/internal/discovery.js +116 -19
- package/dist/internal/distribution.d.ts.map +1 -1
- package/dist/internal/distribution.js +1 -0
- package/dist/internal/eval-run-store.d.ts +22 -3
- package/dist/internal/eval-run-store.d.ts.map +1 -1
- package/dist/internal/eval-run-store.js +39 -20
- package/dist/internal/eval-runner.d.ts +2 -0
- package/dist/internal/eval-runner.d.ts.map +1 -1
- package/dist/internal/eval-runner.js +2 -0
- package/dist/internal/event-mapper.d.ts +54 -1
- package/dist/internal/event-mapper.d.ts.map +1 -1
- package/dist/internal/event-mapper.js +151 -41
- package/dist/internal/handleAgentServeTrigger.d.ts.map +1 -1
- package/dist/internal/handleAgentServeTrigger.js +10 -12
- package/dist/internal/host-platforms.d.ts +7 -2
- package/dist/internal/host-platforms.d.ts.map +1 -1
- package/dist/internal/host-platforms.js +15 -10
- package/dist/internal/hosting.d.ts +37 -0
- package/dist/internal/hosting.d.ts.map +1 -0
- package/dist/internal/hosting.js +67 -0
- package/dist/internal/init-project.d.ts +88 -1
- package/dist/internal/init-project.d.ts.map +1 -1
- package/dist/internal/init-project.js +221 -31
- package/dist/internal/install-cursor-skills.d.ts +64 -0
- package/dist/internal/install-cursor-skills.d.ts.map +1 -0
- package/dist/internal/install-cursor-skills.js +274 -0
- package/dist/internal/logs-client.d.ts +60 -0
- package/dist/internal/logs-client.d.ts.map +1 -0
- package/dist/internal/logs-client.js +311 -0
- package/dist/internal/open-browser.d.ts +5 -0
- package/dist/internal/open-browser.d.ts.map +1 -0
- package/dist/internal/open-browser.js +34 -0
- package/dist/internal/playground/toolchain.d.ts.map +1 -1
- package/dist/internal/playground/toolchain.js +16 -11
- package/dist/internal/playground-proxy.d.ts +69 -0
- package/dist/internal/playground-proxy.d.ts.map +1 -0
- package/dist/internal/playground-proxy.js +468 -0
- package/dist/internal/prompt-context.d.ts +35 -0
- package/dist/internal/prompt-context.d.ts.map +1 -0
- package/dist/internal/prompt-context.js +71 -0
- package/dist/internal/reminder-runner.d.ts +7 -0
- package/dist/internal/reminder-runner.d.ts.map +1 -1
- package/dist/internal/reminder-runner.js +50 -6
- package/dist/internal/reminder-store.d.ts +2 -0
- package/dist/internal/reminder-store.d.ts.map +1 -1
- package/dist/internal/reminder-store.js +18 -0
- package/dist/internal/request-headers.d.ts +11 -0
- package/dist/internal/request-headers.d.ts.map +1 -0
- package/dist/internal/request-headers.js +14 -0
- package/dist/internal/resolve-prod-target.d.ts +42 -0
- package/dist/internal/resolve-prod-target.d.ts.map +1 -0
- package/dist/internal/resolve-prod-target.js +111 -0
- package/dist/internal/run-client.d.ts +2 -2
- package/dist/internal/run-client.d.ts.map +1 -1
- package/dist/internal/run-client.js +38 -23
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +182 -45
- package/dist/internal/session-engine.d.ts +50 -1
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +267 -23
- package/dist/internal/sessions-client.d.ts +21 -0
- package/dist/internal/sessions-client.d.ts.map +1 -0
- package/dist/internal/sessions-client.js +168 -0
- package/dist/internal/storage-coordinator.d.ts +139 -0
- package/dist/internal/storage-coordinator.d.ts.map +1 -0
- package/dist/internal/storage-coordinator.js +499 -0
- package/dist/internal/stream-progress.d.ts.map +1 -1
- package/dist/internal/stream-progress.js +31 -3
- package/dist/internal/terminal-style.d.ts +22 -0
- package/dist/internal/terminal-style.d.ts.map +1 -0
- package/dist/internal/terminal-style.js +49 -0
- package/dist/internal/trajectory.d.ts +10 -5
- package/dist/internal/trajectory.d.ts.map +1 -1
- package/dist/internal/trajectory.js +82 -10
- package/dist/internal/workspace.d.ts +11 -0
- package/dist/internal/workspace.d.ts.map +1 -1
- package/dist/internal/workspace.js +38 -4
- package/dist/playground/assets/cursor-icons-outline-BxTT_FVJ.woff2 +0 -0
- package/dist/playground/assets/index-D-vo2lV_.css +1 -0
- package/dist/playground/assets/index-x60b9q2j.js +312 -0
- package/dist/playground/index.html +2 -2
- package/dist/storage.d.ts +204 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +153 -0
- package/dist/types.d.ts +70 -4
- package/dist/types.d.ts.map +1 -1
- package/docs/README.md +3 -2
- package/docs/guides/github.md +43 -8
- package/docs/guides/slack.md +1 -1
- package/docs/quickstart.md +350 -57
- package/docs/reference/cli.md +51 -3
- package/docs/reference/instructions.md +8 -6
- package/docs/scaffolding-agents.md +1 -1
- package/docs/storage.md +98 -0
- package/package.json +10 -1
- package/skills/ab/SKILL.md +8 -8
- package/skills/create-agent/SKILL.md +28 -22
- package/skills/debug/SKILL.md +11 -11
- package/skills/evals/SKILL.md +16 -16
- package/skills/framework-map/SKILL.md +6 -6
- package/skills/github/SKILL.md +22 -14
- package/skills/hillclimb/SKILL.md +10 -10
- package/skills/setup-slack/SKILL.md +13 -13
- package/src/bin/agent-serve.ts +552 -179
- package/src/channels/github/api.ts +42 -23
- package/src/channels/github/cursor-account.ts +165 -0
- package/src/channels/github/github-channel.ts +66 -6
- package/src/channels/github/index.ts +2 -2
- package/src/channels/github/types.ts +19 -0
- package/src/channels/slack/slack-channel.ts +17 -3
- package/src/channels/slack/types.ts +44 -3
- package/src/index.ts +13 -0
- package/src/internal/chat-client.ts +252 -37
- package/src/internal/cli-ax.ts +722 -72
- package/src/internal/cli-cursor.ts +14 -42
- package/src/internal/cli-deploy.ts +1319 -0
- package/src/internal/cursor/backend-client.ts +103 -1
- package/src/internal/cursor/credentials.ts +14 -0
- package/src/internal/cursor/github-credentials.ts +248 -0
- package/src/internal/deploy-client.ts +632 -0
- package/src/internal/deploy-source.ts +133 -0
- package/src/internal/discovery.ts +141 -17
- package/src/internal/distribution.ts +1 -0
- package/src/internal/eval-run-store.ts +50 -20
- package/src/internal/eval-runner.ts +5 -0
- package/src/internal/event-mapper.ts +222 -42
- package/src/internal/handleAgentServeTrigger.ts +10 -12
- package/src/internal/host-platforms.ts +28 -11
- package/src/internal/hosting.ts +77 -0
- package/src/internal/init-project.ts +333 -51
- package/src/internal/install-cursor-skills.ts +327 -0
- package/src/internal/logs-client.ts +442 -0
- package/src/internal/open-browser.ts +41 -0
- package/src/internal/playground/toolchain.ts +15 -13
- package/src/internal/playground-proxy.ts +576 -0
- package/src/internal/prompt-context.ts +95 -0
- package/src/internal/reminder-runner.ts +50 -6
- package/src/internal/reminder-store.ts +21 -0
- package/src/internal/request-headers.ts +23 -0
- package/src/internal/resolve-prod-target.ts +150 -0
- package/src/internal/run-client.ts +39 -36
- package/src/internal/server.ts +223 -28
- package/src/internal/session-engine.ts +307 -10
- package/src/internal/sessions-client.ts +182 -0
- package/src/internal/storage-coordinator.ts +615 -0
- package/src/internal/stream-progress.ts +36 -2
- package/src/internal/terminal-style.ts +74 -0
- package/src/internal/trajectory.ts +91 -13
- package/src/internal/workspace.ts +42 -4
- package/src/storage.ts +325 -0
- package/src/types.ts +82 -8
- package/dist/docs/assets/chunks/@localSearchIndexroot.CcVk1uKq.js +0 -1
- package/dist/docs/assets/index.md.BPKcj5AI.js +0 -20
- package/dist/docs/assets/quickstart.md.tVPiGK_L.js +0 -35
- package/dist/docs/assets/quickstart.md.tVPiGK_L.lean.js +0 -1
- package/dist/docs/assets/scaffolding-agents.md.CyYfWGdc.js +0 -1
- package/dist/docs/assets/scaffolding-agents.md.CyYfWGdc.lean.js +0 -1
- package/dist/playground/assets/cursor-icons-outline-oY2V_mvK.woff2 +0 -0
- package/dist/playground/assets/index-1K-hG-7p.css +0 -1
- package/dist/playground/assets/index-FlWjhg3x.js +0 -79
- /package/dist/docs/assets/{evals.md.DPZ_MAnI.lean.js → evals.md.DAgEc_hL.lean.js} +0 -0
- /package/dist/docs/assets/{guides_agent-to-agent.md.CrtrsySy.lean.js → guides_agent-to-agent.md.Bpzgq2Pq.lean.js} +0 -0
- /package/dist/docs/assets/{guides_cloud-runtime.md.CYlNMTNp.lean.js → guides_cloud-runtime.md.gVzabdQL.lean.js} +0 -0
- /package/dist/docs/assets/{guides_human-in-the-loop.md.Dvuctx7s.lean.js → guides_human-in-the-loop.md.DlUqsp1S.lean.js} +0 -0
- /package/dist/docs/assets/{guides_webhooks.md.hFTik3lf.lean.js → guides_webhooks.md.B1EswtUu.lean.js} +0 -0
- /package/dist/docs/assets/{reference_connections.md.C3vNH_DE.lean.js → reference_connections.md.zaEYCLHT.lean.js} +0 -0
- /package/dist/docs/assets/{reference_http-api.md.DBAahtdz.lean.js → reference_http-api.md.Dx_nmDG6.lean.js} +0 -0
- /package/dist/docs/assets/{reference_schedules.md.D7qijxLk.lean.js → reference_schedules.md.w_F2mXB6.lean.js} +0 -0
- /package/dist/docs/assets/{reference_subagents.md.CIRAVcPK.lean.js → reference_subagents.md.zWAMNfi1.lean.js} +0 -0
- /package/dist/docs/assets/{reference_tools.md.DF5kwlt0.lean.js → reference_tools.md.CqgJroI0.lean.js} +0 -0
package/dist/internal/server.js
CHANGED
|
@@ -35,12 +35,15 @@ import { Buffer } from "node:buffer";
|
|
|
35
35
|
import { once } from "node:events";
|
|
36
36
|
import { createServer, } from "node:http";
|
|
37
37
|
import { join } from "node:path";
|
|
38
|
+
import { createCursorAccountGithubTokenResolver, getGithubCursorAccountRuntime, parseCursorGithubRepoScope, resolveCursorGithubPermissions, } from "../channels/github/cursor-account.js";
|
|
38
39
|
import { findGitHubChannelTargets } from "../channels/github/forward.js";
|
|
39
40
|
import { dispatchCursorSlackEnvelope, getSlackCursorAccountRuntime, } from "../channels/slack/cursor-account.js";
|
|
41
|
+
import { assertSlackCursorAgentName } from "../channels/slack/types.js";
|
|
40
42
|
import { allowAll, bearerAuth, localDevStrict } from "../channels.js";
|
|
41
43
|
import { CursorAccountMcpBridge, collectCursorAccountConnections, cursorAccountMcpPath, } from "./cursor/account-mcp.js";
|
|
42
44
|
import { CursorBackendClient } from "./cursor/backend-client.js";
|
|
43
|
-
import { cursorBackendUrl, resolveApiKey, SIGN_IN_HINT, } from "./cursor/credentials.js";
|
|
45
|
+
import { cursorBackendUrl, cursorExternalApiUrl, resolveApiKey, SIGN_IN_HINT, } from "./cursor/credentials.js";
|
|
46
|
+
import { CursorGithubCredentialProvider } from "./cursor/github-credentials.js";
|
|
44
47
|
import { CursorEventRelay, formatCursorScmEventLog, scmMetadataToGitHubPayload, } from "./cursor-event-relay.js";
|
|
45
48
|
import { CursorSlackRelay, createCursorSlackApiCaller, formatCursorSlackEventLog, } from "./cursor-slack-relay.js";
|
|
46
49
|
import { formatDiagnostics, hasErrorDiagnostics, projectInfo, } from "./discovery.js";
|
|
@@ -48,7 +51,7 @@ import { packageVersion } from "./distribution.js";
|
|
|
48
51
|
import { docsSiteExists, ensureDocsSiteBundle, renderDocsFile, } from "./docs-site.js";
|
|
49
52
|
import { EvalRunConflictError, EvalRunEmptyError, EvalRunStore, } from "./eval-run-store.js";
|
|
50
53
|
import { collectGitHubTriggerTargets, handleAgentServeTrigger, } from "./handleAgentServeTrigger.js";
|
|
51
|
-
import { warmupHostGitHubAuth } from "./host-platforms.js";
|
|
54
|
+
import { createHostPlatforms, warmupHostGitHubAuth } from "./host-platforms.js";
|
|
52
55
|
import { buildHttpChannelRoutes, errorResponse, jsonResponse, readJsonObject, requireSessionOwner, } from "./http-channel.js";
|
|
53
56
|
import { validateToolInput } from "./json-schema.js";
|
|
54
57
|
import { createLogRing } from "./log-ring.js";
|
|
@@ -72,9 +75,9 @@ const MAX_BODY_BYTES = 32 * 1024 * 1024;
|
|
|
72
75
|
*/
|
|
73
76
|
export function startServer(mounts_1) {
|
|
74
77
|
return __awaiter(this, arguments, void 0, function* (mounts, options = {}) {
|
|
75
|
-
var _a, _b;
|
|
76
|
-
var
|
|
77
|
-
var
|
|
78
|
+
var _a, _b, _c;
|
|
79
|
+
var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
80
|
+
var _r;
|
|
78
81
|
if (mounts.length === 0) {
|
|
79
82
|
throw new Error("startServer requires at least one agent mount");
|
|
80
83
|
}
|
|
@@ -86,31 +89,73 @@ export function startServer(mounts_1) {
|
|
|
86
89
|
}
|
|
87
90
|
}
|
|
88
91
|
const logRing = createLogRing({ capacity: 2000 });
|
|
89
|
-
const logger = logRing.wrap((
|
|
90
|
-
const dev = (
|
|
91
|
-
const playground = (
|
|
92
|
-
const runSchedules = (
|
|
93
|
-
const runReminders = (
|
|
92
|
+
const logger = logRing.wrap((_d = options.logger) !== null && _d !== void 0 ? _d : ((line) => console.log(line)));
|
|
93
|
+
const dev = (_e = options.dev) !== null && _e !== void 0 ? _e : false;
|
|
94
|
+
const playground = (_f = options.playground) !== null && _f !== void 0 ? _f : true;
|
|
95
|
+
const runSchedules = (_g = options.schedules) !== null && _g !== void 0 ? _g : !dev;
|
|
96
|
+
const runReminders = (_h = options.reminders) !== null && _h !== void 0 ? _h : !dev;
|
|
94
97
|
// Identify this process to the Cursor backend as agentkit (the SDK reads
|
|
95
98
|
// this when building its client-version header) so the internal-only
|
|
96
99
|
// agentkit_enabled gate applies to every turn.
|
|
97
|
-
(
|
|
100
|
+
(_j = (_r = process.env).CURSOR_AGENTKIT_VERSION) !== null && _j !== void 0 ? _j : (_r.CURSOR_AGENTKIT_VERSION = packageVersion());
|
|
101
|
+
const cursorGithubTargets = collectCursorGithubTargets(mounts);
|
|
102
|
+
const cursorGithubConfig = resolveCursorGithubEventConfig({
|
|
103
|
+
configured: options.cursorEvents,
|
|
104
|
+
targets: cursorGithubTargets,
|
|
105
|
+
});
|
|
106
|
+
const effectiveCursorEvents = cursorGithubConfig.cursorEvents;
|
|
98
107
|
// One resolution for every Cursor credential consumer (SDK runner, account
|
|
99
|
-
// MCP bridge, SCM event relay): explicit option →
|
|
100
|
-
// `agent-serve login`.
|
|
108
|
+
// MCP bridge, SCM event relay, GitHub credentials): explicit option →
|
|
109
|
+
// CURSOR_API_KEY → stored `agent-serve login`.
|
|
101
110
|
const accountKey = yield resolveApiKey(options.apiKey === undefined ? {} : { apiKey: options.apiKey });
|
|
102
111
|
// The SCM relay reads the event stream as the signed-in user, so
|
|
103
112
|
// `cursorEvents` cannot work signed out. Require the credential before any
|
|
104
113
|
// slow or stateful startup work (playground build, channel onStart, cron).
|
|
105
|
-
const cursorEventsAuth =
|
|
114
|
+
const cursorEventsAuth = effectiveCursorEvents === undefined
|
|
106
115
|
? undefined
|
|
107
|
-
: requireCursorEventsAuth(
|
|
116
|
+
: requireCursorEventsAuth(effectiveCursorEvents, accountKey);
|
|
117
|
+
let cursorGithubCredentials;
|
|
118
|
+
if (cursorGithubConfig.scope !== undefined) {
|
|
119
|
+
if (cursorEventsAuth === undefined) {
|
|
120
|
+
throw new Error("githubChannel({ cursorAccount: true }) could not resolve Cursor event authentication.");
|
|
121
|
+
}
|
|
122
|
+
if (options.allowAnonymous === true) {
|
|
123
|
+
if (options.allowAnonymousCursorGithub !== true) {
|
|
124
|
+
throw new Error("githubChannel({ cursorAccount: true }) cannot be served with --allow-anonymous because admitted callers could use the signed-in account's GitHub access. If every admitted caller is trusted (e.g. behind an SSO proxy), opt in with --allow-anonymous-cursor-github.");
|
|
125
|
+
}
|
|
126
|
+
logger("[agent-serve] warning: --allow-anonymous-cursor-github — every admitted HTTP caller can drive sessions holding the signed-in account's repo-scoped GitHub credential; serve this only behind a trusted boundary (e.g. an SSO proxy)");
|
|
127
|
+
}
|
|
128
|
+
if (cursorGithubConfig.scope.permissions === "contents-write") {
|
|
129
|
+
logger('[agent-serve] warning: Cursor GitHub credentials include contents:write — the host holds a push-capable token shared with model-driven tools and untrusted webhook content; prefer permissions: "pr-write" unless this agent must push code');
|
|
130
|
+
}
|
|
131
|
+
const provider = new CursorGithubCredentialProvider({
|
|
132
|
+
client: new CursorBackendClient({
|
|
133
|
+
backendUrl: cursorEventsAuth.baseUrl,
|
|
134
|
+
apiKey: cursorEventsAuth.apiKey,
|
|
135
|
+
logger,
|
|
136
|
+
}),
|
|
137
|
+
scope: cursorGithubConfig.scope,
|
|
138
|
+
logger,
|
|
139
|
+
});
|
|
140
|
+
cursorGithubCredentials = provider;
|
|
141
|
+
for (const target of cursorGithubTargets) {
|
|
142
|
+
target.accountRuntime.credentials.bind(() => provider.getToken());
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const resolvedCursorGithubCredentials = cursorGithubCredentials;
|
|
146
|
+
const hostPlatforms = createHostPlatforms(resolvedCursorGithubCredentials === undefined
|
|
147
|
+
? {}
|
|
148
|
+
: {
|
|
149
|
+
githubCredentials: {
|
|
150
|
+
token: createCursorAccountGithubTokenResolver(() => resolvedCursorGithubCredentials.getToken()),
|
|
151
|
+
},
|
|
152
|
+
});
|
|
108
153
|
if (playground) {
|
|
109
154
|
// Auto-build dist/playground when missing (monorepo / source checkout).
|
|
110
155
|
// Published installs already ship the bundle; vite may be absent there.
|
|
111
156
|
yield ensurePlaygroundBundle(logger);
|
|
112
157
|
}
|
|
113
|
-
const docsSite = (
|
|
158
|
+
const docsSite = (_k = options.docs) !== null && _k !== void 0 ? _k : true;
|
|
114
159
|
if (docsSite) {
|
|
115
160
|
// Same pattern for the documentation site at /docs.
|
|
116
161
|
yield ensureDocsSiteBundle(logger);
|
|
@@ -118,7 +163,7 @@ export function startServer(mounts_1) {
|
|
|
118
163
|
if (options.allowAnonymous === true) {
|
|
119
164
|
logger("[agent-serve] warning: --allow-anonymous admits every HTTP caller as the same principal; use only on a trusted network (e.g. Tailscale) and prefer --bearer-token for shared hosts");
|
|
120
165
|
}
|
|
121
|
-
const runner = (
|
|
166
|
+
const runner = (_l = options.runner) !== null && _l !== void 0 ? _l : new CursorSdkRunner(accountKey === undefined ? {} : { apiKey: accountKey.apiKey });
|
|
122
167
|
const router = new Router();
|
|
123
168
|
const runtimes = [];
|
|
124
169
|
const channelStopHooks = [];
|
|
@@ -155,18 +200,36 @@ export function startServer(mounts_1) {
|
|
|
155
200
|
}
|
|
156
201
|
for (const { slug, project } of mounts) {
|
|
157
202
|
// Each agent gets an isolated state root so their sessions never mix.
|
|
158
|
-
const baseStateRoot = (
|
|
203
|
+
const baseStateRoot = (_m = options.stateRoot) !== null && _m !== void 0 ? _m : join(project.rootDir, ".agent-serve");
|
|
159
204
|
const stateRoot = slug === "" ? baseStateRoot : join(baseStateRoot, slug);
|
|
160
|
-
const engine = new SessionEngine({
|
|
205
|
+
const engine = new SessionEngine({
|
|
206
|
+
project,
|
|
207
|
+
stateRoot,
|
|
208
|
+
runner,
|
|
209
|
+
logger,
|
|
210
|
+
platforms: hostPlatforms,
|
|
211
|
+
});
|
|
212
|
+
// Rehydrate sessions from the authored storage sink before any
|
|
213
|
+
// channel or route can address them (continuation tokens must resolve).
|
|
214
|
+
yield engine.restoreStoredSessions();
|
|
161
215
|
if (!githubAuthWarmed) {
|
|
162
216
|
// Soft ambient GitHub auth check before channel onStart (which may call
|
|
163
217
|
// host.github). Missing auth is a warning only — serve still starts.
|
|
164
|
-
yield warmupHostGitHubAuth({ logger, github: engine.host.github }
|
|
218
|
+
yield warmupHostGitHubAuth(Object.assign({ logger, github: engine.host.github }, (cursorGithubCredentials === undefined
|
|
219
|
+
? {}
|
|
220
|
+
: { authSource: "cursor-account" })));
|
|
165
221
|
githubAuthWarmed = true;
|
|
166
222
|
}
|
|
167
223
|
const scheduleRunner = new ScheduleRunner(engine, project, logger);
|
|
168
224
|
const reminderRunner = new ReminderRunner(engine, logger);
|
|
169
|
-
const evalRuns = new EvalRunStore(project.rootDir, logger
|
|
225
|
+
const evalRuns = new EvalRunStore(project.rootDir, logger,
|
|
226
|
+
// defineStorage fallback for playground eval history; explicit
|
|
227
|
+
// `evals.config.ts` persistRuns still wins inside the store.
|
|
228
|
+
(_b = engine.storage) === null || _b === void 0 ? void 0 : _b.asEvalRunPersistence());
|
|
229
|
+
// Eval history restores with the same startup step as sessions (reads
|
|
230
|
+
// also hydrate lazily, but doing it here surfaces store problems at
|
|
231
|
+
// boot and makes /v1/dev/evals complete from the first request).
|
|
232
|
+
yield evalRuns.hydrate();
|
|
170
233
|
engine.setReminders({
|
|
171
234
|
create: (input) => reminderRunner.create(input),
|
|
172
235
|
list: (filter) => reminderRunner.list(filter),
|
|
@@ -217,7 +280,7 @@ export function startServer(mounts_1) {
|
|
|
217
280
|
}
|
|
218
281
|
catch (error) {
|
|
219
282
|
logger(`[agent-serve] channel "${channel.id}" onStart failed: ${error instanceof Error
|
|
220
|
-
? ((
|
|
283
|
+
? ((_o = error.stack) !== null && _o !== void 0 ? _o : error.message)
|
|
221
284
|
: String(error)}`);
|
|
222
285
|
}
|
|
223
286
|
}
|
|
@@ -338,14 +401,6 @@ export function startServer(mounts_1) {
|
|
|
338
401
|
? {}
|
|
339
402
|
: { publicUrl: options.publicUrl })));
|
|
340
403
|
}
|
|
341
|
-
// Cursor SCM events relay (opt-in: serve({ cursorEvents }) / --cursor-events).
|
|
342
|
-
const cursorEventRelay = startCursorEventRelay({
|
|
343
|
-
options,
|
|
344
|
-
mounts,
|
|
345
|
-
auth: cursorEventsAuth,
|
|
346
|
-
logger,
|
|
347
|
-
collectTriggerTargets,
|
|
348
|
-
});
|
|
349
404
|
// Cursor Slack relay: automatic when a mounted agent authored
|
|
350
405
|
// `slackChannel({ cursorAccount: true })`. Inbound rides the account's
|
|
351
406
|
// Slack connection (`/v0/slack-events`); the classic Socket-Mode path is
|
|
@@ -356,13 +411,38 @@ export function startServer(mounts_1) {
|
|
|
356
411
|
accountKey,
|
|
357
412
|
logger,
|
|
358
413
|
});
|
|
414
|
+
try {
|
|
415
|
+
yield cursorGithubCredentials === null || cursorGithubCredentials === void 0 ? void 0 : cursorGithubCredentials.start();
|
|
416
|
+
}
|
|
417
|
+
catch (error) {
|
|
418
|
+
yield cursorSlackRelay === null || cursorSlackRelay === void 0 ? void 0 : cursorSlackRelay.stop();
|
|
419
|
+
throw error;
|
|
420
|
+
}
|
|
421
|
+
// Cursor SCM events relay (opt-in: serve({ cursorEvents }) / --cursor-events).
|
|
422
|
+
const cursorEventRelay = startCursorEventRelay({
|
|
423
|
+
config: effectiveCursorEvents,
|
|
424
|
+
stateRoot: options.stateRoot,
|
|
425
|
+
mounts,
|
|
426
|
+
auth: cursorEventsAuth,
|
|
427
|
+
logger,
|
|
428
|
+
collectTriggerTargets,
|
|
429
|
+
cursorAccountOnly: options.cursorEvents === undefined && cursorGithubTargets.length > 0,
|
|
430
|
+
});
|
|
359
431
|
const server = createServer((req, res) => {
|
|
360
432
|
void handleRequest(router, req, res, logger);
|
|
361
433
|
});
|
|
362
|
-
const host = (
|
|
363
|
-
const port = (
|
|
364
|
-
|
|
365
|
-
|
|
434
|
+
const host = (_p = options.host) !== null && _p !== void 0 ? _p : "127.0.0.1";
|
|
435
|
+
const port = (_q = options.port) !== null && _q !== void 0 ? _q : 3000;
|
|
436
|
+
try {
|
|
437
|
+
server.listen(port, host);
|
|
438
|
+
yield once(server, "listening");
|
|
439
|
+
}
|
|
440
|
+
catch (error) {
|
|
441
|
+
yield cursorEventRelay === null || cursorEventRelay === void 0 ? void 0 : cursorEventRelay.stop();
|
|
442
|
+
yield cursorSlackRelay === null || cursorSlackRelay === void 0 ? void 0 : cursorSlackRelay.stop();
|
|
443
|
+
cursorGithubCredentials === null || cursorGithubCredentials === void 0 ? void 0 : cursorGithubCredentials.stop();
|
|
444
|
+
throw error;
|
|
445
|
+
}
|
|
366
446
|
const address = server.address();
|
|
367
447
|
const displayHost = host === "0.0.0.0" || host === "::" ? "127.0.0.1" : host;
|
|
368
448
|
const url = `http://${displayHost}:${address.port}`;
|
|
@@ -411,7 +491,7 @@ export function startServer(mounts_1) {
|
|
|
411
491
|
const handle = {
|
|
412
492
|
url,
|
|
413
493
|
port: address.port,
|
|
414
|
-
project: (
|
|
494
|
+
project: (_c = runtimes[0]) === null || _c === void 0 ? void 0 : _c.project,
|
|
415
495
|
agents,
|
|
416
496
|
dispatchSchedule: (name, slug) => {
|
|
417
497
|
var _a;
|
|
@@ -494,7 +574,12 @@ export function startServer(mounts_1) {
|
|
|
494
574
|
}
|
|
495
575
|
server.close();
|
|
496
576
|
server.closeAllConnections();
|
|
497
|
-
|
|
577
|
+
try {
|
|
578
|
+
yield Promise.all(runtimes.map((runtime) => runtime.engine.close()));
|
|
579
|
+
}
|
|
580
|
+
finally {
|
|
581
|
+
cursorGithubCredentials === null || cursorGithubCredentials === void 0 ? void 0 : cursorGithubCredentials.stop();
|
|
582
|
+
}
|
|
498
583
|
}),
|
|
499
584
|
};
|
|
500
585
|
if ((playgroundDev === null || playgroundDev === void 0 ? void 0 : playgroundDev.url) !== undefined) {
|
|
@@ -955,14 +1040,17 @@ function mountAgentRoutes(router, runtime, args) {
|
|
|
955
1040
|
* serve instead of starting with a relay that could never run.
|
|
956
1041
|
*/
|
|
957
1042
|
function requireCursorEventsAuth(config, accountKey) {
|
|
958
|
-
var _a, _b, _c
|
|
1043
|
+
var _a, _b, _c;
|
|
959
1044
|
const apiKey = ((_b = (_a = config.apiKey) !== null && _a !== void 0 ? _a : accountKey === null || accountKey === void 0 ? void 0 : accountKey.apiKey) !== null && _b !== void 0 ? _b : "").trim();
|
|
960
1045
|
if (apiKey === "") {
|
|
961
1046
|
throw new Error(`[agent-serve] --cursor-events (serve({ cursorEvents })) requires a signed-in Cursor account: the SCM event stream is read as the host's user. ${SIGN_IN_HINT}`);
|
|
962
1047
|
}
|
|
963
1048
|
return {
|
|
964
1049
|
apiKey,
|
|
965
|
-
|
|
1050
|
+
// `/v0/scm-events/*` lives on the external API (api.cursor.com), not
|
|
1051
|
+
// api2. Prefer that default over the account key's backendUrl, which
|
|
1052
|
+
// follows cursorBackendUrl() (api2) when CURSOR_API_KEY is set.
|
|
1053
|
+
baseUrl: (_c = config.baseUrl) !== null && _c !== void 0 ? _c : cursorExternalApiUrl(),
|
|
966
1054
|
};
|
|
967
1055
|
}
|
|
968
1056
|
/**
|
|
@@ -972,9 +1060,8 @@ function requireCursorEventsAuth(config, accountKey) {
|
|
|
972
1060
|
*/
|
|
973
1061
|
function startCursorEventRelay(input) {
|
|
974
1062
|
var _a;
|
|
975
|
-
var _b
|
|
976
|
-
const {
|
|
977
|
-
const config = options.cursorEvents;
|
|
1063
|
+
var _b;
|
|
1064
|
+
const { config, stateRoot, mounts, auth, logger, collectTriggerTargets } = input;
|
|
978
1065
|
if (config === undefined || auth === undefined) {
|
|
979
1066
|
return undefined;
|
|
980
1067
|
}
|
|
@@ -989,7 +1076,7 @@ function startCursorEventRelay(input) {
|
|
|
989
1076
|
logger("[agent-serve] cursor-events: no mounted agent declares a github channel; relay disabled");
|
|
990
1077
|
return undefined;
|
|
991
1078
|
}
|
|
992
|
-
const baseStateRoot =
|
|
1079
|
+
const baseStateRoot = stateRoot !== null && stateRoot !== void 0 ? stateRoot : join((_b = (_a = mounts[0]) === null || _a === void 0 ? void 0 : _a.project.rootDir) !== null && _b !== void 0 ? _b : process.cwd(), ".agent-serve");
|
|
993
1080
|
const relay = new CursorEventRelay({
|
|
994
1081
|
baseUrl: auth.baseUrl,
|
|
995
1082
|
apiKey: auth.apiKey,
|
|
@@ -1002,12 +1089,23 @@ function startCursorEventRelay(input) {
|
|
|
1002
1089
|
dispatch: (event) => __awaiter(this, void 0, void 0, function* () {
|
|
1003
1090
|
if (event.provider !== "github")
|
|
1004
1091
|
return;
|
|
1092
|
+
const targets = collectTriggerTargets().filter((target) => {
|
|
1093
|
+
const cursorAccount = target.options.cursorAccount;
|
|
1094
|
+
if (input.cursorAccountOnly &&
|
|
1095
|
+
cursorAccount !== true &&
|
|
1096
|
+
typeof cursorAccount !== "object") {
|
|
1097
|
+
return false;
|
|
1098
|
+
}
|
|
1099
|
+
return typeof cursorAccount !== "object"
|
|
1100
|
+
? true
|
|
1101
|
+
: cursorAccount.repos.some((repo) => repo.toLowerCase() === event.repo.toLowerCase());
|
|
1102
|
+
});
|
|
1005
1103
|
const result = yield handleAgentServeTrigger({
|
|
1006
1104
|
type: "github",
|
|
1007
1105
|
bodyText: JSON.stringify(scmMetadataToGitHubPayload(event)),
|
|
1008
1106
|
eventName: event.eventName,
|
|
1009
1107
|
deliveryId: event.deliveryId,
|
|
1010
|
-
targets
|
|
1108
|
+
targets,
|
|
1011
1109
|
});
|
|
1012
1110
|
const outcomes = result.targets
|
|
1013
1111
|
.map((target) => `${target.slug || "default"}:${target.status}`)
|
|
@@ -1019,13 +1117,51 @@ function startCursorEventRelay(input) {
|
|
|
1019
1117
|
logger(`[agent-serve] cursor-events: relaying ${events.length} event kind(s) for ${repos.join(", ")} from ${auth.baseUrl}`);
|
|
1020
1118
|
return relay;
|
|
1021
1119
|
}
|
|
1022
|
-
|
|
1120
|
+
function collectCursorGithubTargets(mounts) {
|
|
1121
|
+
const targets = [];
|
|
1122
|
+
for (const mount of mounts) {
|
|
1123
|
+
for (const channel of mount.project.channels) {
|
|
1124
|
+
const accountRuntime = getGithubCursorAccountRuntime(channel.definition);
|
|
1125
|
+
if (accountRuntime !== undefined) {
|
|
1126
|
+
targets.push({
|
|
1127
|
+
slug: mount.slug,
|
|
1128
|
+
channelId: channel.id,
|
|
1129
|
+
accountRuntime,
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
return targets;
|
|
1135
|
+
}
|
|
1136
|
+
function resolveCursorGithubEventConfig(input) {
|
|
1137
|
+
var _a;
|
|
1138
|
+
var _b;
|
|
1139
|
+
if (input.targets.length === 0) {
|
|
1140
|
+
return { cursorEvents: input.configured, scope: undefined };
|
|
1141
|
+
}
|
|
1142
|
+
const repos = [
|
|
1143
|
+
...((_b = (_a = input.configured) === null || _a === void 0 ? void 0 : _a.repos) !== null && _b !== void 0 ? _b : []),
|
|
1144
|
+
...input.targets.flatMap((target) => { var _a; var _b; return [
|
|
1145
|
+
...((_b = (_a = target.accountRuntime.scope) === null || _a === void 0 ? void 0 : _a.repos) !== null && _b !== void 0 ? _b : []),
|
|
1146
|
+
]; }),
|
|
1147
|
+
];
|
|
1148
|
+
const permissions = resolveCursorGithubPermissions(input.targets.map((target) => { var _a; var _b; return (_b = (_a = target.accountRuntime.scope) === null || _a === void 0 ? void 0 : _a.permissions) !== null && _b !== void 0 ? _b : "pr-write"; }));
|
|
1149
|
+
const scope = parseCursorGithubRepoScope(repos, permissions);
|
|
1150
|
+
return {
|
|
1151
|
+
cursorEvents: Object.assign(Object.assign({}, input.configured), { repos: [...scope.repos] }),
|
|
1152
|
+
scope,
|
|
1153
|
+
};
|
|
1154
|
+
}
|
|
1155
|
+
/**
|
|
1156
|
+
* `weather-agent` → `WeatherAgent` (single-token Cursor Slack handle).
|
|
1157
|
+
* Must not contain whitespace — see {@link assertSlackCursorAgentName}.
|
|
1158
|
+
*/
|
|
1023
1159
|
function slackAgentNameFromSlug(slug) {
|
|
1024
1160
|
return slug
|
|
1025
1161
|
.split(/[-_\s]+/)
|
|
1026
1162
|
.filter((word) => word.length > 0)
|
|
1027
1163
|
.map((word) => word[0].toUpperCase() + word.slice(1))
|
|
1028
|
-
.join("
|
|
1164
|
+
.join("");
|
|
1029
1165
|
}
|
|
1030
1166
|
/**
|
|
1031
1167
|
* Mounted Slack channels riding the Cursor account connection
|
|
@@ -1047,6 +1183,7 @@ function collectCursorSlackTargets(runtimes) {
|
|
|
1047
1183
|
if (agentName === "") {
|
|
1048
1184
|
throw new Error(`slackChannel({ cursorAccount: true }) on agent "${runtime.slug || runtime.project.name}" resolved an empty agent name; set agentName.`);
|
|
1049
1185
|
}
|
|
1186
|
+
assertSlackCursorAgentName(agentName);
|
|
1050
1187
|
const nameKey = agentName.toLowerCase();
|
|
1051
1188
|
const existing = byName.get(nameKey);
|
|
1052
1189
|
if (existing !== undefined) {
|
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { type AgentProject, type ApprovalDecision, type AuthContext, type CallToolOptions, type ChannelDefinition, type ChannelSession, type HostContext, type HttpChannelDefinition, type PendingApproval, type ReceiveInput, type SendMessageOptions, type SessionEvent, type SessionInfo, type SessionRecord, type SessionSummary, type ToolCallOutcome, type TurnOutcome } from "../types.js";
|
|
10
10
|
import { type ABSnapshot } from "./ab-snapshot.js";
|
|
11
|
+
import { type HostPlatforms } from "./host-platforms.js";
|
|
11
12
|
import type { AgentRunner } from "./sdk-runner.js";
|
|
12
13
|
import { SessionStore } from "./session-store.js";
|
|
14
|
+
import { StorageCoordinator } from "./storage-coordinator.js";
|
|
13
15
|
export declare const HTTP_CHANNEL_ID = "http";
|
|
14
|
-
export
|
|
16
|
+
export { SCHEDULE_CHANNEL_PREFIX } from "./prompt-context.js";
|
|
15
17
|
export declare class SessionBusyError extends Error {
|
|
16
18
|
constructor(sessionId: string);
|
|
17
19
|
}
|
|
@@ -48,6 +50,7 @@ export interface SessionEngineOptions {
|
|
|
48
50
|
stateRoot: string;
|
|
49
51
|
runner: AgentRunner;
|
|
50
52
|
logger?: (line: string) => void;
|
|
53
|
+
platforms?: HostPlatforms;
|
|
51
54
|
}
|
|
52
55
|
/**
|
|
53
56
|
* A connection the serve host resolved once it was listening — a **peer**
|
|
@@ -80,6 +83,18 @@ export declare class SessionEngine {
|
|
|
80
83
|
readonly project: AgentProject;
|
|
81
84
|
readonly stateRoot: string;
|
|
82
85
|
readonly sessions: SessionStore;
|
|
86
|
+
/**
|
|
87
|
+
* Runtime for `agent/storage.ts` (`defineStorage`), when
|
|
88
|
+
* authored. All durable state changes funnel through it (session
|
|
89
|
+
* records, event chunks, A/B samples/snapshots); the eval run store
|
|
90
|
+
* attaches via {@link StorageCoordinator.asEvalRunPersistence} at
|
|
91
|
+
* serve start.
|
|
92
|
+
*/
|
|
93
|
+
readonly storage: StorageCoordinator | undefined;
|
|
94
|
+
/** In-flight lazy restores, deduped per channel + continuation key. */
|
|
95
|
+
private readonly restoreInFlight;
|
|
96
|
+
/** Once-per-process cache for the A/B snapshot backfill (see abSnapshot). */
|
|
97
|
+
private restoredAbSnapshot;
|
|
83
98
|
private readonly runner;
|
|
84
99
|
private readonly logger;
|
|
85
100
|
private readonly logs;
|
|
@@ -280,6 +295,40 @@ export declare class SessionEngine {
|
|
|
280
295
|
private initialChannelState;
|
|
281
296
|
/** Serialized, immutable record updates (latest-wins per session). */
|
|
282
297
|
private updateRecord;
|
|
298
|
+
/**
|
|
299
|
+
* Restore sessions from the authored storage sink. Called once at
|
|
300
|
+
* serve start, before channels accept traffic: any persisted session
|
|
301
|
+
* missing from the local `--state-root` is materialized there — events
|
|
302
|
+
* as `events.ndjson`, record as `session.json` — after which every
|
|
303
|
+
* existing read path (continuation lookup, event replay/streams, A/B
|
|
304
|
+
* fold hydration) works unchanged. Local state always wins over the
|
|
305
|
+
* sink, so restarts on the same host are no-ops.
|
|
306
|
+
*
|
|
307
|
+
* Failures are logged and skipped; a broken store (including rows that
|
|
308
|
+
* violate the SessionRecord shape) never blocks serve start.
|
|
309
|
+
*/
|
|
310
|
+
restoreStoredSessions(): Promise<void>;
|
|
311
|
+
private runBulkRestore;
|
|
312
|
+
/**
|
|
313
|
+
* Lazy restore: a continuation lookup missed locally, so ask the sink
|
|
314
|
+
* for that one session and materialize it before resuming. Disk grows
|
|
315
|
+
* with sessions that are actually resumed, not with history.
|
|
316
|
+
*
|
|
317
|
+
* Concurrent misses for the same key (webhook redeliveries, retries)
|
|
318
|
+
* share one in-flight restore — a second materialization racing the
|
|
319
|
+
* first resumed turn could truncate events the turn already appended.
|
|
320
|
+
* Sink errors propagate and fail the send (see
|
|
321
|
+
* {@link StorageCoordinator.getSessionByContinuation}).
|
|
322
|
+
*/
|
|
323
|
+
private restoreSessionByContinuation;
|
|
324
|
+
private loadAndMaterializeByContinuation;
|
|
325
|
+
/**
|
|
326
|
+
* Write one restored session to the local state root. Events land on
|
|
327
|
+
* disk before the record: a session becomes visible (and addressable via
|
|
328
|
+
* its continuation key) only with its full stream in place, and the
|
|
329
|
+
* lazily opened event log hydrates from this file.
|
|
330
|
+
*/
|
|
331
|
+
private materializeSession;
|
|
283
332
|
trackBackground(promise: Promise<unknown>): void;
|
|
284
333
|
/** Drain running turns, dispatches, and pending writes, then dispose. */
|
|
285
334
|
close(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-engine.d.ts","sourceRoot":"","sources":["../../src/internal/session-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAYH,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,EAIjB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAEjB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,eAAe,EAGpB,KAAK,WAAW,EACjB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,KAAK,UAAU,EAAmB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"session-engine.d.ts","sourceRoot":"","sources":["../../src/internal/session-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAYH,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,EAIjB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAEjB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,eAAe,EAGpB,KAAK,WAAW,EACjB,MAAM,aAAa,CAAC;A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