@cursor/july 0.1.105 → 0.1.108
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 +10 -5
- package/dist/bin/agent-serve.js +31 -16
- package/dist/channels/bitbucket/types.d.ts +2 -4
- package/dist/channels/bitbucket/types.d.ts.map +1 -1
- package/dist/channels/deployments/types.d.ts +5 -8
- package/dist/channels/deployments/types.d.ts.map +1 -1
- package/dist/channels/github/github-channel.js +8 -5
- package/dist/channels/github/types.d.ts +7 -5
- package/dist/channels/github/types.d.ts.map +1 -1
- package/dist/channels/gitlab/types.d.ts +2 -5
- package/dist/channels/gitlab/types.d.ts.map +1 -1
- package/dist/channels/origin/origin-channel.d.ts.map +1 -1
- package/dist/channels/origin/origin-channel.js +27 -13
- package/dist/channels/origin/types.d.ts +7 -4
- package/dist/channels/origin/types.d.ts.map +1 -1
- package/dist/channels/slack/defaults.d.ts.map +1 -1
- package/dist/channels/slack/defaults.js +3 -0
- package/dist/channels/slack/dispatch.d.ts.map +1 -1
- package/dist/channels/slack/dispatch.js +1 -1
- package/dist/channels/slack/live-delivery.d.ts.map +1 -1
- package/dist/channels/slack/live-delivery.js +48 -11
- package/dist/channels/slack/types.d.ts +4 -3
- package/dist/channels/slack/types.d.ts.map +1 -1
- package/dist/channels.d.ts +45 -0
- package/dist/channels.d.ts.map +1 -1
- package/dist/channels.js +106 -7
- package/dist/connections.d.ts +2 -1
- package/dist/connections.d.ts.map +1 -1
- package/dist/connections.js +2 -1
- package/dist/docs/404.html +3 -3
- package/dist/docs/ab.html +6 -6
- package/dist/docs/assets/{app.BVwaffdK.js → app.BASKM3M4.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.BHZYsNVi.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.WuWTZ1x8.js → VPLocalSearchBox.BOKxlYGP.js} +2 -2
- package/dist/docs/assets/chunks/{theme.BYdI_6sF.js → theme.DbDZW-zb.js} +2 -2
- package/dist/docs/assets/{deployment.md.MFPKqsqI.js → deployment.md.JenwuCCB.js} +4 -4
- package/dist/docs/assets/{deployment.md.MFPKqsqI.lean.js → deployment.md.JenwuCCB.lean.js} +1 -1
- package/dist/docs/assets/{evals.md.CbMoebP1.js → evals.md.C1ekS3k2.js} +1 -1
- package/dist/docs/assets/guides_cloud-agents.md.BsloyHdY.js +9 -0
- package/dist/docs/assets/{guides_cloud-agents.md.DS8RIjwx.lean.js → guides_cloud-agents.md.BsloyHdY.lean.js} +1 -1
- package/dist/docs/assets/{guides_github.md.c0gdGJ-D.js → guides_github.md.BH33UEBJ.js} +1 -1
- package/dist/docs/assets/{guides_grokbot-agents.md.DVqdhBKb.js → guides_grokbot-agents.md.DyV-WArv.js} +1 -1
- package/dist/docs/assets/guides_improve.md.BGVk32bK.js +14 -0
- package/dist/docs/assets/guides_improve.md.BGVk32bK.lean.js +1 -0
- package/dist/docs/assets/{guides_opentelemetry.md.COh9jFVg.js → guides_opentelemetry.md.SCRMskno.js} +3 -3
- package/dist/docs/assets/{guides_opentelemetry.md.COh9jFVg.lean.js → guides_opentelemetry.md.SCRMskno.lean.js} +1 -1
- package/dist/docs/assets/{guides_slack.md.9oHPye9o.js → guides_slack.md.D4RVMM4G.js} +3 -3
- package/dist/docs/assets/{guides_slack.md.9oHPye9o.lean.js → guides_slack.md.D4RVMM4G.lean.js} +1 -1
- package/dist/docs/assets/index.md.BjH1w2ZW.js +5 -0
- package/dist/docs/assets/{reference_agent-config.md.CHNpiyp4.js → reference_agent-config.md.CvoL6pof.js} +1 -1
- package/dist/docs/assets/{reference_channels.md.DBGcaB7m.js → reference_channels.md.D-qTqwcq.js} +2 -2
- package/dist/docs/assets/{reference_channels.md.DBGcaB7m.lean.js → reference_channels.md.D-qTqwcq.lean.js} +1 -1
- package/dist/docs/assets/{reference_cli.md.C6Lo8SEd.js → reference_cli.md.Ca26u0Es.js} +6 -6
- package/dist/docs/assets/{reference_cli.md.C6Lo8SEd.lean.js → reference_cli.md.Ca26u0Es.lean.js} +1 -1
- package/dist/docs/assets/{reference_connections.md.Di6jJAXF.js → reference_connections.md.BojkC6c5.js} +1 -1
- package/dist/docs/assets/{reference_extensions.md.CGmMLblt.js → reference_extensions.md.CPWt00ds.js} +1 -1
- package/dist/docs/assets/{scaffolding-agents.md.em43xlY1.js → scaffolding-agents.md.Kctn3OVb.js} +1 -1
- package/dist/docs/assets/{skills_create-agent.md.BVoWPcan.js → skills_create-agent.md.Q3h6Je-e.js} +1 -1
- package/dist/docs/assets/{skills_debug.md.CDbPhHfg.js → skills_debug.md.CVjCXMFF.js} +1 -1
- package/dist/docs/assets/{skills_debug.md.CDbPhHfg.lean.js → skills_debug.md.CVjCXMFF.lean.js} +1 -1
- package/dist/docs/assets/{skills_evals.md.723kpUmA.js → skills_evals.md.BhovOvrl.js} +1 -1
- package/dist/docs/assets/skills_framework-map.md.D-tFZhFS.js +1 -0
- package/dist/docs/assets/{skills_framework-map.md.haibFyoB.lean.js → skills_framework-map.md.D-tFZhFS.lean.js} +1 -1
- package/dist/docs/assets/{skills_github.md.D0JahM8c.js → skills_github.md.hgFX_oKY.js} +1 -1
- package/dist/docs/assets/{skills_otel.md.CqhobH3B.js → skills_otel.md.B5Ddv1xH.js} +1 -1
- package/dist/docs/assets/{style.BRuM8477.css → style.DCD_zyg3.css} +1 -1
- package/dist/docs/assets/troubleshooting.md.CYEAO9bM.js +1 -0
- package/dist/docs/building-with-agents.html +6 -6
- package/dist/docs/concepts.html +5 -5
- package/dist/docs/deployment.html +9 -9
- package/dist/docs/deployment.md +7 -2
- package/dist/docs/evals.html +8 -8
- package/dist/docs/evals.md +3 -2
- package/dist/docs/guides/agent-to-agent.html +6 -6
- package/dist/docs/guides/cloud-agents.html +7 -7
- package/dist/docs/guides/cloud-agents.md +4 -3
- package/dist/docs/guides/convert-automation.html +6 -6
- package/dist/docs/guides/github.html +7 -7
- package/dist/docs/guides/github.md +2 -1
- package/dist/docs/guides/grokbot-agents.html +7 -7
- package/dist/docs/guides/grokbot-agents.md +2 -2
- package/dist/docs/guides/human-in-the-loop.html +6 -6
- package/dist/docs/guides/improve.html +40 -0
- package/dist/docs/guides/improve.md +91 -0
- package/dist/docs/guides/mcp-oauth.html +6 -6
- package/dist/docs/guides/opentelemetry.html +8 -8
- package/dist/docs/guides/opentelemetry.md +3 -4
- package/dist/docs/guides/slack.html +8 -8
- package/dist/docs/guides/slack.md +2 -1
- package/dist/docs/guides/webhooks.html +6 -6
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +6 -6
- package/dist/docs/index.html +8 -8
- package/dist/docs/index.md +4 -0
- package/dist/docs/llms-full.txt +180 -61
- package/dist/docs/llms.txt +1 -0
- package/dist/docs/quickstart.html +6 -6
- package/dist/docs/reference/agent-config.html +7 -7
- package/dist/docs/reference/agent-config.md +5 -2
- package/dist/docs/reference/artifacts.html +6 -6
- package/dist/docs/reference/channels.html +7 -7
- package/dist/docs/reference/channels.md +11 -19
- package/dist/docs/reference/cli.html +11 -11
- package/dist/docs/reference/cli.md +23 -13
- package/dist/docs/reference/connections.html +8 -8
- package/dist/docs/reference/connections.md +2 -1
- package/dist/docs/reference/extensions.html +7 -7
- package/dist/docs/reference/extensions.md +2 -0
- package/dist/docs/reference/hooks.html +6 -6
- package/dist/docs/reference/http-api.html +6 -6
- package/dist/docs/reference/instructions.html +6 -6
- package/dist/docs/reference/playground.html +5 -5
- package/dist/docs/reference/project-layout.html +6 -6
- package/dist/docs/reference/prompt.html +6 -6
- package/dist/docs/reference/result.html +6 -6
- package/dist/docs/reference/schedules.html +6 -6
- package/dist/docs/reference/sessions.html +5 -5
- package/dist/docs/reference/skills.html +6 -6
- package/dist/docs/reference/subagents.html +6 -6
- package/dist/docs/reference/tools.html +6 -6
- package/dist/docs/scaffolding-agents.html +6 -6
- package/dist/docs/scaffolding-agents.md +2 -1
- package/dist/docs/skills/ab.html +6 -6
- package/dist/docs/skills/create-agent.html +8 -8
- package/dist/docs/skills/create-agent.md +1 -1
- package/dist/docs/skills/debug.html +6 -6
- package/dist/docs/skills/debug.md +1 -1
- package/dist/docs/skills/evals.html +8 -8
- package/dist/docs/skills/evals.md +1 -1
- package/dist/docs/skills/framework-map.html +6 -6
- package/dist/docs/skills/framework-map.md +4 -2
- package/dist/docs/skills/github.html +8 -8
- package/dist/docs/skills/github.md +1 -1
- package/dist/docs/skills/hillclimb.html +6 -6
- package/dist/docs/skills/index.html +5 -5
- package/dist/docs/skills/mcp-auth.html +6 -6
- package/dist/docs/skills/otel.html +8 -8
- package/dist/docs/skills/otel.md +3 -3
- package/dist/docs/skills/setup-slack.html +6 -6
- package/dist/docs/storage.html +6 -6
- package/dist/docs/templates/agentic-owners.html +6 -6
- package/dist/docs/templates/agents-md.html +6 -6
- package/dist/docs/templates/code-wiki.html +6 -6
- package/dist/docs/templates/demo.html +6 -6
- package/dist/docs/templates/grokbot-agents.html +6 -6
- package/dist/docs/templates/pr-autofixer.html +6 -6
- package/dist/docs/templates/security-help.html +6 -6
- package/dist/docs/templates/security-reviewer.html +6 -6
- package/dist/docs/templates/triage.html +6 -6
- package/dist/docs/troubleshooting.html +6 -6
- package/dist/docs/troubleshooting.md +1 -1
- package/dist/extensions/improve/extension.d.ts +46 -0
- package/dist/extensions/improve/extension.d.ts.map +1 -0
- package/dist/extensions/improve/extension.js +41 -0
- package/dist/extensions/improve/skills/yourself.d.ts +4 -0
- package/dist/extensions/improve/skills/yourself.d.ts.map +1 -0
- package/dist/extensions/improve/skills/yourself.js +43 -0
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/internal/builtin-tools/artifacts.d.ts.map +1 -1
- package/dist/internal/builtin-tools/artifacts.js +2 -3
- package/dist/internal/channel-route-dispatch.d.ts +13 -0
- package/dist/internal/channel-route-dispatch.d.ts.map +1 -0
- package/dist/internal/channel-route-dispatch.js +62 -0
- package/dist/internal/channel-state.d.ts +17 -0
- package/dist/internal/channel-state.d.ts.map +1 -0
- package/dist/internal/channel-state.js +78 -0
- package/dist/internal/cli-ax.d.ts +7 -0
- package/dist/internal/cli-ax.d.ts.map +1 -1
- package/dist/internal/cli-ax.js +99 -1
- package/dist/internal/cli-cursor.d.ts.map +1 -1
- package/dist/internal/cli-cursor.js +2 -0
- package/dist/internal/cli-deploy.d.ts.map +1 -1
- package/dist/internal/cli-deploy.js +61 -25
- package/dist/internal/cli-mcp-oauth.d.ts.map +1 -1
- package/dist/internal/cli-mcp-oauth.js +15 -0
- package/dist/internal/cli-mcp.d.ts.map +1 -1
- package/dist/internal/cli-mcp.js +12 -0
- package/dist/internal/cli-slack.d.ts.map +1 -1
- package/dist/internal/cli-slack.js +8 -2
- package/dist/internal/cursor/backend-client.d.ts +25 -0
- package/dist/internal/cursor/backend-client.d.ts.map +1 -1
- package/dist/internal/cursor/backend-client.js +57 -2
- package/dist/internal/cursor/credentials.d.ts +8 -2
- package/dist/internal/cursor/credentials.d.ts.map +1 -1
- package/dist/internal/cursor/credentials.js +27 -5
- package/dist/internal/deploy-client.d.ts +35 -0
- package/dist/internal/deploy-client.d.ts.map +1 -1
- package/dist/internal/deploy-client.js +46 -0
- package/dist/internal/deploy-manifest.d.ts +26 -0
- package/dist/internal/deploy-manifest.d.ts.map +1 -1
- package/dist/internal/deploy-manifest.js +99 -13
- package/dist/internal/describe-error.d.ts +1 -0
- package/dist/internal/describe-error.d.ts.map +1 -1
- package/dist/internal/describe-error.js +25 -0
- package/dist/internal/discovery/agent.d.ts.map +1 -1
- package/dist/internal/discovery/agent.js +1 -0
- package/dist/internal/discovery/info.d.ts.map +1 -1
- package/dist/internal/discovery/info.js +7 -3
- package/dist/internal/discovery/modules.d.ts +1 -1
- package/dist/internal/discovery/modules.d.ts.map +1 -1
- package/dist/internal/discovery/modules.js +1 -0
- package/dist/internal/discovery/project.d.ts.map +1 -1
- package/dist/internal/discovery/project.js +3 -0
- package/dist/internal/discovery/reminders.d.ts +7 -0
- package/dist/internal/discovery/reminders.d.ts.map +1 -0
- package/dist/internal/discovery/reminders.js +65 -0
- package/dist/internal/discovery/subagent.js +1 -0
- package/dist/internal/distribution.d.ts +5 -0
- package/dist/internal/distribution.d.ts.map +1 -1
- package/dist/internal/distribution.js +17 -0
- package/dist/internal/framework-storage-selection.d.ts +14 -3
- package/dist/internal/framework-storage-selection.d.ts.map +1 -1
- package/dist/internal/framework-storage-selection.js +36 -6
- package/dist/internal/guest-network.d.ts +4 -10
- package/dist/internal/guest-network.d.ts.map +1 -1
- package/dist/internal/guest-network.js +44 -26
- package/dist/internal/hosted-admission-adapter.d.ts +2 -0
- package/dist/internal/hosted-admission-adapter.d.ts.map +1 -1
- package/dist/internal/hosted-catch-protocol.d.ts +51 -0
- package/dist/internal/hosted-catch-protocol.d.ts.map +1 -0
- package/dist/internal/hosted-catch-protocol.js +103 -0
- package/dist/internal/hosted-catch.d.ts +40 -0
- package/dist/internal/hosted-catch.d.ts.map +1 -0
- package/dist/internal/hosted-catch.js +149 -0
- package/dist/internal/hosted-delivery-protocol.d.ts +89 -0
- package/dist/internal/hosted-delivery-protocol.d.ts.map +1 -1
- package/dist/internal/hosted-delivery-protocol.js +309 -0
- package/dist/internal/hosted-delivery.d.ts +20 -1
- package/dist/internal/hosted-delivery.d.ts.map +1 -1
- package/dist/internal/hosted-delivery.js +179 -36
- package/dist/internal/hosted-execution-diag.d.ts +4 -1
- package/dist/internal/hosted-execution-diag.d.ts.map +1 -1
- package/dist/internal/hosted-execution-diag.js +13 -4
- package/dist/internal/hosted-execution-flush.d.ts +3 -0
- package/dist/internal/hosted-execution-flush.d.ts.map +1 -1
- package/dist/internal/hosted-execution-flush.js +2 -4
- package/dist/internal/http-control-plane-session.d.ts +30 -0
- package/dist/internal/http-control-plane-session.d.ts.map +1 -0
- package/dist/internal/http-control-plane-session.js +83 -0
- package/dist/internal/legacy-command-guard.d.ts +22 -0
- package/dist/internal/legacy-command-guard.d.ts.map +1 -0
- package/dist/internal/legacy-command-guard.js +51 -0
- package/dist/internal/local-control-plane.d.ts +18 -2
- package/dist/internal/local-control-plane.d.ts.map +1 -1
- package/dist/internal/local-control-plane.js +199 -17
- package/dist/internal/platform-timers.d.ts +7 -0
- package/dist/internal/platform-timers.d.ts.map +1 -1
- package/dist/internal/platform-timers.js +139 -0
- package/dist/internal/reminder-control-plane-protocol.d.ts +189 -0
- package/dist/internal/reminder-control-plane-protocol.d.ts.map +1 -0
- package/dist/internal/reminder-control-plane-protocol.js +251 -0
- package/dist/internal/reminder-runner.d.ts +56 -6
- package/dist/internal/reminder-runner.d.ts.map +1 -1
- package/dist/internal/reminder-runner.js +372 -57
- package/dist/internal/reminder-schedule.d.ts +5 -2
- package/dist/internal/reminder-schedule.d.ts.map +1 -1
- package/dist/internal/reminder-schedule.js +8 -6
- package/dist/internal/reminder-store.d.ts +24 -7
- package/dist/internal/reminder-store.d.ts.map +1 -1
- package/dist/internal/reminder-store.js +6 -5
- package/dist/internal/request-error-status.d.ts +2 -0
- package/dist/internal/request-error-status.d.ts.map +1 -1
- package/dist/internal/request-error-status.js +22 -3
- package/dist/internal/resolve-prod-target.d.ts +2 -0
- package/dist/internal/resolve-prod-target.d.ts.map +1 -1
- package/dist/internal/resolve-prod-target.js +13 -0
- package/dist/internal/scm/pr-url.d.ts +40 -0
- package/dist/internal/scm/pr-url.d.ts.map +1 -1
- package/dist/internal/scm/pr-url.js +93 -14
- package/dist/internal/sdk-runner.d.ts.map +1 -1
- package/dist/internal/sdk-runner.js +4 -3
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +118 -77
- package/dist/internal/session-engine.d.ts +6 -6
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +100 -67
- package/dist/playground/assets/{index-BaQzjaNK.js → index-BMDqAeXu.js} +34 -34
- package/dist/playground/assets/index-LUgJoWdL.css +1 -0
- package/dist/playground/index.html +2 -2
- package/dist/reminders.d.ts +24 -5
- package/dist/reminders.d.ts.map +1 -1
- package/dist/reminders.js +28 -5
- package/dist/storage-backends/cursor-hosted.d.ts +6 -0
- package/dist/storage-backends/cursor-hosted.d.ts.map +1 -1
- package/dist/storage-backends/cursor-hosted.js +29 -1
- package/dist/types.d.ts +122 -25
- package/dist/types.d.ts.map +1 -1
- package/docs/README.md +4 -0
- package/docs/deployment.md +7 -2
- package/docs/evals.md +3 -2
- package/docs/guides/cloud-agents.md +4 -3
- package/docs/guides/github.md +2 -1
- package/docs/guides/grokbot-agents.md +2 -2
- package/docs/guides/improve.md +96 -0
- package/docs/guides/opentelemetry.md +3 -4
- package/docs/guides/slack.md +2 -1
- package/docs/reference/agent-config.md +5 -2
- package/docs/reference/channels.md +11 -19
- package/docs/reference/cli.md +23 -13
- package/docs/reference/connections.md +2 -1
- package/docs/reference/extensions.md +2 -0
- package/docs/scaffolding-agents.md +2 -1
- package/docs/troubleshooting.md +1 -1
- package/package.json +10 -3
- package/skills/create-agent/SKILL.md +1 -1
- package/skills/debug/SKILL.md +1 -1
- package/skills/evals/SKILL.md +1 -1
- package/skills/framework-map/SKILL.md +4 -2
- package/skills/github/SKILL.md +1 -1
- package/skills/otel/SKILL.md +3 -3
- package/src/bin/agent-serve.ts +28 -11
- package/src/channels/bitbucket/types.ts +2 -4
- package/src/channels/deployments/types.ts +5 -8
- package/src/channels/github/github-channel.ts +8 -8
- package/src/channels/github/types.ts +7 -4
- package/src/channels/gitlab/types.ts +2 -5
- package/src/channels/origin/origin-channel.ts +29 -13
- package/src/channels/origin/types.ts +7 -3
- package/src/channels/slack/defaults.ts +3 -0
- package/src/channels/slack/dispatch.ts +1 -0
- package/src/channels/slack/live-delivery.ts +53 -12
- package/src/channels/slack/types.ts +4 -3
- package/src/channels.ts +157 -10
- package/src/connections.ts +2 -1
- package/src/extensions/improve/extension.ts +70 -0
- package/src/extensions/improve/skills/yourself.ts +50 -0
- package/src/index.ts +6 -3
- package/src/internal/builtin-tools/artifacts.ts +2 -3
- package/src/internal/channel-route-dispatch.ts +66 -0
- package/src/internal/channel-state.ts +96 -0
- package/src/internal/cli-ax.ts +110 -1
- package/src/internal/cli-cursor.ts +4 -1
- package/src/internal/cli-deploy.ts +80 -22
- package/src/internal/cli-mcp-oauth.ts +18 -0
- package/src/internal/cli-mcp.ts +11 -0
- package/src/internal/cli-slack.ts +15 -2
- package/src/internal/cursor/backend-client.ts +90 -2
- package/src/internal/cursor/credentials.ts +35 -7
- package/src/internal/deploy-client.ts +70 -0
- package/src/internal/deploy-manifest.ts +131 -12
- package/src/internal/describe-error.ts +28 -0
- package/src/internal/discovery/agent.ts +1 -0
- package/src/internal/discovery/info.ts +6 -0
- package/src/internal/discovery/modules.ts +2 -4
- package/src/internal/discovery/project.ts +3 -0
- package/src/internal/discovery/reminders.ts +65 -0
- package/src/internal/discovery/subagent.ts +1 -0
- package/src/internal/distribution.ts +20 -0
- package/src/internal/framework-storage-selection.ts +43 -6
- package/src/internal/guest-network.ts +46 -29
- package/src/internal/hosted-admission-adapter.ts +2 -0
- package/src/internal/hosted-catch-protocol.ts +130 -0
- package/src/internal/hosted-catch.ts +192 -0
- package/src/internal/hosted-delivery-protocol.ts +483 -0
- package/src/internal/hosted-delivery.ts +303 -43
- package/src/internal/hosted-execution-diag.ts +21 -3
- package/src/internal/hosted-execution-flush.ts +6 -3
- package/src/internal/http-control-plane-session.ts +104 -0
- package/src/internal/legacy-command-guard.ts +59 -0
- package/src/internal/local-control-plane.ts +281 -22
- package/src/internal/platform-timers.ts +191 -0
- package/src/internal/reminder-control-plane-protocol.ts +512 -0
- package/src/internal/reminder-runner.ts +481 -57
- package/src/internal/reminder-schedule.ts +11 -6
- package/src/internal/reminder-store.ts +27 -7
- package/src/internal/request-error-status.ts +27 -3
- package/src/internal/resolve-prod-target.ts +15 -0
- package/src/internal/scm/pr-url.ts +167 -20
- package/src/internal/sdk-runner.ts +2 -1
- package/src/internal/server.ts +151 -88
- package/src/internal/session-engine.ts +146 -83
- package/src/reminders.ts +35 -4
- package/src/storage-backends/cursor-hosted.ts +40 -1
- package/src/types.ts +134 -26
- package/dist/docs/assets/chunks/@localSearchIndexroot.CJxMklAy.js +0 -1
- package/dist/docs/assets/guides_cloud-agents.md.DS8RIjwx.js +0 -9
- package/dist/docs/assets/index.md.BW_6tOgR.js +0 -5
- package/dist/docs/assets/skills_framework-map.md.haibFyoB.js +0 -1
- package/dist/docs/assets/troubleshooting.md.Cus_YZga.js +0 -1
- package/dist/playground/assets/index-CceqnLTX.css +0 -1
- /package/dist/docs/assets/{evals.md.CbMoebP1.lean.js → evals.md.C1ekS3k2.lean.js} +0 -0
- /package/dist/docs/assets/{guides_github.md.c0gdGJ-D.lean.js → guides_github.md.BH33UEBJ.lean.js} +0 -0
- /package/dist/docs/assets/{guides_grokbot-agents.md.DVqdhBKb.lean.js → guides_grokbot-agents.md.DyV-WArv.lean.js} +0 -0
- /package/dist/docs/assets/{index.md.BW_6tOgR.lean.js → index.md.BjH1w2ZW.lean.js} +0 -0
- /package/dist/docs/assets/{reference_agent-config.md.CHNpiyp4.lean.js → reference_agent-config.md.CvoL6pof.lean.js} +0 -0
- /package/dist/docs/assets/{reference_connections.md.Di6jJAXF.lean.js → reference_connections.md.BojkC6c5.lean.js} +0 -0
- /package/dist/docs/assets/{reference_extensions.md.CGmMLblt.lean.js → reference_extensions.md.CPWt00ds.lean.js} +0 -0
- /package/dist/docs/assets/{scaffolding-agents.md.em43xlY1.lean.js → scaffolding-agents.md.Kctn3OVb.lean.js} +0 -0
- /package/dist/docs/assets/{skills_create-agent.md.BVoWPcan.lean.js → skills_create-agent.md.Q3h6Je-e.lean.js} +0 -0
- /package/dist/docs/assets/{skills_evals.md.723kpUmA.lean.js → skills_evals.md.BhovOvrl.lean.js} +0 -0
- /package/dist/docs/assets/{skills_github.md.D0JahM8c.lean.js → skills_github.md.hgFX_oKY.lean.js} +0 -0
- /package/dist/docs/assets/{skills_otel.md.CqhobH3B.lean.js → skills_otel.md.B5Ddv1xH.lean.js} +0 -0
- /package/dist/docs/assets/{troubleshooting.md.Cus_YZga.lean.js → troubleshooting.md.CYEAO9bM.lean.js} +0 -0
|
@@ -36,11 +36,12 @@ import { ApprovalGate } from "./approval-gate.js";
|
|
|
36
36
|
import { ArtifactsStore } from "./artifacts-store.js";
|
|
37
37
|
import { assertTimeArgs, normalizeAsOf, schemaTimeWindowKeys, sessionClock, } from "./as-of.js";
|
|
38
38
|
import { SessionAuthError, samePrincipal } from "./auth.js";
|
|
39
|
+
import { mergeChannelStateMutation, mergeChannelStateSkipNull, } from "./channel-state.js";
|
|
39
40
|
import { mergeCloudOptions, resolveSessionRuntime } from "./cloud-merge.js";
|
|
40
41
|
import { applyCloudUsageToEvents, cloudSdkAgentIdFromEvents, isUnpricedCompletedTurn, mapSdkTokenUsage, } from "./cloud-turn-cost.js";
|
|
41
42
|
import { applyAgentContinuationDefaults, channelContinuationIdentity, httpContinuationIdentity, } from "./continuation-channel.js";
|
|
42
43
|
import { continuationSource, resolveV2Key, V2EngineError, } from "./continuation-identity.js";
|
|
43
|
-
import { describeError } from "./describe-error.js";
|
|
44
|
+
import { describeError, describeErrorCode } from "./describe-error.js";
|
|
44
45
|
import { isDevMode } from "./dev-mode.js";
|
|
45
46
|
import { EventLogStore } from "./event-log.js";
|
|
46
47
|
import { TurnEventMapper } from "./event-mapper.js";
|
|
@@ -52,6 +53,7 @@ import { createHostKvApi } from "./host-kv.js";
|
|
|
52
53
|
import { createHostOtelApi } from "./host-otel.js";
|
|
53
54
|
import { createHostPlatforms, createHostSlackClient, } from "./host-platforms.js";
|
|
54
55
|
import { HostedAdmissionLocalSendError, isDuringHostedAdmission, } from "./hosted-admission-context.js";
|
|
56
|
+
import { hostedSessionResumeKey } from "./hosted-catch-protocol.js";
|
|
55
57
|
import { formatContinuationToken, newContinuationKey, newSessionId, newToolCallId, parseContinuationToken, } from "./ids.js";
|
|
56
58
|
import { validateToolInput } from "./json-schema.js";
|
|
57
59
|
import { isMcpNeedsAuthError, McpHost } from "./mcp-host.js";
|
|
@@ -75,6 +77,7 @@ import { resolveAgentV2Hosting } from "./v2-hosting.js";
|
|
|
75
77
|
import { buildAgentsMdContent, buildCloudMemorySection, buildCloudSessionWorkspaceSection, buildCloudWorkspaceSection, ensureOwnGitRoot, isNestedInGitRepo, materializeWorkspace, SERVER_TOOLS_MCP_SERVER_NAME, } from "./workspace.js";
|
|
76
78
|
import { syncSessionWorkspaceFiles, syncWorkspaceToStore, WorkspaceFileRefusal, wipeSessionWorkspace, } from "./workspace-sync.js";
|
|
77
79
|
export const HTTP_CHANNEL_ID = "http";
|
|
80
|
+
export { mergeChannelStateSkipNull } from "./channel-state.js";
|
|
78
81
|
export { SCHEDULE_CHANNEL_PREFIX } from "./prompt-context.js";
|
|
79
82
|
export class SessionBusyError extends Error {
|
|
80
83
|
constructor(sessionId) {
|
|
@@ -570,8 +573,8 @@ export class SessionEngine {
|
|
|
570
573
|
*/
|
|
571
574
|
send(channelId_1, message_1) {
|
|
572
575
|
return __awaiter(this, arguments, void 0, function* (channelId, message, options = {}) {
|
|
573
|
-
var _a;
|
|
574
|
-
var
|
|
576
|
+
var _a, _b;
|
|
577
|
+
var _c, _d, _e, _f, _g, _h;
|
|
575
578
|
if (isDuringHostedAdmission()) {
|
|
576
579
|
// Only sends that bypassed the admission capture stub (typically a
|
|
577
580
|
// startup-captured `onStart` send) reach the engine inside the
|
|
@@ -592,7 +595,7 @@ export class SessionEngine {
|
|
|
592
595
|
sendOptions = Object.assign(Object.assign({}, options), { continuationToken: cKey });
|
|
593
596
|
skipContinuationLookup = cKey.startsWith("evt:");
|
|
594
597
|
}
|
|
595
|
-
const auth = (
|
|
598
|
+
const auth = (_c = sendOptions.auth) !== null && _c !== void 0 ? _c : null;
|
|
596
599
|
let existing = skipContinuationLookup || sendOptions.continuationToken === undefined
|
|
597
600
|
? undefined
|
|
598
601
|
: yield this.sessions.findByContinuation(channelId, sendOptions.continuationToken);
|
|
@@ -603,6 +606,16 @@ export class SessionEngine {
|
|
|
603
606
|
// fell outside the startup restore window, or restore is lazy-only).
|
|
604
607
|
existing = yield this.restoreSessionByContinuation(channelId, sendOptions.continuationToken);
|
|
605
608
|
}
|
|
609
|
+
if (existing === undefined &&
|
|
610
|
+
sendOptions.hostedSessionId !== undefined &&
|
|
611
|
+
((_a = sendOptions.mailboxContinuation) === null || _a === void 0 ? void 0 : _a.key) ===
|
|
612
|
+
hostedSessionResumeKey(sendOptions.hostedSessionId)) {
|
|
613
|
+
// Explicit control-plane resume of an existing session: the CP named
|
|
614
|
+
// the session by its own id and stamped the matching resume key. The
|
|
615
|
+
// session keeps its original continuation key (a PR lane must stay
|
|
616
|
+
// addressable by its webhooks); this is a follow-up turn by id.
|
|
617
|
+
existing = yield this.getOrRestoreSession(sendOptions.hostedSessionId);
|
|
618
|
+
}
|
|
606
619
|
if (existing !== undefined) {
|
|
607
620
|
if (sendOptions.hostedSessionId !== undefined &&
|
|
608
621
|
existing.sessionId !== sendOptions.hostedSessionId) {
|
|
@@ -638,7 +651,7 @@ export class SessionEngine {
|
|
|
638
651
|
record = yield this.updateRecord(record.sessionId, (current) => (Object.assign(Object.assign({}, current), { channelState: mergeChannelStateSkipNull(current.channelState, sendOptions.refreshState) })));
|
|
639
652
|
}
|
|
640
653
|
const since = (yield this.logs.get(record.sessionId)).count;
|
|
641
|
-
const coalesced = yield this.startTurn(record.sessionId, message, Object.assign({ admission: (
|
|
654
|
+
const coalesced = yield this.startTurn(record.sessionId, message, Object.assign({ admission: (_d = sendOptions.admission) !== null && _d !== void 0 ? _d : "preempt" }, (sendOptions.coalesceSourceTs === undefined
|
|
642
655
|
? {}
|
|
643
656
|
: { sourceTs: sendOptions.coalesceSourceTs })));
|
|
644
657
|
return this.channelSession(record.sessionId, record, false, coalesced, since);
|
|
@@ -655,13 +668,13 @@ export class SessionEngine {
|
|
|
655
668
|
const frozenAsOf = normalizeAsOf(sendOptions.asOf);
|
|
656
669
|
assertTimeArgs(this.project.agent.tools, frozenAsOf);
|
|
657
670
|
let record = {
|
|
658
|
-
sessionId: (
|
|
671
|
+
sessionId: (_e = sendOptions.hostedSessionId) !== null && _e !== void 0 ? _e : newSessionId(),
|
|
659
672
|
channelId,
|
|
660
|
-
mode: (
|
|
673
|
+
mode: (_f = sendOptions.mode) !== null && _f !== void 0 ? _f : "chat",
|
|
661
674
|
purpose,
|
|
662
675
|
dryRun: sendOptions.dryRun === true ? true : undefined,
|
|
663
676
|
asOf: frozenAsOf,
|
|
664
|
-
continuationKey: (
|
|
677
|
+
continuationKey: (_g = sendOptions.continuationToken) !== null && _g !== void 0 ? _g : newContinuationKey(),
|
|
665
678
|
auth,
|
|
666
679
|
title: sendOptions.title,
|
|
667
680
|
channelState,
|
|
@@ -675,7 +688,7 @@ export class SessionEngine {
|
|
|
675
688
|
updatedAt: now,
|
|
676
689
|
};
|
|
677
690
|
yield this.sessions.save(record);
|
|
678
|
-
(
|
|
691
|
+
(_b = this.storage) === null || _b === void 0 ? void 0 : _b.sessionRecord(record);
|
|
679
692
|
yield this.appendEvent(record.sessionId, {
|
|
680
693
|
type: "session.started",
|
|
681
694
|
data: {
|
|
@@ -685,7 +698,7 @@ export class SessionEngine {
|
|
|
685
698
|
});
|
|
686
699
|
record = yield this.enrollABs(record);
|
|
687
700
|
const since = (yield this.logs.get(record.sessionId)).count;
|
|
688
|
-
yield this.startTurn(record.sessionId, message, Object.assign({ admission: (
|
|
701
|
+
yield this.startTurn(record.sessionId, message, Object.assign({ admission: (_h = sendOptions.admission) !== null && _h !== void 0 ? _h : "preempt" }, (sendOptions.coalesceSourceTs === undefined
|
|
689
702
|
? {}
|
|
690
703
|
: { sourceTs: sendOptions.coalesceSourceTs })));
|
|
691
704
|
return this.channelSession(record.sessionId, record, true, false, since);
|
|
@@ -1118,11 +1131,17 @@ export class SessionEngine {
|
|
|
1118
1131
|
poll.unref();
|
|
1119
1132
|
try {
|
|
1120
1133
|
outcome = yield this.executeTurn(record, turnId, message, isFirstTurn, abort.signal);
|
|
1134
|
+
if (outcome.status === "cancelled") {
|
|
1135
|
+
outcome.cancellationReason = abort.signal.aborted
|
|
1136
|
+
? "signal"
|
|
1137
|
+
: "runner";
|
|
1138
|
+
}
|
|
1121
1139
|
}
|
|
1122
1140
|
catch (error) {
|
|
1123
1141
|
outcome = {
|
|
1124
1142
|
status: "error",
|
|
1125
1143
|
errorMessage: describeError(error),
|
|
1144
|
+
errorCode: describeErrorCode(error),
|
|
1126
1145
|
};
|
|
1127
1146
|
}
|
|
1128
1147
|
finally {
|
|
@@ -1562,10 +1581,15 @@ export class SessionEngine {
|
|
|
1562
1581
|
}
|
|
1563
1582
|
executeTurn(record, turnId, message, isFirstTurn, signal) {
|
|
1564
1583
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1565
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1584
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1566
1585
|
const sessionId = record.sessionId;
|
|
1567
1586
|
const workspaceDir = this.scaffoldDir(record);
|
|
1568
1587
|
const harnessCwd = this.harnessCwd(record);
|
|
1588
|
+
const turnChannelState = structuredClone((_a = record.channelState) !== null && _a !== void 0 ? _a : null);
|
|
1589
|
+
const eventContext = {
|
|
1590
|
+
channelState: structuredClone(turnChannelState),
|
|
1591
|
+
session: this.sessionInfo(record),
|
|
1592
|
+
};
|
|
1569
1593
|
// Hold the open log so tool events append synchronously. Fire-and-forget
|
|
1570
1594
|
// `appendEvent` races parallel tool completions and delays the live stream
|
|
1571
1595
|
// until the next await tick — often after *all* parallel tools finish.
|
|
@@ -1573,7 +1597,7 @@ export class SessionEngine {
|
|
|
1573
1597
|
const emit = (payload) => {
|
|
1574
1598
|
try {
|
|
1575
1599
|
const event = log.append(Object.assign(Object.assign({}, payload), { turnId }));
|
|
1576
|
-
this.queueDispatch(sessionId, event);
|
|
1600
|
+
this.queueDispatch(sessionId, event, eventContext);
|
|
1577
1601
|
}
|
|
1578
1602
|
catch (error) {
|
|
1579
1603
|
this.logger(`[agent-sdk] failed to record event for ${sessionId}: ${describeError(error)}`);
|
|
@@ -1640,7 +1664,7 @@ export class SessionEngine {
|
|
|
1640
1664
|
if (hasPendingFiles && runtime !== "cloud") {
|
|
1641
1665
|
const root = yield this.resolveFileSystem({
|
|
1642
1666
|
sessionId,
|
|
1643
|
-
continuationKey: (
|
|
1667
|
+
continuationKey: (_b = record.continuationKey) !== null && _b !== void 0 ? _b : undefined,
|
|
1644
1668
|
cache: true,
|
|
1645
1669
|
cwd: harnessCwd,
|
|
1646
1670
|
});
|
|
@@ -1664,7 +1688,7 @@ export class SessionEngine {
|
|
|
1664
1688
|
const instructionsInvisibleToHarness = isFirstTurn &&
|
|
1665
1689
|
(this.hasBorrowedWorkspace(record) ||
|
|
1666
1690
|
(yield isNestedInGitRepo(harnessCwd)));
|
|
1667
|
-
const request = yield this.buildTurnRequest(record, agent, turnId, message, isFirstTurn, instructionsInvisibleToHarness, emit, (update) => __awaiter(this, void 0, void 0, function* () {
|
|
1691
|
+
const request = yield this.buildTurnRequest(record, agent, turnId, message, isFirstTurn, instructionsInvisibleToHarness, emit, eventContext, (update) => __awaiter(this, void 0, void 0, function* () {
|
|
1668
1692
|
const turn = this.turnRoots.get(sessionId);
|
|
1669
1693
|
if (turn !== undefined) {
|
|
1670
1694
|
update = yield applyWebScratchUpdate({
|
|
@@ -1700,7 +1724,11 @@ export class SessionEngine {
|
|
|
1700
1724
|
catch (error) {
|
|
1701
1725
|
this.approvals.cancelSession(sessionId, "deny");
|
|
1702
1726
|
this.auths.cancelSession(sessionId, "deny");
|
|
1703
|
-
outcome = {
|
|
1727
|
+
outcome = {
|
|
1728
|
+
status: "error",
|
|
1729
|
+
errorMessage: describeError(error),
|
|
1730
|
+
errorCode: describeErrorCode(error),
|
|
1731
|
+
};
|
|
1704
1732
|
}
|
|
1705
1733
|
finally {
|
|
1706
1734
|
permit.release();
|
|
@@ -1718,16 +1746,17 @@ export class SessionEngine {
|
|
|
1718
1746
|
if (mapper.title !== undefined) {
|
|
1719
1747
|
const title = mapper.title;
|
|
1720
1748
|
yield this.updateRecord(sessionId, (current) => (Object.assign(Object.assign({}, current), { title })));
|
|
1749
|
+
eventContext.session = Object.assign(Object.assign({}, eventContext.session), { title });
|
|
1721
1750
|
}
|
|
1722
|
-
const finalResult = (
|
|
1723
|
-
const finalUsage = (
|
|
1751
|
+
const finalResult = (_c = outcome.result) !== null && _c !== void 0 ? _c : mapper.finalText;
|
|
1752
|
+
const finalUsage = (_d = outcome.usage) !== null && _d !== void 0 ? _d : mapper.usage;
|
|
1724
1753
|
const finalCost = finalUsage === undefined
|
|
1725
1754
|
? undefined
|
|
1726
1755
|
: yield this.estimateTurnCost({
|
|
1727
|
-
model: (
|
|
1756
|
+
model: (_e = this.project.agent.model) !== null && _e !== void 0 ? _e : DEFAULT_MODEL,
|
|
1728
1757
|
usage: finalUsage,
|
|
1729
1758
|
agentId: record.sdkAgentId,
|
|
1730
|
-
conversationId: (
|
|
1759
|
+
conversationId: (_f = record.sdkAgentId) !== null && _f !== void 0 ? _f : sessionId,
|
|
1731
1760
|
});
|
|
1732
1761
|
if (finalCost !== undefined) {
|
|
1733
1762
|
outcome = Object.assign(Object.assign({}, outcome), { cost: finalCost });
|
|
@@ -1739,7 +1768,8 @@ export class SessionEngine {
|
|
|
1739
1768
|
text: finalResult,
|
|
1740
1769
|
dryRun: record.dryRun === true,
|
|
1741
1770
|
ctx: {
|
|
1742
|
-
session:
|
|
1771
|
+
session: eventContext.session,
|
|
1772
|
+
channelState: turnChannelState,
|
|
1743
1773
|
host: this.hostForSession(sessionId),
|
|
1744
1774
|
artifacts: this.artifactsApi({ sessionId, turnId }),
|
|
1745
1775
|
stateRoot: this.stateRoot,
|
|
@@ -1765,7 +1795,7 @@ export class SessionEngine {
|
|
|
1765
1795
|
usage: finalUsage,
|
|
1766
1796
|
cost: finalCost,
|
|
1767
1797
|
},
|
|
1768
|
-
});
|
|
1798
|
+
}, eventContext);
|
|
1769
1799
|
}
|
|
1770
1800
|
else {
|
|
1771
1801
|
const interrupted = signal.aborted && outcome.status === "cancelled";
|
|
@@ -1773,24 +1803,25 @@ export class SessionEngine {
|
|
|
1773
1803
|
type: "turn.failed",
|
|
1774
1804
|
turnId,
|
|
1775
1805
|
data: {
|
|
1806
|
+
status: outcome.status,
|
|
1776
1807
|
message: interrupted
|
|
1777
1808
|
? "turn interrupted"
|
|
1778
|
-
: ((
|
|
1809
|
+
: ((_g = outcome.errorMessage) !== null && _g !== void 0 ? _g : (outcome.status === "cancelled"
|
|
1779
1810
|
? "turn cancelled"
|
|
1780
1811
|
: "turn failed")),
|
|
1781
1812
|
},
|
|
1782
|
-
});
|
|
1813
|
+
}, eventContext);
|
|
1783
1814
|
}
|
|
1784
1815
|
const current = yield this.sessions.get(sessionId);
|
|
1785
|
-
const mode = (
|
|
1816
|
+
const mode = (_h = current === null || current === void 0 ? void 0 : current.mode) !== null && _h !== void 0 ? _h : record.mode;
|
|
1786
1817
|
if (mode === "task") {
|
|
1787
1818
|
yield this.appendEvent(sessionId, outcome.status === "finished"
|
|
1788
1819
|
? { type: "session.completed", turnId, data: {} }
|
|
1789
1820
|
: {
|
|
1790
1821
|
type: "session.failed",
|
|
1791
1822
|
turnId,
|
|
1792
|
-
data: { message: (
|
|
1793
|
-
});
|
|
1823
|
+
data: { message: (_j = outcome.errorMessage) !== null && _j !== void 0 ? _j : "task failed" },
|
|
1824
|
+
}, eventContext);
|
|
1794
1825
|
yield this.wipeCloudSessionWorkspace(sessionId);
|
|
1795
1826
|
}
|
|
1796
1827
|
else {
|
|
@@ -1798,7 +1829,7 @@ export class SessionEngine {
|
|
|
1798
1829
|
type: "session.waiting",
|
|
1799
1830
|
turnId,
|
|
1800
1831
|
data: {},
|
|
1801
|
-
});
|
|
1832
|
+
}, eventContext);
|
|
1802
1833
|
}
|
|
1803
1834
|
return Object.assign(Object.assign({}, outcome), { result: finalResult, usage: finalUsage });
|
|
1804
1835
|
});
|
|
@@ -1952,7 +1983,7 @@ export class SessionEngine {
|
|
|
1952
1983
|
}
|
|
1953
1984
|
return undefined;
|
|
1954
1985
|
}
|
|
1955
|
-
buildTurnRequest(record, agent, turnId, prompt, isFirstTurn, instructionsInvisibleToHarness, emit, onUpdate, signal, images) {
|
|
1986
|
+
buildTurnRequest(record, agent, turnId, prompt, isFirstTurn, instructionsInvisibleToHarness, emit, eventContext, onUpdate, signal, images) {
|
|
1956
1987
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1957
1988
|
var _a, _b, _c;
|
|
1958
1989
|
var _d;
|
|
@@ -2157,13 +2188,14 @@ export class SessionEngine {
|
|
|
2157
2188
|
}
|
|
2158
2189
|
yield this.updateRecord(record.sessionId, (current) => (Object.assign(Object.assign({}, current), { sdkAgentId })));
|
|
2159
2190
|
record.sdkAgentId = sdkAgentId;
|
|
2191
|
+
eventContext.session = Object.assign(Object.assign({}, eventContext.session), { sdkAgentId });
|
|
2160
2192
|
yield this.appendEvent(record.sessionId, {
|
|
2161
2193
|
type: "agent.bound",
|
|
2162
2194
|
turnId,
|
|
2163
2195
|
data: Object.assign({ sdkAgentId }, (sdkAgentId.startsWith("bc-")
|
|
2164
2196
|
? { url: `https://cursor.com/agents/${sdkAgentId}` }
|
|
2165
2197
|
: {})),
|
|
2166
|
-
});
|
|
2198
|
+
}, eventContext);
|
|
2167
2199
|
}) });
|
|
2168
2200
|
});
|
|
2169
2201
|
}
|
|
@@ -3389,15 +3421,15 @@ export class SessionEngine {
|
|
|
3389
3421
|
// ==========================================================================
|
|
3390
3422
|
// Events: append, dispatch to channel handlers + hooks
|
|
3391
3423
|
// ==========================================================================
|
|
3392
|
-
appendEvent(sessionId, payload) {
|
|
3424
|
+
appendEvent(sessionId, payload, context) {
|
|
3393
3425
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3394
3426
|
const log = yield this.logs.get(sessionId);
|
|
3395
3427
|
const event = log.append(payload);
|
|
3396
|
-
this.queueDispatch(sessionId, event);
|
|
3428
|
+
this.queueDispatch(sessionId, event, context);
|
|
3397
3429
|
return event;
|
|
3398
3430
|
});
|
|
3399
3431
|
}
|
|
3400
|
-
queueDispatch(sessionId, event) {
|
|
3432
|
+
queueDispatch(sessionId, event, context) {
|
|
3401
3433
|
var _a;
|
|
3402
3434
|
var _b;
|
|
3403
3435
|
// Single funnel for both append paths (appendEvent + the held-log emit),
|
|
@@ -3405,7 +3437,7 @@ export class SessionEngine {
|
|
|
3405
3437
|
(_a = this.storage) === null || _a === void 0 ? void 0 : _a.event(event);
|
|
3406
3438
|
const chain = (_b = this.dispatchChains.get(sessionId)) !== null && _b !== void 0 ? _b : Promise.resolve();
|
|
3407
3439
|
const next = chain
|
|
3408
|
-
.then(() => this.dispatchEvent(sessionId, event))
|
|
3440
|
+
.then(() => this.dispatchEvent(sessionId, event, context))
|
|
3409
3441
|
.catch((error) => {
|
|
3410
3442
|
this.logger(`[agent-sdk] event dispatch failed for ${sessionId}: ${describeError(error)}`);
|
|
3411
3443
|
})
|
|
@@ -3418,17 +3450,25 @@ export class SessionEngine {
|
|
|
3418
3450
|
});
|
|
3419
3451
|
this.dispatchChains.set(sessionId, next);
|
|
3420
3452
|
}
|
|
3421
|
-
dispatchEvent(sessionId, event) {
|
|
3453
|
+
dispatchEvent(sessionId, event, context) {
|
|
3422
3454
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3423
3455
|
var _a;
|
|
3424
|
-
var _b;
|
|
3456
|
+
var _b, _c;
|
|
3425
3457
|
const record = yield this.sessions.get(sessionId);
|
|
3426
3458
|
if (record === undefined) {
|
|
3427
3459
|
return;
|
|
3428
3460
|
}
|
|
3461
|
+
const channelState = context === undefined
|
|
3462
|
+
? ((_b = record.channelState) !== null && _b !== void 0 ? _b : null)
|
|
3463
|
+
: context.channelState;
|
|
3464
|
+
const channelStateBefore = context === undefined ? undefined : structuredClone(channelState);
|
|
3429
3465
|
const sessionCtx = {
|
|
3430
|
-
session: this.sessionInfo(record),
|
|
3466
|
+
session: (_c = context === null || context === void 0 ? void 0 : context.session) !== null && _c !== void 0 ? _c : this.sessionInfo(record),
|
|
3431
3467
|
host: this.hostForSession(record.sessionId),
|
|
3468
|
+
artifacts: this.artifactsApi({
|
|
3469
|
+
sessionId: record.sessionId,
|
|
3470
|
+
turnId: event.turnId,
|
|
3471
|
+
}),
|
|
3432
3472
|
};
|
|
3433
3473
|
const channelEvents = this.channelEventHandlersFor(record.channelId);
|
|
3434
3474
|
if (channelEvents !== undefined) {
|
|
@@ -3440,7 +3480,7 @@ export class SessionEngine {
|
|
|
3440
3480
|
];
|
|
3441
3481
|
const channelCtx = {
|
|
3442
3482
|
channelId: record.channelId,
|
|
3443
|
-
state:
|
|
3483
|
+
state: channelState,
|
|
3444
3484
|
continuationToken: record.continuationKey,
|
|
3445
3485
|
setContinuationToken: (token) => this.setContinuationToken(sessionId, token),
|
|
3446
3486
|
};
|
|
@@ -3455,8 +3495,19 @@ export class SessionEngine {
|
|
|
3455
3495
|
this.logger(`[agent-sdk] channel "${record.channelId}" handler for ${event.type} threw: ${describeError(error)}`);
|
|
3456
3496
|
}
|
|
3457
3497
|
}
|
|
3458
|
-
|
|
3459
|
-
|
|
3498
|
+
if (context === undefined || channelStateBefore === undefined) {
|
|
3499
|
+
// Handlers mutate live channel state in place; save the current record.
|
|
3500
|
+
yield this.updateRecord(sessionId, (current) => (Object.assign({}, current)));
|
|
3501
|
+
}
|
|
3502
|
+
else {
|
|
3503
|
+
const updatedState = channelCtx.state;
|
|
3504
|
+
context.channelState = updatedState;
|
|
3505
|
+
yield this.updateRecord(sessionId, (current) => (Object.assign(Object.assign({}, current), { channelState: mergeChannelStateMutation({
|
|
3506
|
+
current: current.channelState,
|
|
3507
|
+
before: channelStateBefore,
|
|
3508
|
+
after: updatedState,
|
|
3509
|
+
}) })));
|
|
3510
|
+
}
|
|
3460
3511
|
}
|
|
3461
3512
|
for (const hook of this.project.hooks) {
|
|
3462
3513
|
const handlers = [
|
|
@@ -3471,10 +3522,7 @@ export class SessionEngine {
|
|
|
3471
3522
|
yield handler(event, Object.assign(Object.assign({}, sessionCtx), { agent: { name: this.project.name }, channel: {
|
|
3472
3523
|
id: record.channelId,
|
|
3473
3524
|
continuationToken: record.continuationKey,
|
|
3474
|
-
}, stateRoot: this.stateRoot
|
|
3475
|
-
sessionId: record.sessionId,
|
|
3476
|
-
turnId: event.turnId,
|
|
3477
|
-
}) }));
|
|
3525
|
+
}, stateRoot: this.stateRoot }));
|
|
3478
3526
|
}
|
|
3479
3527
|
catch (error) {
|
|
3480
3528
|
this.logger(`[agent-sdk] hook "${hook.name}" handler for ${event.type} threw: ${describeError(error)}`);
|
|
@@ -3507,6 +3555,10 @@ export class SessionEngine {
|
|
|
3507
3555
|
* conversation whose blobs persisted but whose record (which selects the
|
|
3508
3556
|
* conversation to hydrate) never reached the sink. No-op without a
|
|
3509
3557
|
* storage mirror.
|
|
3558
|
+
*
|
|
3559
|
+
* Under a debounced event policy the turn-end flush is a timer, not the
|
|
3560
|
+
* chain's tail, so flush explicitly before waiting on the queue; a no-op
|
|
3561
|
+
* when the chain already flushed.
|
|
3510
3562
|
*/
|
|
3511
3563
|
drainSessionDurability(sessionId) {
|
|
3512
3564
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -3517,6 +3569,7 @@ export class SessionEngine {
|
|
|
3517
3569
|
if (chain !== undefined) {
|
|
3518
3570
|
yield chain.catch(() => { });
|
|
3519
3571
|
}
|
|
3572
|
+
this.storage.flushSession(sessionId);
|
|
3520
3573
|
yield this.storage.whenIdle();
|
|
3521
3574
|
});
|
|
3522
3575
|
}
|
|
@@ -3537,6 +3590,10 @@ export class SessionEngine {
|
|
|
3537
3590
|
yield active;
|
|
3538
3591
|
continue;
|
|
3539
3592
|
}
|
|
3593
|
+
const dispatch = this.dispatchChains.get(sessionId);
|
|
3594
|
+
if (dispatch !== undefined) {
|
|
3595
|
+
yield dispatch.catch(() => { });
|
|
3596
|
+
}
|
|
3540
3597
|
return (_a = this.lastOutcomes.get(sessionId)) !== null && _a !== void 0 ? _a : { status: "finished" };
|
|
3541
3598
|
}
|
|
3542
3599
|
});
|
|
@@ -4340,30 +4397,6 @@ function mergePendingWorkspaceFiles(current, incoming) {
|
|
|
4340
4397
|
}
|
|
4341
4398
|
return Object.assign(Object.assign({}, current), incoming);
|
|
4342
4399
|
}
|
|
4343
|
-
/**
|
|
4344
|
-
* Shallow-merge a wake patch into durable channel state. Null / undefined
|
|
4345
|
-
* patch values leave the existing key alone so sticky fields survive.
|
|
4346
|
-
*/
|
|
4347
|
-
export function mergeChannelStateSkipNull(current, patch) {
|
|
4348
|
-
if (patch === undefined) {
|
|
4349
|
-
return current;
|
|
4350
|
-
}
|
|
4351
|
-
if (typeof patch !== "object" ||
|
|
4352
|
-
patch === null ||
|
|
4353
|
-
Array.isArray(patch) ||
|
|
4354
|
-
typeof current !== "object" ||
|
|
4355
|
-
current === null ||
|
|
4356
|
-
Array.isArray(current)) {
|
|
4357
|
-
return structuredClone(patch);
|
|
4358
|
-
}
|
|
4359
|
-
const merged = Object.assign({}, current);
|
|
4360
|
-
for (const [key, value] of Object.entries(patch)) {
|
|
4361
|
-
if (value !== null && value !== undefined) {
|
|
4362
|
-
merged[key] = value;
|
|
4363
|
-
}
|
|
4364
|
-
}
|
|
4365
|
-
return merged;
|
|
4366
|
-
}
|
|
4367
4400
|
function eventsNdjson(events) {
|
|
4368
4401
|
if (events.length === 0) {
|
|
4369
4402
|
return undefined;
|