stitchkit 0.104.2 → 0.105.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/CHANGELOG.md +372 -13
- package/darwin-native.cjs +4 -2
- package/dist/agent-runtime/browser-control-contract.d.ts +32 -2
- package/dist/agent-runtime/browser-control-contract.d.ts.map +1 -1
- package/dist/agent-runtime/browser-controller.d.ts +21 -3
- package/dist/agent-runtime/browser-controller.d.ts.map +1 -1
- package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-refusals.d.ts +1 -0
- package/dist/agent-runtime/coding-tool-refusals.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-shell.d.ts.map +1 -1
- package/dist/agent-runtime/compaction.d.ts.map +1 -1
- package/dist/agent-runtime/contained-write.d.ts.map +1 -1
- package/dist/agent-runtime/control-schema.d.ts +48 -1
- package/dist/agent-runtime/control-schema.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tool-search.d.ts +3 -2
- package/dist/agent-runtime/deferred-tool-search.d.ts.map +1 -1
- package/dist/agent-runtime/harness-control.d.ts.map +1 -1
- package/dist/agent-runtime/harness-realtime.d.ts +34 -4
- package/dist/agent-runtime/harness-realtime.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-recovery.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-state.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox-contract.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox-process-owner.d.ts +9 -1
- package/dist/agent-runtime/sandbox-process-owner.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox.d.ts +32 -1
- package/dist/agent-runtime/sandbox.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-records.d.ts.map +1 -1
- package/dist/agent-runtime/schedules.d.ts.map +1 -1
- package/dist/agent-runtime/store-events.d.ts +9 -4
- package/dist/agent-runtime/store-events.d.ts.map +1 -1
- package/dist/agent-runtime/testing.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-contract.d.ts +50 -0
- package/dist/application/diagnostic-journal-contract.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-generations.d.ts +24 -0
- package/dist/application/diagnostic-journal-generations.d.ts.map +1 -0
- package/dist/application/diagnostic-journal-manager.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-open.d.ts +10 -0
- package/dist/application/diagnostic-journal-open.d.ts.map +1 -0
- package/dist/application/diagnostic-journal-quarantine.d.ts +28 -0
- package/dist/application/diagnostic-journal-quarantine.d.ts.map +1 -0
- package/dist/application/diagnostic-journal-read-contract.d.ts +73 -3
- package/dist/application/diagnostic-journal-read-contract.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-reader.d.ts +17 -2
- package/dist/application/diagnostic-journal-reader.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-recovery.d.ts +18 -2
- package/dist/application/diagnostic-journal-recovery.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-storage.d.ts +6 -2
- package/dist/application/diagnostic-journal-storage.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-tail.d.ts +12 -0
- package/dist/application/diagnostic-journal-tail.d.ts.map +1 -0
- package/dist/application/diagnostic-journal.d.ts +3 -0
- package/dist/application/diagnostic-journal.d.ts.map +1 -1
- package/dist/application/directory-inbox-accept.d.ts +3 -3
- package/dist/application/directory-inbox-accept.d.ts.map +1 -1
- package/dist/application/directory-inbox-contract.d.ts +38 -10
- package/dist/application/directory-inbox-contract.d.ts.map +1 -1
- package/dist/application/directory-inbox-delivery.d.ts +3 -3
- package/dist/application/directory-inbox-delivery.d.ts.map +1 -1
- package/dist/application/directory-inbox-files.d.ts +17 -2
- package/dist/application/directory-inbox-files.d.ts.map +1 -1
- package/dist/application/directory-inbox-state.d.ts +1 -1
- package/dist/application/directory-inbox-state.d.ts.map +1 -1
- package/dist/application/directory-inbox.d.ts +1 -1
- package/dist/application/directory-inbox.d.ts.map +1 -1
- package/dist/application/file-state-store.d.ts +21 -1
- package/dist/application/file-state-store.d.ts.map +1 -1
- package/dist/application/grammy.d.ts.map +1 -1
- package/dist/application/kernel-contract.d.ts.map +1 -1
- package/dist/application/revision-signal.d.ts.map +1 -1
- package/dist/application/state-store.d.ts +3 -0
- package/dist/application/state-store.d.ts.map +1 -1
- package/dist/browser/api-error.d.ts +38 -0
- package/dist/browser/api-error.d.ts.map +1 -0
- package/dist/browser/chunked-upload.d.ts.map +1 -1
- package/dist/browser/client-executors.d.ts.map +1 -1
- package/dist/browser/client-url.d.ts.map +1 -1
- package/dist/browser/contract-stream.d.ts.map +1 -1
- package/dist/browser/http.d.ts +0 -25
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/browser/resumable.d.ts.map +1 -1
- package/dist/contract/define-validation.d.ts +0 -1
- package/dist/contract/define-validation.d.ts.map +1 -1
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/errors-factory.d.ts.map +1 -1
- package/dist/contract/errors.d.ts +15 -18
- package/dist/contract/errors.d.ts.map +1 -1
- package/dist/contract/normalize.d.ts.map +1 -1
- package/dist/durability/effect.d.ts.map +1 -1
- package/dist/durability/scheduler.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/browser.js +29 -18
- package/dist/entrypoints/agent-runtime/coding-tools.js +8 -7
- package/dist/entrypoints/agent-runtime/harness.js +15 -14
- package/dist/entrypoints/agent-runtime/realtime.d.ts +1 -1
- package/dist/entrypoints/agent-runtime/realtime.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/realtime.js +119 -54
- package/dist/entrypoints/agent-runtime/sandbox.js +23 -17
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +4 -3
- package/dist/entrypoints/agent-runtime/sqlite/node.js +4 -3
- package/dist/entrypoints/agent-runtime/testing.js +8 -6
- package/dist/entrypoints/agent-runtime.js +37 -38
- package/dist/entrypoints/application/diagnostic-journal.js +305 -111
- package/dist/entrypoints/application/directory-inbox.js +174 -77
- package/dist/entrypoints/application/grammy.js +5 -2
- package/dist/entrypoints/application/opentelemetry.js +2 -2
- package/dist/entrypoints/application.d.ts +2 -2
- package/dist/entrypoints/application.d.ts.map +1 -1
- package/dist/entrypoints/application.js +17 -8
- package/dist/entrypoints/cli/publish.d.ts +16 -0
- package/dist/entrypoints/cli/publish.d.ts.map +1 -0
- package/dist/entrypoints/cli/publish.js +527 -0
- package/dist/entrypoints/cli.d.ts +1 -2
- package/dist/entrypoints/cli.d.ts.map +1 -1
- package/dist/entrypoints/cli.js +59 -966
- package/dist/entrypoints/contract.js +3 -3
- package/dist/entrypoints/files/packaging.js +153 -64
- package/dist/entrypoints/files.d.ts +1 -0
- package/dist/entrypoints/files.d.ts.map +1 -1
- package/dist/entrypoints/files.js +17 -10
- package/dist/entrypoints/index.d.ts +2 -1
- package/dist/entrypoints/index.d.ts.map +1 -1
- package/dist/entrypoints/index.js +31 -60
- package/dist/entrypoints/node.js +8 -8
- package/dist/entrypoints/observability.js +3 -3
- package/dist/entrypoints/primitives.js +67 -83
- package/dist/entrypoints/process.d.ts +1 -1
- package/dist/entrypoints/process.d.ts.map +1 -1
- package/dist/entrypoints/process.js +2 -2
- package/dist/entrypoints/react.js +4 -2
- package/dist/entrypoints/remote.js +37 -13
- package/dist/entrypoints/server.js +18 -16
- package/dist/entrypoints/telegram/screens.js +5 -3
- package/dist/entrypoints/telegram.js +31 -46
- package/dist/entrypoints/testing.d.ts +1 -1
- package/dist/entrypoints/testing.d.ts.map +1 -1
- package/dist/entrypoints/testing.js +444 -448
- package/dist/entrypoints/tools/connections.js +268 -105
- package/dist/entrypoints/tools/contract.js +2 -2
- package/dist/entrypoints/tools/invoker.js +8 -7
- package/dist/entrypoints/tools/mcp.d.ts +2 -2
- package/dist/entrypoints/tools/mcp.d.ts.map +1 -1
- package/dist/entrypoints/tools/mcp.js +10 -9
- package/dist/entrypoints/tools.d.ts +0 -1
- package/dist/entrypoints/tools.d.ts.map +1 -1
- package/dist/entrypoints/tools.js +118 -53
- package/dist/entrypoints/tracking.js +2 -3
- package/dist/files/boundary.d.ts +2 -2
- package/dist/files/boundary.d.ts.map +1 -1
- package/dist/files/chunk-spool.d.ts.map +1 -1
- package/dist/files/file-io.d.ts +2 -2
- package/dist/files/file-io.d.ts.map +1 -1
- package/dist/files/native-packaging-layout.d.ts +50 -4
- package/dist/files/native-packaging-layout.d.ts.map +1 -1
- package/dist/files/native-packaging.d.ts +78 -17
- package/dist/files/native-packaging.d.ts.map +1 -1
- package/dist/{index-r5hsgkz5.js → index-0gs4ymfj.js} +6 -3
- package/dist/{index-zax7resm.js → index-0gxvns6s.js} +1 -13
- package/dist/index-0s4xebbg.js +8 -0
- package/dist/{index-r4r70zmh.js → index-12zsej7b.js} +5 -2
- package/dist/{index-kemm0ej5.js → index-1pwwan01.js} +65 -22
- package/dist/{index-vgkbcnkc.js → index-299sm5tr.js} +1 -1
- package/dist/{index-2vnh05w4.js → index-2k91mewf.js} +31 -74
- package/dist/{index-269zqj8m.js → index-2rc6jd9n.js} +28 -12
- package/dist/{index-wh0ecvyk.js → index-37asdw3a.js} +1 -1
- package/dist/index-3h0ztg0z.js +285 -0
- package/dist/{index-g95fk660.js → index-4vsby8n8.js} +8 -15
- package/dist/index-556g5hsh.js +17 -0
- package/dist/{index-adhgd4pe.js → index-5p55xreg.js} +2 -2
- package/dist/index-5w6t91ze.js +47 -0
- package/dist/{index-9pw0a51a.js → index-6yxhe58g.js} +40 -7
- package/dist/{index-6d9xaxw1.js → index-8ks9b85e.js} +33 -5
- package/dist/{index-bhb950qs.js → index-916yh4e2.js} +25 -12
- package/dist/index-9tqbxv5p.js +44 -0
- package/dist/{index-5csmzesf.js → index-azx12jgv.js} +4 -3
- package/dist/{index-mbnnw3f2.js → index-b0kddvzw.js} +15 -5
- package/dist/{index-n5yqxd3d.js → index-b0w7rbpt.js} +23 -2
- package/dist/index-b56nnscm.js +132 -0
- package/dist/{index-0ndk4555.js → index-c0hffcmj.js} +2 -2
- package/dist/{index-pptyv13k.js → index-c17xcx4k.js} +42 -6
- package/dist/{index-g2j7pnak.js → index-cmzvhhtd.js} +5 -2
- package/dist/index-cq59agna.js +51 -0
- package/dist/{index-ssmd41kh.js → index-d2h99n7d.js} +1 -1
- package/dist/{index-z94wht4y.js → index-dky0dcmf.js} +34 -5
- package/dist/{index-za6j7nwy.js → index-dsnjzb62.js} +104 -51
- package/dist/index-eemvahkc.js +21 -0
- package/dist/index-ef8gdaq0.js +105 -0
- package/dist/{index-fa4wg312.js → index-f199nfq5.js} +10 -6
- package/dist/{index-ck71tbcf.js → index-fsw1ybf3.js} +11 -15
- package/dist/{index-f330qqyg.js → index-g2vfg7ak.js} +217 -63
- package/dist/{index-fk18k56k.js → index-gr5g3xfw.js} +11 -18
- package/dist/{index-jn9g8xdt.js → index-hjvje0pf.js} +6 -4
- package/dist/{index-x928baz2.js → index-j9gxbztg.js} +18 -14
- package/dist/index-kfjkb396.js +37 -0
- package/dist/{index-6drst9sg.js → index-ksfagmyz.js} +45 -345
- package/dist/index-m616f0yz.js +120 -0
- package/dist/{index-fm1c1a08.js → index-m6w6jtda.js} +40 -21
- package/dist/{index-ptn0g0gj.js → index-ma963wz7.js} +21 -20
- package/dist/{index-bakgedh8.js → index-msfpyy2f.js} +2 -4
- package/dist/{index-ywppsaby.js → index-n1nszyk0.js} +23 -34
- package/dist/{index-v14qqmys.js → index-n4689krb.js} +1 -1
- package/dist/{index-a0zzh8ak.js → index-pz3y6b6g.js} +3 -3
- package/dist/{index-43p08g7t.js → index-pzb63z66.js} +12 -8
- package/dist/{index-h97tqqp1.js → index-qaet40b2.js} +5 -3
- package/dist/{index-t1sr4aks.js → index-qaqbdm7s.js} +52 -6
- package/dist/{index-77nxk6ay.js → index-r393tnfp.js} +16 -10
- package/dist/{index-kb8styz3.js → index-rpzewktb.js} +15 -5
- package/dist/{index-27a2pj09.js → index-sj28htvf.js} +1 -1
- package/dist/index-szybbezc.js +455 -0
- package/dist/{index-2hyavjjj.js → index-wbhdzxar.js} +3 -3
- package/dist/{index-4e0ah203.js → index-wdy68sh6.js} +47 -24
- package/dist/{index-hbd32c6a.js → index-wqmvtnkp.js} +38 -89
- package/dist/{index-hp9d77wk.js → index-x7w1z6pf.js} +15 -4
- package/dist/{index-20yvtn9a.js → index-yt7gyg5x.js} +1 -1
- package/dist/{index-cvda079a.js → index-yvfk3y36.js} +12 -2
- package/dist/{index-5z6jn897.js → index-z23rfxhj.js} +1 -1
- package/dist/internal/abort-race.d.ts +8 -2
- package/dist/internal/abort-race.d.ts.map +1 -1
- package/dist/internal/atomic-file.d.ts +55 -9
- package/dist/internal/atomic-file.d.ts.map +1 -1
- package/dist/internal/atomic-publication.d.ts +39 -4
- package/dist/internal/atomic-publication.d.ts.map +1 -1
- package/dist/internal/atomic-staging.d.ts +46 -0
- package/dist/internal/atomic-staging.d.ts.map +1 -0
- package/dist/internal/bounded-file-read.d.ts +19 -11
- package/dist/internal/bounded-file-read.d.ts.map +1 -1
- package/dist/internal/bounded-lines.d.ts.map +1 -1
- package/dist/internal/close-after.d.ts +11 -0
- package/dist/internal/close-after.d.ts.map +1 -0
- package/dist/internal/deadline.d.ts +10 -0
- package/dist/internal/deadline.d.ts.map +1 -1
- package/dist/internal/exclusive-lock-read.d.ts +10 -12
- package/dist/internal/exclusive-lock-read.d.ts.map +1 -1
- package/dist/internal/exclusive-lock.d.ts +2 -2
- package/dist/internal/exclusive-lock.d.ts.map +1 -1
- package/dist/internal/file-observation.d.ts +14 -0
- package/dist/internal/file-observation.d.ts.map +1 -0
- package/dist/internal/json-data.d.ts +22 -5
- package/dist/internal/json-data.d.ts.map +1 -1
- package/dist/internal/positive-integer.d.ts +9 -0
- package/dist/internal/positive-integer.d.ts.map +1 -0
- package/dist/internal/process-instance.d.ts +35 -5
- package/dist/internal/process-instance.d.ts.map +1 -1
- package/dist/internal/secure-fetch.d.ts.map +1 -1
- package/dist/internal/timers.d.ts +11 -0
- package/dist/internal/timers.d.ts.map +1 -0
- package/dist/internal/with-exclusive-lock.d.ts +5 -4
- package/dist/internal/with-exclusive-lock.d.ts.map +1 -1
- package/dist/observability/bounded-sink.d.ts.map +1 -1
- package/dist/primitives/canonical-json.d.ts +23 -2
- package/dist/primitives/canonical-json.d.ts.map +1 -1
- package/dist/primitives/delivery.d.ts.map +1 -1
- package/dist/primitives/index.d.ts +1 -1
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/money.d.ts.map +1 -1
- package/dist/process/cleanup.d.ts +6 -1
- package/dist/process/cleanup.d.ts.map +1 -1
- package/dist/process/command-lifetime.d.ts +4 -0
- package/dist/process/command-lifetime.d.ts.map +1 -1
- package/dist/process/command-owner.d.ts.map +1 -1
- package/dist/process/command.d.ts +4 -0
- package/dist/process/command.d.ts.map +1 -1
- package/dist/process/contract.d.ts +67 -2
- package/dist/process/contract.d.ts.map +1 -1
- package/dist/process/group.d.ts +40 -3
- package/dist/process/group.d.ts.map +1 -1
- package/dist/process/launch.d.ts +12 -1
- package/dist/process/launch.d.ts.map +1 -1
- package/dist/process/terminate.d.ts +39 -0
- package/dist/process/terminate.d.ts.map +1 -0
- package/dist/react/query-client.d.ts.map +1 -1
- package/dist/realtime/rejection.d.ts.map +1 -1
- package/dist/server/contract-stream.d.ts.map +1 -1
- package/dist/server/handler-state.d.ts.map +1 -1
- package/dist/server/implement.d.ts.map +1 -1
- package/dist/server/request-body.d.ts +0 -1
- package/dist/server/request-body.d.ts.map +1 -1
- package/dist/server/unix-client.d.ts.map +1 -1
- package/dist/telegram/broadcast-delivery.d.ts.map +1 -1
- package/dist/telegram/broadcast-failure.d.ts +10 -2
- package/dist/telegram/broadcast-failure.d.ts.map +1 -1
- package/dist/telegram/operator-channel.d.ts.map +1 -1
- package/dist/telegram/screens/outcome.d.ts.map +1 -1
- package/dist/testing/surface-conformance.d.ts +1 -1
- package/dist/testing/surface-conformance.d.ts.map +1 -1
- package/dist/testing/surface-manifest.d.ts +0 -6
- 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.d.ts +1 -1
- package/dist/tools/cli/args.d.ts.map +1 -1
- package/dist/tools/cli/help.d.ts.map +1 -1
- package/dist/tools/cli/invoke.d.ts +2 -2
- package/dist/tools/cli/invoke.d.ts.map +1 -1
- package/dist/tools/cli/profile.d.ts.map +1 -1
- package/dist/tools/cli/publication-assets.d.ts.map +1 -1
- package/dist/tools/cli/publication-contract.d.ts +8 -0
- package/dist/tools/cli/publication-contract.d.ts.map +1 -1
- package/dist/tools/cli/publication-control.d.ts.map +1 -1
- package/dist/tools/cli/publication-storage.d.ts +23 -2
- package/dist/tools/cli/publication-storage.d.ts.map +1 -1
- package/dist/tools/cli/publication.d.ts +8 -1
- package/dist/tools/cli/publication.d.ts.map +1 -1
- package/dist/tools/connections/errors.d.ts +18 -6
- package/dist/tools/connections/errors.d.ts.map +1 -1
- package/dist/tools/connections/limits.d.ts +8 -2
- package/dist/tools/connections/limits.d.ts.map +1 -1
- package/dist/tools/connections/mcp-client.d.ts.map +1 -1
- package/dist/tools/connections/mcp-envelope.d.ts.map +1 -1
- package/dist/tools/connections/openapi.d.ts.map +1 -1
- package/dist/tools/connections/schema-budget.d.ts +1 -1
- package/dist/tools/connections/schema-budget.d.ts.map +1 -1
- package/dist/tools/connections/sse-session.d.ts.map +1 -1
- package/dist/tools/execute-args.d.ts.map +1 -1
- package/dist/tools/execute-result.d.ts.map +1 -1
- package/dist/tools/internal/surface-projector.d.ts +17 -3
- package/dist/tools/internal/surface-projector.d.ts.map +1 -1
- package/dist/tools/internal/tool-error-projection.d.ts +16 -0
- package/dist/tools/internal/tool-error-projection.d.ts.map +1 -0
- package/dist/tools/internal/tool-view.d.ts.map +1 -1
- package/dist/tools/invoker.d.ts.map +1 -1
- package/dist/tools/list-names.d.ts +3 -2
- package/dist/tools/list-names.d.ts.map +1 -1
- package/dist/tools/manifest.d.ts +3 -2
- package/dist/tools/manifest.d.ts.map +1 -1
- package/dist/tools/mcp/handler.d.ts +7 -0
- package/dist/tools/mcp/handler.d.ts.map +1 -1
- package/dist/tools/mcp/mount.d.ts +18 -2
- package/dist/tools/mcp/mount.d.ts.map +1 -1
- package/dist/tools/mcp/prepare.d.ts +3 -3
- package/dist/tools/mcp/prepare.d.ts.map +1 -1
- package/dist/tools/mcp/register.d.ts.map +1 -1
- package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
- package/dist/tools/mcp/stdio-signals.d.ts +14 -0
- package/dist/tools/mcp/stdio-signals.d.ts.map +1 -1
- package/dist/tools/mcp/stdio.d.ts +7 -0
- package/dist/tools/mcp/stdio.d.ts.map +1 -1
- package/dist/tools/operations/async-operation-runtime-tools.d.ts.map +1 -1
- package/dist/tools/operations/async-operation-runtime-types.d.ts +3 -3
- package/dist/tools/operations/async-operation-runtime-types.d.ts.map +1 -1
- package/dist/tools/operations/define-wait-tool.d.ts +1 -1
- package/dist/tools/operations/define-wait-tool.d.ts.map +1 -1
- package/dist/tools/operations/wait-core.d.ts +0 -6
- package/dist/tools/operations/wait-core.d.ts.map +1 -1
- package/dist/tools/registry.d.ts +1 -1
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/remote.d.ts +1 -1
- package/dist/tools/remote.d.ts.map +1 -1
- package/dist/tools/{runtime-tool-execution.d.ts → runtime-tool-declaration.d.ts} +32 -9
- package/dist/tools/runtime-tool-declaration.d.ts.map +1 -0
- package/dist/tools/runtime-tool-mcp.d.ts +6 -15
- package/dist/tools/runtime-tool-mcp.d.ts.map +1 -1
- package/dist/tools/runtime-tool.d.ts +14 -12
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools/schema/coerce.d.ts +4 -0
- package/dist/tools/schema/coerce.d.ts.map +1 -1
- package/dist/tools/schema/flatten-join.d.ts.map +1 -1
- package/dist/tools/surface.d.ts +7 -11
- package/dist/tools/surface.d.ts.map +1 -1
- package/dist/tools/transfer/define-download-tool.d.ts +1 -1
- package/dist/tools/transfer/define-download-tool.d.ts.map +1 -1
- package/dist/tools/transfer/define-upload-tool.d.ts +1 -1
- package/dist/tools/transfer/define-upload-tool.d.ts.map +1 -1
- package/dist/tools/transfer/define-view-file-tool.d.ts +1 -1
- package/dist/tools/transfer/define-view-file-tool.d.ts.map +1 -1
- package/dist/tools/transfer/managed-file-error.d.ts.map +1 -1
- package/dist/tools/transfer/view-file-contract.d.ts.map +1 -1
- package/dist/tools/transfer/view-file.d.ts +1 -1
- package/dist/tools/transfer/view-file.d.ts.map +1 -1
- package/dist/tools/transports.d.ts +3 -2
- package/dist/tools/transports.d.ts.map +1 -1
- package/llms/agent-runtime-browser.txt +10 -4
- package/llms/agent-runtime-harness.txt +32 -31
- package/llms/agent-runtime-react.txt +1 -1
- package/llms/agent-runtime-realtime.txt +14 -5
- package/llms/agent-runtime-sandbox.txt +3 -11
- package/llms/agent-runtime.3.txt +2 -2
- package/llms/agent-runtime.txt +0 -9
- package/llms/application.2.txt +3 -12
- package/llms/application.3.txt +7 -4
- package/llms/application.txt +44 -15
- package/llms/cli-publish.txt +29 -0
- package/llms/cli.2.txt +9 -11
- package/llms/cli.txt +26 -14
- package/llms/declaration.txt +0 -9
- package/llms/files-packaging.txt +16 -8
- package/llms/files.txt +4 -2
- package/llms/geo.txt +0 -9
- package/llms/live.txt +4 -13
- package/llms/observability.txt +31 -5
- package/llms/primitives.txt +38 -20
- package/llms/process.txt +287 -157
- package/llms/react-keyboard.txt +0 -9
- package/llms/react.txt +0 -18
- package/llms/server.4.txt +1 -1
- package/llms/server.5.txt +1 -1
- package/llms/server.txt +1 -1
- package/llms/stitchkit.txt +6 -7
- package/llms/telegram-screens.txt +2 -2
- package/llms/testing.txt +0 -1
- package/llms/tools-mcp.txt +2 -3
- package/llms/tools.2.txt +12 -0
- package/llms/tools.3.txt +5 -6
- package/llms/tools.txt +6 -4
- package/llms/upgrading-0.37.0-0.50.0.txt +947 -0
- package/llms/{upgrading-0.44.0-0.61.0.txt → upgrading-0.53.0-0.67.0.txt} +576 -506
- package/llms/{upgrading-0.62.0-0.80.0.txt → upgrading-0.68.0-0.94.0.txt} +562 -576
- package/llms/{upgrading-0.81.0-0.104.0.txt → upgrading-0.95.0-0.105.0.txt} +452 -567
- package/llms/upgrading.txt +4 -4
- package/llms-full.txt +1029 -409
- package/llms.txt +24 -24
- package/native-assets.json +11 -3
- package/package.json +6 -6
- package/dist/agent-runtime/harness-tools.d.ts +0 -11
- package/dist/agent-runtime/harness-tools.d.ts.map +0 -1
- package/dist/entrypoints/agent-runtime/harness-tools.d.ts +0 -2
- package/dist/entrypoints/agent-runtime/harness-tools.d.ts.map +0 -1
- package/dist/entrypoints/agent-runtime/harness-tools.js +0 -32
- package/dist/index-1a6jtnd9.js +0 -88
- package/dist/index-8a9ksm91.js +0 -95
- package/dist/index-a3wma1hk.js +0 -48
- package/dist/index-jd470k6q.js +0 -109
- package/dist/index-n1dqr7gf.js +0 -20
- package/dist/index-nggfa2yn.js +0 -34
- package/dist/index-s4evrmp5.js +0 -98
- package/dist/index-ze1eph1k.js +0 -20
- package/dist/tools/connections/error-projection.d.ts +0 -4
- package/dist/tools/connections/error-projection.d.ts.map +0 -1
- package/dist/tools/runtime-tool-execution.d.ts.map +0 -1
- package/llms/agent-runtime-harness-tools.txt +0 -25
- package/llms/upgrading-0.37.0-0.44.0.txt +0 -444
|
@@ -1,24 +1,37 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DiagnosticJournalFrameSchema2,
|
|
3
3
|
createDiagnosticJournalReadResultSchema2,
|
|
4
|
+
DIAGNOSTIC_JOURNAL_LISTED_QUARANTINE_LIMIT,
|
|
4
5
|
DiagnosticJournalRecoveryStatusSchema2,
|
|
5
6
|
DiagnosticJournalRecoveryError2,
|
|
6
7
|
DiagnosticJournalLimitsSchema2,
|
|
7
8
|
DiagnosticJournalLockPolicySchema2,
|
|
9
|
+
DiagnosticJournalStartupScanSchema2,
|
|
10
|
+
DiagnosticJournalStartupRefusalPolicySchema2,
|
|
8
11
|
DiagnosticJournalStatusSchema2,
|
|
9
12
|
DiagnosticJournalSubmitResultSchema2,
|
|
10
13
|
DiagnosticJournalWaitResultSchema2,
|
|
11
14
|
DiagnosticJournalCloseResultSchema2,
|
|
12
15
|
parseDiagnosticJournalMode
|
|
13
|
-
} from "../../index-
|
|
16
|
+
} from "../../index-dky0dcmf.js";
|
|
14
17
|
import {
|
|
15
18
|
createBoundedChannel2
|
|
16
19
|
} from "../../index-w0eqdhyd.js";
|
|
17
20
|
import {
|
|
18
21
|
attemptExclusiveLock
|
|
19
|
-
} from "../../index-
|
|
20
|
-
import"../../index-
|
|
22
|
+
} from "../../index-dsnjzb62.js";
|
|
23
|
+
import"../../index-azx12jgv.js";
|
|
21
24
|
import"../../index-v5ee8ath.js";
|
|
25
|
+
import {
|
|
26
|
+
BoundedFileReadError,
|
|
27
|
+
openRegularFile
|
|
28
|
+
} from "../../index-m616f0yz.js";
|
|
29
|
+
import {
|
|
30
|
+
closeAfter
|
|
31
|
+
} from "../../index-b56nnscm.js";
|
|
32
|
+
import {
|
|
33
|
+
assertPositiveSafeInteger
|
|
34
|
+
} from "../../index-0s4xebbg.js";
|
|
22
35
|
import {
|
|
23
36
|
isRecord
|
|
24
37
|
} from "../../index-9jfdm5tg.js";
|
|
@@ -27,12 +40,116 @@ import {
|
|
|
27
40
|
import { randomUUID } from "node:crypto";
|
|
28
41
|
|
|
29
42
|
// src/application/diagnostic-journal-manager.ts
|
|
30
|
-
import { z as
|
|
43
|
+
import { z as z5 } from "zod";
|
|
31
44
|
|
|
32
45
|
// src/application/diagnostic-journal-storage.ts
|
|
33
|
-
import { constants
|
|
34
|
-
import { lstat as lstat2, open
|
|
35
|
-
import { basename, dirname, isAbsolute as isAbsolute2, resolve as
|
|
46
|
+
import { constants } from "node:fs";
|
|
47
|
+
import { lstat as lstat2, open, realpath, rename as rename2, unlink } from "node:fs/promises";
|
|
48
|
+
import { basename, dirname, isAbsolute as isAbsolute2, resolve as resolve3 } from "node:path";
|
|
49
|
+
|
|
50
|
+
// src/application/diagnostic-journal-generations.ts
|
|
51
|
+
import { lstat, readdir } from "node:fs/promises";
|
|
52
|
+
import { resolve } from "node:path";
|
|
53
|
+
|
|
54
|
+
// src/application/diagnostic-journal-quarantine.ts
|
|
55
|
+
import { rename } from "node:fs/promises";
|
|
56
|
+
function createStartupRefusalHandler(policy, epoch) {
|
|
57
|
+
return async (refusal) => {
|
|
58
|
+
if (policy === "fail")
|
|
59
|
+
throw new DiagnosticJournalRecoveryError2(refusal);
|
|
60
|
+
const quarantinedAs = `${refusal.file}.quarantined-${epoch}`;
|
|
61
|
+
try {
|
|
62
|
+
await rename(refusal.file, quarantinedAs);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
throw new DiagnosticJournalRecoveryError2({
|
|
65
|
+
...refusal,
|
|
66
|
+
quarantineFailed: true,
|
|
67
|
+
cause: new AggregateError(refusal.cause === undefined ? [error] : [refusal.cause, error], "Diagnostic journal could not move a refused file aside")
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const code = refusal.reason === "unreadable" && isRecord(refusal.cause) && typeof refusal.cause.code === "string" ? refusal.cause.code : undefined;
|
|
71
|
+
return {
|
|
72
|
+
file: refusal.file,
|
|
73
|
+
quarantinedAs,
|
|
74
|
+
reason: refusal.reason,
|
|
75
|
+
...code !== undefined && { code }
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function quarantinedOrigin(name, prefix) {
|
|
80
|
+
if (!name.startsWith(prefix))
|
|
81
|
+
return;
|
|
82
|
+
const match = /^(?:(\d+)\.)?quarantined-[\s\S]+$/.exec(name.slice(prefix.length));
|
|
83
|
+
if (!match)
|
|
84
|
+
return;
|
|
85
|
+
const index = match[1];
|
|
86
|
+
return index === undefined ? prefix.slice(0, -1) : `${prefix}${index}`;
|
|
87
|
+
}
|
|
88
|
+
function listQuarantinedFiles(movedNow, movedEarlier) {
|
|
89
|
+
const total = movedNow.length + movedEarlier.length;
|
|
90
|
+
if (total === 0)
|
|
91
|
+
return {};
|
|
92
|
+
const limit = DIAGNOSTIC_JOURNAL_LISTED_QUARANTINE_LIMIT;
|
|
93
|
+
const quarantined = [
|
|
94
|
+
...movedNow.slice(0, limit),
|
|
95
|
+
...movedEarlier.slice(0, Math.max(0, limit - movedNow.length))
|
|
96
|
+
];
|
|
97
|
+
const unlisted = total - quarantined.length;
|
|
98
|
+
return { quarantined, ...unlisted > 0 && { quarantinedUnlisted: unlisted } };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// src/application/diagnostic-journal-generations.ts
|
|
102
|
+
function generation(path, index) {
|
|
103
|
+
return `${path}.${index}`;
|
|
104
|
+
}
|
|
105
|
+
function generationIndex(name, prefix) {
|
|
106
|
+
if (!name.startsWith(prefix))
|
|
107
|
+
return;
|
|
108
|
+
const suffix = name.slice(prefix.length);
|
|
109
|
+
if (!/^\d+$/.test(suffix))
|
|
110
|
+
return;
|
|
111
|
+
const value = Number(suffix);
|
|
112
|
+
return Number.isSafeInteger(value) && value > 0 ? value : undefined;
|
|
113
|
+
}
|
|
114
|
+
async function listDiagnosticJournalGenerations(parent, prefix, maxFiles, refuse) {
|
|
115
|
+
const expired = [];
|
|
116
|
+
const quarantined = [];
|
|
117
|
+
const quarantinedEarlier = [];
|
|
118
|
+
let existing = 0;
|
|
119
|
+
for (const name of (await readdir(parent)).sort()) {
|
|
120
|
+
const origin = quarantinedOrigin(name, prefix);
|
|
121
|
+
if (origin !== undefined) {
|
|
122
|
+
quarantinedEarlier.push({
|
|
123
|
+
file: resolve(parent, origin),
|
|
124
|
+
quarantinedAs: resolve(parent, name)
|
|
125
|
+
});
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
const index = generationIndex(name, prefix);
|
|
129
|
+
if (index === undefined)
|
|
130
|
+
continue;
|
|
131
|
+
const path = resolve(parent, name);
|
|
132
|
+
const info = await lstat(path);
|
|
133
|
+
if (info.isSymbolicLink() || !info.isFile()) {
|
|
134
|
+
quarantined.push(await refuse({ file: path, reason: "not-a-regular-file" }));
|
|
135
|
+
} else if (index >= maxFiles) {
|
|
136
|
+
expired.push(path);
|
|
137
|
+
} else {
|
|
138
|
+
existing += 1;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return { expired, existing, quarantined, quarantinedEarlier };
|
|
142
|
+
}
|
|
143
|
+
async function retainedDiagnosticJournalGenerations(parent, prefix, maxFiles) {
|
|
144
|
+
const paths = [];
|
|
145
|
+
for (const name of await readdir(parent)) {
|
|
146
|
+
const index = generationIndex(name, prefix);
|
|
147
|
+
if (index !== undefined && index < maxFiles) {
|
|
148
|
+
paths.push({ index, path: resolve(parent, name) });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return paths.sort((left, right) => right.index - left.index).map((file) => file.path);
|
|
152
|
+
}
|
|
36
153
|
|
|
37
154
|
// src/application/diagnostic-journal-lock.ts
|
|
38
155
|
async function acquireDiagnosticJournalLock(lockPath, mode, policy, declaredIdentity) {
|
|
@@ -52,13 +169,28 @@ async function acquireDiagnosticJournalLock(lockPath, mode, policy, declaredIden
|
|
|
52
169
|
}
|
|
53
170
|
|
|
54
171
|
// src/application/diagnostic-journal-recovery.ts
|
|
55
|
-
import { z as
|
|
172
|
+
import { z as z4 } from "zod";
|
|
56
173
|
|
|
57
174
|
// src/application/diagnostic-journal-reader.ts
|
|
58
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
|
|
175
|
+
import { isAbsolute, resolve as resolve2 } from "node:path";
|
|
176
|
+
import { z as z2 } from "zod";
|
|
177
|
+
|
|
178
|
+
// src/application/diagnostic-journal-open.ts
|
|
61
179
|
import { z } from "zod";
|
|
180
|
+
async function openJournalFile(path) {
|
|
181
|
+
try {
|
|
182
|
+
const { handle, before } = await openRegularFile(path, { rejectSymlinks: true });
|
|
183
|
+
return { handle, size: z.number().int().nonnegative().parse(before.size) };
|
|
184
|
+
} catch (error) {
|
|
185
|
+
if (error instanceof BoundedFileReadError && (error.code === "FILE_UNSAFE_LINK" || error.code === "FILE_NOT_REGULAR"))
|
|
186
|
+
throw new TypeError("Diagnostic journal reader requires a regular file, never a symlink", {
|
|
187
|
+
cause: error
|
|
188
|
+
});
|
|
189
|
+
throw error;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// src/application/diagnostic-journal-reader.ts
|
|
62
194
|
function decodeLine(schema, location, body) {
|
|
63
195
|
const anomaly = (reason, skippedBytes = location.bytes) => schema.parse({
|
|
64
196
|
type: "anomaly",
|
|
@@ -102,35 +234,19 @@ function decodeLine(schema, location, body) {
|
|
|
102
234
|
}
|
|
103
235
|
return location.terminated ? [parsed.data] : [anomaly("unterminated-line", 0), parsed.data];
|
|
104
236
|
}
|
|
105
|
-
async function openRegularFile(path) {
|
|
106
|
-
const before = await lstat(path);
|
|
107
|
-
if (before.isSymbolicLink() || !before.isFile()) {
|
|
108
|
-
throw new TypeError("Diagnostic journal reader requires a regular file, never a symlink");
|
|
109
|
-
}
|
|
110
|
-
const handle = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
111
|
-
try {
|
|
112
|
-
const info = await handle.stat();
|
|
113
|
-
if (!info.isFile())
|
|
114
|
-
throw new TypeError("Diagnostic journal reader requires a regular file");
|
|
115
|
-
return { handle, size: z.number().int().nonnegative().parse(info.size) };
|
|
116
|
-
} catch (error) {
|
|
117
|
-
await handle.close();
|
|
118
|
-
throw error;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
237
|
async function* readDiagnosticJournal(config) {
|
|
122
|
-
const maxLineBytes =
|
|
238
|
+
const maxLineBytes = z2.number().int().positive().parse(config.maxLineBytes);
|
|
123
239
|
if (config.paths.length === 0)
|
|
124
240
|
throw new TypeError("Diagnostic journal reader needs at least one path");
|
|
125
241
|
for (const path of config.paths) {
|
|
126
|
-
if (!isAbsolute(path) ||
|
|
242
|
+
if (!isAbsolute(path) || resolve2(path) !== path) {
|
|
127
243
|
throw new TypeError("Diagnostic journal reader paths must be normalized and absolute");
|
|
128
244
|
}
|
|
129
245
|
}
|
|
130
246
|
const schema = createDiagnosticJournalReadResultSchema2(config.eventSchema);
|
|
131
247
|
for (const file of config.paths) {
|
|
132
248
|
config.signal?.throwIfAborted();
|
|
133
|
-
const { handle, size } = await
|
|
249
|
+
const { handle, size } = await openJournalFile(file);
|
|
134
250
|
try {
|
|
135
251
|
const chunk = Buffer.alloc(64 * 1024);
|
|
136
252
|
let offset = 0;
|
|
@@ -193,26 +309,98 @@ async function* readDiagnosticJournal(config) {
|
|
|
193
309
|
}
|
|
194
310
|
}
|
|
195
311
|
|
|
312
|
+
// src/application/diagnostic-journal-tail.ts
|
|
313
|
+
import { z as z3 } from "zod";
|
|
314
|
+
var SCAN_CHUNK_BYTES = 1024 * 1024;
|
|
315
|
+
var jsonSchema = z3.json();
|
|
316
|
+
var resultSchema = createDiagnosticJournalReadResultSchema2(jsonSchema);
|
|
317
|
+
async function* readDiagnosticJournalTails(paths, maxLineBytes) {
|
|
318
|
+
for (const file of paths) {
|
|
319
|
+
const { handle, size } = await openJournalFile(file);
|
|
320
|
+
const last = await closeAfter(handle, async () => {
|
|
321
|
+
if (size === 0)
|
|
322
|
+
return;
|
|
323
|
+
const chunk = Buffer.alloc(SCAN_CHUNK_BYTES);
|
|
324
|
+
let lineFeeds = 0;
|
|
325
|
+
let lastFeed = -1;
|
|
326
|
+
let previousFeed = -1;
|
|
327
|
+
for (let offset = 0;offset < size; ) {
|
|
328
|
+
const { bytesRead } = await handle.read(chunk, 0, Math.min(chunk.length, size - offset), offset);
|
|
329
|
+
if (bytesRead === 0)
|
|
330
|
+
throw new Error(`Diagnostic journal file was truncated during read: ${file}`);
|
|
331
|
+
const block = chunk.subarray(0, bytesRead);
|
|
332
|
+
for (let at = block.indexOf(10);at !== -1; at = block.indexOf(10, at + 1)) {
|
|
333
|
+
lineFeeds += 1;
|
|
334
|
+
previousFeed = lastFeed;
|
|
335
|
+
lastFeed = offset + at;
|
|
336
|
+
}
|
|
337
|
+
offset += bytesRead;
|
|
338
|
+
}
|
|
339
|
+
const terminated = lastFeed === size - 1;
|
|
340
|
+
const start = (terminated ? previousFeed : lastFeed) + 1;
|
|
341
|
+
const length = (terminated ? size - 1 : size) - start;
|
|
342
|
+
const location = {
|
|
343
|
+
file,
|
|
344
|
+
offset: start,
|
|
345
|
+
line: terminated ? lineFeeds : lineFeeds + 1,
|
|
346
|
+
bytes: length + (terminated ? 1 : 0),
|
|
347
|
+
terminated,
|
|
348
|
+
position: "tail"
|
|
349
|
+
};
|
|
350
|
+
if (length > maxLineBytes)
|
|
351
|
+
return { location, body: undefined };
|
|
352
|
+
const body = Buffer.alloc(length);
|
|
353
|
+
for (let filled = 0;filled < length; ) {
|
|
354
|
+
const { bytesRead } = await handle.read(body, filled, length - filled, start + filled);
|
|
355
|
+
if (bytesRead === 0)
|
|
356
|
+
throw new Error(`Diagnostic journal file was truncated during read: ${file}`);
|
|
357
|
+
filled += bytesRead;
|
|
358
|
+
}
|
|
359
|
+
return { location, body };
|
|
360
|
+
});
|
|
361
|
+
if (last)
|
|
362
|
+
yield* decodeLine(resultSchema, last.location, last.body);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
196
366
|
// src/application/diagnostic-journal-recovery.ts
|
|
197
|
-
|
|
367
|
+
function readFile(file, maxLineBytes, scan) {
|
|
368
|
+
return scan === "full" ? readDiagnosticJournal({ paths: [file], maxLineBytes, eventSchema: z4.json() }) : readDiagnosticJournalTails([file], maxLineBytes);
|
|
369
|
+
}
|
|
370
|
+
async function inspectDiagnosticJournalRecovery(inspection) {
|
|
371
|
+
let filesChecked = 0;
|
|
198
372
|
let anomalies = 0;
|
|
199
373
|
let skippedBytes = 0;
|
|
200
374
|
let firstAnomaly;
|
|
201
375
|
let lastAnomaly;
|
|
202
|
-
for
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
376
|
+
for (const file of inspection.paths) {
|
|
377
|
+
let fileAnomalies = 0;
|
|
378
|
+
let fileSkipped = 0;
|
|
379
|
+
let fileFirst;
|
|
380
|
+
let fileLast;
|
|
381
|
+
try {
|
|
382
|
+
for await (const result of readFile(file, inspection.maxLineBytes, inspection.scan)) {
|
|
383
|
+
if (result.type !== "anomaly")
|
|
384
|
+
continue;
|
|
385
|
+
fileAnomalies += 1;
|
|
386
|
+
fileSkipped += result.anomaly.skippedBytes;
|
|
387
|
+
fileFirst ??= result.anomaly;
|
|
388
|
+
fileLast = result.anomaly;
|
|
389
|
+
}
|
|
390
|
+
} catch (error) {
|
|
391
|
+
if (!inspection.onUnreadable)
|
|
392
|
+
throw error;
|
|
393
|
+
await inspection.onUnreadable(file, error);
|
|
208
394
|
continue;
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
395
|
+
}
|
|
396
|
+
filesChecked += 1;
|
|
397
|
+
anomalies += fileAnomalies;
|
|
398
|
+
skippedBytes += fileSkipped;
|
|
399
|
+
firstAnomaly ??= fileFirst;
|
|
400
|
+
lastAnomaly = fileLast ?? lastAnomaly;
|
|
213
401
|
}
|
|
214
402
|
return DiagnosticJournalRecoveryStatusSchema2.parse({
|
|
215
|
-
filesChecked
|
|
403
|
+
filesChecked,
|
|
216
404
|
anomalies,
|
|
217
405
|
skippedBytes,
|
|
218
406
|
...firstAnomaly && { firstAnomaly },
|
|
@@ -250,7 +438,7 @@ async function moveIfPresent(from, to) {
|
|
|
250
438
|
if (info.isSymbolicLink() || !info.isFile()) {
|
|
251
439
|
throw new Error("Diagnostic journal generations must be regular files");
|
|
252
440
|
}
|
|
253
|
-
await
|
|
441
|
+
await rename2(from, to);
|
|
254
442
|
return true;
|
|
255
443
|
} catch (error) {
|
|
256
444
|
if (isMissing(error))
|
|
@@ -258,24 +446,12 @@ async function moveIfPresent(from, to) {
|
|
|
258
446
|
throw error;
|
|
259
447
|
}
|
|
260
448
|
}
|
|
261
|
-
function generation(path, index) {
|
|
262
|
-
return `${path}.${index}`;
|
|
263
|
-
}
|
|
264
|
-
function generationIndex(name, prefix) {
|
|
265
|
-
if (!name.startsWith(prefix))
|
|
266
|
-
return;
|
|
267
|
-
const suffix = name.slice(prefix.length);
|
|
268
|
-
if (!/^\d+$/.test(suffix))
|
|
269
|
-
return;
|
|
270
|
-
const value = Number(suffix);
|
|
271
|
-
return Number.isSafeInteger(value) && value > 0 ? value : undefined;
|
|
272
|
-
}
|
|
273
449
|
async function createRotatingDiagnosticJournalStorage(config) {
|
|
274
|
-
if (!isAbsolute2(config.path) ||
|
|
450
|
+
if (!isAbsolute2(config.path) || resolve3(config.path) !== config.path) {
|
|
275
451
|
throw new TypeError("Diagnostic journal path must be normalized and absolute");
|
|
276
452
|
}
|
|
277
453
|
const parent = await realpath(dirname(config.path));
|
|
278
|
-
const journalPath =
|
|
454
|
+
const journalPath = resolve3(parent, basename(config.path));
|
|
279
455
|
const lockPath = `${journalPath}.lock`;
|
|
280
456
|
const { lock, reclaimedStale } = await acquireDiagnosticJournalLock(lockPath, config.mode, config.lock, config.machineIdentity);
|
|
281
457
|
let handle;
|
|
@@ -286,7 +462,7 @@ async function createRotatingDiagnosticJournalStorage(config) {
|
|
|
286
462
|
let recovery;
|
|
287
463
|
let closed = false;
|
|
288
464
|
const openCurrent = async () => {
|
|
289
|
-
handle = await
|
|
465
|
+
handle = await open(journalPath, constants.O_APPEND | constants.O_CREAT | constants.O_RDWR | constants.O_NOFOLLOW, config.mode);
|
|
290
466
|
const info = await handle.stat();
|
|
291
467
|
if (!info.isFile()) {
|
|
292
468
|
await handle.close();
|
|
@@ -315,52 +491,65 @@ async function createRotatingDiagnosticJournalStorage(config) {
|
|
|
315
491
|
throw new DiagnosticJournalStorageError("rotation", "Diagnostic journal rotation failed", { cause: error });
|
|
316
492
|
}
|
|
317
493
|
};
|
|
494
|
+
const refuse = createStartupRefusalHandler(config.onStartupRefusal, config.epoch);
|
|
318
495
|
try {
|
|
319
|
-
const names = await readdir(parent);
|
|
320
496
|
const prefix = `${basename(journalPath)}.`;
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
const index = generationIndex(name, prefix);
|
|
325
|
-
if (index === undefined)
|
|
326
|
-
continue;
|
|
327
|
-
const path = resolve2(parent, name);
|
|
328
|
-
const info = await lstat2(path);
|
|
329
|
-
if (info.isSymbolicLink() || !info.isFile()) {
|
|
330
|
-
throw new Error("Diagnostic journal generations must be regular files");
|
|
331
|
-
}
|
|
332
|
-
if (index >= config.maxFiles) {
|
|
333
|
-
expiredGenerations.push(path);
|
|
334
|
-
} else {
|
|
335
|
-
existingGenerations += 1;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
retainedFiles = Math.min(config.maxFiles, existingGenerations + 1);
|
|
497
|
+
const listing = await listDiagnosticJournalGenerations(parent, prefix, config.maxFiles, refuse);
|
|
498
|
+
const quarantined = [...listing.quarantined];
|
|
499
|
+
retainedFiles = Math.min(config.maxFiles, listing.existing + 1);
|
|
339
500
|
await openCurrent();
|
|
340
501
|
if (currentFileBytes > 0) {
|
|
341
502
|
const tail = new Uint8Array(1);
|
|
342
503
|
const read = await handle?.read(tail, 0, 1, currentFileBytes - 1);
|
|
343
504
|
if (read?.bytesRead === 1 && tail[0] !== 10) {
|
|
505
|
+
partialTails += 1;
|
|
344
506
|
if (config.maxFiles === 1) {
|
|
345
|
-
|
|
507
|
+
const recovery = config.onStartupRefusal === "fail" ? await inspectDiagnosticJournalRecovery({
|
|
508
|
+
paths: [journalPath],
|
|
509
|
+
maxLineBytes: config.maxFileBytes,
|
|
510
|
+
scan: config.scan
|
|
511
|
+
}) : undefined;
|
|
512
|
+
await handle?.close();
|
|
513
|
+
handle = undefined;
|
|
514
|
+
quarantined.push(await refuse({
|
|
515
|
+
file: journalPath,
|
|
516
|
+
reason: "torn-without-retention-slot",
|
|
517
|
+
...recovery && { recovery }
|
|
518
|
+
}));
|
|
519
|
+
await openCurrent();
|
|
520
|
+
} else {
|
|
521
|
+
await rotate();
|
|
346
522
|
}
|
|
347
|
-
partialTails += 1;
|
|
348
|
-
await rotate();
|
|
349
523
|
}
|
|
350
524
|
}
|
|
351
|
-
for (const path of
|
|
525
|
+
for (const path of listing.expired)
|
|
352
526
|
await removeIfPresent(path);
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
527
|
+
const retained = await retainedDiagnosticJournalGenerations(parent, prefix, config.maxFiles);
|
|
528
|
+
const inspected = await inspectDiagnosticJournalRecovery({
|
|
529
|
+
paths: [...retained, journalPath],
|
|
530
|
+
maxLineBytes: config.maxFileBytes,
|
|
531
|
+
scan: config.scan,
|
|
532
|
+
onUnreadable: async (file, error) => {
|
|
533
|
+
const active = file === journalPath;
|
|
534
|
+
if (active) {
|
|
535
|
+
await handle?.close();
|
|
536
|
+
handle = undefined;
|
|
537
|
+
}
|
|
538
|
+
quarantined.push(await refuse({
|
|
539
|
+
file,
|
|
540
|
+
reason: error instanceof TypeError ? "not-a-regular-file" : "unreadable",
|
|
541
|
+
cause: error
|
|
542
|
+
}));
|
|
543
|
+
if (active)
|
|
544
|
+
await openCurrent();
|
|
545
|
+
else
|
|
546
|
+
retainedFiles -= 1;
|
|
358
547
|
}
|
|
548
|
+
});
|
|
549
|
+
const listed = listQuarantinedFiles(quarantined, listing.quarantinedEarlier);
|
|
550
|
+
if (inspected.anomalies > 0 || listed.quarantined) {
|
|
551
|
+
recovery = { ...inspected, ...listed };
|
|
359
552
|
}
|
|
360
|
-
paths.sort((left, right) => right.index - left.index);
|
|
361
|
-
const inspected = await inspectDiagnosticJournalRecovery([...paths.map((file) => file.path), journalPath], config.maxFileBytes);
|
|
362
|
-
if (inspected.anomalies > 0)
|
|
363
|
-
recovery = inspected;
|
|
364
553
|
} catch (error) {
|
|
365
554
|
await handle?.close().catch(() => {
|
|
366
555
|
return;
|
|
@@ -403,33 +592,34 @@ async function createRotatingDiagnosticJournalStorage(config) {
|
|
|
403
592
|
if (closed)
|
|
404
593
|
return;
|
|
405
594
|
closed = true;
|
|
406
|
-
|
|
407
|
-
try {
|
|
408
|
-
await handle?.close();
|
|
409
|
-
} catch (error) {
|
|
410
|
-
failure = error;
|
|
411
|
-
}
|
|
412
|
-
try {
|
|
413
|
-
await lock.release();
|
|
414
|
-
} catch (error) {
|
|
415
|
-
failure ??= error;
|
|
416
|
-
}
|
|
417
|
-
if (failure !== undefined) {
|
|
418
|
-
throw new DiagnosticJournalStorageError("close", "Diagnostic journal close failed", {
|
|
419
|
-
cause: failure
|
|
420
|
-
});
|
|
421
|
-
}
|
|
595
|
+
await closeBoth(handle, lock);
|
|
422
596
|
}
|
|
423
597
|
};
|
|
424
598
|
}
|
|
599
|
+
async function closeBoth(handle, lock) {
|
|
600
|
+
let failure;
|
|
601
|
+
try {
|
|
602
|
+
await handle?.close();
|
|
603
|
+
} catch (error) {
|
|
604
|
+
failure = error;
|
|
605
|
+
}
|
|
606
|
+
try {
|
|
607
|
+
await lock.release();
|
|
608
|
+
} catch (error) {
|
|
609
|
+
failure ??= error;
|
|
610
|
+
}
|
|
611
|
+
if (failure !== undefined) {
|
|
612
|
+
throw new DiagnosticJournalStorageError("close", "Diagnostic journal close failed", {
|
|
613
|
+
cause: failure
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
}
|
|
425
617
|
|
|
426
618
|
// src/application/diagnostic-journal-manager.ts
|
|
427
619
|
function waitBudget(options) {
|
|
428
620
|
if (options.timeoutMs === undefined)
|
|
429
621
|
return;
|
|
430
|
-
|
|
431
|
-
throw new TypeError("Diagnostic journal timeoutMs must be a positive safe integer");
|
|
432
|
-
}
|
|
622
|
+
assertPositiveSafeInteger("Diagnostic journal timeoutMs", options.timeoutMs);
|
|
433
623
|
return options.timeoutMs;
|
|
434
624
|
}
|
|
435
625
|
var NO_REFUSALS = {
|
|
@@ -600,7 +790,7 @@ function createDiagnosticJournalManager(config, storage) {
|
|
|
600
790
|
const parsed = config.eventSchema.safeParse(event);
|
|
601
791
|
if (!parsed.success)
|
|
602
792
|
return refuse("invalid");
|
|
603
|
-
const json =
|
|
793
|
+
const json = z5.json().safeParse(parsed.data);
|
|
604
794
|
if (!json.success)
|
|
605
795
|
return refuse("invalid");
|
|
606
796
|
const payload = encoder.encode(JSON.stringify(json.data));
|
|
@@ -666,17 +856,21 @@ function createDiagnosticJournalManager(config, storage) {
|
|
|
666
856
|
async function createDiagnosticJournal(config) {
|
|
667
857
|
const limits = DiagnosticJournalLimitsSchema2.parse(config.limits);
|
|
668
858
|
const lock = DiagnosticJournalLockPolicySchema2.parse(config.lock ?? "refuse");
|
|
859
|
+
const epoch = randomUUID();
|
|
669
860
|
const storage = await createRotatingDiagnosticJournalStorage({
|
|
670
861
|
path: config.path,
|
|
671
862
|
maxFileBytes: limits.maxFileBytes,
|
|
672
863
|
maxFiles: limits.maxFiles,
|
|
673
864
|
mode: parseDiagnosticJournalMode(config.mode),
|
|
674
865
|
lock,
|
|
866
|
+
scan: DiagnosticJournalStartupScanSchema2.parse(config.startupScan ?? "tails"),
|
|
867
|
+
onStartupRefusal: DiagnosticJournalStartupRefusalPolicySchema2.parse(config.onStartupRefusal ?? "quarantine"),
|
|
868
|
+
epoch,
|
|
675
869
|
...config.machineIdentity !== undefined && { machineIdentity: config.machineIdentity }
|
|
676
870
|
});
|
|
677
871
|
return createDiagnosticJournalManager({
|
|
678
872
|
eventSchema: config.eventSchema,
|
|
679
|
-
epoch
|
|
873
|
+
epoch,
|
|
680
874
|
limits,
|
|
681
875
|
lock: { policy: lock, reclaimedStale: storage.reclaimedStale },
|
|
682
876
|
...config.onFailure && { onFailure: config.onFailure }
|