stitchkit 0.94.0 → 0.94.1
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/CHANGELOG.md +64 -0
- package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-listing.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +1 -1
- package/dist/agent-runtime/contained-darwin.d.ts +38 -0
- package/dist/agent-runtime/contained-darwin.d.ts.map +1 -0
- package/dist/agent-runtime/contained-files.d.ts +11 -26
- package/dist/agent-runtime/contained-files.d.ts.map +1 -1
- package/dist/agent-runtime/contained-scan.d.ts +21 -0
- package/dist/agent-runtime/contained-scan.d.ts.map +1 -0
- package/dist/agent-runtime/contained-write.d.ts +9 -0
- package/dist/agent-runtime/contained-write.d.ts.map +1 -0
- package/dist/agent-runtime/deferred-tool-types.d.ts +3 -2
- package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
- package/dist/agent-runtime/harness-control.d.ts +0 -1
- package/dist/agent-runtime/harness-control.d.ts.map +1 -1
- package/dist/agent-runtime/harness.d.ts +0 -5
- package/dist/agent-runtime/harness.d.ts.map +1 -1
- package/dist/agent-runtime/managed-tools.d.ts +3 -2
- package/dist/agent-runtime/managed-tools.d.ts.map +1 -1
- package/dist/agent-runtime/runtime.d.ts +1 -1
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-records.d.ts +34 -0
- package/dist/agent-runtime/schedule-records.d.ts.map +1 -0
- package/dist/agent-runtime/schedules.d.ts +34 -0
- package/dist/agent-runtime/schedules.d.ts.map +1 -1
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +434 -0
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-ordering.d.ts +18 -0
- package/dist/agent-runtime/store-conformance-ordering.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-support.d.ts +130 -0
- package/dist/agent-runtime/store-conformance-support.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-terminal.d.ts +12 -0
- package/dist/agent-runtime/store-conformance-terminal.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance.d.ts.map +1 -1
- package/dist/application/admission-rate.d.ts +21 -0
- package/dist/application/admission-rate.d.ts.map +1 -0
- package/dist/application/admission-run.d.ts +8 -0
- package/dist/application/admission-run.d.ts.map +1 -0
- package/dist/application/admission.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-lock.d.ts +9 -34
- package/dist/application/diagnostic-journal-lock.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-manager.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-storage.d.ts.map +1 -1
- package/dist/application/kernel-resource-context.d.ts.map +1 -1
- package/dist/application/notification-outbox.d.ts.map +1 -1
- package/dist/application/schedule.d.ts +0 -1
- package/dist/application/schedule.d.ts.map +1 -1
- package/dist/application/watch-hub-core.d.ts +122 -0
- package/dist/application/watch-hub-core.d.ts.map +1 -0
- package/dist/application/watch-hub.d.ts +2 -2
- package/dist/application/watch-hub.d.ts.map +1 -1
- package/dist/browser/client-executors.d.ts +14 -0
- package/dist/browser/client-executors.d.ts.map +1 -0
- package/dist/browser/client-multipart.d.ts +1 -1
- package/dist/browser/client-multipart.d.ts.map +1 -1
- package/dist/browser/client.d.ts +3 -2
- package/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/http-fetch.d.ts +22 -0
- package/dist/browser/http-fetch.d.ts.map +1 -0
- package/dist/browser/http.d.ts +1 -3
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/browser/live-state-core.d.ts +63 -0
- package/dist/browser/live-state-core.d.ts.map +1 -0
- package/dist/browser/live-state.d.ts.map +1 -1
- package/dist/browser/realtime-client.d.ts +26 -0
- package/dist/browser/realtime-client.d.ts.map +1 -0
- package/dist/browser/socket-io-connection.d.ts +82 -0
- package/dist/browser/socket-io-connection.d.ts.map +1 -0
- package/dist/browser/socket-io-peer.d.ts +20 -0
- package/dist/browser/socket-io-peer.d.ts.map +1 -0
- package/dist/browser/socket-io-trace.d.ts +31 -0
- package/dist/browser/socket-io-trace.d.ts.map +1 -0
- package/dist/browser/socket-io.d.ts +2 -18
- package/dist/browser/socket-io.d.ts.map +1 -1
- package/dist/contract/client-types.d.ts +134 -0
- package/dist/contract/client-types.d.ts.map +1 -0
- package/dist/contract/define-validation.d.ts +30 -0
- package/dist/contract/define-validation.d.ts.map +1 -0
- package/dist/contract/define.d.ts +3 -357
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/runtime-context.d.ts +131 -0
- package/dist/contract/runtime-context.d.ts.map +1 -0
- package/dist/contract/tool-options.d.ts +105 -0
- package/dist/contract/tool-options.d.ts.map +1 -0
- package/dist/contract/tool-view.d.ts +15 -2
- package/dist/contract/tool-view.d.ts.map +1 -1
- package/dist/durability/contract.d.ts +83 -0
- package/dist/durability/contract.d.ts.map +1 -1
- package/dist/durability/effect.d.ts +24 -0
- package/dist/durability/effect.d.ts.map +1 -0
- package/dist/durability/engine.d.ts +2 -2
- package/dist/durability/engine.d.ts.map +1 -1
- package/dist/durability/events.d.ts +2 -0
- package/dist/durability/events.d.ts.map +1 -1
- package/dist/durability/ledger.d.ts +11 -0
- package/dist/durability/ledger.d.ts.map +1 -1
- package/dist/durability/parks.d.ts +22 -0
- package/dist/durability/parks.d.ts.map +1 -0
- package/dist/durability/scheduler.d.ts +1 -0
- package/dist/durability/scheduler.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/coding-tools.js +4 -4
- package/dist/entrypoints/agent-runtime/harness.js +127 -116
- package/dist/entrypoints/agent-runtime/sandbox.js +4 -4
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +3 -3
- package/dist/entrypoints/agent-runtime/sqlite/node.js +3 -3
- package/dist/entrypoints/agent-runtime/testing.js +246 -214
- package/dist/entrypoints/agent-runtime.js +224 -203
- package/dist/entrypoints/application/diagnostic-journal.js +63 -203
- package/dist/entrypoints/application/opentelemetry.js +1 -1
- package/dist/entrypoints/application.js +361 -324
- package/dist/entrypoints/cli.d.ts +4 -1
- package/dist/entrypoints/cli.d.ts.map +1 -1
- package/dist/entrypoints/cli.js +57 -35
- package/dist/entrypoints/contract.d.ts +5 -2
- package/dist/entrypoints/contract.d.ts.map +1 -1
- package/dist/entrypoints/contract.js +3 -2
- package/dist/entrypoints/files.d.ts +2 -0
- package/dist/entrypoints/files.d.ts.map +1 -1
- package/dist/entrypoints/files.js +98 -2
- package/dist/entrypoints/index.d.ts +4 -2
- package/dist/entrypoints/index.d.ts.map +1 -1
- package/dist/entrypoints/index.js +348 -282
- package/dist/entrypoints/live.js +89 -71
- package/dist/entrypoints/node.d.ts +2 -1
- package/dist/entrypoints/node.d.ts.map +1 -1
- package/dist/entrypoints/node.js +13 -12
- package/dist/entrypoints/react.js +1 -1
- package/dist/entrypoints/remote.js +4 -4
- package/dist/entrypoints/server.d.ts +4 -2
- package/dist/entrypoints/server.d.ts.map +1 -1
- package/dist/entrypoints/server.js +293 -79
- package/dist/entrypoints/testing.d.ts +2 -1
- package/dist/entrypoints/testing.d.ts.map +1 -1
- package/dist/entrypoints/testing.js +288 -281
- package/dist/entrypoints/tools/connections.js +2 -2
- package/dist/entrypoints/tools/invoker.js +4 -4
- package/dist/entrypoints/tools.d.ts +6 -3
- package/dist/entrypoints/tools.d.ts.map +1 -1
- package/dist/entrypoints/tools.js +245 -202
- package/dist/entrypoints/tracking.js +325 -274
- package/dist/files/boundary.d.ts.map +1 -1
- package/dist/files/file-io.d.ts +14 -0
- package/dist/files/file-io.d.ts.map +1 -0
- package/dist/index-1j8pm5t0.js +412 -0
- package/dist/{index-kvj7f4hq.js → index-2bxbyab0.js} +10 -2
- package/dist/{index-xnj9bgxe.js → index-2gxzjvyr.js} +2 -162
- package/dist/index-4gcnakhx.js +82 -0
- package/dist/{index-j05z5gn4.js → index-55hkhm67.js} +136 -119
- package/dist/{index-cq4qfycf.js → index-79z7m7dt.js} +227 -59
- package/dist/{index-97ac4gph.js → index-7f68ghdn.js} +3 -3
- package/dist/{index-r7nmqpsg.js → index-7p1f0vp2.js} +1 -1
- package/dist/{index-dcpdvjsc.js → index-863ea9jb.js} +4 -4
- package/dist/index-8p52kd5p.js +242 -0
- package/dist/{index-2qzskm8h.js → index-dce5wxcq.js} +1 -1
- package/dist/index-e01r054k.js +105 -0
- package/dist/{index-sees8yf8.js → index-ensd0r74.js} +118 -111
- package/dist/{index-1nd48tm9.js → index-gxrt5h6v.js} +2 -1
- package/dist/{index-e87kakm4.js → index-ham5sz8m.js} +112 -110
- package/dist/{index-kj2wbeta.js → index-het2he5g.js} +280 -196
- package/dist/{index-vcvkq30w.js → index-hmp4800j.js} +3 -3
- package/dist/{index-gyr48nzg.js → index-k30h66yd.js} +71 -151
- package/dist/{index-2cr1cqhn.js → index-khtgb21r.js} +2 -2
- package/dist/{index-x4799c19.js → index-ndddxtyx.js} +11 -11
- package/dist/{index-dydjcp8z.js → index-np4m8hd3.js} +38 -36
- package/dist/{index-p81267c2.js → index-p3vsv1fb.js} +621 -357
- package/dist/{index-mp5sn43f.js → index-p9e0w8hs.js} +2 -2
- package/dist/{index-rewkc2hj.js → index-p9sh0xx4.js} +3 -3
- package/dist/{index-70yj2ebz.js → index-paz6sgdp.js} +107 -103
- package/dist/{index-bn2cjajt.js → index-px2gm2jp.js} +26 -102
- package/dist/index-s812ycat.js +65 -0
- package/dist/{index-xsqjkha9.js → index-sp1tzwnb.js} +2 -2
- package/dist/{index-n6hxg8as.js → index-t9rhjr9f.js} +615 -566
- package/dist/{index-zeemqhqx.js → index-v260df89.js} +88 -80
- package/dist/{index-fdp6hdxn.js → index-w906953s.js} +5 -1
- package/dist/{index-mdzh02yc.js → index-wdkt63w3.js} +1 -1
- package/dist/{index-58k4fp34.js → index-wsm5w4ee.js} +1 -1
- package/dist/{index-v38qyerb.js → index-xw3s75nj.js} +1 -1
- package/dist/internal/atomic-file.d.ts +23 -2
- package/dist/internal/atomic-file.d.ts.map +1 -1
- package/dist/internal/exclusive-lock.d.ts +51 -0
- package/dist/internal/exclusive-lock.d.ts.map +1 -0
- package/dist/internal/process-identity.d.ts +47 -0
- package/dist/internal/process-identity.d.ts.map +1 -0
- package/dist/internal/with-exclusive-lock.d.ts +67 -0
- package/dist/internal/with-exclusive-lock.d.ts.map +1 -0
- package/dist/live/watch-client.d.ts.map +1 -1
- package/dist/observability/audit.d.ts +2 -2
- package/dist/observability/audit.d.ts.map +1 -1
- package/dist/observability/event.d.ts +2 -1
- package/dist/observability/event.d.ts.map +1 -1
- package/dist/primitives/export-operation.d.ts +1 -1
- package/dist/primitives/export-operation.d.ts.map +1 -1
- package/dist/realtime/registry.d.ts +0 -5
- package/dist/realtime/registry.d.ts.map +1 -1
- package/dist/server/bun.d.ts +0 -1
- package/dist/server/bun.d.ts.map +1 -1
- package/dist/server/context-contribution.d.ts +1 -1
- package/dist/server/context-contribution.d.ts.map +1 -1
- package/dist/server/context.d.ts +1 -1
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/endpoint-response.d.ts +2 -1
- package/dist/server/endpoint-response.d.ts.map +1 -1
- package/dist/server/error-dispatch.d.ts +1 -1
- package/dist/server/error-dispatch.d.ts.map +1 -1
- package/dist/server/error-hook.d.ts +1 -1
- package/dist/server/error-hook.d.ts.map +1 -1
- package/dist/server/handler-state.d.ts +1 -1
- package/dist/server/handler-state.d.ts.map +1 -1
- package/dist/server/implement-registry.d.ts +54 -0
- package/dist/server/implement-registry.d.ts.map +1 -0
- package/dist/server/implement.d.ts +9 -55
- package/dist/server/implement.d.ts.map +1 -1
- package/dist/server/middleware/auth.d.ts +1 -31
- package/dist/server/middleware/auth.d.ts.map +1 -1
- package/dist/server/middleware/jwt.d.ts +31 -0
- package/dist/server/middleware/jwt.d.ts.map +1 -0
- package/dist/server/multipart-reader.d.ts +22 -0
- package/dist/server/multipart-reader.d.ts.map +1 -0
- package/dist/server/multipart.d.ts +1 -1
- package/dist/server/multipart.d.ts.map +1 -1
- package/dist/server/oauth/cimd.d.ts +88 -0
- package/dist/server/oauth/cimd.d.ts.map +1 -0
- package/dist/server/oauth/endpoints.d.ts +39 -0
- package/dist/server/oauth/endpoints.d.ts.map +1 -0
- package/dist/server/oauth/provider.d.ts +1 -68
- package/dist/server/oauth/provider.d.ts.map +1 -1
- package/dist/server/streaming-pump.d.ts +66 -0
- package/dist/server/streaming-pump.d.ts.map +1 -0
- package/dist/server/streaming-route.d.ts +12 -5
- package/dist/server/streaming-route.d.ts.map +1 -1
- package/dist/server/types.d.ts +4 -1
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/unix-client-bun.d.ts.map +1 -1
- package/dist/server/unix-client-http1.d.ts +76 -0
- package/dist/server/unix-client-http1.d.ts.map +1 -0
- package/dist/server/unix-client.d.ts.map +1 -1
- package/dist/testing/handler-clients.d.ts +2 -1
- package/dist/testing/handler-clients.d.ts.map +1 -1
- package/dist/testing/realtime-probe.d.ts +33 -0
- package/dist/testing/realtime-probe.d.ts.map +1 -0
- package/dist/testing/surface-conformance.d.ts +0 -31
- package/dist/testing/surface-conformance.d.ts.map +1 -1
- package/dist/testing/surface-manifest-digest.d.ts +44 -0
- package/dist/testing/surface-manifest-digest.d.ts.map +1 -0
- package/dist/testing/surface-manifest.d.ts.map +1 -1
- package/dist/tools/agent.d.ts +1 -1
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/cli/args-fields.d.ts +31 -0
- package/dist/tools/cli/args-fields.d.ts.map +1 -0
- package/dist/tools/cli/args-route.d.ts +42 -0
- package/dist/tools/cli/args-route.d.ts.map +1 -0
- package/dist/tools/cli/args-view.d.ts +32 -0
- package/dist/tools/cli/args-view.d.ts.map +1 -0
- package/dist/tools/cli/args.d.ts +2 -65
- package/dist/tools/cli/args.d.ts.map +1 -1
- package/dist/tools/cli/argument-error.d.ts +5 -0
- package/dist/tools/cli/argument-error.d.ts.map +1 -0
- package/dist/tools/cli/checkpoint.d.ts.map +1 -1
- package/dist/tools/cli/command.d.ts +1 -1
- package/dist/tools/cli/command.d.ts.map +1 -1
- package/dist/tools/cli/config.d.ts +1 -1
- package/dist/tools/cli/config.d.ts.map +1 -1
- package/dist/tools/cli/format.d.ts +2 -1
- package/dist/tools/cli/format.d.ts.map +1 -1
- package/dist/tools/cli/invoke.d.ts +2 -1
- package/dist/tools/cli/invoke.d.ts.map +1 -1
- package/dist/tools/cli/managed-surface.d.ts +1 -1
- package/dist/tools/cli/managed-surface.d.ts.map +1 -1
- package/dist/tools/cli/policy.d.ts +1 -1
- package/dist/tools/cli/policy.d.ts.map +1 -1
- package/dist/tools/cli/prepare.d.ts.map +1 -1
- package/dist/tools/cli/run-managed.d.ts.map +1 -1
- package/dist/tools/cli/session.d.ts +1 -1
- package/dist/tools/cli/session.d.ts.map +1 -1
- package/dist/tools/cli/update.d.ts +19 -0
- package/dist/tools/cli/update.d.ts.map +1 -1
- package/dist/tools/cli/view.d.ts +1 -1
- package/dist/tools/cli/view.d.ts.map +1 -1
- package/dist/tools/cli/wait.d.ts +1 -1
- package/dist/tools/cli/wait.d.ts.map +1 -1
- package/dist/tools/connections/runtime.d.ts +1 -1
- package/dist/tools/connections/runtime.d.ts.map +1 -1
- package/dist/tools/execute-args.d.ts +23 -0
- package/dist/tools/execute-args.d.ts.map +1 -0
- package/dist/tools/execute-hooks.d.ts +146 -0
- package/dist/tools/execute-hooks.d.ts.map +1 -0
- package/dist/tools/execute-result.d.ts +40 -0
- package/dist/tools/execute-result.d.ts.map +1 -0
- package/dist/tools/execute.d.ts +4 -193
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/internal/surface-projector.d.ts +2 -1
- package/dist/tools/internal/surface-projector.d.ts.map +1 -1
- package/dist/tools/invoker.d.ts +2 -1
- package/dist/tools/invoker.d.ts.map +1 -1
- package/dist/tools/lifecycle.d.ts +1 -1
- package/dist/tools/lifecycle.d.ts.map +1 -1
- package/dist/tools/mcp/mount.d.ts +1 -1
- package/dist/tools/mcp/mount.d.ts.map +1 -1
- package/dist/tools/mcp/prepare.d.ts +2 -1
- package/dist/tools/mcp/prepare.d.ts.map +1 -1
- package/dist/tools/mcp/progress.d.ts +1 -1
- package/dist/tools/mcp/progress.d.ts.map +1 -1
- package/dist/tools/mcp/register.d.ts +3 -2
- package/dist/tools/mcp/register.d.ts.map +1 -1
- package/dist/tools/mcp/round-context.d.ts +38 -0
- package/dist/tools/mcp/round-context.d.ts.map +1 -0
- package/dist/tools/mcp/round-policy.d.ts +1 -1
- package/dist/tools/mcp/round-policy.d.ts.map +1 -1
- package/dist/tools/mcp/round.d.ts +3 -11
- package/dist/tools/mcp/round.d.ts.map +1 -1
- package/dist/tools/mcp/runtime-tools.d.ts +2 -1
- package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
- package/dist/tools/mount.d.ts +3 -1
- package/dist/tools/mount.d.ts.map +1 -1
- package/dist/tools/native-definition.d.ts +2 -1
- package/dist/tools/native-definition.d.ts.map +1 -1
- package/dist/tools/operations/async-operation-runtime-tools.d.ts +2 -1
- package/dist/tools/operations/async-operation-runtime-tools.d.ts.map +1 -1
- package/dist/tools/operations/async-operation-runtime-types.d.ts +2 -1
- package/dist/tools/operations/async-operation-runtime-types.d.ts.map +1 -1
- package/dist/tools/remote.d.ts.map +1 -1
- package/dist/tools/runtime-tool.d.ts +3 -1
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools/tool-logger.d.ts +1 -1
- package/dist/tools/tool-logger.d.ts.map +1 -1
- package/dist/tracking/client-listeners.d.ts +30 -0
- package/dist/tracking/client-listeners.d.ts.map +1 -0
- package/dist/tracking/client-visit.d.ts +61 -0
- package/dist/tracking/client-visit.d.ts.map +1 -0
- package/dist/tracking/client.d.ts +3 -2
- package/dist/tracking/client.d.ts.map +1 -1
- package/llms/application.2.txt +266 -2
- package/llms/application.txt +8 -266
- package/llms/cli.2.txt +80 -0
- package/llms/cli.txt +45 -74
- package/llms/contract.txt +3 -3
- package/llms/files.txt +3 -0
- package/llms/tools.2.txt +88 -279
- package/llms/tools.3.txt +288 -0
- package/llms/tools.txt +27 -65
- package/llms-full.txt +108 -12
- package/llms.txt +5 -5
- package/package.json +1 -1
- package/dist/index-e2z3ahw9.js +0 -325
- package/dist/index-mkm15s49.js +0 -394
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
+
NumericFileHandle,
|
|
2
3
|
assertContainedFileCurrent,
|
|
3
4
|
assertContainedParentCurrent,
|
|
4
5
|
containedEntryMetadata,
|
|
6
|
+
descriptorPath,
|
|
5
7
|
listContainedDirectory,
|
|
8
|
+
loadDarwinBinding,
|
|
6
9
|
missingContainedDirectories,
|
|
7
10
|
openContainedFile,
|
|
8
11
|
openContainedParent,
|
|
9
12
|
openContainedParentFile,
|
|
10
13
|
readContainedUtf8Handle,
|
|
11
|
-
scanContainedFiles
|
|
12
|
-
|
|
13
|
-
} from "./index-bn2cjajt.js";
|
|
14
|
+
scanContainedFiles
|
|
15
|
+
} from "./index-px2gm2jp.js";
|
|
14
16
|
import {
|
|
15
17
|
codingPathRefusal,
|
|
16
18
|
codingRefusal,
|
|
@@ -20,7 +22,7 @@ import {
|
|
|
20
22
|
} from "./index-qmy6zq75.js";
|
|
21
23
|
import {
|
|
22
24
|
defineRuntimeTool
|
|
23
|
-
} from "./index-
|
|
25
|
+
} from "./index-xw3s75nj.js";
|
|
24
26
|
import {
|
|
25
27
|
conflict,
|
|
26
28
|
forbidden
|
|
@@ -170,7 +172,7 @@ function resolveCodingToolLimits(input) {
|
|
|
170
172
|
}
|
|
171
173
|
|
|
172
174
|
// src/agent-runtime/coding-tools.ts
|
|
173
|
-
import
|
|
175
|
+
import path5 from "node:path";
|
|
174
176
|
import { z as z4 } from "zod";
|
|
175
177
|
|
|
176
178
|
// src/agent-runtime/coding-tool-files.ts
|
|
@@ -328,6 +330,86 @@ function utf8AlignedStart(data, start, end) {
|
|
|
328
330
|
return safe;
|
|
329
331
|
}
|
|
330
332
|
|
|
333
|
+
// src/agent-runtime/contained-write.ts
|
|
334
|
+
import { fchmod, write as writeDescriptor } from "node:fs";
|
|
335
|
+
import { rename, unlink, writeFile } from "node:fs/promises";
|
|
336
|
+
import path2 from "node:path";
|
|
337
|
+
async function writeDescriptorFully(descriptor, content) {
|
|
338
|
+
const bytes = Buffer.from(content);
|
|
339
|
+
let offset = 0;
|
|
340
|
+
while (offset < bytes.byteLength) {
|
|
341
|
+
const written = await new Promise((resolve, reject) => {
|
|
342
|
+
writeDescriptor(descriptor, bytes, offset, bytes.byteLength - offset, null, (error, bytesWritten) => error ? reject(error) : resolve(bytesWritten));
|
|
343
|
+
});
|
|
344
|
+
if (written === 0)
|
|
345
|
+
throw new Error("Contained file write made no progress");
|
|
346
|
+
offset += written;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
async function chmodDescriptor(descriptor, mode) {
|
|
350
|
+
await new Promise((resolve, reject) => {
|
|
351
|
+
fchmod(descriptor, mode & 4095, (error) => error ? reject(error) : resolve());
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
async function createDarwinFile(parent, name, content, mode) {
|
|
355
|
+
const binding = loadDarwinBinding();
|
|
356
|
+
const descriptor = binding.createFileAt(parent.fd, name, mode & 4095);
|
|
357
|
+
let failed;
|
|
358
|
+
try {
|
|
359
|
+
await writeDescriptorFully(descriptor, content);
|
|
360
|
+
await chmodDescriptor(descriptor, mode);
|
|
361
|
+
} catch (error) {
|
|
362
|
+
failed = error;
|
|
363
|
+
} finally {
|
|
364
|
+
try {
|
|
365
|
+
await new NumericFileHandle(descriptor).close();
|
|
366
|
+
} catch (error) {
|
|
367
|
+
failed ??= error;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
if (failed) {
|
|
371
|
+
binding.unlinkAt(parent.fd, name);
|
|
372
|
+
throw failed;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
async function writeContainedFile(input) {
|
|
376
|
+
const mode = input.mode ?? 438;
|
|
377
|
+
if (!input.replace) {
|
|
378
|
+
if (process.platform === "darwin") {
|
|
379
|
+
await createDarwinFile(input.parent.handle, input.parent.basename, input.content, mode);
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
await writeFile(path2.join(descriptorPath(input.parent.handle), input.parent.basename), input.content, { flag: "wx", mode });
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
const temporary = `.${input.parent.basename}.${process.pid}.${crypto.randomUUID()}.tmp`;
|
|
386
|
+
if (process.platform === "darwin") {
|
|
387
|
+
const binding = loadDarwinBinding();
|
|
388
|
+
let created = false;
|
|
389
|
+
try {
|
|
390
|
+
await createDarwinFile(input.parent.handle, temporary, input.content, mode);
|
|
391
|
+
created = true;
|
|
392
|
+
binding.renameAt(input.parent.handle.fd, temporary, input.parent.basename);
|
|
393
|
+
} catch (error) {
|
|
394
|
+
if (created)
|
|
395
|
+
binding.unlinkAt(input.parent.handle.fd, temporary);
|
|
396
|
+
throw error;
|
|
397
|
+
}
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
const directory = descriptorPath(input.parent.handle);
|
|
401
|
+
const temporaryPath = path2.join(directory, temporary);
|
|
402
|
+
try {
|
|
403
|
+
await writeFile(temporaryPath, input.content, { flag: "wx", mode });
|
|
404
|
+
await rename(temporaryPath, path2.join(directory, input.parent.basename));
|
|
405
|
+
} catch (error) {
|
|
406
|
+
await unlink(temporaryPath).catch(() => {
|
|
407
|
+
return;
|
|
408
|
+
});
|
|
409
|
+
throw error;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
331
413
|
// src/agent-runtime/coding-tool-files.ts
|
|
332
414
|
async function digestFile(handle, size) {
|
|
333
415
|
const hash = createHash("sha256");
|
|
@@ -484,7 +566,7 @@ function createFileCodingTools(config, limits) {
|
|
|
484
566
|
|
|
485
567
|
// src/agent-runtime/coding-tool-listing.ts
|
|
486
568
|
import { realpath as realpath3 } from "node:fs/promises";
|
|
487
|
-
import
|
|
569
|
+
import path3 from "node:path";
|
|
488
570
|
import { z as z2 } from "zod";
|
|
489
571
|
var DEFAULT_EXCLUDED_DIRECTORIES = [
|
|
490
572
|
".git",
|
|
@@ -580,7 +662,7 @@ function createListingCodingTools(config, limits) {
|
|
|
580
662
|
truncated: listing.truncated,
|
|
581
663
|
...listing.denied.length > 0 && {
|
|
582
664
|
denied: listing.denied.map((entry) => ({
|
|
583
|
-
path: relative === "." ? entry.name :
|
|
665
|
+
path: relative === "." ? entry.name : path3.join(relative, entry.name),
|
|
584
666
|
kind: entry.kind
|
|
585
667
|
})),
|
|
586
668
|
deniedTruncated: listing.deniedTruncated
|
|
@@ -618,10 +700,10 @@ function createListingCodingTools(config, limits) {
|
|
|
618
700
|
maxDepth: limits.maxSearchDepth,
|
|
619
701
|
maxFiles: limits.maxSearchFiles,
|
|
620
702
|
symlinks: "skip",
|
|
621
|
-
excludeDirectory: (directory) => directory.split(
|
|
703
|
+
excludeDirectory: (directory) => directory.split(path3.sep).some((segment) => excluded.has(segment)),
|
|
622
704
|
authorizePath: (candidate) => isCodingPathAuthorized(config, candidate)
|
|
623
705
|
});
|
|
624
|
-
const prefix = relative === "." ? "" : `${relative}${
|
|
706
|
+
const prefix = relative === "." ? "" : `${relative}${path3.sep}`;
|
|
625
707
|
const matched = scan.files.filter((file) => file.relative.startsWith(prefix)).map((file) => file.relative).filter((candidate) => matcher.test(candidate.slice(prefix.length))).sort();
|
|
626
708
|
const paths = matched.slice(0, limits.maxSearchResults);
|
|
627
709
|
const scopedDenied = scan.denied.filter((entry) => entry.relative.startsWith(prefix));
|
|
@@ -648,7 +730,7 @@ function createListingCodingTools(config, limits) {
|
|
|
648
730
|
// src/agent-runtime/coding-tool-search-patch.ts
|
|
649
731
|
import { createHash as createHash2 } from "node:crypto";
|
|
650
732
|
import { realpath as realpath4 } from "node:fs/promises";
|
|
651
|
-
import
|
|
733
|
+
import path4 from "node:path";
|
|
652
734
|
import { z as z3 } from "zod";
|
|
653
735
|
var SearchInputSchema = z3.object({
|
|
654
736
|
query: z3.string().min(1),
|
|
@@ -709,6 +791,168 @@ var EditOutputSchema = z3.object({
|
|
|
709
791
|
function sha256(value) {
|
|
710
792
|
return createHash2("sha256").update(value).digest("hex");
|
|
711
793
|
}
|
|
794
|
+
async function searchFiles(config, limits, input) {
|
|
795
|
+
await authorizeCodingTool(config, {
|
|
796
|
+
operation: "search",
|
|
797
|
+
query: input.query,
|
|
798
|
+
mode: input.mode
|
|
799
|
+
});
|
|
800
|
+
const root = await realpath4(config.root);
|
|
801
|
+
await authorizeCodingPath(config, ".");
|
|
802
|
+
const excluded = new Set(config.search?.excludeDirectories ?? DEFAULT_EXCLUDED_DIRECTORIES);
|
|
803
|
+
const included = input.include ? compileWorkspaceGlob(input.include) : null;
|
|
804
|
+
let rejectedByInclude = 0;
|
|
805
|
+
const scan = await scanContainedFiles({
|
|
806
|
+
root,
|
|
807
|
+
maxDepth: limits.maxSearchDepth,
|
|
808
|
+
maxFiles: limits.maxSearchFiles,
|
|
809
|
+
symlinks: "skip",
|
|
810
|
+
...input.mode === "content" && {
|
|
811
|
+
readMaxBytes: limits.maxReadBytes,
|
|
812
|
+
skipUnreadable: true
|
|
813
|
+
},
|
|
814
|
+
excludeDirectory: (relative) => relative.split(path4.sep).some((segment) => excluded.has(segment)),
|
|
815
|
+
includeFile: (candidate) => {
|
|
816
|
+
if (included && !included.test(candidate)) {
|
|
817
|
+
rejectedByInclude += 1;
|
|
818
|
+
return false;
|
|
819
|
+
}
|
|
820
|
+
return true;
|
|
821
|
+
},
|
|
822
|
+
authorizePath: (candidate) => isCodingPathAuthorized(config, candidate)
|
|
823
|
+
});
|
|
824
|
+
const matcher = input.regex ? compileSearchRegex(input.query) : null;
|
|
825
|
+
const hit = (line) => {
|
|
826
|
+
if (line.length > MAX_SEARCHED_LINE_BYTES)
|
|
827
|
+
return false;
|
|
828
|
+
if (matcher) {
|
|
829
|
+
matcher.lastIndex = 0;
|
|
830
|
+
return matcher.test(line);
|
|
831
|
+
}
|
|
832
|
+
return line.includes(input.query);
|
|
833
|
+
};
|
|
834
|
+
const matches = [];
|
|
835
|
+
let truncated = false;
|
|
836
|
+
for (const file of scan.files) {
|
|
837
|
+
if (input.mode === "path") {
|
|
838
|
+
if (hit(file.relative))
|
|
839
|
+
matches.push({ path: file.relative });
|
|
840
|
+
} else {
|
|
841
|
+
const text = file.content?.text;
|
|
842
|
+
if (text === undefined)
|
|
843
|
+
continue;
|
|
844
|
+
const lines = text.split(`
|
|
845
|
+
`);
|
|
846
|
+
for (let index = 0;index < lines.length; index += 1) {
|
|
847
|
+
const line = lines[index];
|
|
848
|
+
if (line === undefined || !hit(line))
|
|
849
|
+
continue;
|
|
850
|
+
matches.push({
|
|
851
|
+
path: file.relative,
|
|
852
|
+
line: index + 1,
|
|
853
|
+
text: line,
|
|
854
|
+
...input.context > 0 && {
|
|
855
|
+
before: lines.slice(Math.max(0, index - input.context), index),
|
|
856
|
+
after: lines.slice(index + 1, index + 1 + input.context)
|
|
857
|
+
}
|
|
858
|
+
});
|
|
859
|
+
if (matches.length >= limits.maxSearchResults)
|
|
860
|
+
break;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
if (matches.length >= limits.maxSearchResults) {
|
|
864
|
+
truncated = true;
|
|
865
|
+
break;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
return {
|
|
869
|
+
matches,
|
|
870
|
+
truncated: truncated || scan.truncated,
|
|
871
|
+
scannedFiles: scan.files.length,
|
|
872
|
+
skippedDirectories: scan.skippedDirectories,
|
|
873
|
+
skippedSymlinks: scan.skippedSymlinks,
|
|
874
|
+
...scan.denied.length > 0 && {
|
|
875
|
+
denied: scan.denied.slice(0, limits.maxSearchResults).map(({ relative, kind }) => ({ path: relative, kind })),
|
|
876
|
+
deniedTruncated: scan.deniedTruncated || scan.denied.length > limits.maxSearchResults
|
|
877
|
+
},
|
|
878
|
+
...input.include && scan.files.length === 0 && rejectedByInclude > 0 && {
|
|
879
|
+
hint: `The anchored include pattern \`${input.include}\` rejected all ${rejectedByInclude} ${rejectedByInclude === 1 ? "file" : "files"} the scan reached. \`*\` does not cross \`/\`; use a pattern such as \`**/*.ts\` for matching files in subdirectories.`
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
async function editFile(config, limits, input) {
|
|
884
|
+
const root = await realpath4(config.root);
|
|
885
|
+
const relative = boundedCodingRelativePath(root, input.path, limits.maxPathBytes);
|
|
886
|
+
await authorizeCodingPathChain(config, relative);
|
|
887
|
+
const parent = await openContainedParent(root, relative).catch((error) => refuseMissingCodingPath(error, relative));
|
|
888
|
+
try {
|
|
889
|
+
return await withCodingPathLock(`${root}:${relative}`, async () => {
|
|
890
|
+
const handle = await openContainedParentFile(parent).catch((error) => refuseMissingCodingPath(error, relative));
|
|
891
|
+
const read = await readContainedUtf8Handle(handle, limits.maxWriteBytes).finally(() => handle.close());
|
|
892
|
+
const source = read.text;
|
|
893
|
+
const baseSha256 = sha256(source);
|
|
894
|
+
if (input.expectedSha256 !== undefined && baseSha256 !== input.expectedSha256) {
|
|
895
|
+
conflict("The file changed since it was read", {
|
|
896
|
+
message: "The file changed since it was read",
|
|
897
|
+
path: relative,
|
|
898
|
+
expectedSha256: input.expectedSha256,
|
|
899
|
+
actualSha256: baseSha256
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
const count = textOccurrences(source, input.oldText);
|
|
903
|
+
if (count === 0) {
|
|
904
|
+
codingPathRefusal("NOT_FOUND", "oldText does not appear in this file", relative, {
|
|
905
|
+
details: { occurrences: 0 },
|
|
906
|
+
hint: "Read the file and copy the snippet exactly, including indentation."
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
if (!input.replaceAll && count !== 1) {
|
|
910
|
+
codingPathRefusal("CONFLICT", `oldText appears ${count} times, so the edit is ambiguous`, relative, {
|
|
911
|
+
details: { occurrences: count },
|
|
912
|
+
hint: "Lengthen the snippet until it is unique, or pass replaceAll: true."
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
const replacements = input.replaceAll ? count : 1;
|
|
916
|
+
const changed = input.replaceAll ? source.replaceAll(input.oldText, input.newText) : source.replace(input.oldText, () => input.newText);
|
|
917
|
+
const bytes = Buffer.byteLength(changed);
|
|
918
|
+
const resultSha256 = sha256(changed);
|
|
919
|
+
if (bytes > limits.maxWriteBytes) {
|
|
920
|
+
codingPathRefusal("BAD_REQUEST", `The result would be ${bytes} bytes, over the ${limits.maxWriteBytes}-byte limit`, relative, {
|
|
921
|
+
details: { bytes, maxWriteBytes: limits.maxWriteBytes },
|
|
922
|
+
hint: "Make a smaller edit, or split the file."
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
await authorizeCodingTool(config, {
|
|
926
|
+
operation: "edit",
|
|
927
|
+
path: relative,
|
|
928
|
+
baseSha256,
|
|
929
|
+
resultSha256,
|
|
930
|
+
resultBytes: bytes,
|
|
931
|
+
replacements,
|
|
932
|
+
dryRun: input.dryRun
|
|
933
|
+
});
|
|
934
|
+
await assertContainedParentCurrent(root, relative, parent.handle);
|
|
935
|
+
if (!input.dryRun) {
|
|
936
|
+
await writeContainedFile({
|
|
937
|
+
parent,
|
|
938
|
+
content: changed,
|
|
939
|
+
replace: true,
|
|
940
|
+
mode: read.mode
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
return {
|
|
944
|
+
path: relative,
|
|
945
|
+
baseSha256,
|
|
946
|
+
sha256: resultSha256,
|
|
947
|
+
replacements,
|
|
948
|
+
bytes,
|
|
949
|
+
applied: !input.dryRun
|
|
950
|
+
};
|
|
951
|
+
});
|
|
952
|
+
} finally {
|
|
953
|
+
await parent.handle.close();
|
|
954
|
+
}
|
|
955
|
+
}
|
|
712
956
|
function createSearchAndPatchCodingTools(config, limits) {
|
|
713
957
|
const search = defineRuntimeTool({
|
|
714
958
|
name: "search_files",
|
|
@@ -717,95 +961,7 @@ function createSearchAndPatchCodingTools(config, limits) {
|
|
|
717
961
|
input: SearchInputSchema,
|
|
718
962
|
output: SearchOutputSchema,
|
|
719
963
|
transports: ["AGENT"],
|
|
720
|
-
handler:
|
|
721
|
-
await authorizeCodingTool(config, {
|
|
722
|
-
operation: "search",
|
|
723
|
-
query: input.query,
|
|
724
|
-
mode: input.mode
|
|
725
|
-
});
|
|
726
|
-
const root = await realpath4(config.root);
|
|
727
|
-
await authorizeCodingPath(config, ".");
|
|
728
|
-
const excluded = new Set(config.search?.excludeDirectories ?? DEFAULT_EXCLUDED_DIRECTORIES);
|
|
729
|
-
const included = input.include ? compileWorkspaceGlob(input.include) : null;
|
|
730
|
-
let rejectedByInclude = 0;
|
|
731
|
-
const scan = await scanContainedFiles({
|
|
732
|
-
root,
|
|
733
|
-
maxDepth: limits.maxSearchDepth,
|
|
734
|
-
maxFiles: limits.maxSearchFiles,
|
|
735
|
-
symlinks: "skip",
|
|
736
|
-
...input.mode === "content" && {
|
|
737
|
-
readMaxBytes: limits.maxReadBytes,
|
|
738
|
-
skipUnreadable: true
|
|
739
|
-
},
|
|
740
|
-
excludeDirectory: (relative) => relative.split(path3.sep).some((segment) => excluded.has(segment)),
|
|
741
|
-
includeFile: (candidate) => {
|
|
742
|
-
if (included && !included.test(candidate)) {
|
|
743
|
-
rejectedByInclude += 1;
|
|
744
|
-
return false;
|
|
745
|
-
}
|
|
746
|
-
return true;
|
|
747
|
-
},
|
|
748
|
-
authorizePath: (candidate) => isCodingPathAuthorized(config, candidate)
|
|
749
|
-
});
|
|
750
|
-
const matcher = input.regex ? compileSearchRegex(input.query) : null;
|
|
751
|
-
const hit = (line) => {
|
|
752
|
-
if (line.length > MAX_SEARCHED_LINE_BYTES)
|
|
753
|
-
return false;
|
|
754
|
-
if (matcher) {
|
|
755
|
-
matcher.lastIndex = 0;
|
|
756
|
-
return matcher.test(line);
|
|
757
|
-
}
|
|
758
|
-
return line.includes(input.query);
|
|
759
|
-
};
|
|
760
|
-
const matches = [];
|
|
761
|
-
let truncated = false;
|
|
762
|
-
for (const file of scan.files) {
|
|
763
|
-
if (input.mode === "path") {
|
|
764
|
-
if (hit(file.relative))
|
|
765
|
-
matches.push({ path: file.relative });
|
|
766
|
-
} else {
|
|
767
|
-
const text = file.content?.text;
|
|
768
|
-
if (text === undefined)
|
|
769
|
-
continue;
|
|
770
|
-
const lines = text.split(`
|
|
771
|
-
`);
|
|
772
|
-
for (let index = 0;index < lines.length; index += 1) {
|
|
773
|
-
const line = lines[index];
|
|
774
|
-
if (line === undefined || !hit(line))
|
|
775
|
-
continue;
|
|
776
|
-
matches.push({
|
|
777
|
-
path: file.relative,
|
|
778
|
-
line: index + 1,
|
|
779
|
-
text: line,
|
|
780
|
-
...input.context > 0 && {
|
|
781
|
-
before: lines.slice(Math.max(0, index - input.context), index),
|
|
782
|
-
after: lines.slice(index + 1, index + 1 + input.context)
|
|
783
|
-
}
|
|
784
|
-
});
|
|
785
|
-
if (matches.length >= limits.maxSearchResults)
|
|
786
|
-
break;
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
if (matches.length >= limits.maxSearchResults) {
|
|
790
|
-
truncated = true;
|
|
791
|
-
break;
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
return {
|
|
795
|
-
matches,
|
|
796
|
-
truncated: truncated || scan.truncated,
|
|
797
|
-
scannedFiles: scan.files.length,
|
|
798
|
-
skippedDirectories: scan.skippedDirectories,
|
|
799
|
-
skippedSymlinks: scan.skippedSymlinks,
|
|
800
|
-
...scan.denied.length > 0 && {
|
|
801
|
-
denied: scan.denied.slice(0, limits.maxSearchResults).map(({ relative, kind }) => ({ path: relative, kind })),
|
|
802
|
-
deniedTruncated: scan.deniedTruncated || scan.denied.length > limits.maxSearchResults
|
|
803
|
-
},
|
|
804
|
-
...input.include && scan.files.length === 0 && rejectedByInclude > 0 && {
|
|
805
|
-
hint: `The anchored include pattern \`${input.include}\` rejected all ${rejectedByInclude} ${rejectedByInclude === 1 ? "file" : "files"} the scan reached. \`*\` does not cross \`/\`; use a pattern such as \`**/*.ts\` for matching files in subdirectories.`
|
|
806
|
-
}
|
|
807
|
-
};
|
|
808
|
-
}
|
|
964
|
+
handler: ({ input }) => searchFiles(config, limits, input)
|
|
809
965
|
});
|
|
810
966
|
const edit = defineRuntimeTool({
|
|
811
967
|
name: "edit_file",
|
|
@@ -814,79 +970,7 @@ function createSearchAndPatchCodingTools(config, limits) {
|
|
|
814
970
|
input: EditInputSchema,
|
|
815
971
|
output: EditOutputSchema,
|
|
816
972
|
transports: ["AGENT"],
|
|
817
|
-
handler:
|
|
818
|
-
const root = await realpath4(config.root);
|
|
819
|
-
const relative = boundedCodingRelativePath(root, input.path, limits.maxPathBytes);
|
|
820
|
-
await authorizeCodingPathChain(config, relative);
|
|
821
|
-
const parent = await openContainedParent(root, relative).catch((error) => refuseMissingCodingPath(error, relative));
|
|
822
|
-
try {
|
|
823
|
-
return await withCodingPathLock(`${root}:${relative}`, async () => {
|
|
824
|
-
const handle = await openContainedParentFile(parent).catch((error) => refuseMissingCodingPath(error, relative));
|
|
825
|
-
const read = await readContainedUtf8Handle(handle, limits.maxWriteBytes).finally(() => handle.close());
|
|
826
|
-
const source = read.text;
|
|
827
|
-
const baseSha256 = sha256(source);
|
|
828
|
-
if (input.expectedSha256 !== undefined && baseSha256 !== input.expectedSha256) {
|
|
829
|
-
conflict("The file changed since it was read", {
|
|
830
|
-
message: "The file changed since it was read",
|
|
831
|
-
path: relative,
|
|
832
|
-
expectedSha256: input.expectedSha256,
|
|
833
|
-
actualSha256: baseSha256
|
|
834
|
-
});
|
|
835
|
-
}
|
|
836
|
-
const count = textOccurrences(source, input.oldText);
|
|
837
|
-
if (count === 0) {
|
|
838
|
-
codingPathRefusal("NOT_FOUND", "oldText does not appear in this file", relative, {
|
|
839
|
-
details: { occurrences: 0 },
|
|
840
|
-
hint: "Read the file and copy the snippet exactly, including indentation."
|
|
841
|
-
});
|
|
842
|
-
}
|
|
843
|
-
if (!input.replaceAll && count !== 1) {
|
|
844
|
-
codingPathRefusal("CONFLICT", `oldText appears ${count} times, so the edit is ambiguous`, relative, {
|
|
845
|
-
details: { occurrences: count },
|
|
846
|
-
hint: "Lengthen the snippet until it is unique, or pass replaceAll: true."
|
|
847
|
-
});
|
|
848
|
-
}
|
|
849
|
-
const replacements = input.replaceAll ? count : 1;
|
|
850
|
-
const changed = input.replaceAll ? source.replaceAll(input.oldText, input.newText) : source.replace(input.oldText, () => input.newText);
|
|
851
|
-
const bytes = Buffer.byteLength(changed);
|
|
852
|
-
const resultSha256 = sha256(changed);
|
|
853
|
-
if (bytes > limits.maxWriteBytes) {
|
|
854
|
-
codingPathRefusal("BAD_REQUEST", `The result would be ${bytes} bytes, over the ${limits.maxWriteBytes}-byte limit`, relative, {
|
|
855
|
-
details: { bytes, maxWriteBytes: limits.maxWriteBytes },
|
|
856
|
-
hint: "Make a smaller edit, or split the file."
|
|
857
|
-
});
|
|
858
|
-
}
|
|
859
|
-
await authorizeCodingTool(config, {
|
|
860
|
-
operation: "edit",
|
|
861
|
-
path: relative,
|
|
862
|
-
baseSha256,
|
|
863
|
-
resultSha256,
|
|
864
|
-
resultBytes: bytes,
|
|
865
|
-
replacements,
|
|
866
|
-
dryRun: input.dryRun
|
|
867
|
-
});
|
|
868
|
-
await assertContainedParentCurrent(root, relative, parent.handle);
|
|
869
|
-
if (!input.dryRun) {
|
|
870
|
-
await writeContainedFile({
|
|
871
|
-
parent,
|
|
872
|
-
content: changed,
|
|
873
|
-
replace: true,
|
|
874
|
-
mode: read.mode
|
|
875
|
-
});
|
|
876
|
-
}
|
|
877
|
-
return {
|
|
878
|
-
path: relative,
|
|
879
|
-
baseSha256,
|
|
880
|
-
sha256: resultSha256,
|
|
881
|
-
replacements,
|
|
882
|
-
bytes,
|
|
883
|
-
applied: !input.dryRun
|
|
884
|
-
};
|
|
885
|
-
});
|
|
886
|
-
} finally {
|
|
887
|
-
await parent.handle.close();
|
|
888
|
-
}
|
|
889
|
-
}
|
|
973
|
+
handler: ({ input }) => editFile(config, limits, input)
|
|
890
974
|
});
|
|
891
975
|
return [search, edit];
|
|
892
976
|
}
|
|
@@ -896,30 +980,30 @@ import { realpath as realpath5, stat } from "node:fs/promises";
|
|
|
896
980
|
|
|
897
981
|
// src/agent-runtime/coding-shell-process.ts
|
|
898
982
|
import { spawn } from "node:child_process";
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
omittedBytes: data.byteLength - headEnd - tailBytes
|
|
912
|
-
};
|
|
983
|
+
function preview(data, budget) {
|
|
984
|
+
if (data.byteLength <= budget) {
|
|
985
|
+
return { data, headBytes: data.byteLength, tailBytes: 0, omittedBytes: 0 };
|
|
986
|
+
}
|
|
987
|
+
const headEnd = utf8AlignedEnd(data, 0, Math.ceil(budget / 2));
|
|
988
|
+
const tailStart = Math.max(headEnd, utf8AlignedStart(data, data.byteLength - Math.floor(budget / 2), data.byteLength));
|
|
989
|
+
const tailBytes = data.byteLength - tailStart;
|
|
990
|
+
return {
|
|
991
|
+
data: Buffer.concat([data.subarray(0, headEnd), data.subarray(tailStart)]),
|
|
992
|
+
headBytes: headEnd,
|
|
993
|
+
tailBytes,
|
|
994
|
+
omittedBytes: data.byteLength - headEnd - tailBytes
|
|
913
995
|
};
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
996
|
+
}
|
|
997
|
+
function retainedPreview(data) {
|
|
998
|
+
const end = utf8AlignedEnd(data, 0, data.byteLength);
|
|
999
|
+
return {
|
|
1000
|
+
data: data.subarray(0, end),
|
|
1001
|
+
headBytes: end,
|
|
1002
|
+
tailBytes: 0,
|
|
1003
|
+
omittedBytes: data.byteLength - end
|
|
922
1004
|
};
|
|
1005
|
+
}
|
|
1006
|
+
async function runCodingShell(input) {
|
|
923
1007
|
const stdoutHeader = Buffer.from(`--- stdout ---
|
|
924
1008
|
`);
|
|
925
1009
|
const stderrHeader = Buffer.from(`
|
|
@@ -1192,10 +1276,10 @@ var AGENT_CODING_TOOL_NAMES = {
|
|
|
1192
1276
|
writeFile: "write_file"
|
|
1193
1277
|
};
|
|
1194
1278
|
function createAgentCodingTools(config) {
|
|
1195
|
-
if (!
|
|
1279
|
+
if (!path5.isAbsolute(config.root))
|
|
1196
1280
|
throw new Error("Coding tool root must be absolute");
|
|
1197
1281
|
for (const executable of Object.values(config.executables ?? {})) {
|
|
1198
|
-
if (!
|
|
1282
|
+
if (!path5.isAbsolute(executable)) {
|
|
1199
1283
|
throw new Error("Coding tool executables must be absolute paths");
|
|
1200
1284
|
}
|
|
1201
1285
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
contractToolMountable
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-khtgb21r.js";
|
|
4
4
|
import {
|
|
5
5
|
runtimeToolMountable
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-xw3s75nj.js";
|
|
7
7
|
import {
|
|
8
8
|
projectToolSurface
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-np4m8hd3.js";
|
|
10
10
|
|
|
11
11
|
// src/tools/surface.ts
|
|
12
12
|
function collectToolSurface({
|