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
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
AgentStoredRunSchema,
|
|
11
11
|
appendEventIn,
|
|
12
12
|
createAgentRuntimeStore
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-wsm5w4ee.js";
|
|
14
14
|
import {
|
|
15
15
|
AgentRecoverableDescriptorSchema,
|
|
16
16
|
AgentRecoverablePageSchema,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
AgentStoreEventPageSchema,
|
|
19
19
|
AppendAgentStoreEventSchema,
|
|
20
20
|
canonicalAgentJson
|
|
21
|
-
} from "./index-
|
|
21
|
+
} from "./index-gxrt5h6v.js";
|
|
22
22
|
import {
|
|
23
23
|
AgentMessageSchema,
|
|
24
24
|
AgentRunSchema
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
collectTools,
|
|
3
3
|
createToolRunner
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-khtgb21r.js";
|
|
5
5
|
import {
|
|
6
6
|
toolErrorFromResult
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-55hkhm67.js";
|
|
8
8
|
import {
|
|
9
9
|
assertUniqueToolName
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-np4m8hd3.js";
|
|
11
11
|
import {
|
|
12
12
|
AppError
|
|
13
13
|
} from "./index-2vtcmrj9.js";
|
|
@@ -11,113 +11,12 @@ import { randomUUID } from "node:crypto";
|
|
|
11
11
|
import { constants } from "node:fs";
|
|
12
12
|
import { link, mkdir, open, realpath, rename, stat, unlink } from "node:fs/promises";
|
|
13
13
|
import { basename, dirname, resolve } from "node:path";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var DEFAULT_INSPECTION_TIMEOUT_MS = 15000;
|
|
17
|
-
var nofollowFlag;
|
|
18
|
-
var noFollow = () => {
|
|
19
|
-
nofollowFlag ??= constants.O_NOFOLLOW ?? 0;
|
|
20
|
-
return nofollowFlag;
|
|
21
|
-
};
|
|
14
|
+
|
|
15
|
+
// src/files/file-io.ts
|
|
22
16
|
var ManagedFileInspectionSchema = ManagedFileRefSchema.pick({
|
|
23
17
|
mediaType: true,
|
|
24
18
|
name: true
|
|
25
19
|
});
|
|
26
|
-
|
|
27
|
-
class ManagedFileError extends Error {
|
|
28
|
-
code;
|
|
29
|
-
constructor(code, message, options) {
|
|
30
|
-
super(message, options);
|
|
31
|
-
this.code = code;
|
|
32
|
-
this.name = "ManagedFileError";
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function positiveLimit(value, fallback, name) {
|
|
36
|
-
const resolved = value ?? fallback;
|
|
37
|
-
if (!Number.isSafeInteger(resolved) || resolved <= 0) {
|
|
38
|
-
throw new TypeError(`${name} must be a positive safe integer`);
|
|
39
|
-
}
|
|
40
|
-
return resolved;
|
|
41
|
-
}
|
|
42
|
-
function filePath(path) {
|
|
43
|
-
const parsed = ManagedFilePathSchema.safeParse(path);
|
|
44
|
-
if (!parsed.success) {
|
|
45
|
-
throw new ManagedFileError("FILE_INVALID_PATH", "invalid managed-file path");
|
|
46
|
-
}
|
|
47
|
-
return parsed.data;
|
|
48
|
-
}
|
|
49
|
-
function errorCode(error) {
|
|
50
|
-
if (typeof error !== "object" || error === null || !("code" in error))
|
|
51
|
-
return;
|
|
52
|
-
return typeof error.code === "string" ? error.code : undefined;
|
|
53
|
-
}
|
|
54
|
-
function ioError(message, error) {
|
|
55
|
-
if (error instanceof ManagedFileError)
|
|
56
|
-
return error;
|
|
57
|
-
return new ManagedFileError("FILE_IO_ERROR", message, { cause: error });
|
|
58
|
-
}
|
|
59
|
-
async function realpathOrNull(path, message) {
|
|
60
|
-
try {
|
|
61
|
-
return await realpath(path);
|
|
62
|
-
} catch (error) {
|
|
63
|
-
if (errorCode(error) === "ENOENT")
|
|
64
|
-
return null;
|
|
65
|
-
throw ioError(message, error);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
async function bindRoot(config) {
|
|
69
|
-
const requested = resolve(config.root);
|
|
70
|
-
let canonical = await realpathOrNull(requested, "failed to resolve managed-file root");
|
|
71
|
-
if (canonical === null && config.createRoot) {
|
|
72
|
-
const parent = await realpathOrNull(dirname(requested), "failed to resolve managed-file root parent");
|
|
73
|
-
if (parent === null) {
|
|
74
|
-
throw new ManagedFileError("FILE_NOT_FOUND", "managed-file root parent must exist");
|
|
75
|
-
}
|
|
76
|
-
const parentInfo = await stat(parent).catch((error) => {
|
|
77
|
-
throw ioError("failed to inspect managed-file root parent", error);
|
|
78
|
-
});
|
|
79
|
-
if (!parentInfo.isDirectory()) {
|
|
80
|
-
throw new ManagedFileError("FILE_NOT_REGULAR", "managed-file root parent must be a directory");
|
|
81
|
-
}
|
|
82
|
-
try {
|
|
83
|
-
await mkdir(requested, { mode: 448 });
|
|
84
|
-
} catch (error) {
|
|
85
|
-
if (errorCode(error) !== "EEXIST") {
|
|
86
|
-
if (errorCode(error) === "ENOENT") {
|
|
87
|
-
throw new ManagedFileError("FILE_NOT_FOUND", "managed-file root parent must exist");
|
|
88
|
-
}
|
|
89
|
-
throw ioError("failed to create managed-file root", error);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
canonical = await realpathOrNull(requested, "failed to resolve managed-file root");
|
|
93
|
-
}
|
|
94
|
-
if (canonical === null) {
|
|
95
|
-
throw new ManagedFileError("FILE_NOT_FOUND", "managed-file root must exist");
|
|
96
|
-
}
|
|
97
|
-
const info = await stat(canonical).catch((error) => {
|
|
98
|
-
throw ioError("failed to inspect managed-file root", error);
|
|
99
|
-
});
|
|
100
|
-
if (!info.isDirectory()) {
|
|
101
|
-
throw new ManagedFileError("FILE_NOT_REGULAR", "managed-file root must be a directory");
|
|
102
|
-
}
|
|
103
|
-
return canonical;
|
|
104
|
-
}
|
|
105
|
-
async function existingParent(root, target) {
|
|
106
|
-
const parent = await realpathOrNull(dirname(target), "failed to resolve managed-file parent directory");
|
|
107
|
-
if (parent === null) {
|
|
108
|
-
throw new ManagedFileError("FILE_NOT_FOUND", "managed-file parent directory not found");
|
|
109
|
-
}
|
|
110
|
-
if (!isWithinDir(root, parent)) {
|
|
111
|
-
throw new ManagedFileError("FILE_OUTSIDE_ROOT", "managed-file path escapes its boundary");
|
|
112
|
-
}
|
|
113
|
-
const info = await stat(parent).catch((error) => {
|
|
114
|
-
throw ioError("failed to inspect managed-file parent directory", error);
|
|
115
|
-
});
|
|
116
|
-
if (!info.isDirectory()) {
|
|
117
|
-
throw new ManagedFileError("FILE_NOT_REGULAR", "managed-file parent is not a directory");
|
|
118
|
-
}
|
|
119
|
-
return parent;
|
|
120
|
-
}
|
|
121
20
|
function abortReason(signal) {
|
|
122
21
|
return signal.reason ?? new DOMException("The operation was aborted", "AbortError");
|
|
123
22
|
}
|
|
@@ -249,6 +148,111 @@ async function writeSource(handle, source, maxBytes, inspectionBytes, signal) {
|
|
|
249
148
|
}
|
|
250
149
|
return { size, prefix };
|
|
251
150
|
}
|
|
151
|
+
|
|
152
|
+
// src/files/boundary.ts
|
|
153
|
+
var DEFAULT_MAX_BYTES = 100 * 1024 * 1024;
|
|
154
|
+
var DEFAULT_INSPECTION_BYTES = 64 * 1024;
|
|
155
|
+
var DEFAULT_INSPECTION_TIMEOUT_MS = 15000;
|
|
156
|
+
var nofollowFlag;
|
|
157
|
+
var noFollow = () => {
|
|
158
|
+
nofollowFlag ??= constants.O_NOFOLLOW ?? 0;
|
|
159
|
+
return nofollowFlag;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
class ManagedFileError extends Error {
|
|
163
|
+
code;
|
|
164
|
+
constructor(code, message, options) {
|
|
165
|
+
super(message, options);
|
|
166
|
+
this.code = code;
|
|
167
|
+
this.name = "ManagedFileError";
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function positiveLimit(value, fallback, name) {
|
|
171
|
+
const resolved = value ?? fallback;
|
|
172
|
+
if (!Number.isSafeInteger(resolved) || resolved <= 0) {
|
|
173
|
+
throw new TypeError(`${name} must be a positive safe integer`);
|
|
174
|
+
}
|
|
175
|
+
return resolved;
|
|
176
|
+
}
|
|
177
|
+
function filePath(path) {
|
|
178
|
+
const parsed = ManagedFilePathSchema.safeParse(path);
|
|
179
|
+
if (!parsed.success) {
|
|
180
|
+
throw new ManagedFileError("FILE_INVALID_PATH", "invalid managed-file path");
|
|
181
|
+
}
|
|
182
|
+
return parsed.data;
|
|
183
|
+
}
|
|
184
|
+
function errorCode(error) {
|
|
185
|
+
if (typeof error !== "object" || error === null || !("code" in error))
|
|
186
|
+
return;
|
|
187
|
+
return typeof error.code === "string" ? error.code : undefined;
|
|
188
|
+
}
|
|
189
|
+
function ioError(message, error) {
|
|
190
|
+
if (error instanceof ManagedFileError)
|
|
191
|
+
return error;
|
|
192
|
+
return new ManagedFileError("FILE_IO_ERROR", message, { cause: error });
|
|
193
|
+
}
|
|
194
|
+
async function realpathOrNull(path, message) {
|
|
195
|
+
try {
|
|
196
|
+
return await realpath(path);
|
|
197
|
+
} catch (error) {
|
|
198
|
+
if (errorCode(error) === "ENOENT")
|
|
199
|
+
return null;
|
|
200
|
+
throw ioError(message, error);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
async function bindRoot(config) {
|
|
204
|
+
const requested = resolve(config.root);
|
|
205
|
+
let canonical = await realpathOrNull(requested, "failed to resolve managed-file root");
|
|
206
|
+
if (canonical === null && config.createRoot) {
|
|
207
|
+
const parent = await realpathOrNull(dirname(requested), "failed to resolve managed-file root parent");
|
|
208
|
+
if (parent === null) {
|
|
209
|
+
throw new ManagedFileError("FILE_NOT_FOUND", "managed-file root parent must exist");
|
|
210
|
+
}
|
|
211
|
+
const parentInfo = await stat(parent).catch((error) => {
|
|
212
|
+
throw ioError("failed to inspect managed-file root parent", error);
|
|
213
|
+
});
|
|
214
|
+
if (!parentInfo.isDirectory()) {
|
|
215
|
+
throw new ManagedFileError("FILE_NOT_REGULAR", "managed-file root parent must be a directory");
|
|
216
|
+
}
|
|
217
|
+
try {
|
|
218
|
+
await mkdir(requested, { mode: 448 });
|
|
219
|
+
} catch (error) {
|
|
220
|
+
if (errorCode(error) !== "EEXIST") {
|
|
221
|
+
if (errorCode(error) === "ENOENT") {
|
|
222
|
+
throw new ManagedFileError("FILE_NOT_FOUND", "managed-file root parent must exist");
|
|
223
|
+
}
|
|
224
|
+
throw ioError("failed to create managed-file root", error);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
canonical = await realpathOrNull(requested, "failed to resolve managed-file root");
|
|
228
|
+
}
|
|
229
|
+
if (canonical === null) {
|
|
230
|
+
throw new ManagedFileError("FILE_NOT_FOUND", "managed-file root must exist");
|
|
231
|
+
}
|
|
232
|
+
const info = await stat(canonical).catch((error) => {
|
|
233
|
+
throw ioError("failed to inspect managed-file root", error);
|
|
234
|
+
});
|
|
235
|
+
if (!info.isDirectory()) {
|
|
236
|
+
throw new ManagedFileError("FILE_NOT_REGULAR", "managed-file root must be a directory");
|
|
237
|
+
}
|
|
238
|
+
return canonical;
|
|
239
|
+
}
|
|
240
|
+
async function existingParent(root, target) {
|
|
241
|
+
const parent = await realpathOrNull(dirname(target), "failed to resolve managed-file parent directory");
|
|
242
|
+
if (parent === null) {
|
|
243
|
+
throw new ManagedFileError("FILE_NOT_FOUND", "managed-file parent directory not found");
|
|
244
|
+
}
|
|
245
|
+
if (!isWithinDir(root, parent)) {
|
|
246
|
+
throw new ManagedFileError("FILE_OUTSIDE_ROOT", "managed-file path escapes its boundary");
|
|
247
|
+
}
|
|
248
|
+
const info = await stat(parent).catch((error) => {
|
|
249
|
+
throw ioError("failed to inspect managed-file parent directory", error);
|
|
250
|
+
});
|
|
251
|
+
if (!info.isDirectory()) {
|
|
252
|
+
throw new ManagedFileError("FILE_NOT_REGULAR", "managed-file parent is not a directory");
|
|
253
|
+
}
|
|
254
|
+
return parent;
|
|
255
|
+
}
|
|
252
256
|
async function createManagedFileBoundary(config) {
|
|
253
257
|
const root = await bindRoot(config);
|
|
254
258
|
const maxReadBytes = positiveLimit(config.maxReadBytes, DEFAULT_MAX_BYTES, "maxReadBytes");
|
|
@@ -1,29 +1,21 @@
|
|
|
1
|
+
// src/agent-runtime/contained-scan.ts
|
|
2
|
+
import path3 from "node:path";
|
|
3
|
+
|
|
1
4
|
// src/agent-runtime/contained-files.ts
|
|
5
|
+
import { constants } from "node:fs";
|
|
6
|
+
import { lstat, mkdir, open, readdir, realpath } from "node:fs/promises";
|
|
7
|
+
import path2 from "node:path";
|
|
8
|
+
|
|
9
|
+
// src/agent-runtime/contained-darwin.ts
|
|
2
10
|
import {
|
|
3
11
|
close as closeDescriptor,
|
|
4
|
-
constants,
|
|
5
12
|
existsSync,
|
|
6
|
-
fchmod,
|
|
7
13
|
fstat,
|
|
8
|
-
read as readDescriptor
|
|
9
|
-
write as writeDescriptor
|
|
14
|
+
read as readDescriptor
|
|
10
15
|
} from "node:fs";
|
|
11
|
-
import {
|
|
12
|
-
lstat,
|
|
13
|
-
mkdir,
|
|
14
|
-
open,
|
|
15
|
-
readdir,
|
|
16
|
-
realpath,
|
|
17
|
-
rename,
|
|
18
|
-
unlink,
|
|
19
|
-
writeFile
|
|
20
|
-
} from "node:fs/promises";
|
|
21
16
|
import { createRequire } from "node:module";
|
|
22
17
|
import path from "node:path";
|
|
23
18
|
import { fileURLToPath } from "node:url";
|
|
24
|
-
function containedEntryKind(entry) {
|
|
25
|
-
return entry.isDirectory() ? "directory" : entry.isSymbolicLink() ? "symlink" : entry.isFile() ? "file" : "other";
|
|
26
|
-
}
|
|
27
19
|
var FILE_TYPE_MASK = 61440;
|
|
28
20
|
var FILE_TYPE_DIRECTORY = 16384;
|
|
29
21
|
var FILE_TYPE_REGULAR = 32768;
|
|
@@ -87,6 +79,11 @@ class NumericFileHandle {
|
|
|
87
79
|
});
|
|
88
80
|
}
|
|
89
81
|
}
|
|
82
|
+
|
|
83
|
+
// src/agent-runtime/contained-files.ts
|
|
84
|
+
function containedEntryKind(entry) {
|
|
85
|
+
return entry.isDirectory() ? "directory" : entry.isSymbolicLink() ? "symlink" : entry.isFile() ? "file" : "other";
|
|
86
|
+
}
|
|
90
87
|
function descriptorPath(handle) {
|
|
91
88
|
if (process.platform === "linux")
|
|
92
89
|
return `/proc/self/fd/${handle.fd}`;
|
|
@@ -113,7 +110,7 @@ async function openPinnedDirectory(absolute) {
|
|
|
113
110
|
}
|
|
114
111
|
}
|
|
115
112
|
function safeSegments(relative) {
|
|
116
|
-
if (
|
|
113
|
+
if (path2.isAbsolute(relative))
|
|
117
114
|
throw new Error("Contained paths must be relative");
|
|
118
115
|
const segments = relative.split(/[\\/]/u);
|
|
119
116
|
if (segments.length === 0 || segments.some((segment) => segment === "" || segment === "." || segment === "..")) {
|
|
@@ -125,13 +122,13 @@ async function openDirectoryAt(directory, name) {
|
|
|
125
122
|
if (process.platform === "darwin") {
|
|
126
123
|
return new NumericFileHandle(loadDarwinBinding().openDirectoryAt(directory.fd, name));
|
|
127
124
|
}
|
|
128
|
-
return open(
|
|
125
|
+
return open(path2.join(descriptorPath(directory), name), constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
|
|
129
126
|
}
|
|
130
127
|
async function openFileAt(directory, name) {
|
|
131
128
|
if (process.platform === "darwin") {
|
|
132
129
|
return new NumericFileHandle(loadDarwinBinding().openFileAt(directory.fd, name));
|
|
133
130
|
}
|
|
134
|
-
return open(
|
|
131
|
+
return open(path2.join(descriptorPath(directory), name), constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
135
132
|
}
|
|
136
133
|
function entryMetadata(mode, size) {
|
|
137
134
|
return {
|
|
@@ -147,7 +144,7 @@ async function statAt(directory, name) {
|
|
|
147
144
|
const metadata = loadDarwinBinding().statAt(directory.fd, name);
|
|
148
145
|
return metadata ? entryMetadata(metadata.mode, metadata.size) : null;
|
|
149
146
|
}
|
|
150
|
-
return lstat(
|
|
147
|
+
return lstat(path2.join(descriptorPath(directory), name)).catch((error) => {
|
|
151
148
|
if (error.code === "ENOENT")
|
|
152
149
|
return null;
|
|
153
150
|
throw error;
|
|
@@ -179,7 +176,7 @@ async function listContainedDirectory(root, relative, maxEntries, authorizePath)
|
|
|
179
176
|
const admitted = [];
|
|
180
177
|
const denied = [];
|
|
181
178
|
for (const entry of raw) {
|
|
182
|
-
const entryPath = relative === "." ? entry.name :
|
|
179
|
+
const entryPath = relative === "." ? entry.name : path2.join(relative, entry.name);
|
|
183
180
|
if (authorizePath && !await authorizePath(entryPath)) {
|
|
184
181
|
denied.push({ name: entry.name, kind: containedEntryKind(entry) });
|
|
185
182
|
continue;
|
|
@@ -220,7 +217,7 @@ async function createDirectoryAt(directory, name) {
|
|
|
220
217
|
return loadDarwinBinding().createDirectoryAt(directory.fd, name, 511);
|
|
221
218
|
}
|
|
222
219
|
try {
|
|
223
|
-
await mkdir(
|
|
220
|
+
await mkdir(path2.join(descriptorPath(directory), name));
|
|
224
221
|
return true;
|
|
225
222
|
} catch (error) {
|
|
226
223
|
if (error.code === "EEXIST")
|
|
@@ -238,7 +235,7 @@ async function missingContainedDirectories(root, relative) {
|
|
|
238
235
|
for (const segment of segments) {
|
|
239
236
|
walked = [...walked, segment];
|
|
240
237
|
if (missing.length > 0) {
|
|
241
|
-
missing.push(walked.join(
|
|
238
|
+
missing.push(walked.join(path2.sep));
|
|
242
239
|
continue;
|
|
243
240
|
}
|
|
244
241
|
const next = await openDirectoryAt(current, segment).catch((error) => {
|
|
@@ -247,7 +244,7 @@ async function missingContainedDirectories(root, relative) {
|
|
|
247
244
|
throw error;
|
|
248
245
|
});
|
|
249
246
|
if (!next) {
|
|
250
|
-
missing.push(walked.join(
|
|
247
|
+
missing.push(walked.join(path2.sep));
|
|
251
248
|
continue;
|
|
252
249
|
}
|
|
253
250
|
await current.close();
|
|
@@ -317,81 +314,6 @@ async function assertContainedParentCurrent(root, relative, expected) {
|
|
|
317
314
|
await current.handle.close();
|
|
318
315
|
}
|
|
319
316
|
}
|
|
320
|
-
async function writeDescriptorFully(descriptor, content) {
|
|
321
|
-
const bytes = Buffer.from(content);
|
|
322
|
-
let offset = 0;
|
|
323
|
-
while (offset < bytes.byteLength) {
|
|
324
|
-
const written = await new Promise((resolve, reject) => {
|
|
325
|
-
writeDescriptor(descriptor, bytes, offset, bytes.byteLength - offset, null, (error, bytesWritten) => error ? reject(error) : resolve(bytesWritten));
|
|
326
|
-
});
|
|
327
|
-
if (written === 0)
|
|
328
|
-
throw new Error("Contained file write made no progress");
|
|
329
|
-
offset += written;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
async function chmodDescriptor(descriptor, mode) {
|
|
333
|
-
await new Promise((resolve, reject) => {
|
|
334
|
-
fchmod(descriptor, mode & 4095, (error) => error ? reject(error) : resolve());
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
async function createDarwinFile(parent, name, content, mode) {
|
|
338
|
-
const binding = loadDarwinBinding();
|
|
339
|
-
const descriptor = binding.createFileAt(parent.fd, name, mode & 4095);
|
|
340
|
-
let failed;
|
|
341
|
-
try {
|
|
342
|
-
await writeDescriptorFully(descriptor, content);
|
|
343
|
-
await chmodDescriptor(descriptor, mode);
|
|
344
|
-
} catch (error) {
|
|
345
|
-
failed = error;
|
|
346
|
-
} finally {
|
|
347
|
-
try {
|
|
348
|
-
await new NumericFileHandle(descriptor).close();
|
|
349
|
-
} catch (error) {
|
|
350
|
-
failed ??= error;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
if (failed) {
|
|
354
|
-
binding.unlinkAt(parent.fd, name);
|
|
355
|
-
throw failed;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
async function writeContainedFile(input) {
|
|
359
|
-
const mode = input.mode ?? 438;
|
|
360
|
-
if (!input.replace) {
|
|
361
|
-
if (process.platform === "darwin") {
|
|
362
|
-
await createDarwinFile(input.parent.handle, input.parent.basename, input.content, mode);
|
|
363
|
-
return;
|
|
364
|
-
}
|
|
365
|
-
await writeFile(path.join(descriptorPath(input.parent.handle), input.parent.basename), input.content, { flag: "wx", mode });
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
const temporary = `.${input.parent.basename}.${process.pid}.${crypto.randomUUID()}.tmp`;
|
|
369
|
-
if (process.platform === "darwin") {
|
|
370
|
-
const binding = loadDarwinBinding();
|
|
371
|
-
let created = false;
|
|
372
|
-
try {
|
|
373
|
-
await createDarwinFile(input.parent.handle, temporary, input.content, mode);
|
|
374
|
-
created = true;
|
|
375
|
-
binding.renameAt(input.parent.handle.fd, temporary, input.parent.basename);
|
|
376
|
-
} catch (error) {
|
|
377
|
-
if (created)
|
|
378
|
-
binding.unlinkAt(input.parent.handle.fd, temporary);
|
|
379
|
-
throw error;
|
|
380
|
-
}
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
const directory = descriptorPath(input.parent.handle);
|
|
384
|
-
const temporaryPath = path.join(directory, temporary);
|
|
385
|
-
try {
|
|
386
|
-
await writeFile(temporaryPath, input.content, { flag: "wx", mode });
|
|
387
|
-
await rename(temporaryPath, path.join(directory, input.parent.basename));
|
|
388
|
-
} catch (error) {
|
|
389
|
-
await unlink(temporaryPath).catch(() => {
|
|
390
|
-
return;
|
|
391
|
-
});
|
|
392
|
-
throw error;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
317
|
async function containedEntryMetadata(parent) {
|
|
396
318
|
return statAt(parent.handle, parent.basename);
|
|
397
319
|
}
|
|
@@ -425,6 +347,8 @@ async function readContainedUtf8Handle(handle, maxBytes) {
|
|
|
425
347
|
mode: metadata.mode
|
|
426
348
|
};
|
|
427
349
|
}
|
|
350
|
+
|
|
351
|
+
// src/agent-runtime/contained-scan.ts
|
|
428
352
|
async function walkContainedFiles(input) {
|
|
429
353
|
const scan = await scanContainedFiles({ ...input, symlinks: "refuse" });
|
|
430
354
|
if (scan.truncated)
|
|
@@ -449,7 +373,7 @@ async function scanContainedFiles(input) {
|
|
|
449
373
|
const entries = [...await listAt(directory)];
|
|
450
374
|
entries.sort((left, right) => left.name.localeCompare(right.name));
|
|
451
375
|
for (const entry of entries) {
|
|
452
|
-
const relative = relativeDirectory ?
|
|
376
|
+
const relative = relativeDirectory ? path3.join(relativeDirectory, entry.name) : entry.name;
|
|
453
377
|
const kind = entry.isDirectory() ? "directory" : entry.isSymbolicLink() ? "symlink" : entry.isFile() ? "file" : "other";
|
|
454
378
|
if (kind === "file" && input.includeFile && !input.includeFile(relative))
|
|
455
379
|
continue;
|
|
@@ -521,4 +445,4 @@ async function scanContainedFiles(input) {
|
|
|
521
445
|
return { files, truncated, skippedDirectories, skippedSymlinks, denied, deniedTruncated };
|
|
522
446
|
}
|
|
523
447
|
|
|
524
|
-
export { listContainedDirectory, missingContainedDirectories, openContainedParent, openContainedFile, assertContainedFileCurrent, assertContainedParentCurrent,
|
|
448
|
+
export { loadDarwinBinding, NumericFileHandle, descriptorPath, listContainedDirectory, missingContainedDirectories, openContainedParent, openContainedFile, assertContainedFileCurrent, assertContainedParentCurrent, containedEntryMetadata, openContainedParentFile, readContainedUtf8Handle, walkContainedFiles, scanContainedFiles };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// src/internal/atomic-file.ts
|
|
2
|
+
import { randomBytes } from "node:crypto";
|
|
3
|
+
import {
|
|
4
|
+
closeSync,
|
|
5
|
+
fchmodSync,
|
|
6
|
+
fsyncSync,
|
|
7
|
+
openSync,
|
|
8
|
+
renameSync,
|
|
9
|
+
unlinkSync,
|
|
10
|
+
writeSync
|
|
11
|
+
} from "node:fs";
|
|
12
|
+
import { open, rename, unlink } from "node:fs/promises";
|
|
13
|
+
import { basename, dirname, join } from "node:path";
|
|
14
|
+
var DEFAULT_MODE = 384;
|
|
15
|
+
function stagingPath(target) {
|
|
16
|
+
return join(dirname(target), `.${basename(target)}.${randomBytes(12).toString("hex")}.tmp`);
|
|
17
|
+
}
|
|
18
|
+
function bytesOf(data) {
|
|
19
|
+
return typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
20
|
+
}
|
|
21
|
+
async function writeFileAtomic(target, data, options = {}) {
|
|
22
|
+
const mode = options.mode ?? DEFAULT_MODE;
|
|
23
|
+
const staged = stagingPath(target);
|
|
24
|
+
const handle = await open(staged, "wx", mode);
|
|
25
|
+
try {
|
|
26
|
+
try {
|
|
27
|
+
await handle.writeFile(bytesOf(data));
|
|
28
|
+
await handle.chmod(mode);
|
|
29
|
+
await handle.sync();
|
|
30
|
+
} finally {
|
|
31
|
+
await handle.close();
|
|
32
|
+
}
|
|
33
|
+
await rename(staged, target);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
await unlink(staged).catch(() => {
|
|
36
|
+
return;
|
|
37
|
+
});
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function writeFileAtomicSync(target, data, options = {}) {
|
|
42
|
+
const mode = options.mode ?? DEFAULT_MODE;
|
|
43
|
+
const bytes = bytesOf(data);
|
|
44
|
+
const staged = stagingPath(target);
|
|
45
|
+
const handle = openSync(staged, "wx", mode);
|
|
46
|
+
try {
|
|
47
|
+
try {
|
|
48
|
+
for (let offset = 0;offset < bytes.byteLength; ) {
|
|
49
|
+
offset += writeSync(handle, bytes, offset, bytes.byteLength - offset);
|
|
50
|
+
}
|
|
51
|
+
fchmodSync(handle, mode);
|
|
52
|
+
fsyncSync(handle);
|
|
53
|
+
} finally {
|
|
54
|
+
closeSync(handle);
|
|
55
|
+
}
|
|
56
|
+
renameSync(staged, target);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
try {
|
|
59
|
+
unlinkSync(staged);
|
|
60
|
+
} catch {}
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { writeFileAtomic, writeFileAtomicSync };
|
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
createAgentRuntimeStore,
|
|
8
8
|
isActiveRunState,
|
|
9
9
|
replaceMessage
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-wsm5w4ee.js";
|
|
11
11
|
import {
|
|
12
12
|
AgentRecoverablePageSchema,
|
|
13
13
|
AgentStoreEventEnvelopeSchema,
|
|
14
14
|
AgentStoreEventPageSchema
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-gxrt5h6v.js";
|
|
16
16
|
import {
|
|
17
17
|
AgentMessageSchema,
|
|
18
18
|
AgentRecordIdSchema
|