@cursor/july 0.1.96 → 0.1.97
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 +3 -2
- package/dist/bin/agent-serve.js +14 -3
- package/dist/channels/origin/api.d.ts +15 -4
- package/dist/channels/origin/api.d.ts.map +1 -1
- package/dist/channels/origin/api.js +19 -3
- package/dist/channels/origin/binding.d.ts +11 -0
- package/dist/channels/origin/binding.d.ts.map +1 -1
- package/dist/channels/origin/binding.js +41 -25
- package/dist/channels/origin/index.d.ts +1 -0
- package/dist/channels/origin/index.d.ts.map +1 -1
- package/dist/channels/origin/index.js +1 -0
- package/dist/channels/origin/origin-channel.d.ts.map +1 -1
- package/dist/channels/origin/origin-channel.js +3 -0
- package/dist/channels/origin/reactions.d.ts +56 -0
- package/dist/channels/origin/reactions.d.ts.map +1 -0
- package/dist/channels/origin/reactions.js +67 -0
- package/dist/channels/origin/types.d.ts +11 -0
- package/dist/channels/origin/types.d.ts.map +1 -1
- package/dist/channels/slack/approvals.d.ts +16 -0
- package/dist/channels/slack/approvals.d.ts.map +1 -1
- package/dist/channels/slack/approvals.js +86 -0
- package/dist/channels/slack/cli-project.d.ts +19 -0
- package/dist/channels/slack/cli-project.d.ts.map +1 -0
- package/dist/channels/slack/cli-project.js +234 -0
- package/dist/channels/slack/defaults.d.ts.map +1 -1
- package/dist/channels/slack/defaults.js +97 -39
- package/dist/channels/slack/init.d.ts +3 -2
- package/dist/channels/slack/init.d.ts.map +1 -1
- package/dist/channels/slack/init.js +5 -5
- package/dist/channels/slack/interactive.d.ts +2 -1
- package/dist/channels/slack/interactive.d.ts.map +1 -1
- package/dist/channels/slack/interactive.js +15 -4
- package/dist/channels/slack/manifest.d.ts +1 -1
- package/dist/channels/slack/manifest.js +1 -1
- package/dist/channels/slack/setup.d.ts +1 -1
- package/dist/channels/slack/setup.d.ts.map +1 -1
- package/dist/channels/slack/setup.js +10 -6
- package/dist/channels/slack/slack-channel.d.ts.map +1 -1
- package/dist/channels/slack/slack-channel.js +1 -0
- package/dist/channels/slack/tool-approval-events.d.ts.map +1 -1
- package/dist/channels/slack/tool-approval-events.js +91 -1
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +4 -4
- package/dist/docs/assets/{app.jXleCmOc.js → app.B3rWNYE1.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.BU9nHdnQ.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.8LhyglIT.js → VPLocalSearchBox.C1lhqJJR.js} +1 -1
- package/dist/docs/assets/chunks/{theme.9ged-pr2.js → theme.B40_SXuv.js} +2 -2
- package/dist/docs/assets/{deployment.md.D9msOFOW.js → deployment.md.MFPKqsqI.js} +2 -2
- package/dist/docs/assets/{guides_mcp-oauth.md.DPYmBCbV.js → guides_mcp-oauth.md.CN-6YmTJ.js} +4 -4
- package/dist/docs/assets/{guides_mcp-oauth.md.DPYmBCbV.lean.js → guides_mcp-oauth.md.CN-6YmTJ.lean.js} +1 -1
- package/dist/docs/assets/guides_slack.md.VDXQV3ja.js +22 -0
- package/dist/docs/assets/guides_slack.md.VDXQV3ja.lean.js +1 -0
- package/dist/docs/assets/index.md.CVeRUOeZ.js +5 -0
- package/dist/docs/assets/{reference_agent-config.md.Cp_x38Nl.js → reference_agent-config.md.BHeYMgme.js} +1 -1
- package/dist/docs/assets/{reference_cli.md.CCnG-nJx.js → reference_cli.md.RyZf5OTE.js} +9 -6
- package/dist/docs/assets/{reference_cli.md.CCnG-nJx.lean.js → reference_cli.md.RyZf5OTE.lean.js} +1 -1
- package/dist/docs/assets/{reference_connections.md.BH8Oc0D0.js → reference_connections.md.DxldvyIB.js} +4 -3
- package/dist/docs/assets/{reference_http-api.md.D89k1mdm.js → reference_http-api.md.5zOAbV86.js} +1 -1
- package/dist/docs/assets/reference_sessions.md.NxFP_CAC.js +1 -0
- package/dist/docs/assets/{reference_tools.md.BHeXn2id.js → reference_tools.md.B84gw9Ii.js} +1 -1
- package/dist/docs/assets/templates_agents-md.md.CXSMZljE.js +2 -0
- package/dist/docs/assets/templates_agents-md.md.CXSMZljE.lean.js +1 -0
- package/dist/docs/assets/troubleshooting.md.DCiPBhYs.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/deployment.md +5 -4
- package/dist/docs/evals.html +4 -4
- package/dist/docs/guides/agent-to-agent.html +4 -4
- package/dist/docs/guides/cloud-runtime.html +4 -4
- package/dist/docs/guides/convert-automation.html +4 -4
- package/dist/docs/guides/github.html +4 -4
- package/dist/docs/guides/human-in-the-loop.html +4 -4
- package/dist/docs/guides/mcp-oauth.html +8 -8
- package/dist/docs/guides/mcp-oauth.md +26 -8
- package/dist/docs/guides/opentelemetry.html +4 -4
- package/dist/docs/guides/slack.html +17 -33
- package/dist/docs/guides/slack.md +92 -201
- package/dist/docs/guides/webhooks.html +4 -4
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +4 -4
- package/dist/docs/index.html +6 -6
- package/dist/docs/index.md +5 -3
- package/dist/docs/llms-full.txt +299 -653
- package/dist/docs/llms.txt +2 -2
- package/dist/docs/quickstart.html +4 -4
- package/dist/docs/reference/agent-config.html +6 -6
- package/dist/docs/reference/agent-config.md +2 -2
- package/dist/docs/reference/artifacts.html +4 -4
- package/dist/docs/reference/channels.html +4 -4
- package/dist/docs/reference/cli.html +13 -10
- package/dist/docs/reference/cli.md +38 -16
- package/dist/docs/reference/connections.html +9 -8
- package/dist/docs/reference/connections.md +6 -3
- package/dist/docs/reference/hooks.html +4 -4
- package/dist/docs/reference/http-api.html +6 -6
- package/dist/docs/reference/http-api.md +2 -1
- package/dist/docs/reference/instructions.html +4 -4
- package/dist/docs/reference/playground.html +4 -4
- package/dist/docs/reference/project-layout.html +4 -4
- package/dist/docs/reference/prompt.html +4 -4
- package/dist/docs/reference/schedules.html +4 -4
- package/dist/docs/reference/sessions.html +5 -5
- package/dist/docs/reference/sessions.md +4 -2
- package/dist/docs/reference/skills.html +4 -4
- package/dist/docs/reference/subagents.html +4 -4
- package/dist/docs/reference/tools.html +6 -6
- package/dist/docs/reference/tools.md +9 -2
- package/dist/docs/scaffolding-agents.html +4 -4
- package/dist/docs/storage.html +4 -4
- package/dist/docs/templates/agentic-owners.html +4 -4
- package/dist/docs/templates/agents-md.html +28 -0
- package/dist/docs/templates/agents-md.md +105 -0
- package/dist/docs/templates/code-wiki.html +5 -5
- package/dist/docs/templates/demo.html +4 -4
- package/dist/docs/templates/pr-autofixer.html +4 -4
- package/dist/docs/templates/security-help.html +4 -4
- package/dist/docs/templates/security-reviewer.html +5 -5
- package/dist/docs/templates/triage.html +4 -4
- package/dist/docs/troubleshooting.html +5 -5
- package/dist/docs/troubleshooting.md +2 -2
- package/dist/evals/run-facts.d.ts.map +1 -1
- package/dist/evals/run-facts.js +27 -0
- package/dist/internal/advertise-tools.d.ts.map +1 -1
- package/dist/internal/advertise-tools.js +15 -9
- package/dist/internal/approval-gate.d.ts +12 -13
- package/dist/internal/approval-gate.d.ts.map +1 -1
- package/dist/internal/approval-gate.js +16 -21
- package/dist/internal/chat-client.js +10 -0
- package/dist/internal/cli-deploy.d.ts +5 -0
- package/dist/internal/cli-deploy.d.ts.map +1 -1
- package/dist/internal/cli-deploy.js +50 -17
- package/dist/internal/cli-mcp-oauth.js +8 -18
- package/dist/internal/cli-slack-manual.d.ts +24 -2
- package/dist/internal/cli-slack-manual.d.ts.map +1 -1
- package/dist/internal/cli-slack-manual.js +251 -20
- package/dist/internal/cli-slack.d.ts +9 -2
- package/dist/internal/cli-slack.d.ts.map +1 -1
- package/dist/internal/cli-slack.js +29 -82
- package/dist/internal/cursor/account-mcp.d.ts +1 -0
- package/dist/internal/cursor/account-mcp.d.ts.map +1 -1
- package/dist/internal/cursor/account-mcp.js +17 -0
- package/dist/internal/cursor-agent-template.d.ts +1 -1
- package/dist/internal/cursor-agent-template.d.ts.map +1 -1
- package/dist/internal/cursor-agent-template.js +1 -0
- package/dist/internal/deploy-client.d.ts +17 -0
- package/dist/internal/deploy-client.d.ts.map +1 -1
- package/dist/internal/deploy-client.js +31 -10
- package/dist/internal/env-file.d.ts +19 -0
- package/dist/internal/env-file.d.ts.map +1 -0
- package/dist/internal/env-file.js +90 -0
- package/dist/internal/framework-file-storage.d.ts +1 -1
- package/dist/internal/framework-file-storage.d.ts.map +1 -1
- package/dist/internal/framework-file-storage.js +6 -0
- package/dist/internal/hosted-delivery-protocol.d.ts +7 -0
- package/dist/internal/hosted-delivery-protocol.d.ts.map +1 -1
- package/dist/internal/hosted-delivery-protocol.js +7 -0
- package/dist/internal/hosted-delivery.d.ts +6 -0
- package/dist/internal/hosted-delivery.d.ts.map +1 -1
- package/dist/internal/hosted-delivery.js +63 -22
- package/dist/internal/hosted-execution-diag.d.ts +48 -0
- package/dist/internal/hosted-execution-diag.d.ts.map +1 -0
- package/dist/internal/hosted-execution-diag.js +150 -0
- package/dist/internal/http-channel.d.ts.map +1 -1
- package/dist/internal/http-channel.js +81 -1
- package/dist/internal/init-project.d.ts.map +1 -1
- package/dist/internal/init-project.js +2 -0
- package/dist/internal/logs-client.d.ts +5 -0
- package/dist/internal/logs-client.d.ts.map +1 -1
- package/dist/internal/logs-client.js +5 -0
- package/dist/internal/mcp-endpoint.js +2 -3
- package/dist/internal/mcp-host.d.ts +10 -0
- package/dist/internal/mcp-host.d.ts.map +1 -1
- package/dist/internal/mcp-host.js +57 -8
- package/dist/internal/mcp-oauth-on-demand.d.ts +68 -0
- package/dist/internal/mcp-oauth-on-demand.d.ts.map +1 -0
- package/dist/internal/mcp-oauth-on-demand.js +287 -0
- package/dist/internal/mcp-oauth-persist.d.ts +42 -0
- package/dist/internal/mcp-oauth-persist.d.ts.map +1 -0
- package/dist/internal/mcp-oauth-persist.js +92 -0
- package/dist/internal/mcp-oauth.d.ts +1 -0
- package/dist/internal/mcp-oauth.d.ts.map +1 -1
- package/dist/internal/mcp-oauth.js +10 -2
- package/dist/internal/otel/collector.d.ts.map +1 -1
- package/dist/internal/otel/collector.js +22 -9
- package/dist/internal/server.d.ts +3 -0
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +49 -22
- package/dist/internal/session-engine.d.ts +88 -3
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +515 -43
- package/dist/internal/sessions-client.d.ts +9 -7
- package/dist/internal/sessions-client.d.ts.map +1 -1
- package/dist/internal/sessions-client.js +3 -1
- package/dist/internal/storage-coordinator.d.ts +7 -0
- package/dist/internal/storage-coordinator.d.ts.map +1 -1
- package/dist/internal/storage-coordinator.js +28 -5
- package/dist/internal/storage-roles.d.ts +5 -0
- package/dist/internal/storage-roles.d.ts.map +1 -1
- package/dist/internal/stream-progress.d.ts.map +1 -1
- package/dist/internal/stream-progress.js +10 -0
- package/dist/internal/tool-policy.d.ts +9 -1
- package/dist/internal/tool-policy.d.ts.map +1 -1
- package/dist/internal/tool-policy.js +13 -0
- package/dist/internal/trajectory.d.ts.map +1 -1
- package/dist/internal/trajectory.js +10 -0
- package/dist/internal/turn-outbox.d.ts +24 -0
- package/dist/internal/turn-outbox.d.ts.map +1 -0
- package/dist/internal/turn-outbox.js +80 -0
- package/dist/playground/assets/{index-Cx9CclK_.js → index-DrkI6y5O.js} +45 -45
- package/dist/playground/assets/index-DzNGwm7q.css +1 -0
- package/dist/playground/index.html +2 -2
- package/dist/storage-backends/cursor-hosted.d.ts +1 -1
- package/dist/storage-backends/cursor-hosted.d.ts.map +1 -1
- package/dist/storage-backends/cursor-hosted.js +12 -0
- package/dist/storage.d.ts +8 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/types.d.ts +63 -7
- package/dist/types.d.ts.map +1 -1
- package/docs/README.md +5 -3
- package/docs/deployment.md +5 -4
- package/docs/guides/mcp-oauth.md +26 -8
- package/docs/guides/slack.md +93 -202
- package/docs/reference/agent-config.md +2 -2
- package/docs/reference/cli.md +38 -16
- package/docs/reference/connections.md +6 -3
- package/docs/reference/http-api.md +2 -1
- package/docs/reference/sessions.md +4 -2
- package/docs/reference/tools.md +9 -2
- package/docs/templates/agents-md.md +110 -0
- package/docs/troubleshooting.md +2 -2
- package/package.json +1 -1
- package/skills/create-agent/SKILL.md +2 -1
- package/skills/mcp-auth/SKILL.md +6 -3
- package/skills/setup-slack/SKILL.md +23 -13
- package/src/bin/agent-serve.ts +13 -1
- package/src/channels/origin/api.ts +24 -5
- package/src/channels/origin/binding.ts +55 -26
- package/src/channels/origin/index.ts +1 -0
- package/src/channels/origin/origin-channel.ts +4 -0
- package/src/channels/origin/reactions.ts +82 -0
- package/src/channels/origin/types.ts +11 -0
- package/src/channels/slack/approvals.ts +105 -0
- package/src/channels/slack/cli-project.ts +267 -0
- package/src/channels/slack/defaults.ts +109 -46
- package/src/channels/slack/init.ts +10 -5
- package/src/channels/slack/interactive.ts +35 -9
- package/src/channels/slack/manifest.ts +1 -1
- package/src/channels/slack/setup.ts +10 -6
- package/src/channels/slack/slack-channel.ts +1 -0
- package/src/channels/slack/tool-approval-events.ts +93 -0
- package/src/evals/run-facts.ts +32 -0
- package/src/internal/advertise-tools.ts +31 -10
- package/src/internal/approval-gate.ts +20 -29
- package/src/internal/chat-client.ts +19 -0
- package/src/internal/cli-deploy.ts +79 -9
- package/src/internal/cli-mcp-oauth.ts +7 -21
- package/src/internal/cli-slack-manual.ts +350 -18
- package/src/internal/cli-slack.ts +40 -84
- package/src/internal/cursor/account-mcp.ts +21 -0
- package/src/internal/cursor-agent-template.ts +1 -0
- package/src/internal/deploy-client.ts +43 -0
- package/src/internal/env-file.ts +84 -0
- package/src/internal/framework-file-storage.ts +7 -1
- package/src/internal/hosted-delivery-protocol.ts +7 -0
- package/src/internal/hosted-delivery.ts +100 -27
- package/src/internal/hosted-execution-diag.ts +207 -0
- package/src/internal/http-channel.ts +99 -0
- package/src/internal/init-project.ts +2 -0
- package/src/internal/logs-client.ts +5 -0
- package/src/internal/mcp-endpoint.ts +13 -4
- package/src/internal/mcp-host.ts +77 -11
- package/src/internal/mcp-oauth-on-demand.ts +352 -0
- package/src/internal/mcp-oauth-persist.ts +127 -0
- package/src/internal/mcp-oauth.ts +17 -1
- package/src/internal/otel/collector.ts +30 -0
- package/src/internal/server.ts +59 -9
- package/src/internal/session-engine.ts +659 -56
- package/src/internal/sessions-client.ts +17 -8
- package/src/internal/storage-coordinator.ts +38 -8
- package/src/internal/storage-roles.ts +7 -0
- package/src/internal/stream-progress.ts +19 -0
- package/src/internal/tool-policy.ts +18 -0
- package/src/internal/trajectory.ts +10 -0
- package/src/internal/turn-outbox.ts +85 -0
- package/src/storage-backends/cursor-hosted.ts +13 -1
- package/src/storage.ts +12 -0
- package/src/types.ts +68 -8
- package/templates/agents-md/README.md +39 -0
- package/templates/agents-md/agent/agent.ts +8 -0
- package/templates/agents-md/agent/channels/github.ts +10 -0
- package/templates/agents-md/agent/channels/queue.ts +28 -0
- package/templates/agents-md/agent/channels/slack.ts +9 -0
- package/templates/agents-md/agent/instructions.md +39 -0
- package/templates/agents-md/agent/lib/collect.ts +439 -0
- package/templates/agents-md/agent/lib/config.ts +8 -0
- package/templates/agents-md/agent/lib/paths.ts +51 -0
- package/templates/agents-md/agent/schedules/weekly.ts +17 -0
- package/templates/agents-md/agent/tools/apply_agents.ts +226 -0
- package/templates/agents-md/evals/agents.eval.ts +135 -0
- package/templates/agents-md/evals/evals.config.ts +5 -0
- package/templates/agents-md/init.json +38 -0
- package/templates/agents-md/package.json +18 -0
- package/templates/agents-md/tsconfig.json +12 -0
- package/dist/docs/assets/chunks/@localSearchIndexroot.DFoGuETX.js +0 -1
- package/dist/docs/assets/guides_slack.md.C32HsdKk.js +0 -38
- package/dist/docs/assets/guides_slack.md.C32HsdKk.lean.js +0 -1
- package/dist/docs/assets/index.md.CI93Ltlb.js +0 -5
- package/dist/docs/assets/reference_sessions.md.D0mIh4KK.js +0 -1
- package/dist/docs/assets/troubleshooting.md.Ctv3T8C2.js +0 -1
- package/dist/docs/design/agsh.md +0 -406
- package/dist/playground/assets/index-B1DDvBeC.css +0 -1
- package/docs/design/agsh.md +0 -406
- /package/dist/docs/assets/{deployment.md.D9msOFOW.lean.js → deployment.md.MFPKqsqI.lean.js} +0 -0
- /package/dist/docs/assets/{index.md.CI93Ltlb.lean.js → index.md.CVeRUOeZ.lean.js} +0 -0
- /package/dist/docs/assets/{reference_agent-config.md.Cp_x38Nl.lean.js → reference_agent-config.md.BHeYMgme.lean.js} +0 -0
- /package/dist/docs/assets/{reference_connections.md.BH8Oc0D0.lean.js → reference_connections.md.DxldvyIB.lean.js} +0 -0
- /package/dist/docs/assets/{reference_http-api.md.D89k1mdm.lean.js → reference_http-api.md.5zOAbV86.lean.js} +0 -0
- /package/dist/docs/assets/{reference_sessions.md.D0mIh4KK.lean.js → reference_sessions.md.NxFP_CAC.lean.js} +0 -0
- /package/dist/docs/assets/{reference_tools.md.BHeXn2id.lean.js → reference_tools.md.B84gw9Ii.lean.js} +0 -0
- /package/dist/docs/assets/{troubleshooting.md.Ctv3T8C2.lean.js → troubleshooting.md.DCiPBhYs.lean.js} +0 -0
|
@@ -411,13 +411,25 @@ export class HostMcpOAuthProvider implements OAuthClientProvider {
|
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
413
|
|
|
414
|
+
function clientForRedirect(
|
|
415
|
+
info: OAuthClientInformationFull | undefined,
|
|
416
|
+
redirectUrl: string
|
|
417
|
+
): OAuthClientInformationFull | undefined {
|
|
418
|
+
if (info === undefined || !info.redirect_uris.includes(redirectUrl)) {
|
|
419
|
+
return undefined;
|
|
420
|
+
}
|
|
421
|
+
return info;
|
|
422
|
+
}
|
|
423
|
+
|
|
414
424
|
export async function createHostMcpOAuthProvider(args: {
|
|
415
425
|
identifier: string;
|
|
416
426
|
resourceUrl: string;
|
|
417
427
|
store?: FileMcpOAuthStore;
|
|
418
428
|
onRedirect?: (url: URL) => void;
|
|
429
|
+
redirectUrl?: string;
|
|
419
430
|
}): Promise<HostMcpOAuthProvider> {
|
|
420
431
|
const store = args.store ?? new FileMcpOAuthStore();
|
|
432
|
+
const redirectUrl = args.redirectUrl ?? MCP_OAUTH_CALLBACK_URL;
|
|
421
433
|
const [fileTokens, fileClient, omitResourceIndicator] = await Promise.all([
|
|
422
434
|
store.loadTokens(args.identifier, args.resourceUrl),
|
|
423
435
|
store.loadClientInformation(args.identifier, args.resourceUrl),
|
|
@@ -427,8 +439,12 @@ export async function createHostMcpOAuthProvider(args: {
|
|
|
427
439
|
identifier: args.identifier,
|
|
428
440
|
resourceUrl: args.resourceUrl,
|
|
429
441
|
store,
|
|
442
|
+
redirectUrl,
|
|
430
443
|
tokens: fileTokens ?? tokensFromEnv(args.identifier),
|
|
431
|
-
clientInformation:
|
|
444
|
+
clientInformation: clientForRedirect(
|
|
445
|
+
fileClient ?? clientIdFromEnv(args.identifier),
|
|
446
|
+
redirectUrl
|
|
447
|
+
),
|
|
432
448
|
onRedirect: args.onRedirect,
|
|
433
449
|
omitResourceIndicator,
|
|
434
450
|
});
|
|
@@ -284,6 +284,36 @@ export function createOtelCollector(
|
|
|
284
284
|
);
|
|
285
285
|
return;
|
|
286
286
|
}
|
|
287
|
+
case "action.auth_requested": {
|
|
288
|
+
ensureTurn(event, session, startTime)
|
|
289
|
+
?.tools.get(event.data.callId)
|
|
290
|
+
?.addEvent("auth_requested", undefined, startTime);
|
|
291
|
+
emitLog(
|
|
292
|
+
"action.auth_requested",
|
|
293
|
+
SeverityNumber.INFO,
|
|
294
|
+
attrs({
|
|
295
|
+
...baseLog(event, session),
|
|
296
|
+
"cursor.tool.name": event.data.toolName,
|
|
297
|
+
"agent_sdk.call_id": event.data.callId,
|
|
298
|
+
"agent_sdk.mcp_connection": event.data.connection,
|
|
299
|
+
})
|
|
300
|
+
);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
case "action.auth_resolved": {
|
|
304
|
+
ensureTurn(event, session, startTime)
|
|
305
|
+
?.tools.get(event.data.callId)
|
|
306
|
+
?.addEvent(
|
|
307
|
+
"auth_resolved",
|
|
308
|
+
attrs({
|
|
309
|
+
"agent_sdk.decision": event.data.decision,
|
|
310
|
+
"agent_sdk.decision_by": event.data.by,
|
|
311
|
+
"agent_sdk.mcp_connection": event.data.connection,
|
|
312
|
+
}),
|
|
313
|
+
startTime
|
|
314
|
+
);
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
287
317
|
case "action.result": {
|
|
288
318
|
const turn = ensureTurn(event, session, startTime);
|
|
289
319
|
const span = turn?.tools.get(event.data.callId);
|
package/src/internal/server.ts
CHANGED
|
@@ -130,6 +130,11 @@ import {
|
|
|
130
130
|
MCP_ENDPOINT_PATH,
|
|
131
131
|
TOOL_MCP_ENDPOINT_PATH,
|
|
132
132
|
} from "./mcp-endpoint.js";
|
|
133
|
+
import {
|
|
134
|
+
mcpOauthServeCallbackPath,
|
|
135
|
+
mcpOauthServeCallbackUrl,
|
|
136
|
+
} from "./mcp-oauth-on-demand.js";
|
|
137
|
+
import type { McpOauthSecretsTarget } from "./mcp-oauth-persist.js";
|
|
133
138
|
import { isLoopbackAddress } from "./net.js";
|
|
134
139
|
import { createOtelCollector, type OtelCollector } from "./otel/collector.js";
|
|
135
140
|
import { pickAuthoredOtel, resolveOtelConfig } from "./otel/config.js";
|
|
@@ -240,6 +245,8 @@ function isV2Project(project: { agent: { architecture?: string } }): boolean {
|
|
|
240
245
|
export interface StartServerInternalOptions {
|
|
241
246
|
/** Test seam: replace the Cursor SDK runner (integration tests). */
|
|
242
247
|
runner?: AgentRunner;
|
|
248
|
+
/** Test seam: bind the `--store` secrets client for on-demand MCP OAuth. */
|
|
249
|
+
mcpOauthSecrets?: McpOauthSecretsTarget;
|
|
243
250
|
}
|
|
244
251
|
|
|
245
252
|
/**
|
|
@@ -647,6 +654,12 @@ export async function startServer(
|
|
|
647
654
|
otel: otelCollector,
|
|
648
655
|
otelMeter: otelRuntime?.meter,
|
|
649
656
|
});
|
|
657
|
+
engine.oauthCallbackHub.secrets = options.mcpOauthSecrets;
|
|
658
|
+
engine.oauthCallbackHub.secretsBind = {
|
|
659
|
+
slug: slug === "" ? undefined : slug,
|
|
660
|
+
cloudToolsUrl: options.cloudToolsUrl,
|
|
661
|
+
};
|
|
662
|
+
engine.oauthCallbackHub.logger = logger;
|
|
650
663
|
// Rehydrate sessions from the authored storage sink before any
|
|
651
664
|
// channel or route can address them (continuation tokens must resolve).
|
|
652
665
|
await engine.restoreStoredSessions();
|
|
@@ -732,6 +745,7 @@ export async function startServer(
|
|
|
732
745
|
multi,
|
|
733
746
|
logger,
|
|
734
747
|
logRing,
|
|
748
|
+
diagStateRoot: baseStateRoot,
|
|
735
749
|
...(options.authToken === undefined
|
|
736
750
|
? {}
|
|
737
751
|
: { authToken: options.authToken }),
|
|
@@ -762,6 +776,8 @@ export async function startServer(
|
|
|
762
776
|
},
|
|
763
777
|
resolveApproval: (sessionId, callId, decision, auth) =>
|
|
764
778
|
engine.resolveApproval(sessionId, callId, decision, auth),
|
|
779
|
+
resolveAuth: (sessionId, callId, decision, auth) =>
|
|
780
|
+
engine.resolveAuth(sessionId, callId, decision, auth),
|
|
765
781
|
hasContinuationSession: (continuationToken) =>
|
|
766
782
|
engine.hasContinuationSession(channel.id, continuationToken),
|
|
767
783
|
isContinuationBusy: (continuationToken) =>
|
|
@@ -1013,6 +1029,7 @@ export async function startServer(
|
|
|
1013
1029
|
const address = server.address() as AddressInfo;
|
|
1014
1030
|
const displayHost = host === "0.0.0.0" || host === "::" ? "127.0.0.1" : host;
|
|
1015
1031
|
const url = `http://${displayHost}:${boundPort}`;
|
|
1032
|
+
const oauthOrigin = (options.publicUrl ?? url).replace(/\/$/, "");
|
|
1016
1033
|
|
|
1017
1034
|
// Resolve peer + Cursor account MCP connections now that the listen port is
|
|
1018
1035
|
// known (see resolved-connections.ts for the URL/runtime rules).
|
|
@@ -1039,6 +1056,20 @@ export async function startServer(
|
|
|
1039
1056
|
if (resolved.length > 0) {
|
|
1040
1057
|
runtime.engine.setResolvedConnections(resolved);
|
|
1041
1058
|
}
|
|
1059
|
+
const oauthBase = runtime.slug === "" ? "" : `/${runtime.slug}`;
|
|
1060
|
+
runtime.engine.setMcpOauthCallbackUrl(
|
|
1061
|
+
mcpOauthServeCallbackUrl(oauthOrigin, oauthBase)
|
|
1062
|
+
);
|
|
1063
|
+
if (accountBridge !== undefined && accountRefs !== undefined) {
|
|
1064
|
+
const bridge = accountBridge;
|
|
1065
|
+
runtime.engine.setCursorAccountAuthProbe(async (connection) => {
|
|
1066
|
+
const ref = accountRefs.find((entry) => entry.name === connection);
|
|
1067
|
+
if (ref === undefined) {
|
|
1068
|
+
return undefined;
|
|
1069
|
+
}
|
|
1070
|
+
return await bridge.probeAuthUrl(ref);
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1042
1073
|
const hasServerTools = runtime.project.agent.tools.some(
|
|
1043
1074
|
(tool) => tool.execution === "server"
|
|
1044
1075
|
);
|
|
@@ -1227,6 +1258,11 @@ function mountAgentRoutes(
|
|
|
1227
1258
|
/** Cursor account bridge + this mount's account MCP connections, when authored. */
|
|
1228
1259
|
accountBridge?: CursorAccountMcpBridge;
|
|
1229
1260
|
accountRefs?: CursorAccountConnectionRef[];
|
|
1261
|
+
/**
|
|
1262
|
+
* Serve `--state-root`. Hosted-execution writes `hosted-execution.json`
|
|
1263
|
+
* here so the Temporal host can read a stable path after the POST.
|
|
1264
|
+
*/
|
|
1265
|
+
diagStateRoot?: string;
|
|
1230
1266
|
}
|
|
1231
1267
|
): void {
|
|
1232
1268
|
const { slug, project, engine, scheduleRunner, reminderRunner } = runtime;
|
|
@@ -1288,6 +1324,9 @@ function mountAgentRoutes(
|
|
|
1288
1324
|
}),
|
|
1289
1325
|
drainSessionDurability: (sessionId) =>
|
|
1290
1326
|
engine.drainSessionDurability(sessionId),
|
|
1327
|
+
...(args.diagStateRoot === undefined
|
|
1328
|
+
? {}
|
|
1329
|
+
: { stateRoot: args.diagStateRoot }),
|
|
1291
1330
|
});
|
|
1292
1331
|
}
|
|
1293
1332
|
// Playground lists/opens Slack (and other channel) sessions across
|
|
@@ -1303,6 +1342,13 @@ function mountAgentRoutes(
|
|
|
1303
1342
|
// tools (Slack principals never match local/anonymous HTTP auth).
|
|
1304
1343
|
const relaxSessionApprovalAuth = relaxSessionReadAuth;
|
|
1305
1344
|
|
|
1345
|
+
router.add({
|
|
1346
|
+
method: "GET",
|
|
1347
|
+
pattern: `${base}${mcpOauthServeCallbackPath()}`,
|
|
1348
|
+
auth: "none",
|
|
1349
|
+
handler: (request) => engine.oauthCallbackHub.handleCallback(request),
|
|
1350
|
+
});
|
|
1351
|
+
|
|
1306
1352
|
router.add({
|
|
1307
1353
|
method: "GET",
|
|
1308
1354
|
pattern: `${base}/v1/health`,
|
|
@@ -1391,7 +1437,7 @@ function mountAgentRoutes(
|
|
|
1391
1437
|
method: "GET",
|
|
1392
1438
|
pattern: `${base}/v1/sessions`,
|
|
1393
1439
|
auth: httpAuth,
|
|
1394
|
-
handler: async (
|
|
1440
|
+
handler: async (request, ctx) => {
|
|
1395
1441
|
// Same gate as requireSessionOwner / relaxSessionReadAuth: never with
|
|
1396
1442
|
// bearer or custom channel auth (strict per-principal isolation).
|
|
1397
1443
|
// `--allow-anonymous` alone is a shared-principal trust boundary (corp
|
|
@@ -1401,9 +1447,14 @@ function mountAgentRoutes(
|
|
|
1401
1447
|
(relaxSessionReadAuthBeyondLoopback ||
|
|
1402
1448
|
(typeof ctx.requestIp === "string" &&
|
|
1403
1449
|
isLoopbackAddress(ctx.requestIp)));
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1450
|
+
// `?latest=1` — only the newest visible session. Clients binding a
|
|
1451
|
+
// default session (agsh) do not need the whole list, and on hosted
|
|
1452
|
+
// storage the whole list is a database scan.
|
|
1453
|
+
const latest = new URL(request.url).searchParams.get("latest");
|
|
1454
|
+
const listed =
|
|
1455
|
+
latest === "1" || latest === "true"
|
|
1456
|
+
? await engine.latestSessionWithSource(ctx.auth, { includeAll })
|
|
1457
|
+
: await engine.listSessionsWithSource(ctx.auth, { includeAll });
|
|
1407
1458
|
return jsonResponse({
|
|
1408
1459
|
sessions: listed.sessions,
|
|
1409
1460
|
source: listed.source,
|
|
@@ -1613,23 +1664,22 @@ function mountAgentRoutes(
|
|
|
1613
1664
|
return binding.errorResponse;
|
|
1614
1665
|
}
|
|
1615
1666
|
try {
|
|
1616
|
-
const
|
|
1667
|
+
const described = await engine.describeCatalogTool(toolName, {
|
|
1617
1668
|
auth: ctx.auth,
|
|
1618
1669
|
...binding,
|
|
1619
1670
|
});
|
|
1620
|
-
|
|
1621
|
-
if (tool === undefined) {
|
|
1671
|
+
if (described.tool === undefined) {
|
|
1622
1672
|
return jsonResponse(
|
|
1623
1673
|
{
|
|
1624
1674
|
ok: false,
|
|
1625
1675
|
error: "unknown_tool",
|
|
1626
1676
|
message: `Unknown tool "${toolName}".`,
|
|
1627
|
-
availableTools:
|
|
1677
|
+
availableTools: described.availableTools,
|
|
1628
1678
|
},
|
|
1629
1679
|
{ status: 404 }
|
|
1630
1680
|
);
|
|
1631
1681
|
}
|
|
1632
|
-
return jsonResponse(catalogDetailEntry(tool));
|
|
1682
|
+
return jsonResponse(catalogDetailEntry(described.tool));
|
|
1633
1683
|
} catch (error) {
|
|
1634
1684
|
if (error instanceof InvalidContinuationTokenError) {
|
|
1635
1685
|
return errorResponse(
|