@grok/agent-sdk 0.4.0 → 0.5.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/docs/404.html +2 -2
- package/dist/docs/assets/{app.BSH__xV4.js → app.CYdjweqP.js} +4 -4
- package/dist/docs/assets/changelog.md.BMrJ5WxW.js +1 -0
- package/dist/docs/assets/changelog.md.BMrJ5WxW.lean.js +1 -0
- package/dist/docs/assets/chunks/@localSearchIndexroot.dUaE1f8e.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.Cadl7A0k.js → VPLocalSearchBox.CRATKS9J.js} +1 -1
- package/dist/docs/assets/chunks/{arc.K7t9nNY6.js → arc.BxM78ISR.js} +1 -1
- package/dist/docs/assets/chunks/{architectureDiagram-Q4EWVU46.SlHEknkX.js → architectureDiagram-Q4EWVU46.Bi6MuKaU.js} +1 -1
- package/dist/docs/assets/chunks/{baseUniq.DJLRMLkz.js → baseUniq.L47qqpDG.js} +1 -1
- package/dist/docs/assets/chunks/{blockDiagram-DXYQGD6D.Bs6XxFpe.js → blockDiagram-DXYQGD6D.kHFF2FK5.js} +1 -1
- package/dist/docs/assets/chunks/{c4Diagram-AHTNJAMY.CyLg6Ovc.js → c4Diagram-AHTNJAMY.BTW85ll3.js} +1 -1
- package/dist/docs/assets/chunks/channel.ljJtQtBi.js +1 -0
- package/dist/docs/assets/chunks/{chunk-4BX2VUAB.DTQ4TinT.js → chunk-4BX2VUAB.Bbh3_48g.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-4TB4RGXK.Es84IgcH.js → chunk-4TB4RGXK.WeAmK3fK.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-55IACEB6.Clm3cGPQ.js → chunk-55IACEB6.DTdUiVHf.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-EDXVE4YY.DE4CRkS5.js → chunk-EDXVE4YY.n5XzANDz.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-FMBD7UC4.Bf8HCvqp.js → chunk-FMBD7UC4.D51eewCb.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-OYMX7WX6.eub-7nSx.js → chunk-OYMX7WX6.BrY0U7ZV.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-QZHKN3VN.WyP9VAS_.js → chunk-QZHKN3VN.B0OA4aFV.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-YZCP3GAM.LO9ohhDE.js → chunk-YZCP3GAM.Djt3Mjft.js} +1 -1
- package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.BZ3Uc-XU.js +1 -0
- package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.BZ3Uc-XU.js +1 -0
- package/dist/docs/assets/chunks/clone.BDtbEo69.js +1 -0
- package/dist/docs/assets/chunks/{cose-bilkent-S5V4N54A.D5za6aH0.js → cose-bilkent-S5V4N54A.DiMcA6Q8.js} +1 -1
- package/dist/docs/assets/chunks/{dagre-KV5264BT.Dq1daUru.js → dagre-KV5264BT.BGqI4vrS.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-5BDNPKRD.j1YL5BKS.js → diagram-5BDNPKRD.bDqFuMoH.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-G4DWMVQ6.Bi1aLdhC.js → diagram-G4DWMVQ6.Y0sxaXRU.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-MMDJMWI5.BOzMEkAr.js → diagram-MMDJMWI5.Bg43b0yi.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-TYMM5635.Dx2FVhCr.js → diagram-TYMM5635.DCfVasEC.js} +1 -1
- package/dist/docs/assets/chunks/{erDiagram-SMLLAGMA.DI4TNkye.js → erDiagram-SMLLAGMA.C72GaD16.js} +1 -1
- package/dist/docs/assets/chunks/{flowDiagram-DWJPFMVM.C58Z9uPK.js → flowDiagram-DWJPFMVM.DxRQj7pP.js} +1 -1
- package/dist/docs/assets/chunks/{ganttDiagram-T4ZO3ILL.DXSpW809.js → ganttDiagram-T4ZO3ILL.DiLZy5Q4.js} +1 -1
- package/dist/docs/assets/chunks/{gitGraphDiagram-UUTBAWPF.B955oaFl.js → gitGraphDiagram-UUTBAWPF.DL8XkRvh.js} +1 -1
- package/dist/docs/assets/chunks/{graph.BQXhKtxS.js → graph.3Xub80xJ.js} +1 -1
- package/dist/docs/assets/chunks/{infoDiagram-42DDH7IO.Dozj_-Gm.js → infoDiagram-42DDH7IO.O3lGaspu.js} +1 -1
- package/dist/docs/assets/chunks/{ishikawaDiagram-UXIWVN3A.D2140OzH.js → ishikawaDiagram-UXIWVN3A.w-pCiQzn.js} +1 -1
- package/dist/docs/assets/chunks/{journeyDiagram-VCZTEJTY.DrqrMhCk.js → journeyDiagram-VCZTEJTY.Cg_oBs9j.js} +1 -1
- package/dist/docs/assets/chunks/{kanban-definition-6JOO6SKY.Dv-LTrlw.js → kanban-definition-6JOO6SKY.BpfMGPwn.js} +1 -1
- package/dist/docs/assets/chunks/{layout.CGtHp49X.js → layout.CtwXs__p.js} +1 -1
- package/dist/docs/assets/chunks/{linear.CHZLYB52.js → linear.NmCskOrP.js} +1 -1
- package/dist/docs/assets/chunks/{min.D4Vt3eIy.js → min.DpQtsLKs.js} +1 -1
- package/dist/docs/assets/chunks/{mindmap-definition-QFDTVHPH.BBfpYTea.js → mindmap-definition-QFDTVHPH.B-P-aKVp.js} +1 -1
- package/dist/docs/assets/chunks/{pieDiagram-DEJITSTG.BVYvElmY.js → pieDiagram-DEJITSTG.BfjjqK7j.js} +1 -1
- package/dist/docs/assets/chunks/{quadrantDiagram-34T5L4WZ.C6Gc2mdY.js → quadrantDiagram-34T5L4WZ.BTzHo53F.js} +1 -1
- package/dist/docs/assets/chunks/{requirementDiagram-MS252O5E.DWa8b4cn.js → requirementDiagram-MS252O5E.DIT2FIKr.js} +1 -1
- package/dist/docs/assets/chunks/{sankeyDiagram-XADWPNL6.Bi-g4ajv.js → sankeyDiagram-XADWPNL6.NK1wCsgt.js} +1 -1
- package/dist/docs/assets/chunks/{sequenceDiagram-FGHM5R23.DlU3vVN9.js → sequenceDiagram-FGHM5R23.D9oElkvo.js} +1 -1
- package/dist/docs/assets/chunks/{stateDiagram-FHFEXIEX.CeqJRqnU.js → stateDiagram-FHFEXIEX.IPksnixH.js} +1 -1
- package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.CbhzVsQE.js +1 -0
- package/dist/docs/assets/chunks/{theme.DGq7D4tt.js → theme.CgKu7tr3.js} +2 -2
- package/dist/docs/assets/chunks/{timeline-definition-GMOUNBTQ.Cqf2kjq9.js → timeline-definition-GMOUNBTQ.CuAtJapY.js} +1 -1
- package/dist/docs/assets/chunks/{vennDiagram-DHZGUBPP.BeOpE_lM.js → vennDiagram-DHZGUBPP.B87nNW9E.js} +1 -1
- package/dist/docs/assets/chunks/wardley-RL74JXVD.BFIVMaoi.js +162 -0
- package/dist/docs/assets/chunks/{wardleyDiagram-NUSXRM2D.BXS65dAC.js → wardleyDiagram-NUSXRM2D.BELjSq8w.js} +1 -1
- package/dist/docs/assets/chunks/{xychartDiagram-5P7HB3ND.haEiSxqc.js → xychartDiagram-5P7HB3ND.5zN5ZGsz.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 +31 -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 +113 -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/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-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.map +1 -1
- package/dist/internal/sdk-runner.js +22 -40
- package/dist/internal/session-engine.d.ts +33 -19
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +170 -251
- 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-D0-FHg1x.css +1 -0
- package/dist/playground/assets/index-D5SLKUy6.js +62 -0
- package/dist/playground/index.html +2 -2
- package/dist/types.d.ts +41 -23
- package/dist/types.d.ts.map +1 -1
- package/docs/changelog.md +31 -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/docs/assets/chunks/wardley-RL74JXVD.FMQXA-6q.js +0 -162
- 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";
|
|
@@ -295,8 +296,6 @@ export class SessionEngine {
|
|
|
295
296
|
this.sessionRoots = new Map();
|
|
296
297
|
/** In-flight factory resolves, so the first turn and a racing callTool share one handle. */
|
|
297
298
|
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
299
|
this.project = options.project;
|
|
301
300
|
applyAgentContinuationDefaults(this.project);
|
|
302
301
|
this.stateRoot = options.stateRoot;
|
|
@@ -588,7 +587,9 @@ export class SessionEngine {
|
|
|
588
587
|
// inject one thread's follow-ups into another thread's turn. Nothing is
|
|
589
588
|
// lost: a borrowed checkout is its own git root, so the harness reads its
|
|
590
589
|
// hooks rather than these, and follow-ups drain at the turn boundary.
|
|
591
|
-
this.hasBorrowedWorkspace(record)
|
|
590
|
+
this.hasBorrowedWorkspace(record) ||
|
|
591
|
+
// No Cursor hook runs on a tree.
|
|
592
|
+
this.confinesWorkspaceReads("local")) {
|
|
592
593
|
return;
|
|
593
594
|
}
|
|
594
595
|
if (steeringEnabled()) {
|
|
@@ -1422,47 +1423,62 @@ export class SessionEngine {
|
|
|
1422
1423
|
hasRootOverride() {
|
|
1423
1424
|
return this.project.agent.fs !== undefined || this.project.agent.root !== undefined;
|
|
1424
1425
|
}
|
|
1426
|
+
/**
|
|
1427
|
+
* A sandboxed host-disk agent whose `tools` grant file tools and no shell
|
|
1428
|
+
* runs on its session workspace as a tree, mounted at its `workspace`.
|
|
1429
|
+
*/
|
|
1430
|
+
confinesWorkspaceReads(runtime) {
|
|
1431
|
+
const agent = this.project.agent;
|
|
1432
|
+
return (runtime === "local" &&
|
|
1433
|
+
!this.hasRootOverride() &&
|
|
1434
|
+
confinesWorkspaceReads({ local: agent.local, tools: agent.allowedTools }));
|
|
1435
|
+
}
|
|
1436
|
+
treeWorkspace() {
|
|
1437
|
+
return this.project.agent.workspace ?? DEFAULT_TREE_WORKSPACE;
|
|
1438
|
+
}
|
|
1439
|
+
/**
|
|
1440
|
+
* The session workspace at {@link treeWorkspace}, with the skills mount over
|
|
1441
|
+
* it. Shared memory is a symlink out of the workspace, so it is mounted
|
|
1442
|
+
* read-only in its place, as a sandboxed host agent can read it but not
|
|
1443
|
+
* write through the link.
|
|
1444
|
+
*/
|
|
1445
|
+
async workspaceTree(cwd, options) {
|
|
1446
|
+
const skills = this.project.agent.skills;
|
|
1447
|
+
const workspace = this.treeWorkspace();
|
|
1448
|
+
return sessionFileSystem({
|
|
1449
|
+
authored: unionFs({
|
|
1450
|
+
[workspace]: hostDirectoryTree(cwd),
|
|
1451
|
+
[posix.join(workspace, MEMORY_DIR_NAME)]: readOnlyFs(hostDirectoryTree(join(this.stateRoot, MEMORY_DIR_NAME))),
|
|
1452
|
+
}),
|
|
1453
|
+
skills: skills.length === 0
|
|
1454
|
+
? undefined
|
|
1455
|
+
: { path: SKILLS_MOUNT_PATH, fs: await this.baseSkillsFileSystem() },
|
|
1456
|
+
scratch: options.scratch ? tempFs() : undefined,
|
|
1457
|
+
});
|
|
1458
|
+
}
|
|
1425
1459
|
/** The field the author set, for messages. Discovery copies a lone `root` onto `fs`. */
|
|
1426
1460
|
authoredFsField() {
|
|
1427
1461
|
return this.project.agent.root === undefined ? "fs" : "root";
|
|
1428
1462
|
}
|
|
1429
1463
|
/**
|
|
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.
|
|
1464
|
+
* The tree an `fs` agent runs on: the authored `fs` at `/` with the
|
|
1465
|
+
* skills mount over it. A turn passes it to the SDK as `local.fs`, and
|
|
1466
|
+
* the SDK mounts a fresh `/tmp` over it for each run. A direct call
|
|
1467
|
+
* gets its own empty `/tmp` (`scratch`), so it sees what a run sees.
|
|
1468
|
+
* Authored `fs` (static or factory) is cached per session when `cache`
|
|
1469
|
+
* is set; unscoped `callTool` passes the invocation id and does not
|
|
1470
|
+
* cache, so factories cannot share one tree across callers. A static
|
|
1471
|
+
* handle is used as authored — every session sees that same object.
|
|
1440
1472
|
*/
|
|
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
|
-
}
|
|
1473
|
+
async resolveSessionTree(options) {
|
|
1449
1474
|
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({
|
|
1475
|
+
return sessionFileSystem({
|
|
1457
1476
|
authored: authored.fs,
|
|
1458
1477
|
skills: authored.skills === undefined
|
|
1459
1478
|
? undefined
|
|
1460
1479
|
: { path: SKILLS_MOUNT_PATH, fs: authored.skills },
|
|
1480
|
+
scratch: options.scratch === true ? tempFs() : undefined,
|
|
1461
1481
|
});
|
|
1462
|
-
if (options.cache && this.isTurnRunning(options.sessionId)) {
|
|
1463
|
-
this.turnRoots.set(options.sessionId, { root, cwd: options.cwd });
|
|
1464
|
-
}
|
|
1465
|
-
return root;
|
|
1466
1482
|
}
|
|
1467
1483
|
async resolveAuthoredFileSystem(options) {
|
|
1468
1484
|
const agent = this.project.agent;
|
|
@@ -1547,60 +1563,42 @@ export class SessionEngine {
|
|
|
1547
1563
|
});
|
|
1548
1564
|
return this.baseSkills;
|
|
1549
1565
|
}
|
|
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;
|
|
1566
|
+
/**
|
|
1567
|
+
* A native file tool run outside a turn, on the tree a turn of this
|
|
1568
|
+
* session would use. Host-disk agents run it on the harness cwd,
|
|
1569
|
+
* confined to that cwd, with the workspace set to the cwd as a turn's
|
|
1570
|
+
* native tools report it. The read verbs can also reach the SDK's spill
|
|
1571
|
+
* directory for that cwd, where native WebFetch and WebSearch write
|
|
1572
|
+
* large output.
|
|
1573
|
+
*/
|
|
1574
|
+
async directFileToolOutcome(options) {
|
|
1575
|
+
const { toolName, input, callId, sessionId } = options;
|
|
1576
|
+
const tools = this.hasRootOverride()
|
|
1577
|
+
? createFileSystemTools(await this.resolveSessionTree({
|
|
1578
|
+
sessionId: sessionId ?? callId,
|
|
1579
|
+
continuationKey: options.continuationKey,
|
|
1580
|
+
cache: sessionId !== undefined,
|
|
1581
|
+
scratch: true,
|
|
1582
|
+
}), { workspace: this.project.agent.workspace })
|
|
1583
|
+
: this.confinesWorkspaceReads("local")
|
|
1584
|
+
? createFileSystemTools(await this.workspaceTree(options.cwd, { scratch: true }), {
|
|
1585
|
+
workspace: this.treeWorkspace(),
|
|
1586
|
+
})
|
|
1587
|
+
: createFileSystemTools(localFileSystem({
|
|
1588
|
+
cwd: options.cwd,
|
|
1589
|
+
confineToWorkspace: true,
|
|
1590
|
+
readOnlyRoots: [hostAgentToolsDir(options.cwd)],
|
|
1591
|
+
}), { workspace: options.cwd });
|
|
1592
|
+
const tool = tools[options.name];
|
|
1593
|
+
const mutates = tool.annotations.readOnlyHint === false;
|
|
1594
|
+
if (mutates && options.busy && sessionId !== undefined) {
|
|
1595
|
+
throw new SessionBusyError(sessionId);
|
|
1597
1596
|
}
|
|
1598
1597
|
// Same policy the authored callTool path asks: a dry-run write is
|
|
1599
|
-
// answered by the host
|
|
1600
|
-
// decideToolCall and persist through the FileSystem.
|
|
1598
|
+
// answered by the host and never reaches the tree.
|
|
1601
1599
|
const decision = decideToolCall({
|
|
1602
|
-
dryRun: options.dryRun
|
|
1603
|
-
effect:
|
|
1600
|
+
dryRun: options.dryRun,
|
|
1601
|
+
effect: mutates ? "write" : "read",
|
|
1604
1602
|
input,
|
|
1605
1603
|
});
|
|
1606
1604
|
if (decision.kind === "answer") {
|
|
@@ -1610,82 +1608,34 @@ export class SessionEngine {
|
|
|
1610
1608
|
isError: false,
|
|
1611
1609
|
result: decision.result,
|
|
1612
1610
|
durationMs: 0,
|
|
1613
|
-
sessionId
|
|
1611
|
+
sessionId,
|
|
1614
1612
|
};
|
|
1615
1613
|
}
|
|
1616
|
-
const
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
const args = await this.prepareScratchToolInput({
|
|
1625
|
-
sessionId: options.sessionId,
|
|
1626
|
-
input: rawArgs,
|
|
1614
|
+
const failed = (message) => ({
|
|
1615
|
+
callId,
|
|
1616
|
+
toolName,
|
|
1617
|
+
isError: true,
|
|
1618
|
+
result: { status: "error", error: { message } },
|
|
1619
|
+
durationMs: 0,
|
|
1620
|
+
sessionId,
|
|
1621
|
+
errorMessage: message,
|
|
1627
1622
|
});
|
|
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
|
-
}
|
|
1623
|
+
let call;
|
|
1662
1624
|
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
|
-
};
|
|
1625
|
+
call = await tool.execute(isRecord(input) ? input : {});
|
|
1676
1626
|
}
|
|
1677
1627
|
catch (error) {
|
|
1678
|
-
|
|
1679
|
-
return {
|
|
1680
|
-
callId,
|
|
1681
|
-
toolName,
|
|
1682
|
-
isError: true,
|
|
1683
|
-
result: { status: "error", error: { message } },
|
|
1684
|
-
durationMs: 0,
|
|
1685
|
-
sessionId: options.sessionId,
|
|
1686
|
-
errorMessage: message,
|
|
1687
|
-
};
|
|
1628
|
+
return failed(error instanceof Error ? error.message : String(error));
|
|
1688
1629
|
}
|
|
1630
|
+
const result = call.result;
|
|
1631
|
+
if (result === undefined) {
|
|
1632
|
+
return failed(`${options.name} returned no result`);
|
|
1633
|
+
}
|
|
1634
|
+
if (result.status === "error") {
|
|
1635
|
+
const message = describeToolCallError(result.error);
|
|
1636
|
+
return { ...failed(message), result };
|
|
1637
|
+
}
|
|
1638
|
+
return { callId, toolName, isError: false, result, durationMs: 0, sessionId };
|
|
1689
1639
|
}
|
|
1690
1640
|
/**
|
|
1691
1641
|
* Local harness cwd for a session: per-send override, else the shared
|
|
@@ -1877,12 +1827,13 @@ export class SessionEngine {
|
|
|
1877
1827
|
});
|
|
1878
1828
|
const hasPendingFiles = pendingFiles !== undefined && Object.keys(pendingFiles).length > 0;
|
|
1879
1829
|
if (hasPendingFiles && runtime !== "cloud") {
|
|
1880
|
-
const root =
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1830
|
+
const root = this.hasRootOverride()
|
|
1831
|
+
? await this.resolveSessionTree({
|
|
1832
|
+
sessionId,
|
|
1833
|
+
continuationKey: record.continuationKey ?? undefined,
|
|
1834
|
+
cache: true,
|
|
1835
|
+
})
|
|
1836
|
+
: localFileSystem({ cwd: harnessCwd });
|
|
1886
1837
|
await writeWorkspaceFilesToRoot(root, pendingFiles);
|
|
1887
1838
|
}
|
|
1888
1839
|
if ((hasPendingFiles && runtime !== "cloud") ||
|
|
@@ -1901,14 +1852,6 @@ export class SessionEngine {
|
|
|
1901
1852
|
const onUpdate = async (update) => {
|
|
1902
1853
|
endFirstUpdate?.();
|
|
1903
1854
|
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
1855
|
mapper.handleUpdate(update);
|
|
1913
1856
|
// Yield so the HTTP NDJSON writer can flush tool start/result
|
|
1914
1857
|
// events while sibling parallel tools are still executing.
|
|
@@ -1952,7 +1895,6 @@ export class SessionEngine {
|
|
|
1952
1895
|
}
|
|
1953
1896
|
finally {
|
|
1954
1897
|
permit.release();
|
|
1955
|
-
this.dropTurnFileSystem(sessionId);
|
|
1956
1898
|
this.approvals.cancelSession(sessionId, "deny");
|
|
1957
1899
|
this.auths.cancelSession(sessionId, "deny");
|
|
1958
1900
|
await this.clearPendingApprovals(sessionId);
|
|
@@ -2232,34 +2174,24 @@ export class SessionEngine {
|
|
|
2232
2174
|
})
|
|
2233
2175
|
: undefined;
|
|
2234
2176
|
const authoredRoot = this.hasRootOverride();
|
|
2235
|
-
const
|
|
2236
|
-
|
|
2177
|
+
const workspaceConfined = this.confinesWorkspaceReads(runtime);
|
|
2178
|
+
const fileSystem = runtime === "local" && authoredRoot
|
|
2179
|
+
? await this.resolveSessionTree({
|
|
2237
2180
|
sessionId: record.sessionId,
|
|
2238
2181
|
continuationKey: record.continuationKey ?? undefined,
|
|
2239
2182
|
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
2183
|
})
|
|
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);
|
|
2184
|
+
: workspaceConfined
|
|
2185
|
+
? await this.workspaceTree(this.harnessCwd(record), { scratch: false })
|
|
2186
|
+
: undefined;
|
|
2187
|
+
// An agent on a tree passes its allowlist through: the SDK backs file
|
|
2188
|
+
// tools with the tree and refuses tools it cannot. Host-disk agents keep
|
|
2189
|
+
// the SDK's host natives.
|
|
2190
|
+
const harnessTools = runtime !== "local"
|
|
2191
|
+
? undefined
|
|
2192
|
+
: fileSystem !== undefined
|
|
2193
|
+
? { tools: agent.allowedTools }
|
|
2194
|
+
: resolveHostHarnessToolOptions(agent.allowedTools);
|
|
2263
2195
|
let turnPrompt = prompt;
|
|
2264
2196
|
if (isFirstTurn) {
|
|
2265
2197
|
const contextBlock = buildSessionContextBlock({
|
|
@@ -2327,27 +2259,34 @@ export class SessionEngine {
|
|
|
2327
2259
|
turnPrompt = [preamble, ...sections, turnPrompt].filter((part) => part !== "").join("\n\n");
|
|
2328
2260
|
}
|
|
2329
2261
|
}
|
|
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.
|
|
2262
|
+
// An `fs` agent has no scaffold dir, so its catalog embeds script
|
|
2263
|
+
// bodies and indexes the skills mounted in the tree.
|
|
2336
2264
|
const localInstructions = runtime === "local"
|
|
2337
2265
|
? authoredRoot
|
|
2338
|
-
? buildAgentsMdContent(
|
|
2266
|
+
? buildAgentsMdContent(instructionsAgent, {
|
|
2267
|
+
includeScripts: true,
|
|
2268
|
+
skillsIndex: agent.skillsMount !== false,
|
|
2269
|
+
})
|
|
2339
2270
|
: buildAgentsMdContent(instructionsAgent, {
|
|
2340
2271
|
includeScripts: this.hasBorrowedWorkspace(record),
|
|
2272
|
+
skillsIndex: workspaceConfined && agent.skills.length > 0,
|
|
2341
2273
|
})
|
|
2342
2274
|
: undefined;
|
|
2343
|
-
const childFiles = authoredRoot && root !== undefined ? createRootSubagentInherit(root) : undefined;
|
|
2344
2275
|
const selection = this.turnModel(record);
|
|
2345
2276
|
return {
|
|
2346
2277
|
sessionId: record.sessionId,
|
|
2347
2278
|
...(record.sdkAgentId === undefined ? {} : { sdkAgentId: record.sdkAgentId }),
|
|
2348
2279
|
workspaceDir: this.harnessCwd(record),
|
|
2349
|
-
sandbox:
|
|
2350
|
-
|
|
2280
|
+
sandbox: agent.local?.sandbox === true,
|
|
2281
|
+
fs: fileSystem,
|
|
2282
|
+
reportedWorkspacePath: authoredRoot
|
|
2283
|
+
? agent.workspace
|
|
2284
|
+
: workspaceConfined
|
|
2285
|
+
? this.treeWorkspace()
|
|
2286
|
+
: undefined,
|
|
2287
|
+
// As on the host, project rules load from the workspace: the tree's
|
|
2288
|
+
// `<workspace>/AGENTS.md` and `<workspace>/.cursor/rules/`.
|
|
2289
|
+
settingSources: fileSystem === undefined ? undefined : ["project"],
|
|
2351
2290
|
...(runtime === "local" && harnessTools !== undefined
|
|
2352
2291
|
? {
|
|
2353
2292
|
...(harnessTools.tools === undefined ? {} : { tools: harnessTools.tools }),
|
|
@@ -2380,9 +2319,7 @@ export class SessionEngine {
|
|
|
2380
2319
|
...(runtime === "cloud" && !isCursorHostedFilesAvailable()
|
|
2381
2320
|
? { agentServeAgent: this.project.name }
|
|
2382
2321
|
: {}),
|
|
2383
|
-
customTools: runtime === "local"
|
|
2384
|
-
? await this.buildCustomTools(record, turnId, emit, synthesized, signal, childFiles)
|
|
2385
|
-
: {},
|
|
2322
|
+
customTools: runtime === "local" ? await this.buildCustomTools(record, turnId, emit, signal) : {},
|
|
2386
2323
|
mcpServers: this.buildMcpServers(runtime, record.sessionId, await this.evaluateConnectionAuth(record)),
|
|
2387
2324
|
...(runtime === "local" &&
|
|
2388
2325
|
(this.hasAttachedAuthedConnections() ||
|
|
@@ -2628,7 +2565,7 @@ export class SessionEngine {
|
|
|
2628
2565
|
}
|
|
2629
2566
|
return evaluated;
|
|
2630
2567
|
}
|
|
2631
|
-
async buildCustomTools(record, turnId, emit,
|
|
2568
|
+
async buildCustomTools(record, turnId, emit, signal) {
|
|
2632
2569
|
const agent = this.project.agent;
|
|
2633
2570
|
const tools = {};
|
|
2634
2571
|
const register = (tool) => {
|
|
@@ -2642,31 +2579,19 @@ export class SessionEngine {
|
|
|
2642
2579
|
// MCP passthrough's server-declared hints (bounded at listing time)
|
|
2643
2580
|
// ride into the harness listing once the dependency bumps.
|
|
2644
2581
|
...(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
|
-
},
|
|
2582
|
+
execute: async (args, context) => this.executeServerTool({
|
|
2583
|
+
tool,
|
|
2584
|
+
input: args,
|
|
2585
|
+
toolCallId: context.toolCallId,
|
|
2586
|
+
record,
|
|
2587
|
+
turnId,
|
|
2588
|
+
emit,
|
|
2589
|
+
signal,
|
|
2590
|
+
fromModel: true,
|
|
2591
|
+
}),
|
|
2667
2592
|
};
|
|
2668
2593
|
};
|
|
2669
|
-
for (const tool of
|
|
2594
|
+
for (const tool of agent.tools) {
|
|
2670
2595
|
if (tool.execution !== "server") {
|
|
2671
2596
|
continue;
|
|
2672
2597
|
}
|
|
@@ -3519,33 +3444,23 @@ export class SessionEngine {
|
|
|
3519
3444
|
const session = identity.session;
|
|
3520
3445
|
let workspaceDir = identity.workspaceDir;
|
|
3521
3446
|
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({
|
|
3447
|
+
let tool = this.project.agent.tools.find((t) => t.name === toolName);
|
|
3448
|
+
// An authored tool owns its exact name; the natives stay reachable by their other names.
|
|
3449
|
+
const fileTool = tool === undefined ? directFileToolName(toolName, input) : undefined;
|
|
3450
|
+
if (fileTool !== undefined &&
|
|
3451
|
+
directFileToolAllowed(fileTool, this.project.agent.allowedTools)) {
|
|
3452
|
+
return this.directFileToolOutcome({
|
|
3453
|
+
name: fileTool,
|
|
3536
3454
|
toolName,
|
|
3537
3455
|
input,
|
|
3538
3456
|
callId,
|
|
3539
3457
|
sessionId: record?.sessionId,
|
|
3540
3458
|
continuationKey: record?.continuationKey ?? session.continuationKey ?? undefined,
|
|
3541
3459
|
cwd: workspaceDir,
|
|
3460
|
+
busy: identity.busy,
|
|
3542
3461
|
dryRun: record?.dryRun === true,
|
|
3543
3462
|
});
|
|
3544
|
-
if (native !== undefined) {
|
|
3545
|
-
return native;
|
|
3546
|
-
}
|
|
3547
3463
|
}
|
|
3548
|
-
let tool = this.project.agent.tools.find((t) => t.name === toolName);
|
|
3549
3464
|
if (tool === undefined &&
|
|
3550
3465
|
this.project.agent.connections.some((c) => c.advertiseTools === true)) {
|
|
3551
3466
|
// Advertised passthroughs are ordinary server tools in the session's
|
|
@@ -4882,6 +4797,10 @@ function buildRunnerSubagents(agent) {
|
|
|
4882
4797
|
...(subagent.model === undefined ? {} : { model: subagent.model }),
|
|
4883
4798
|
}));
|
|
4884
4799
|
}
|
|
4800
|
+
/** The message of a native tool call's error result. */
|
|
4801
|
+
function describeToolCallError(error) {
|
|
4802
|
+
return isRecord(error) && typeof error.message === "string" ? error.message : "tool call failed";
|
|
4803
|
+
}
|
|
4885
4804
|
function toolErrorResult(message) {
|
|
4886
4805
|
return {
|
|
4887
4806
|
content: [{ type: "text", text: message }],
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The SDK's file tools normalize every path to POSIX form with a leading
|
|
3
|
+
* `/`, so a Windows path such as `C:\Users\me\a.txt` reaches a FileSystem
|
|
4
|
+
* as `/C:/Users/me/a.txt`. Strip that leading `/` on Windows so the host
|
|
5
|
+
* path module sees a drive path.
|
|
6
|
+
*/
|
|
7
|
+
export declare function hostPathFromToolPath(input: string, platform?: NodeJS.Platform): string;
|
|
8
|
+
//# sourceMappingURL=tool-paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-paths.d.ts","sourceRoot":"","sources":["../../src/internal/tool-paths.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC3C,MAAM,CAKR"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The SDK's file tools normalize every path to POSIX form with a leading
|
|
3
|
+
* `/`, so a Windows path such as `C:\Users\me\a.txt` reaches a FileSystem
|
|
4
|
+
* as `/C:/Users/me/a.txt`. Strip that leading `/` on Windows so the host
|
|
5
|
+
* path module sees a drive path.
|
|
6
|
+
*/
|
|
7
|
+
export function hostPathFromToolPath(input, platform = process.platform) {
|
|
8
|
+
if (platform === "win32" && /^\/[A-Za-z]:(?:[\\/]|$)/.test(input)) {
|
|
9
|
+
return input.slice(1);
|
|
10
|
+
}
|
|
11
|
+
return input;
|
|
12
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { FileSystem } from "@cursor/sdk";
|
|
2
|
+
/**
|
|
3
|
+
* A host directory as a tree rooted at `/`: `/src/a.ts` is `<dir>/src/a.ts`.
|
|
4
|
+
* A path that resolves outside the directory, through `..` or a symlink, is
|
|
5
|
+
* refused. Results and error messages name tree paths, never host paths.
|
|
6
|
+
*/
|
|
7
|
+
export declare function hostDirectoryTree(dir: string): FileSystem;
|
|
8
|
+
/** Where a confined host workspace is mounted when the agent sets no `workspace`. */
|
|
9
|
+
export declare const DEFAULT_TREE_WORKSPACE = "/workspace";
|
|
10
|
+
/**
|
|
11
|
+
* Whether a host-disk agent runs on its session workspace as a tree: it is
|
|
12
|
+
* sandboxed, its `tools` grant a file tool, and they grant no shell. Its
|
|
13
|
+
* reads then stay inside the workspace without a shell that could read
|
|
14
|
+
* around them.
|
|
15
|
+
*/
|
|
16
|
+
export declare function confinesWorkspaceReads(agent: {
|
|
17
|
+
readonly local?: {
|
|
18
|
+
readonly sandbox?: boolean;
|
|
19
|
+
};
|
|
20
|
+
readonly tools?: readonly string[];
|
|
21
|
+
}): boolean;
|
|
22
|
+
/** `tools` without the ones a tree cannot back, and the names it dropped. */
|
|
23
|
+
export declare function treeToolAllowlist<T extends string>(tools: readonly T[]): {
|
|
24
|
+
tools: T[];
|
|
25
|
+
dropped: T[];
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=workspace-tree.d.ts.map
|