stitchkit 0.104.2 → 0.105.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 +401 -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 +161 -66
- 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-269zqj8m.js → index-1ptj98e0.js} +28 -12
- 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-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-f330qqyg.js → index-5c26631f.js} +244 -67
- 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-cazts87s.js +105 -0
- package/dist/{index-g2j7pnak.js → index-cmzvhhtd.js} +5 -2
- package/dist/{index-ssmd41kh.js → index-d2h99n7d.js} +1 -1
- package/dist/{index-z94wht4y.js → index-dky0dcmf.js} +34 -5
- package/dist/index-drs41arz.js +455 -0
- package/dist/{index-za6j7nwy.js → index-dsnjzb62.js} +104 -51
- package/dist/index-eemvahkc.js +21 -0
- package/dist/{index-fa4wg312.js → index-f199nfq5.js} +10 -6
- package/dist/{index-ck71tbcf.js → index-fsw1ybf3.js} +11 -15
- package/dist/{index-fk18k56k.js → index-gr5g3xfw.js} +11 -18
- package/dist/{index-jn9g8xdt.js → index-hjvje0pf.js} +6 -4
- package/dist/index-j4zh647a.js +59 -0
- 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-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-hbd32c6a.js → index-w8etpm8j.js} +38 -89
- package/dist/{index-2hyavjjj.js → index-wbhdzxar.js} +3 -3
- package/dist/{index-4e0ah203.js → index-wdy68sh6.js} +47 -24
- package/dist/{index-hp9d77wk.js → index-x7w1z6pf.js} +15 -4
- package/dist/{index-ptn0g0gj.js → index-y7k2cdgv.js} +21 -20
- 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 +47 -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 +7 -2
- package/dist/process/cleanup.d.ts.map +1 -1
- package/dist/process/command-lifetime.d.ts +6 -1
- package/dist/process/command-lifetime.d.ts.map +1 -1
- package/dist/process/command-owner.d.ts +1 -0
- 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 +68 -2
- package/dist/process/contract.d.ts.map +1 -1
- package/dist/process/group.d.ts +42 -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 +40 -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 +18 -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 +324 -160
- 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 +1068 -412
- 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
|
@@ -43,20 +43,47 @@ function createDiagnosticJournalReadResultSchema2(eventSchema) {
|
|
|
43
43
|
z2.object({ type: z2.literal("anomaly"), anomaly: DiagnosticJournalAnomalySchema2 }).strict().readonly()
|
|
44
44
|
]);
|
|
45
45
|
}
|
|
46
|
+
var DiagnosticJournalStartupRefusalReasonSchema2 = z2.enum([
|
|
47
|
+
"torn-without-retention-slot",
|
|
48
|
+
"not-a-regular-file",
|
|
49
|
+
"unreadable"
|
|
50
|
+
]);
|
|
51
|
+
var DIAGNOSTIC_JOURNAL_LISTED_QUARANTINE_LIMIT = 32;
|
|
52
|
+
var QuarantinedFileSchema = z2.object({
|
|
53
|
+
file: z2.string(),
|
|
54
|
+
quarantinedAs: z2.string(),
|
|
55
|
+
reason: DiagnosticJournalStartupRefusalReasonSchema2.optional(),
|
|
56
|
+
code: z2.string().optional()
|
|
57
|
+
}).strict().readonly();
|
|
46
58
|
var DiagnosticJournalRecoveryStatusSchema2 = z2.object({
|
|
47
59
|
filesChecked: ByteCountSchema,
|
|
48
60
|
anomalies: ByteCountSchema,
|
|
49
61
|
skippedBytes: ByteCountSchema,
|
|
50
62
|
firstAnomaly: DiagnosticJournalAnomalySchema2.optional(),
|
|
51
|
-
lastAnomaly: DiagnosticJournalAnomalySchema2.optional()
|
|
63
|
+
lastAnomaly: DiagnosticJournalAnomalySchema2.optional(),
|
|
64
|
+
quarantined: z2.array(QuarantinedFileSchema).max(DIAGNOSTIC_JOURNAL_LISTED_QUARANTINE_LIMIT).readonly().optional(),
|
|
65
|
+
quarantinedUnlisted: z2.number().int().positive().optional()
|
|
52
66
|
}).strict().readonly();
|
|
67
|
+
var REFUSAL_MESSAGES = {
|
|
68
|
+
"torn-without-retention-slot": "Diagnostic journal tail recovery requires maxFiles >= 2; no data was removed",
|
|
69
|
+
"not-a-regular-file": "Diagnostic journal generations must be regular files",
|
|
70
|
+
unreadable: "Diagnostic journal could not read a retained file"
|
|
71
|
+
};
|
|
53
72
|
|
|
54
73
|
class DiagnosticJournalRecoveryError2 extends Error {
|
|
74
|
+
reason;
|
|
75
|
+
file;
|
|
55
76
|
recovery;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
77
|
+
quarantineFailed;
|
|
78
|
+
constructor(options) {
|
|
79
|
+
const quarantineFailed = options.quarantineFailed ?? false;
|
|
80
|
+
super(`${REFUSAL_MESSAGES[options.reason]}: ${options.file}${quarantineFailed ? " (moving it aside failed)" : ""}`, options.cause === undefined ? undefined : { cause: options.cause });
|
|
59
81
|
this.name = "DiagnosticJournalRecoveryError";
|
|
82
|
+
this.reason = options.reason;
|
|
83
|
+
this.file = options.file;
|
|
84
|
+
if (options.recovery)
|
|
85
|
+
this.recovery = options.recovery;
|
|
86
|
+
this.quarantineFailed = quarantineFailed;
|
|
60
87
|
}
|
|
61
88
|
}
|
|
62
89
|
|
|
@@ -72,6 +99,8 @@ var DiagnosticJournalLimitsSchema2 = z3.object({
|
|
|
72
99
|
maxFiles: PositiveSafeIntegerSchema
|
|
73
100
|
}).strict().readonly();
|
|
74
101
|
var DiagnosticJournalLockPolicySchema2 = z3.enum(["refuse", "reclaim-stale"]);
|
|
102
|
+
var DiagnosticJournalStartupScanSchema2 = z3.enum(["tails", "full"]);
|
|
103
|
+
var DiagnosticJournalStartupRefusalPolicySchema2 = z3.enum(["quarantine", "fail"]);
|
|
75
104
|
var DiagnosticJournalStateSchema2 = z3.enum(["open", "draining", "closed", "failed"]);
|
|
76
105
|
var DiagnosticJournalRefusalReasonSchema2 = z3.enum([
|
|
77
106
|
"closed",
|
|
@@ -153,4 +182,4 @@ function readDiagnosticJournalLockDiagnosis2(error) {
|
|
|
153
182
|
return isRecord(diagnosis) ? diagnosis : undefined;
|
|
154
183
|
}
|
|
155
184
|
|
|
156
|
-
export { DiagnosticJournalFrameSchema2, DiagnosticJournalAnomalySchema2, createDiagnosticJournalReadResultSchema2, DiagnosticJournalRecoveryStatusSchema2, DiagnosticJournalRecoveryError2, DiagnosticJournalLimitsSchema2, DiagnosticJournalLockPolicySchema2, DiagnosticJournalStateSchema2, DiagnosticJournalRefusalReasonSchema2, DiagnosticJournalFailurePhaseSchema2, DiagnosticJournalStatusSchema2, DiagnosticJournalSubmitResultSchema2, DiagnosticJournalWaitResultSchema2, DiagnosticJournalCloseResultSchema2, parseDiagnosticJournalMode, readDiagnosticJournalLockDiagnosis2 };
|
|
185
|
+
export { DiagnosticJournalFrameSchema2, DiagnosticJournalAnomalySchema2, createDiagnosticJournalReadResultSchema2, DiagnosticJournalStartupRefusalReasonSchema2, DIAGNOSTIC_JOURNAL_LISTED_QUARANTINE_LIMIT, DiagnosticJournalRecoveryStatusSchema2, DiagnosticJournalRecoveryError2, DiagnosticJournalLimitsSchema2, DiagnosticJournalLockPolicySchema2, DiagnosticJournalStartupScanSchema2, DiagnosticJournalStartupRefusalPolicySchema2, DiagnosticJournalStateSchema2, DiagnosticJournalRefusalReasonSchema2, DiagnosticJournalFailurePhaseSchema2, DiagnosticJournalStatusSchema2, DiagnosticJournalSubmitResultSchema2, DiagnosticJournalWaitResultSchema2, DiagnosticJournalCloseResultSchema2, parseDiagnosticJournalMode, readDiagnosticJournalLockDiagnosis2 };
|
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
import {
|
|
2
|
+
withSignalDeadline
|
|
3
|
+
} from "./index-9tqbxv5p.js";
|
|
4
|
+
import {
|
|
5
|
+
fetchGuarded,
|
|
6
|
+
PrivateAddressRefusal,
|
|
7
|
+
readCapped
|
|
8
|
+
} from "./index-3h0ztg0z.js";
|
|
9
|
+
import {
|
|
10
|
+
raceAbort
|
|
11
|
+
} from "./index-b0kddvzw.js";
|
|
12
|
+
import {
|
|
13
|
+
writeFileAtomicSync2
|
|
14
|
+
} from "./index-cazts87s.js";
|
|
15
|
+
import {
|
|
16
|
+
assertPositiveSafeInteger
|
|
17
|
+
} from "./index-0s4xebbg.js";
|
|
18
|
+
import {
|
|
19
|
+
serializeCanonicalJson
|
|
20
|
+
} from "./index-zsvzhjtk.js";
|
|
21
|
+
|
|
22
|
+
// src/tools/cli/signature.ts
|
|
23
|
+
import {
|
|
24
|
+
createPrivateKey,
|
|
25
|
+
createPublicKey,
|
|
26
|
+
sign as cryptoSign,
|
|
27
|
+
verify as cryptoVerify
|
|
28
|
+
} from "node:crypto";
|
|
29
|
+
import { z } from "zod";
|
|
30
|
+
var CliBuildSignatureSchema2 = z.object({
|
|
31
|
+
algorithm: z.literal("ed25519"),
|
|
32
|
+
keyId: z.string().min(1),
|
|
33
|
+
signature: z.string().min(1)
|
|
34
|
+
});
|
|
35
|
+
function cliManifestSigningPayload2(manifest) {
|
|
36
|
+
return serializeCanonicalJson({
|
|
37
|
+
name: manifest.name,
|
|
38
|
+
version: manifest.version,
|
|
39
|
+
commit: manifest.commit,
|
|
40
|
+
builtAt: manifest.builtAt,
|
|
41
|
+
assets: manifest.assets.map((asset) => ({
|
|
42
|
+
platform: asset.platform,
|
|
43
|
+
arch: asset.arch,
|
|
44
|
+
compression: asset.compression,
|
|
45
|
+
size: asset.size,
|
|
46
|
+
sha256: asset.sha256
|
|
47
|
+
}))
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function publicKeyOf(material) {
|
|
51
|
+
const trimmed = material.trim();
|
|
52
|
+
if (trimmed.includes("BEGIN PUBLIC KEY"))
|
|
53
|
+
return createPublicKey(trimmed);
|
|
54
|
+
const raw = Buffer.from(trimmed, "base64");
|
|
55
|
+
if (raw.length !== 32) {
|
|
56
|
+
throw new Error("[stitchkit] an Ed25519 public key is 32 bytes or SPKI PEM");
|
|
57
|
+
}
|
|
58
|
+
const spki = Buffer.concat([Buffer.from("302a300506032b6570032100", "hex"), raw]);
|
|
59
|
+
return createPublicKey({ key: spki, format: "der", type: "spki" });
|
|
60
|
+
}
|
|
61
|
+
function signCliManifest2(manifest, options) {
|
|
62
|
+
const signature = cryptoSign(null, Buffer.from(cliManifestSigningPayload2(manifest), "utf8"), createPrivateKey(typeof options.privateKey === "string" ? options.privateKey : { key: Buffer.from(options.privateKey), format: "der", type: "pkcs8" }));
|
|
63
|
+
return {
|
|
64
|
+
algorithm: "ed25519",
|
|
65
|
+
keyId: options.keyId,
|
|
66
|
+
signature: signature.toString("base64")
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function verifyCliManifest2(manifest, signature, trust) {
|
|
70
|
+
const keys = trust?.keys;
|
|
71
|
+
if (!keys || Object.keys(keys).length === 0)
|
|
72
|
+
return "unenforced";
|
|
73
|
+
if (!signature)
|
|
74
|
+
return "missing";
|
|
75
|
+
const material = Object.hasOwn(keys, signature.keyId) ? keys[signature.keyId] : undefined;
|
|
76
|
+
if (material === undefined)
|
|
77
|
+
return "unknown-key";
|
|
78
|
+
try {
|
|
79
|
+
const ok = cryptoVerify(null, Buffer.from(cliManifestSigningPayload2(manifest), "utf8"), publicKeyOf(material), Buffer.from(signature.signature, "base64"));
|
|
80
|
+
return ok ? "valid" : "invalid";
|
|
81
|
+
} catch {
|
|
82
|
+
return "invalid";
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function cliSignatureAccepted2(verdict) {
|
|
86
|
+
return verdict === "valid" || verdict === "unenforced";
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// src/tools/cli/manifest.ts
|
|
90
|
+
import { z as z2 } from "zod";
|
|
91
|
+
var CliBuildTargetSchema2 = z2.object({
|
|
92
|
+
platform: z2.string().min(1),
|
|
93
|
+
arch: z2.string().min(1)
|
|
94
|
+
});
|
|
95
|
+
var CliBuildAssetSchema2 = CliBuildTargetSchema2.extend({
|
|
96
|
+
url: z2.url(),
|
|
97
|
+
compression: z2.enum(["gzip", "none"]).default("none"),
|
|
98
|
+
size: z2.int().positive(),
|
|
99
|
+
sha256: z2.string().regex(/^[0-9a-f]{64}$/, "sha256 must be 64 lowercase hex characters")
|
|
100
|
+
});
|
|
101
|
+
var CliBuildManifestSchema2 = z2.object({
|
|
102
|
+
name: z2.string().min(1),
|
|
103
|
+
version: z2.string().min(1),
|
|
104
|
+
commit: z2.string().min(1),
|
|
105
|
+
builtAt: z2.iso.datetime(),
|
|
106
|
+
assets: z2.array(CliBuildAssetSchema2),
|
|
107
|
+
signature: CliBuildSignatureSchema2.optional()
|
|
108
|
+
});
|
|
109
|
+
var CliBuildStampSchema2 = z2.object({
|
|
110
|
+
version: z2.string().min(1),
|
|
111
|
+
commit: z2.string().min(1),
|
|
112
|
+
builtAt: z2.iso.datetime()
|
|
113
|
+
});
|
|
114
|
+
function formatCliBuildStamp2(stamp, name) {
|
|
115
|
+
const prefix = name ? `${name} ` : "";
|
|
116
|
+
return `${prefix}${stamp.version} (${stamp.commit.slice(0, 12)}, built ${stamp.builtAt})`;
|
|
117
|
+
}
|
|
118
|
+
function currentCliBuildTarget2() {
|
|
119
|
+
return { platform: process.platform, arch: process.arch };
|
|
120
|
+
}
|
|
121
|
+
function selectCliBuildAsset2(manifest, target = currentCliBuildTarget2()) {
|
|
122
|
+
return manifest.assets.find((asset) => asset.platform === target.platform && asset.arch === target.arch);
|
|
123
|
+
}
|
|
124
|
+
function isManifestList(value) {
|
|
125
|
+
return Array.isArray(value);
|
|
126
|
+
}
|
|
127
|
+
function assertCliPublishable2(previous, next) {
|
|
128
|
+
const published = previous === undefined ? [] : isManifestList(previous) ? previous : [previous];
|
|
129
|
+
for (const candidate of published) {
|
|
130
|
+
if (candidate.version !== next.version)
|
|
131
|
+
continue;
|
|
132
|
+
if (candidate.commit === next.commit)
|
|
133
|
+
continue;
|
|
134
|
+
throw new Error(`[stitchkit] ${next.name} ${next.version} was already published from commit ${candidate.commit}; ` + `refusing to republish it from ${next.commit} — bump the version instead`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// src/tools/cli/update.ts
|
|
139
|
+
import { createHash as createHash2, randomBytes } from "node:crypto";
|
|
140
|
+
import { existsSync, readFileSync, statSync, unlinkSync } from "node:fs";
|
|
141
|
+
import { basename, dirname, extname, join } from "node:path";
|
|
142
|
+
|
|
143
|
+
// src/tools/cli/publication-assets.ts
|
|
144
|
+
import { createHash } from "node:crypto";
|
|
145
|
+
import { Readable } from "node:stream";
|
|
146
|
+
import { setImmediate as nextTurn } from "node:timers/promises";
|
|
147
|
+
import { createGunzip, createGzip } from "node:zlib";
|
|
148
|
+
|
|
149
|
+
// src/tools/cli/publication-control.ts
|
|
150
|
+
function waitForPublication(operation, signal) {
|
|
151
|
+
return raceAbort(operation, signal, (value) => {
|
|
152
|
+
if (value instanceof ReadableStream && !value.locked)
|
|
153
|
+
value.cancel(signal.reason).catch(() => {
|
|
154
|
+
return;
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function withPublicationDeadline(timeoutMs, caller, body) {
|
|
159
|
+
return withSignalDeadline(timeoutMs, caller, () => new Error(`CLI publication exceeded ${timeoutMs} ms`), body);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// src/tools/cli/publication-assets.ts
|
|
163
|
+
async function collectCliBytes(source, maxBytes, signal) {
|
|
164
|
+
assertPositiveSafeInteger("CLI asset byte cap", maxBytes, RangeError);
|
|
165
|
+
const blocks = [];
|
|
166
|
+
let total = 0;
|
|
167
|
+
let filled = 0;
|
|
168
|
+
let block;
|
|
169
|
+
const consume = (chunk) => {
|
|
170
|
+
signal?.throwIfAborted();
|
|
171
|
+
if (!(chunk instanceof Uint8Array))
|
|
172
|
+
throw new TypeError("CLI asset stream must contain Uint8Array chunks");
|
|
173
|
+
if (total + chunk.byteLength > maxBytes)
|
|
174
|
+
throw new RangeError(`CLI asset exceeds ${maxBytes} bytes`);
|
|
175
|
+
for (let offset = 0;offset < chunk.byteLength; ) {
|
|
176
|
+
if (!block || filled === block.length) {
|
|
177
|
+
block = new Uint8Array(Math.min(64 * 1024, maxBytes - total));
|
|
178
|
+
blocks.push(block);
|
|
179
|
+
filled = 0;
|
|
180
|
+
}
|
|
181
|
+
const count = Math.min(chunk.byteLength - offset, block.length - filled);
|
|
182
|
+
block.set(chunk.subarray(offset, offset + count), filled);
|
|
183
|
+
filled += count;
|
|
184
|
+
total += count;
|
|
185
|
+
offset += count;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
if (source instanceof Uint8Array)
|
|
189
|
+
consume(source);
|
|
190
|
+
else {
|
|
191
|
+
const reader = source.getReader();
|
|
192
|
+
let chunks = 0;
|
|
193
|
+
try {
|
|
194
|
+
for (;; ) {
|
|
195
|
+
const next = signal ? await waitForPublication(reader.read(), signal) : await reader.read();
|
|
196
|
+
if (next.done)
|
|
197
|
+
break;
|
|
198
|
+
consume(next.value);
|
|
199
|
+
if (++chunks % 128 === 0) {
|
|
200
|
+
if (signal)
|
|
201
|
+
await waitForPublication(nextTurn(), signal);
|
|
202
|
+
else
|
|
203
|
+
await nextTurn();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
} catch (error) {
|
|
207
|
+
reader.cancel(error).catch(() => {
|
|
208
|
+
return;
|
|
209
|
+
});
|
|
210
|
+
throw error;
|
|
211
|
+
} finally {
|
|
212
|
+
reader.releaseLock();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
signal?.throwIfAborted();
|
|
216
|
+
const bytes = new Uint8Array(total);
|
|
217
|
+
let offset = 0;
|
|
218
|
+
for (const chunk of blocks) {
|
|
219
|
+
const count = Math.min(chunk.length, total - offset);
|
|
220
|
+
bytes.set(chunk.subarray(0, count), offset);
|
|
221
|
+
offset += count;
|
|
222
|
+
}
|
|
223
|
+
return bytes;
|
|
224
|
+
}
|
|
225
|
+
async function transformAsset(bytes, kind, maxBytes, signal) {
|
|
226
|
+
const codec = kind === "gzip" ? createGzip() : createGunzip();
|
|
227
|
+
const output = Readable.toWeb(codec);
|
|
228
|
+
codec.end(bytes);
|
|
229
|
+
try {
|
|
230
|
+
return await collectCliBytes(output, maxBytes, signal);
|
|
231
|
+
} finally {
|
|
232
|
+
codec.destroy();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function gzipCliAsset(bytes, maxBytes, signal) {
|
|
236
|
+
return transformAsset(bytes, "gzip", maxBytes, signal);
|
|
237
|
+
}
|
|
238
|
+
async function decodeCliAsset(transferred, asset, maxBytes, signal) {
|
|
239
|
+
assertPositiveSafeInteger("CLI asset byte cap", maxBytes, RangeError);
|
|
240
|
+
assertPositiveSafeInteger("CLI asset size", asset.size, RangeError);
|
|
241
|
+
if (asset.size > maxBytes)
|
|
242
|
+
throw new RangeError(`CLI asset declared size exceeds ${maxBytes} bytes`);
|
|
243
|
+
const bytes = asset.compression === "gzip" ? await transformAsset(transferred, "gunzip", asset.size, signal) : transferred;
|
|
244
|
+
if (bytes.length !== asset.size)
|
|
245
|
+
throw new Error(`CLI asset is ${bytes.length} bytes, manifest says ${asset.size}`);
|
|
246
|
+
const sha256 = createHash("sha256").update(bytes).digest("hex");
|
|
247
|
+
if (sha256 !== asset.sha256)
|
|
248
|
+
throw new Error("CLI asset digest does not match the manifest (checksum mismatch) — refusing to install it");
|
|
249
|
+
return { bytes, sha256 };
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// src/tools/cli/update.ts
|
|
253
|
+
var DEFAULT_CHECK_TIMEOUT_MS = 2000;
|
|
254
|
+
var DEFAULT_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
255
|
+
var DEFAULT_DOWNLOAD_TIMEOUT_MS = 120000;
|
|
256
|
+
var DEFAULT_VERIFY_TIMEOUT_MS = 30000;
|
|
257
|
+
var MANIFEST_MAX_BYTES = 256 * 1024;
|
|
258
|
+
var DEFAULT_MAX_ASSET_BYTES = 256 * 1024 * 1024;
|
|
259
|
+
function parseVersion(value) {
|
|
260
|
+
const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?/.exec(value.trim());
|
|
261
|
+
if (!match)
|
|
262
|
+
return;
|
|
263
|
+
const numbers = [match[1], match[2], match[3]].map((part) => Number(part));
|
|
264
|
+
if (numbers.some((part) => !Number.isFinite(part)))
|
|
265
|
+
return;
|
|
266
|
+
return { numbers, prerelease: match[4] };
|
|
267
|
+
}
|
|
268
|
+
function compareCliVersions2(left, right) {
|
|
269
|
+
const a = parseVersion(left);
|
|
270
|
+
const b = parseVersion(right);
|
|
271
|
+
if (!a || !b)
|
|
272
|
+
return;
|
|
273
|
+
for (let index = 0;index < 3; index++) {
|
|
274
|
+
const difference = (a.numbers[index] ?? 0) - (b.numbers[index] ?? 0);
|
|
275
|
+
if (difference !== 0)
|
|
276
|
+
return difference < 0 ? -1 : 1;
|
|
277
|
+
}
|
|
278
|
+
if (a.prerelease === b.prerelease)
|
|
279
|
+
return 0;
|
|
280
|
+
if (a.prerelease === undefined)
|
|
281
|
+
return 1;
|
|
282
|
+
if (b.prerelease === undefined)
|
|
283
|
+
return -1;
|
|
284
|
+
const leftParts = a.prerelease.split(".");
|
|
285
|
+
const rightParts = b.prerelease.split(".");
|
|
286
|
+
for (let index = 0;index < Math.max(leftParts.length, rightParts.length); index++) {
|
|
287
|
+
const leftPart = leftParts[index];
|
|
288
|
+
const rightPart = rightParts[index];
|
|
289
|
+
if (leftPart === rightPart)
|
|
290
|
+
continue;
|
|
291
|
+
if (leftPart === undefined)
|
|
292
|
+
return -1;
|
|
293
|
+
if (rightPart === undefined)
|
|
294
|
+
return 1;
|
|
295
|
+
const leftNumeric = /^\d+$/.test(leftPart);
|
|
296
|
+
const rightNumeric = /^\d+$/.test(rightPart);
|
|
297
|
+
if (leftNumeric !== rightNumeric)
|
|
298
|
+
return leftNumeric ? -1 : 1;
|
|
299
|
+
if (leftNumeric) {
|
|
300
|
+
const leftDigits = leftPart.replace(/^0+(?=\d)/, "");
|
|
301
|
+
const rightDigits = rightPart.replace(/^0+(?=\d)/, "");
|
|
302
|
+
if (leftDigits.length !== rightDigits.length)
|
|
303
|
+
return leftDigits.length < rightDigits.length ? -1 : 1;
|
|
304
|
+
if (leftDigits === rightDigits)
|
|
305
|
+
continue;
|
|
306
|
+
return leftDigits < rightDigits ? -1 : 1;
|
|
307
|
+
}
|
|
308
|
+
return leftPart < rightPart ? -1 : 1;
|
|
309
|
+
}
|
|
310
|
+
return 0;
|
|
311
|
+
}
|
|
312
|
+
async function checkCliUpdate2(config) {
|
|
313
|
+
const now = config.now ?? Date.now();
|
|
314
|
+
const interval = config.intervalMs ?? DEFAULT_CHECK_INTERVAL_MS;
|
|
315
|
+
if (config.lastCheckedAt !== undefined && now - config.lastCheckedAt < interval) {
|
|
316
|
+
return { status: "skipped", nextCheckAt: config.lastCheckedAt + interval };
|
|
317
|
+
}
|
|
318
|
+
try {
|
|
319
|
+
const response = await fetchGuarded(new URL(config.manifestUrl), config.allowPrivateHosts ?? false, {
|
|
320
|
+
timeoutMs: config.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS,
|
|
321
|
+
bodyTimeoutMs: config.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS
|
|
322
|
+
});
|
|
323
|
+
if (!response.ok)
|
|
324
|
+
return { status: "unknown", reason: `manifest responded ${response.status}` };
|
|
325
|
+
const body = await readCapped(response, MANIFEST_MAX_BYTES);
|
|
326
|
+
if (!body)
|
|
327
|
+
return { status: "unknown", reason: "manifest is larger than expected" };
|
|
328
|
+
const parsed = CliBuildManifestSchema2.safeParse(JSON.parse(body.toString("utf8")));
|
|
329
|
+
if (!parsed.success)
|
|
330
|
+
return { status: "unknown", reason: "manifest did not validate" };
|
|
331
|
+
const manifest = parsed.data;
|
|
332
|
+
const order = compareCliVersions2(config.currentVersion, manifest.version);
|
|
333
|
+
if (order === undefined) {
|
|
334
|
+
return {
|
|
335
|
+
status: "unknown",
|
|
336
|
+
reason: `cannot compare ${config.currentVersion} with ${manifest.version}`
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
const verdict = verifyCliManifest2(manifest, manifest.signature, config.trust);
|
|
340
|
+
if (order >= 0)
|
|
341
|
+
return { status: "current", version: manifest.version, signature: verdict };
|
|
342
|
+
if (!cliSignatureAccepted2(verdict)) {
|
|
343
|
+
return { status: "unknown", reason: `manifest signature: ${verdict}` };
|
|
344
|
+
}
|
|
345
|
+
const asset = selectCliBuildAsset2(manifest, config.target ?? currentCliBuildTarget2());
|
|
346
|
+
return {
|
|
347
|
+
status: "outdated",
|
|
348
|
+
version: manifest.version,
|
|
349
|
+
manifest,
|
|
350
|
+
...asset && { asset },
|
|
351
|
+
signature: verdict
|
|
352
|
+
};
|
|
353
|
+
} catch (error) {
|
|
354
|
+
if (error instanceof PrivateAddressRefusal) {
|
|
355
|
+
return {
|
|
356
|
+
status: "unknown",
|
|
357
|
+
reason: `${error.message} — the manifest endpoint is not public. Set ` + "`allowPrivateHosts` if it is your own deployment; the download keeps " + "its own setting, because an asset URL comes from the document."
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
return {
|
|
361
|
+
status: "unknown",
|
|
362
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
async function applyCliUpdate2(config) {
|
|
367
|
+
const target = config.targetPath ?? process.execPath;
|
|
368
|
+
if (config.trust) {
|
|
369
|
+
if (!config.manifest) {
|
|
370
|
+
throw new Error("[stitchkit] update: a trust root needs the manifest the asset came from");
|
|
371
|
+
}
|
|
372
|
+
const verdict = verifyCliManifest2(config.manifest, config.manifest.signature, config.trust);
|
|
373
|
+
if (!cliSignatureAccepted2(verdict)) {
|
|
374
|
+
throw new Error(`[stitchkit] update: refusing to install — manifest signature ${verdict}`);
|
|
375
|
+
}
|
|
376
|
+
if (!config.manifest.assets.some((asset) => asset.sha256 === config.asset.sha256)) {
|
|
377
|
+
throw new Error("[stitchkit] update: the asset is not one the signed manifest names");
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
const response = await fetchGuarded(new URL(config.asset.url), config.allowPrivateHosts ?? false, {
|
|
381
|
+
timeoutMs: config.timeoutMs ?? DEFAULT_DOWNLOAD_TIMEOUT_MS,
|
|
382
|
+
bodyTimeoutMs: config.timeoutMs ?? DEFAULT_DOWNLOAD_TIMEOUT_MS
|
|
383
|
+
});
|
|
384
|
+
if (!response.ok) {
|
|
385
|
+
throw new Error(`[stitchkit] update download responded ${response.status}`);
|
|
386
|
+
}
|
|
387
|
+
const transferred = await readCapped(response, config.maxBytes ?? DEFAULT_MAX_ASSET_BYTES);
|
|
388
|
+
if (!transferred)
|
|
389
|
+
throw new Error("[stitchkit] update download exceeded the size ceiling");
|
|
390
|
+
const { bytes, sha256 } = await decodeCliAsset(transferred, config.asset, config.maxBytes ?? DEFAULT_MAX_ASSET_BYTES);
|
|
391
|
+
if (config.verify)
|
|
392
|
+
await verifyCandidate(target, bytes, config.verify, config.verifyTimeoutMs);
|
|
393
|
+
const backup = config.backupPath ? keepReplacedBinary(target, config.backupPath) : undefined;
|
|
394
|
+
writeFileAtomicSync2(target, bytes, { mode: 493 });
|
|
395
|
+
return {
|
|
396
|
+
path: target,
|
|
397
|
+
bytes: bytes.length,
|
|
398
|
+
sha256,
|
|
399
|
+
...backup && { backupPath: backup.path, backupSha256: backup.sha256 }
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
async function verifyCandidate(target, bytes, verify, timeoutMs = DEFAULT_VERIFY_TIMEOUT_MS) {
|
|
403
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
404
|
+
throw new RangeError("[stitchkit] update: verifyTimeoutMs must be a positive number");
|
|
405
|
+
}
|
|
406
|
+
const candidate = join(dirname(target), `.${basename(target)}.candidate-${randomBytes(8).toString("hex")}${extname(target)}`);
|
|
407
|
+
writeFileAtomicSync2(candidate, bytes, { mode: 493 });
|
|
408
|
+
const controller = new AbortController;
|
|
409
|
+
let timer;
|
|
410
|
+
const deadline = new Promise((_, reject) => {
|
|
411
|
+
timer = setTimeout(() => {
|
|
412
|
+
const error = new Error(`verification did not finish within ${timeoutMs} ms`);
|
|
413
|
+
controller.abort(error);
|
|
414
|
+
reject(error);
|
|
415
|
+
}, timeoutMs);
|
|
416
|
+
});
|
|
417
|
+
try {
|
|
418
|
+
await Promise.race([
|
|
419
|
+
Promise.resolve().then(() => verify(candidate, controller.signal)),
|
|
420
|
+
deadline
|
|
421
|
+
]);
|
|
422
|
+
} catch (error) {
|
|
423
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
424
|
+
throw new Error(`[stitchkit] update: the new build failed verification — ${reason}`, {
|
|
425
|
+
cause: error
|
|
426
|
+
});
|
|
427
|
+
} finally {
|
|
428
|
+
clearTimeout(timer);
|
|
429
|
+
try {
|
|
430
|
+
unlinkSync(candidate);
|
|
431
|
+
} catch {}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
function keepReplacedBinary(target, backupPath) {
|
|
435
|
+
if (!existsSync(target))
|
|
436
|
+
return;
|
|
437
|
+
const previous = readFileSync(target);
|
|
438
|
+
writeFileAtomicSync2(backupPath, previous, { mode: statSync(target).mode & 511 });
|
|
439
|
+
return { path: backupPath, sha256: createHash2("sha256").update(previous).digest("hex") };
|
|
440
|
+
}
|
|
441
|
+
function rollbackCliUpdate2(config) {
|
|
442
|
+
const target = config.targetPath ?? process.execPath;
|
|
443
|
+
if (!existsSync(config.backupPath)) {
|
|
444
|
+
throw new Error(`[stitchkit] rollback: no backup at ${config.backupPath}`);
|
|
445
|
+
}
|
|
446
|
+
const bytes = readFileSync(config.backupPath);
|
|
447
|
+
const sha256 = createHash2("sha256").update(bytes).digest("hex");
|
|
448
|
+
if (sha256 !== config.expectedSha256) {
|
|
449
|
+
throw new Error(`[stitchkit] rollback: backup digest ${sha256} does not match the expected ${config.expectedSha256} — refusing to restore it`);
|
|
450
|
+
}
|
|
451
|
+
writeFileAtomicSync2(target, bytes, { mode: statSync(config.backupPath).mode & 511 });
|
|
452
|
+
return { path: target, bytes: bytes.length, sha256 };
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
export { CliBuildSignatureSchema2, cliManifestSigningPayload2, signCliManifest2, verifyCliManifest2, cliSignatureAccepted2, CliBuildTargetSchema2, CliBuildAssetSchema2, CliBuildManifestSchema2, CliBuildStampSchema2, formatCliBuildStamp2, currentCliBuildTarget2, selectCliBuildAsset2, assertCliPublishable2, waitForPublication, withPublicationDeadline, collectCliBytes, gzipCliAsset, decodeCliAsset, compareCliVersions2, checkCliUpdate2, applyCliUpdate2, rollbackCliUpdate2 };
|