@grok/agent-sdk 0.4.0 → 0.6.0
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/channels/match-ready/index.d.ts +4 -0
- package/dist/channels/match-ready/index.d.ts.map +1 -0
- package/dist/channels/match-ready/index.js +2 -0
- package/dist/channels/match-ready/match-ready-channel.d.ts +5 -0
- package/dist/channels/match-ready/match-ready-channel.d.ts.map +1 -0
- package/dist/channels/match-ready/match-ready-channel.js +42 -0
- package/dist/channels/match-ready/types.d.ts +25 -0
- package/dist/channels/match-ready/types.d.ts.map +1 -0
- package/dist/channels/match-ready/types.js +1 -0
- package/dist/channels/slack/manifest.d.ts.map +1 -1
- package/dist/channels/slack/manifest.js +2 -15
- package/dist/docs/404.html +2 -2
- package/dist/docs/assets/{app.BSH__xV4.js → app.lt-BYgI2.js} +4 -4
- package/dist/docs/assets/changelog.md.DVNB-ApU.js +1 -0
- package/dist/docs/assets/changelog.md.DVNB-ApU.lean.js +1 -0
- package/dist/docs/assets/chunks/@localSearchIndexroot.DdlR-9Oe.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.Cadl7A0k.js → VPLocalSearchBox.v_dV4U2Q.js} +1 -1
- package/dist/docs/assets/chunks/{arc.K7t9nNY6.js → arc.5o92kOg5.js} +1 -1
- package/dist/docs/assets/chunks/{architectureDiagram-Q4EWVU46.SlHEknkX.js → architectureDiagram-Q4EWVU46.C-oTwnNq.js} +1 -1
- package/dist/docs/assets/chunks/{baseUniq.DJLRMLkz.js → baseUniq.zJ-VNOib.js} +1 -1
- package/dist/docs/assets/chunks/{blockDiagram-DXYQGD6D.Bs6XxFpe.js → blockDiagram-DXYQGD6D.B9ZJZuPd.js} +1 -1
- package/dist/docs/assets/chunks/{c4Diagram-AHTNJAMY.CyLg6Ovc.js → c4Diagram-AHTNJAMY.BBMwSIaN.js} +1 -1
- package/dist/docs/assets/chunks/channel.CdyTxaXV.js +1 -0
- package/dist/docs/assets/chunks/{chunk-4BX2VUAB.DTQ4TinT.js → chunk-4BX2VUAB.D8qAJpDD.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-4TB4RGXK.Es84IgcH.js → chunk-4TB4RGXK.B8QR5cdE.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-55IACEB6.Clm3cGPQ.js → chunk-55IACEB6.BsWxVuew.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-EDXVE4YY.DE4CRkS5.js → chunk-EDXVE4YY.BeGygY_i.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-FMBD7UC4.Bf8HCvqp.js → chunk-FMBD7UC4.DdwgH-ZH.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-OYMX7WX6.eub-7nSx.js → chunk-OYMX7WX6.B9zC_ALe.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-QZHKN3VN.WyP9VAS_.js → chunk-QZHKN3VN.BIxJ0rcL.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-YZCP3GAM.LO9ohhDE.js → chunk-YZCP3GAM.qiM_23_f.js} +1 -1
- package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.CeUcN6TW.js +1 -0
- package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.CeUcN6TW.js +1 -0
- package/dist/docs/assets/chunks/clone.DpIwUbur.js +1 -0
- package/dist/docs/assets/chunks/{cose-bilkent-S5V4N54A.D5za6aH0.js → cose-bilkent-S5V4N54A.BKB971D5.js} +1 -1
- package/dist/docs/assets/chunks/{dagre-KV5264BT.Dq1daUru.js → dagre-KV5264BT.CcILjJgp.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-5BDNPKRD.j1YL5BKS.js → diagram-5BDNPKRD.DkY9A0nu.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-G4DWMVQ6.Bi1aLdhC.js → diagram-G4DWMVQ6.BbdzmjMt.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-MMDJMWI5.BOzMEkAr.js → diagram-MMDJMWI5.Be0zy1cM.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-TYMM5635.Dx2FVhCr.js → diagram-TYMM5635.zOiEycLe.js} +1 -1
- package/dist/docs/assets/chunks/{erDiagram-SMLLAGMA.DI4TNkye.js → erDiagram-SMLLAGMA.DUd_9HMF.js} +1 -1
- package/dist/docs/assets/chunks/{flowDiagram-DWJPFMVM.C58Z9uPK.js → flowDiagram-DWJPFMVM.2KPYoZBO.js} +1 -1
- package/dist/docs/assets/chunks/{ganttDiagram-T4ZO3ILL.DXSpW809.js → ganttDiagram-T4ZO3ILL.DqE8_YpP.js} +1 -1
- package/dist/docs/assets/chunks/{gitGraphDiagram-UUTBAWPF.B955oaFl.js → gitGraphDiagram-UUTBAWPF.CO0Tk47h.js} +1 -1
- package/dist/docs/assets/chunks/{graph.BQXhKtxS.js → graph.CNe5KbNy.js} +1 -1
- package/dist/docs/assets/chunks/{infoDiagram-42DDH7IO.Dozj_-Gm.js → infoDiagram-42DDH7IO.BBhJ1X1B.js} +1 -1
- package/dist/docs/assets/chunks/{ishikawaDiagram-UXIWVN3A.D2140OzH.js → ishikawaDiagram-UXIWVN3A.KSIw9w3I.js} +1 -1
- package/dist/docs/assets/chunks/{journeyDiagram-VCZTEJTY.DrqrMhCk.js → journeyDiagram-VCZTEJTY.BN2Y5oUJ.js} +1 -1
- package/dist/docs/assets/chunks/{kanban-definition-6JOO6SKY.Dv-LTrlw.js → kanban-definition-6JOO6SKY.2KFuDYn_.js} +1 -1
- package/dist/docs/assets/chunks/{layout.CGtHp49X.js → layout.Demb_pzL.js} +1 -1
- package/dist/docs/assets/chunks/{linear.CHZLYB52.js → linear.kYKxzbbR.js} +1 -1
- package/dist/docs/assets/chunks/{min.D4Vt3eIy.js → min.DwmCN5dF.js} +1 -1
- package/dist/docs/assets/chunks/{mindmap-definition-QFDTVHPH.BBfpYTea.js → mindmap-definition-QFDTVHPH.CGlz01QG.js} +1 -1
- package/dist/docs/assets/chunks/{pieDiagram-DEJITSTG.BVYvElmY.js → pieDiagram-DEJITSTG.n3qsq4nA.js} +1 -1
- package/dist/docs/assets/chunks/{quadrantDiagram-34T5L4WZ.C6Gc2mdY.js → quadrantDiagram-34T5L4WZ.CGNJ1GSb.js} +1 -1
- package/dist/docs/assets/chunks/{requirementDiagram-MS252O5E.DWa8b4cn.js → requirementDiagram-MS252O5E.VhAzHDwQ.js} +1 -1
- package/dist/docs/assets/chunks/{sankeyDiagram-XADWPNL6.Bi-g4ajv.js → sankeyDiagram-XADWPNL6.DmHA5pW-.js} +1 -1
- package/dist/docs/assets/chunks/{sequenceDiagram-FGHM5R23.DlU3vVN9.js → sequenceDiagram-FGHM5R23._TC1aKhg.js} +1 -1
- package/dist/docs/assets/chunks/{stateDiagram-FHFEXIEX.CeqJRqnU.js → stateDiagram-FHFEXIEX.B-kLjV3O.js} +1 -1
- package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.HtBkUH4J.js +1 -0
- package/dist/docs/assets/chunks/{theme.DGq7D4tt.js → theme.BaVlHHL-.js} +2 -2
- package/dist/docs/assets/chunks/{timeline-definition-GMOUNBTQ.Cqf2kjq9.js → timeline-definition-GMOUNBTQ.CresbphV.js} +1 -1
- package/dist/docs/assets/chunks/{vennDiagram-DHZGUBPP.BeOpE_lM.js → vennDiagram-DHZGUBPP.CegHD8Y4.js} +1 -1
- package/dist/docs/assets/chunks/{wardley-RL74JXVD.FMQXA-6q.js → wardley-RL74JXVD.DjCmZrUO.js} +1 -1
- package/dist/docs/assets/chunks/{wardleyDiagram-NUSXRM2D.BXS65dAC.js → wardleyDiagram-NUSXRM2D.BJ7s1zdZ.js} +1 -1
- package/dist/docs/assets/chunks/{xychartDiagram-5P7HB3ND.haEiSxqc.js → xychartDiagram-5P7HB3ND.IrEXlemI.js} +1 -1
- package/dist/docs/assets/{reference_agent-config.md.BSNp2uJ7.js → reference_agent-config.md.Bbqf0lgS.js} +11 -3
- package/dist/docs/assets/{reference_agent-config.md.BSNp2uJ7.lean.js → reference_agent-config.md.Bbqf0lgS.lean.js} +1 -1
- package/dist/docs/assets/{reference_schedules.md.Dd8_d0WG.js → reference_schedules.md.RhQ9ZLo1.js} +3 -3
- package/dist/docs/assets/{reference_tools.md.B2OaR1Nb.js → reference_tools.md.BhqW6neF.js} +4 -2
- package/dist/docs/assets/{reference_tools.md.B2OaR1Nb.lean.js → reference_tools.md.BhqW6neF.lean.js} +1 -1
- package/dist/docs/building-with-agents.html +35 -35
- package/dist/docs/changelog.html +36 -36
- package/dist/docs/changelog.md +47 -7
- package/dist/docs/deployment.html +35 -35
- package/dist/docs/evals.html +35 -35
- package/dist/docs/guides/agent-to-agent.html +35 -35
- package/dist/docs/guides/bitbucket.html +35 -35
- package/dist/docs/guides/cloud-agents.html +35 -35
- package/dist/docs/guides/convert-automation.html +35 -35
- package/dist/docs/guides/github.html +35 -35
- package/dist/docs/guides/gitlab.html +35 -35
- package/dist/docs/guides/improve.html +35 -35
- package/dist/docs/guides/jev.html +35 -35
- package/dist/docs/guides/mcp-oauth.html +35 -35
- package/dist/docs/guides/migrate.html +35 -35
- package/dist/docs/guides/opentelemetry.html +35 -35
- package/dist/docs/guides/pagerduty.html +35 -35
- package/dist/docs/guides/slack.html +35 -35
- package/dist/docs/guides/webhooks.html +35 -35
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +35 -35
- package/dist/docs/index.html +35 -35
- package/dist/docs/llms-full.txt +129 -11
- package/dist/docs/quickstart.html +35 -35
- package/dist/docs/reference/access.html +35 -35
- package/dist/docs/reference/agent-config.html +45 -37
- package/dist/docs/reference/agent-config.md +70 -4
- package/dist/docs/reference/artifacts.html +35 -35
- package/dist/docs/reference/channels.html +35 -35
- package/dist/docs/reference/cli.html +35 -35
- package/dist/docs/reference/connections.html +35 -35
- package/dist/docs/reference/evals.html +35 -35
- package/dist/docs/reference/extensions.html +35 -35
- package/dist/docs/reference/hooks.html +35 -35
- package/dist/docs/reference/http-api.html +35 -35
- package/dist/docs/reference/instructions.html +35 -35
- package/dist/docs/reference/limits.html +35 -35
- package/dist/docs/reference/memory.html +35 -35
- package/dist/docs/reference/playground.html +35 -35
- package/dist/docs/reference/project-layout.html +35 -35
- package/dist/docs/reference/schedules.html +38 -38
- package/dist/docs/reference/sessions.html +35 -35
- package/dist/docs/reference/skills.html +35 -35
- package/dist/docs/reference/subagents.html +35 -35
- package/dist/docs/reference/tools.html +39 -37
- package/dist/docs/reference/tools.md +12 -0
- package/dist/docs/templates/agentic-owners.html +35 -35
- package/dist/docs/templates/reviews.html +35 -35
- package/dist/docs/troubleshooting.html +35 -35
- package/dist/filesystem.d.ts +10 -97
- package/dist/filesystem.d.ts.map +1 -1
- package/dist/filesystem.js +28 -290
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/internal/cli-deploy.d.ts.map +1 -1
- package/dist/internal/cli-deploy.js +12 -7
- package/dist/internal/continuation-channel.d.ts +3 -3
- package/dist/internal/continuation-channel.js +3 -3
- package/dist/internal/continuation-identity.d.ts +6 -5
- package/dist/internal/continuation-identity.d.ts.map +1 -1
- package/dist/internal/continuation-identity.js +17 -2
- package/dist/internal/direct-file-tools.d.ts +21 -0
- package/dist/internal/direct-file-tools.d.ts.map +1 -0
- package/dist/internal/direct-file-tools.js +60 -0
- package/dist/internal/discovery/agent.d.ts.map +1 -1
- package/dist/internal/discovery/agent.js +71 -66
- package/dist/internal/filesystem/walk.d.ts +4 -52
- package/dist/internal/filesystem/walk.d.ts.map +1 -1
- package/dist/internal/filesystem/walk.js +4 -190
- package/dist/internal/hosted-delivery-protocol.d.ts +3 -0
- package/dist/internal/hosted-delivery-protocol.d.ts.map +1 -1
- package/dist/internal/hosted-delivery-protocol.js +2 -0
- package/dist/internal/hosted-delivery.d.ts.map +1 -1
- package/dist/internal/hosted-delivery.js +25 -10
- package/dist/internal/hosted-execution-latency.d.ts +3 -0
- package/dist/internal/hosted-execution-latency.d.ts.map +1 -1
- package/dist/internal/hosted-execution-latency.js +11 -0
- package/dist/internal/hosted-managed-automation.js +1 -1
- package/dist/internal/otel/http.d.ts +2 -1
- package/dist/internal/otel/http.d.ts.map +1 -1
- package/dist/internal/otel/http.js +2 -3
- package/dist/internal/sdk-runner.d.ts +1 -1
- package/dist/internal/sdk-runner.d.ts.map +1 -1
- package/dist/internal/sdk-runner.js +28 -40
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +8 -4
- package/dist/internal/session-engine.d.ts +34 -19
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +196 -251
- package/dist/internal/tcp-address.d.ts +3 -1
- package/dist/internal/tcp-address.d.ts.map +1 -1
- package/dist/internal/tcp-address.js +6 -0
- package/dist/internal/tool-paths.d.ts +8 -0
- package/dist/internal/tool-paths.d.ts.map +1 -0
- package/dist/internal/tool-paths.js +12 -0
- package/dist/internal/workspace-tree.d.ts +27 -0
- package/dist/internal/workspace-tree.d.ts.map +1 -0
- package/dist/internal/workspace-tree.js +106 -0
- package/dist/playground/assets/index-CnFd5R1_.js +62 -0
- package/dist/playground/assets/index-DNzRv6G8.css +1 -0
- package/dist/playground/index.html +2 -2
- package/dist/types.d.ts +48 -23
- package/dist/types.d.ts.map +1 -1
- package/docs/changelog.md +47 -7
- package/docs/reference/agent-config.md +70 -4
- package/docs/reference/tools.md +12 -0
- package/package.json +9 -14
- package/skills/deploy/SKILL.md +1 -1
- package/dist/docs/assets/changelog.md.b6H_ea44.js +0 -1
- package/dist/docs/assets/changelog.md.b6H_ea44.lean.js +0 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.CiRGcfZg.js +0 -1
- package/dist/docs/assets/chunks/channel.CVTdqYx0.js +0 -1
- package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.CsJJyx6-.js +0 -1
- package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.CsJJyx6-.js +0 -1
- package/dist/docs/assets/chunks/clone.Dk8KvtOB.js +0 -1
- package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.DE0BnUZh.js +0 -1
- package/dist/executors.d.ts +0 -11
- package/dist/executors.d.ts.map +0 -1
- package/dist/executors.js +0 -21
- package/dist/internal/filesystem/format.d.ts +0 -28
- package/dist/internal/filesystem/format.d.ts.map +0 -1
- package/dist/internal/filesystem/format.js +0 -209
- package/dist/internal/filesystem/nearest.d.ts +0 -15
- package/dist/internal/filesystem/nearest.d.ts.map +0 -1
- package/dist/internal/filesystem/nearest.js +0 -90
- package/dist/internal/filesystem/scratch.d.ts +0 -60
- package/dist/internal/filesystem/scratch.d.ts.map +0 -1
- package/dist/internal/filesystem/scratch.js +0 -187
- package/dist/internal/filesystem/sdk-schemas.d.ts +0 -29
- package/dist/internal/filesystem/sdk-schemas.d.ts.map +0 -1
- package/dist/internal/filesystem/sdk-schemas.js +0 -148
- package/dist/internal/filesystem/subagent-inherit.d.ts +0 -39
- package/dist/internal/filesystem/subagent-inherit.d.ts.map +0 -1
- package/dist/internal/filesystem/subagent-inherit.js +0 -96
- package/dist/internal/filesystem/tools.d.ts +0 -59
- package/dist/internal/filesystem/tools.d.ts.map +0 -1
- package/dist/internal/filesystem/tools.js +0 -634
- package/dist/internal/otel/propagation.d.ts +0 -7
- package/dist/internal/otel/propagation.d.ts.map +0 -1
- package/dist/internal/otel/propagation.js +0 -15
- package/dist/internal/sdk-subagent-inherit-support.d.ts +0 -9
- package/dist/internal/sdk-subagent-inherit-support.d.ts.map +0 -1
- package/dist/internal/sdk-subagent-inherit-support.js +0 -90
- package/dist/playground/assets/index-Bno25Cg0.css +0 -1
- package/dist/playground/assets/index-SGKsaznh.js +0 -62
- /package/dist/docs/assets/{reference_schedules.md.Dd8_d0WG.lean.js → reference_schedules.md.RhQ9ZLo1.lean.js} +0 -0
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
10
10
|
import { access, mkdir, rm, writeFile } from "node:fs/promises";
|
|
11
|
-
import { dirname, join } from "node:path";
|
|
11
|
+
import { dirname, join, posix } from "node:path";
|
|
12
12
|
import { isRecord } from "./is-record.js";
|
|
13
|
+
import { createFileSystemTools } from "@cursor/sdk";
|
|
13
14
|
import { SLACK_CHANNEL_ID } from "../channels/slack/constants.js";
|
|
14
15
|
import { telemetry } from "../telemetry.js";
|
|
15
16
|
import { materializeSlackNudgeCarrier } from "../channels/slack/nudge-carrier.js";
|
|
@@ -17,7 +18,7 @@ import { SlackAskDedupeStore, SlackNudgeStore } from "../channels/slack/nudge-st
|
|
|
17
18
|
import { resolveDedicatedSlackHostBinding } from "../channels/slack/slack-channel.js";
|
|
18
19
|
import { AGENT_SERVE_USER_STORE_FILES_SOURCE_ID, agentStoreKeys, DEPLOYMENT_STORE_MOUNT_PATH, USER_STORE_MOUNT_PATH, } from "../files.js";
|
|
19
20
|
import { cursorHostedFiles, isCursorHostedFilesAvailable, isCursorUserStoreFilesAvailable, } from "../files-backends/cursor-hosted.js";
|
|
20
|
-
import { isFileNotFoundError,
|
|
21
|
+
import { isFileNotFoundError, localFileSystem, readOnlyFs, resolveHostHarnessToolOptions, sessionFileSystem, tempFs, unionFs, writeWorkspaceFilesToRoot, } from "../filesystem.js";
|
|
21
22
|
import { storageKeysForArchitecture } from "../storage.js";
|
|
22
23
|
import { DEFAULT_MODEL, DIRECT_TOOL_CALL_CHANNEL_ID, isCursorAccountTransport, isHostOauthConnectionTransport, isSymbolicConnectionTransport, } from "../types.js";
|
|
23
24
|
import { resolveAdvertisedTools } from "./advertise-tools.js";
|
|
@@ -36,9 +37,7 @@ import { describeError, describeErrorCode } from "./describe-error.js";
|
|
|
36
37
|
import { isDevMode } from "./dev-mode.js";
|
|
37
38
|
import { EventLogStore } from "./event-log.js";
|
|
38
39
|
import { TurnEventMapper } from "./event-mapper.js";
|
|
39
|
-
import {
|
|
40
|
-
import { applyWebScratchUpdate, hostAgentToolsDir, ingestHostAgentToolsScratch, remapScratchPaths, } from "./filesystem/scratch.js";
|
|
41
|
-
import { fileSystemTool, hostFileToolsFromAuthored, isDirectFileToolAdmitted, isSynthesizedFileSystemToolName, rootFileToolsFromAuthored, runWithFileSystem, synthesizeFileSystemTools, } from "./filesystem/tools.js";
|
|
40
|
+
import { directFileToolAllowed, directFileToolName, hostAgentToolsDir, } from "./direct-file-tools.js";
|
|
42
41
|
import { selectFrameworkStorageDefinition } from "./framework-storage-selection.js";
|
|
43
42
|
import { createHostFilesApi } from "./host-files.js";
|
|
44
43
|
import { createHostKvApi } from "./host-kv.js";
|
|
@@ -56,7 +55,9 @@ import { buildSessionContextBlock, SCHEDULE_CHANNEL_PREFIX } from "./prompt-cont
|
|
|
56
55
|
import { assertCloudCanHonorAccountServersFilters } from "./resolved-connections.js";
|
|
57
56
|
import { sessionExternalLinks } from "./session-links.js";
|
|
58
57
|
import { SessionStore } from "./session-store.js";
|
|
58
|
+
import { MEMORY_DIR_NAME } from "./memory-dir.js";
|
|
59
59
|
import { syncSkillsToStore } from "./skills-sync.js";
|
|
60
|
+
import { confinesWorkspaceReads, DEFAULT_TREE_WORKSPACE, hostDirectoryTree, } from "./workspace-tree.js";
|
|
60
61
|
import { steeringEnabled } from "./steering.js";
|
|
61
62
|
import { resolveApiKeySync } from "./cursor/credentials.js";
|
|
62
63
|
import { CLI_COMMAND_NAME } from "./distribution.js";
|
|
@@ -69,6 +70,7 @@ import { estimateCostFromApi, roundCostUsd } from "./estimate-cost.js";
|
|
|
69
70
|
import { TurnGovernor } from "./turn-governor.js";
|
|
70
71
|
import { TurnLeaseStore } from "./turn-lease-store.js";
|
|
71
72
|
import { TurnOutbox } from "./turn-outbox.js";
|
|
73
|
+
import { markHostedTurnStarted } from "./hosted-execution-latency.js";
|
|
72
74
|
import { isCursorManagedV2Hosting, resolveAgentV2Hosting } from "./v2-hosting.js";
|
|
73
75
|
import { buildAgentsMdContent, buildCloudMemorySection, buildCloudSessionWorkspaceSection, buildCloudWorkspaceSection, ensureOwnGitRoot, isNestedInGitRepo, materializeWorkspace, SERVER_TOOLS_MCP_SERVER_NAME, SKILLS_MOUNT_PATH, skillsFileSystem, withIdentityPreamble, } from "./workspace.js";
|
|
74
76
|
import { syncSessionWorkspaceFiles, syncWorkspaceToStore, WorkspaceFileRefusal, wipeSessionWorkspace, } from "./workspace-sync.js";
|
|
@@ -222,6 +224,17 @@ function canonicalJson(value) {
|
|
|
222
224
|
}
|
|
223
225
|
return value;
|
|
224
226
|
}
|
|
227
|
+
const LOOPBACK_HOSTS = new Set(["127.0.0.1", "localhost", "[::1]"]);
|
|
228
|
+
/** The SDK exempts only loopback bridges, so a serve bound to another host names none. */
|
|
229
|
+
function isLoopbackHttpUrl(url) {
|
|
230
|
+
try {
|
|
231
|
+
const parsed = new URL(url);
|
|
232
|
+
return parsed.protocol === "http:" && LOOPBACK_HOSTS.has(parsed.hostname);
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
225
238
|
export class SessionEngine {
|
|
226
239
|
constructor(options) {
|
|
227
240
|
/** In-flight lazy restores, deduped per channel + continuation key. */
|
|
@@ -295,8 +308,6 @@ export class SessionEngine {
|
|
|
295
308
|
this.sessionRoots = new Map();
|
|
296
309
|
/** In-flight factory resolves, so the first turn and a racing callTool share one handle. */
|
|
297
310
|
this.sessionRootInflight = new Map();
|
|
298
|
-
/** Per-turn union of the authored tree, `/agent/skills`, and `/tmp`. Dropped at end of turn. */
|
|
299
|
-
this.turnRoots = new Map();
|
|
300
311
|
this.project = options.project;
|
|
301
312
|
applyAgentContinuationDefaults(this.project);
|
|
302
313
|
this.stateRoot = options.stateRoot;
|
|
@@ -431,6 +442,17 @@ export class SessionEngine {
|
|
|
431
442
|
});
|
|
432
443
|
}
|
|
433
444
|
}
|
|
445
|
+
hostMcpBridgeUrlsField() {
|
|
446
|
+
const urls = this.resolvedConnections
|
|
447
|
+
.filter((resolved) => {
|
|
448
|
+
const authored = this.authoredConnection(resolved.name);
|
|
449
|
+
return (authored !== undefined &&
|
|
450
|
+
isCursorAccountTransport(authored.transport) &&
|
|
451
|
+
isLoopbackHttpUrl(resolved.localUrl));
|
|
452
|
+
})
|
|
453
|
+
.map((resolved) => resolved.localUrl);
|
|
454
|
+
return urls.length === 0 ? {} : { hostMcpBridgeUrls: urls };
|
|
455
|
+
}
|
|
434
456
|
authoredConnection(name) {
|
|
435
457
|
return (this.project.agent.connections.find((item) => item.name === name) ??
|
|
436
458
|
this.project.agent.hostConnections?.find((item) => item.name === name));
|
|
@@ -588,7 +610,9 @@ export class SessionEngine {
|
|
|
588
610
|
// inject one thread's follow-ups into another thread's turn. Nothing is
|
|
589
611
|
// lost: a borrowed checkout is its own git root, so the harness reads its
|
|
590
612
|
// hooks rather than these, and follow-ups drain at the turn boundary.
|
|
591
|
-
this.hasBorrowedWorkspace(record)
|
|
613
|
+
this.hasBorrowedWorkspace(record) ||
|
|
614
|
+
// No Cursor hook runs on a tree.
|
|
615
|
+
this.confinesWorkspaceReads("local")) {
|
|
592
616
|
return;
|
|
593
617
|
}
|
|
594
618
|
if (steeringEnabled()) {
|
|
@@ -1422,47 +1446,62 @@ export class SessionEngine {
|
|
|
1422
1446
|
hasRootOverride() {
|
|
1423
1447
|
return this.project.agent.fs !== undefined || this.project.agent.root !== undefined;
|
|
1424
1448
|
}
|
|
1449
|
+
/**
|
|
1450
|
+
* A sandboxed host-disk agent whose `tools` grant file tools and no shell
|
|
1451
|
+
* runs on its session workspace as a tree, mounted at its `workspace`.
|
|
1452
|
+
*/
|
|
1453
|
+
confinesWorkspaceReads(runtime) {
|
|
1454
|
+
const agent = this.project.agent;
|
|
1455
|
+
return (runtime === "local" &&
|
|
1456
|
+
!this.hasRootOverride() &&
|
|
1457
|
+
confinesWorkspaceReads({ local: agent.local, tools: agent.allowedTools }));
|
|
1458
|
+
}
|
|
1459
|
+
treeWorkspace() {
|
|
1460
|
+
return this.project.agent.workspace ?? DEFAULT_TREE_WORKSPACE;
|
|
1461
|
+
}
|
|
1462
|
+
/**
|
|
1463
|
+
* The session workspace at {@link treeWorkspace}, with the skills mount over
|
|
1464
|
+
* it. Shared memory is a symlink out of the workspace, so it is mounted
|
|
1465
|
+
* read-only in its place, as a sandboxed host agent can read it but not
|
|
1466
|
+
* write through the link.
|
|
1467
|
+
*/
|
|
1468
|
+
async workspaceTree(cwd, options) {
|
|
1469
|
+
const skills = this.project.agent.skills;
|
|
1470
|
+
const workspace = this.treeWorkspace();
|
|
1471
|
+
return sessionFileSystem({
|
|
1472
|
+
authored: unionFs({
|
|
1473
|
+
[workspace]: hostDirectoryTree(cwd),
|
|
1474
|
+
[posix.join(workspace, MEMORY_DIR_NAME)]: readOnlyFs(hostDirectoryTree(join(this.stateRoot, MEMORY_DIR_NAME))),
|
|
1475
|
+
}),
|
|
1476
|
+
skills: skills.length === 0
|
|
1477
|
+
? undefined
|
|
1478
|
+
: { path: SKILLS_MOUNT_PATH, fs: await this.baseSkillsFileSystem() },
|
|
1479
|
+
scratch: options.scratch ? tempFs() : undefined,
|
|
1480
|
+
});
|
|
1481
|
+
}
|
|
1425
1482
|
/** The field the author set, for messages. Discovery copies a lone `root` onto `fs`. */
|
|
1426
1483
|
authoredFsField() {
|
|
1427
1484
|
return this.project.agent.root === undefined ? "fs" : "root";
|
|
1428
1485
|
}
|
|
1429
1486
|
/**
|
|
1430
|
-
*
|
|
1431
|
-
*
|
|
1432
|
-
*
|
|
1433
|
-
*
|
|
1434
|
-
*
|
|
1435
|
-
*
|
|
1436
|
-
*
|
|
1437
|
-
*
|
|
1438
|
-
* cwd. The read verbs can still reach the Cursor SDK's scratch dir for
|
|
1439
|
-
* that cwd, where native WebFetch and WebSearch write large output.
|
|
1487
|
+
* The tree an `fs` agent runs on: the authored `fs` at `/` with the
|
|
1488
|
+
* skills mount over it. A turn passes it to the SDK as `local.fs`, and
|
|
1489
|
+
* the SDK mounts a fresh `/tmp` over it for each run. A direct call
|
|
1490
|
+
* gets its own empty `/tmp` (`scratch`), so it sees what a run sees.
|
|
1491
|
+
* Authored `fs` (static or factory) is cached per session when `cache`
|
|
1492
|
+
* is set; unscoped `callTool` passes the invocation id and does not
|
|
1493
|
+
* cache, so factories cannot share one tree across callers. A static
|
|
1494
|
+
* handle is used as authored — every session sees that same object.
|
|
1440
1495
|
*/
|
|
1441
|
-
async
|
|
1442
|
-
if (!this.hasRootOverride()) {
|
|
1443
|
-
return localFileSystem({
|
|
1444
|
-
cwd: options.cwd,
|
|
1445
|
-
confineToWorkspace: options.confineToWorkspace === true,
|
|
1446
|
-
readOnlyRoots: [hostAgentToolsDir(options.cwd)],
|
|
1447
|
-
});
|
|
1448
|
-
}
|
|
1496
|
+
async resolveSessionTree(options) {
|
|
1449
1497
|
const authored = await this.resolveAuthoredFileSystem(options);
|
|
1450
|
-
|
|
1451
|
-
const existing = this.turnRoots.get(options.sessionId);
|
|
1452
|
-
if (existing !== undefined) {
|
|
1453
|
-
return existing.root;
|
|
1454
|
-
}
|
|
1455
|
-
}
|
|
1456
|
-
const root = sessionFileSystem({
|
|
1498
|
+
return sessionFileSystem({
|
|
1457
1499
|
authored: authored.fs,
|
|
1458
1500
|
skills: authored.skills === undefined
|
|
1459
1501
|
? undefined
|
|
1460
1502
|
: { path: SKILLS_MOUNT_PATH, fs: authored.skills },
|
|
1503
|
+
scratch: options.scratch === true ? tempFs() : undefined,
|
|
1461
1504
|
});
|
|
1462
|
-
if (options.cache && this.isTurnRunning(options.sessionId)) {
|
|
1463
|
-
this.turnRoots.set(options.sessionId, { root, cwd: options.cwd });
|
|
1464
|
-
}
|
|
1465
|
-
return root;
|
|
1466
1505
|
}
|
|
1467
1506
|
async resolveAuthoredFileSystem(options) {
|
|
1468
1507
|
const agent = this.project.agent;
|
|
@@ -1547,60 +1586,42 @@ export class SessionEngine {
|
|
|
1547
1586
|
});
|
|
1548
1587
|
return this.baseSkills;
|
|
1549
1588
|
}
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
...tool.definition,
|
|
1581
|
-
execute: async (input, ctx) => {
|
|
1582
|
-
const remapped = await this.prepareScratchToolInput({
|
|
1583
|
-
sessionId,
|
|
1584
|
-
input: input !== null && typeof input === "object" && !Array.isArray(input) ? input : {},
|
|
1585
|
-
});
|
|
1586
|
-
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- tool execute erases its input to never so an authored handler stays assignable
|
|
1587
|
-
return execute(remapped, ctx);
|
|
1588
|
-
},
|
|
1589
|
-
},
|
|
1590
|
-
};
|
|
1591
|
-
});
|
|
1592
|
-
}
|
|
1593
|
-
async nativeFileSystemOutcome(options) {
|
|
1594
|
-
const { toolName, input, callId } = options;
|
|
1595
|
-
if (!isFileSystemToolAlias(toolName)) {
|
|
1596
|
-
return undefined;
|
|
1589
|
+
/**
|
|
1590
|
+
* A native file tool run outside a turn, on the tree a turn of this
|
|
1591
|
+
* session would use. Host-disk agents run it on the harness cwd,
|
|
1592
|
+
* confined to that cwd, with the workspace set to the cwd as a turn's
|
|
1593
|
+
* native tools report it. The read verbs can also reach the SDK's spill
|
|
1594
|
+
* directory for that cwd, where native WebFetch and WebSearch write
|
|
1595
|
+
* large output.
|
|
1596
|
+
*/
|
|
1597
|
+
async directFileToolOutcome(options) {
|
|
1598
|
+
const { toolName, input, callId, sessionId } = options;
|
|
1599
|
+
const tools = this.hasRootOverride()
|
|
1600
|
+
? createFileSystemTools(await this.resolveSessionTree({
|
|
1601
|
+
sessionId: sessionId ?? callId,
|
|
1602
|
+
continuationKey: options.continuationKey,
|
|
1603
|
+
cache: sessionId !== undefined,
|
|
1604
|
+
scratch: true,
|
|
1605
|
+
}), { workspace: this.project.agent.workspace })
|
|
1606
|
+
: this.confinesWorkspaceReads("local")
|
|
1607
|
+
? createFileSystemTools(await this.workspaceTree(options.cwd, { scratch: true }), {
|
|
1608
|
+
workspace: this.treeWorkspace(),
|
|
1609
|
+
})
|
|
1610
|
+
: createFileSystemTools(localFileSystem({
|
|
1611
|
+
cwd: options.cwd,
|
|
1612
|
+
confineToWorkspace: true,
|
|
1613
|
+
readOnlyRoots: [hostAgentToolsDir(options.cwd)],
|
|
1614
|
+
}), { workspace: options.cwd });
|
|
1615
|
+
const tool = tools[options.name];
|
|
1616
|
+
const mutates = tool.annotations.readOnlyHint === false;
|
|
1617
|
+
if (mutates && options.busy && sessionId !== undefined) {
|
|
1618
|
+
throw new SessionBusyError(sessionId);
|
|
1597
1619
|
}
|
|
1598
1620
|
// Same policy the authored callTool path asks: a dry-run write is
|
|
1599
|
-
// answered by the host
|
|
1600
|
-
// decideToolCall and persist through the FileSystem.
|
|
1621
|
+
// answered by the host and never reaches the tree.
|
|
1601
1622
|
const decision = decideToolCall({
|
|
1602
|
-
dryRun: options.dryRun
|
|
1603
|
-
effect:
|
|
1623
|
+
dryRun: options.dryRun,
|
|
1624
|
+
effect: mutates ? "write" : "read",
|
|
1604
1625
|
input,
|
|
1605
1626
|
});
|
|
1606
1627
|
if (decision.kind === "answer") {
|
|
@@ -1610,82 +1631,34 @@ export class SessionEngine {
|
|
|
1610
1631
|
isError: false,
|
|
1611
1632
|
result: decision.result,
|
|
1612
1633
|
durationMs: 0,
|
|
1613
|
-
sessionId
|
|
1634
|
+
sessionId,
|
|
1614
1635
|
};
|
|
1615
1636
|
}
|
|
1616
|
-
const
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
const args = await this.prepareScratchToolInput({
|
|
1625
|
-
sessionId: options.sessionId,
|
|
1626
|
-
input: rawArgs,
|
|
1637
|
+
const failed = (message) => ({
|
|
1638
|
+
callId,
|
|
1639
|
+
toolName,
|
|
1640
|
+
isError: true,
|
|
1641
|
+
result: { status: "error", error: { message } },
|
|
1642
|
+
durationMs: 0,
|
|
1643
|
+
sessionId,
|
|
1644
|
+
errorMessage: message,
|
|
1627
1645
|
});
|
|
1628
|
-
|
|
1629
|
-
const execute = tool?.definition.execute;
|
|
1630
|
-
if (tool === undefined || typeof execute !== "function") {
|
|
1631
|
-
// A resolved root owns this native name. Falling through would let
|
|
1632
|
-
// an authored lookalike run, or surface UnknownToolError after we
|
|
1633
|
-
// already advertised the FileSystem tool.
|
|
1634
|
-
return {
|
|
1635
|
-
callId,
|
|
1636
|
-
toolName,
|
|
1637
|
-
isError: true,
|
|
1638
|
-
result: {
|
|
1639
|
-
status: "error",
|
|
1640
|
-
error: { message: `FileSystem cannot handle ${toolName}` },
|
|
1641
|
-
},
|
|
1642
|
-
durationMs: 0,
|
|
1643
|
-
sessionId: options.sessionId,
|
|
1644
|
-
errorMessage: `FileSystem cannot handle ${toolName}`,
|
|
1645
|
-
};
|
|
1646
|
-
}
|
|
1647
|
-
const validation = validateToolInput(tool.definition.inputSchema, args);
|
|
1648
|
-
if (!validation.ok) {
|
|
1649
|
-
return {
|
|
1650
|
-
callId,
|
|
1651
|
-
toolName,
|
|
1652
|
-
isError: true,
|
|
1653
|
-
result: {
|
|
1654
|
-
status: "error",
|
|
1655
|
-
error: { message: validation.message },
|
|
1656
|
-
},
|
|
1657
|
-
durationMs: 0,
|
|
1658
|
-
sessionId: options.sessionId,
|
|
1659
|
-
errorMessage: validation.message,
|
|
1660
|
-
};
|
|
1661
|
-
}
|
|
1646
|
+
let call;
|
|
1662
1647
|
try {
|
|
1663
|
-
|
|
1664
|
-
const toolInput = validation.value;
|
|
1665
|
-
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- this execute erases ToolContext to never
|
|
1666
|
-
const toolCtx = { toolCallId: callId, workspaceDir: options.cwd };
|
|
1667
|
-
const value = await execute(toolInput, toolCtx);
|
|
1668
|
-
return {
|
|
1669
|
-
callId,
|
|
1670
|
-
toolName,
|
|
1671
|
-
isError: false,
|
|
1672
|
-
result: normalizeToolResult(value),
|
|
1673
|
-
durationMs: 0,
|
|
1674
|
-
sessionId: options.sessionId,
|
|
1675
|
-
};
|
|
1648
|
+
call = await tool.execute(isRecord(input) ? input : {});
|
|
1676
1649
|
}
|
|
1677
1650
|
catch (error) {
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
};
|
|
1651
|
+
return failed(error instanceof Error ? error.message : String(error));
|
|
1652
|
+
}
|
|
1653
|
+
const result = call.result;
|
|
1654
|
+
if (result === undefined) {
|
|
1655
|
+
return failed(`${options.name} returned no result`);
|
|
1656
|
+
}
|
|
1657
|
+
if (result.status === "error") {
|
|
1658
|
+
const message = describeToolCallError(result.error);
|
|
1659
|
+
return { ...failed(message), result };
|
|
1688
1660
|
}
|
|
1661
|
+
return { callId, toolName, isError: false, result, durationMs: 0, sessionId };
|
|
1689
1662
|
}
|
|
1690
1663
|
/**
|
|
1691
1664
|
* Local harness cwd for a session: per-send override, else the shared
|
|
@@ -1762,6 +1735,7 @@ export class SessionEngine {
|
|
|
1762
1735
|
// warmed without an identity; the per-send flag still has to match
|
|
1763
1736
|
// the turns' requests or the warmed executor is one no turn asks for.
|
|
1764
1737
|
mcpServers: this.buildMcpServers("local"),
|
|
1738
|
+
...this.hostMcpBridgeUrlsField(),
|
|
1765
1739
|
...(this.hasAttachedAuthedConnections() ||
|
|
1766
1740
|
this.project.agent.connections.some((connection) => isCursorAccountTransport(connection.transport))
|
|
1767
1741
|
? { perSendMcpServers: true }
|
|
@@ -1835,6 +1809,7 @@ export class SessionEngine {
|
|
|
1835
1809
|
}
|
|
1836
1810
|
else {
|
|
1837
1811
|
emit({ type: "turn.started", data: {} });
|
|
1812
|
+
markHostedTurnStarted();
|
|
1838
1813
|
try {
|
|
1839
1814
|
if (record.workspaceOverride === undefined &&
|
|
1840
1815
|
this.project.agent.local?.workspaceDir !== undefined) {
|
|
@@ -1877,12 +1852,13 @@ export class SessionEngine {
|
|
|
1877
1852
|
});
|
|
1878
1853
|
const hasPendingFiles = pendingFiles !== undefined && Object.keys(pendingFiles).length > 0;
|
|
1879
1854
|
if (hasPendingFiles && runtime !== "cloud") {
|
|
1880
|
-
const root =
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1855
|
+
const root = this.hasRootOverride()
|
|
1856
|
+
? await this.resolveSessionTree({
|
|
1857
|
+
sessionId,
|
|
1858
|
+
continuationKey: record.continuationKey ?? undefined,
|
|
1859
|
+
cache: true,
|
|
1860
|
+
})
|
|
1861
|
+
: localFileSystem({ cwd: harnessCwd });
|
|
1886
1862
|
await writeWorkspaceFilesToRoot(root, pendingFiles);
|
|
1887
1863
|
}
|
|
1888
1864
|
if ((hasPendingFiles && runtime !== "cloud") ||
|
|
@@ -1901,14 +1877,6 @@ export class SessionEngine {
|
|
|
1901
1877
|
const onUpdate = async (update) => {
|
|
1902
1878
|
endFirstUpdate?.();
|
|
1903
1879
|
endFirstUpdate = undefined;
|
|
1904
|
-
const turn = this.turnRoots.get(sessionId);
|
|
1905
|
-
if (turn !== undefined) {
|
|
1906
|
-
update = await applyWebScratchUpdate({
|
|
1907
|
-
cwd: turn.cwd,
|
|
1908
|
-
root: turn.root,
|
|
1909
|
-
update,
|
|
1910
|
-
});
|
|
1911
|
-
}
|
|
1912
1880
|
mapper.handleUpdate(update);
|
|
1913
1881
|
// Yield so the HTTP NDJSON writer can flush tool start/result
|
|
1914
1882
|
// events while sibling parallel tools are still executing.
|
|
@@ -1952,7 +1920,6 @@ export class SessionEngine {
|
|
|
1952
1920
|
}
|
|
1953
1921
|
finally {
|
|
1954
1922
|
permit.release();
|
|
1955
|
-
this.dropTurnFileSystem(sessionId);
|
|
1956
1923
|
this.approvals.cancelSession(sessionId, "deny");
|
|
1957
1924
|
this.auths.cancelSession(sessionId, "deny");
|
|
1958
1925
|
await this.clearPendingApprovals(sessionId);
|
|
@@ -2232,34 +2199,24 @@ export class SessionEngine {
|
|
|
2232
2199
|
})
|
|
2233
2200
|
: undefined;
|
|
2234
2201
|
const authoredRoot = this.hasRootOverride();
|
|
2235
|
-
const
|
|
2236
|
-
|
|
2202
|
+
const workspaceConfined = this.confinesWorkspaceReads(runtime);
|
|
2203
|
+
const fileSystem = runtime === "local" && authoredRoot
|
|
2204
|
+
? await this.resolveSessionTree({
|
|
2237
2205
|
sessionId: record.sessionId,
|
|
2238
2206
|
continuationKey: record.continuationKey ?? undefined,
|
|
2239
2207
|
cache: true,
|
|
2240
|
-
cwd: this.harnessCwd(record),
|
|
2241
|
-
// The synthesized file tools run in this process, outside the
|
|
2242
|
-
// harness sandbox. Without this, a sandboxed turn's Read or
|
|
2243
|
-
// Write reaches any path the serve process can.
|
|
2244
|
-
confineToWorkspace: agent.local?.sandbox === true,
|
|
2245
2208
|
})
|
|
2246
|
-
:
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
:
|
|
2256
|
-
|
|
2257
|
-
const fileTools = root === undefined
|
|
2258
|
-
? []
|
|
2259
|
-
: synthesizeFileSystemTools(root, authoredRoot
|
|
2260
|
-
? rootFileToolsFromAuthored(agent.allowedTools)
|
|
2261
|
-
: hostFileToolsFromAuthored(agent.allowedTools));
|
|
2262
|
-
const synthesized = root === undefined ? [] : this.withTurnScratchTools(fileTools, record.sessionId);
|
|
2209
|
+
: workspaceConfined
|
|
2210
|
+
? await this.workspaceTree(this.harnessCwd(record), { scratch: false })
|
|
2211
|
+
: undefined;
|
|
2212
|
+
// An agent on a tree passes its allowlist through: the SDK backs file
|
|
2213
|
+
// tools with the tree and refuses tools it cannot. Host-disk agents keep
|
|
2214
|
+
// the SDK's host natives.
|
|
2215
|
+
const harnessTools = runtime !== "local"
|
|
2216
|
+
? undefined
|
|
2217
|
+
: fileSystem !== undefined
|
|
2218
|
+
? { tools: agent.allowedTools }
|
|
2219
|
+
: resolveHostHarnessToolOptions(agent.allowedTools);
|
|
2263
2220
|
let turnPrompt = prompt;
|
|
2264
2221
|
if (isFirstTurn) {
|
|
2265
2222
|
const contextBlock = buildSessionContextBlock({
|
|
@@ -2327,27 +2284,34 @@ export class SessionEngine {
|
|
|
2327
2284
|
turnPrompt = [preamble, ...sections, turnPrompt].filter((part) => part !== "").join("\n\n");
|
|
2328
2285
|
}
|
|
2329
2286
|
}
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
turnPrompt = `<user_info>\nWorkspace Path: /\n</user_info>\n\n${turnPrompt}`;
|
|
2333
|
-
}
|
|
2334
|
-
// A virtual root has no scaffold dir either, so its catalog carries the
|
|
2335
|
-
// synthesized file tools and embedded script bodies.
|
|
2287
|
+
// An `fs` agent has no scaffold dir, so its catalog embeds script
|
|
2288
|
+
// bodies and indexes the skills mounted in the tree.
|
|
2336
2289
|
const localInstructions = runtime === "local"
|
|
2337
2290
|
? authoredRoot
|
|
2338
|
-
? buildAgentsMdContent(
|
|
2291
|
+
? buildAgentsMdContent(instructionsAgent, {
|
|
2292
|
+
includeScripts: true,
|
|
2293
|
+
skillsIndex: agent.skillsMount !== false,
|
|
2294
|
+
})
|
|
2339
2295
|
: buildAgentsMdContent(instructionsAgent, {
|
|
2340
2296
|
includeScripts: this.hasBorrowedWorkspace(record),
|
|
2297
|
+
skillsIndex: workspaceConfined && agent.skills.length > 0,
|
|
2341
2298
|
})
|
|
2342
2299
|
: undefined;
|
|
2343
|
-
const childFiles = authoredRoot && root !== undefined ? createRootSubagentInherit(root) : undefined;
|
|
2344
2300
|
const selection = this.turnModel(record);
|
|
2345
2301
|
return {
|
|
2346
2302
|
sessionId: record.sessionId,
|
|
2347
2303
|
...(record.sdkAgentId === undefined ? {} : { sdkAgentId: record.sdkAgentId }),
|
|
2348
2304
|
workspaceDir: this.harnessCwd(record),
|
|
2349
|
-
sandbox:
|
|
2350
|
-
|
|
2305
|
+
sandbox: agent.local?.sandbox === true,
|
|
2306
|
+
fs: fileSystem,
|
|
2307
|
+
reportedWorkspacePath: authoredRoot
|
|
2308
|
+
? agent.workspace
|
|
2309
|
+
: workspaceConfined
|
|
2310
|
+
? this.treeWorkspace()
|
|
2311
|
+
: undefined,
|
|
2312
|
+
// As on the host, project rules load from the workspace: the tree's
|
|
2313
|
+
// `<workspace>/AGENTS.md` and `<workspace>/.cursor/rules/`.
|
|
2314
|
+
settingSources: fileSystem === undefined ? undefined : ["project"],
|
|
2351
2315
|
...(runtime === "local" && harnessTools !== undefined
|
|
2352
2316
|
? {
|
|
2353
2317
|
...(harnessTools.tools === undefined ? {} : { tools: harnessTools.tools }),
|
|
@@ -2380,10 +2344,9 @@ export class SessionEngine {
|
|
|
2380
2344
|
...(runtime === "cloud" && !isCursorHostedFilesAvailable()
|
|
2381
2345
|
? { agentServeAgent: this.project.name }
|
|
2382
2346
|
: {}),
|
|
2383
|
-
customTools: runtime === "local"
|
|
2384
|
-
? await this.buildCustomTools(record, turnId, emit, synthesized, signal, childFiles)
|
|
2385
|
-
: {},
|
|
2347
|
+
customTools: runtime === "local" ? await this.buildCustomTools(record, turnId, emit, signal) : {},
|
|
2386
2348
|
mcpServers: this.buildMcpServers(runtime, record.sessionId, await this.evaluateConnectionAuth(record)),
|
|
2349
|
+
...(runtime === "local" ? this.hostMcpBridgeUrlsField() : {}),
|
|
2387
2350
|
...(runtime === "local" &&
|
|
2388
2351
|
(this.hasAttachedAuthedConnections() ||
|
|
2389
2352
|
this.project.agent.connections.some((connection) => isCursorAccountTransport(connection.transport)))
|
|
@@ -2628,7 +2591,7 @@ export class SessionEngine {
|
|
|
2628
2591
|
}
|
|
2629
2592
|
return evaluated;
|
|
2630
2593
|
}
|
|
2631
|
-
async buildCustomTools(record, turnId, emit,
|
|
2594
|
+
async buildCustomTools(record, turnId, emit, signal) {
|
|
2632
2595
|
const agent = this.project.agent;
|
|
2633
2596
|
const tools = {};
|
|
2634
2597
|
const register = (tool) => {
|
|
@@ -2642,31 +2605,19 @@ export class SessionEngine {
|
|
|
2642
2605
|
// MCP passthrough's server-declared hints (bounded at listing time)
|
|
2643
2606
|
// ride into the harness listing once the dependency bumps.
|
|
2644
2607
|
...(tool.annotations === undefined ? {} : { annotations: tool.annotations }),
|
|
2645
|
-
execute: async (args, context) => {
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
});
|
|
2656
|
-
const sessionId = context.sessionId;
|
|
2657
|
-
if (childFiles === undefined ||
|
|
2658
|
-
sessionId === undefined ||
|
|
2659
|
-
sessionId === "" ||
|
|
2660
|
-
sessionId === record.sessionId ||
|
|
2661
|
-
sessionId === record.sdkAgentId ||
|
|
2662
|
-
!isSynthesizedFileSystemToolName(tool.name)) {
|
|
2663
|
-
return run();
|
|
2664
|
-
}
|
|
2665
|
-
return runWithFileSystem(childFiles.fileSystemForSession(sessionId), run);
|
|
2666
|
-
},
|
|
2608
|
+
execute: async (args, context) => this.executeServerTool({
|
|
2609
|
+
tool,
|
|
2610
|
+
input: args,
|
|
2611
|
+
toolCallId: context.toolCallId,
|
|
2612
|
+
record,
|
|
2613
|
+
turnId,
|
|
2614
|
+
emit,
|
|
2615
|
+
signal,
|
|
2616
|
+
fromModel: true,
|
|
2617
|
+
}),
|
|
2667
2618
|
};
|
|
2668
2619
|
};
|
|
2669
|
-
for (const tool of
|
|
2620
|
+
for (const tool of agent.tools) {
|
|
2670
2621
|
if (tool.execution !== "server") {
|
|
2671
2622
|
continue;
|
|
2672
2623
|
}
|
|
@@ -3519,33 +3470,23 @@ export class SessionEngine {
|
|
|
3519
3470
|
const session = identity.session;
|
|
3520
3471
|
let workspaceDir = identity.workspaceDir;
|
|
3521
3472
|
let scratchDir = identity.scratchDir;
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
identity.busy &&
|
|
3530
|
-
record !== undefined &&
|
|
3531
|
-
isMutatingFileSystemTool(toolName)) {
|
|
3532
|
-
throw new SessionBusyError(record.sessionId);
|
|
3533
|
-
}
|
|
3534
|
-
if (fileToolAdmitted) {
|
|
3535
|
-
const native = await this.nativeFileSystemOutcome({
|
|
3473
|
+
let tool = this.project.agent.tools.find((t) => t.name === toolName);
|
|
3474
|
+
// An authored tool owns its exact name; the natives stay reachable by their other names.
|
|
3475
|
+
const fileTool = tool === undefined ? directFileToolName(toolName, input) : undefined;
|
|
3476
|
+
if (fileTool !== undefined &&
|
|
3477
|
+
directFileToolAllowed(fileTool, this.project.agent.allowedTools)) {
|
|
3478
|
+
return this.directFileToolOutcome({
|
|
3479
|
+
name: fileTool,
|
|
3536
3480
|
toolName,
|
|
3537
3481
|
input,
|
|
3538
3482
|
callId,
|
|
3539
3483
|
sessionId: record?.sessionId,
|
|
3540
3484
|
continuationKey: record?.continuationKey ?? session.continuationKey ?? undefined,
|
|
3541
3485
|
cwd: workspaceDir,
|
|
3486
|
+
busy: identity.busy,
|
|
3542
3487
|
dryRun: record?.dryRun === true,
|
|
3543
3488
|
});
|
|
3544
|
-
if (native !== undefined) {
|
|
3545
|
-
return native;
|
|
3546
|
-
}
|
|
3547
3489
|
}
|
|
3548
|
-
let tool = this.project.agent.tools.find((t) => t.name === toolName);
|
|
3549
3490
|
if (tool === undefined &&
|
|
3550
3491
|
this.project.agent.connections.some((c) => c.advertiseTools === true)) {
|
|
3551
3492
|
// Advertised passthroughs are ordinary server tools in the session's
|
|
@@ -4882,6 +4823,10 @@ function buildRunnerSubagents(agent) {
|
|
|
4882
4823
|
...(subagent.model === undefined ? {} : { model: subagent.model }),
|
|
4883
4824
|
}));
|
|
4884
4825
|
}
|
|
4826
|
+
/** The message of a native tool call's error result. */
|
|
4827
|
+
function describeToolCallError(error) {
|
|
4828
|
+
return isRecord(error) && typeof error.message === "string" ? error.message : "tool call failed";
|
|
4829
|
+
}
|
|
4885
4830
|
function toolErrorResult(message) {
|
|
4886
4831
|
return {
|
|
4887
4832
|
content: [{ type: "text", text: message }],
|