@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
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native file tools for direct tool calls (`POST /v1/tools/:toolName`).
|
|
3
|
+
* The tools themselves are the SDK's `createFileSystemTools`; this module
|
|
4
|
+
* only maps the names a caller may use onto them and applies the agent's
|
|
5
|
+
* `tools` allowlist the way a turn does.
|
|
6
|
+
*/
|
|
7
|
+
import { homedir } from "node:os";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import { isRecord } from "./is-record.js";
|
|
10
|
+
const DIRECT_FILE_TOOL_NAMES = {
|
|
11
|
+
read: "Read",
|
|
12
|
+
Read: "Read",
|
|
13
|
+
ls: "LS",
|
|
14
|
+
LS: "LS",
|
|
15
|
+
glob: "Glob",
|
|
16
|
+
Glob: "Glob",
|
|
17
|
+
grep: "Grep",
|
|
18
|
+
Grep: "Grep",
|
|
19
|
+
write: "Write",
|
|
20
|
+
Write: "Write",
|
|
21
|
+
StrReplace: "StrReplace",
|
|
22
|
+
delete: "Delete",
|
|
23
|
+
Delete: "Delete",
|
|
24
|
+
};
|
|
25
|
+
/** The `tools` names that grant each file tool in a turn. */
|
|
26
|
+
const ALLOWLIST_GRANTS = {
|
|
27
|
+
Read: "read",
|
|
28
|
+
LS: "ls",
|
|
29
|
+
Glob: "glob",
|
|
30
|
+
Grep: "grep",
|
|
31
|
+
Write: "edit",
|
|
32
|
+
StrReplace: "edit",
|
|
33
|
+
Delete: "delete",
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* The file tool a direct call runs. `edit` with `fileText` or `contents`
|
|
37
|
+
* is Write; any other `edit` is StrReplace.
|
|
38
|
+
*/
|
|
39
|
+
export function directFileToolName(name, input) {
|
|
40
|
+
if (name === "edit") {
|
|
41
|
+
const args = isRecord(input) ? input : {};
|
|
42
|
+
return "fileText" in args || "contents" in args ? "Write" : "StrReplace";
|
|
43
|
+
}
|
|
44
|
+
return DIRECT_FILE_TOOL_NAMES[name];
|
|
45
|
+
}
|
|
46
|
+
/** Omitted `tools` allows every file tool, as it does in a turn. */
|
|
47
|
+
export function directFileToolAllowed(name, tools) {
|
|
48
|
+
return tools === undefined || tools.includes(ALLOWLIST_GRANTS[name]);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Where the SDK spills large WebFetch and WebSearch output for a host
|
|
52
|
+
* cwd. Direct Read calls on a host-disk agent may read it.
|
|
53
|
+
*/
|
|
54
|
+
export function hostAgentToolsDir(cwd) {
|
|
55
|
+
const slug = cwd
|
|
56
|
+
.replace(/[^a-zA-Z0-9]/g, "-")
|
|
57
|
+
.replace(/-+/g, "-")
|
|
58
|
+
.replace(/^-+|-+$/g, "");
|
|
59
|
+
return path.join(homedir(), ".cursor", "projects", slug, "agent-tools");
|
|
60
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../src/internal/discovery/agent.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../src/internal/discovery/agent.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAQL,KAAK,aAAa,EACnB,MAAM,gBAAgB,CAAC;AAgBxB,OAAO,EAAE,KAAK,gBAAgB,EAAqC,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,KAAK,sBAAsB,EAAoB,MAAM,iBAAiB,CAAC;AAShF,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,aAAa,CAAC;IACrB,YAAY,EAAE,IAAI,CAChB,sBAAsB,EACtB,OAAO,GAAG,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,CAC/D,CAAC;CACH;AAED,wBAAsB,SAAS,CAC7B,GAAG,EAAE,gBAAgB,EACrB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GACzC,OAAO,CAAC,eAAe,CAAC,CAyQ1B;AA6CD,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA0C7F"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Compile one `agent/` directory (and its subagents) into a {@link ResolvedAgent}.
|
|
3
3
|
*/
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { assertNoRemovedFileSearchTools,
|
|
4
|
+
import { join, posix } from "node:path";
|
|
5
|
+
import { assertNoRemovedFileSearchTools, isRemovedFileSearchTool } from "../../filesystem.js";
|
|
6
6
|
import { DEFAULT_MODEL, } from "../../types.js";
|
|
7
|
-
import { synthesizedFileSystemToolNames } from "../filesystem/tools.js";
|
|
8
7
|
import { FS_AND_ROOT_CONFLICT, withIdentityPreamble } from "../workspace.js";
|
|
8
|
+
import { confinesWorkspaceReads, treeToolAllowlist } from "../workspace-tree.js";
|
|
9
9
|
import { isValidModelSetting, loadAgentConfig, resolveAgentCwd, resolveArchitecture, resolveConcurrency, resolveFallbackAfterStream, resolveHosting, resolveLocalCwd, rejectPersistentOption, resolveModelFallbacks, } from "./agent-config.js";
|
|
10
10
|
import { loadConnections, loadHostConnections } from "./connections.js";
|
|
11
11
|
import { displayPath, pushConfigDiagnostic } from "./context.js";
|
|
@@ -85,15 +85,12 @@ export async function loadAgent(ctx, agentDir, options) {
|
|
|
85
85
|
const authoredAllowlist = config?.tools;
|
|
86
86
|
const authored = authoredFileSystem(ctx, agentDir, config);
|
|
87
87
|
const root = authored?.fs;
|
|
88
|
-
const hasRoot = authored !== undefined;
|
|
89
88
|
if (authored !== undefined) {
|
|
90
|
-
if (config?.local?.cwd !== undefined ||
|
|
91
|
-
config?.local?.workspaceDir !== undefined ||
|
|
92
|
-
config?.local?.sandbox === true) {
|
|
89
|
+
if (config?.local?.cwd !== undefined || config?.local?.workspaceDir !== undefined) {
|
|
93
90
|
pushConfigDiagnostic(ctx, {
|
|
94
91
|
severity: "error",
|
|
95
92
|
path: displayPath(ctx, join(agentDir, "agent.ts")),
|
|
96
|
-
message: `\`${authored.field}\` cannot be combined with \`local.cwd
|
|
93
|
+
message: `\`${authored.field}\` cannot be combined with \`local.cwd\` or \`local.workspaceDir\`. Those fields configure the host tree the override replaced.`,
|
|
97
94
|
});
|
|
98
95
|
}
|
|
99
96
|
if (runtime === "cloud") {
|
|
@@ -112,70 +109,58 @@ export async function loadAgent(ctx, agentDir, options) {
|
|
|
112
109
|
});
|
|
113
110
|
}
|
|
114
111
|
}
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
tools: authoredAllowlist,
|
|
118
|
-
}));
|
|
119
|
-
const clash = tools.find((tool) => {
|
|
120
|
-
if (isRemovedFileSearchTool(tool.name) || reservedNames.has(tool.name)) {
|
|
121
|
-
return true;
|
|
122
|
-
}
|
|
123
|
-
const canonical = canonicalizeFileSystemToolName(tool.name);
|
|
124
|
-
return canonical !== undefined && reservedNames.has(canonical);
|
|
125
|
-
});
|
|
126
|
-
if (clash !== undefined) {
|
|
112
|
+
const removedSearchTool = tools.find((tool) => isRemovedFileSearchTool(tool.name));
|
|
113
|
+
if (removedSearchTool !== undefined) {
|
|
127
114
|
ctx.diagnostics.push({
|
|
128
115
|
severity: "error",
|
|
129
|
-
path: displayPath(ctx, join(agentDir, "tools", `${
|
|
130
|
-
message:
|
|
131
|
-
? `Semantic search has been removed. Use Grep. Tool name "${clash.name}" is not available.`
|
|
132
|
-
: `Tool name "${clash.name}" is reserved for the synthesized FileSystem tool.`,
|
|
116
|
+
path: displayPath(ctx, join(agentDir, "tools", `${removedSearchTool.name}.ts`)),
|
|
117
|
+
message: `Semantic search has been removed. Use Grep. Tool name "${removedSearchTool.name}" is not available.`,
|
|
133
118
|
});
|
|
134
119
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
path: displayPath(ctx, join(agentDir, "agent.ts")),
|
|
143
|
-
message: error instanceof FileSystemConfigError
|
|
144
|
-
? error.message
|
|
145
|
-
: error instanceof Error
|
|
146
|
-
? error.message
|
|
147
|
-
: String(error),
|
|
148
|
-
});
|
|
149
|
-
}
|
|
120
|
+
// A sandboxed host agent with file tools and no shell runs on its session
|
|
121
|
+
// workspace as a tree, so its reads stay in the workspace.
|
|
122
|
+
const workspaceConfined = root === undefined &&
|
|
123
|
+
runtime === "local" &&
|
|
124
|
+
confinesWorkspaceReads({ local: config?.local, tools: authoredAllowlist });
|
|
125
|
+
try {
|
|
126
|
+
assertNoRemovedFileSearchTools(authoredAllowlist);
|
|
150
127
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
resolveFileSystemTools({
|
|
158
|
-
root,
|
|
159
|
-
tools: authoredAllowlist,
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
resolveRootHarnessAllowlist(authoredAllowlist);
|
|
164
|
-
}
|
|
165
|
-
allowedTools = authoredAllowlist;
|
|
166
|
-
}
|
|
167
|
-
catch (error) {
|
|
168
|
-
pushConfigDiagnostic(ctx, {
|
|
169
|
-
severity: "error",
|
|
170
|
-
path: displayPath(ctx, join(agentDir, "agent.ts")),
|
|
171
|
-
message: error instanceof FileSystemConfigError
|
|
172
|
-
? error.message
|
|
173
|
-
: error instanceof Error
|
|
174
|
-
? error.message
|
|
175
|
-
: String(error),
|
|
176
|
-
});
|
|
177
|
-
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
pushConfigDiagnostic(ctx, {
|
|
130
|
+
severity: "error",
|
|
131
|
+
path: displayPath(ctx, join(agentDir, "agent.ts")),
|
|
132
|
+
message: error instanceof Error ? error.message : String(error),
|
|
133
|
+
});
|
|
178
134
|
}
|
|
135
|
+
const workspaceProblem = checkWorkspace(config?.workspace);
|
|
136
|
+
if (workspaceProblem !== undefined) {
|
|
137
|
+
pushConfigDiagnostic(ctx, {
|
|
138
|
+
severity: "error",
|
|
139
|
+
path: displayPath(ctx, join(agentDir, "agent.ts")),
|
|
140
|
+
message: workspaceProblem,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
if (root === undefined && !workspaceConfined && config?.workspace !== undefined) {
|
|
144
|
+
pushConfigDiagnostic(ctx, {
|
|
145
|
+
severity: "error",
|
|
146
|
+
path: displayPath(ctx, join(agentDir, "agent.ts")),
|
|
147
|
+
message: "`workspace` places the workspace inside a tree: the one `fs` sets, or the session workspace of a sandboxed agent whose `tools` list file tools and no shell. Set `fs`, or remove it.",
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
const treeTools = authoredAllowlist !== undefined && (root !== undefined || workspaceConfined)
|
|
151
|
+
? treeToolAllowlist(authoredAllowlist)
|
|
152
|
+
: undefined;
|
|
153
|
+
if (treeTools !== undefined && treeTools.dropped.length > 0) {
|
|
154
|
+
pushConfigDiagnostic(ctx, {
|
|
155
|
+
severity: "warning",
|
|
156
|
+
path: displayPath(ctx, join(agentDir, "agent.ts")),
|
|
157
|
+
message: `\`tools\` lists ${treeTools.dropped.join(", ")}, which an agent on a tree cannot run. Agent SDK leaves ${treeTools.dropped.length === 1 ? "it" : "them"} out.`,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
const listedTools = treeTools?.tools ?? authoredAllowlist;
|
|
161
|
+
const allowedTools = listedTools === undefined || listedTools.includes("mcp")
|
|
162
|
+
? listedTools
|
|
163
|
+
: [...listedTools, "mcp"];
|
|
179
164
|
// The allowlist states runtime-agnostic intent, but only the local
|
|
180
165
|
// harness can enforce it (the Cursor SDK rejects tool restrictions on
|
|
181
166
|
// cloud agents, and the Grok Bot harness has its own fixed toolset) — a
|
|
@@ -254,6 +239,7 @@ export async function loadAgent(ctx, agentDir, options) {
|
|
|
254
239
|
runtime,
|
|
255
240
|
fs: root,
|
|
256
241
|
root: authored?.field === "root" ? root : undefined,
|
|
242
|
+
workspace: config?.workspace === undefined ? undefined : normalizeWorkspace(config.workspace),
|
|
257
243
|
skillsMount: config?.skills,
|
|
258
244
|
cloud,
|
|
259
245
|
local,
|
|
@@ -278,6 +264,25 @@ export async function loadAgent(ctx, agentDir, options) {
|
|
|
278
264
|
},
|
|
279
265
|
};
|
|
280
266
|
}
|
|
267
|
+
/** `workspace` as the SDK's tree paths spell it: normalized, no trailing slash. */
|
|
268
|
+
function normalizeWorkspace(workspace) {
|
|
269
|
+
const normalized = posix.normalize(workspace);
|
|
270
|
+
return normalized.length > 1 && normalized.endsWith("/") ? normalized.slice(0, -1) : normalized;
|
|
271
|
+
}
|
|
272
|
+
/** Why `workspace` cannot be the workspace inside the tree, if it cannot. */
|
|
273
|
+
function checkWorkspace(workspace) {
|
|
274
|
+
if (workspace === undefined) {
|
|
275
|
+
return undefined;
|
|
276
|
+
}
|
|
277
|
+
if (!workspace.startsWith("/") || workspace.includes("\\")) {
|
|
278
|
+
return `\`workspace\` must be an absolute posix path inside \`fs\`, got ${JSON.stringify(workspace)}.`;
|
|
279
|
+
}
|
|
280
|
+
const normalized = posix.normalize(workspace);
|
|
281
|
+
if (normalized === "/tmp" || normalized.startsWith("/tmp/")) {
|
|
282
|
+
return "`workspace` cannot be under `/tmp`: the SDK mounts a fresh `/tmp` over the tree for each turn.";
|
|
283
|
+
}
|
|
284
|
+
return undefined;
|
|
285
|
+
}
|
|
281
286
|
function authoredFileSystem(ctx, agentDir, config) {
|
|
282
287
|
if (config?.fs !== undefined && config.root !== undefined) {
|
|
283
288
|
pushConfigDiagnostic(ctx, {
|
|
@@ -1,27 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Flat-index listing helpers for trees that hold a list of file paths
|
|
3
|
+
* (`hostFs`). `list` is files-only and recursive; `stat` tells file /
|
|
4
|
+
* directory / missing apart.
|
|
5
5
|
*/
|
|
6
|
-
import { type DirEntry, type FileInfo, type
|
|
7
|
-
/**
|
|
8
|
-
* Native LS `directoryTreeRoot` (LocalLsExecutor ingest tree).
|
|
9
|
-
* Synthesis builds this from `list` + `stat` via `buildLsTree`.
|
|
10
|
-
* Not a FileSystem method result and not part of the public
|
|
11
|
-
* Agent SDK surface.
|
|
12
|
-
*/
|
|
13
|
-
export interface LsDirectoryTreeNode {
|
|
14
|
-
absPath: string;
|
|
15
|
-
childrenDirs: LsDirectoryTreeNode[];
|
|
16
|
-
childrenFiles: Array<{
|
|
17
|
-
name: string;
|
|
18
|
-
}>;
|
|
19
|
-
childrenWereProcessed: boolean;
|
|
20
|
-
fullSubtreeExtensionCounts: Record<string, number>;
|
|
21
|
-
numFiles: number;
|
|
22
|
-
}
|
|
23
|
-
/** Filename-character ingest budget; matches LocalLsExecutor. */
|
|
24
|
-
export declare const LS_INGEST_CHARACTER_BUDGET = 2500;
|
|
6
|
+
import { type DirEntry, type FileInfo, type ListOptions } from "../../filesystem.js";
|
|
25
7
|
/**
|
|
26
8
|
* Yield the files under `prefix`, sorted. A file whose path equals
|
|
27
9
|
* `prefix` is not under itself.
|
|
@@ -33,25 +15,6 @@ export declare function normalizeListPrefix(prefix?: string): string;
|
|
|
33
15
|
* key with this prefix → directory; `""` / `/` → directory; else missing.
|
|
34
16
|
*/
|
|
35
17
|
export declare function statFromFilePaths(files: Iterable<string>, path: string): FileInfo;
|
|
36
|
-
export declare function collectList(root: Pick<FileSystem, "list">, prefix?: string, options?: ListOptions): Promise<DirEntry[]>;
|
|
37
|
-
export declare function collectGlob(root: Pick<FileSystem, "glob">, options: {
|
|
38
|
-
pattern: string;
|
|
39
|
-
dir?: string;
|
|
40
|
-
limit?: number;
|
|
41
|
-
}): Promise<DirEntry[]>;
|
|
42
|
-
/**
|
|
43
|
-
* List, then `stat` only when nothing came back. A non-empty listing is
|
|
44
|
-
* already a directory (a file is not under itself).
|
|
45
|
-
*/
|
|
46
|
-
export declare function collectListOrStat(root: Pick<FileSystem, "list" | "stat">, path?: string, options?: ListOptions): Promise<{
|
|
47
|
-
kind: FileInfo["kind"];
|
|
48
|
-
files: DirEntry[];
|
|
49
|
-
}>;
|
|
50
|
-
/**
|
|
51
|
-
* Build the native LS tree from a recursive file listing. Applies the
|
|
52
|
-
* LocalLsExecutor ingest budget so a huge directory truncates the same way.
|
|
53
|
-
*/
|
|
54
|
-
export declare function buildLsTree(dir: string, files: readonly DirEntry[]): LsDirectoryTreeNode;
|
|
55
18
|
/**
|
|
56
19
|
* Native LS ignore_globs: a pattern that is not already recursive is
|
|
57
20
|
* matched at any depth (the same `** /` prefix the Cursor SDK native uses).
|
|
@@ -59,15 +22,4 @@ export declare function buildLsTree(dir: string, files: readonly DirEntry[]): Ls
|
|
|
59
22
|
export declare function applyIgnores(entries: readonly DirEntry[], ignoreGlobs?: readonly string[]): DirEntry[];
|
|
60
23
|
/** True when `path` matches any {@link ListOptions.excludes} glob. */
|
|
61
24
|
export declare function isExcludedPath(path: string, excludes?: readonly string[]): boolean;
|
|
62
|
-
export declare function lsFromList(root: Pick<FileSystem, "list" | "stat">, path?: string, ignoreGlobs?: readonly string[]): Promise<{
|
|
63
|
-
status: "success";
|
|
64
|
-
value: {
|
|
65
|
-
directoryTreeRoot: LsDirectoryTreeNode;
|
|
66
|
-
};
|
|
67
|
-
} | {
|
|
68
|
-
status: "error";
|
|
69
|
-
error: {
|
|
70
|
-
message: string;
|
|
71
|
-
};
|
|
72
|
-
}>;
|
|
73
25
|
//# sourceMappingURL=walk.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../../../src/internal/filesystem/walk.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../../../src/internal/filesystem/walk.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,WAAW,EAEjB,MAAM,qBAAqB,CAAC;AAU7B;;;GAGG;AACH,wBAAuB,kBAAkB,CACvC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,EACzB,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,WAAW,GACpB,cAAc,CAAC,QAAQ,CAAC,CAqB1B;AAED,wBAAgB,mBAAmB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAK3D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,CAgBjF;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,SAAS,QAAQ,EAAE,EAC5B,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,GAC9B,QAAQ,EAAE,CAOZ;AAkBD,sEAAsE;AACtE,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAKlF"}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Flat-index listing helpers for trees that hold a list of file paths
|
|
3
|
+
* (`hostFs`). `list` is files-only and recursive; `stat` tells file /
|
|
4
|
+
* directory / missing apart.
|
|
5
5
|
*/
|
|
6
|
-
import { posix } from "node:path";
|
|
7
6
|
import { minimatch } from "minimatch";
|
|
8
|
-
import {
|
|
9
|
-
/** Filename-character ingest budget; matches LocalLsExecutor. */
|
|
10
|
-
export const LS_INGEST_CHARACTER_BUDGET = 2_500;
|
|
7
|
+
import { normalizeFsPath, } from "../../filesystem.js";
|
|
11
8
|
function takeLimit(entries, limit) {
|
|
12
9
|
if (limit === undefined || !Number.isFinite(limit)) {
|
|
13
10
|
return [...entries];
|
|
@@ -64,135 +61,6 @@ export function statFromFilePaths(files, path) {
|
|
|
64
61
|
}
|
|
65
62
|
return { kind: "missing" };
|
|
66
63
|
}
|
|
67
|
-
export async function collectList(root, prefix, options) {
|
|
68
|
-
const entries = [];
|
|
69
|
-
if (root.list === undefined) {
|
|
70
|
-
return entries;
|
|
71
|
-
}
|
|
72
|
-
for await (const entry of root.list(prefix, options)) {
|
|
73
|
-
entries.push(entry);
|
|
74
|
-
}
|
|
75
|
-
return entries;
|
|
76
|
-
}
|
|
77
|
-
export async function collectGlob(root, options) {
|
|
78
|
-
const entries = [];
|
|
79
|
-
if (root.glob === undefined) {
|
|
80
|
-
return entries;
|
|
81
|
-
}
|
|
82
|
-
const globOptions = options.limit === undefined ? undefined : { limit: options.limit };
|
|
83
|
-
for await (const entry of root.glob(options.pattern, options.dir, globOptions)) {
|
|
84
|
-
entries.push(entry);
|
|
85
|
-
}
|
|
86
|
-
return entries;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* List, then `stat` only when nothing came back. A non-empty listing is
|
|
90
|
-
* already a directory (a file is not under itself).
|
|
91
|
-
*/
|
|
92
|
-
export async function collectListOrStat(root, path, options) {
|
|
93
|
-
const files = await collectList(root, path, options);
|
|
94
|
-
if (files.length > 0) {
|
|
95
|
-
return { kind: "directory", files };
|
|
96
|
-
}
|
|
97
|
-
if (root.stat === undefined) {
|
|
98
|
-
return { kind: "missing", files };
|
|
99
|
-
}
|
|
100
|
-
const probe = path === undefined || path === "" ? "." : path;
|
|
101
|
-
return { kind: (await root.stat(probe)).kind, files };
|
|
102
|
-
}
|
|
103
|
-
function emptyLsNode(absPath) {
|
|
104
|
-
return {
|
|
105
|
-
absPath,
|
|
106
|
-
childrenDirs: [],
|
|
107
|
-
childrenFiles: [],
|
|
108
|
-
childrenWereProcessed: true,
|
|
109
|
-
fullSubtreeExtensionCounts: {},
|
|
110
|
-
numFiles: 0,
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Build the native LS tree from a recursive file listing. Applies the
|
|
115
|
-
* LocalLsExecutor ingest budget so a huge directory truncates the same way.
|
|
116
|
-
*/
|
|
117
|
-
export function buildLsTree(dir, files) {
|
|
118
|
-
const rootPath = normalizeListPrefix(dir);
|
|
119
|
-
const root = emptyLsNode(rootPath);
|
|
120
|
-
const dirNodes = new Map([[rootPath, root]]);
|
|
121
|
-
const state = {
|
|
122
|
-
charactersUsed: rootPath.length,
|
|
123
|
-
budgetExceeded: false,
|
|
124
|
-
};
|
|
125
|
-
for (const file of files) {
|
|
126
|
-
addPathToTree(file.path, rootPath, dirNodes, state, LS_INGEST_CHARACTER_BUDGET);
|
|
127
|
-
}
|
|
128
|
-
return root;
|
|
129
|
-
}
|
|
130
|
-
function addPathToTree(filePath, rootPath, dirNodes, state, characterBudget) {
|
|
131
|
-
const fileName = posix.basename(filePath);
|
|
132
|
-
const dirPath = posixParent(filePath);
|
|
133
|
-
ensureDirectoryPath(dirPath, rootPath, dirNodes, state.budgetExceeded);
|
|
134
|
-
const parentNode = dirNodes.get(dirPath);
|
|
135
|
-
if (parentNode === undefined) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
const fileCharCost = fileName.length;
|
|
139
|
-
if (!state.budgetExceeded && state.charactersUsed + fileCharCost <= characterBudget) {
|
|
140
|
-
parentNode.childrenFiles.push({ name: fileName });
|
|
141
|
-
state.charactersUsed += fileCharCost;
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
if (!state.budgetExceeded) {
|
|
145
|
-
state.budgetExceeded = true;
|
|
146
|
-
let currentDir = dirPath;
|
|
147
|
-
while (currentDir.startsWith(rootPath)) {
|
|
148
|
-
const node = dirNodes.get(currentDir);
|
|
149
|
-
if (node !== undefined) {
|
|
150
|
-
node.childrenWereProcessed = false;
|
|
151
|
-
}
|
|
152
|
-
const parentDir = posixParent(currentDir);
|
|
153
|
-
if (parentDir === currentDir) {
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
currentDir = parentDir;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
const extension = posix.extname(filePath);
|
|
160
|
-
let currentDir = dirPath;
|
|
161
|
-
while (currentDir.startsWith(rootPath)) {
|
|
162
|
-
const node = dirNodes.get(currentDir);
|
|
163
|
-
if (node !== undefined) {
|
|
164
|
-
node.fullSubtreeExtensionCounts[extension] =
|
|
165
|
-
(node.fullSubtreeExtensionCounts[extension] ?? 0) + 1;
|
|
166
|
-
node.numFiles += 1;
|
|
167
|
-
}
|
|
168
|
-
const parentDir = posixParent(currentDir);
|
|
169
|
-
if (parentDir === currentDir) {
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
currentDir = parentDir;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
function ensureDirectoryPath(dirPath, rootPath, dirNodes, budgetExceeded) {
|
|
176
|
-
if (dirNodes.has(dirPath) || dirPath === rootPath) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
const parentPath = posixParent(dirPath);
|
|
180
|
-
if (parentPath !== dirPath && pathIsUnderRoot(parentPath, rootPath)) {
|
|
181
|
-
ensureDirectoryPath(parentPath, rootPath, dirNodes, budgetExceeded);
|
|
182
|
-
}
|
|
183
|
-
const dirNode = {
|
|
184
|
-
...emptyLsNode(dirPath),
|
|
185
|
-
childrenWereProcessed: !budgetExceeded,
|
|
186
|
-
};
|
|
187
|
-
dirNodes.set(dirPath, dirNode);
|
|
188
|
-
const parentNode = dirNodes.get(parentPath);
|
|
189
|
-
if (parentNode !== undefined) {
|
|
190
|
-
parentNode.childrenDirs.push(dirNode);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
function pathIsUnderRoot(path, rootPath) {
|
|
194
|
-
return path === rootPath || path.startsWith(rootPath === "/" ? "/" : `${rootPath}/`);
|
|
195
|
-
}
|
|
196
64
|
/**
|
|
197
65
|
* Native LS ignore_globs: a pattern that is not already recursive is
|
|
198
66
|
* matched at any depth (the same `** /` prefix the Cursor SDK native uses).
|
|
@@ -223,57 +91,3 @@ export function isExcludedPath(path, excludes) {
|
|
|
223
91
|
}
|
|
224
92
|
return excludes.some((glob) => matchesIgnoreGlob(path, glob));
|
|
225
93
|
}
|
|
226
|
-
export async function lsFromList(root, path, ignoreGlobs) {
|
|
227
|
-
const listed = await collectListOrStat(root, path, {
|
|
228
|
-
limit: FILE_SYSTEM_SCAN_LIMIT,
|
|
229
|
-
...(ignoreGlobs === undefined || ignoreGlobs.length === 0 ? {} : { excludes: ignoreGlobs }),
|
|
230
|
-
});
|
|
231
|
-
const treePath = path ?? inferListedRoot(listed.files);
|
|
232
|
-
switch (listed.kind) {
|
|
233
|
-
case "missing":
|
|
234
|
-
return {
|
|
235
|
-
status: "error",
|
|
236
|
-
error: { message: `Path does not exist: ${treePath}` },
|
|
237
|
-
};
|
|
238
|
-
case "file":
|
|
239
|
-
return {
|
|
240
|
-
status: "error",
|
|
241
|
-
error: { message: `Path is not a directory: ${treePath}` },
|
|
242
|
-
};
|
|
243
|
-
case "directory":
|
|
244
|
-
return {
|
|
245
|
-
status: "success",
|
|
246
|
-
value: {
|
|
247
|
-
directoryTreeRoot: buildLsTree(treePath, applyIgnores(listed.files, ignoreGlobs)),
|
|
248
|
-
},
|
|
249
|
-
};
|
|
250
|
-
default: {
|
|
251
|
-
const unexpected = listed.kind;
|
|
252
|
-
return unexpected;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
function inferListedRoot(files) {
|
|
257
|
-
if (files.length === 0) {
|
|
258
|
-
return "/";
|
|
259
|
-
}
|
|
260
|
-
let prefix = posixParent(files[0].path);
|
|
261
|
-
for (const file of files) {
|
|
262
|
-
while (prefix !== "/" && file.path !== prefix && !file.path.startsWith(`${prefix}/`)) {
|
|
263
|
-
const parent = posixParent(prefix);
|
|
264
|
-
if (parent === prefix) {
|
|
265
|
-
return "/";
|
|
266
|
-
}
|
|
267
|
-
prefix = parent;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
return prefix;
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* `path.posix.dirname` returns `.` for slash-free paths. Treat that as
|
|
274
|
-
* the virtual root so LS walks terminate and relative files attach to `/`.
|
|
275
|
-
*/
|
|
276
|
-
function posixParent(path) {
|
|
277
|
-
const dir = posix.dirname(path);
|
|
278
|
-
return dir === "." || dir === path ? "/" : dir;
|
|
279
|
-
}
|
|
@@ -38,7 +38,7 @@ const MANAGED_AUTOMATION_TTL_MS = 60 * 60_000;
|
|
|
38
38
|
const MANAGED_AUTOMATION_MAX_ENTRIES = 10_000;
|
|
39
39
|
export function recordHostedManagedAutomation(delivery) {
|
|
40
40
|
if (delivery.managedAutomation === undefined) {
|
|
41
|
-
console.info(`[bdk] hosted managedAutomation not recorded deliveryId=${delivery.deliveryId}: admission envelope carried no managedAutomation slice (non-managed delivery, or the
|
|
41
|
+
console.info(`[bdk] hosted managedAutomation not recorded deliveryId=${delivery.deliveryId}: admission envelope carried no managedAutomation slice (non-managed delivery, or the installation has no document for the matched automation)`);
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
const managedAutomationByDelivery = managedAutomationTable();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* HTTP SERVER spans. Inbound requests extract
|
|
2
|
+
* HTTP SERVER spans. Inbound requests extract with the global propagator
|
|
3
|
+
* that `installCustomerOtel` registers (W3C trace context and baggage).
|
|
3
4
|
*/
|
|
4
5
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
5
6
|
import type { OtelRuntime } from "./runtime.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/internal/otel/http.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/internal/otel/http.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAUjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAShD,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAI3E;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,OAAO,EAAE,WAAW,EACpB,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAcZ"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* HTTP SERVER spans. Inbound requests extract
|
|
2
|
+
* HTTP SERVER spans. Inbound requests extract with the global propagator
|
|
3
|
+
* that `installCustomerOtel` registers (W3C trace context and baggage).
|
|
3
4
|
*/
|
|
4
5
|
import { context, propagation, SpanKind, SpanStatusCode, trace, } from "@opentelemetry/api";
|
|
5
6
|
import { describeError } from "../describe-error.js";
|
|
6
|
-
import { ensureW3cPropagator } from "./propagation.js";
|
|
7
7
|
const HTTP_SPAN_HANDLE_KEY = Symbol.for("anysphere.july.otel.httpSpanHandle");
|
|
8
8
|
/** End the inbound SERVER span once the Fetch status is known (hosted flush). */
|
|
9
9
|
export function endActiveHttpSpan(statusCode, error) {
|
|
@@ -34,7 +34,6 @@ function startHttpSpan(runtime, req) {
|
|
|
34
34
|
if (runtime.config.traces === false) {
|
|
35
35
|
return undefined;
|
|
36
36
|
}
|
|
37
|
-
ensureW3cPropagator();
|
|
38
37
|
const headers = {};
|
|
39
38
|
for (const [key, value] of Object.entries(req.headers)) {
|
|
40
39
|
if (typeof value === "string") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-runner.d.ts","sourceRoot":"","sources":["../../src/internal/sdk-runner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EASL,KAAK,eAAe,EAEpB,KAAK,cAAc,EAEnB,KAAK,SAAS,EAEf,MAAM,aAAa,CAAC;AAErB,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,iBAAiB,EAEtB,KAAK,WAAW,EAEjB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk-runner.d.ts","sourceRoot":"","sources":["../../src/internal/sdk-runner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EASL,KAAK,eAAe,EAEpB,KAAK,cAAc,EAEnB,KAAK,SAAS,EAEf,MAAM,aAAa,CAAC;AAErB,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,iBAAiB,EAEtB,KAAK,WAAW,EAEjB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAOnE,gFAAgF;AAChF,MAAM,MAAM,eAAe,GAAG,oBAAoB,GAAG,oBAAoB,CAAC;AAE1E,2EAA2E;AAC3E,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,O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