@cursor/july 0.1.16 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -4
- package/dist/bin/agent-serve.js +60 -2
- package/dist/channels/slack/api.d.ts.map +1 -1
- package/dist/channels/slack/api.js +13 -3
- package/dist/channels/slack/auth.d.ts +7 -1
- package/dist/channels/slack/auth.d.ts.map +1 -1
- package/dist/channels/slack/auth.js +14 -0
- package/dist/channels/slack/blocks.d.ts +61 -0
- package/dist/channels/slack/blocks.d.ts.map +1 -0
- package/dist/channels/slack/blocks.js +90 -0
- package/dist/channels/slack/cursor-account.d.ts.map +1 -1
- package/dist/channels/slack/cursor-account.js +1 -1
- package/dist/channels/slack/defaults.d.ts +2 -0
- package/dist/channels/slack/defaults.d.ts.map +1 -1
- package/dist/channels/slack/defaults.js +29 -3
- package/dist/channels/slack/dispatch.d.ts +3 -17
- package/dist/channels/slack/dispatch.d.ts.map +1 -1
- package/dist/channels/slack/dispatch.js +4 -1
- package/dist/channels/slack/inbound.d.ts.map +1 -1
- package/dist/channels/slack/inbound.js +6 -1
- package/dist/channels/slack/index.d.ts +2 -0
- package/dist/channels/slack/index.d.ts.map +1 -1
- package/dist/channels/slack/index.js +2 -0
- package/dist/channels/slack/init.d.ts.map +1 -1
- package/dist/channels/slack/init.js +4 -1
- package/dist/channels/slack/interactive.d.ts +39 -3
- package/dist/channels/slack/interactive.d.ts.map +1 -1
- package/dist/channels/slack/interactive.js +153 -7
- package/dist/channels/slack/manifest.d.ts +13 -0
- package/dist/channels/slack/manifest.d.ts.map +1 -1
- package/dist/channels/slack/manifest.js +36 -14
- package/dist/channels/slack/message-body.d.ts +13 -0
- package/dist/channels/slack/message-body.d.ts.map +1 -0
- package/dist/channels/slack/message-body.js +82 -0
- package/dist/channels/slack/setup.d.ts +4 -1
- package/dist/channels/slack/setup.d.ts.map +1 -1
- package/dist/channels/slack/setup.js +16 -2
- package/dist/channels/slack/slack-channel.d.ts.map +1 -1
- package/dist/channels/slack/slack-channel.js +24 -3
- package/dist/channels/slack/thread-context.d.ts +0 -2
- package/dist/channels/slack/thread-context.d.ts.map +1 -1
- package/dist/channels/slack/thread-context.js +1 -65
- package/dist/channels/slack/types.d.ts +93 -1
- package/dist/channels/slack/types.d.ts.map +1 -1
- package/dist/connections.d.ts +4 -1
- package/dist/connections.d.ts.map +1 -1
- package/dist/connections.js +4 -1
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +3 -3
- package/dist/docs/assets/{app.DjHC-Ggf.js → app.BR5EdVSq.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.BOzkeUi8.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.DwviwmIq.js → VPLocalSearchBox.CNCzfUKC.js} +1 -1
- package/dist/docs/assets/chunks/{theme.BIpeYSon.js → theme.CwKvMSWv.js} +2 -2
- package/dist/docs/assets/{example-agents_security-reviewer.md.BZSNycMf.js → example-agents_security-reviewer.md.Dhj_m7_B.js} +1 -1
- package/dist/docs/assets/{guides_mcp-oauth.md.DqmEOQY1.js → guides_mcp-oauth.md.Dd8EgSem.js} +3 -2
- package/dist/docs/assets/{guides_mcp-oauth.md.DqmEOQY1.lean.js → guides_mcp-oauth.md.Dd8EgSem.lean.js} +1 -1
- package/dist/docs/assets/{guides_slack.md.FWale6Ip.js → guides_slack.md.D_xFKlnF.js} +1 -1
- package/dist/docs/assets/{reference_connections.md.CsSr3rDz.js → reference_connections.md.B9Q3TOve.js} +12 -5
- package/dist/docs/assets/{reference_connections.md.CsSr3rDz.lean.js → reference_connections.md.B9Q3TOve.lean.js} +1 -1
- package/dist/docs/building-with-agents.html +3 -3
- package/dist/docs/concepts.html +3 -3
- package/dist/docs/deployment.html +3 -3
- package/dist/docs/evals.html +3 -3
- package/dist/docs/example-agents/approval-buddy.html +3 -3
- package/dist/docs/example-agents/benny.html +3 -3
- package/dist/docs/example-agents/bugbot.html +3 -3
- package/dist/docs/example-agents/codebase-wiki.html +3 -3
- package/dist/docs/example-agents/codeowners-review.html +3 -3
- package/dist/docs/example-agents/concierge.html +3 -3
- package/dist/docs/example-agents/fsd.html +3 -3
- package/dist/docs/example-agents/index.html +3 -3
- 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 +5 -5
- package/dist/docs/example-agents/slack-agent.html +3 -3
- package/dist/docs/example-agents/weather-agent.html +3 -3
- package/dist/docs/guides/agent-to-agent.html +3 -3
- package/dist/docs/guides/cloud-runtime.html +3 -3
- package/dist/docs/guides/github.html +3 -3
- package/dist/docs/guides/human-in-the-loop.html +3 -3
- package/dist/docs/guides/mcp-oauth.html +6 -5
- package/dist/docs/guides/slack.html +5 -5
- package/dist/docs/guides/webhooks.html +3 -3
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +3 -3
- package/dist/docs/index.html +3 -3
- package/dist/docs/quickstart.html +3 -3
- package/dist/docs/reference/agent-config.html +3 -3
- package/dist/docs/reference/channels.html +3 -3
- package/dist/docs/reference/cli.html +3 -3
- package/dist/docs/reference/connections.html +14 -7
- package/dist/docs/reference/hooks.html +3 -3
- package/dist/docs/reference/http-api.html +3 -3
- package/dist/docs/reference/instructions.html +3 -3
- package/dist/docs/reference/playground.html +3 -3
- package/dist/docs/reference/project-layout.html +3 -3
- package/dist/docs/reference/prompt.html +3 -3
- package/dist/docs/reference/schedules.html +3 -3
- package/dist/docs/reference/sessions.html +3 -3
- package/dist/docs/reference/skills.html +3 -3
- package/dist/docs/reference/subagents.html +3 -3
- package/dist/docs/reference/tools.html +3 -3
- package/dist/docs/scaffolding-agents.html +3 -3
- package/dist/docs/storage.html +3 -3
- package/dist/docs/troubleshooting.html +3 -3
- package/dist/evals/assertions.d.ts +190 -0
- package/dist/evals/assertions.d.ts.map +1 -0
- package/dist/evals/assertions.js +461 -0
- package/dist/evals/expect.d.ts +95 -0
- package/dist/evals/expect.d.ts.map +1 -0
- package/dist/evals/expect.js +194 -0
- package/dist/evals/judge.d.ts +133 -0
- package/dist/evals/judge.d.ts.map +1 -0
- package/dist/evals/judge.js +228 -0
- package/dist/evals/loaders.d.ts +51 -0
- package/dist/evals/loaders.d.ts.map +1 -0
- package/dist/evals/loaders.js +124 -0
- package/dist/evals/matchers.d.ts +95 -0
- package/dist/evals/matchers.d.ts.map +1 -0
- package/dist/evals/matchers.js +145 -0
- package/dist/evals/reporters.d.ts +70 -0
- package/dist/evals/reporters.d.ts.map +1 -0
- package/dist/evals/reporters.js +221 -0
- package/dist/evals/results.d.ts +103 -0
- package/dist/evals/results.d.ts.map +1 -0
- package/dist/evals/results.js +28 -0
- package/dist/evals/run-facts.d.ts +77 -0
- package/dist/evals/run-facts.d.ts.map +1 -0
- package/dist/evals/run-facts.js +187 -0
- package/dist/evals.d.ts +118 -31
- package/dist/evals.d.ts.map +1 -1
- package/dist/evals.js +46 -12
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/builtin-tools/index.d.ts +10 -0
- package/dist/internal/builtin-tools/index.d.ts.map +1 -0
- package/dist/internal/builtin-tools/index.js +27 -0
- package/dist/internal/builtin-tools/reminders.d.ts +9 -0
- package/dist/internal/builtin-tools/reminders.d.ts.map +1 -0
- package/dist/internal/builtin-tools/reminders.js +138 -0
- package/dist/internal/cli-ax.d.ts +27 -0
- package/dist/internal/cli-ax.d.ts.map +1 -1
- package/dist/internal/cli-ax.js +90 -12
- package/dist/internal/cli-mcp.d.ts +8 -0
- package/dist/internal/cli-mcp.d.ts.map +1 -1
- package/dist/internal/cli-mcp.js +98 -0
- package/dist/internal/cli-slack.d.ts +29 -1
- package/dist/internal/cli-slack.d.ts.map +1 -1
- package/dist/internal/cli-slack.js +799 -13
- package/dist/internal/cursor-event-relay.d.ts +30 -0
- package/dist/internal/cursor-event-relay.d.ts.map +1 -1
- package/dist/internal/cursor-event-relay.js +37 -0
- package/dist/internal/deploy-client.d.ts +7 -0
- package/dist/internal/deploy-client.d.ts.map +1 -1
- package/dist/internal/deploy-client.js +9 -0
- package/dist/internal/discovery.d.ts.map +1 -1
- package/dist/internal/discovery.js +70 -9
- package/dist/internal/distribution.d.ts.map +1 -1
- package/dist/internal/distribution.js +2 -0
- package/dist/internal/eval-judge-model.d.ts +59 -0
- package/dist/internal/eval-judge-model.d.ts.map +1 -0
- package/dist/internal/eval-judge-model.js +131 -0
- package/dist/internal/eval-run-store.d.ts.map +1 -1
- package/dist/internal/eval-run-store.js +12 -20
- package/dist/internal/eval-runner.d.ts +31 -25
- package/dist/internal/eval-runner.d.ts.map +1 -1
- package/dist/internal/eval-runner.js +329 -126
- package/dist/internal/evals-client.d.ts.map +1 -1
- package/dist/internal/evals-client.js +4 -1
- package/dist/internal/local-env.d.ts +8 -0
- package/dist/internal/local-env.d.ts.map +1 -0
- package/dist/internal/local-env.js +47 -0
- package/dist/internal/playground/static.d.ts +3 -0
- package/dist/internal/playground/static.d.ts.map +1 -1
- package/dist/internal/playground/static.js +3 -0
- package/dist/internal/reminder-runner.d.ts +7 -0
- package/dist/internal/reminder-runner.d.ts.map +1 -1
- package/dist/internal/reminder-runner.js +21 -0
- package/dist/internal/run-client.d.ts +15 -0
- package/dist/internal/run-client.d.ts.map +1 -1
- package/dist/internal/run-client.js +3 -2
- package/dist/internal/sdk-runner.d.ts +51 -1
- package/dist/internal/sdk-runner.d.ts.map +1 -1
- package/dist/internal/sdk-runner.js +176 -36
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +11 -1
- package/dist/internal/session-engine.d.ts +18 -5
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +81 -19
- package/dist/internal/slack-provision-client.d.ts +133 -0
- package/dist/internal/slack-provision-client.d.ts.map +1 -0
- package/dist/internal/slack-provision-client.js +286 -0
- package/dist/playground/assets/cursor-icons-16-f_W_ogc-.woff2 +0 -0
- package/dist/playground/assets/index-DRjS5klQ.js +85 -0
- package/dist/playground/assets/index-TCDs-UhZ.css +1 -0
- package/dist/playground/index.html +2 -2
- package/dist/types.d.ts +98 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +26 -0
- package/docs/example-agents/security-reviewer.md +1 -1
- package/docs/guides/mcp-oauth.md +10 -5
- package/docs/guides/slack.md +3 -2
- package/docs/reference/connections.md +28 -18
- package/package.json +20 -2
- package/skills/create-agent/SKILL.md +15 -7
- package/skills/debug/SKILL.md +3 -1
- package/skills/mcp-auth/SKILL.md +1 -1
- package/skills/setup-slack/SKILL.md +177 -11
- package/src/bin/agent-serve.ts +63 -2
- package/src/channels/slack/api.ts +16 -3
- package/src/channels/slack/auth.ts +16 -1
- package/src/channels/slack/blocks.ts +139 -0
- package/src/channels/slack/cursor-account.ts +1 -0
- package/src/channels/slack/defaults.ts +32 -4
- package/src/channels/slack/dispatch.ts +6 -19
- package/src/channels/slack/inbound.ts +6 -1
- package/src/channels/slack/index.ts +2 -0
- package/src/channels/slack/init.ts +3 -0
- package/src/channels/slack/interactive.ts +184 -19
- package/src/channels/slack/manifest.ts +37 -6
- package/src/channels/slack/message-body.ts +90 -0
- package/src/channels/slack/setup.ts +16 -2
- package/src/channels/slack/slack-channel.ts +37 -6
- package/src/channels/slack/thread-context.ts +1 -69
- package/src/channels/slack/types.ts +105 -1
- package/src/connections.ts +4 -1
- package/src/evals/assertions.ts +704 -0
- package/src/evals/expect.ts +272 -0
- package/src/evals/judge.ts +346 -0
- package/src/evals/loaders.ts +113 -0
- package/src/evals/matchers.ts +246 -0
- package/src/evals/reporters.ts +274 -0
- package/src/evals/results.ts +132 -0
- package/src/evals/run-facts.ts +274 -0
- package/src/evals.ts +205 -42
- package/src/index.ts +2 -0
- package/src/internal/builtin-tools/index.ts +40 -0
- package/src/internal/builtin-tools/reminders.ts +158 -0
- package/src/internal/cli-ax.ts +134 -15
- package/src/internal/cli-mcp.ts +118 -5
- package/src/internal/cli-slack.ts +1017 -15
- package/src/internal/cursor-event-relay.ts +67 -0
- package/src/internal/deploy-client.ts +10 -0
- package/src/internal/discovery.ts +83 -5
- package/src/internal/distribution.ts +2 -0
- package/src/internal/eval-judge-model.ts +148 -0
- package/src/internal/eval-run-store.ts +10 -14
- package/src/internal/eval-runner.ts +460 -214
- package/src/internal/evals-client.ts +5 -0
- package/src/internal/local-env.ts +53 -0
- package/src/internal/playground/static.ts +3 -0
- package/src/internal/reminder-runner.ts +30 -0
- package/src/internal/run-client.ts +17 -1
- package/src/internal/sdk-runner.ts +234 -35
- package/src/internal/server.ts +12 -0
- package/src/internal/session-engine.ts +103 -21
- package/src/internal/slack-provision-client.ts +442 -0
- package/src/types.ts +125 -4
- package/dist/channels/slack/post-update-delivery.d.ts +0 -85
- package/dist/channels/slack/post-update-delivery.d.ts.map +0 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.DZtu0ZIc.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/persistence.d.ts +0 -184
- package/dist/persistence.d.ts.map +0 -1
- package/dist/playground/assets/cursor-icons-16-CQ50JpfO.woff2 +0 -0
- package/dist/playground/assets/index-Bwl4Onx4.js +0 -85
- package/dist/playground/assets/index-ByV4nfch.css +0 -1
- /package/dist/docs/assets/{example-agents_security-reviewer.md.BZSNycMf.lean.js → example-agents_security-reviewer.md.Dhj_m7_B.lean.js} +0 -0
- /package/dist/docs/assets/{guides_slack.md.FWale6Ip.lean.js → guides_slack.md.D_xFKlnF.lean.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-engine.d.ts","sourceRoot":"","sources":["../../src/internal/session-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAYH,OAAO,EACL,mBAAmB,EACnB,eAAe,EAChB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,KA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AAC,aAAa,GAAG,SAAS,CAAC,CAMpC;IAED;;;;;;;;;;OAUG;IACH,OAAO,CAAC,4BAA4B;IAqBpC,OAAO,CAAC,kBAAkB;YAkBZ,gCAAgC;YAgBhC,sBAAsB;YAWtB,yBAAyB;IAmBvC;;;;;OAKG;YACW,kBAAkB;IAYhC,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAO/C;IAED,yEAAyE;IACnE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAU3B;CACF"}
|
|
@@ -666,27 +666,72 @@ export class SessionEngine {
|
|
|
666
666
|
});
|
|
667
667
|
}
|
|
668
668
|
/**
|
|
669
|
-
* Local harness cwd for a session: per-send override, else
|
|
670
|
-
* `<agent.local.cwd>/<sessionId>`, else
|
|
669
|
+
* Local harness cwd for a session: per-send override, else the shared
|
|
670
|
+
* `agent.local.workspaceDir`, else `<agent.local.cwd>/<sessionId>`, else
|
|
671
|
+
* the durable session workspace.
|
|
671
672
|
*/
|
|
672
673
|
harnessCwd(record) {
|
|
673
|
-
var _a;
|
|
674
|
+
var _a, _b;
|
|
674
675
|
if (record.workspaceOverride !== undefined) {
|
|
675
676
|
return record.workspaceOverride;
|
|
676
677
|
}
|
|
677
|
-
const
|
|
678
|
+
const shared = (_a = this.project.agent.local) === null || _a === void 0 ? void 0 : _a.workspaceDir;
|
|
679
|
+
if (shared !== undefined) {
|
|
680
|
+
return shared;
|
|
681
|
+
}
|
|
682
|
+
const agentCwd = (_b = this.project.agent.local) === null || _b === void 0 ? void 0 : _b.cwd;
|
|
678
683
|
if (agentCwd !== undefined) {
|
|
679
684
|
return join(agentCwd, record.sessionId);
|
|
680
685
|
}
|
|
681
686
|
return this.sessions.workspaceDir(record.sessionId);
|
|
682
687
|
}
|
|
683
688
|
/**
|
|
684
|
-
*
|
|
685
|
-
*
|
|
686
|
-
*
|
|
689
|
+
* True when the harness cwd is a directory the session does not own — a
|
|
690
|
+
* per-send override (e.g. a PR worktree) or a workspace shared by every
|
|
691
|
+
* session. Agent scaffold has to stay out of those, so it lands in the
|
|
692
|
+
* durable session workspace and the instructions travel inline instead.
|
|
687
693
|
*/
|
|
694
|
+
hasBorrowedWorkspace(record) {
|
|
695
|
+
var _a;
|
|
696
|
+
return (record.workspaceOverride !== undefined ||
|
|
697
|
+
((_a = this.project.agent.local) === null || _a === void 0 ? void 0 : _a.workspaceDir) !== undefined);
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Resolve the shared harness workspace during startup, so the first session
|
|
701
|
+
* is not the one that waits for it. Only possible with
|
|
702
|
+
* `local.workspaceDir`: every other layout gives a session its own cwd,
|
|
703
|
+
* which is unknowable until that session exists.
|
|
704
|
+
*
|
|
705
|
+
* Best effort — warming is an optimization, and a turn rebuilds on its own.
|
|
706
|
+
*/
|
|
707
|
+
prewarmSharedWorkspace() {
|
|
708
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
709
|
+
var _a, _b;
|
|
710
|
+
const agent = this.project.agent;
|
|
711
|
+
const workspaceDir = (_a = agent.local) === null || _a === void 0 ? void 0 : _a.workspaceDir;
|
|
712
|
+
if (workspaceDir === undefined ||
|
|
713
|
+
agent.runtime !== "local" ||
|
|
714
|
+
this.runner.prewarm === undefined) {
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
const startedAt = Date.now();
|
|
718
|
+
try {
|
|
719
|
+
const outcome = yield this.runner.prewarm(Object.assign({ workspaceDir, runnerStateDir: join(this.stateRoot, "runner"), sandbox: ((_b = agent.local) === null || _b === void 0 ? void 0 : _b.sandbox) === true, mcpServers: this.buildMcpServers("local"), subagents: buildRunnerSubagents(agent) }, (agent.model === undefined ? {} : { model: agent.model })));
|
|
720
|
+
// Report what happened rather than that the call returned: a runner
|
|
721
|
+
// that cannot warm resolves cleanly, and logging success there would
|
|
722
|
+
// tell an operator the workspace is hot when nothing touched it.
|
|
723
|
+
this.logger(outcome.warmed
|
|
724
|
+
? `[agentkit] warmed ${workspaceDir} in ${Date.now() - startedAt}ms`
|
|
725
|
+
: `[agentkit] did not warm ${workspaceDir}: ${outcome.reason}`);
|
|
726
|
+
}
|
|
727
|
+
catch (error) {
|
|
728
|
+
this.logger(`[agentkit] could not warm ${workspaceDir}: ${describeError(error)}`);
|
|
729
|
+
}
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
/** Directory that receives AGENTS.md / skills / agent tools. */
|
|
688
733
|
scaffoldDir(record) {
|
|
689
|
-
if (record
|
|
734
|
+
if (this.hasBorrowedWorkspace(record)) {
|
|
690
735
|
return this.sessions.workspaceDir(record.sessionId);
|
|
691
736
|
}
|
|
692
737
|
return this.harnessCwd(record);
|
|
@@ -752,12 +797,12 @@ export class SessionEngine {
|
|
|
752
797
|
});
|
|
753
798
|
}
|
|
754
799
|
// The harness only loads the scaffolded AGENTS.md when the session
|
|
755
|
-
// workspace is its own project root.
|
|
756
|
-
// (PR worktree) the scaffold lands elsewhere, and a
|
|
757
|
-
// inside a git repo re-roots harness rules at that
|
|
758
|
-
// cases deliver instructions inline on the first turn
|
|
800
|
+
// workspace is its own project root. When the harness cwd is borrowed
|
|
801
|
+
// (PR worktree, shared checkout) the scaffold lands elsewhere, and a
|
|
802
|
+
// workspace nested inside a git repo re-roots harness rules at that
|
|
803
|
+
// repo — in both cases deliver instructions inline on the first turn.
|
|
759
804
|
const instructionsInvisibleToHarness = isFirstTurn &&
|
|
760
|
-
(record
|
|
805
|
+
(this.hasBorrowedWorkspace(record) ||
|
|
761
806
|
(yield isNestedInGitRepo(harnessCwd)));
|
|
762
807
|
const request = this.buildTurnRequest(record, agent, turnId, message, isFirstTurn, instructionsInvisibleToHarness, emit, (update) => __awaiter(this, void 0, void 0, function* () {
|
|
763
808
|
mapper.handleUpdate(update);
|
|
@@ -833,7 +878,7 @@ export class SessionEngine {
|
|
|
833
878
|
});
|
|
834
879
|
}
|
|
835
880
|
buildTurnRequest(record, agent, turnId, prompt, isFirstTurn, instructionsInvisibleToHarness, emit, onUpdate, signal) {
|
|
836
|
-
var _a, _b;
|
|
881
|
+
var _a, _b, _c;
|
|
837
882
|
// Per-session cloud attach (channel/tool handoff) forces cloud runtime
|
|
838
883
|
// even when the agent defaults to local for chat server tools.
|
|
839
884
|
const runtime = resolveSessionRuntime({
|
|
@@ -865,17 +910,17 @@ export class SessionEngine {
|
|
|
865
910
|
}
|
|
866
911
|
else if (instructionsInvisibleToHarness) {
|
|
867
912
|
// Local workspace whose AGENTS.md the harness will not load. With a
|
|
868
|
-
//
|
|
869
|
-
//
|
|
870
|
-
//
|
|
871
|
-
const includeScripts = record
|
|
913
|
+
// borrowed harness cwd, agent tool scripts live only in the durable
|
|
914
|
+
// scaffold dir — embed bodies like cloud. Otherwise the catalog can
|
|
915
|
+
// reference on-disk paths under the harness cwd.
|
|
916
|
+
const includeScripts = this.hasBorrowedWorkspace(record);
|
|
872
917
|
const preamble = buildAgentsMdContent(agent, { includeScripts });
|
|
873
918
|
turnPrompt = `${preamble}\n\n${turnPrompt}`;
|
|
874
919
|
}
|
|
875
920
|
}
|
|
876
921
|
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ sessionId: record.sessionId }, (record.sdkAgentId === undefined
|
|
877
922
|
? {}
|
|
878
|
-
: { sdkAgentId: record.sdkAgentId })), { workspaceDir: this.harnessCwd(record), runnerStateDir: join(this.stateRoot, "runner"), prompt: turnPrompt, isFirstTurn }), (agent.model === undefined ? {} : { model: agent.model })), { runtime }), (mergedCloud === undefined ? {} : { cloud: mergedCloud })), { customTools: runtime === "local" ? this.buildCustomTools(record, turnId, emit) : {}, mcpServers: this.buildMcpServers(runtime), subagents: agent
|
|
923
|
+
: { sdkAgentId: record.sdkAgentId })), { workspaceDir: this.harnessCwd(record), sandbox: ((_c = this.project.agent.local) === null || _c === void 0 ? void 0 : _c.sandbox) === true, runnerStateDir: join(this.stateRoot, "runner"), prompt: turnPrompt, isFirstTurn }), (agent.model === undefined ? {} : { model: agent.model })), { runtime }), (mergedCloud === undefined ? {} : { cloud: mergedCloud })), { customTools: runtime === "local" ? this.buildCustomTools(record, turnId, emit) : {}, mcpServers: this.buildMcpServers(runtime), subagents: buildRunnerSubagents(agent), onUpdate,
|
|
879
924
|
signal,
|
|
880
925
|
// Local follow-ups expire any lingering active run so a preempted turn
|
|
881
926
|
// (or one orphaned by a crashed process) never blocks this send.
|
|
@@ -1578,7 +1623,16 @@ export class SessionEngine {
|
|
|
1578
1623
|
}
|
|
1579
1624
|
setContinuationToken(sessionId, token) {
|
|
1580
1625
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1626
|
+
var _a;
|
|
1627
|
+
const previous = yield this.sessions.get(sessionId);
|
|
1581
1628
|
yield this.updateRecord(sessionId, (current) => (Object.assign(Object.assign({}, current), { continuationKey: token })));
|
|
1629
|
+
// Keep armed reminders addressed at the conversation across rotation
|
|
1630
|
+
// (the built-in HTTP channel rotates after every follow-up).
|
|
1631
|
+
if ((previous === null || previous === void 0 ? void 0 : previous.continuationKey) != null &&
|
|
1632
|
+
token !== null &&
|
|
1633
|
+
token !== previous.continuationKey) {
|
|
1634
|
+
yield (_a = this.reminderApi) === null || _a === void 0 ? void 0 : _a.rekeyContinuation(previous.channelId, previous.continuationKey, token);
|
|
1635
|
+
}
|
|
1582
1636
|
});
|
|
1583
1637
|
}
|
|
1584
1638
|
isTurnRunning(sessionId) {
|
|
@@ -1897,6 +1951,14 @@ function subagentPrompt(subagent) {
|
|
|
1897
1951
|
}
|
|
1898
1952
|
return (_a = subagent.description) !== null && _a !== void 0 ? _a : subagent.name;
|
|
1899
1953
|
}
|
|
1954
|
+
/**
|
|
1955
|
+
* Subagents as the runner takes them. Shared by turns and by workspace
|
|
1956
|
+
* warming, which has to describe the same agent a turn would to reach the
|
|
1957
|
+
* executor that turn will run on.
|
|
1958
|
+
*/
|
|
1959
|
+
function buildRunnerSubagents(agent) {
|
|
1960
|
+
return agent.subagents.map((subagent) => { var _a; return (Object.assign({ name: subagent.name, description: (_a = subagent.description) !== null && _a !== void 0 ? _a : subagent.name, prompt: subagentPrompt(subagent) }, (subagent.model === undefined ? {} : { model: subagent.model }))); });
|
|
1961
|
+
}
|
|
1900
1962
|
function describeError(error) {
|
|
1901
1963
|
return error instanceof Error ? error.message : String(error);
|
|
1902
1964
|
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin client for the Agent Serve Slack provisioning API
|
|
3
|
+
* (`/internal/agent-serve/slack` on the Cursor backend — "Add to Slack").
|
|
4
|
+
* Pure request/response + error mapping — no console I/O, no polling
|
|
5
|
+
* loops; rendering lives in `cli-slack.ts`.
|
|
6
|
+
*
|
|
7
|
+
* Auth is the user API key sent directly as the bearer (the routes are
|
|
8
|
+
* `wrapUserApiRoute` on the backend); there is no token exchange here.
|
|
9
|
+
* The endpoints are gated on the `agent_serve_slack_provisioning` Statsig
|
|
10
|
+
* gate and 404 when it is off — the error mapping says so instead of
|
|
11
|
+
* "not found". Expected provisioning failures carry a stable JSON `code`
|
|
12
|
+
* (`not_connected`, `insufficient_scopes`, `manager_reauth_required`,
|
|
13
|
+
* `app_conflict`, `app_cap_reached`, `ratelimited`, `invalid_app_id`, …)
|
|
14
|
+
* which flows through on {@link SlackProvisionApiError.code} so the CLI
|
|
15
|
+
* can branch.
|
|
16
|
+
*/
|
|
17
|
+
export type SlackAppEnv = "dev" | "prod";
|
|
18
|
+
/** One manager-connected Slack workspace from `GET /status`. */
|
|
19
|
+
export interface SlackConnectedWorkspace {
|
|
20
|
+
slackTeamId: string;
|
|
21
|
+
/** Workspace name; absent on older backends, null on pre-existing rows. */
|
|
22
|
+
slackTeamName?: string | null;
|
|
23
|
+
slackUserId: string;
|
|
24
|
+
connectedAt: string;
|
|
25
|
+
}
|
|
26
|
+
/** One provisioned managed Slack app from `GET /status` (no token material). */
|
|
27
|
+
export interface SlackManagedAppInfo {
|
|
28
|
+
slackAppId: string;
|
|
29
|
+
slackTeamId: string;
|
|
30
|
+
slug: string;
|
|
31
|
+
env: string;
|
|
32
|
+
installStatus: string;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
updatedAt: string;
|
|
35
|
+
}
|
|
36
|
+
export interface SlackProvisionStatus {
|
|
37
|
+
workspaces: SlackConnectedWorkspace[];
|
|
38
|
+
apps: SlackManagedAppInfo[];
|
|
39
|
+
}
|
|
40
|
+
export type SlackAppIconContentType = "image/png" | "image/jpeg" | "image/gif";
|
|
41
|
+
/** Icon source for `setAppIcon`: an https image URL or a base64 file. */
|
|
42
|
+
export type SlackAppIconInput = {
|
|
43
|
+
url: string;
|
|
44
|
+
} | {
|
|
45
|
+
base64: string;
|
|
46
|
+
contentType: SlackAppIconContentType;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Outcome of `POST /apps`. Credentials are returned exactly once and never
|
|
50
|
+
* persisted server-side — the caller owns storing them. `appToken` can be
|
|
51
|
+
* absent when Slack's install response omitted the app-level token.
|
|
52
|
+
* `oauthAuthorizeUrl` is only minted on a fresh app create, so an update
|
|
53
|
+
* that lands in admin approval omits it.
|
|
54
|
+
*/
|
|
55
|
+
export type SlackAppProvisionResult = {
|
|
56
|
+
status: "installed";
|
|
57
|
+
appId: string;
|
|
58
|
+
botToken: string;
|
|
59
|
+
appToken?: string;
|
|
60
|
+
/** Present when the provision requested an icon (best-effort outcome). */
|
|
61
|
+
iconStatus?: "set" | "failed";
|
|
62
|
+
} | {
|
|
63
|
+
status: "pending_admin_approval";
|
|
64
|
+
appId: string;
|
|
65
|
+
oauthAuthorizeUrl?: string;
|
|
66
|
+
iconStatus?: "set" | "failed";
|
|
67
|
+
};
|
|
68
|
+
export declare class SlackProvisionApiError extends Error {
|
|
69
|
+
readonly status: number;
|
|
70
|
+
/** Stable backend error code (`not_connected`, `ratelimited`, …). */
|
|
71
|
+
readonly code?: string;
|
|
72
|
+
/** Seconds to wait before retrying (from 429 responses). */
|
|
73
|
+
readonly retryAfterSeconds?: number;
|
|
74
|
+
/** Drifted manifest paths (from `manifest_drift` 409 bodies). */
|
|
75
|
+
readonly changedPaths?: string[];
|
|
76
|
+
constructor(message: string, options: {
|
|
77
|
+
status: number;
|
|
78
|
+
code?: string;
|
|
79
|
+
retryAfterSeconds?: number;
|
|
80
|
+
changedPaths?: string[];
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
export interface AgentServeSlackClientOptions {
|
|
84
|
+
backendUrl: string;
|
|
85
|
+
apiKey: string;
|
|
86
|
+
/** Test seam; defaults to global fetch. */
|
|
87
|
+
fetchImpl?: typeof fetch;
|
|
88
|
+
}
|
|
89
|
+
export declare class AgentServeSlackClient {
|
|
90
|
+
private readonly backendUrl;
|
|
91
|
+
private readonly apiKey;
|
|
92
|
+
private readonly fetchImpl;
|
|
93
|
+
constructor(options: AgentServeSlackClientOptions);
|
|
94
|
+
/** Manager-connected workspaces + the managed-app inventory. */
|
|
95
|
+
status(teamId: number): Promise<SlackProvisionStatus>;
|
|
96
|
+
/**
|
|
97
|
+
* Mint the browser consent URL for the Slack manager grant. After the
|
|
98
|
+
* user approves it, the workspace shows up in {@link status}.
|
|
99
|
+
*/
|
|
100
|
+
connect(teamId: number): Promise<string>;
|
|
101
|
+
/**
|
|
102
|
+
* Provision (create or update) and install one managed Slack app for
|
|
103
|
+
* (slackTeamId, slug, env). Expected failures throw
|
|
104
|
+
* {@link SlackProvisionApiError} with a stable `code`.
|
|
105
|
+
*/
|
|
106
|
+
provisionApp(args: {
|
|
107
|
+
teamId: number;
|
|
108
|
+
slackTeamId: string;
|
|
109
|
+
slug: string;
|
|
110
|
+
env: SlackAppEnv;
|
|
111
|
+
/** Full Slack app manifest JSON string. */
|
|
112
|
+
manifest: string;
|
|
113
|
+
/** Icon URL, applied best-effort by the backend after the install. */
|
|
114
|
+
icon?: {
|
|
115
|
+
url: string;
|
|
116
|
+
};
|
|
117
|
+
/** Overwrite manifest edits made in Slack (skips the drift check). */
|
|
118
|
+
force?: boolean;
|
|
119
|
+
}): Promise<SlackAppProvisionResult>;
|
|
120
|
+
/** Delete the Slack app and its inventory row. */
|
|
121
|
+
deleteApp(args: {
|
|
122
|
+
teamId: number;
|
|
123
|
+
slackAppId: string;
|
|
124
|
+
}): Promise<void>;
|
|
125
|
+
/** Set the app's icon: an https image URL or a base64 png/jpeg/gif ≤512KB. */
|
|
126
|
+
setAppIcon(args: {
|
|
127
|
+
teamId: number;
|
|
128
|
+
slackAppId: string;
|
|
129
|
+
icon: SlackAppIconInput;
|
|
130
|
+
}): Promise<void>;
|
|
131
|
+
private request;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=slack-provision-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slack-provision-client.d.ts","sourceRoot":"","sources":["../../src/internal/slack-provision-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,MAAM,CAAC;AAEzC,gEAAgE;AAChE,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,2EAA2E;IAC3E,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,gFAAgF;AAChF,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,uBAAuB,EAAE,CAAC;IACtC,IAAI,EAAE,mBAAmB,EAAE,CAAC;CAC7B;AAED,MAAM,MAAM,uBAAuB,GAAG,WAAW,GAAG,YAAY,GAAG,WAAW,CAAC;AAE/E,yEAAyE;AACzE,MAAM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C,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;IAEzC,YAAY,OAAO,EAAE,4BAA4B,EAMhD;IAED,gEAAgE;IAC1D,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAO1D;IAED;;;OAGG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQ7C;IAED;;;;OAIG;IACG,YAAY,CAAC,IAAI,EAAE;QACvB,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,WAAW,CAAC;QACjB,2CAA2C;QAC3C,QAAQ,EAAE,MAAM,CAAC;QACjB,sEAAsE;QACtE,IAAI,CAAC,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC;QACvB,sEAAsE;QACtE,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAgBnC;IAED,kDAAkD;IAC5C,SAAS,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAO3E;IAED,8EAA8E;IACxE,UAAU,CAAC,IAAI,EAAE;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,iBAAiB,CAAC;KACzB,GAAG,OAAO,CAAC,IAAI,CAAC,CAQhB;YAEa,OAAO;CA0CtB"}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin client for the Agent Serve Slack provisioning API
|
|
3
|
+
* (`/internal/agent-serve/slack` on the Cursor backend — "Add to Slack").
|
|
4
|
+
* Pure request/response + error mapping — no console I/O, no polling
|
|
5
|
+
* loops; rendering lives in `cli-slack.ts`.
|
|
6
|
+
*
|
|
7
|
+
* Auth is the user API key sent directly as the bearer (the routes are
|
|
8
|
+
* `wrapUserApiRoute` on the backend); there is no token exchange here.
|
|
9
|
+
* The endpoints are gated on the `agent_serve_slack_provisioning` Statsig
|
|
10
|
+
* gate and 404 when it is off — the error mapping says so instead of
|
|
11
|
+
* "not found". Expected provisioning failures carry a stable JSON `code`
|
|
12
|
+
* (`not_connected`, `insufficient_scopes`, `manager_reauth_required`,
|
|
13
|
+
* `app_conflict`, `app_cap_reached`, `ratelimited`, `invalid_app_id`, …)
|
|
14
|
+
* which flows through on {@link SlackProvisionApiError.code} so the CLI
|
|
15
|
+
* can branch.
|
|
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 { z } from "zod";
|
|
27
|
+
export class SlackProvisionApiError extends Error {
|
|
28
|
+
constructor(message, options) {
|
|
29
|
+
super(message);
|
|
30
|
+
this.name = "SlackProvisionApiError";
|
|
31
|
+
this.status = options.status;
|
|
32
|
+
this.code = options.code;
|
|
33
|
+
this.retryAfterSeconds = options.retryAfterSeconds;
|
|
34
|
+
this.changedPaths = options.changedPaths;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// ============================================================================
|
|
38
|
+
// Response shapes (backend agentServeSlackEndpoints route bodies).
|
|
39
|
+
// Interfaces are hand-written (the package compiles with
|
|
40
|
+
// --isolatedDeclarations, so exported types cannot be z.infer of an
|
|
41
|
+
// unannotated schema); the zod schemas below stay module-internal.
|
|
42
|
+
// ============================================================================
|
|
43
|
+
// All response schemas are `.passthrough()` so unknown fields from a newer
|
|
44
|
+
// backend flow through untouched instead of breaking the parse.
|
|
45
|
+
const statusResponseSchema = z
|
|
46
|
+
.object({
|
|
47
|
+
workspaces: z.array(z
|
|
48
|
+
.object({
|
|
49
|
+
slackTeamId: z.string(),
|
|
50
|
+
slackTeamName: z.string().nullish(),
|
|
51
|
+
slackUserId: z.string(),
|
|
52
|
+
connectedAt: z.string(),
|
|
53
|
+
})
|
|
54
|
+
.passthrough()),
|
|
55
|
+
apps: z.array(z
|
|
56
|
+
.object({
|
|
57
|
+
slackAppId: z.string(),
|
|
58
|
+
slackTeamId: z.string(),
|
|
59
|
+
slug: z.string(),
|
|
60
|
+
env: z.string(),
|
|
61
|
+
installStatus: z.string(),
|
|
62
|
+
createdAt: z.string(),
|
|
63
|
+
updatedAt: z.string(),
|
|
64
|
+
})
|
|
65
|
+
.passthrough()),
|
|
66
|
+
})
|
|
67
|
+
.passthrough();
|
|
68
|
+
const connectResponseSchema = z
|
|
69
|
+
.object({
|
|
70
|
+
url: z.string().min(1),
|
|
71
|
+
})
|
|
72
|
+
.passthrough();
|
|
73
|
+
const provisionResponseSchema = z.discriminatedUnion("status", [
|
|
74
|
+
z
|
|
75
|
+
.object({
|
|
76
|
+
status: z.literal("installed"),
|
|
77
|
+
appId: z.string(),
|
|
78
|
+
botToken: z.string(),
|
|
79
|
+
appToken: z.string().optional(),
|
|
80
|
+
iconStatus: z.enum(["set", "failed"]).optional(),
|
|
81
|
+
})
|
|
82
|
+
.passthrough(),
|
|
83
|
+
z
|
|
84
|
+
.object({
|
|
85
|
+
status: z.literal("pending_admin_approval"),
|
|
86
|
+
appId: z.string(),
|
|
87
|
+
oauthAuthorizeUrl: z.string().optional(),
|
|
88
|
+
iconStatus: z.enum(["set", "failed"]).optional(),
|
|
89
|
+
})
|
|
90
|
+
.passthrough(),
|
|
91
|
+
]);
|
|
92
|
+
const deleteResponseSchema = z
|
|
93
|
+
.object({
|
|
94
|
+
deleted: z.boolean(),
|
|
95
|
+
})
|
|
96
|
+
.passthrough();
|
|
97
|
+
const setIconResponseSchema = z
|
|
98
|
+
.object({
|
|
99
|
+
ok: z.boolean(),
|
|
100
|
+
})
|
|
101
|
+
.passthrough();
|
|
102
|
+
export class AgentServeSlackClient {
|
|
103
|
+
constructor(options) {
|
|
104
|
+
var _a;
|
|
105
|
+
this.backendUrl = options.backendUrl.endsWith("/")
|
|
106
|
+
? options.backendUrl.slice(0, -1)
|
|
107
|
+
: options.backendUrl;
|
|
108
|
+
this.apiKey = options.apiKey;
|
|
109
|
+
this.fetchImpl = (_a = options.fetchImpl) !== null && _a !== void 0 ? _a : fetch;
|
|
110
|
+
}
|
|
111
|
+
/** Manager-connected workspaces + the managed-app inventory. */
|
|
112
|
+
status(teamId) {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
const raw = yield this.request({
|
|
115
|
+
method: "GET",
|
|
116
|
+
path: `/internal/agent-serve/slack/status?teamId=${teamId}`,
|
|
117
|
+
context: { verb: "read Slack provisioning status" },
|
|
118
|
+
});
|
|
119
|
+
return statusResponseSchema.parse(raw);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Mint the browser consent URL for the Slack manager grant. After the
|
|
124
|
+
* user approves it, the workspace shows up in {@link status}.
|
|
125
|
+
*/
|
|
126
|
+
connect(teamId) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
const raw = yield this.request({
|
|
129
|
+
method: "POST",
|
|
130
|
+
path: "/internal/agent-serve/slack/connect",
|
|
131
|
+
body: { teamId },
|
|
132
|
+
context: { verb: "start the Slack workspace connect" },
|
|
133
|
+
});
|
|
134
|
+
return connectResponseSchema.parse(raw).url;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Provision (create or update) and install one managed Slack app for
|
|
139
|
+
* (slackTeamId, slug, env). Expected failures throw
|
|
140
|
+
* {@link SlackProvisionApiError} with a stable `code`.
|
|
141
|
+
*/
|
|
142
|
+
provisionApp(args) {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
+
const raw = yield this.request({
|
|
145
|
+
method: "POST",
|
|
146
|
+
path: "/internal/agent-serve/slack/apps",
|
|
147
|
+
body: {
|
|
148
|
+
teamId: args.teamId,
|
|
149
|
+
slackTeamId: args.slackTeamId,
|
|
150
|
+
slug: args.slug,
|
|
151
|
+
env: args.env,
|
|
152
|
+
manifest: args.manifest,
|
|
153
|
+
icon: args.icon,
|
|
154
|
+
force: args.force,
|
|
155
|
+
},
|
|
156
|
+
context: { verb: "provision the Slack app" },
|
|
157
|
+
});
|
|
158
|
+
return provisionResponseSchema.parse(raw);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/** Delete the Slack app and its inventory row. */
|
|
162
|
+
deleteApp(args) {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
const raw = yield this.request({
|
|
165
|
+
method: "DELETE",
|
|
166
|
+
path: `/internal/agent-serve/slack/apps/${encodeURIComponent(args.slackAppId)}?teamId=${args.teamId}`,
|
|
167
|
+
context: { verb: "delete the Slack app" },
|
|
168
|
+
});
|
|
169
|
+
deleteResponseSchema.parse(raw);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/** Set the app's icon: an https image URL or a base64 png/jpeg/gif ≤512KB. */
|
|
173
|
+
setAppIcon(args) {
|
|
174
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
+
const raw = yield this.request({
|
|
176
|
+
method: "POST",
|
|
177
|
+
path: `/internal/agent-serve/slack/apps/${encodeURIComponent(args.slackAppId)}/icon`,
|
|
178
|
+
body: { teamId: args.teamId, icon: args.icon },
|
|
179
|
+
context: { verb: "set the Slack app icon" },
|
|
180
|
+
});
|
|
181
|
+
setIconResponseSchema.parse(raw);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
request(args) {
|
|
185
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
+
const headers = {
|
|
187
|
+
accept: "application/json",
|
|
188
|
+
authorization: `Bearer ${this.apiKey}`,
|
|
189
|
+
};
|
|
190
|
+
if (args.body !== undefined) {
|
|
191
|
+
headers["content-type"] = "application/json";
|
|
192
|
+
}
|
|
193
|
+
let response;
|
|
194
|
+
try {
|
|
195
|
+
response = yield this.fetchImpl(`${this.backendUrl}${args.path}`, {
|
|
196
|
+
method: args.method,
|
|
197
|
+
headers,
|
|
198
|
+
body: args.body === undefined ? undefined : JSON.stringify(args.body),
|
|
199
|
+
signal: AbortSignal.timeout(60000),
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
throw new SlackProvisionApiError(`Could not reach the Cursor backend at ${this.backendUrl}: ${error instanceof Error ? error.message : String(error)}`, { status: 0 });
|
|
204
|
+
}
|
|
205
|
+
const text = yield response.text();
|
|
206
|
+
if (!response.ok) {
|
|
207
|
+
throw mapErrorResponse(response, text, args.context);
|
|
208
|
+
}
|
|
209
|
+
try {
|
|
210
|
+
return JSON.parse(text);
|
|
211
|
+
}
|
|
212
|
+
catch (_a) {
|
|
213
|
+
throw new SlackProvisionApiError(`The Cursor backend returned a non-JSON response to ${args.context.verb}.`, { status: response.status });
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// ============================================================================
|
|
219
|
+
// Error mapping (HTTP → actionable human messages, stable codes kept)
|
|
220
|
+
// ============================================================================
|
|
221
|
+
function parseErrorBody(bodyText) {
|
|
222
|
+
let parsed;
|
|
223
|
+
try {
|
|
224
|
+
parsed = JSON.parse(bodyText);
|
|
225
|
+
}
|
|
226
|
+
catch (_a) {
|
|
227
|
+
return {};
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
error: typeof parsed.error === "string" && parsed.error !== ""
|
|
231
|
+
? parsed.error
|
|
232
|
+
: undefined,
|
|
233
|
+
code: typeof parsed.code === "string" && parsed.code !== ""
|
|
234
|
+
? parsed.code
|
|
235
|
+
: undefined,
|
|
236
|
+
retryAfterSeconds: typeof parsed.retryAfterSeconds === "number"
|
|
237
|
+
? parsed.retryAfterSeconds
|
|
238
|
+
: undefined,
|
|
239
|
+
changedPaths: Array.isArray(parsed.changedPaths) &&
|
|
240
|
+
parsed.changedPaths.every((path) => typeof path === "string")
|
|
241
|
+
? parsed.changedPaths
|
|
242
|
+
: undefined,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function mapErrorResponse(response, bodyText, context) {
|
|
246
|
+
var _a;
|
|
247
|
+
const body = parseErrorBody(bodyText);
|
|
248
|
+
const serverError = body.error;
|
|
249
|
+
switch (response.status) {
|
|
250
|
+
case 401:
|
|
251
|
+
return new SlackProvisionApiError("The Cursor API key was rejected. Run `agentkit login` again or update CURSOR_API_KEY.", { status: 401 });
|
|
252
|
+
case 403:
|
|
253
|
+
return new SlackProvisionApiError(`${serverError !== null && serverError !== void 0 ? serverError : "Not authorized"} — Slack provisioning needs team-admin permission and the cloud-agent entitlement on that team.`, { status: 403 });
|
|
254
|
+
case 404: {
|
|
255
|
+
// Fastify's route-not-found envelope means we hit the wrong host
|
|
256
|
+
// (api2 vs api.cursor.com), not a closed gate.
|
|
257
|
+
if (/Route \S+ not found/i.test(bodyText)) {
|
|
258
|
+
return new SlackProvisionApiError(`Agent Serve Slack API not found on this host — use the default api.cursor.com (unset CURSOR_API_BASE_URL), or point CURSOR_API_BASE_URL at a backend that mounts /internal/agent-serve/*.`, { status: 404 });
|
|
259
|
+
}
|
|
260
|
+
// The gate-off body is exactly {error: "Not found"}; anything else
|
|
261
|
+
// (e.g. "App not found" on delete) is a real not-found to surface.
|
|
262
|
+
if (serverError !== undefined && serverError !== "Not found") {
|
|
263
|
+
return new SlackProvisionApiError(serverError, {
|
|
264
|
+
status: 404,
|
|
265
|
+
code: body.code,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
return new SlackProvisionApiError(`Not found — Cursor's "Add to Slack" provisioning (the agent_serve_slack_provisioning feature gate) is not enabled for this account yet.`, { status: 404 });
|
|
269
|
+
}
|
|
270
|
+
case 429: {
|
|
271
|
+
const retryAfterHeader = response.headers.get("retry-after");
|
|
272
|
+
const retryAfterSeconds = retryAfterHeader !== null && /^\d+$/.test(retryAfterHeader)
|
|
273
|
+
? Number(retryAfterHeader)
|
|
274
|
+
: body.retryAfterSeconds;
|
|
275
|
+
return new SlackProvisionApiError(`${serverError !== null && serverError !== void 0 ? serverError : "Rate limited"}${retryAfterSeconds === undefined
|
|
276
|
+
? ""
|
|
277
|
+
: ` — retry in ${retryAfterSeconds}s`}`, { status: 429, code: (_a = body.code) !== null && _a !== void 0 ? _a : "ratelimited", retryAfterSeconds });
|
|
278
|
+
}
|
|
279
|
+
default:
|
|
280
|
+
return new SlackProvisionApiError(serverError !== null && serverError !== void 0 ? serverError : `The ${context.verb} request failed (${response.status}): ${bodyText.slice(0, 300) || "(empty body)"}`, {
|
|
281
|
+
status: response.status,
|
|
282
|
+
code: body.code,
|
|
283
|
+
changedPaths: body.changedPaths,
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
}
|
|
Binary file
|