toolcraft 0.0.749 → 0.0.751
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/composition.json +23 -3
- package/dist/composition.json +23 -3
- package/dist/human-in-loop/approvals-commands.d.ts +1 -1
- package/dist/index.d.ts +1 -262
- package/dist/index.js +1 -573
- package/dist/runtime-platform.d.ts +2 -0
- package/dist/runtime-platform.js +2 -0
- package/dist/runtime-platform.workerd.d.ts +3 -0
- package/dist/runtime-platform.workerd.js +10 -0
- package/dist/runtime.d.ts +262 -0
- package/dist/runtime.js +576 -0
- package/node_modules/@noble/hashes/LICENSE +21 -0
- package/node_modules/@noble/hashes/README.md +478 -0
- package/node_modules/@noble/hashes/_blake.d.ts +20 -0
- package/node_modules/@noble/hashes/_blake.js +59 -0
- package/node_modules/@noble/hashes/_md.d.ts +95 -0
- package/node_modules/@noble/hashes/_md.js +209 -0
- package/node_modules/@noble/hashes/_u64.d.ts +36 -0
- package/node_modules/@noble/hashes/_u64.js +77 -0
- package/node_modules/@noble/hashes/argon2.d.ts +148 -0
- package/node_modules/@noble/hashes/argon2.js +577 -0
- package/node_modules/@noble/hashes/blake1.d.ts +162 -0
- package/node_modules/@noble/hashes/blake1.js +630 -0
- package/node_modules/@noble/hashes/blake2.d.ts +203 -0
- package/node_modules/@noble/hashes/blake2.js +573 -0
- package/node_modules/@noble/hashes/blake3.d.ts +68 -0
- package/node_modules/@noble/hashes/blake3.js +310 -0
- package/node_modules/@noble/hashes/eskdf.d.ts +91 -0
- package/node_modules/@noble/hashes/eskdf.js +225 -0
- package/node_modules/@noble/hashes/hkdf.d.ts +70 -0
- package/node_modules/@noble/hashes/hkdf.js +152 -0
- package/node_modules/@noble/hashes/hmac.d.ts +50 -0
- package/node_modules/@noble/hashes/hmac.js +93 -0
- package/node_modules/@noble/hashes/index.d.ts +1 -0
- package/node_modules/@noble/hashes/index.js +34 -0
- package/node_modules/@noble/hashes/legacy.d.ts +107 -0
- package/node_modules/@noble/hashes/legacy.js +348 -0
- package/node_modules/@noble/hashes/package.json +91 -0
- package/node_modules/@noble/hashes/pbkdf2.d.ts +66 -0
- package/node_modules/@noble/hashes/pbkdf2.js +176 -0
- package/node_modules/@noble/hashes/scrypt.d.ts +98 -0
- package/node_modules/@noble/hashes/scrypt.js +304 -0
- package/node_modules/@noble/hashes/sha2.d.ts +176 -0
- package/node_modules/@noble/hashes/sha2.js +446 -0
- package/node_modules/@noble/hashes/sha3-addons.d.ts +533 -0
- package/node_modules/@noble/hashes/sha3-addons.js +973 -0
- package/node_modules/@noble/hashes/sha3.d.ts +208 -0
- package/node_modules/@noble/hashes/sha3.js +475 -0
- package/node_modules/@noble/hashes/src/_blake.ts +67 -0
- package/node_modules/@noble/hashes/src/_md.ts +227 -0
- package/node_modules/@noble/hashes/src/_u64.ts +111 -0
- package/node_modules/@noble/hashes/src/argon2.ts +693 -0
- package/node_modules/@noble/hashes/src/blake1.ts +677 -0
- package/node_modules/@noble/hashes/src/blake2.ts +648 -0
- package/node_modules/@noble/hashes/src/blake3.ts +344 -0
- package/node_modules/@noble/hashes/src/eskdf.ts +265 -0
- package/node_modules/@noble/hashes/src/hkdf.ts +161 -0
- package/node_modules/@noble/hashes/src/hmac.ts +130 -0
- package/node_modules/@noble/hashes/src/index.ts +33 -0
- package/node_modules/@noble/hashes/src/legacy.ts +361 -0
- package/node_modules/@noble/hashes/src/pbkdf2.ts +219 -0
- package/node_modules/@noble/hashes/src/scrypt.ts +375 -0
- package/node_modules/@noble/hashes/src/sha2.ts +486 -0
- package/node_modules/@noble/hashes/src/sha3-addons.ts +1157 -0
- package/node_modules/@noble/hashes/src/sha3.ts +525 -0
- package/node_modules/@noble/hashes/src/utils.ts +978 -0
- package/node_modules/@noble/hashes/src/webcrypto.ts +283 -0
- package/node_modules/@noble/hashes/utils.d.ts +560 -0
- package/node_modules/@noble/hashes/utils.js +687 -0
- package/node_modules/@noble/hashes/webcrypto.d.ts +121 -0
- package/node_modules/@noble/hashes/webcrypto.js +228 -0
- package/node_modules/@poe-code/agent-mcp-config/dist/apply.js +23 -9
- package/node_modules/@poe-code/config-mutations/README.md +2 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.js +4 -5
- package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.d.ts +3 -4
- package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.js +3 -3
- package/node_modules/@poe-code/config-mutations/dist/template/render.js +1 -1
- package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.d.ts +2 -2
- package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.js +3 -6
- package/node_modules/@poe-code/config-mutations/dist/types.d.ts +4 -2
- package/node_modules/@poe-code/process-runner/README.md +2 -1
- package/node_modules/@poe-code/process-runner/dist/transfer-filesystem.d.ts +1 -0
- package/node_modules/@poe-code/process-runner/dist/transfer-filesystem.js +1 -0
- package/node_modules/@poe-code/process-runner/dist/transfer-filesystem.workerd.d.ts +2 -0
- package/node_modules/@poe-code/process-runner/dist/transfer-filesystem.workerd.js +1 -0
- package/node_modules/@poe-code/process-runner/dist/types.d.ts +1 -1
- package/node_modules/@poe-code/process-runner/dist/workspace-transfer.d.ts +6 -5
- package/node_modules/@poe-code/process-runner/dist/workspace-transfer.js +67 -29
- package/node_modules/@poe-code/process-runner/package.json +13 -0
- package/node_modules/@poe-code/safe-fs/LICENSE +21 -0
- package/node_modules/@poe-code/safe-fs/PROVENANCE.json +428 -0
- package/node_modules/@poe-code/safe-fs/README.md +411 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/confinement.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/confinement.js +171 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/filesystem.d.ts +93 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/filesystem.js +453 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/index.d.ts +7 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/index.js +19 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/stats.d.ts +4 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/stats.js +37 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/types.d.ts +81 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/types.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/values.d.ts +6 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/values.js +65 -0
- package/node_modules/@poe-code/safe-fs/dist/config/memory.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/config/memory.js +7 -0
- package/node_modules/@poe-code/safe-fs/dist/config/real.d.ts +5 -0
- package/node_modules/@poe-code/safe-fs/dist/config/real.js +16 -0
- package/node_modules/@poe-code/safe-fs/dist/config/registry.d.ts +2 -0
- package/node_modules/@poe-code/safe-fs/dist/config/registry.js +15 -0
- package/node_modules/@poe-code/safe-fs/dist/config.d.ts +15 -0
- package/node_modules/@poe-code/safe-fs/dist/config.js +46 -0
- package/node_modules/@poe-code/safe-fs/dist/config.node.d.ts +2 -0
- package/node_modules/@poe-code/safe-fs/dist/config.node.js +11 -0
- package/node_modules/@poe-code/safe-fs/dist/config.portable.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/config.portable.js +9 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/abort.d.ts +5 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/abort.js +34 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/cleanup.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/cleanup.js +9 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/descriptor.d.ts +38 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/descriptor.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/errors.d.ts +53 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/errors.js +99 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/filesystem.d.ts +379 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/filesystem.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/index.d.ts +6 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/index.js +6 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/io.d.ts +12 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/io.js +321 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/object.d.ts +134 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/object.js +97 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/path.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/path.js +2 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/portable-path.d.ts +21 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/portable-path.js +78 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/virtual-path.d.ts +15 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/virtual-path.js +162 -0
- package/node_modules/@poe-code/safe-fs/dist/core.d.ts +19 -0
- package/node_modules/@poe-code/safe-fs/dist/core.js +17 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/capabilities.d.ts +10 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/capabilities.js +216 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/conditional-chmod.d.ts +7 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/conditional-chmod.js +19 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/descriptor.d.ts +21 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/descriptor.js +279 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/devices/index.d.ts +59 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/devices/index.js +875 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/devices/path.d.ts +7 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/devices/path.js +250 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/devices/stream.d.ts +6 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/devices/stream.js +136 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/directory-admission.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/directory-admission.js +14 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/atomic-view.d.ts +11 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/atomic-view.js +13 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/index.d.ts +186 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/index.js +3771 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/ledger.d.ts +26 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/ledger.js +96 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/limits.d.ts +13 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/limits.js +26 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/missing-target.d.ts +15 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/missing-target.js +144 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/mount/comparison.d.ts +19 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/mount/comparison.js +118 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/mount/identity.d.ts +6 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/mount/identity.js +29 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/mount/index.d.ts +74 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/mount/index.js +1291 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/object-authority.d.ts +27 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/object-authority.js +287 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/object-publication/index.d.ts +45 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/object-publication/index.js +531 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/overlay/index.d.ts +87 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/overlay/index.js +1185 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/overlay/memory-publication.d.ts +42 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/overlay/memory-publication.js +558 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/path-namespace.d.ts +4 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/path-namespace.js +63 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/quota/index.d.ts +12 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/quota/index.js +520 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/readonly/index.d.ts +37 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/readonly/index.js +208 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/real/allocation.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/real/allocation.js +8 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/real/index.d.ts +105 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/real/index.js +1259 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/authority.d.ts +7 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/authority.js +38 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/filesystem.d.ts +130 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/filesystem.js +1137 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/bytes.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/bytes.js +9 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/index.d.ts +2 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/index.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-fetch.d.ts +15 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-fetch.js +74 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-node.d.ts +4 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-node.js +111 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request.d.ts +17 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request.js +89 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/signature.d.ts +20 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/signature.js +76 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/transport.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/transport.js +478 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/types.d.ts +30 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/types.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/xml.d.ts +14 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/xml.js +192 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/index.d.ts +8 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/index.js +4 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/key-order.d.ts +2 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/key-order.js +11 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/manifest-admission.d.ts +8 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/manifest-admission.js +167 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/mock.d.ts +48 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/mock.js +249 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/namespace.d.ts +13 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/namespace.js +400 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/registry.d.ts +10 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/registry.js +73 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/transport.d.ts +103 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/transport.js +28 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/scoped.d.ts +19 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/scoped.js +663 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/staging-ancestry.d.ts +8 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/staging-ancestry.js +115 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/staging-cleanup.d.ts +5 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/staging-cleanup.js +63 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/index.d.ts +2 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/index.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/resource-id.d.ts +18 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/resource-id.js +109 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/webdav.d.ts +141 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/webdav.js +1377 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/xml.d.ts +15 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/xml.js +59 -0
- package/node_modules/@poe-code/safe-fs/dist/index.d.ts +25 -0
- package/node_modules/@poe-code/safe-fs/dist/index.js +21 -0
- package/node_modules/@poe-code/safe-fs/dist/native/fs-seek/linux-x64-glibc.node +0 -0
- package/node_modules/@poe-code/safe-fs/dist/native/fs-seek/loader.d.ts +5 -0
- package/node_modules/@poe-code/safe-fs/dist/native/fs-seek/loader.mjs +120 -0
- package/node_modules/@poe-code/safe-fs/dist/native/fs-seek/manifest.json +46 -0
- package/node_modules/@poe-code/safe-fs/dist/node/filesystem.d.ts +19 -0
- package/node_modules/@poe-code/safe-fs/dist/node/filesystem.js +30 -0
- package/node_modules/@poe-code/safe-fs/dist/node/host.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/node/host.js +78 -0
- package/node_modules/@poe-code/safe-fs/dist/node/index.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/node/index.js +2 -0
- package/node_modules/@poe-code/safe-fs/dist/node/native-seek-unavailable.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node/native-seek-unavailable.js +5 -0
- package/node_modules/@poe-code/safe-fs/dist/node/native-seek.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/node/native-seek.js +54 -0
- package/node_modules/@poe-code/safe-fs/dist/node/stats.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node/stats.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node/values.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node/values.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node-host.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node-host.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node-unavailable.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node-unavailable.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/package.json +29 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/browser-path.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/browser-path.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/browser.d.ts +26 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/browser.js +58 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/node-path.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/node-path.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/node.d.ts +26 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/node.js +64 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/transport-budget.d.ts +9 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/transport-budget.js +17 -0
- package/node_modules/@poe-code/safe-fs/dist/python/emscripten.d.ts +15 -0
- package/node_modules/@poe-code/safe-fs/dist/python/emscripten.js +357 -0
- package/node_modules/@poe-code/safe-fs/dist/python/filesystem.d.ts +51 -0
- package/node_modules/@poe-code/safe-fs/dist/python/filesystem.js +243 -0
- package/node_modules/@poe-code/safe-fs/dist/python/flags.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/python/flags.js +14 -0
- package/node_modules/@poe-code/safe-fs/dist/python/index.d.ts +9 -0
- package/node_modules/@poe-code/safe-fs/dist/python/index.js +5 -0
- package/node_modules/@poe-code/safe-fs/dist/python/native.d.ts +18 -0
- package/node_modules/@poe-code/safe-fs/dist/python/native.js +446 -0
- package/node_modules/@poe-code/safe-fs/dist/python/request.d.ts +2 -0
- package/node_modules/@poe-code/safe-fs/dist/python/request.js +61 -0
- package/node_modules/@poe-code/safe-fs/dist/python/stat.d.ts +8 -0
- package/node_modules/@poe-code/safe-fs/dist/python/stat.js +34 -0
- package/node_modules/@poe-code/safe-fs/dist/runtime-core.d.ts +27 -0
- package/node_modules/@poe-code/safe-fs/dist/runtime-core.js +57 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/atomic-filesystem.d.ts +16 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/atomic-filesystem.js +496 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/object-io-control.d.ts +23 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/object-io-control.js +39 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/object-io-metrics.d.ts +31 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/object-io-metrics.js +143 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/object-publication.d.ts +19 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/object-publication.js +209 -0
- package/node_modules/@poe-code/safe-fs/dist/xml.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/xml.js +1 -0
- package/node_modules/@poe-code/safe-fs/package.json +189 -0
- package/node_modules/@poe-code/task-list/README.md +2 -0
- package/node_modules/@poe-code/task-list/dist/backends/gh-issues-client.d.ts +1 -1
- package/node_modules/@poe-code/task-list/dist/backends/gh-issues-client.js +11 -4
- package/node_modules/@poe-code/task-list/dist/backends/markdown-dir.js +2 -2
- package/node_modules/@poe-code/task-list/dist/backends/utils.js +5 -7
- package/node_modules/@poe-code/task-list/dist/backends/yaml-file.js +1 -1
- package/node_modules/@poe-code/task-list/dist/default-host.d.ts +2 -0
- package/node_modules/@poe-code/task-list/dist/default-host.js +2 -0
- package/node_modules/@poe-code/task-list/dist/default-host.workerd.d.ts +4 -0
- package/node_modules/@poe-code/task-list/dist/default-host.workerd.js +6 -0
- package/node_modules/@poe-code/task-list/dist/filesystem.d.ts +3 -0
- package/node_modules/@poe-code/task-list/dist/filesystem.js +32 -0
- package/node_modules/@poe-code/task-list/dist/move.js +3 -3
- package/node_modules/@poe-code/task-list/dist/open.js +2 -5
- package/node_modules/@poe-code/task-list/dist/paths.d.ts +12 -0
- package/node_modules/@poe-code/task-list/dist/paths.js +7 -0
- package/node_modules/@poe-code/task-list/dist/types.d.ts +6 -5
- package/node_modules/@poe-code/task-list/package.json +9 -0
- package/node_modules/@poe-code/terminal-text/LICENSE +21 -0
- package/node_modules/@poe-code/terminal-text/README.md +12 -0
- package/node_modules/@poe-code/terminal-text/dist/index.d.ts +2 -0
- package/node_modules/@poe-code/terminal-text/dist/index.js +20 -0
- package/node_modules/@poe-code/terminal-text/package.json +22 -0
- package/node_modules/@poe-code/xml-ast/LICENSE +21 -0
- package/node_modules/@poe-code/xml-ast/README.md +28 -0
- package/node_modules/@poe-code/xml-ast/dist/index.d.ts +47 -0
- package/node_modules/@poe-code/xml-ast/dist/index.js +635 -0
- package/node_modules/@poe-code/xml-ast/package.json +25 -0
- package/node_modules/auth-store/README.md +35 -0
- package/node_modules/auth-store/dist/index.browser.d.ts +4 -0
- package/node_modules/auth-store/dist/index.browser.js +2 -0
- package/node_modules/auth-store/dist/provider-store.d.ts +1 -1
- package/node_modules/auth-store/dist/safe-fs-secret-store.d.ts +21 -0
- package/node_modules/auth-store/dist/safe-fs-secret-store.js +119 -0
- package/node_modules/auth-store/dist/secret-store.d.ts +12 -0
- package/node_modules/auth-store/dist/secret-store.js +1 -0
- package/node_modules/auth-store/dist/transaction-lock.d.ts +2 -4
- package/node_modules/auth-store/dist/types.d.ts +2 -9
- package/node_modules/auth-store/package.json +16 -2
- package/node_modules/tiny-http-mcp-server/dist/composition.json +16 -1
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/README.md +25 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/authorization-state.js +4 -4
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/default-oauth-client-provider.js +6 -40
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/oauth-form.d.ts +10 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/oauth-form.js +20 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/pkce.js +4 -3
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/register-client.d.ts +14 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/register-client.js +53 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/resumable.d.ts +16 -2
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/resumable.js +29 -9
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/revoke-token.d.ts +12 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/revoke-token.js +23 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/token-endpoint.js +6 -19
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/http-fetch.js +1 -1
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.browser.d.ts +6 -2
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.browser.js +5 -1
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.d.ts +5 -2
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.js +4 -1
- package/node_modules/tiny-http-mcp-server/package.json +4 -4
- package/node_modules/tiny-mcp-client/README.md +2 -0
- package/node_modules/tiny-mcp-client/dist/index.browser.d.ts +25 -23
- package/node_modules/tiny-mcp-client/dist/index.browser.js +116 -1
- package/node_modules/tiny-mcp-client/dist/index.d.ts +25 -23
- package/node_modules/tiny-mcp-client/dist/index.js +1034 -561
- package/node_modules/tiny-mcp-client/package.json +15 -0
- package/node_modules/tiny-stdio-mcp-server/dist/composition.json +1 -1
- package/node_modules/toolcraft-design/dist/components/table.js +6 -0
- package/node_modules/toolcraft-design/dist/escape-terminal-text.d.ts +1 -2
- package/node_modules/toolcraft-design/dist/escape-terminal-text.js +1 -20
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/frontmatter.js +2 -1
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser.js +2 -1
- package/node_modules/toolcraft-schema/dist/json-schema/utils.js +3 -0
- package/node_modules/toolcraft-schema/package.json +1 -1
- package/package.json +32 -7
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
import { fileURLToPath, defaultEnvironment } from "#toolcraft-runtime-platform";
|
|
2
|
+
import { ApprovalDeclinedError } from "./human-in-loop/types.js";
|
|
3
|
+
import { mergeHumanInLoopFromGroup, validateHumanInLoopOnDefine } from "./human-in-loop/config.js";
|
|
4
|
+
import { ToolcraftBugError, UserError, isUserError } from "./user-error.js";
|
|
5
|
+
import { suggest } from "./suggest.js";
|
|
6
|
+
import { isProxyNode } from "./mcp-proxy-metadata.js";
|
|
7
|
+
export { createManagedStream } from "./stream.js";
|
|
8
|
+
const commandConfigSymbol = Symbol("toolcraft.command.config");
|
|
9
|
+
const groupConfigSymbol = Symbol("toolcraft.group.config");
|
|
10
|
+
const commandSourcePathSymbol = Symbol("toolcraft.command.sourcePath");
|
|
11
|
+
function cloneScope(scope) {
|
|
12
|
+
return scope === undefined ? undefined : [...scope];
|
|
13
|
+
}
|
|
14
|
+
function cloneSecretDefinition(secret) {
|
|
15
|
+
return {
|
|
16
|
+
env: secret.env,
|
|
17
|
+
description: secret.description,
|
|
18
|
+
optional: secret.optional
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function cloneSecrets(secrets) {
|
|
22
|
+
if (secrets === undefined) {
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
return Object.fromEntries(Object.entries(secrets).map(([key, secret]) => [key, cloneSecretDefinition(secret)]));
|
|
26
|
+
}
|
|
27
|
+
function cloneRequires(requires) {
|
|
28
|
+
if (requires === undefined) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
auth: requires.auth,
|
|
33
|
+
apiVersion: requires.apiVersion,
|
|
34
|
+
check: requires.check
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function cloneToolAnnotations(annotations) {
|
|
38
|
+
return annotations === undefined ? undefined : { ...annotations };
|
|
39
|
+
}
|
|
40
|
+
function cloneStringArray(values) {
|
|
41
|
+
return values === undefined ? undefined : [...values];
|
|
42
|
+
}
|
|
43
|
+
function cloneCommandExamples(examples) {
|
|
44
|
+
return (examples ?? []).map((example) => ({
|
|
45
|
+
title: example.title,
|
|
46
|
+
params: { ...example.params }
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
function cloneStringRecord(values) {
|
|
50
|
+
return values === undefined ? undefined : { ...values };
|
|
51
|
+
}
|
|
52
|
+
function cloneMcpServerConfig(config) {
|
|
53
|
+
if (config === undefined) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
if (config.transport === "stdio") {
|
|
57
|
+
return {
|
|
58
|
+
transport: "stdio",
|
|
59
|
+
command: config.command,
|
|
60
|
+
args: cloneStringArray(config.args),
|
|
61
|
+
env: cloneStringRecord(config.env)
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
transport: "http",
|
|
66
|
+
url: config.url,
|
|
67
|
+
headers: cloneStringRecord(config.headers)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function cloneRenameMap(rename) {
|
|
71
|
+
return rename === undefined ? undefined : { ...rename };
|
|
72
|
+
}
|
|
73
|
+
function validateRenameMap(rename) {
|
|
74
|
+
if (rename === undefined) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const seenTargets = new Map();
|
|
78
|
+
for (const [upstreamName, targetPath] of Object.entries(rename)) {
|
|
79
|
+
if (targetPath.length === 0) {
|
|
80
|
+
throw new UserError(`Invalid rename target for upstream tool "${upstreamName}": path cannot be empty.`);
|
|
81
|
+
}
|
|
82
|
+
if (targetPath.split(".").some((segment) => segment.length === 0)) {
|
|
83
|
+
throw new UserError(`Invalid rename target for upstream tool "${upstreamName}": "${targetPath}" contains an empty segment.`);
|
|
84
|
+
}
|
|
85
|
+
const existingUpstreamName = seenTargets.get(targetPath);
|
|
86
|
+
if (existingUpstreamName !== undefined) {
|
|
87
|
+
throw new UserError(`Duplicate rename target "${targetPath}" for upstream tools "${existingUpstreamName}" and "${upstreamName}".`);
|
|
88
|
+
}
|
|
89
|
+
seenTargets.set(targetPath, upstreamName);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function parseStackPath(candidate) {
|
|
93
|
+
if (candidate.startsWith("file://")) {
|
|
94
|
+
try {
|
|
95
|
+
return fileURLToPath(candidate);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (candidate.startsWith("/")) {
|
|
102
|
+
return candidate;
|
|
103
|
+
}
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
function extractStackPath(line) {
|
|
107
|
+
const trimmed = line.trim();
|
|
108
|
+
const fileIndex = trimmed.indexOf("file://");
|
|
109
|
+
if (fileIndex >= 0) {
|
|
110
|
+
const location = trimmed.slice(fileIndex);
|
|
111
|
+
const separatorIndex = location.lastIndexOf(":");
|
|
112
|
+
const previousSeparatorIndex = separatorIndex >= 0 ? location.lastIndexOf(":", separatorIndex - 1) : -1;
|
|
113
|
+
const candidate = separatorIndex >= 0 && previousSeparatorIndex >= 0
|
|
114
|
+
? location.slice(0, previousSeparatorIndex)
|
|
115
|
+
: location;
|
|
116
|
+
return parseStackPath(candidate);
|
|
117
|
+
}
|
|
118
|
+
const slashIndex = trimmed.indexOf("/");
|
|
119
|
+
if (slashIndex < 0) {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
const location = trimmed.slice(slashIndex);
|
|
123
|
+
const separatorIndex = location.lastIndexOf(":");
|
|
124
|
+
const previousSeparatorIndex = separatorIndex >= 0 ? location.lastIndexOf(":", separatorIndex - 1) : -1;
|
|
125
|
+
const candidate = separatorIndex >= 0 && previousSeparatorIndex >= 0
|
|
126
|
+
? location.slice(0, previousSeparatorIndex)
|
|
127
|
+
: location;
|
|
128
|
+
return parseStackPath(candidate);
|
|
129
|
+
}
|
|
130
|
+
function inferCommandSourcePath() {
|
|
131
|
+
const stack = new Error().stack;
|
|
132
|
+
if (typeof stack !== "string") {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
for (const line of stack.split("\n").slice(1)) {
|
|
136
|
+
const candidate = extractStackPath(line);
|
|
137
|
+
if (candidate === undefined) {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (candidate.includes("/packages/toolcraft/src/index.ts") ||
|
|
141
|
+
candidate.includes("/packages/toolcraft/dist/index.js") ||
|
|
142
|
+
candidate.includes("/node_modules/toolcraft/dist/index.js") ||
|
|
143
|
+
candidate.includes("/packages/toolcraft/src/runtime.ts") ||
|
|
144
|
+
candidate.includes("/packages/toolcraft/dist/runtime.js") ||
|
|
145
|
+
candidate.includes("/node_modules/toolcraft/dist/runtime.js")) {
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
return candidate;
|
|
149
|
+
}
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
function composeChecks(parentCheck, childCheck) {
|
|
153
|
+
if (parentCheck === undefined) {
|
|
154
|
+
return childCheck;
|
|
155
|
+
}
|
|
156
|
+
if (childCheck === undefined) {
|
|
157
|
+
return parentCheck;
|
|
158
|
+
}
|
|
159
|
+
return async (ctx) => {
|
|
160
|
+
const parentResult = await parentCheck(ctx);
|
|
161
|
+
if (!parentResult.ok) {
|
|
162
|
+
return parentResult;
|
|
163
|
+
}
|
|
164
|
+
return childCheck(ctx);
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function mergeRequires(parent, child) {
|
|
168
|
+
if (parent === undefined && child === undefined) {
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
const merged = {
|
|
172
|
+
auth: child?.auth ?? parent?.auth,
|
|
173
|
+
apiVersion: child?.apiVersion ?? parent?.apiVersion,
|
|
174
|
+
check: composeChecks(parent?.check, child?.check)
|
|
175
|
+
};
|
|
176
|
+
if (merged.auth === undefined && merged.apiVersion === undefined && merged.check === undefined) {
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
179
|
+
return merged;
|
|
180
|
+
}
|
|
181
|
+
function parseSimpleSemver(value) {
|
|
182
|
+
const parts = value.split(".");
|
|
183
|
+
if (parts.length !== 3) {
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
const parsed = parts.map((part) => {
|
|
187
|
+
if (part.length === 0) {
|
|
188
|
+
return Number.NaN;
|
|
189
|
+
}
|
|
190
|
+
for (const char of part) {
|
|
191
|
+
if (char < "0" || char > "9") {
|
|
192
|
+
return Number.NaN;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return Number(part);
|
|
196
|
+
});
|
|
197
|
+
if (parsed.some((part) => !Number.isInteger(part) || part < 0)) {
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
200
|
+
return parsed;
|
|
201
|
+
}
|
|
202
|
+
function parseMinimumApiVersion(requirement) {
|
|
203
|
+
if (!requirement.startsWith(">=")) {
|
|
204
|
+
return undefined;
|
|
205
|
+
}
|
|
206
|
+
return parseSimpleSemver(requirement.slice(2).trim());
|
|
207
|
+
}
|
|
208
|
+
function compareSemver(left, right) {
|
|
209
|
+
for (let index = 0; index < left.length; index += 1) {
|
|
210
|
+
if (left[index] === right[index]) {
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
return left[index] > right[index] ? 1 : -1;
|
|
214
|
+
}
|
|
215
|
+
return 0;
|
|
216
|
+
}
|
|
217
|
+
export function resolveCommandSecrets(command, env = defaultEnvironment()) {
|
|
218
|
+
const secrets = {};
|
|
219
|
+
for (const [name, secret] of Object.entries(command.secrets)) {
|
|
220
|
+
const value = env[secret.env];
|
|
221
|
+
if (value === undefined && secret.optional !== true) {
|
|
222
|
+
const details = secret.description ? `\n ${secret.description}` : "";
|
|
223
|
+
const candidates = Object.keys(env).filter((candidate) => candidate !== secret.env && env[candidate] !== undefined);
|
|
224
|
+
const suggestions = suggestSecretEnv(secret.env, candidates);
|
|
225
|
+
const suggestionLine = suggestions.length > 0 ? `\nDid you mean: ${suggestions.join(", ")}?` : "";
|
|
226
|
+
throw new UserError(`Missing required secret ${secret.env}${details}${suggestionLine}`);
|
|
227
|
+
}
|
|
228
|
+
Object.defineProperty(secrets, name, {
|
|
229
|
+
value,
|
|
230
|
+
enumerable: true,
|
|
231
|
+
configurable: true,
|
|
232
|
+
writable: true
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
return secrets;
|
|
236
|
+
}
|
|
237
|
+
function suggestSecretEnv(input, candidates) {
|
|
238
|
+
const directSuggestions = suggest(input, candidates);
|
|
239
|
+
if (!input.includes("_")) {
|
|
240
|
+
return directSuggestions;
|
|
241
|
+
}
|
|
242
|
+
const inputParts = input.split("_");
|
|
243
|
+
const firstPart = inputParts[0];
|
|
244
|
+
const lastPart = inputParts[inputParts.length - 1];
|
|
245
|
+
const relatedCandidates = candidates.filter((candidate) => {
|
|
246
|
+
const candidateParts = candidate.split("_");
|
|
247
|
+
return (candidateParts[0] === firstPart && candidateParts[candidateParts.length - 1] === lastPart);
|
|
248
|
+
});
|
|
249
|
+
const expandedSuggestions = suggest(input, relatedCandidates, {
|
|
250
|
+
threshold: Math.max(4, Math.floor(input.length / 4))
|
|
251
|
+
});
|
|
252
|
+
return [...new Set([...directSuggestions, ...expandedSuggestions])].slice(0, 3);
|
|
253
|
+
}
|
|
254
|
+
export async function assertCommandRequirements(command, context, options = {}) {
|
|
255
|
+
const requires = command.requires;
|
|
256
|
+
if (requires === undefined) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const env = options.env ?? defaultEnvironment();
|
|
260
|
+
const authEnvVar = options.authEnvVar ?? "POE_API_KEY";
|
|
261
|
+
if (requires.auth === true && env[authEnvVar] === undefined) {
|
|
262
|
+
throw new UserError(`Command "${command.name}" requires authentication.\n Run 'poe-code login' first.`);
|
|
263
|
+
}
|
|
264
|
+
if (requires.apiVersion !== undefined) {
|
|
265
|
+
const minimumVersion = parseMinimumApiVersion(requires.apiVersion);
|
|
266
|
+
if (minimumVersion === undefined) {
|
|
267
|
+
throw new UserError(`Command "${command.name}" has invalid apiVersion requirement "${requires.apiVersion}". Expected format ">=X.Y.Z".`);
|
|
268
|
+
}
|
|
269
|
+
if (options.apiVersion === undefined) {
|
|
270
|
+
throw new UserError(`Command "${command.name}" requires API version ${requires.apiVersion}, but no runner API version was provided.`);
|
|
271
|
+
}
|
|
272
|
+
const runnerVersion = parseSimpleSemver(options.apiVersion);
|
|
273
|
+
if (runnerVersion === undefined) {
|
|
274
|
+
throw new UserError(`Command "${command.name}" requires API version ${requires.apiVersion}, but runner API version "${options.apiVersion}" is not valid semver.`);
|
|
275
|
+
}
|
|
276
|
+
if (compareSemver(runnerVersion, minimumVersion) < 0) {
|
|
277
|
+
throw new UserError(`Command "${command.name}" requires API version ${requires.apiVersion}, but runner API version is ${options.apiVersion}.`);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
const checkResult = await requires.check?.(context);
|
|
281
|
+
if (checkResult && !checkResult.ok) {
|
|
282
|
+
throw new UserError(checkResult.message ?? "Command precondition failed.");
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
function mergeSecrets(parent, child) {
|
|
286
|
+
return cloneSecrets({
|
|
287
|
+
...parent,
|
|
288
|
+
...child
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
function resolveCommandScope(ownScope, inheritedScope) {
|
|
292
|
+
return cloneScope(ownScope ?? inheritedScope) ?? ["cli", "sdk"];
|
|
293
|
+
}
|
|
294
|
+
function resolveGroupScope(ownScope, inheritedScope) {
|
|
295
|
+
return cloneScope(ownScope ?? inheritedScope);
|
|
296
|
+
}
|
|
297
|
+
function createBaseCommand(config) {
|
|
298
|
+
if (config.mcpResult !== undefined && config.result === undefined) {
|
|
299
|
+
throw new ToolcraftBugError(`Command "${config.name}" defines mcpResult without a result schema.`);
|
|
300
|
+
}
|
|
301
|
+
const command = {
|
|
302
|
+
kind: "command",
|
|
303
|
+
name: config.name,
|
|
304
|
+
title: config.title,
|
|
305
|
+
description: config.description,
|
|
306
|
+
annotations: cloneToolAnnotations(config.annotations),
|
|
307
|
+
hidden: config.hidden ?? false,
|
|
308
|
+
examples: cloneCommandExamples(config.examples),
|
|
309
|
+
aliases: [...(config.aliases ?? [])],
|
|
310
|
+
positional: [...(config.positional ?? [])],
|
|
311
|
+
params: config.params,
|
|
312
|
+
result: config.result,
|
|
313
|
+
mcpResult: config.mcpResult,
|
|
314
|
+
stream: undefined,
|
|
315
|
+
secrets: cloneSecrets(config.secrets),
|
|
316
|
+
scope: resolveCommandScope(config.scope, undefined),
|
|
317
|
+
confirm: config.confirm ?? false,
|
|
318
|
+
humanInLoop: config.humanInLoop,
|
|
319
|
+
requires: cloneRequires(config.requires),
|
|
320
|
+
handler: config.handler,
|
|
321
|
+
render: config.render
|
|
322
|
+
};
|
|
323
|
+
Object.defineProperty(command, commandConfigSymbol, {
|
|
324
|
+
value: {
|
|
325
|
+
title: config.title,
|
|
326
|
+
annotations: cloneToolAnnotations(config.annotations),
|
|
327
|
+
scope: cloneScope(config.scope),
|
|
328
|
+
hidden: config.hidden ?? false,
|
|
329
|
+
examples: cloneCommandExamples(config.examples),
|
|
330
|
+
result: config.result,
|
|
331
|
+
mcpResult: config.mcpResult,
|
|
332
|
+
humanInLoop: config.humanInLoop,
|
|
333
|
+
secrets: cloneSecrets(config.secrets),
|
|
334
|
+
requires: cloneRequires(config.requires),
|
|
335
|
+
sourcePath: inferCommandSourcePath()
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
return command;
|
|
339
|
+
}
|
|
340
|
+
function createBaseGroup(config) {
|
|
341
|
+
const group = {
|
|
342
|
+
kind: "group",
|
|
343
|
+
name: config.name,
|
|
344
|
+
description: config.description,
|
|
345
|
+
aliases: [...(config.aliases ?? [])],
|
|
346
|
+
scope: resolveGroupScope(config.scope, undefined),
|
|
347
|
+
humanInLoop: config.humanInLoop,
|
|
348
|
+
secrets: cloneSecrets(config.secrets),
|
|
349
|
+
requires: cloneRequires(config.requires),
|
|
350
|
+
children: [],
|
|
351
|
+
default: undefined
|
|
352
|
+
};
|
|
353
|
+
Object.defineProperty(group, groupConfigSymbol, {
|
|
354
|
+
value: {
|
|
355
|
+
mcp: cloneMcpServerConfig(config.mcp),
|
|
356
|
+
scope: cloneScope(config.scope),
|
|
357
|
+
humanInLoop: config.humanInLoop,
|
|
358
|
+
secrets: cloneSecrets(config.secrets),
|
|
359
|
+
tools: cloneStringArray(config.tools),
|
|
360
|
+
rename: cloneRenameMap(config.rename),
|
|
361
|
+
requires: cloneRequires(config.requires),
|
|
362
|
+
children: [...config.children],
|
|
363
|
+
default: config.default
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
return group;
|
|
367
|
+
}
|
|
368
|
+
function getInternalCommandConfig(command) {
|
|
369
|
+
return command[commandConfigSymbol];
|
|
370
|
+
}
|
|
371
|
+
function getInternalGroupConfig(group) {
|
|
372
|
+
return group[groupConfigSymbol];
|
|
373
|
+
}
|
|
374
|
+
function materializeCommand(command, inherited) {
|
|
375
|
+
const internal = getInternalCommandConfig(command);
|
|
376
|
+
const materialized = {
|
|
377
|
+
kind: "command",
|
|
378
|
+
name: command.name,
|
|
379
|
+
title: internal.title,
|
|
380
|
+
description: command.description,
|
|
381
|
+
annotations: cloneToolAnnotations(internal.annotations),
|
|
382
|
+
hidden: internal.hidden,
|
|
383
|
+
examples: cloneCommandExamples(internal.examples),
|
|
384
|
+
aliases: [...command.aliases],
|
|
385
|
+
positional: [...command.positional],
|
|
386
|
+
params: command.params,
|
|
387
|
+
result: internal.result,
|
|
388
|
+
mcpResult: internal.mcpResult,
|
|
389
|
+
stream: command.stream,
|
|
390
|
+
secrets: mergeSecrets(inherited.secrets, internal.secrets),
|
|
391
|
+
scope: resolveCommandScope(internal.scope, inherited.scope),
|
|
392
|
+
confirm: command.confirm,
|
|
393
|
+
humanInLoop: mergeHumanInLoopFromGroup(inherited.humanInLoop, internal.humanInLoop),
|
|
394
|
+
requires: mergeRequires(inherited.requires, internal.requires),
|
|
395
|
+
handler: command.handler,
|
|
396
|
+
render: command.render
|
|
397
|
+
};
|
|
398
|
+
Object.defineProperty(materialized, commandConfigSymbol, {
|
|
399
|
+
value: {
|
|
400
|
+
title: internal.title,
|
|
401
|
+
annotations: cloneToolAnnotations(internal.annotations),
|
|
402
|
+
scope: cloneScope(internal.scope),
|
|
403
|
+
hidden: internal.hidden,
|
|
404
|
+
examples: cloneCommandExamples(internal.examples),
|
|
405
|
+
result: internal.result,
|
|
406
|
+
mcpResult: internal.mcpResult,
|
|
407
|
+
humanInLoop: internal.humanInLoop,
|
|
408
|
+
secrets: cloneSecrets(internal.secrets),
|
|
409
|
+
requires: cloneRequires(internal.requires),
|
|
410
|
+
sourcePath: internal.sourcePath
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
Object.defineProperty(materialized, commandSourcePathSymbol, {
|
|
414
|
+
value: internal.sourcePath
|
|
415
|
+
});
|
|
416
|
+
return materialized;
|
|
417
|
+
}
|
|
418
|
+
function mergeInheritedMetadata(group, inherited) {
|
|
419
|
+
return {
|
|
420
|
+
scope: resolveGroupScope(group.scope, inherited.scope),
|
|
421
|
+
humanInLoop: mergeHumanInLoopFromGroup(inherited.humanInLoop, group.humanInLoop),
|
|
422
|
+
secrets: mergeSecrets(inherited.secrets, group.secrets),
|
|
423
|
+
requires: mergeRequires(inherited.requires, group.requires)
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
function materializeGroup(group, inherited) {
|
|
427
|
+
const internal = getInternalGroupConfig(group);
|
|
428
|
+
const mergedInherited = mergeInheritedMetadata(internal, inherited);
|
|
429
|
+
const materializedChildren = internal.children.map((child) => materializeNode(child, mergedInherited));
|
|
430
|
+
let defaultChild;
|
|
431
|
+
if (internal.default !== undefined) {
|
|
432
|
+
const defaultIndex = internal.children.indexOf(internal.default);
|
|
433
|
+
if (defaultIndex === -1) {
|
|
434
|
+
throw new ToolcraftBugError(`Default command "${internal.default.name}" must be listed in children.`);
|
|
435
|
+
}
|
|
436
|
+
const resolvedDefault = materializedChildren[defaultIndex];
|
|
437
|
+
if (resolvedDefault?.kind !== "command") {
|
|
438
|
+
throw new ToolcraftBugError(`Default child "${internal.default.name}" must be a command.`);
|
|
439
|
+
}
|
|
440
|
+
defaultChild = resolvedDefault;
|
|
441
|
+
}
|
|
442
|
+
const materialized = {
|
|
443
|
+
kind: "group",
|
|
444
|
+
name: group.name,
|
|
445
|
+
description: group.description,
|
|
446
|
+
aliases: [...group.aliases],
|
|
447
|
+
scope: mergedInherited.scope,
|
|
448
|
+
humanInLoop: mergedInherited.humanInLoop,
|
|
449
|
+
secrets: mergedInherited.secrets,
|
|
450
|
+
requires: mergedInherited.requires,
|
|
451
|
+
children: materializedChildren,
|
|
452
|
+
default: defaultChild
|
|
453
|
+
};
|
|
454
|
+
Object.defineProperty(materialized, groupConfigSymbol, {
|
|
455
|
+
value: {
|
|
456
|
+
mcp: cloneMcpServerConfig(internal.mcp),
|
|
457
|
+
scope: cloneScope(internal.scope),
|
|
458
|
+
humanInLoop: internal.humanInLoop,
|
|
459
|
+
secrets: cloneSecrets(internal.secrets),
|
|
460
|
+
tools: cloneStringArray(internal.tools),
|
|
461
|
+
rename: cloneRenameMap(internal.rename),
|
|
462
|
+
requires: cloneRequires(internal.requires),
|
|
463
|
+
children: [...internal.children],
|
|
464
|
+
default: internal.default
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
return materialized;
|
|
468
|
+
}
|
|
469
|
+
function materializeNode(node, inherited) {
|
|
470
|
+
if (node.kind === "command") {
|
|
471
|
+
return materializeCommand(node, inherited);
|
|
472
|
+
}
|
|
473
|
+
return materializeGroup(node, inherited);
|
|
474
|
+
}
|
|
475
|
+
export function defineCommand(config) {
|
|
476
|
+
validateHumanInLoopOnDefine(config);
|
|
477
|
+
return materializeCommand(createBaseCommand(config), {
|
|
478
|
+
scope: undefined,
|
|
479
|
+
humanInLoop: undefined,
|
|
480
|
+
secrets: {},
|
|
481
|
+
requires: undefined
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
export function defineStreamCommand(config) {
|
|
485
|
+
const command = defineCommand({
|
|
486
|
+
...config,
|
|
487
|
+
confirm: false,
|
|
488
|
+
humanInLoop: null,
|
|
489
|
+
handler: config.handler,
|
|
490
|
+
render: undefined
|
|
491
|
+
});
|
|
492
|
+
command.stream = {
|
|
493
|
+
event: config.event,
|
|
494
|
+
bufferSize: 1
|
|
495
|
+
};
|
|
496
|
+
command.render = config.render;
|
|
497
|
+
return command;
|
|
498
|
+
}
|
|
499
|
+
export function defineGroup(config) {
|
|
500
|
+
validateRenameMap(config.rename);
|
|
501
|
+
validateHumanInLoopOnDefine(config);
|
|
502
|
+
return materializeGroup(createBaseGroup(config), {
|
|
503
|
+
scope: undefined,
|
|
504
|
+
humanInLoop: undefined,
|
|
505
|
+
secrets: {},
|
|
506
|
+
requires: undefined
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
export function cloneCommandNode(node, scopeOverride) {
|
|
510
|
+
function rebuildNode(current, root, withinProxy) {
|
|
511
|
+
const description = current.kind === "command"
|
|
512
|
+
? commandConfigSymbol.description
|
|
513
|
+
: groupConfigSymbol.description;
|
|
514
|
+
const symbol = Object.getOwnPropertySymbols(current).find((candidate) => candidate.description === description);
|
|
515
|
+
const config = symbol === undefined ? undefined : Reflect.get(current, symbol);
|
|
516
|
+
const inherited = root || config === undefined ? current : config;
|
|
517
|
+
const metadata = {
|
|
518
|
+
scope: scopeOverride ?? inherited.scope,
|
|
519
|
+
humanInLoop: inherited.humanInLoop,
|
|
520
|
+
secrets: inherited.secrets,
|
|
521
|
+
requires: inherited.requires
|
|
522
|
+
};
|
|
523
|
+
if (current.kind === "command") {
|
|
524
|
+
const base = createBaseCommand({ ...current, ...metadata });
|
|
525
|
+
if (config !== undefined) {
|
|
526
|
+
getInternalCommandConfig(base).sourcePath = config.sourcePath;
|
|
527
|
+
}
|
|
528
|
+
base.stream = current.stream === undefined ? undefined : { ...current.stream };
|
|
529
|
+
return base;
|
|
530
|
+
}
|
|
531
|
+
const groupConfig = config;
|
|
532
|
+
const proxyChildren = withinProxy || groupConfig?.mcp !== undefined;
|
|
533
|
+
const sourceChildren = current.children.filter((child) => !proxyChildren || !isProxyNode(child));
|
|
534
|
+
const children = sourceChildren.map((child) => rebuildNode(child, false, proxyChildren));
|
|
535
|
+
const defaultIndex = current.default === undefined ? -1 : sourceChildren.indexOf(current.default);
|
|
536
|
+
if (current.default !== undefined && defaultIndex === -1) {
|
|
537
|
+
throw new ToolcraftBugError(`Default command "${current.default.name}" must be listed in children.`);
|
|
538
|
+
}
|
|
539
|
+
return createBaseGroup({
|
|
540
|
+
...current,
|
|
541
|
+
...metadata,
|
|
542
|
+
mcp: groupConfig?.mcp,
|
|
543
|
+
tools: groupConfig?.tools,
|
|
544
|
+
rename: groupConfig?.rename,
|
|
545
|
+
children,
|
|
546
|
+
default: defaultIndex === -1 ? undefined : children[defaultIndex]
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
return materializeNode(rebuildNode(node, true, false), {
|
|
550
|
+
scope: undefined,
|
|
551
|
+
humanInLoop: undefined,
|
|
552
|
+
secrets: {},
|
|
553
|
+
requires: undefined
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
export function getCommandSourcePath(command) {
|
|
557
|
+
return command[commandSourcePathSymbol];
|
|
558
|
+
}
|
|
559
|
+
export function hasMcpProxyConfig(group) {
|
|
560
|
+
const configSymbol = Object.getOwnPropertySymbols(group).find((candidate) => candidate.description === groupConfigSymbol.description);
|
|
561
|
+
const config = configSymbol === undefined
|
|
562
|
+
? undefined
|
|
563
|
+
: group[configSymbol];
|
|
564
|
+
if (config?.mcp !== undefined) {
|
|
565
|
+
return true;
|
|
566
|
+
}
|
|
567
|
+
const children = config?.children ?? group.children;
|
|
568
|
+
return children.some((child) => child.kind === "group" && hasMcpProxyConfig(child));
|
|
569
|
+
}
|
|
570
|
+
export { S, toJsonSchema, withStandardSchema } from "./schema.js";
|
|
571
|
+
export { AuthenticationError, BadRequestError, ClientError, ConflictError, HttpError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, ServerError, ServiceUnavailableError, UnprocessableEntityError, createHttpError } from "./http-errors.js";
|
|
572
|
+
export { ApprovalDeclinedError, ToolcraftBugError, UserError, isUserError };
|
|
573
|
+
export { suggest } from "./suggest.js";
|
|
574
|
+
export { createRuntimeLogger, isLogLevel, shouldEmitDiagnostic } from "./runtime-logging.js";
|
|
575
|
+
export { isSensitiveName, redactHttpBody } from "./redaction.js";
|
|
576
|
+
export { asMCPResult } from "./mcp-result.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Paul Miller (https://paulmillr.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the “Software”), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|