@cursor/july 0.1.26 → 0.1.28
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/dist/ab.d.ts +6 -0
- package/dist/ab.d.ts.map +1 -1
- package/dist/ab.js +1 -0
- package/dist/artifacts.d.ts +34 -0
- package/dist/artifacts.d.ts.map +1 -0
- package/dist/artifacts.js +57 -0
- package/dist/bin/agent-serve.js +43 -12
- package/dist/channels/github/github-channel.d.ts +1 -1
- package/dist/channels/github/github-channel.d.ts.map +1 -1
- package/dist/channels/github/github-channel.js +14 -1
- package/dist/channels/github/types.d.ts +6 -1
- package/dist/channels/github/types.d.ts.map +1 -1
- package/dist/channels/slack/api.d.ts +2 -1
- package/dist/channels/slack/api.d.ts.map +1 -1
- package/dist/channels/slack/api.js +1 -0
- package/dist/channels/slack/auth.d.ts +13 -13
- package/dist/channels/slack/auth.d.ts.map +1 -1
- package/dist/channels/slack/auth.js +19 -10
- package/dist/channels/slack/cursor-account.d.ts +2 -1
- package/dist/channels/slack/cursor-account.d.ts.map +1 -1
- package/dist/channels/slack/cursor-account.js +3 -1
- package/dist/channels/slack/defaults.d.ts +7 -4
- package/dist/channels/slack/defaults.d.ts.map +1 -1
- package/dist/channels/slack/defaults.js +14 -4
- package/dist/channels/slack/dispatch.d.ts +10 -1
- package/dist/channels/slack/dispatch.d.ts.map +1 -1
- package/dist/channels/slack/dispatch.js +59 -21
- package/dist/channels/slack/external-policy.d.ts +27 -0
- package/dist/channels/slack/external-policy.d.ts.map +1 -0
- package/dist/channels/slack/external-policy.js +53 -0
- package/dist/channels/slack/index.d.ts +1 -0
- package/dist/channels/slack/index.d.ts.map +1 -1
- package/dist/channels/slack/index.js +1 -0
- package/dist/channels/slack/interactive.d.ts +8 -1
- package/dist/channels/slack/interactive.d.ts.map +1 -1
- package/dist/channels/slack/interactive.js +43 -15
- package/dist/channels/slack/slack-channel.d.ts.map +1 -1
- package/dist/channels/slack/slack-channel.js +22 -8
- package/dist/channels/slack/types.d.ts +16 -1
- package/dist/channels/slack/types.d.ts.map +1 -1
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +3 -3
- package/dist/docs/assets/{app.DYcC9FY-.js → app.CqjrYaT2.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.VWQoPFJ1.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.o4N_knTV.js → VPLocalSearchBox.ag-MwUel.js} +1 -1
- package/dist/docs/assets/chunks/{theme.DQ-njyo0.js → theme.BS-DJWat.js} +2 -2
- package/dist/docs/assets/{guides_slack.md.D_xFKlnF.js → guides_slack.md.CjmJSvZS.js} +8 -4
- package/dist/docs/assets/guides_slack.md.CjmJSvZS.lean.js +1 -0
- package/dist/docs/assets/guides_webhooks.md.wSOYas3X.js +183 -0
- package/dist/docs/assets/{guides_webhooks.md.B1EswtUu.lean.js → guides_webhooks.md.wSOYas3X.lean.js} +1 -1
- package/dist/docs/assets/{index.md.Dfv5ic9t.js → index.md.CH_s5uZe.js} +1 -1
- package/dist/docs/assets/{reference_channels.md.DdmiKgqf.js → reference_channels.md.CDhTRfUz.js} +2 -2
- package/dist/docs/assets/{reference_channels.md.DdmiKgqf.lean.js → reference_channels.md.CDhTRfUz.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 +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 +11 -7
- package/dist/docs/guides/webhooks.html +138 -5
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +3 -3
- package/dist/docs/index.html +5 -5
- package/dist/docs/quickstart.html +3 -3
- package/dist/docs/reference/agent-config.html +3 -3
- package/dist/docs/reference/channels.html +5 -5
- package/dist/docs/reference/cli.html +3 -3
- package/dist/docs/reference/connections.html +3 -3
- 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 +10 -1
- package/dist/evals/assertions.d.ts.map +1 -1
- package/dist/evals/assertions.js +12 -0
- package/dist/evals.d.ts +1 -1
- package/dist/evals.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/internal/ab-fold.d.ts.map +1 -1
- package/dist/internal/ab-fold.js +4 -0
- package/dist/internal/ab-snapshot.d.ts.map +1 -1
- package/dist/internal/ab-snapshot.js +1 -0
- package/dist/internal/artifacts-store.d.ts +45 -0
- package/dist/internal/artifacts-store.d.ts.map +1 -0
- package/dist/internal/artifacts-store.js +250 -0
- package/dist/internal/builtin-tools/artifacts.d.ts +10 -0
- package/dist/internal/builtin-tools/artifacts.d.ts.map +1 -0
- package/dist/internal/builtin-tools/artifacts.js +73 -0
- package/dist/internal/builtin-tools/index.d.ts +8 -1
- package/dist/internal/builtin-tools/index.d.ts.map +1 -1
- package/dist/internal/builtin-tools/index.js +15 -0
- package/dist/internal/cli-ax.d.ts +19 -0
- package/dist/internal/cli-ax.d.ts.map +1 -1
- package/dist/internal/cli-ax.js +196 -57
- package/dist/internal/cli-slack.d.ts.map +1 -1
- package/dist/internal/cli-slack.js +14 -6
- package/dist/internal/cursor-slack-relay.d.ts +2 -0
- package/dist/internal/cursor-slack-relay.d.ts.map +1 -1
- package/dist/internal/cursor-slack-relay.js +1 -0
- package/dist/internal/deploy-client.d.ts +2 -0
- package/dist/internal/deploy-client.d.ts.map +1 -1
- package/dist/internal/deploy-client.js +1 -0
- package/dist/internal/discovery.d.ts.map +1 -1
- package/dist/internal/discovery.js +91 -3
- package/dist/internal/distribution.d.ts.map +1 -1
- package/dist/internal/distribution.js +1 -0
- package/dist/internal/model-pricing.d.ts +49 -0
- package/dist/internal/model-pricing.d.ts.map +1 -0
- package/dist/internal/model-pricing.js +377 -0
- package/dist/internal/reminder-runner.d.ts.map +1 -1
- package/dist/internal/reminder-runner.js +1 -0
- package/dist/internal/schedule-runner.d.ts.map +1 -1
- package/dist/internal/schedule-runner.js +1 -0
- package/dist/internal/sdk-runner.d.ts.map +1 -1
- package/dist/internal/sdk-runner.js +9 -1
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +49 -5
- package/dist/internal/session-cost.d.ts +49 -0
- package/dist/internal/session-cost.d.ts.map +1 -0
- package/dist/internal/session-cost.js +175 -0
- package/dist/internal/session-engine.d.ts +35 -1
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +128 -7
- package/dist/internal/storage-coordinator.d.ts +15 -0
- package/dist/internal/storage-coordinator.d.ts.map +1 -1
- package/dist/internal/storage-coordinator.js +52 -0
- package/dist/internal/trajectory.d.ts +9 -1
- package/dist/internal/trajectory.d.ts.map +1 -1
- package/dist/internal/trajectory.js +32 -5
- package/dist/playground/assets/index-Bul1WfrB.css +1 -0
- package/dist/playground/assets/index-CkN74U_L.js +87 -0
- package/dist/playground/index.html +2 -2
- package/dist/storage.d.ts +4 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +4 -0
- package/dist/types.d.ts +164 -1
- package/dist/types.d.ts.map +1 -1
- package/docs/README.md +1 -0
- package/docs/guides/slack.md +32 -7
- package/docs/guides/webhooks.md +183 -0
- package/docs/reference/channels.md +2 -1
- package/package.json +26 -26
- package/skills/setup-slack/SKILL.md +3 -0
- package/src/ab.ts +7 -0
- package/src/bin/agent-serve.ts +42 -5
- package/src/channels/slack/auth.ts +29 -22
- package/src/channels/slack/cursor-account.ts +2 -0
- package/src/channels/slack/defaults.ts +24 -4
- package/src/channels/slack/dispatch.ts +42 -1
- package/src/channels/slack/external-policy.ts +62 -0
- package/src/channels/slack/index.ts +1 -0
- package/src/channels/slack/interactive.ts +42 -10
- package/src/channels/slack/slack-channel.ts +20 -3
- package/src/channels/slack/types.ts +12 -0
- package/src/internal/ab-fold.ts +4 -0
- package/src/internal/ab-snapshot.ts +1 -0
- package/src/internal/cli-ax.ts +205 -34
- package/src/internal/cursor-slack-relay.ts +3 -0
- package/src/internal/deploy-client.ts +3 -0
- package/src/internal/discovery.ts +8 -1
- package/src/internal/model-pricing.ts +426 -0
- package/src/internal/sdk-runner.ts +10 -2
- package/src/internal/server.ts +9 -5
- package/src/internal/session-cost.ts +231 -0
- package/src/internal/session-engine.ts +28 -0
- package/src/internal/trajectory.ts +45 -3
- package/src/types.ts +24 -1
- package/dist/channels/github/instrument.d.ts +0 -20
- package/dist/channels/github/instrument.d.ts.map +0 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.BQTzJjR_.js +0 -1
- package/dist/docs/assets/guides_slack.md.D_xFKlnF.lean.js +0 -1
- package/dist/docs/assets/guides_webhooks.md.B1EswtUu.js +0 -50
- package/dist/internal/json-dir-store.d.ts +0 -32
- package/dist/internal/json-dir-store.d.ts.map +0 -1
- package/dist/internal/json-dir-store.js +0 -100
- package/dist/playground/assets/index-CjOQ4hN9.css +0 -1
- package/dist/playground/assets/index-DqXdAFGa.js +0 -85
- package/src/bin/agent-serve.version.test.ts +0 -64
- package/src/channels/github/api.test.ts +0 -64
- package/src/channels/github/auth.test.ts +0 -105
- package/src/channels/github/cursor-account.test.ts +0 -204
- package/src/channels/github/forward.test.ts +0 -457
- package/src/channels/github/github.test.ts +0 -985
- package/src/channels/github/replay.test.ts +0 -179
- package/src/channels/slack/api.post-message.test.ts +0 -148
- package/src/channels/slack/approvals.test.ts +0 -328
- package/src/channels/slack/block-actions.test.ts +0 -469
- package/src/channels/slack/bot-mentions.test.ts +0 -267
- package/src/channels/slack/channel-watch.test.ts +0 -363
- package/src/channels/slack/cursor-account.test.ts +0 -301
- package/src/channels/slack/defaults.final-post.test.ts +0 -182
- package/src/channels/slack/dispatch.test.ts +0 -875
- package/src/channels/slack/eval-directive.test.ts +0 -273
- package/src/channels/slack/message-body.test.ts +0 -54
- package/src/channels/slack/nudge-store.test.ts +0 -143
- package/src/channels/slack/slack.test.ts +0 -391
- package/src/channels/slack/stop.test.ts +0 -23
- package/src/channels/slack/thread-context.test.ts +0 -202
- package/src/evals/assertions.test.ts +0 -617
- package/src/evals/expect.test.ts +0 -144
- package/src/evals/judge.test.ts +0 -181
- package/src/evals/loaders.test.ts +0 -132
- package/src/evals/matchers.test.ts +0 -95
- package/src/evals/reporters.test.ts +0 -303
- package/src/evals/run-facts.test.ts +0 -259
- package/src/internal/ab-snapshot.test.ts +0 -325
- package/src/internal/approval-gate.test.ts +0 -49
- package/src/internal/approvals.integration.test.ts +0 -383
- package/src/internal/artifacts-store.test.ts +0 -283
- package/src/internal/authored-loaders.test.ts +0 -31
- package/src/internal/builtin-tools/artifacts.test.ts +0 -247
- package/src/internal/builtin-tools/reminders.test.ts +0 -201
- package/src/internal/channel-route-schema.test.ts +0 -294
- package/src/internal/chat-attach.test.ts +0 -262
- package/src/internal/cli-deploy.test.ts +0 -1991
- package/src/internal/cli-docs.test.ts +0 -161
- package/src/internal/cli-mcp.test.ts +0 -789
- package/src/internal/cli-skills.test.ts +0 -133
- package/src/internal/cli-slack.test.ts +0 -1654
- package/src/internal/cloud-merge.test.ts +0 -74
- package/src/internal/cron.test.ts +0 -22
- package/src/internal/cursor/account-mcp.test.ts +0 -807
- package/src/internal/cursor/backend-client.test.ts +0 -591
- package/src/internal/cursor/credentials.test.ts +0 -351
- package/src/internal/cursor/github-credentials.test.ts +0 -136
- package/src/internal/cursor-account-mcp-auth.test.ts +0 -310
- package/src/internal/cursor-account.integration.test.ts +0 -441
- package/src/internal/cursor-event-relay.test.ts +0 -746
- package/src/internal/cursor-github-credentials.integration.test.ts +0 -271
- package/src/internal/cursor-slack-relay.test.ts +0 -525
- package/src/internal/deploy-source.test.ts +0 -111
- package/src/internal/discovery.artifact-tool.test.ts +0 -136
- package/src/internal/discovery.artifacts.test.ts +0 -119
- package/src/internal/discovery.builtin-tools.test.ts +0 -94
- package/src/internal/discovery.concurrency.test.ts +0 -60
- package/src/internal/discovery.cursor-account.test.ts +0 -133
- package/src/internal/discovery.cwd.test.ts +0 -83
- package/src/internal/discovery.hosting.test.ts +0 -80
- package/src/internal/discovery.identity.test.ts +0 -44
- package/src/internal/docs-site.test.ts +0 -66
- package/src/internal/duration.test.ts +0 -29
- package/src/internal/eval-judge-model.test.ts +0 -187
- package/src/internal/eval-run-store.cancel.test.ts +0 -142
- package/src/internal/eval-run-store.storage.test.ts +0 -211
- package/src/internal/eval-runner.http.test.ts +0 -403
- package/src/internal/eval-runner.run.test.ts +0 -928
- package/src/internal/evals-client.test.ts +0 -307
- package/src/internal/event-mapper.test.ts +0 -243
- package/src/internal/github-fanout.test.ts +0 -213
- package/src/internal/handleAgentServeTrigger.test.ts +0 -185
- package/src/internal/host-kv.test.ts +0 -82
- package/src/internal/host-platforms.test.ts +0 -126
- package/src/internal/http-channel.test.ts +0 -402
- package/src/internal/init-project.test.ts +0 -270
- package/src/internal/install-cursor-skills.test.ts +0 -262
- package/src/internal/local-env.test.ts +0 -120
- package/src/internal/log-ring.test.ts +0 -31
- package/src/internal/logs-client.test.ts +0 -350
- package/src/internal/mcp-endpoint.test.ts +0 -436
- package/src/internal/mcp-host.test.ts +0 -298
- package/src/internal/mcp-oauth.test.ts +0 -148
- package/src/internal/net.test.ts +0 -17
- package/src/internal/peer-connections.test.ts +0 -128
- package/src/internal/peer-mcp.integration.test.ts +0 -289
- package/src/internal/playground/toolchain.test.ts +0 -53
- package/src/internal/playground-cli.test.ts +0 -187
- package/src/internal/playground-proxy.test.ts +0 -376
- package/src/internal/prompt-context.integration.test.ts +0 -232
- package/src/internal/prompt-context.test.ts +0 -127
- package/src/internal/reminder-runner.test.ts +0 -432
- package/src/internal/reminder-store.test.ts +0 -53
- package/src/internal/request-headers.test.ts +0 -27
- package/src/internal/resolve-prod-target.test.ts +0 -787
- package/src/internal/resolved-connections.test.ts +0 -295
- package/src/internal/router.test.ts +0 -57
- package/src/internal/sdk-runner.test.ts +0 -290
- package/src/internal/server.artifacts.test.ts +0 -334
- package/src/internal/session-engine.artifacts.test.ts +0 -293
- package/src/internal/session-engine.coalesce.test.ts +0 -169
- package/src/internal/session-engine.concurrency.test.ts +0 -250
- package/src/internal/session-engine.host-oauth-mcp.test.ts +0 -110
- package/src/internal/session-engine.interrupt.test.ts +0 -577
- package/src/internal/session-engine.storage.test.ts +0 -547
- package/src/internal/session-urls.test.ts +0 -28
- package/src/internal/sessions-client.test.ts +0 -518
- package/src/internal/storage-coordinator.test.ts +0 -517
- package/src/internal/tool-call.test.ts +0 -458
- package/src/internal/tool-result.test.ts +0 -52
- package/src/internal/trajectory.approvals.test.ts +0 -83
- package/src/internal/trajectory.subagents.test.ts +0 -198
- package/src/internal/turn-governor.test.ts +0 -137
- package/src/internal/update-check.test.ts +0 -485
- package/src/internal/workspace.test.ts +0 -207
- package/src/storage-backends/cursor-hosted.test.ts +0 -121
- /package/dist/docs/assets/{index.md.Dfv5ic9t.lean.js → index.md.CH_s5uZe.lean.js} +0 -0
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from "vitest";
|
|
2
|
-
import type { ArtifactsApi, HostContext, SendMessageFn } from "../../types.js";
|
|
3
|
-
import {
|
|
4
|
-
type CursorSlackEnvelope,
|
|
5
|
-
createPendingSlackApiTransport,
|
|
6
|
-
dispatchCursorSlackEnvelope,
|
|
7
|
-
getSlackCursorAccountRuntime,
|
|
8
|
-
} from "./cursor-account.js";
|
|
9
|
-
import { slackChannel } from "./slack-channel.js";
|
|
10
|
-
|
|
11
|
-
function envelope(
|
|
12
|
-
overrides: Partial<CursorSlackEnvelope> = {}
|
|
13
|
-
): CursorSlackEnvelope {
|
|
14
|
-
return {
|
|
15
|
-
eventName: "app_mention",
|
|
16
|
-
slackTeamId: "T0TEST",
|
|
17
|
-
channelId: "C0100",
|
|
18
|
-
channelType: "channel",
|
|
19
|
-
threadTs: "111.222",
|
|
20
|
-
messageTs: "111.222",
|
|
21
|
-
slackUserId: "U0AAA",
|
|
22
|
-
text: "benny hello <@U0BBB>",
|
|
23
|
-
agentName: "Benny",
|
|
24
|
-
consumerId: "consumer-1",
|
|
25
|
-
matchedBy: "name",
|
|
26
|
-
eventId: "Ev1",
|
|
27
|
-
receivedAtMs: Date.now(),
|
|
28
|
-
...overrides,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function fakeHost(): HostContext {
|
|
33
|
-
return {} as HostContext;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function testArtifacts(): ArtifactsApi {
|
|
37
|
-
return {
|
|
38
|
-
tag: async () => {
|
|
39
|
-
throw new Error("artifacts not configured in test");
|
|
40
|
-
},
|
|
41
|
-
list: async () => [],
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
describe("slackChannel({ cursorAccount: true })", () => {
|
|
46
|
-
it("registers a runtime with a pending transport and no Socket Mode routes", () => {
|
|
47
|
-
const definition = slackChannel({ cursorAccount: true });
|
|
48
|
-
const runtime = getSlackCursorAccountRuntime(definition);
|
|
49
|
-
expect(runtime).toBeDefined();
|
|
50
|
-
expect(runtime?.transport.kind).toBe("api-transport");
|
|
51
|
-
expect(definition.meta?.slackCursorAccount).toBe(true);
|
|
52
|
-
// Plain socket-mode channels register nothing.
|
|
53
|
-
expect(
|
|
54
|
-
getSlackCursorAccountRuntime(slackChannel({ envPrefix: "X" }))
|
|
55
|
-
).toBeUndefined();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("rejects mixing cursorAccount with a dedicated Slack app credentials", () => {
|
|
59
|
-
expect(() =>
|
|
60
|
-
slackChannel({ cursorAccount: true, envPrefix: "BUGBOT" })
|
|
61
|
-
).toThrow(/do not also set credentials\/envPrefix/);
|
|
62
|
-
expect(() =>
|
|
63
|
-
slackChannel({
|
|
64
|
-
cursorAccount: true,
|
|
65
|
-
credentials: { botToken: "xoxb-x" },
|
|
66
|
-
})
|
|
67
|
-
).toThrow(/do not also set credentials\/envPrefix/);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it("rejects channelPosts, toolApprovals, interactivity, and mention/DM off", () => {
|
|
71
|
-
expect(() =>
|
|
72
|
-
slackChannel({
|
|
73
|
-
cursorAccount: true,
|
|
74
|
-
engagement: { channelPosts: { allow: ["C0TEST"] } },
|
|
75
|
-
})
|
|
76
|
-
).toThrow(/channelPosts/);
|
|
77
|
-
// Approvals ride Socket Mode interactive envelopes; there is no relay
|
|
78
|
-
// tap over the Cursor connection, so both toggles reject at construction.
|
|
79
|
-
expect(() =>
|
|
80
|
-
slackChannel({
|
|
81
|
-
cursorAccount: true,
|
|
82
|
-
toolApprovals: true,
|
|
83
|
-
})
|
|
84
|
-
).toThrow(/toolApprovals/);
|
|
85
|
-
expect(() =>
|
|
86
|
-
slackChannel({
|
|
87
|
-
cursorAccount: true,
|
|
88
|
-
interactivity: true,
|
|
89
|
-
})
|
|
90
|
-
).toThrow(/interactivity/);
|
|
91
|
-
expect(() =>
|
|
92
|
-
slackChannel({
|
|
93
|
-
cursorAccount: true,
|
|
94
|
-
onBlockAction: () => null,
|
|
95
|
-
})
|
|
96
|
-
).toThrow(/onBlockAction/);
|
|
97
|
-
expect(() =>
|
|
98
|
-
slackChannel({
|
|
99
|
-
cursorAccount: true,
|
|
100
|
-
engagement: { mentions: false },
|
|
101
|
-
})
|
|
102
|
-
).toThrow(/mentions/);
|
|
103
|
-
expect(() =>
|
|
104
|
-
slackChannel({
|
|
105
|
-
cursorAccount: true,
|
|
106
|
-
engagement: { directMessages: false },
|
|
107
|
-
})
|
|
108
|
-
).toThrow(/directMessages/);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it("rejects agentName values that contain whitespace", () => {
|
|
112
|
-
expect(() =>
|
|
113
|
-
slackChannel({
|
|
114
|
-
cursorAccount: true,
|
|
115
|
-
// Cast: string literals with spaces are a type error; runtime still
|
|
116
|
-
// guards dynamic / widened strings.
|
|
117
|
-
agentName: "Approval Buddy" as string,
|
|
118
|
-
})
|
|
119
|
-
).toThrow(/single token with no whitespace/);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it("calls through the transport once bound, soft-failing before", async () => {
|
|
123
|
-
const transport = createPendingSlackApiTransport();
|
|
124
|
-
expect(await transport.call("chat.postMessage", {})).toEqual({
|
|
125
|
-
ok: false,
|
|
126
|
-
error: "cursor_slack_relay_not_started",
|
|
127
|
-
});
|
|
128
|
-
const calls: Array<{ method: string; args: Record<string, unknown> }> = [];
|
|
129
|
-
transport.bind(async (method, args) => {
|
|
130
|
-
calls.push({ method, args });
|
|
131
|
-
return { ok: true, ts: "1.2" };
|
|
132
|
-
});
|
|
133
|
-
expect(await transport.call("chat.postMessage", { channel: "C1" })).toEqual(
|
|
134
|
-
{ ok: true, ts: "1.2" }
|
|
135
|
-
);
|
|
136
|
-
expect(calls).toEqual([
|
|
137
|
-
{ method: "chat.postMessage", args: { channel: "C1" } },
|
|
138
|
-
]);
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
describe("dispatchCursorSlackEnvelope", () => {
|
|
143
|
-
function setup(options?: Parameters<typeof slackChannel>[0]) {
|
|
144
|
-
const definition = slackChannel({
|
|
145
|
-
cursorAccount: true,
|
|
146
|
-
agentName: "Benny",
|
|
147
|
-
...options,
|
|
148
|
-
});
|
|
149
|
-
const runtime = getSlackCursorAccountRuntime(definition);
|
|
150
|
-
if (runtime === undefined) {
|
|
151
|
-
throw new Error("runtime not registered");
|
|
152
|
-
}
|
|
153
|
-
const apiCalls: Array<{ method: string; args: Record<string, unknown> }> =
|
|
154
|
-
[];
|
|
155
|
-
runtime.transport.bind(async (method, args) => {
|
|
156
|
-
apiCalls.push({ method, args });
|
|
157
|
-
return { ok: true, ts: "999.111" };
|
|
158
|
-
});
|
|
159
|
-
const sent: Array<{ message: string; options: any }> = [];
|
|
160
|
-
const send: SendMessageFn = async (message, sendOptions) => {
|
|
161
|
-
sent.push({ message, options: sendOptions });
|
|
162
|
-
return {
|
|
163
|
-
id: "ses_1",
|
|
164
|
-
isNew: true,
|
|
165
|
-
channelId: "slack",
|
|
166
|
-
continuationToken: "next",
|
|
167
|
-
} as any;
|
|
168
|
-
};
|
|
169
|
-
return { runtime, apiCalls, sent, send };
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
it("dispatches a mention into a thread-keyed session and proxies thread setup calls", async () => {
|
|
173
|
-
const { runtime, apiCalls, sent, send } = setup();
|
|
174
|
-
await dispatchCursorSlackEnvelope({
|
|
175
|
-
runtime,
|
|
176
|
-
envelope: envelope(),
|
|
177
|
-
send,
|
|
178
|
-
host: fakeHost(),
|
|
179
|
-
artifacts: testArtifacts(),
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
expect(sent).toHaveLength(1);
|
|
183
|
-
expect(sent[0].options.continuationToken).toBe("C0100:111.222");
|
|
184
|
-
expect(sent[0].options.auth).toMatchObject({
|
|
185
|
-
authenticator: "slack",
|
|
186
|
-
principalId: "slack:T0TEST:C0100:111.222",
|
|
187
|
-
});
|
|
188
|
-
expect(sent[0].message).toContain("benny hello @U0BBB");
|
|
189
|
-
expect(sent[0].message).toContain("<slack_context>");
|
|
190
|
-
|
|
191
|
-
// Root message: title + typing go through the bound transport.
|
|
192
|
-
const methods = apiCalls.map((call) => call.method);
|
|
193
|
-
expect(methods).toContain("assistant.threads.setTitle");
|
|
194
|
-
expect(methods).toContain("assistant.threads.setStatus");
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
it("hands the artifacts facade to the mention handler binding", async () => {
|
|
198
|
-
const tags: Array<Parameters<ArtifactsApi["tag"]>[0]> = [];
|
|
199
|
-
const artifacts: ArtifactsApi = {
|
|
200
|
-
tag: async (input) => {
|
|
201
|
-
tags.push(input);
|
|
202
|
-
return {
|
|
203
|
-
id: `art_${tags.length}`,
|
|
204
|
-
kind: input.kind ?? "artifact",
|
|
205
|
-
key: input.key,
|
|
206
|
-
data: input.data,
|
|
207
|
-
source: "host",
|
|
208
|
-
createdAt: new Date().toISOString(),
|
|
209
|
-
updatedAt: new Date().toISOString(),
|
|
210
|
-
};
|
|
211
|
-
},
|
|
212
|
-
list: async () => [],
|
|
213
|
-
};
|
|
214
|
-
const { runtime, send } = setup({
|
|
215
|
-
onAppMention: async (ctx) => {
|
|
216
|
-
await ctx.artifacts.tag({ key: "from-relay", data: "r" });
|
|
217
|
-
return null;
|
|
218
|
-
},
|
|
219
|
-
});
|
|
220
|
-
await dispatchCursorSlackEnvelope({
|
|
221
|
-
runtime,
|
|
222
|
-
envelope: envelope(),
|
|
223
|
-
send,
|
|
224
|
-
host: fakeHost(),
|
|
225
|
-
artifacts,
|
|
226
|
-
});
|
|
227
|
-
expect(tags).toEqual([{ key: "from-relay", data: "r" }]);
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
it("routes DMs to the direct-message handler", async () => {
|
|
231
|
-
const kinds: string[] = [];
|
|
232
|
-
const { runtime, send } = setup({
|
|
233
|
-
onAppMention: (ctx, message) => {
|
|
234
|
-
kinds.push("mention");
|
|
235
|
-
return null;
|
|
236
|
-
},
|
|
237
|
-
onDirectMessage: (ctx, message) => {
|
|
238
|
-
kinds.push("dm");
|
|
239
|
-
return null;
|
|
240
|
-
},
|
|
241
|
-
});
|
|
242
|
-
await dispatchCursorSlackEnvelope({
|
|
243
|
-
runtime,
|
|
244
|
-
envelope: envelope({
|
|
245
|
-
channelType: "im",
|
|
246
|
-
channelId: "D0200",
|
|
247
|
-
eventId: "Ev2",
|
|
248
|
-
}),
|
|
249
|
-
send,
|
|
250
|
-
host: fakeHost(),
|
|
251
|
-
artifacts: testArtifacts(),
|
|
252
|
-
});
|
|
253
|
-
await dispatchCursorSlackEnvelope({
|
|
254
|
-
runtime,
|
|
255
|
-
envelope: envelope({ eventId: "Ev3" }),
|
|
256
|
-
send,
|
|
257
|
-
host: fakeHost(),
|
|
258
|
-
artifacts: testArtifacts(),
|
|
259
|
-
});
|
|
260
|
-
expect(kinds).toEqual(["dm", "mention"]);
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
it("dedupes by Slack event id", async () => {
|
|
264
|
-
const { runtime, sent, send } = setup();
|
|
265
|
-
await dispatchCursorSlackEnvelope({
|
|
266
|
-
runtime,
|
|
267
|
-
envelope: envelope({ eventId: "EvDup" }),
|
|
268
|
-
send,
|
|
269
|
-
host: fakeHost(),
|
|
270
|
-
artifacts: testArtifacts(),
|
|
271
|
-
});
|
|
272
|
-
await dispatchCursorSlackEnvelope({
|
|
273
|
-
runtime,
|
|
274
|
-
envelope: envelope({ eventId: "EvDup" }),
|
|
275
|
-
send,
|
|
276
|
-
host: fakeHost(),
|
|
277
|
-
artifacts: testArtifacts(),
|
|
278
|
-
});
|
|
279
|
-
expect(sent).toHaveLength(1);
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
it("claimed-thread replies dispatch as mention-kind follow-ups on the same session key", async () => {
|
|
283
|
-
const { runtime, sent, send } = setup();
|
|
284
|
-
await dispatchCursorSlackEnvelope({
|
|
285
|
-
runtime,
|
|
286
|
-
envelope: envelope({
|
|
287
|
-
eventName: "message",
|
|
288
|
-
matchedBy: "thread",
|
|
289
|
-
messageTs: "111.333",
|
|
290
|
-
text: "and tomorrow?",
|
|
291
|
-
eventId: "Ev4",
|
|
292
|
-
}),
|
|
293
|
-
send,
|
|
294
|
-
host: fakeHost(),
|
|
295
|
-
artifacts: testArtifacts(),
|
|
296
|
-
});
|
|
297
|
-
expect(sent).toHaveLength(1);
|
|
298
|
-
expect(sent[0].options.continuationToken).toBe("C0100:111.222");
|
|
299
|
-
expect(sent[0].message).toContain("and tomorrow?");
|
|
300
|
-
});
|
|
301
|
-
});
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
import type {
|
|
3
|
-
ChannelEventContext,
|
|
4
|
-
ChannelEventHandlers,
|
|
5
|
-
SessionContext,
|
|
6
|
-
SessionEvent,
|
|
7
|
-
} from "../../types.js";
|
|
8
|
-
import type { SlackChannelState } from "./types.js";
|
|
9
|
-
|
|
10
|
-
const mocks = vi.hoisted(() => ({
|
|
11
|
-
postMessage: vi.fn(),
|
|
12
|
-
updateMessage: vi.fn(),
|
|
13
|
-
setThreadStatus: vi.fn(),
|
|
14
|
-
startChatStream: vi.fn(),
|
|
15
|
-
appendChatStream: vi.fn(),
|
|
16
|
-
stopChatStream: vi.fn(),
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
|
-
vi.mock("./api.js", () => ({
|
|
20
|
-
postMessage: mocks.postMessage,
|
|
21
|
-
updateMessage: mocks.updateMessage,
|
|
22
|
-
setThreadStatus: mocks.setThreadStatus,
|
|
23
|
-
startChatStream: mocks.startChatStream,
|
|
24
|
-
appendChatStream: mocks.appendChatStream,
|
|
25
|
-
stopChatStream: mocks.stopChatStream,
|
|
26
|
-
truncateTypingStatus: (text: string) => text.slice(0, 50),
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
|
-
vi.mock("./assistant.js", () => ({
|
|
30
|
-
firstNonEmptyLine: (text: string) =>
|
|
31
|
-
text
|
|
32
|
-
.split("\n")
|
|
33
|
-
.map((line) => line.trim())
|
|
34
|
-
.find((line) => line.length > 0),
|
|
35
|
-
maybeSetSuggestedPrompts: vi.fn(),
|
|
36
|
-
}));
|
|
37
|
-
|
|
38
|
-
import { buildDefaultEvents } from "./defaults.js";
|
|
39
|
-
|
|
40
|
-
let eventIndex = 0;
|
|
41
|
-
|
|
42
|
-
function evt<T extends SessionEvent["type"]>(
|
|
43
|
-
partial: Omit<Extract<SessionEvent, { type: T }>, "index" | "at"> &
|
|
44
|
-
Partial<Pick<SessionEvent, "index" | "at">>
|
|
45
|
-
): Extract<SessionEvent, { type: T }> {
|
|
46
|
-
return {
|
|
47
|
-
index: eventIndex++,
|
|
48
|
-
at: new Date().toISOString(),
|
|
49
|
-
...partial,
|
|
50
|
-
} as Extract<SessionEvent, { type: T }>;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function channelOf(
|
|
54
|
-
state: SlackChannelState
|
|
55
|
-
): ChannelEventContext<SlackChannelState> {
|
|
56
|
-
return {
|
|
57
|
-
channelId: "slack",
|
|
58
|
-
state,
|
|
59
|
-
continuationToken: null,
|
|
60
|
-
setContinuationToken: async () => {},
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const sessionCtx: SessionContext = {
|
|
65
|
-
session: {
|
|
66
|
-
id: "s1",
|
|
67
|
-
channelId: "slack",
|
|
68
|
-
mode: "chat",
|
|
69
|
-
auth: null,
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
describe("buildDefaultEvents streaming:false (cursorAccount)", () => {
|
|
74
|
-
let handlers: ChannelEventHandlers<SlackChannelState>;
|
|
75
|
-
|
|
76
|
-
beforeEach(() => {
|
|
77
|
-
vi.clearAllMocks();
|
|
78
|
-
eventIndex = 0;
|
|
79
|
-
mocks.postMessage.mockResolvedValue({ ts: "9.9" });
|
|
80
|
-
mocks.setThreadStatus.mockResolvedValue(undefined);
|
|
81
|
-
handlers = buildDefaultEvents({ streaming: false });
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("uses setStatus for thinking and a single final postMessage", async () => {
|
|
85
|
-
const channel = channelOf({
|
|
86
|
-
channelId: "C1",
|
|
87
|
-
threadTs: "1.0",
|
|
88
|
-
teamId: "T1",
|
|
89
|
-
triggeringUserId: "U1",
|
|
90
|
-
pendingToolCallMessage: null,
|
|
91
|
-
lastReasoningTypingAtMs: null,
|
|
92
|
-
lastReasoningTypingStatus: null,
|
|
93
|
-
streamTs: null,
|
|
94
|
-
streamChannelId: null,
|
|
95
|
-
lastPostedText: null,
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
await handlers["turn.started"]!(
|
|
99
|
-
evt({
|
|
100
|
-
type: "turn.started",
|
|
101
|
-
sessionId: "s1",
|
|
102
|
-
turnId: "t1",
|
|
103
|
-
data: {},
|
|
104
|
-
}),
|
|
105
|
-
channel,
|
|
106
|
-
sessionCtx
|
|
107
|
-
);
|
|
108
|
-
expect(mocks.startChatStream).not.toHaveBeenCalled();
|
|
109
|
-
expect(mocks.postMessage).not.toHaveBeenCalled();
|
|
110
|
-
expect(mocks.setThreadStatus).toHaveBeenCalledWith(
|
|
111
|
-
expect.objectContaining({ status: "Working…" })
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
await handlers["actions.requested"]!(
|
|
115
|
-
evt({
|
|
116
|
-
type: "actions.requested",
|
|
117
|
-
sessionId: "s1",
|
|
118
|
-
turnId: "t1",
|
|
119
|
-
data: {
|
|
120
|
-
calls: [{ callId: "c1", toolName: "get_weather", args: {} }],
|
|
121
|
-
},
|
|
122
|
-
}),
|
|
123
|
-
channel,
|
|
124
|
-
sessionCtx
|
|
125
|
-
);
|
|
126
|
-
expect(mocks.updateMessage).not.toHaveBeenCalled();
|
|
127
|
-
expect(mocks.setThreadStatus).toHaveBeenCalledWith(
|
|
128
|
-
expect.objectContaining({ status: "Running get_weather…" })
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
await handlers["message.completed"]!(
|
|
132
|
-
evt({
|
|
133
|
-
type: "message.completed",
|
|
134
|
-
sessionId: "s1",
|
|
135
|
-
turnId: "t1",
|
|
136
|
-
data: { text: "Sunny in SF", finishReason: "stop" },
|
|
137
|
-
}),
|
|
138
|
-
channel,
|
|
139
|
-
sessionCtx
|
|
140
|
-
);
|
|
141
|
-
expect(mocks.updateMessage).not.toHaveBeenCalled();
|
|
142
|
-
expect(mocks.postMessage).toHaveBeenCalledTimes(1);
|
|
143
|
-
expect(mocks.postMessage).toHaveBeenCalledWith(
|
|
144
|
-
expect.objectContaining({ text: "Sunny in SF" })
|
|
145
|
-
);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it("posts the scrubbed turn.failed reason into the thread", async () => {
|
|
149
|
-
const channel = channelOf({
|
|
150
|
-
channelId: "C1",
|
|
151
|
-
threadTs: "1.0",
|
|
152
|
-
teamId: "T1",
|
|
153
|
-
triggeringUserId: "U1",
|
|
154
|
-
pendingToolCallMessage: null,
|
|
155
|
-
lastReasoningTypingAtMs: null,
|
|
156
|
-
lastReasoningTypingStatus: null,
|
|
157
|
-
streamTs: null,
|
|
158
|
-
streamChannelId: null,
|
|
159
|
-
lastPostedText: null,
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
await handlers["turn.failed"]!(
|
|
163
|
-
evt({
|
|
164
|
-
type: "turn.failed",
|
|
165
|
-
sessionId: "s1",
|
|
166
|
-
turnId: "t1",
|
|
167
|
-
data: {
|
|
168
|
-
message: String.raw`Authentication error at C:\Users\alice\secret and /home/ubuntu/secret`,
|
|
169
|
-
},
|
|
170
|
-
}),
|
|
171
|
-
channel,
|
|
172
|
-
sessionCtx
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
expect(mocks.postMessage).toHaveBeenCalledWith(
|
|
176
|
-
expect.objectContaining({
|
|
177
|
-
text: "I hit an error while handling your request: Authentication error at [path] and [path]",
|
|
178
|
-
threadTs: "1.0",
|
|
179
|
-
})
|
|
180
|
-
);
|
|
181
|
-
});
|
|
182
|
-
});
|