shennian 0.5.35 → 0.5.37
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/README.md +16 -0
- package/dist/publish-build-manifest.json +73 -23
- package/dist/src/agents/acp/discovery.js +1 -1
- package/dist/src/agents/detect.js +1 -1
- package/dist/src/agents/model-values.js +1 -0
- package/dist/src/commands/config.js +1 -0
- package/dist/src/commands/local-apps.js +1 -0
- package/dist/src/commands/steward.js +6 -3
- package/dist/src/index.js +3 -3
- package/dist/src/local-apps/service.js +1 -0
- package/dist/src/personal-workspace/service.js +1 -0
- package/dist/src/room/activation-service.js +7 -7
- package/dist/src/room/standalone-agent-turn.js +5 -0
- package/dist/src/session/handlers/chat-recovery.js +1 -1
- package/dist/src/session/handlers/chat.js +2 -2
- package/dist/src/session/handlers/local-apps.js +1 -0
- package/dist/src/session/handlers/personal-workspace.js +1 -0
- package/dist/src/session/manager.js +1 -1
- package/dist/src/session/queued-chat-dispatch.js +1 -1
- package/dist/src/steward/configure.js +1 -0
- package/dist/src/steward/settings.js +2 -0
- package/dist/src/steward/templates.js +7 -0
- package/dist/src/steward/workspace.js +1 -1
- package/node_modules/@shennian/wire/dist/index.js +1 -1
- package/node_modules/@shennian/wire/dist/local-apps.js +5 -0
- package/node_modules/@sinclair/typebox/build/cjs/compiler/compiler.js +46 -26
- package/node_modules/@sinclair/typebox/build/cjs/parser/runtime/guard.d.ts +1 -1
- package/node_modules/@sinclair/typebox/build/cjs/parser/runtime/token.d.ts +2 -2
- package/node_modules/@sinclair/typebox/build/cjs/syntax/mapping.d.ts +1 -1
- package/node_modules/@sinclair/typebox/build/cjs/system/index.d.ts +0 -1
- package/node_modules/@sinclair/typebox/build/cjs/system/index.js +0 -1
- package/node_modules/@sinclair/typebox/build/cjs/type/object/object.d.ts +2 -2
- package/node_modules/@sinclair/typebox/build/cjs/type/object/object.js +2 -18
- package/node_modules/@sinclair/typebox/build/cjs/value/parse/parse.d.ts +1 -1
- package/node_modules/@sinclair/typebox/build/esm/compiler/compiler.mjs +47 -27
- package/node_modules/@sinclair/typebox/build/esm/parser/runtime/guard.d.mts +1 -1
- package/node_modules/@sinclair/typebox/build/esm/parser/runtime/token.d.mts +2 -2
- package/node_modules/@sinclair/typebox/build/esm/syntax/mapping.d.mts +1 -1
- package/node_modules/@sinclair/typebox/build/esm/system/index.d.mts +0 -1
- package/node_modules/@sinclair/typebox/build/esm/system/index.mjs +0 -1
- package/node_modules/@sinclair/typebox/build/esm/type/composite/composite.mjs +2 -2
- package/node_modules/@sinclair/typebox/build/esm/type/const/const.mjs +3 -3
- package/node_modules/@sinclair/typebox/build/esm/type/instantiate/instantiate.mjs +2 -2
- package/node_modules/@sinclair/typebox/build/esm/type/mapped/mapped.mjs +3 -3
- package/node_modules/@sinclair/typebox/build/esm/type/module/compute.mjs +2 -2
- package/node_modules/@sinclair/typebox/build/esm/type/object/object.d.mts +2 -2
- package/node_modules/@sinclair/typebox/build/esm/type/object/object.mjs +2 -18
- package/node_modules/@sinclair/typebox/build/esm/type/omit/omit.mjs +3 -3
- package/node_modules/@sinclair/typebox/build/esm/type/partial/partial.mjs +3 -3
- package/node_modules/@sinclair/typebox/build/esm/type/pick/pick.mjs +3 -3
- package/node_modules/@sinclair/typebox/build/esm/type/record/record.mjs +3 -3
- package/node_modules/@sinclair/typebox/build/esm/type/required/required.mjs +3 -3
- package/node_modules/@sinclair/typebox/build/esm/type/type/json.mjs +2 -2
- package/node_modules/@sinclair/typebox/build/esm/value/delta/delta.mjs +4 -4
- package/node_modules/@sinclair/typebox/build/esm/value/parse/parse.d.mts +1 -1
- package/node_modules/@sinclair/typebox/package.json +1 -1
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/strip-ansi/index.d.ts +17 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/strip-ansi/index.js +4 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/strip-ansi/node_modules/ansi-regex/index.d.ts +37 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/strip-ansi/node_modules/ansi-regex/index.js +10 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/strip-ansi/node_modules/ansi-regex/package.json +55 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/strip-ansi/node_modules/ansi-regex/readme.md +78 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/strip-ansi/package.json +54 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/strip-ansi/readme.md +46 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/index.d.ts +29 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/index.js +47 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/emoji-regex/README.md +73 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/emoji-regex/es2015/index.js +6 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/emoji-regex/es2015/text.js +6 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/emoji-regex/index.d.ts +23 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/emoji-regex/index.js +6 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/emoji-regex/package.json +50 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/emoji-regex/text.js +6 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/is-fullwidth-code-point/index.d.ts +17 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/is-fullwidth-code-point/index.js +50 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/is-fullwidth-code-point/package.json +42 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/is-fullwidth-code-point/readme.md +39 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/strip-ansi/index.d.ts +17 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/strip-ansi/index.js +4 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/strip-ansi/node_modules/ansi-regex/index.d.ts +37 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/strip-ansi/node_modules/ansi-regex/index.js +10 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/strip-ansi/node_modules/ansi-regex/package.json +55 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/strip-ansi/node_modules/ansi-regex/readme.md +78 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/strip-ansi/package.json +54 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/strip-ansi/readme.md +46 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/package.json +56 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/readme.md +50 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/strip-ansi/index.d.ts +17 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/strip-ansi/index.js +4 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/strip-ansi/node_modules/ansi-regex/index.d.ts +37 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/strip-ansi/node_modules/ansi-regex/index.js +10 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/strip-ansi/node_modules/ansi-regex/license +9 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/strip-ansi/node_modules/ansi-regex/package.json +55 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/strip-ansi/node_modules/ansi-regex/readme.md +78 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/strip-ansi/package.json +54 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/strip-ansi/readme.md +46 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/find-up/license +9 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/find-up/node_modules/locate-path/license +9 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/find-up/node_modules/locate-path/node_modules/p-locate/license +9 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/find-up/node_modules/locate-path/node_modules/p-locate/node_modules/p-limit/license +9 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/find-up/node_modules/locate-path/node_modules/p-locate/node_modules/p-limit/node_modules/p-try/license +9 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/find-up/node_modules/path-exists/license +9 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/index.d.ts +29 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/index.js +47 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/license +9 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/emoji-regex/README.md +73 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/emoji-regex/es2015/index.js +6 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/emoji-regex/es2015/text.js +6 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/emoji-regex/index.d.ts +23 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/emoji-regex/index.js +6 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/emoji-regex/package.json +50 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/emoji-regex/text.js +6 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/is-fullwidth-code-point/index.d.ts +17 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/is-fullwidth-code-point/index.js +50 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/is-fullwidth-code-point/license +9 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/is-fullwidth-code-point/package.json +42 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/is-fullwidth-code-point/readme.md +39 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/strip-ansi/index.d.ts +17 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/strip-ansi/index.js +4 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/strip-ansi/license +9 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/strip-ansi/node_modules/ansi-regex/index.d.ts +37 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/strip-ansi/node_modules/ansi-regex/index.js +10 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/strip-ansi/node_modules/ansi-regex/license +9 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/strip-ansi/node_modules/ansi-regex/package.json +55 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/strip-ansi/node_modules/ansi-regex/readme.md +78 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/strip-ansi/package.json +54 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/node_modules/strip-ansi/readme.md +46 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/package.json +56 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/string-width/readme.md +50 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/yargs-parser/node_modules/camelcase/license +9 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/yargs-parser/node_modules/decamelize/index.js +13 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/yargs-parser/node_modules/decamelize/license +21 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/yargs-parser/node_modules/decamelize/package.json +38 -0
- package/node_modules/qrcode/node_modules/yargs/node_modules/yargs-parser/node_modules/decamelize/readme.md +48 -0
- package/node_modules/ws/lib/permessage-deflate.js +1 -3
- package/node_modules/ws/lib/receiver.js +0 -37
- package/node_modules/ws/lib/sender.js +1 -6
- package/node_modules/ws/lib/websocket-server.js +0 -8
- package/node_modules/ws/lib/websocket.js +3 -31
- package/node_modules/ws/package.json +1 -5
- package/package.json +1 -1
- package/node_modules/@sinclair/typebox/build/cjs/system/evaluate.d.ts +0 -5
- package/node_modules/@sinclair/typebox/build/cjs/system/evaluate.js +0 -11
- package/node_modules/@sinclair/typebox/build/esm/system/evaluate.d.mts +0 -5
- package/node_modules/@sinclair/typebox/build/esm/system/evaluate.mjs +0 -7
- /package/node_modules/{dijkstrajs → qrcode/node_modules/dijkstrajs}/.travis.yml +0 -0
- /package/node_modules/{dijkstrajs → qrcode/node_modules/dijkstrajs}/CONTRIBUTING.md +0 -0
- /package/node_modules/{dijkstrajs → qrcode/node_modules/dijkstrajs}/LICENSE.md +0 -0
- /package/node_modules/{dijkstrajs → qrcode/node_modules/dijkstrajs}/README.md +0 -0
- /package/node_modules/{dijkstrajs → qrcode/node_modules/dijkstrajs}/dijkstra.js +0 -0
- /package/node_modules/{dijkstrajs → qrcode/node_modules/dijkstrajs}/package.json +0 -0
- /package/node_modules/{dijkstrajs → qrcode/node_modules/dijkstrajs}/test/dijkstra.test.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/.eslintignore +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/.eslintrc.json +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/.prettierignore +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/LICENSE +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/README.md +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/browser.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/base.css +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/bitmapper.js.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/bitpacker.js.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/block-navigation.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/chunkstream.js.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/constants.js.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/crc.js.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/favicon.png +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/filter-pack.js.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/filter-parse-async.js.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/filter-parse-sync.js.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/filter-parse.js.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/format-normaliser.js.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/index.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/interlace.js.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/packer-async.js.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/packer-sync.js.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/packer.js.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/paeth-predictor.js.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/parser-async.js.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/parser-sync.js.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/parser.js.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/png-sync.js.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/png.js.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/prettify.css +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/prettify.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/sorter.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/sync-inflate.js.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov-report/sync-reader.js.html +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/coverage/lcov.info +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/lib/bitmapper.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/lib/bitpacker.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/lib/chunkstream.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/lib/constants.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/lib/crc.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/lib/filter-pack.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/lib/filter-parse-async.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/lib/filter-parse-sync.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/lib/filter-parse.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/lib/format-normaliser.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/lib/interlace.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/lib/packer-async.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/lib/packer-sync.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/lib/packer.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/lib/paeth-predictor.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/lib/parser-async.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/lib/parser-sync.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/lib/parser.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/lib/png-sync.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/lib/png.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/lib/sync-inflate.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/lib/sync-reader.js +0 -0
- /package/node_modules/{pngjs → qrcode/node_modules/pngjs}/package.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/LICENSE +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/README.md +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/apply-extends.d.ts +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/apply-extends.js +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/argsert.d.ts +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/argsert.js +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/command.d.ts +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/command.js +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/common-types.d.ts +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/common-types.js +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/completion-templates.d.ts +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/completion-templates.js +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/completion.d.ts +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/completion.js +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/is-promise.d.ts +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/is-promise.js +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/levenshtein.d.ts +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/levenshtein.js +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/middleware.d.ts +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/middleware.js +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/obj-filter.d.ts +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/obj-filter.js +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/parse-command.d.ts +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/parse-command.js +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/process-argv.d.ts +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/process-argv.js +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/usage.d.ts +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/usage.js +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/validation.d.ts +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/validation.js +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/yargs.d.ts +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/yargs.js +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/yerror.d.ts +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/build/lib/yerror.js +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/index.js +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/be.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/de.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/en.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/es.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/fi.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/fr.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/hi.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/hu.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/id.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/it.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/ja.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/ko.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/nb.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/nl.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/nn.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/pirate.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/pl.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/pt.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/pt_BR.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/ru.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/th.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/tr.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/zh_CN.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/locales/zh_TW.json +0 -0
- /package/node_modules/{cliui → qrcode/node_modules/yargs/node_modules/cliui}/LICENSE.txt +0 -0
- /package/node_modules/{cliui → qrcode/node_modules/yargs/node_modules/cliui}/README.md +0 -0
- /package/node_modules/{cliui → qrcode/node_modules/yargs/node_modules/cliui}/index.js +0 -0
- /package/node_modules/{string-width → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width}/index.d.ts +0 -0
- /package/node_modules/{string-width → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width}/index.js +0 -0
- /package/node_modules/{ansi-regex → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width}/license +0 -0
- /package/node_modules/{emoji-regex → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/emoji-regex}/LICENSE-MIT.txt +0 -0
- /package/node_modules/{emoji-regex → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/emoji-regex}/README.md +0 -0
- /package/node_modules/{emoji-regex → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/emoji-regex}/es2015/index.js +0 -0
- /package/node_modules/{emoji-regex → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/emoji-regex}/es2015/text.js +0 -0
- /package/node_modules/{emoji-regex → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/emoji-regex}/index.d.ts +0 -0
- /package/node_modules/{emoji-regex → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/emoji-regex}/index.js +0 -0
- /package/node_modules/{emoji-regex → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/emoji-regex}/package.json +0 -0
- /package/node_modules/{emoji-regex → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/emoji-regex}/text.js +0 -0
- /package/node_modules/{is-fullwidth-code-point → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/is-fullwidth-code-point}/index.d.ts +0 -0
- /package/node_modules/{is-fullwidth-code-point → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/is-fullwidth-code-point}/index.js +0 -0
- /package/node_modules/{ansi-styles → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/is-fullwidth-code-point}/license +0 -0
- /package/node_modules/{is-fullwidth-code-point → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/is-fullwidth-code-point}/package.json +0 -0
- /package/node_modules/{is-fullwidth-code-point → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/is-fullwidth-code-point}/readme.md +0 -0
- /package/node_modules/{strip-ansi → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/strip-ansi}/index.d.ts +0 -0
- /package/node_modules/{strip-ansi → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/strip-ansi}/index.js +0 -0
- /package/node_modules/{camelcase → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/strip-ansi}/license +0 -0
- /package/node_modules/{ansi-regex → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/strip-ansi/node_modules/ansi-regex}/index.d.ts +0 -0
- /package/node_modules/{ansi-regex → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/strip-ansi/node_modules/ansi-regex}/index.js +0 -0
- /package/node_modules/{find-up → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/strip-ansi/node_modules/ansi-regex}/license +0 -0
- /package/node_modules/{ansi-regex → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/strip-ansi/node_modules/ansi-regex}/package.json +0 -0
- /package/node_modules/{ansi-regex → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/strip-ansi/node_modules/ansi-regex}/readme.md +0 -0
- /package/node_modules/{strip-ansi → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/strip-ansi}/package.json +0 -0
- /package/node_modules/{strip-ansi → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/strip-ansi}/readme.md +0 -0
- /package/node_modules/{string-width → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width}/package.json +0 -0
- /package/node_modules/{string-width → qrcode/node_modules/yargs/node_modules/cliui/node_modules/string-width}/readme.md +0 -0
- /package/node_modules/{is-fullwidth-code-point → qrcode/node_modules/yargs/node_modules/cliui/node_modules/strip-ansi}/license +0 -0
- /package/node_modules/{locate-path → qrcode/node_modules/yargs/node_modules/cliui/node_modules/strip-ansi/node_modules/ansi-regex}/license +0 -0
- /package/node_modules/{wrap-ansi → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi}/index.js +0 -0
- /package/node_modules/{p-limit → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi}/license +0 -0
- /package/node_modules/{ansi-styles → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/ansi-styles}/index.d.ts +0 -0
- /package/node_modules/{ansi-styles → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/ansi-styles}/index.js +0 -0
- /package/node_modules/{p-locate → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/ansi-styles}/license +0 -0
- /package/node_modules/{color-convert → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/ansi-styles/node_modules/color-convert}/LICENSE +0 -0
- /package/node_modules/{color-convert → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/ansi-styles/node_modules/color-convert}/README.md +0 -0
- /package/node_modules/{color-convert → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/ansi-styles/node_modules/color-convert}/conversions.js +0 -0
- /package/node_modules/{color-convert → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/ansi-styles/node_modules/color-convert}/index.js +0 -0
- /package/node_modules/{color-name → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/ansi-styles/node_modules/color-convert/node_modules/color-name}/LICENSE +0 -0
- /package/node_modules/{color-name → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/ansi-styles/node_modules/color-convert/node_modules/color-name}/README.md +0 -0
- /package/node_modules/{color-name → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/ansi-styles/node_modules/color-convert/node_modules/color-name}/index.js +0 -0
- /package/node_modules/{color-name → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/ansi-styles/node_modules/color-convert/node_modules/color-name}/package.json +0 -0
- /package/node_modules/{color-convert → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/ansi-styles/node_modules/color-convert}/package.json +0 -0
- /package/node_modules/{color-convert → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/ansi-styles/node_modules/color-convert}/route.js +0 -0
- /package/node_modules/{ansi-styles → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/ansi-styles}/package.json +0 -0
- /package/node_modules/{ansi-styles → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/ansi-styles}/readme.md +0 -0
- /package/node_modules/{p-try → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width}/license +0 -0
- /package/node_modules/{path-exists → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/is-fullwidth-code-point}/license +0 -0
- /package/node_modules/{string-width → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/strip-ansi}/license +0 -0
- /package/node_modules/{strip-ansi → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/string-width/node_modules/strip-ansi/node_modules/ansi-regex}/license +0 -0
- /package/node_modules/{wrap-ansi → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi/node_modules/strip-ansi}/license +0 -0
- /package/node_modules/{wrap-ansi → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi}/package.json +0 -0
- /package/node_modules/{wrap-ansi → qrcode/node_modules/yargs/node_modules/cliui/node_modules/wrap-ansi}/readme.md +0 -0
- /package/node_modules/{cliui → qrcode/node_modules/yargs/node_modules/cliui}/package.json +0 -0
- /package/node_modules/{decamelize → qrcode/node_modules/yargs/node_modules/decamelize}/index.js +0 -0
- /package/node_modules/{decamelize → qrcode/node_modules/yargs/node_modules/decamelize}/license +0 -0
- /package/node_modules/{decamelize → qrcode/node_modules/yargs/node_modules/decamelize}/package.json +0 -0
- /package/node_modules/{decamelize → qrcode/node_modules/yargs/node_modules/decamelize}/readme.md +0 -0
- /package/node_modules/{find-up → qrcode/node_modules/yargs/node_modules/find-up}/index.d.ts +0 -0
- /package/node_modules/{find-up → qrcode/node_modules/yargs/node_modules/find-up}/index.js +0 -0
- /package/node_modules/{locate-path → qrcode/node_modules/yargs/node_modules/find-up/node_modules/locate-path}/index.d.ts +0 -0
- /package/node_modules/{locate-path → qrcode/node_modules/yargs/node_modules/find-up/node_modules/locate-path}/index.js +0 -0
- /package/node_modules/{p-locate → qrcode/node_modules/yargs/node_modules/find-up/node_modules/locate-path/node_modules/p-locate}/index.d.ts +0 -0
- /package/node_modules/{p-locate → qrcode/node_modules/yargs/node_modules/find-up/node_modules/locate-path/node_modules/p-locate}/index.js +0 -0
- /package/node_modules/{p-limit → qrcode/node_modules/yargs/node_modules/find-up/node_modules/locate-path/node_modules/p-locate/node_modules/p-limit}/index.d.ts +0 -0
- /package/node_modules/{p-limit → qrcode/node_modules/yargs/node_modules/find-up/node_modules/locate-path/node_modules/p-locate/node_modules/p-limit}/index.js +0 -0
- /package/node_modules/{p-try → qrcode/node_modules/yargs/node_modules/find-up/node_modules/locate-path/node_modules/p-locate/node_modules/p-limit/node_modules/p-try}/index.d.ts +0 -0
- /package/node_modules/{p-try → qrcode/node_modules/yargs/node_modules/find-up/node_modules/locate-path/node_modules/p-locate/node_modules/p-limit/node_modules/p-try}/index.js +0 -0
- /package/node_modules/{p-try → qrcode/node_modules/yargs/node_modules/find-up/node_modules/locate-path/node_modules/p-locate/node_modules/p-limit/node_modules/p-try}/package.json +0 -0
- /package/node_modules/{p-try → qrcode/node_modules/yargs/node_modules/find-up/node_modules/locate-path/node_modules/p-locate/node_modules/p-limit/node_modules/p-try}/readme.md +0 -0
- /package/node_modules/{p-limit → qrcode/node_modules/yargs/node_modules/find-up/node_modules/locate-path/node_modules/p-locate/node_modules/p-limit}/package.json +0 -0
- /package/node_modules/{p-limit → qrcode/node_modules/yargs/node_modules/find-up/node_modules/locate-path/node_modules/p-locate/node_modules/p-limit}/readme.md +0 -0
- /package/node_modules/{p-locate → qrcode/node_modules/yargs/node_modules/find-up/node_modules/locate-path/node_modules/p-locate}/package.json +0 -0
- /package/node_modules/{p-locate → qrcode/node_modules/yargs/node_modules/find-up/node_modules/locate-path/node_modules/p-locate}/readme.md +0 -0
- /package/node_modules/{locate-path → qrcode/node_modules/yargs/node_modules/find-up/node_modules/locate-path}/package.json +0 -0
- /package/node_modules/{locate-path → qrcode/node_modules/yargs/node_modules/find-up/node_modules/locate-path}/readme.md +0 -0
- /package/node_modules/{path-exists → qrcode/node_modules/yargs/node_modules/find-up/node_modules/path-exists}/index.d.ts +0 -0
- /package/node_modules/{path-exists → qrcode/node_modules/yargs/node_modules/find-up/node_modules/path-exists}/index.js +0 -0
- /package/node_modules/{path-exists → qrcode/node_modules/yargs/node_modules/find-up/node_modules/path-exists}/package.json +0 -0
- /package/node_modules/{path-exists → qrcode/node_modules/yargs/node_modules/find-up/node_modules/path-exists}/readme.md +0 -0
- /package/node_modules/{find-up → qrcode/node_modules/yargs/node_modules/find-up}/package.json +0 -0
- /package/node_modules/{find-up → qrcode/node_modules/yargs/node_modules/find-up}/readme.md +0 -0
- /package/node_modules/{get-caller-file → qrcode/node_modules/yargs/node_modules/get-caller-file}/LICENSE.md +0 -0
- /package/node_modules/{get-caller-file → qrcode/node_modules/yargs/node_modules/get-caller-file}/README.md +0 -0
- /package/node_modules/{get-caller-file → qrcode/node_modules/yargs/node_modules/get-caller-file}/index.d.ts +0 -0
- /package/node_modules/{get-caller-file → qrcode/node_modules/yargs/node_modules/get-caller-file}/index.js +0 -0
- /package/node_modules/{get-caller-file → qrcode/node_modules/yargs/node_modules/get-caller-file}/index.js.map +0 -0
- /package/node_modules/{get-caller-file → qrcode/node_modules/yargs/node_modules/get-caller-file}/package.json +0 -0
- /package/node_modules/{require-directory → qrcode/node_modules/yargs/node_modules/require-directory}/.jshintrc +0 -0
- /package/node_modules/{require-directory → qrcode/node_modules/yargs/node_modules/require-directory}/.npmignore +0 -0
- /package/node_modules/{require-directory → qrcode/node_modules/yargs/node_modules/require-directory}/.travis.yml +0 -0
- /package/node_modules/{require-directory → qrcode/node_modules/yargs/node_modules/require-directory}/LICENSE +0 -0
- /package/node_modules/{require-directory → qrcode/node_modules/yargs/node_modules/require-directory}/README.markdown +0 -0
- /package/node_modules/{require-directory → qrcode/node_modules/yargs/node_modules/require-directory}/index.js +0 -0
- /package/node_modules/{require-directory → qrcode/node_modules/yargs/node_modules/require-directory}/package.json +0 -0
- /package/node_modules/{require-main-filename → qrcode/node_modules/yargs/node_modules/require-main-filename}/LICENSE.txt +0 -0
- /package/node_modules/{require-main-filename → qrcode/node_modules/yargs/node_modules/require-main-filename}/README.md +0 -0
- /package/node_modules/{require-main-filename → qrcode/node_modules/yargs/node_modules/require-main-filename}/index.js +0 -0
- /package/node_modules/{require-main-filename → qrcode/node_modules/yargs/node_modules/require-main-filename}/package.json +0 -0
- /package/node_modules/{set-blocking → qrcode/node_modules/yargs/node_modules/set-blocking}/LICENSE.txt +0 -0
- /package/node_modules/{set-blocking → qrcode/node_modules/yargs/node_modules/set-blocking}/README.md +0 -0
- /package/node_modules/{set-blocking → qrcode/node_modules/yargs/node_modules/set-blocking}/index.js +0 -0
- /package/node_modules/{set-blocking → qrcode/node_modules/yargs/node_modules/set-blocking}/package.json +0 -0
- /package/node_modules/{which-module → qrcode/node_modules/yargs/node_modules/which-module}/LICENSE +0 -0
- /package/node_modules/{which-module → qrcode/node_modules/yargs/node_modules/which-module}/README.md +0 -0
- /package/node_modules/{which-module → qrcode/node_modules/yargs/node_modules/which-module}/index.js +0 -0
- /package/node_modules/{which-module → qrcode/node_modules/yargs/node_modules/which-module}/package.json +0 -0
- /package/node_modules/{y18n → qrcode/node_modules/yargs/node_modules/y18n}/LICENSE +0 -0
- /package/node_modules/{y18n → qrcode/node_modules/yargs/node_modules/y18n}/README.md +0 -0
- /package/node_modules/{y18n → qrcode/node_modules/yargs/node_modules/y18n}/index.js +0 -0
- /package/node_modules/{y18n → qrcode/node_modules/yargs/node_modules/y18n}/package.json +0 -0
- /package/node_modules/{yargs-parser → qrcode/node_modules/yargs/node_modules/yargs-parser}/LICENSE.txt +0 -0
- /package/node_modules/{yargs-parser → qrcode/node_modules/yargs/node_modules/yargs-parser}/README.md +0 -0
- /package/node_modules/{yargs-parser → qrcode/node_modules/yargs/node_modules/yargs-parser}/index.js +0 -0
- /package/node_modules/{yargs-parser → qrcode/node_modules/yargs/node_modules/yargs-parser}/lib/tokenize-arg-string.js +0 -0
- /package/node_modules/{camelcase → qrcode/node_modules/yargs/node_modules/yargs-parser/node_modules/camelcase}/index.d.ts +0 -0
- /package/node_modules/{camelcase → qrcode/node_modules/yargs/node_modules/yargs-parser/node_modules/camelcase}/index.js +0 -0
- /package/node_modules/{camelcase → qrcode/node_modules/yargs/node_modules/yargs-parser/node_modules/camelcase}/package.json +0 -0
- /package/node_modules/{camelcase → qrcode/node_modules/yargs/node_modules/yargs-parser/node_modules/camelcase}/readme.md +0 -0
- /package/node_modules/{yargs-parser → qrcode/node_modules/yargs/node_modules/yargs-parser}/package.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/package.json +0 -0
- /package/node_modules/{yargs → qrcode/node_modules/yargs}/yargs.js +0 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{createHash as g}from"node:crypto";import{isRoomRuntimeAdapter as p}from"@shennian/wire";import{PublicAgentClient as u}from"../agents/public-agent-client.js";import{resolveManagedAgentPolicy as f}from"./activation-service.js";import{buildManagedAgentPermissionPrompt as y,MANAGED_ROOM_POLICY_VERSION as P}from"./managed-prompt-composer.js";async function C(i,s={list:()=>new u().list(),resolvePolicy:f}){const m=await s.list();if(!Array.isArray(m.agents))throw new Error("managed_agent_context_unavailable");const e=m.agents.find(r=>r.sessions?.some(c=>c.id===i)),n=e?.sessions.find(r=>r.id===i);if(!e||!n)return null;if(n.room||e.status!=="active"||n.status==="failed"||n.machineId!==e.machineId||!e.runtimeAdapter||!p(e.runtimeAdapter)||!e.workDir||!e.permissionPolicy)throw new Error("managed_agent_context_unavailable");const o=await s.resolvePolicy({registration:{runtimeAdapter:e.runtimeAdapter},permissionPolicy:e.permissionPolicy,permissionConfirmation:e.permissionConfirmation??null,workDir:e.workDir}),d=[`[\u795E\u5FF5\u81EA\u7528\u667A\u80FD\u4F53\u5BF9\u8BDD]
|
|
2
|
+
\u8FD9\u662F\u521B\u5EFA\u8005\u4E0E\u667A\u80FD\u4F53\u7684\u79C1\u6709\u5BF9\u8BDD\uFF0C\u4E0D\u5C5E\u4E8E\u4EFB\u4F55\u7FA4\u804A\u3002\u6CA1\u6709\u7FA4\u804A\u8BFB\u53D6\u3001\u53D1\u9001\u6216\u6210\u5458\u7BA1\u7406\u6743\u9650\u3002\u4E0D\u5F97\u731C\u6D4B\u6216\u5C55\u793A\u5185\u90E8\u6807\u8BC6\u6216\u51ED\u636E\u3002`,y({requestedPolicy:o.requestedPolicy,enforcement:o.enforcement,resolvedWorkDir:o.adapterPolicy.workDir}),e.systemPrompt?.trim()?`[\u667A\u80FD\u4F53\u79C1\u6709\u7CFB\u7EDF\u63D0\u793A\u8BCD]
|
|
3
|
+
${e.systemPrompt.trim()}`:""].filter(Boolean).join(`
|
|
4
|
+
|
|
5
|
+
`),t=r=>g("sha256").update(r).digest("hex"),l=e.sessionMode==="manager"?"manager":"standard",a=l==="manager"?e.managerConfig:null;return{standalone:!0,agentType:e.runtimeAdapter,effectiveModelId:n.modelId??e.modelId,workDir:o.adapterPolicy.workDir,agentSessionId:`managed:${i}`,systemPrompt:d,sessionMode:l,managerConfig:a,managerDefaultWorkerAgentType:a?.defaultWorkerAgentType??null,managerDefaultWorkerModelId:a?.defaultWorkerModelId??null,roomContextRegistryKey:"",managedRoomContextToken:"",managedAgentPolicy:o,managedRoomPromptSnapshot:{agentConfigurationVersion:e.configurationVersion,providerBaseVersion:"provider-owned",managedRoomPolicyVersion:P,sessionModeInstructionsHash:null,agentSystemPromptHash:e.systemPrompt?t(e.systemPrompt):null,runtimePermissionPolicyHash:t(JSON.stringify({requestedPolicy:o.requestedPolicy,enforcement:o.enforcement})),resolvedWorkDirHash:t(o.adapterPolicy.workDir),enforcementLevel:o.enforcement.level,trustedRoomContextHash:t(""),allowedRoomOperations:[]}}}export{C as prepareStandaloneAgentTurn};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash as u}from"node:crypto";import{buildManagedAgentPermissionPrompt as g}from"../../room/managed-prompt-composer.js";import{configureAdapterForSession as d,replaceManagedRoomContextToken as p}from"./chat-adapter-config.js";import{createActiveSession as c}from"./chat-session-lifecycle.js";import{validateManagedRoomExecutionContext as y}from"./chat.js";async function R(
|
|
1
|
+
import{createHash as u}from"node:crypto";import{buildManagedAgentPermissionPrompt as g}from"../../room/managed-prompt-composer.js";import{configureAdapterForSession as d,replaceManagedRoomContextToken as p}from"./chat-adapter-config.js";import{createActiveSession as c}from"./chat-session-lifecycle.js";import{validateManagedRoomExecutionContext as y}from"./chat.js";async function R(o,e,m=()=>{}){let a=null,s=null,i=null,r;if(e.source==="managed_room"||e.source==="managed_direct"||e.source==="manager_event"&&e.managedPolicyVersion){const n=await o.prepareManagedRecovery?.(e);if(!n)return{result:"recovery_failed",reason:"permission_context_unavailable",message:"managed recovery requires a fresh permission context"};if(n.agentType!==e.agentType||n.sessionMode!==e.sessionMode||o.resolvePath(n.workDir)!==o.resolvePath(e.workDir)||n.managedRoomPromptSnapshot.managedRoomPolicyVersion!==e.managedPolicyVersion||n.managedRoomPromptSnapshot.runtimePermissionPolicyHash!==e.managedRuntimePolicyHash)return o.revokeManagedRoomContextToken?.(n.managedRoomContextToken),{result:"recovery_failed",reason:"permission_context_unavailable",message:"managed recovery authority no longer matches the interrupted run"};if(a=n.managedAgentPolicy,e.source==="manager_event"||e.source==="managed_direct")s=n.managedRoomContextToken,i=n.systemPrompt,r={source:"managed_private",recovery:"upgrade",modelSelectionSource:"upgrade_recovery_model"};else{const l={source:"room_activation",managedAgentPolicy:n.managedAgentPolicy,managedRoomPromptSnapshot:n.managedRoomPromptSnapshot};y(l,n.systemPrompt,n.managedRoomContextToken),s=n.managedRoomContextToken,i=n.systemPrompt,r={...l,recovery:"upgrade",modelSelectionSource:"upgrade_recovery_model"}}}else if(e.source==="manager_worker"&&!e.managerWorkerNativeFull){const n=e.parentSessionId;if(a=n?o.managerRuntime?.getManagedAgentPolicyForWorker(n,e.workDir)??null:null,!a)return{result:"recovery_failed",reason:"permission_context_unavailable",message:"manager worker recovery requires the current parent policy"};if(u("sha256").update(JSON.stringify({requestedPolicy:a.requestedPolicy,enforcement:a.enforcement})).digest("hex")!==e.managedRuntimePolicyHash)return{result:"recovery_failed",reason:"permission_context_unavailable",message:"manager worker policy changed after interruption"};i=g({requestedPolicy:a.requestedPolicy,enforcement:a.enforcement,resolvedWorkDir:a.adapterPolicy.workDir})}r??={source:"upgrade_recovery",recovery:"upgrade",modelSelectionSource:"upgrade_recovery_model"};let t=o.sessions.get(e.sessionId);return t||(t=await c(o,e.sessionId,e.agentType,e.sessionMode,e.workDir,e.agentSessionId,null,null,a,e.nativeSessionVisibility)),(s||a&&(e.source==="managed_direct"||e.source==="manager_event"))&&(p(o,t,s??""),d(t.adapter,e.sessionId,e.agentType,null,null,s,a,o.managedRoomExecutor)),t.journalRunId=e.runId,t.currentRunId=e.providerRunId??`recovery:${e.runId}`,t.currentRunPhase="thinking",t.lastProviderActivityAt=Date.now(),e.agentType==="codex"&&e.deliveryMode==="external_owner_queue"&&e.agentSessionId&&e.externalRunId&&o.nativeFusion?.restoreExternalObservation({sessionId:e.sessionId,sourceSessionKey:e.agentSessionId,runId:e.externalRunId,canonicalMessageId:e.clientMessageId,createdAt:Date.parse(e.createdAt)})?{result:"reattached"}:t.adapter.recoverInterruptedRun({sessionId:e.sessionId,shennianRunId:e.runId,workDir:e.workDir,agentSessionId:e.agentSessionId,modelId:e.modelId,reasoningEffort:e.reasoningEffort,providerRunId:e.providerRunId,lastObservedEventSeq:e.lastObservedEventSeq,continueDispatchState:e.continueDispatchState,systemPrompt:i,sendContext:r,beforeContinueDispatch:m})}export{R as recoverJournaledRun};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{buildUserMessagePayload as pe}from"@shennian/wire";import{createHash as be,randomUUID as xe}from"node:crypto";import me from"node:os";import{reportLog as b}from"../../log-reporter.js";import{getPersonalSyncIdentity as $e}from"../../personal-sync/epoch.js";import{buildManagedAgentPermissionPrompt as Ce}from"../../room/managed-prompt-composer.js";import{parsePersonalAttachmentReferences as We}from"../attachment-reference.js";import{assertFinishedAttachmentReferences as qe,markAttachmentReferences as je}from"../attachment-transfer-store.js";import{requestSessionIndexPublish as
|
|
2
|
-
`):p&&v?Ce({requestedPolicy:v.requestedPolicy,enforcement:v.enforcement,resolvedWorkDir:v.adapterPolicy.workDir}):ne??null,Ee=h,C=We(t.params.attachments);C?.length&&qe(h,C);const f={text:g,attachments:C,localized:!1};let r=e.sessions.get(n);if(r){if(r.lastActiveAt=Date.now(),r.agentType!==s||(r.sessionMode??(r.agentType==="manager"?"manager":"standard"))!==S||r.workDir!==h||r.sessionScope==="steward"!==$||(r.nativeSessionVisibility??"user")!==V||JSON.stringify(r.externalChannel??null)!==JSON.stringify(x??null)){e.sessions.delete(n);try{await W(e,r)}catch{e.processedReqIds.delete(t.id)}r=void 0}else if(m&&r.agentSessionId!==m)try{await r.adapter.resume(m),r.agentSessionId=m}catch{e.sessions.delete(n);try{await W(e,r)}catch{e.processedReqIds.delete(t.id)}r=void 0}}if(!r)try{r=await Ge(e,n,s,S,h,m,x,H,v,V)}catch(a){const l=a instanceof Error&&a.message.startsWith("Unsupported agent:")?a.message:`Failed to start ${R}: ${a instanceof Error?a.message:String(a)}`;console.error(`[chat.send] start failed reqId=${t.id} sessionId=${n} agentType=${R} workDir=${h} agentSessionId=${m??""}: ${l}`),e.client.sendEvent({type:"event",event:"agent",payload:{state:"error",sessionId:n,message:l,runId:"",seq:0}}),e.processedReqIds.delete(t.id),e.client.sendRes({type:"res",id:c,ok:!1,error:l});return}const u={id:ke??`user-${t.id}`,sessionId:n,role:"user",ts:Date.now(),payload:pe(f.text,f.attachments)},re=Array.isArray(J)&&J.length>0?J.map(a=>({id:a.clientMessageId??a.id,sessionId:n,role:E==="manager_event"||t.params.scheduledDelivery===!0?"agent":"user",ts:E==="manager_event"||o?.source==="room_activation"?Date.parse(a.createdAt):u.ts,payload:pe(a.text,a.attachments)})):null,A=re??[u],L=Fe(n,u.id),se=L.state==="queued";if(L.state!=="not_found"&&!se){e.client.sendRes({type:"res",id:c,ok:!0,payload:L});return}if(ae){(o?.source==="room_activation"||o?.source==="manager_event")&&he(r.adapter,n,s,x,H,k,o.managedAgentPolicy,e.managedRoomExecutor);try{await Xe(r.adapter,f.text,y,D,f.attachments,K,N)}catch(a){e.processedReqIds.delete(t.id),e.sessions.delete(n),await W(e,r),e.client.sendRes({type:"res",id:c,ok:!1,error:a instanceof Error?a.message:String(a)});return}}b({level:"info",sessionId:n,wsEvent:"chat.send.start",metadata:{reqId:t.id,agentType:s,sessionMode:S,managerConfig:ee??null,modelId:y,managerDefaultWorkerAgentType:O??null,managerDefaultWorkerModelId:B??null,reasoningEffort:D,...o?.source==="room_activation"?{managedRoomPromptSnapshot:o.managedRoomPromptSnapshot}:{}}});const M=(a,l)=>({...$e(ye()),sessionId:n,clientMessageId:u.id,messageId:u.id,deliveryState:a,bodyRevision:l,committedAt:new Date(u.ts).toISOString()}),Q=a=>{e.nativeFusion?.registerManagedSend({sessionId:n,agentType:s,sourceAgentType:Ye(s,y),canonicalMessageId:u.id,sourceSessionKey:r.agentSessionId??m??null,text:f.text,managedEchoPolicy:a?.deliveryMode==="external_owner_queue"&&!Pe?"import_following":"suppress_following",externalRunId:a?.deliveryMode==="external_owner_queue"?`codex-external-${a.queuedSubmissionId??u.id}`:null})},ie=()=>{r.currentRunId||(r.currentRunId=`dispatch:${t.id}`,r.currentRunPhase="thinking",r.nextEventSeq=0,r.lastProviderActivityAt=Date.now())},de=()=>{if(!e.runJournal||r.journalRunId)return;const a=`run:${xe()}`;e.runJournal.begin({daemonInstallationId:ye(),sessionId:n,runId:a,clientMessageId:u.id,agentType:s,sessionMode:S,workDir:h,agentSessionId:r.agentSessionId??m??null,modelId:y??null,reasoningEffort:D??null,nativeSessionVisibility:V,providerRunId:null,source:E==="manager_event"?"manager_event":o?.source==="room_activation"?E==="managed_direct"?"managed_direct":"managed_room":p?"manager_worker":"personal",parentSessionId:p??null,managerWorkerNativeFull:U===!0,roomContextRegistryKey:typeof t.params.roomContextRegistryKey=="string"?t.params.roomContextRegistryKey:null,activationCauseMessageId:typeof t.params.activationCauseMessageId=="string"?t.params.activationCauseMessageId:null,rootCauseMessageId:typeof t.params.rootCauseMessageId=="string"?t.params.rootCauseMessageId:null,activationSequence:typeof t.params.activationSequence=="string"?t.params.activationSequence:null,activationHopCount:typeof t.params.activationHopCount=="number"?t.params.activationHopCount:null,managedPolicyVersion:o?.source==="room_activation"?o.managedRoomPromptSnapshot.managedRoomPolicyVersion:o?.source==="manager_event"?o.managedRoomPolicyVersion:null,managedRuntimePolicyHash:(o?.source==="room_activation"?o.managedRoomPromptSnapshot.runtimePermissionPolicyHash:o?.source==="manager_event"?o.managedRuntimePolicyHash:null)??(v?be("sha256").update(JSON.stringify({requestedPolicy:v.requestedPolicy,enforcement:v.enforcement})).digest("hex"):null)}),r.journalRunId=a},le=()=>{if(Q(),se){let a=0;for(const[l,d]of A.entries()){const I=w(n,d,"queued");l===0&&(a=I)}return M("queued",a)}try{Le(e,{sessionId:n,agentType:s,sessionMode:S,managerConfig:ee??null,workDir:Ee,agentSessionId:r.agentSessionId??m??null,modelId:y,managerDefaultWorkerAgentType:O??null,managerDefaultWorkerModelId:B??null});let a=0;for(const[l,d]of A.entries()){const I=re?w(n,d,"committed"):fe(n,d,"committed");l===0&&(a=I)}return je(h,C??[]),_(e.client),M("committed",a)}catch(a){throw e.nativeFusion?.cancelManagedSend?.(u.id),a}},ce=a=>{r.journalRunId&&e.runJournal?.update(n,r.journalRunId,{deliveryMode:a?.deliveryMode==="external_owner_queue"?"external_owner_queue":"direct",externalRunId:a?.deliveryMode==="external_owner_queue"?`codex-external-${a.queuedSubmissionId??u.id}`:null})},ue=a=>{r.currentRunId||(r.nextEventSeq=0),ce(a),Q(a);const l=a?.deliveryMode==="external_owner_queue"?"queued":"executing";let d=0;for(const[I,T]of A.entries()){const P=w(n,T,l);I===0&&(d=P)}return _(e.client),M(l,d)},Y=async(a,l)=>{e.nativeFusion?.cancelManagedSend?.(u.id);const d=_e(s,a);if(console.error(`[chat.send] send failed reqId=${t.id} sessionId=${n} agentType=${R} workDir=${h} agentSessionId=${r.agentSessionId??m??""}: ${d}`),r.adapter.hasPendingAuthenticationRetry?.()===!0){l&&e.client.sendRes({type:"res",id:c,ok:!0,payload:M("queued",0)});return}e.sessions.delete(n),r.journalRunId&&(e.runJournal?.update(n,r.journalRunId,{phase:"terminal"}),e.runJournal?.remove(n,r.journalRunId),e.recoveryBarrier?.end(n),r.journalRunId=null);try{await W(e,r)}catch{}if(e.client.sendEvent({type:"event",event:"agent",payload:{state:"error",sessionId:n,message:d,runId:"",seq:0}}),!l){const T={id:`agent-error-${t.id}-${Date.now()}`,sessionId:n,role:"agent",ts:Date.now(),payload:d};fe(n,T),_(e.client)}l&&(e.processedReqIds.delete(t.id),e.client.sendRes({type:"res",id:c,ok:!1,error:d}))};if(ae){try{le()}catch(d){e.processedReqIds.delete(t.id),e.client.sendRes({type:"res",id:c,ok:!1,error:`Durable message commit failed: ${d instanceof Error?d.message:String(d)}`});return}de(),ie();let a;try{(o?.source==="room_activation"||o?.source==="manager_event")&&(Ie(e,r,k),i());const d=f.attachments;p&&e.managerRuntime?.prepareWorkerTurnOrigin(n,z),a=await Se(r.adapter,f.text,y,D,d,K,N),b({level:"info",sessionId:n,wsEvent:"chat.send.done",metadata:{reqId:t.id}})}catch(d){if(p&&e.managerRuntime?.prepareWorkerTurnOrigin(n),r.adapter.hasPendingAuthenticationRetry?.()){let P=0;for(const[Z,G]of A.entries()){const Te=w(n,G,"queued");Z===0&&(P=Te)}_(e.client),await Y(d,!1),e.client.sendRes({type:"res",id:c,ok:!0,payload:M("queued",P)});return}let I=0;for(const[P,Z]of A.entries()){const G=w(n,Z,"failed");P===0&&(I=G)}_(e.client);const T=_e(s,d);await Y(d,!1),e.client.sendRes({type:"res",id:c,ok:!0,payload:{...M("failed",I),failureMessage:T}});return}const l=ue(a??void 0);e.client.sendRes({type:"res",id:c,ok:!0,payload:{...l,...f.localized?{localizedAttachments:!0}:{},...a?.deliveryMode==="external_owner_queue"?{queued:!0,deliveryMode:a.deliveryMode,queuedSubmissionId:a.queuedSubmissionId}:{}}}),b({level:"info",sessionId:n,wsEvent:"chat.send.res",metadata:{reqId:t.id,ok:!0}});return}let ge;try{ge=le()}catch(a){e.processedReqIds.delete(t.id),e.client.sendRes({type:"res",id:c,ok:!1,error:`Durable message commit failed: ${a instanceof Error?a.message:String(a)}`});return}de(),ie(),(o?.source==="room_activation"||o?.source==="manager_event")&&(he(r.adapter,n,s,x,H,k,o.managedAgentPolicy,e.managedRoomExecutor),Ie(e,r,k),i()),ue(),e.client.sendRes({type:"res",id:c,ok:!0,payload:{...ge,...f.localized?{localizedAttachments:!0}:{}}}),b({level:"info",sessionId:n,wsEvent:"chat.send.res",metadata:{reqId:t.id,ok:!0}});const De=f.attachments;p&&e.managerRuntime?.prepareWorkerTurnOrigin(n,z),Se(r.adapter,f.text,y,D,De,K,N).then(a=>{if(a?.deliveryMode==="external_owner_queue"){ce(a),Q(a);for(const l of A)w(n,l,"queued");_(e.client)}b({level:"info",sessionId:n,wsEvent:"chat.send.done",metadata:{reqId:t.id}})}).catch(a=>{p&&e.managerRuntime?.prepareWorkerTurnOrigin(n),w(n,u,r.adapter.hasPendingAuthenticationRetry?.()?"queued":"failed"),_(e.client),Y(a,!1)})}const tn=2e4;async function on(e,t){let o;const i=new Promise(n=>{o=setTimeout(()=>n("timed_out"),t)});try{return await Promise.race([e.adapter.stop().then(()=>"stopped"),i])}finally{clearTimeout(o)}}async function Pn(e,t,o=tn){const{sessionId:i,discardPending:n}=t.params,g=e.sessions.get(i);if(g){g.journalRunId&&e.runJournal?.markAborted(i,g.journalRunId),Re(e,g);let R;try{R=await on(g,o)}catch{e.client.sendRes({type:"res",id:t.id,ok:!1,error:"agent_stop_failed"});return}const q=g.currentRunId;nn(e,i),R==="timed_out"&&(e.sessions.delete(i),g.adapter.removeAllListeners(),g.adapter.stop().catch(()=>{}),console.error(`[chat.abort] agent did not stop within ${o}ms; ended the run by force sessionId=${i}`),w(i,{id:`stop-forced-${q??t.id}`,sessionId:i,role:"agent",ts:Date.now(),payload:"AI \u6CA1\u6709\u54CD\u5E94\u201C\u505C\u6B62\u201D\u8BF7\u6C42\uFF0C\u795E\u5FF5\u5DF2\u5F3A\u5236\u7ED3\u675F\u8FD9\u4E00\u8F6E\u3002\u53EF\u4EE5\u76F4\u63A5\u53D1\u9001\u65B0\u6D88\u606F\u7EE7\u7EED\uFF1B\u5982\u679C\u53CD\u590D\u51FA\u73B0\uFF0C\u8BF7\u68C0\u67E5\u8FD9\u53F0\u7535\u8111\u4E0A\u8BE5 AI \u7684\u8FD0\u884C\u72B6\u6001\u3002"}),_(e.client)),e.activityPublisher?.publish(i,null)}n===!0&&e.chatQueue?.purgeSession(i),e.client.sendRes({type:"res",id:t.id,ok:!0})}export{tn as STOP_TIMEOUT_MS,Pn as handleChatAbort,Mn as handleChatSend,Tn as sendSessionUpdateEvent,bn as validateManagedRoomExecutionContext};
|
|
1
|
+
import{buildUserMessagePayload as pe}from"@shennian/wire";import{createHash as be,randomUUID as xe}from"node:crypto";import me from"node:os";import{reportLog as b}from"../../log-reporter.js";import{getPersonalSyncIdentity as $e}from"../../personal-sync/epoch.js";import{buildManagedAgentPermissionPrompt as Ce}from"../../room/managed-prompt-composer.js";import{parsePersonalAttachmentReferences as We}from"../attachment-reference.js";import{assertFinishedAttachmentReferences as qe,markAttachmentReferences as je}from"../attachment-transfer-store.js";import{requestSessionIndexPublish as w}from"../index-publisher.js";import{isTrustedManagerEvent as Oe}from"../manager-event-authority.js";import{mergeProjectedSessions as Be}from"../projection.js";import{appendMessage as fe,getDaemonInstallationId as ye,getMessageDeliveryStatus as Fe,listSessionRecords as Je,recordSession as ze,upsertMessage as k}from"../store.js";import{STEWARD_SYSTEM_PROMPT as Ue,isStewardSessionId as ee,pinStewardWorkDir as ve}from"../../steward/session.js";import{rememberStewardTurn as He,takeStewardHandover as Ne}from"../../steward/failover.js";import{configureAdapterForSession as he,maybeResolveClaudeImportedWorkDir as Ve,replaceManagedRoomContextToken as Ie,revokeManagedRoomContextToken as Re}from"./chat-adapter-config.js";import{resolveNativeSessionVisibility as Ke,sendSessionUpdateEvent as Le,validateManagedRoomExecutionContext as Qe}from"./chat-context.js";import{getNativeSourceAgentType as Ye}from"./chat-events.js";import{noteRunActivity as Ze}from"../run-stall.js";import{createActiveSession as Ge,disposeSession as W,prepareAdapterTurn as Xe,rememberProcessedReqId as en,sendAdapterTurn as _e}from"./chat-session-lifecycle.js";import{sendSessionUpdateEvent as Tn,validateManagedRoomExecutionContext as bn}from"./chat-context.js";function Se(e,t){return`Agent send failed: ${t instanceof Error?t.message:String(t)}`}function nn(e,t){const o=e.sessions.get(t),i=o?.currentRunId;if(!o||!i)return;const n=o.nextEventSeq;e.runTextAcc.delete(`${t}:${i}`),Re(e,o),o.pendingTextEvent=null,Ze(t,o,!0),o.currentRunId=null,o.currentRunPhase=null,o.nextEventSeq=0,o.heartbeatTimer&&(clearInterval(o.heartbeatTimer),o.heartbeatTimer=null),e.client.sendAgentEvent({type:"event",event:"agent",payload:{state:"aborted",sessionId:t,runId:i,seq:n},seq:n,id:`agent-evt-${i}-${n}`}),o.journalRunId&&(e.runJournal?.remove(t,o.journalRunId),e.recoveryBarrier?.end(t),o.journalRunId=null),e.chatQueue?.noteTerminal(t)}async function Mn(e,t,o){const i=o?t.params.managedRoomContextToken??null:null;let n=!1;try{await an(e,t,o,()=>{n=!0})}finally{i&&!n&&e.revokeManagedRoomContextToken?.(i)}}async function an(e,t,o,i){if(e.processedReqIds.has(t.id)){e.client.sendRes({type:"res",id:t.id,ok:!0});return}const{sessionId:n,text:g,agentType:R,sessionMode:q,managerConfig:ne,workDir:we,agentSessionId:m,modelId:y,modelSelectionSource:j,systemPrompt:O,managerDefaultWorkerAgentType:B,managerDefaultWorkerModelId:F,reasoningEffort:J,clientMessageId:ke,sessionListProjection:Ae,waitForDispatch:ae,responseId:Me,managedRoomContextToken:_,suppressExternalOwnerEcho:Pe,queuedBatchItems:z,managedWorkerParentSessionId:p,managerWorkerRoomOrigin:U,managerWorkerNativeFull:H,managedRecoverySource:E}=t.params,c=Me||t.id,te=t.params;if((te.managerEventId||te.managerEventRoomOrigin||p||U||H||E)&&!Oe(t))throw new Error("manager_event_source_untrusted");Be(Ae);const x=null,N="";if(o?.source==="room_activation"&&(Qe(o,O,_),R==="manager"))throw new Error("managed_agent_manager_mode_unsupported");if(o?.source==="manager_event"){if(!o.managedAgentPolicy)throw new Error("managed_agent_policy_missing");if(o.standalone){if(_||!O?.trim())throw new Error("standalone_agent_context_invalid")}else if(!_||!/^mrc_[A-Za-z0-9_-]{43}$/.test(_))throw new Error("managed_room_context_unavailable")}if(en(e,t.id),!n||!g){e.processedReqIds.delete(t.id),e.client.sendRes({type:"res",id:c,ok:!1,error:"sessionId and text are required"});return}if(e.recoveryBarrier?.isDispatchFrozen()){e.processedReqIds.delete(t.id),e.client.sendRes({type:"res",id:c,ok:!1,error:"upgrade_in_progress"});return}e.recoveryBarrier?.isRecovering(n)&&await e.recoveryBarrier.wait(n);const s=R,S=s==="manager"||q==="manager"?"manager":"standard";S==="manager"&&e.managerRuntime?.setManagerWorkerDefaults(n,B??null,F??null);const D=(s==="claude"||s==="codex"||s==="workbuddy"||s==="pi-coding-agent"||s.startsWith("acp:"))&&typeof J=="string"&&J.trim()?J.trim():void 0,V=o?.source==="room_activation"?{source:"room_activation",...s==="pi-coding-agent"?{modelSelectionSource:j??(y?"request_model":"pi_default_model")}:{}}:o?.source==="manager_event"?{source:"managed_private",...s==="pi-coding-agent"?{modelSelectionSource:j??(y?"request_model":"pi_default_model")}:{}}:s==="pi-coding-agent"?{source:"personal",modelSelectionSource:j??(y?"request_model":"pi_default_model")}:void 0,oe=ee(n)||t.params.sessionScope==="steward",h=oe?ve():e.resolvePath(Ve(s,we||me.homedir(),m)||me.homedir()),v=o?.managedAgentPolicy??(p?e.managerRuntime?.getManagedAgentPolicyForWorker(p,h)??null:null);if(p&&!H&&!v)throw new Error("managed_worker_permission_context_unavailable");const $=oe;if($){if(S!=="standard")throw new Error("steward_session_mode_invalid");if(!ee(n)&&Je().some(a=>a.sessionId===n))throw new Error("steward_scope_conflict");ee(n)||ze({sessionId:n,agentType:s,workDir:ve(),sessionScope:"steward"})}const K=Ke(n,s,S,!(o?.source==="manager_event"&&o.standalone)&&!!(v||p||o));$&&He(n,String(g??""));const L=$?[Ue,Ne(n)].filter(Boolean).join(`
|
|
2
|
+
`):p&&v?Ce({requestedPolicy:v.requestedPolicy,enforcement:v.enforcement,resolvedWorkDir:v.adapterPolicy.workDir}):O??null,Ee=h,C=We(t.params.attachments);C?.length&&qe(h,C);const f={text:g,attachments:C,localized:!1};let r=e.sessions.get(n);if(r){if(r.lastActiveAt=Date.now(),r.agentType!==s||(r.sessionMode??(r.agentType==="manager"?"manager":"standard"))!==S||r.workDir!==h||r.sessionScope==="steward"!==$||(r.nativeSessionVisibility??"user")!==K||JSON.stringify(r.externalChannel??null)!==JSON.stringify(x??null)){e.sessions.delete(n);try{await W(e,r)}catch{e.processedReqIds.delete(t.id)}r=void 0}else if(m&&r.agentSessionId!==m)try{await r.adapter.resume(m),r.agentSessionId=m}catch{e.sessions.delete(n);try{await W(e,r)}catch{e.processedReqIds.delete(t.id)}r=void 0}}if(!r)try{r=await Ge(e,n,s,S,h,m,x,N,v,K)}catch(a){const l=a instanceof Error&&a.message.startsWith("Unsupported agent:")?a.message:`Failed to start ${R}: ${a instanceof Error?a.message:String(a)}`;console.error(`[chat.send] start failed reqId=${t.id} sessionId=${n} agentType=${R} workDir=${h} agentSessionId=${m??""}: ${l}`),e.client.sendEvent({type:"event",event:"agent",payload:{state:"error",sessionId:n,message:l,runId:"",seq:0}}),e.processedReqIds.delete(t.id),e.client.sendRes({type:"res",id:c,ok:!1,error:l});return}const u={id:ke??`user-${t.id}`,sessionId:n,role:"user",ts:Date.now(),payload:pe(f.text,f.attachments)},re=Array.isArray(z)&&z.length>0?z.map(a=>({id:a.clientMessageId??a.id,sessionId:n,role:E==="manager_event"||t.params.scheduledDelivery===!0?"agent":"user",ts:E==="manager_event"||o?.source==="room_activation"?Date.parse(a.createdAt):u.ts,payload:pe(a.text,a.attachments)})):null,A=re??[u],Q=Fe(n,u.id),se=Q.state==="queued";if(Q.state!=="not_found"&&!se){e.client.sendRes({type:"res",id:c,ok:!0,payload:Q});return}if(ae){(o?.source==="room_activation"||o?.source==="manager_event")&&he(r.adapter,n,s,x,N,_,o.managedAgentPolicy,e.managedRoomExecutor);try{await Xe(r.adapter,f.text,y,D,f.attachments,L,V)}catch(a){e.processedReqIds.delete(t.id),e.sessions.delete(n),await W(e,r),e.client.sendRes({type:"res",id:c,ok:!1,error:a instanceof Error?a.message:String(a)});return}}b({level:"info",sessionId:n,wsEvent:"chat.send.start",metadata:{reqId:t.id,agentType:s,sessionMode:S,managerConfig:ne??null,modelId:y,managerDefaultWorkerAgentType:B??null,managerDefaultWorkerModelId:F??null,reasoningEffort:D,...o?.source==="room_activation"?{managedRoomPromptSnapshot:o.managedRoomPromptSnapshot}:{}}});const M=(a,l)=>({...$e(ye()),sessionId:n,clientMessageId:u.id,messageId:u.id,deliveryState:a,bodyRevision:l,committedAt:new Date(u.ts).toISOString()}),Y=a=>{e.nativeFusion?.registerManagedSend({sessionId:n,agentType:s,sourceAgentType:Ye(s,y),canonicalMessageId:u.id,sourceSessionKey:r.agentSessionId??m??null,text:f.text,managedEchoPolicy:a?.deliveryMode==="external_owner_queue"&&!Pe?"import_following":"suppress_following",externalRunId:a?.deliveryMode==="external_owner_queue"?`codex-external-${a.queuedSubmissionId??u.id}`:null})},ie=()=>{r.currentRunId||(r.currentRunId=`dispatch:${t.id}`,r.currentRunPhase="thinking",r.nextEventSeq=0,r.lastProviderActivityAt=Date.now())},de=()=>{if(!e.runJournal||r.journalRunId)return;const a=`run:${xe()}`;e.runJournal.begin({daemonInstallationId:ye(),sessionId:n,runId:a,clientMessageId:u.id,agentType:s,sessionMode:S,workDir:h,agentSessionId:r.agentSessionId??m??null,modelId:y??null,reasoningEffort:D??null,nativeSessionVisibility:K,providerRunId:null,source:E==="manager_event"?"manager_event":E==="managed_direct"?"managed_direct":o?.source==="room_activation"?"managed_room":p?"manager_worker":"personal",parentSessionId:p??null,managerWorkerNativeFull:H===!0,roomContextRegistryKey:typeof t.params.roomContextRegistryKey=="string"?t.params.roomContextRegistryKey:null,activationCauseMessageId:typeof t.params.activationCauseMessageId=="string"?t.params.activationCauseMessageId:null,rootCauseMessageId:typeof t.params.rootCauseMessageId=="string"?t.params.rootCauseMessageId:null,activationSequence:typeof t.params.activationSequence=="string"?t.params.activationSequence:null,activationHopCount:typeof t.params.activationHopCount=="number"?t.params.activationHopCount:null,managedPolicyVersion:o?.source==="room_activation"?o.managedRoomPromptSnapshot.managedRoomPolicyVersion:o?.source==="manager_event"?o.managedRoomPolicyVersion:null,managedRuntimePolicyHash:(o?.source==="room_activation"?o.managedRoomPromptSnapshot.runtimePermissionPolicyHash:o?.source==="manager_event"?o.managedRuntimePolicyHash:null)??(v?be("sha256").update(JSON.stringify({requestedPolicy:v.requestedPolicy,enforcement:v.enforcement})).digest("hex"):null)}),r.journalRunId=a},le=()=>{if(Y(),se){let a=0;for(const[l,d]of A.entries()){const I=k(n,d,"queued");l===0&&(a=I)}return M("queued",a)}try{Le(e,{sessionId:n,agentType:s,sessionMode:S,managerConfig:ne??null,workDir:Ee,agentSessionId:r.agentSessionId??m??null,modelId:y,managerDefaultWorkerAgentType:B??null,managerDefaultWorkerModelId:F??null});let a=0;for(const[l,d]of A.entries()){const I=re?k(n,d,"committed"):fe(n,d,"committed");l===0&&(a=I)}return je(h,C??[]),w(e.client),M("committed",a)}catch(a){throw e.nativeFusion?.cancelManagedSend?.(u.id),a}},ce=a=>{r.journalRunId&&e.runJournal?.update(n,r.journalRunId,{deliveryMode:a?.deliveryMode==="external_owner_queue"?"external_owner_queue":"direct",externalRunId:a?.deliveryMode==="external_owner_queue"?`codex-external-${a.queuedSubmissionId??u.id}`:null})},ue=a=>{r.currentRunId||(r.nextEventSeq=0),ce(a),Y(a);const l=a?.deliveryMode==="external_owner_queue"?"queued":"executing";let d=0;for(const[I,T]of A.entries()){const P=k(n,T,l);I===0&&(d=P)}return w(e.client),M(l,d)},Z=async(a,l)=>{e.nativeFusion?.cancelManagedSend?.(u.id);const d=Se(s,a);if(console.error(`[chat.send] send failed reqId=${t.id} sessionId=${n} agentType=${R} workDir=${h} agentSessionId=${r.agentSessionId??m??""}: ${d}`),r.adapter.hasPendingAuthenticationRetry?.()===!0){l&&e.client.sendRes({type:"res",id:c,ok:!0,payload:M("queued",0)});return}e.sessions.delete(n),r.journalRunId&&(e.runJournal?.update(n,r.journalRunId,{phase:"terminal"}),e.runJournal?.remove(n,r.journalRunId),e.recoveryBarrier?.end(n),r.journalRunId=null);try{await W(e,r)}catch{}if(e.client.sendEvent({type:"event",event:"agent",payload:{state:"error",sessionId:n,message:d,runId:"",seq:0}}),!l){const T={id:`agent-error-${t.id}-${Date.now()}`,sessionId:n,role:"agent",ts:Date.now(),payload:d};fe(n,T),w(e.client)}l&&(e.processedReqIds.delete(t.id),e.client.sendRes({type:"res",id:c,ok:!1,error:d}))};if(ae){try{le()}catch(d){e.processedReqIds.delete(t.id),e.client.sendRes({type:"res",id:c,ok:!1,error:`Durable message commit failed: ${d instanceof Error?d.message:String(d)}`});return}de(),ie();let a;try{(o?.source==="room_activation"||o?.source==="manager_event")&&(Ie(e,r,_),i());const d=f.attachments;p&&e.managerRuntime?.prepareWorkerTurnOrigin(n,U),a=await _e(r.adapter,f.text,y,D,d,L,V),b({level:"info",sessionId:n,wsEvent:"chat.send.done",metadata:{reqId:t.id}})}catch(d){if(p&&e.managerRuntime?.prepareWorkerTurnOrigin(n),r.adapter.hasPendingAuthenticationRetry?.()){let P=0;for(const[G,X]of A.entries()){const Te=k(n,X,"queued");G===0&&(P=Te)}w(e.client),await Z(d,!1),e.client.sendRes({type:"res",id:c,ok:!0,payload:M("queued",P)});return}let I=0;for(const[P,G]of A.entries()){const X=k(n,G,"failed");P===0&&(I=X)}w(e.client);const T=Se(s,d);await Z(d,!1),e.client.sendRes({type:"res",id:c,ok:!0,payload:{...M("failed",I),failureMessage:T}});return}const l=ue(a??void 0);e.client.sendRes({type:"res",id:c,ok:!0,payload:{...l,...f.localized?{localizedAttachments:!0}:{},...a?.deliveryMode==="external_owner_queue"?{queued:!0,deliveryMode:a.deliveryMode,queuedSubmissionId:a.queuedSubmissionId}:{}}}),b({level:"info",sessionId:n,wsEvent:"chat.send.res",metadata:{reqId:t.id,ok:!0}});return}let ge;try{ge=le()}catch(a){e.processedReqIds.delete(t.id),e.client.sendRes({type:"res",id:c,ok:!1,error:`Durable message commit failed: ${a instanceof Error?a.message:String(a)}`});return}de(),ie(),(o?.source==="room_activation"||o?.source==="manager_event")&&(he(r.adapter,n,s,x,N,_,o.managedAgentPolicy,e.managedRoomExecutor),Ie(e,r,_),i()),ue(),e.client.sendRes({type:"res",id:c,ok:!0,payload:{...ge,...f.localized?{localizedAttachments:!0}:{}}}),b({level:"info",sessionId:n,wsEvent:"chat.send.res",metadata:{reqId:t.id,ok:!0}});const De=f.attachments;p&&e.managerRuntime?.prepareWorkerTurnOrigin(n,U),_e(r.adapter,f.text,y,D,De,L,V).then(a=>{if(a?.deliveryMode==="external_owner_queue"){ce(a),Y(a);for(const l of A)k(n,l,"queued");w(e.client)}b({level:"info",sessionId:n,wsEvent:"chat.send.done",metadata:{reqId:t.id}})}).catch(a=>{p&&e.managerRuntime?.prepareWorkerTurnOrigin(n),k(n,u,r.adapter.hasPendingAuthenticationRetry?.()?"queued":"failed"),w(e.client),Z(a,!1)})}const tn=2e4;async function on(e,t){let o;const i=new Promise(n=>{o=setTimeout(()=>n("timed_out"),t)});try{return await Promise.race([e.adapter.stop().then(()=>"stopped"),i])}finally{clearTimeout(o)}}async function Pn(e,t,o=tn){const{sessionId:i,discardPending:n}=t.params,g=e.sessions.get(i);if(g){g.journalRunId&&e.runJournal?.markAborted(i,g.journalRunId),Re(e,g);let R;try{R=await on(g,o)}catch{e.client.sendRes({type:"res",id:t.id,ok:!1,error:"agent_stop_failed"});return}const q=g.currentRunId;nn(e,i),R==="timed_out"&&(e.sessions.delete(i),g.adapter.removeAllListeners(),g.adapter.stop().catch(()=>{}),console.error(`[chat.abort] agent did not stop within ${o}ms; ended the run by force sessionId=${i}`),k(i,{id:`stop-forced-${q??t.id}`,sessionId:i,role:"agent",ts:Date.now(),payload:"AI \u6CA1\u6709\u54CD\u5E94\u201C\u505C\u6B62\u201D\u8BF7\u6C42\uFF0C\u795E\u5FF5\u5DF2\u5F3A\u5236\u7ED3\u675F\u8FD9\u4E00\u8F6E\u3002\u53EF\u4EE5\u76F4\u63A5\u53D1\u9001\u65B0\u6D88\u606F\u7EE7\u7EED\uFF1B\u5982\u679C\u53CD\u590D\u51FA\u73B0\uFF0C\u8BF7\u68C0\u67E5\u8FD9\u53F0\u7535\u8111\u4E0A\u8BE5 AI \u7684\u8FD0\u884C\u72B6\u6001\u3002"}),w(e.client)),e.activityPublisher?.publish(i,null)}n===!0&&e.chatQueue?.purgeSession(i),e.client.sendRes({type:"res",id:t.id,ok:!0})}export{tn as STOP_TIMEOUT_MS,Pn as handleChatAbort,Mn as handleChatSend,Tn as sendSessionUpdateEvent,bn as validateManagedRoomExecutionContext};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{localApps as s}from"../../local-apps/service.js";async function o(p,a){try{let e;a.method==="personal.apps.list"?e={apps:await s.list()}:a.method==="personal.apps.register"?e={app:await s.register(a.params)}:a.method==="personal.apps.remove"?e=await s.remove(String(a.params?.appId??"")):e=await s.request(a.params),p.client.sendRes({type:"res",id:a.id,ok:!0,payload:e})}catch(e){const t=e instanceof Error&&/^(invalid_|local_app_|service_)/.test(e.message);p.client.sendRes({type:"res",id:a.id,ok:!1,error:t?e.message:"local_service_unavailable"})}}export{o as handleLocalApps};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{personalWorkspace as o}from"../../personal-workspace/service.js";async function t(r,e){try{r.client.sendRes({type:"res",id:e.id,ok:!0,payload:o(e.params)})}catch(s){const a=s instanceof Error?s.message:"";r.client.sendRes({type:"res",id:e.id,ok:!1,error:/^personal_[a-z_]+$/.test(a)?a:"personal_directory_unavailable"})}}export{t as handlePersonalWorkspace};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import b from"node:crypto";import{getRegisteredAgents as S,unregisterAgent as k}from"../agents/adapter.js";import{resetCommandSpecCache as w}from"../agents/command-spec.js";import{loadConfig as I}from"../config/index.js";import{handleUpgradeStart as A,handleUpgradeStatus as T}from"../commands/upgrade.js";import{handleAgentsRefresh as P,handleModelsRefresh as C,refreshMachineAgents as M}from"./handlers/agents.js";import{AcpDiscoveryWatcher as x}from"../agents/acp/watcher.js";import{handleAgentCapabilitiesList as D}from"./handlers/agent-capabilities.js";import{handleAgentConfigClear as F,handleAgentConfigGet as E,handleAgentConfigTest as Q,handleAgentConfigUpsert as j}from"./handlers/agent-config.js";import{handleCodexSettings as z}from"./handlers/codex-settings.js";import{handleChatAbort as O,handleChatSend as B}from"./handlers/chat.js";import{recoverJournaledRun as H}from"./handlers/chat-recovery.js";import{handleSessionRefresh as W}from"./handlers/session-refresh.js";import{handleSessionToolDetail as _}from"./handlers/tool-detail.js";import{handleSessionTitleSet as U}from"./handlers/title.js";import{handleSessionMessageStatus as J}from"./handlers/message-status.js";import{handleAgentWorkspaceValidation as $}from"./handlers/agent-workspace-validation.js";import{handleVoiceSessionBodyWindow as V}from"./handlers/voice-window.js";import{commitStewardSay as L,commitTerminalStewardSay as N}from"./handlers/steward.js";import{handleRemoteAccessPause as G}from"./handlers/remote-access.js";import{cleanupPendingTransfers as K,handleFsLs as X,handleFsRead as Z,handleFsRename as Y,handleFsWrite as q,handleFsTransferAbort as ee,handleFsTransferChunk as se,handleFsTransferFinish as te,handleFsTransferStart as ae,handleFsExportMarkdownPdf as ne,handleFsExportMarkdownPdfSetup as re,handleFsArchiveZip as ie}from"./handlers/fs.js";import{handleRegionProbe as oe,handleRegionSwitch as ce,handleUpgradeSetPolicy as le}from"./handlers/control.js";import{ManagerRuntimeService as ue,setManagerRuntimeService as d}from"../manager/runtime.js";import{ChatQueueManager as he}from"./queue.js";import{createAuthorizedFsRoot as de,createAuthorizedFsRootAsync as me,resolveAuthorizedPath as pe,resolveAuthorizedPathAsync as ge,resolveSessionWorkDir as fe}from"../fs/boundary.js";import"../agents/claude.js";import"../agents/codex.js";import"../agents/workbuddy.js";import"../agents/gemini.js";import"../agents/cursor.js";import"../agents/opencode.js";import"../agents/pi-coding-agent.js";import"../agents/manager.js";import{registerCustomAgent as ve}from"../agents/custom.js";import{listNodeAdapters as ye}from"../adapter-kit/registry.js";import{syncNodeAdapterAgents as Re}from"../agents/node-adapter.js";import{bindManagedRoom as be,handleManagedRoomBind as Se,handleManagedRoomRestart as ke,discardPreBindingSession as we}from"./handlers/room-managed.js";import{getDaemonInstallationId as m,listSessionRecords as u,purgeCanonicalSession as Ie,purgeSessionRecord as Ae,recordSession as Te,upsertMessage as Pe}from"./store.js";import{requestSessionIndexPublish as p}from"./index-publisher.js";import{checkRunStalls as Ce}from"./run-stall.js";import{reportUpgradeAggregateMetric as Me}from"../log-reporter.js";import{PersonalHistorySubscriptions as xe}from"./history-subscriptions.js";import{sweepAttachmentTransfers as De}from"./attachment-transfer-store.js";import{NativeSourceDeletionStore as Fe}from"../native-fusion/native-source-deletions.js";import{collectLocalNativeSources as Ee}from"../native-fusion/session-native-sources.js";import{purgeToolDetails as Qe}from"./tool-detail-store.js";import{NativeSessionCleanupOutbox as je}from"./native-cleanup-outbox.js";import{assertPersonalSyncIdentity as c}from"../personal-sync/epoch.js";import{ActiveRunJournal as ze}from"./run-recovery/journal.js";import{RunRecoveryBarrier as Oe}from"./run-recovery/barrier.js";import{RunRecoveryCoordinator as Be}from"./run-recovery/coordinator.js";import{ProjectFsHandleStore as He}from"./project-fs-store.js";import{handleProjectFsRequest as We}from"./handlers/project-fs.js";import{handleAgentPermissionResponse as _e,handleAcpAgentRequest as Ue}from"./handlers/agent-control.js";import{SessionDeletionSynchronizer as Je}from"./deletion-synchronizer.js";import{dispatchManagedChat as $e,dispatchQueuedChat as Ve,interruptQueuedChat as Le}from"./queued-chat-dispatch.js";const Ne=50;import{resolveSessionWorkDir as st}from"../fs/boundary.js";function Ge(){return"\u795E\u5FF5\u5347\u7EA7\u4E2D\u65AD\u4E86\u672C\u6B21\u8FD0\u884C\u3002\u5DF2\u5B8C\u6210\u7684\u56DE\u590D\u6216\u64CD\u4F5C\u4ECD\u7136\u6709\u6548\uFF0C\u672A\u5B8C\u6210\u90E8\u5206\u53EF\u91CD\u8BD5\u3002\u539F\u4F1A\u8BDD\u5DF2\u4FDD\u7559\u3002"}class Ys{client;nativeFusion;cliVersion;upgradePolicyController;managedRoomBinder;remoteAccessPauseController;managedRoomContextRevoker;managedRoomExecutor;trustedProjectFsRequestResolver;getAgentSnapshot;scheduleHandler;getScheduleQueue(){return this.chatQueue}sessions=new Map;processedReqIds=new Set;runTextAcc=new Map;pendingTransfers=new Map;managerRuntime;chatQueue;historySubscriptions;nativeCleanupOutbox;activityProbeTimer=null;attachmentCleanupTimer=null;activeRequests=0;acpDiscoveryWatcher;runJournal;recoveryBarrier=new Oe;recoveryCoordinator;recoveryPass=null;prepareManagedRecovery;projectFsHandleStore=new He;deletionSynchronizer;constructor(e,t=null,s,n=null,r=null,o=null,h=null,g=null,f=null,v=null,y=null){this.client=e,this.nativeFusion=t,this.cliVersion=s,this.upgradePolicyController=n,this.managedRoomBinder=r,this.remoteAccessPauseController=o,this.managedRoomContextRevoker=h,this.managedRoomExecutor=g,this.trustedProjectFsRequestResolver=v,this.getAgentSnapshot=y,this.runJournal=f??new ze(m());for(const a of this.runJournal.loadPendingReconciliation().records)this.recoveryBarrier.begin(a.sessionId);this.recoveryCoordinator=new Be({journal:this.runJournal,barrier:this.recoveryBarrier,recover:(a,i)=>H(this.getRuntime(),a,i),commitTerminal:(a,i)=>this.commitRecoveryTerminal(a,i),isCanonicalTerminal:a=>{const i=u().find(R=>R.sessionId===a.sessionId),l=`terminal:${b.createHash("sha256").update(`${a.runId}\0`).digest("hex")}`;return i?.lastAttentionId===l},onOutcome:a=>Me({kind:"recovery",adapterType:a.adapterType,result:a.result,stage:a.result==="continued"?"continue":a.result==="reattached"?"reattach":a.result==="resumed"?"resume":a.result==="terminal_reconciled"?"inspect":"terminal",durationMs:a.durationMs,retries:Math.max(0,a.attempts-1),...a.reason?{errorCode:a.reason}:{}})}),this.managerRuntime=new ue({getRuntime:()=>this.getRuntime(),getAgentSnapshot:this.getAgentSnapshot??void 0,dispatchReq:a=>this.handleReq(a,{propagateErrors:!0})}),this.chatQueue=new he({getRuntime:()=>this.getRuntime(),dispatchReq:a=>this.handleReq(a),dispatchManagedReq:(a,i)=>$e(this.getRuntime(),a,i),dispatchQueuedReq:(a,i)=>Ve(this.getRuntime(),a,i),interruptQueuedSession:a=>Le(this.getRuntime(),a)}),this.deletionSynchronizer=new Je(e,a=>this.applySessionDeletion(a)),this.historySubscriptions=new xe(this.client),this.nativeCleanupOutbox=new je({logger:console.info}),this.acpDiscoveryWatcher=new x(async()=>{w(),await M(this.getRuntime())}),this.nativeFusion?.setExternalTerminalHandler?.(a=>{this.handleExternalTerminal(a)}),this.nativeFusion?.setExternalClaimHandler?.((a,i)=>{this.chatQueue.noteExternalClaim(a,i)}),this.nativeCleanupOutbox.start(),d(this.managerRuntime),this.managerRuntime.start(),this.reloadCustomAgents();try{this.acpDiscoveryWatcher.start()}catch(a){console.warn(`[acp.discovery] watcher unavailable: ${a instanceof Error?a.message:String(a)}`)}this.activityProbeTimer=setInterval(()=>{Ce(this.sessions.entries(),()=>p(this.client)),this.publishManagedActivitySnapshots().catch(a=>{console.error("[session.activity] managed probe failed",a)})},15e3),this.activityProbeTimer.unref?.(),this.attachmentCleanupTimer=setInterval(()=>{const a=new Set([...u().map(i=>i.workDir),...Array.from(this.pendingTransfers.values()).map(i=>i.rootPath)]);for(const i of a)try{De(this.resolvePath(i))}catch(l){console.error("[attachment.cleanup] failed",l instanceof Error?l.message:String(l))}},6e4),this.attachmentCleanupTimer.unref?.()}executeManagedManagerAction(e){return this.managerRuntime.executeScopedWorkerAction(e.managerSessionId,e.action,e.params,e.roomOrigin)}noteManagedRoomSendOutcome(e){for(const t of this.sessions.values()){if(t.managedRoomContextToken!==e.token)continue;const s=t.roomSendOutcome??(t.roomSendOutcome={successes:0,failureCodes:[]});e.ok?s.successes+=1:s.failureCodes.length<20&&s.failureCodes.push(e.errorCode??"managed_room_action_failed");return}}getManagedRoomActiveRunId(e,t){const s=this.sessions.get(t);if(s?.currentRunId)return s.currentRunId;for(const n of this.sessions.values())if(n.managedRoomContextToken===e)return n.currentRunId??null;return null}getRuntime(){return{client:this.client,pendingTransfers:this.pendingTransfers,processedReqIds:this.processedReqIds,reloadCustomAgents:()=>this.reloadCustomAgents(),getAgentSnapshot:this.getAgentSnapshot??void 0,resolvePath:e=>this.resolvePath(e),resolveAuthorizedPath:(e,t)=>this.resolveAuthorizedPath(e,t),resolveAuthorizedPathAsync:(e,t)=>this.resolveAuthorizedPathAsync(e,t),runTextAcc:this.runTextAcc,sessions:this.sessions,evictIdleSessions:()=>this.evictIdleSessions(),nativeFusion:this.nativeFusion,managerRuntime:this.managerRuntime,chatQueue:this.chatQueue,activityPublisher:{publish:(e,t)=>this.publishSessionActivity(e,t)},upgradePolicyController:this.upgradePolicyController,revokeManagedRoomContextToken:this.managedRoomContextRevoker,managedRoomExecutor:this.managedRoomExecutor,runJournal:this.runJournal,recoveryBarrier:this.recoveryBarrier,prepareManagedRecovery:this.prepareManagedRecovery}}async resumePendingAcpAuthentication(e){const t=[...this.sessions.values()].find(s=>s.agentType===e&&s.adapter.hasPendingAuthenticationRetry?.());return t?.adapter.resumeAfterExternalAuthentication?(await t.adapter.resumeAfterExternalAuthentication(),!0):!1}getUpgradeIdleState(){const e=[];return[...this.sessions.values()].some(t=>t.currentRunId!==null)&&e.push("active-agent-turn"),this.pendingTransfers.size>0&&e.push("file-transfer"),this.activeRequests>0&&e.push("active-daemon-request"),{idle:e.length===0,reasons:e}}bindManagedRoomFromLocal(e){return be(this.getRuntime(),this.managedRoomBinder,e)}stewardSayFromLocal(e){const t=typeof e.sessionId=="string"?e.sessionId:"",s=typeof e.text=="string"?e.text:"";return t?L(this.getRuntime(),t,s):N(this.getRuntime(),s)}prepareForUpgrade(e){this.recoveryBarrier.freezeDispatch();const t=this.runJournal.markPlannedUpgrade(e);return this.runJournal.sync(),{activeRunCount:t}}cancelUpgradePreparation(){this.recoveryBarrier.unfreezeDispatch()}async recoverInterruptedRuns(){this.recoveryPass??=this.recoveryCoordinator.recoverAll(),await this.recoveryPass}getPendingRecoveryCount(){return this.runJournal.loadPendingReconciliation().records.length}revokeProjectFsHandles(){this.projectFsHandleStore.revokeAll()}async commitRecoveryTerminal(e,t){const s=this.sessions.get(e.sessionId);s&&(s.currentRunId=null,s.currentRunPhase=null,s.journalRunId=null,s.heartbeatTimer&&(clearInterval(s.heartbeatTimer),s.heartbeatTimer=null)),this.runTextAcc.delete(`${e.sessionId}:${e.providerRunId??e.runId}`),this.publishSessionActivity(e.sessionId,null);const n=Ge();Pe(e.sessionId,{id:`upgrade-recovery-terminal-${e.runId}`,sessionId:e.sessionId,role:"agent",ts:Date.now(),payload:JSON.stringify({v:1,type:"error",content:n,error:!0,recoveryState:t.result,recoveryReason:t.reason})}),Te({sessionId:e.sessionId,agentType:e.agentType,sessionMode:e.sessionMode,workDir:e.workDir,agentSessionId:e.agentSessionId,modelId:e.modelId,status:"failed",attentionId:`upgrade-recovery:${e.runId}`,lastActivityAt:new Date().toISOString()}),this.managerRuntime.noteAgentEvent(e.sessionId,{state:"error",runId:e.providerRunId??e.runId,seq:e.lastObservedEventSeq+1,message:n}),p(this.client);const r=e.lastObservedEventSeq+1;this.client.sendAgentEvent({type:"event",event:"agent",payload:t.result==="interrupted_by_upgrade"?{state:"interrupted_by_upgrade",sessionId:e.sessionId,runId:e.providerRunId??e.runId,seq:r,reason:t.reason}:{state:"recovery_failed",sessionId:e.sessionId,runId:e.providerRunId??e.runId,seq:r,reason:t.reason,...t.message?{message:t.message}:{}},seq:r,id:`agent-recovery-terminal-${e.runId}`}),this.chatQueue.noteTerminal(e.sessionId)}setManagedRoomTurnPreparer(e){this.chatQueue.setManagedRoomTurnPreparer(e)}setManagedAgentDirectTurnPreparer(e){this.chatQueue.setManagedAgentDirectTurnPreparer(e)}setManagedRecoveryPreparer(e){this.prepareManagedRecovery=e}async enqueueManagedRoomBatch(e){const t=e.map(s=>{const n=u().find(r=>r.sessionId===s.params.sessionId);return{context:s.context,params:{...s.params,modelId:n?.modelId??s.params.modelId,sessionMode:n?.sessionMode??s.params.sessionMode,managerConfig:n?.managerConfig??s.params.managerConfig,managerDefaultWorkerAgentType:n?.managerDefaultWorkerAgentType??s.params.managerDefaultWorkerAgentType,managerDefaultWorkerModelId:n?.managerDefaultWorkerModelId??s.params.managerDefaultWorkerModelId}}});await this.chatQueue.enqueueManagedRoomBatch(t)}async retireManagedRoomSession(e){this.chatQueue.purgeSession(e),await we(this.getRuntime(),e)}discardPendingManagedRoomMessages(e){return this.chatQueue.discardPendingManagedRoomMessages(e)}async synchronizeSessionDeletions(){await this.deletionSynchronizer.synchronize()}async applySessionDeletion(e){const t=new Fe({daemonInstallationId:m()}),s=u().find(o=>o.sessionId===e.sessionId)?.codexSettings?.codexHome;let n=[];try{n=Ee(e.sessionId,{records:u()})}catch(o){console.warn("[session.deletions] local native source lookup failed",{error:o instanceof Error?o.message:String(o)})}t.recordSession(e);for(const o of[...e.sources,...n]){const h=t.find(o.agentType,o.sourceSessionKey);h&&h.sessionId!==e.sessionId||t.record({...e,...o})}this.runJournal.markSessionAborted(e.sessionId),this.recoveryBarrier.end(e.sessionId);const r=this.sessions.get(e.sessionId);if(r){this.revokeManagedRoomToken(r);try{await r.adapter.stop()}catch{}this.sessions.delete(e.sessionId)}this.historySubscriptions.closeSession(e.sessionId),this.nativeFusion?.handleSessionDeleted(e.sessionId),this.chatQueue.purgeSession(e.sessionId),Qe(e.sessionId),Ie(e.sessionId),Ae(e.sessionId),this.runTextAcc.delete(e.sessionId),this.publishSessionActivity(e.sessionId,null),this.nativeCleanupOutbox.enqueue(e,s),this.nativeCleanupOutbox.kick()}publishSessionActivity(e,t){this.client.sendEvent({type:"event",event:"session.activity",payload:{sessionId:e,activity:t}})}async handleExternalTerminal(e){const t=this.sessions.get(e);t&&(t.journalRunId&&(this.recoveryCoordinator.completeFromProvider(e,t.journalRunId),t.journalRunId=null),this.sessions.delete(e),this.revokeManagedRoomToken(t),t.heartbeatTimer&&clearInterval(t.heartbeatTimer),t.adapter.removeAllListeners(),await t.adapter.stop().catch(()=>{})),this.chatQueue.noteTerminal(e)}async publishManagedActivitySnapshots(){for(const[e,t]of this.sessions.entries()){if(t.heartbeatTimer||!t.currentRunId||!t.adapter.getStatus)continue;const s=await t.adapter.getStatus().catch(()=>null);if(!s?.active||!s.runPhase)continue;const n=new Date().toISOString();this.publishSessionActivity(e,{sessionId:e,runId:s.runId||t.currentRunId,runPhase:s.runPhase,startedAt:new Date(t.lastActiveAt).toISOString(),updatedAt:n,canStop:s.canStop??!0});const r=t.heartbeatSeq++;this.client.sendAgentEvent({type:"event",event:"agent",payload:{state:"heartbeat",sessionId:e,runId:s.runId||t.currentRunId,seq:r,runPhase:s.runPhase,canStop:s.canStop??!0},seq:r,id:`agent-status-${s.runId||t.currentRunId}-${Date.now()}`})}}reloadCustomAgents(){for(const t of S())t.startsWith("custom:")&&k(t);const e=I();for(const[t,s]of Object.entries(e.customAgents??{}))ve(t,s);Re(ye(),new Set(Object.keys(e.customAgents??{})))}async handleReq(e,t={}){const s=this.getRuntime();let n;this.activeRequests++;try{switch(e.method){case"schedule.deliver":if(!this.scheduleHandler)throw new Error("schedules_unavailable");await this.scheduleHandler(e);break;case"chat.send":if(e.params.scheduledDelivery)throw new Error("schedule_source_untrusted");c(e.params),this.recoveryBarrier.isDispatchFrozen()||this.recoveryBarrier.isRecovering(String(e.params.sessionId??""))?n={durableQueueHandoff:await this.chatQueue.handleEnqueue({...e,method:"chat.enqueue"})}:await B(s,e);break;case"chat.enqueue":c(e.params),n={durableQueueHandoff:await this.chatQueue.handleEnqueue(e)};break;case"chat.codex.settings.get":case"chat.codex.settings.set":z(s,e);break;case"chat.queue.get":c(e.params),await this.chatQueue.handleGet(e);break;case"chat.queue.edit":c(e.params),await this.chatQueue.handleEdit(e);break;case"chat.queue.delete":c(e.params),await this.chatQueue.handleDelete(e);break;case"chat.queue.promote":c(e.params),await this.chatQueue.handlePromote(e);break;case"chat.abort":c(e.params),await O(s,e);break;case"session.refresh":c(e.params),await W(s,e);break;case"session.history.open":this.historySubscriptions.handleOpen(e);break;case"session.history.sync":this.historySubscriptions.handleSync(e);break;case"session.history.page":this.historySubscriptions.handlePage(e);break;case"session.history.close":this.historySubscriptions.handleClose(e);break;case"session.body.replica.subscribe":this.historySubscriptions.handleReplicaSubscribe(e);break;case"session.body.replica.unsubscribe":this.historySubscriptions.handleReplicaUnsubscribe(e);break;case"session.history":this.client.sendRes({type:"res",id:e.id,ok:!1,error:"upgrade_required"});break;case"session.message.status":J(s,e);break;case"session.tool.detail":await _(s,e);break;case"voice.session.body.window":V(s,e);break;case"session.title.set":await U(s,e);break;case"room.agent.bind-managed":await Se(s,this.managedRoomBinder,e);break;case"room.agent.restart-managed":await ke(s,this.managedRoomBinder,e);break;case"fs.ls":await X(s,e);break;case"project.fs.open":case"project.fs.list":case"project.fs.read":case"project.fs.close":await We(this.client,this.projectFsHandleStore,e,this.trustedProjectFsRequestResolver);break;case"fs.read":await Z(s,e);break;case"fs.write":await q(s,e);break;case"fs.export.markdown-pdf":await ne(s,e);break;case"fs.export.markdown-pdf.setup":await re(s,e);break;case"fs.archive.zip":await ie(s,e);break;case"fs.rename":await Y(s,e);break;case"fs.transfer.start":await ae(s,e);break;case"fs.transfer.chunk":await se(s,e);break;case"fs.transfer.finish":await te(s,e);break;case"fs.transfer.abort":await ee(s,e);break;case"region.probe":await oe(s,e);break;case"region.switch":await ce(s,e);break;case"upgrade.start":await A(this.client,e.id,e.params.version,{currentVersion:this.cliVersion,confirmedMajor:e.params.confirmedMajor===!0,prepareForUpgrade:r=>this.prepareForUpgrade(r),cancelUpgradePreparation:()=>this.cancelUpgradePreparation(),shutdownAfterHandoff:()=>{setTimeout(()=>process.kill(process.pid,"SIGTERM"),100).unref?.()}});break;case"upgrade.status":await T(this.client,e.id,{currentVersion:this.cliVersion});break;case"upgrade.set-policy":await le(s,e);break;case"machine.remote-access.pause":await G(this.client,this.remoteAccessPauseController,e);break;case"agents.refresh":await P(s,e);break;case"agent.permission.respond":await _e(s,e);break;case"agent.auth.start":case"agent.auth.logout":case"agent.session-options.get":case"agent.external-sessions.list":case"agent.external-sessions.import":case"agent.external-sessions.close":case"agent.external-sessions.delete":await Ue(s,e);break;case"models.refresh":await C(s,e);break;case"agent.config.get":await E(s,e);break;case"agent.config.upsert":await j(s,e);break;case"agent.config.clear":await F(s,e);break;case"agent.config.test":await Q(s,e);break;case"agent.workspace.validate":await $(s,e);break;case"agent.capabilities.list":await D(s,e);break;case"skill.list":case"skill.install":case"skill.doctor":case"skill.setup":case"skill.use":this.client.sendRes({type:"res",id:e.id,ok:!1,error:"feature_retired"});break;case"session.wechat-rpa.channel.get":case"session.wechat-rpa.channel.upsert":case"session.wechat-rpa.channel.sync":case"manager.wechat-rpa.channel.get":case"manager.wechat-rpa.channel.upsert":case"manager.wechat-rpa.channel.sync":this.client.sendRes({type:"res",id:e.id,ok:!1,error:"feature_retired"});break;default:this.client.sendRes({type:"res",id:e.id,ok:!1,error:`Unknown method: ${e.method}`})}}catch(r){if(t.propagateErrors)throw r;this.client.sendRes({type:"res",id:e.id,ok:!1,error:r instanceof Error?r.message:String(r)})}finally{this.activeRequests--}return n}evictIdleSessions(){if(this.sessions.size<Ne)return;let e=null;for(const[t,s]of this.sessions)(!e||s.lastActiveAt<e.session.lastActiveAt)&&(e={key:t,session:s});e&&(this.revokeManagedRoomToken(e.session),e.session.heartbeatTimer&&(clearInterval(e.session.heartbeatTimer),e.session.heartbeatTimer=null),e.session.adapter.removeAllListeners(),e.session.adapter.stop().catch(()=>{}),this.sessions.delete(e.key))}resolvePath(e){return fe(e)}resolveAuthorizedPath(e,t){return pe(e,de(t))}async resolveAuthorizedPathAsync(e,t){return ge(e,await me(t))}async cleanup(){this.chatQueue.stop(),this.projectFsHandleStore.revokeAll(),this.acpDiscoveryWatcher.stop(),this.nativeFusion?.setExternalTerminalHandler?.(null),this.nativeCleanupOutbox.stop(),this.historySubscriptions.closeAll(),this.activityProbeTimer&&(clearInterval(this.activityProbeTimer),this.activityProbeTimer=null),this.attachmentCleanupTimer&&(clearInterval(this.attachmentCleanupTimer),this.attachmentCleanupTimer=null);for(const[,e]of this.sessions)this.revokeManagedRoomToken(e),e.heartbeatTimer&&(clearInterval(e.heartbeatTimer),e.heartbeatTimer=null),e.adapter.removeAllListeners(),await e.adapter.stop().catch(()=>{});this.sessions.clear(),this.runTextAcc.clear(),K(this.getRuntime()),await this.managerRuntime.stop(),d(null)}revokeManagedRoomToken(e){const t=e.managedRoomContextToken;e.managedRoomContextToken=null,t&&this.managedRoomContextRevoker?.(t)}}export{Ys as SessionManager,st as resolveSessionWorkDir,Ge as upgradeRecoveryVisibleMessage};
|
|
1
|
+
import b from"node:crypto";import{getRegisteredAgents as S,unregisterAgent as k}from"../agents/adapter.js";import{resetCommandSpecCache as w}from"../agents/command-spec.js";import{loadConfig as I}from"../config/index.js";import{handleUpgradeStart as A,handleUpgradeStatus as T}from"../commands/upgrade.js";import{handleAgentsRefresh as P,handleModelsRefresh as C,refreshMachineAgents as M}from"./handlers/agents.js";import{AcpDiscoveryWatcher as x}from"../agents/acp/watcher.js";import{handleAgentCapabilitiesList as D}from"./handlers/agent-capabilities.js";import{handleAgentConfigClear as F,handleAgentConfigGet as E,handleAgentConfigTest as Q,handleAgentConfigUpsert as j}from"./handlers/agent-config.js";import{handleCodexSettings as z}from"./handlers/codex-settings.js";import{handleChatAbort as O,handleChatSend as B}from"./handlers/chat.js";import{recoverJournaledRun as H}from"./handlers/chat-recovery.js";import{handleSessionRefresh as W}from"./handlers/session-refresh.js";import{handleSessionToolDetail as _}from"./handlers/tool-detail.js";import{handleSessionTitleSet as U}from"./handlers/title.js";import{handleSessionMessageStatus as J}from"./handlers/message-status.js";import{handleAgentWorkspaceValidation as $}from"./handlers/agent-workspace-validation.js";import{handleVoiceSessionBodyWindow as L}from"./handlers/voice-window.js";import{commitStewardSay as V,commitTerminalStewardSay as N}from"./handlers/steward.js";import{handlePersonalWorkspace as G}from"./handlers/personal-workspace.js";import{handleLocalApps as K}from"./handlers/local-apps.js";import{handleRemoteAccessPause as X}from"./handlers/remote-access.js";import{cleanupPendingTransfers as Z,handleFsLs as Y,handleFsRead as q,handleFsRename as ee,handleFsWrite as se,handleFsTransferAbort as te,handleFsTransferChunk as ae,handleFsTransferFinish as re,handleFsTransferStart as ne,handleFsExportMarkdownPdf as ie,handleFsExportMarkdownPdfSetup as oe,handleFsArchiveZip as ce}from"./handlers/fs.js";import{handleRegionProbe as le,handleRegionSwitch as ue,handleUpgradeSetPolicy as he}from"./handlers/control.js";import{ManagerRuntimeService as de,setManagerRuntimeService as d}from"../manager/runtime.js";import{ChatQueueManager as me}from"./queue.js";import{createAuthorizedFsRoot as pe,createAuthorizedFsRootAsync as ge,resolveAuthorizedPath as fe,resolveAuthorizedPathAsync as ve,resolveSessionWorkDir as ye}from"../fs/boundary.js";import"../agents/claude.js";import"../agents/codex.js";import"../agents/workbuddy.js";import"../agents/gemini.js";import"../agents/cursor.js";import"../agents/opencode.js";import"../agents/pi-coding-agent.js";import"../agents/manager.js";import{registerCustomAgent as Re}from"../agents/custom.js";import{listNodeAdapters as be}from"../adapter-kit/registry.js";import{syncNodeAdapterAgents as Se}from"../agents/node-adapter.js";import{bindManagedRoom as ke,handleManagedRoomBind as we,handleManagedRoomRestart as Ie,discardPreBindingSession as Ae}from"./handlers/room-managed.js";import{getDaemonInstallationId as m,listSessionRecords as u,purgeCanonicalSession as Te,purgeSessionRecord as Pe,recordSession as Ce,upsertMessage as Me}from"./store.js";import{requestSessionIndexPublish as p}from"./index-publisher.js";import{checkRunStalls as xe}from"./run-stall.js";import{reportUpgradeAggregateMetric as De}from"../log-reporter.js";import{PersonalHistorySubscriptions as Fe}from"./history-subscriptions.js";import{sweepAttachmentTransfers as Ee}from"./attachment-transfer-store.js";import{NativeSourceDeletionStore as Qe}from"../native-fusion/native-source-deletions.js";import{collectLocalNativeSources as je}from"../native-fusion/session-native-sources.js";import{purgeToolDetails as ze}from"./tool-detail-store.js";import{NativeSessionCleanupOutbox as Oe}from"./native-cleanup-outbox.js";import{assertPersonalSyncIdentity as c}from"../personal-sync/epoch.js";import{ActiveRunJournal as Be}from"./run-recovery/journal.js";import{RunRecoveryBarrier as He}from"./run-recovery/barrier.js";import{RunRecoveryCoordinator as We}from"./run-recovery/coordinator.js";import{ProjectFsHandleStore as _e}from"./project-fs-store.js";import{handleProjectFsRequest as Ue}from"./handlers/project-fs.js";import{handleAgentPermissionResponse as Je,handleAcpAgentRequest as $e}from"./handlers/agent-control.js";import{SessionDeletionSynchronizer as Le}from"./deletion-synchronizer.js";import{dispatchManagedChat as Ve,dispatchQueuedChat as Ne,interruptQueuedChat as Ge}from"./queued-chat-dispatch.js";const Ke=50;import{resolveSessionWorkDir as nt}from"../fs/boundary.js";function Xe(){return"\u795E\u5FF5\u5347\u7EA7\u4E2D\u65AD\u4E86\u672C\u6B21\u8FD0\u884C\u3002\u5DF2\u5B8C\u6210\u7684\u56DE\u590D\u6216\u64CD\u4F5C\u4ECD\u7136\u6709\u6548\uFF0C\u672A\u5B8C\u6210\u90E8\u5206\u53EF\u91CD\u8BD5\u3002\u539F\u4F1A\u8BDD\u5DF2\u4FDD\u7559\u3002"}class tt{client;nativeFusion;cliVersion;upgradePolicyController;managedRoomBinder;remoteAccessPauseController;managedRoomContextRevoker;managedRoomExecutor;trustedProjectFsRequestResolver;getAgentSnapshot;scheduleHandler;getScheduleQueue(){return this.chatQueue}sessions=new Map;processedReqIds=new Set;runTextAcc=new Map;pendingTransfers=new Map;managerRuntime;chatQueue;historySubscriptions;nativeCleanupOutbox;activityProbeTimer=null;attachmentCleanupTimer=null;activeRequests=0;acpDiscoveryWatcher;runJournal;recoveryBarrier=new He;recoveryCoordinator;recoveryPass=null;prepareManagedRecovery;projectFsHandleStore=new _e;deletionSynchronizer;constructor(e,t=null,s,r=null,n=null,o=null,h=null,g=null,f=null,v=null,y=null){this.client=e,this.nativeFusion=t,this.cliVersion=s,this.upgradePolicyController=r,this.managedRoomBinder=n,this.remoteAccessPauseController=o,this.managedRoomContextRevoker=h,this.managedRoomExecutor=g,this.trustedProjectFsRequestResolver=v,this.getAgentSnapshot=y,this.runJournal=f??new Be(m());for(const a of this.runJournal.loadPendingReconciliation().records)this.recoveryBarrier.begin(a.sessionId);this.recoveryCoordinator=new We({journal:this.runJournal,barrier:this.recoveryBarrier,recover:(a,i)=>H(this.getRuntime(),a,i),commitTerminal:(a,i)=>this.commitRecoveryTerminal(a,i),isCanonicalTerminal:a=>{const i=u().find(R=>R.sessionId===a.sessionId),l=`terminal:${b.createHash("sha256").update(`${a.runId}\0`).digest("hex")}`;return i?.lastAttentionId===l},onOutcome:a=>De({kind:"recovery",adapterType:a.adapterType,result:a.result,stage:a.result==="continued"?"continue":a.result==="reattached"?"reattach":a.result==="resumed"?"resume":a.result==="terminal_reconciled"?"inspect":"terminal",durationMs:a.durationMs,retries:Math.max(0,a.attempts-1),...a.reason?{errorCode:a.reason}:{}})}),this.managerRuntime=new de({getRuntime:()=>this.getRuntime(),getAgentSnapshot:this.getAgentSnapshot??void 0,dispatchReq:a=>this.handleReq(a,{propagateErrors:!0})}),this.chatQueue=new me({getRuntime:()=>this.getRuntime(),dispatchReq:a=>this.handleReq(a),dispatchManagedReq:(a,i)=>Ve(this.getRuntime(),a,i),dispatchQueuedReq:(a,i)=>Ne(this.getRuntime(),a,i),interruptQueuedSession:a=>Ge(this.getRuntime(),a)}),this.deletionSynchronizer=new Le(e,a=>this.applySessionDeletion(a)),this.historySubscriptions=new Fe(this.client),this.nativeCleanupOutbox=new Oe({logger:console.info}),this.acpDiscoveryWatcher=new x(async()=>{w(),await M(this.getRuntime())}),this.nativeFusion?.setExternalTerminalHandler?.(a=>{this.handleExternalTerminal(a)}),this.nativeFusion?.setExternalClaimHandler?.((a,i)=>{this.chatQueue.noteExternalClaim(a,i)}),this.nativeCleanupOutbox.start(),d(this.managerRuntime),this.managerRuntime.start(),this.reloadCustomAgents();try{this.acpDiscoveryWatcher.start()}catch(a){console.warn(`[acp.discovery] watcher unavailable: ${a instanceof Error?a.message:String(a)}`)}this.activityProbeTimer=setInterval(()=>{xe(this.sessions.entries(),()=>p(this.client)),this.publishManagedActivitySnapshots().catch(a=>{console.error("[session.activity] managed probe failed",a)})},15e3),this.activityProbeTimer.unref?.(),this.attachmentCleanupTimer=setInterval(()=>{const a=new Set([...u().map(i=>i.workDir),...Array.from(this.pendingTransfers.values()).map(i=>i.rootPath)]);for(const i of a)try{Ee(this.resolvePath(i))}catch(l){console.error("[attachment.cleanup] failed",l instanceof Error?l.message:String(l))}},6e4),this.attachmentCleanupTimer.unref?.()}executeManagedManagerAction(e){return this.managerRuntime.executeScopedWorkerAction(e.managerSessionId,e.action,e.params,e.roomOrigin)}noteManagedRoomSendOutcome(e){for(const t of this.sessions.values()){if(t.managedRoomContextToken!==e.token)continue;const s=t.roomSendOutcome??(t.roomSendOutcome={successes:0,failureCodes:[]});e.ok?s.successes+=1:s.failureCodes.length<20&&s.failureCodes.push(e.errorCode??"managed_room_action_failed");return}}getManagedRoomActiveRunId(e,t){const s=this.sessions.get(t);if(s?.currentRunId)return s.currentRunId;for(const r of this.sessions.values())if(r.managedRoomContextToken===e)return r.currentRunId??null;return null}getRuntime(){return{client:this.client,pendingTransfers:this.pendingTransfers,processedReqIds:this.processedReqIds,reloadCustomAgents:()=>this.reloadCustomAgents(),getAgentSnapshot:this.getAgentSnapshot??void 0,resolvePath:e=>this.resolvePath(e),resolveAuthorizedPath:(e,t)=>this.resolveAuthorizedPath(e,t),resolveAuthorizedPathAsync:(e,t)=>this.resolveAuthorizedPathAsync(e,t),runTextAcc:this.runTextAcc,sessions:this.sessions,evictIdleSessions:()=>this.evictIdleSessions(),nativeFusion:this.nativeFusion,managerRuntime:this.managerRuntime,chatQueue:this.chatQueue,activityPublisher:{publish:(e,t)=>this.publishSessionActivity(e,t)},upgradePolicyController:this.upgradePolicyController,revokeManagedRoomContextToken:this.managedRoomContextRevoker,managedRoomExecutor:this.managedRoomExecutor,runJournal:this.runJournal,recoveryBarrier:this.recoveryBarrier,prepareManagedRecovery:this.prepareManagedRecovery}}async resumePendingAcpAuthentication(e){const t=[...this.sessions.values()].find(s=>s.agentType===e&&s.adapter.hasPendingAuthenticationRetry?.());return t?.adapter.resumeAfterExternalAuthentication?(await t.adapter.resumeAfterExternalAuthentication(),!0):!1}getUpgradeIdleState(){const e=[];return[...this.sessions.values()].some(t=>t.currentRunId!==null)&&e.push("active-agent-turn"),this.pendingTransfers.size>0&&e.push("file-transfer"),this.activeRequests>0&&e.push("active-daemon-request"),{idle:e.length===0,reasons:e}}bindManagedRoomFromLocal(e){return ke(this.getRuntime(),this.managedRoomBinder,e)}stewardSayFromLocal(e){const t=typeof e.sessionId=="string"?e.sessionId:"",s=typeof e.text=="string"?e.text:"";return t?V(this.getRuntime(),t,s):N(this.getRuntime(),s)}prepareForUpgrade(e){this.recoveryBarrier.freezeDispatch();const t=this.runJournal.markPlannedUpgrade(e);return this.runJournal.sync(),{activeRunCount:t}}cancelUpgradePreparation(){this.recoveryBarrier.unfreezeDispatch()}async recoverInterruptedRuns(){this.recoveryPass??=this.recoveryCoordinator.recoverAll(),await this.recoveryPass}getPendingRecoveryCount(){return this.runJournal.loadPendingReconciliation().records.length}revokeProjectFsHandles(){this.projectFsHandleStore.revokeAll()}async commitRecoveryTerminal(e,t){const s=this.sessions.get(e.sessionId);s&&(s.currentRunId=null,s.currentRunPhase=null,s.journalRunId=null,s.heartbeatTimer&&(clearInterval(s.heartbeatTimer),s.heartbeatTimer=null)),this.runTextAcc.delete(`${e.sessionId}:${e.providerRunId??e.runId}`),this.publishSessionActivity(e.sessionId,null);const r=Xe();Me(e.sessionId,{id:`upgrade-recovery-terminal-${e.runId}`,sessionId:e.sessionId,role:"agent",ts:Date.now(),payload:JSON.stringify({v:1,type:"error",content:r,error:!0,recoveryState:t.result,recoveryReason:t.reason})}),Ce({sessionId:e.sessionId,agentType:e.agentType,sessionMode:e.sessionMode,workDir:e.workDir,agentSessionId:e.agentSessionId,modelId:e.modelId,status:"failed",attentionId:`upgrade-recovery:${e.runId}`,lastActivityAt:new Date().toISOString()}),this.managerRuntime.noteAgentEvent(e.sessionId,{state:"error",runId:e.providerRunId??e.runId,seq:e.lastObservedEventSeq+1,message:r}),p(this.client);const n=e.lastObservedEventSeq+1;this.client.sendAgentEvent({type:"event",event:"agent",payload:t.result==="interrupted_by_upgrade"?{state:"interrupted_by_upgrade",sessionId:e.sessionId,runId:e.providerRunId??e.runId,seq:n,reason:t.reason}:{state:"recovery_failed",sessionId:e.sessionId,runId:e.providerRunId??e.runId,seq:n,reason:t.reason,...t.message?{message:t.message}:{}},seq:n,id:`agent-recovery-terminal-${e.runId}`}),this.chatQueue.noteTerminal(e.sessionId)}setManagedRoomTurnPreparer(e){this.chatQueue.setManagedRoomTurnPreparer(e)}setManagedAgentDirectTurnPreparer(e){this.chatQueue.setManagedAgentDirectTurnPreparer(e)}setManagedRecoveryPreparer(e){this.prepareManagedRecovery=e}async enqueueManagedRoomBatch(e){const t=e.map(s=>{const r=u().find(n=>n.sessionId===s.params.sessionId);return{context:s.context,params:{...s.params,modelId:r?.modelId??s.params.modelId,sessionMode:r?.sessionMode??s.params.sessionMode,managerConfig:r?.managerConfig??s.params.managerConfig,managerDefaultWorkerAgentType:r?.managerDefaultWorkerAgentType??s.params.managerDefaultWorkerAgentType,managerDefaultWorkerModelId:r?.managerDefaultWorkerModelId??s.params.managerDefaultWorkerModelId}}});await this.chatQueue.enqueueManagedRoomBatch(t)}async retireManagedRoomSession(e){this.chatQueue.purgeSession(e),await Ae(this.getRuntime(),e)}discardPendingManagedRoomMessages(e){return this.chatQueue.discardPendingManagedRoomMessages(e)}async synchronizeSessionDeletions(){await this.deletionSynchronizer.synchronize()}async applySessionDeletion(e){const t=new Qe({daemonInstallationId:m()}),s=u().find(o=>o.sessionId===e.sessionId)?.codexSettings?.codexHome;let r=[];try{r=je(e.sessionId,{records:u()})}catch(o){console.warn("[session.deletions] local native source lookup failed",{error:o instanceof Error?o.message:String(o)})}t.recordSession(e);for(const o of[...e.sources,...r]){const h=t.find(o.agentType,o.sourceSessionKey);h&&h.sessionId!==e.sessionId||t.record({...e,...o})}this.runJournal.markSessionAborted(e.sessionId),this.recoveryBarrier.end(e.sessionId);const n=this.sessions.get(e.sessionId);if(n){this.revokeManagedRoomToken(n);try{await n.adapter.stop()}catch{}this.sessions.delete(e.sessionId)}this.historySubscriptions.closeSession(e.sessionId),this.nativeFusion?.handleSessionDeleted(e.sessionId),this.chatQueue.purgeSession(e.sessionId),ze(e.sessionId),Te(e.sessionId),Pe(e.sessionId),this.runTextAcc.delete(e.sessionId),this.publishSessionActivity(e.sessionId,null),this.nativeCleanupOutbox.enqueue(e,s),this.nativeCleanupOutbox.kick()}publishSessionActivity(e,t){this.client.sendEvent({type:"event",event:"session.activity",payload:{sessionId:e,activity:t}})}async handleExternalTerminal(e){const t=this.sessions.get(e);t&&(t.journalRunId&&(this.recoveryCoordinator.completeFromProvider(e,t.journalRunId),t.journalRunId=null),this.sessions.delete(e),this.revokeManagedRoomToken(t),t.heartbeatTimer&&clearInterval(t.heartbeatTimer),t.adapter.removeAllListeners(),await t.adapter.stop().catch(()=>{})),this.chatQueue.noteTerminal(e)}async publishManagedActivitySnapshots(){for(const[e,t]of this.sessions.entries()){if(t.heartbeatTimer||!t.currentRunId||!t.adapter.getStatus)continue;const s=await t.adapter.getStatus().catch(()=>null);if(!s?.active||!s.runPhase)continue;const r=new Date().toISOString();this.publishSessionActivity(e,{sessionId:e,runId:s.runId||t.currentRunId,runPhase:s.runPhase,startedAt:new Date(t.lastActiveAt).toISOString(),updatedAt:r,canStop:s.canStop??!0});const n=t.heartbeatSeq++;this.client.sendAgentEvent({type:"event",event:"agent",payload:{state:"heartbeat",sessionId:e,runId:s.runId||t.currentRunId,seq:n,runPhase:s.runPhase,canStop:s.canStop??!0},seq:n,id:`agent-status-${s.runId||t.currentRunId}-${Date.now()}`})}}reloadCustomAgents(){for(const t of S())t.startsWith("custom:")&&k(t);const e=I();for(const[t,s]of Object.entries(e.customAgents??{}))Re(t,s);Se(be(),new Set(Object.keys(e.customAgents??{})))}async handleReq(e,t={}){const s=this.getRuntime();let r;this.activeRequests++;try{switch(e.method){case"schedule.deliver":if(!this.scheduleHandler)throw new Error("schedules_unavailable");await this.scheduleHandler(e);break;case"chat.send":if(e.params.scheduledDelivery)throw new Error("schedule_source_untrusted");c(e.params),this.recoveryBarrier.isDispatchFrozen()||this.recoveryBarrier.isRecovering(String(e.params.sessionId??""))?r={durableQueueHandoff:await this.chatQueue.handleEnqueue({...e,method:"chat.enqueue"})}:await B(s,e);break;case"chat.enqueue":c(e.params),r={durableQueueHandoff:await this.chatQueue.handleEnqueue(e)};break;case"chat.codex.settings.get":case"chat.codex.settings.set":z(s,e);break;case"chat.queue.get":c(e.params),await this.chatQueue.handleGet(e);break;case"chat.queue.edit":c(e.params),await this.chatQueue.handleEdit(e);break;case"chat.queue.delete":c(e.params),await this.chatQueue.handleDelete(e);break;case"chat.queue.promote":c(e.params),await this.chatQueue.handlePromote(e);break;case"chat.abort":c(e.params),await O(s,e);break;case"session.refresh":c(e.params),await W(s,e);break;case"session.history.open":this.historySubscriptions.handleOpen(e);break;case"session.history.sync":this.historySubscriptions.handleSync(e);break;case"session.history.page":this.historySubscriptions.handlePage(e);break;case"session.history.close":this.historySubscriptions.handleClose(e);break;case"session.body.replica.subscribe":this.historySubscriptions.handleReplicaSubscribe(e);break;case"session.body.replica.unsubscribe":this.historySubscriptions.handleReplicaUnsubscribe(e);break;case"session.history":this.client.sendRes({type:"res",id:e.id,ok:!1,error:"upgrade_required"});break;case"session.message.status":J(s,e);break;case"session.tool.detail":await _(s,e);break;case"voice.session.body.window":L(s,e);break;case"session.title.set":await U(s,e);break;case"room.agent.bind-managed":await we(s,this.managedRoomBinder,e);break;case"room.agent.restart-managed":await Ie(s,this.managedRoomBinder,e);break;case"personal.workspace":await G(s,e);break;case"personal.apps.list":case"personal.apps.register":case"personal.apps.remove":case"personal.service":await K(s,e);break;case"fs.ls":await Y(s,e);break;case"project.fs.open":case"project.fs.list":case"project.fs.read":case"project.fs.close":await Ue(this.client,this.projectFsHandleStore,e,this.trustedProjectFsRequestResolver);break;case"fs.read":await q(s,e);break;case"fs.write":await se(s,e);break;case"fs.export.markdown-pdf":await ie(s,e);break;case"fs.export.markdown-pdf.setup":await oe(s,e);break;case"fs.archive.zip":await ce(s,e);break;case"fs.rename":await ee(s,e);break;case"fs.transfer.start":await ne(s,e);break;case"fs.transfer.chunk":await ae(s,e);break;case"fs.transfer.finish":await re(s,e);break;case"fs.transfer.abort":await te(s,e);break;case"region.probe":await le(s,e);break;case"region.switch":await ue(s,e);break;case"upgrade.start":await A(this.client,e.id,e.params.version,{currentVersion:this.cliVersion,confirmedMajor:e.params.confirmedMajor===!0,prepareForUpgrade:n=>this.prepareForUpgrade(n),cancelUpgradePreparation:()=>this.cancelUpgradePreparation(),shutdownAfterHandoff:()=>{setTimeout(()=>process.kill(process.pid,"SIGTERM"),100).unref?.()}});break;case"upgrade.status":await T(this.client,e.id,{currentVersion:this.cliVersion});break;case"upgrade.set-policy":await he(s,e);break;case"machine.remote-access.pause":await X(this.client,this.remoteAccessPauseController,e);break;case"agents.refresh":await P(s,e);break;case"agent.permission.respond":await Je(s,e);break;case"agent.auth.start":case"agent.auth.logout":case"agent.session-options.get":case"agent.external-sessions.list":case"agent.external-sessions.import":case"agent.external-sessions.close":case"agent.external-sessions.delete":await $e(s,e);break;case"models.refresh":await C(s,e);break;case"agent.config.get":await E(s,e);break;case"agent.config.upsert":await j(s,e);break;case"agent.config.clear":await F(s,e);break;case"agent.config.test":await Q(s,e);break;case"agent.workspace.validate":await $(s,e);break;case"agent.capabilities.list":await D(s,e);break;case"skill.list":case"skill.install":case"skill.doctor":case"skill.setup":case"skill.use":this.client.sendRes({type:"res",id:e.id,ok:!1,error:"feature_retired"});break;case"session.wechat-rpa.channel.get":case"session.wechat-rpa.channel.upsert":case"session.wechat-rpa.channel.sync":case"manager.wechat-rpa.channel.get":case"manager.wechat-rpa.channel.upsert":case"manager.wechat-rpa.channel.sync":this.client.sendRes({type:"res",id:e.id,ok:!1,error:"feature_retired"});break;default:this.client.sendRes({type:"res",id:e.id,ok:!1,error:`Unknown method: ${e.method}`})}}catch(n){if(t.propagateErrors)throw n;this.client.sendRes({type:"res",id:e.id,ok:!1,error:n instanceof Error?n.message:String(n)})}finally{this.activeRequests--}return r}evictIdleSessions(){if(this.sessions.size<Ke)return;let e=null;for(const[t,s]of this.sessions)(!e||s.lastActiveAt<e.session.lastActiveAt)&&(e={key:t,session:s});e&&(this.revokeManagedRoomToken(e.session),e.session.heartbeatTimer&&(clearInterval(e.session.heartbeatTimer),e.session.heartbeatTimer=null),e.session.adapter.removeAllListeners(),e.session.adapter.stop().catch(()=>{}),this.sessions.delete(e.key))}resolvePath(e){return ye(e)}resolveAuthorizedPath(e,t){return fe(e,pe(t))}async resolveAuthorizedPathAsync(e,t){return ve(e,await ge(t))}async cleanup(){this.chatQueue.stop(),this.projectFsHandleStore.revokeAll(),this.acpDiscoveryWatcher.stop(),this.nativeFusion?.setExternalTerminalHandler?.(null),this.nativeCleanupOutbox.stop(),this.historySubscriptions.closeAll(),this.activityProbeTimer&&(clearInterval(this.activityProbeTimer),this.activityProbeTimer=null),this.attachmentCleanupTimer&&(clearInterval(this.attachmentCleanupTimer),this.attachmentCleanupTimer=null);for(const[,e]of this.sessions)this.revokeManagedRoomToken(e),e.heartbeatTimer&&(clearInterval(e.heartbeatTimer),e.heartbeatTimer=null),e.adapter.removeAllListeners(),await e.adapter.stop().catch(()=>{});this.sessions.clear(),this.runTextAcc.clear(),Z(this.getRuntime()),await this.managerRuntime.stop(),d(null)}revokeManagedRoomToken(e){const t=e.managedRoomContextToken;e.managedRoomContextToken=null,t&&this.managedRoomContextRevoker?.(t)}}export{tt as SessionManager,nt as resolveSessionWorkDir,Xe as upgradeRecoveryVisibleMessage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{handleChatAbort as
|
|
1
|
+
import{handleChatAbort as m,handleChatSend as d}from"./handlers/chat.js";import{TerminalQueuedChatDispatchError as h}from"./queue.js";import{markTrustedManagerEvent as r}from"./manager-event-authority.js";function c(e){return{source:"room_activation",managedAgentPolicy:e.managedAgentPolicy,managedRoomPromptSnapshot:e.managedRoomPromptSnapshot}}function f(e){return{source:"manager_event",...e.standalone?{standalone:!0}:{},managedAgentPolicy:e.managedAgentPolicy,managedRoomPolicyVersion:e.managedRoomPromptSnapshot.managedRoomPolicyVersion,managedRuntimePolicyHash:e.managedRoomPromptSnapshot.runtimePermissionPolicyHash}}async function p(e,i,n){await d(e,r(i),c(n))}async function P(e,i,n){const a={value:null},o=new Proxy(e.client,{get:(t,l)=>{if(l==="sendRes")return s=>{a.value=s};const u=Reflect.get(t,l,t);return typeof u=="function"?u.bind(t):u}});if(await d({...e,client:o},r(i),n?i.params.managedRecoverySource==="managed_room"||i.params.scheduledDelivery===!0?c(n):f(n):void 0),a.value?.payload?.deliveryState==="failed")throw new h(a.value.payload.failureMessage??a.value.error??"queued_chat_dispatch_failed");if(!a.value?.ok)throw new Error(a.value?.error??"queued_chat_dispatch_failed");return{deliveryMode:a.value.payload?.deliveryMode,queuedSubmissionId:a.value.payload?.queuedSubmissionId}}async function R(e,i){const n={value:null},a=new Proxy(e.client,{get:(o,t)=>t==="sendRes"?l=>{n.value=l}:typeof Reflect.get(o,t,o)=="function"?Reflect.get(o,t,o).bind(o):Reflect.get(o,t,o)});if(await m({...e,client:a},{type:"req",id:`queue-promote-abort-${Date.now()}`,method:"chat.abort",params:{sessionId:i,discardPending:!1}}),!n.value?.ok)throw new Error(n.value?.error??"agent_stop_failed")}export{p as dispatchManagedChat,P as dispatchQueuedChat,R as interruptQueuedChat,c as managedChatContext,f as managedManagerEventContext};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import o from"node:fs";import a from"node:path";import{getShennianDir as s}from"../config/index.js";import{assertPathsSeparate as d}from"./workspace.js";import{readPersonalPaths as l,savePersonalPaths as y}from"./settings.js";function f(e){if(!a.isAbsolute(e)||/[\u0000-\u001f]/.test(e))throw new Error("personal_absolute_directory_required");const r=a.resolve(e);d(r,s());let t=r;for(;;){try{if(o.lstatSync(t).isSymbolicLink())throw new Error("personal_symlink_forbidden")}catch(c){if(c.code!=="ENOENT")throw c}const n=a.dirname(t);if(n===t)break;t=n}if(o.existsSync(r)&&!o.statSync(r).isDirectory())throw new Error("personal_directory_required");o.mkdirSync(r,{recursive:!0,mode:448});const i=o.realpathSync(r);return d(i,o.existsSync(s())?o.realpathSync(s()):s()),i}function _(e){if(!e.workspace&&!e.diary)throw new Error("personal_directory_required");const r={...l()};return e.workspace&&(r.workspace=f(e.workspace)),e.diary&&(r.diary=f(e.diary)),y(r),r}export{_ as configurePersonalPaths,f as validatePersonalDirectory};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import o from"node:fs";import s from"node:os";import n from"node:path";import{randomUUID as a}from"node:crypto";import{getShennianDir as t}from"../config/index.js";const i=()=>n.join(t(),"personal-paths.json");function m(){try{const r=JSON.parse(o.readFileSync(i(),"utf8"));if(!r||typeof r!="object"||Array.isArray(r))throw new Error;for(const e of["workspace","diary"])if(r[e]!==void 0&&(typeof r[e]!="string"||!n.isAbsolute(r[e])))throw new Error;return{workspace:r.workspace,diary:r.diary}}catch(r){if(r.code==="ENOENT")return{};throw new Error("personal_settings_invalid")}}function d(){const r=`${t()}-steward`;return o.existsSync(r)||process.env.SHENNIAN_HOME||process.env.VITEST?r:n.join(s.homedir(),"shennian_agent")}function u(r){o.mkdirSync(t(),{recursive:!0,mode:448});const e=`${i()}.${a()}.tmp`;try{o.writeFileSync(e,JSON.stringify(r,null,2)+`
|
|
2
|
+
`,{mode:384,flag:"wx"}),o.renameSync(e,i())}finally{try{o.unlinkSync(e)}catch{}}}export{d as defaultWorkspace,m as readPersonalPaths,u as savePersonalPaths};
|
|
@@ -45,6 +45,13 @@ import{STEWARD_INDEX_ONBOARDING as n}from"./onboarding.js";const e=4,s=`<!-- she
|
|
|
45
45
|
|
|
46
46
|
${n}
|
|
47
47
|
|
|
48
|
+
## \u65E5\u8BB0\u4E0E\u8BB0\u5FC6
|
|
49
|
+
|
|
50
|
+
- Personal Agent \u5DE5\u4F5C\u533A\u4E0E\u65E5\u8BB0\u76EE\u5F55\u7531 Client \u5206\u522B\u914D\u7F6E\u3002\u7528 shennian steward paths \u67E5\u770B\u5B9E\u9645\u8DEF\u5F84\uFF0C\u4E0D\u5199\u6B7B\u7528\u6237\u76EE\u5F55\uFF0C\u4E0D\u628A\u672A\u914D\u7F6E\u89E3\u91CA\u4E3A\u7A7A\u65E5\u8BB0\u3002
|
|
51
|
+
- \u53EA\u6709\u7528\u6237\u660E\u786E\u8981\u6C42\u8BB0\u65E5\u8BB0\u3001\u8865\u8BB0\u6216\u7FFB\u770B\u65F6\u624D\u8FDB\u5165\u65E5\u8BB0\u76EE\u5F55\uFF1B\u4E00\u5929\u4E00\u7BC7\uFF0C\u4EE5\u7528\u6237\u8BBE\u5B9A\u7684\u65F6\u533A\uFF08\u672A\u8BBE\u65F6\u5148\u786E\u8BA4\uFF09\u4FDD\u5B58\u4E3A YYYY/YYYY-MM-DD.md\u3002
|
|
52
|
+
- \u6B63\u6587\u4F7F\u7528 # \u65E5\u671F\uFF5C\u4E00\u53E5\u8BDD\u5C0F\u6807\u9898\uFF0C\u4E0B\u4E00\u884C > \u6982\u8981\uFF1A\u2026\uFF1B\u53EA\u4F9D\u636E\u7528\u6237\u63D0\u4F9B\u7684\u7ECF\u5386\u8BB0\u5F55\uFF0C\u4E0D\u7F16\u9020\uFF0C\u5DF2\u6709\u6B63\u6587\u5148\u8BFB\u518D\u8865\u5145\uFF0C\u4E0D\u8986\u76D6\u3002
|
|
53
|
+
- \u65E5\u8BB0\u6807\u9898\u3001\u6982\u8981\u548C\u6B63\u6587\u4E0D\u8FDB\u5165\u5168\u5C40\u8D44\u6599\u7D22\u5F15\u3002\u624B\u673A\u65E5\u8BB0\u548C\u8BB0\u5FC6\u9996\u7248\u53EA\u8BFB\uFF0C\u4E0D\u56E0\u6D4F\u89C8\u8BF7\u6C42\u7F16\u8F91\u6216\u81EA\u52A8\u751F\u6210\u6587\u4EF6\u3002
|
|
54
|
+
|
|
48
55
|
## \u8BB0\u5F55
|
|
49
56
|
|
|
50
57
|
- \u53EA\u5728\u7528\u6237\u8981\u6C42\uFF0C\u6216\u51FA\u73B0\u957F\u671F\u6709\u7528\u7684\u4FE1\u606F\uFF08\u65B0\u9879\u76EE\u7684\u7528\u9014\u3001\u5E38\u7528\u7FA4\u7684\u7EA6\u5B9A\uFF09\u65F6\uFF0C\u624D\u66F4\u65B0 index.md \u7B49\u6587\u4EF6\u3002\u4E0D\u8981\u5199\u6D88\u606F\u6570\u3001\u5728\u7EBF\u72B6\u6001\u3001\u6210\u5458\u540D\u5355\u8FD9\u7C7B\u5B9E\u65F6\u5185\u5BB9\u3002
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import o from"node:fs";import n from"node:path";import{getShennianDir as
|
|
1
|
+
import o from"node:fs";import n from"node:path";import{getShennianDir as i}from"../config/index.js";import{readPersonalPaths as u,defaultWorkspace as h}from"./settings.js";import{STEWARD_AGENTS_MD as l,STEWARD_CLAUDE_MD as m,STEWARD_INDEX_MD as S}from"./templates.js";class a extends Error{code;constructor(r,t){super(t),this.code=r}}function y(){return u().workspace??h()}const E=[["AGENTS.md",l],["index.md",S],["CLAUDE.md",m]];function W(){const e=y();w(e,i()),_(e),w(o.realpathSync.native(e),k(i()));const r=[];for(const[t,s]of E){const f=n.join(e,t);try{o.writeFileSync(f,s,{encoding:"utf8",mode:384,flag:"wx"}),r.push(t)}catch(c){if(c.code!=="EEXIST")throw c}}return{dir:o.realpathSync.native(e),created:r}}function _(e){let r=null;try{r=o.lstatSync(e)}catch(s){if(s.code!=="ENOENT")throw s}if(r?.isSymbolicLink())throw new a("steward_workspace_symlink","The steward workspace path must not be a symbolic link.");if(r&&!r.isDirectory())throw new a("steward_workspace_not_directory","The steward workspace path is not a directory.");if(r||o.mkdirSync(e,{mode:448}),process.platform==="win32")return;const t=o.lstatSync(e);if(typeof process.getuid=="function"&&t.uid!==process.getuid())throw new a("steward_workspace_owner","The steward workspace is owned by another user.");(t.mode&63)!==0&&o.chmodSync(e,448)}function k(e){try{return o.realpathSync.native(e)}catch{return n.resolve(e)}}function p(e){const r=n.resolve(e);return process.platform==="win32"||process.platform==="darwin"?r.toLowerCase():r}function d(e,r){const t=n.relative(p(r),p(e));return t===""||!t.startsWith("..")&&!n.isAbsolute(t)}function w(e,r){if(d(e,r)||d(r,e))throw new a("steward_workspace_overlaps_credentials","The steward workspace must be separate from the Shennian credential directory.")}export{E as STEWARD_FILES,a as StewardWorkspaceError,w as assertPathsSeparate,W as ensureStewardWorkspace,y as getStewardDir};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./envelope.js";export*from"./events.js";export*from"./machine.js";export*from"./methods.js";export*from"./frames.js";export*from"./fs.js";export*from"./session.js";export*from"./session-sync.js";export*from"./message-payload.js";export*from"./external-message-format.js";export*from"./native-session.js";export*from"./tool-detail.js";export*from"./voice-chief.js";export*from"./project.js";export*from"./project-fs.js";export*from"./room.js";export*from"./agent-capabilities.js";export*from"./agent-workspace.js";export*from"./relay-connectivity.js";export*from"./project-path.js";export*from"./schedule.js";export*from"./support.js";export*from"./adapter-submission.js";export*from"./codex-settings.js";
|
|
1
|
+
export*from"./envelope.js";export*from"./events.js";export*from"./machine.js";export*from"./methods.js";export*from"./frames.js";export*from"./fs.js";export*from"./session.js";export*from"./session-sync.js";export*from"./message-payload.js";export*from"./external-message-format.js";export*from"./native-session.js";export*from"./tool-detail.js";export*from"./voice-chief.js";export*from"./project.js";export*from"./project-fs.js";export*from"./room.js";export*from"./agent-capabilities.js";export*from"./agent-workspace.js";export*from"./relay-connectivity.js";export*from"./project-path.js";export*from"./schedule.js";export*from"./support.js";export*from"./adapter-submission.js";export*from"./codex-settings.js";export*from"./local-apps.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const n=2097152;function i(r){if(typeof r!="string"||r.length>2048||!r.startsWith("/")||r.startsWith("//")||/[\\\u0000-\u0020#]/.test(r))throw new Error("invalid_service_path");let e=r.split("?")[0];try{for(let t=0;t<8;t++){const s=decodeURIComponent(e);if(s===e)break;e=s}if(decodeURIComponent(e)!==e)throw new Error}catch{throw new Error("invalid_service_path")}if(e.startsWith("//")||e.split("/").some(t=>t===".."||t===".")||/[\\\u0000-\u001f]/.test(e))throw new Error("invalid_service_path");return r}function o(r){if(!r||typeof r!="object"||Array.isArray(r))throw new Error("invalid_service_request");const e=r;if(Object.keys(e).some(s=>!["appId","port","method","path","args","asset"].includes(s)))throw new Error("invalid_service_request");if(typeof e.appId!="string"||!/^[a-zA-Z0-9_-]{1,80}$/.test(e.appId)||!Number.isInteger(e.port)||Number(e.port)<1024||Number(e.port)>65535)throw new Error("invalid_service_target");const t=typeof e.method=="string"?e.method.toUpperCase():"";if(!["GET","POST","DELETE"].includes(t))throw new Error("invalid_service_method");if(e.args!==void 0&&(!e.args||typeof e.args!="object"||Array.isArray(e.args)||JSON.stringify(e.args).length>64e3))throw new Error("invalid_service_args");if(e.asset!==void 0&&typeof e.asset!="boolean")throw new Error("invalid_service_request");if(e.asset&&(t!=="GET"||e.args!==void 0))throw new Error("invalid_asset_request");return{appId:e.appId,port:Number(e.port),method:t,path:i(e.path),...e.args!==void 0?{args:e.args}:{},...e.asset?{asset:!0}:{}}}function a(r,e){return`(()=>{const target=${JSON.stringify({machineId:r,port:e}).replace(/</g,"\\u003c")}, pending=new Map();let seq=0;
|
|
2
|
+
const settle=(id,result)=>{const p=pending.get(id);if(!p)return;pending.delete(id);clearTimeout(p.timer);if(result.error)return p.reject(new Error(result.error));try{const r=result.value;const bytes=Uint8Array.from(atob(r.base64),c=>c.charCodeAt(0));const text=new TextDecoder().decode(bytes);p.resolve({status:r.status,headers:r.headers,body:(r.headers['content-type']||'').includes('application/json')?JSON.parse(text):text});}catch{p.reject(new Error('service_invalid_response'));}};
|
|
3
|
+
const service=(machine_id,port,method,path,args)=>new Promise((resolve,reject)=>{if(machine_id!==target.machineId||port!==target.port)return reject(new Error('service_target_forbidden'));if(!window.ReactNativeWebView)return reject(new Error('native_bridge_unavailable'));if(pending.size>=8)return reject(new Error('service_busy'));const id=String(++seq);const message=JSON.stringify({kind:'local-service',id,machineId:machine_id,port,method,path,args});if(message.length>300000)return reject(new Error('invalid_service_args'));const timer=setTimeout(()=>{pending.delete(id);reject(new Error('service_timeout'));},22000);pending.set(id,{resolve,reject,timer});window.ReactNativeWebView.postMessage(message);});
|
|
4
|
+
Object.defineProperty(window,'__shennianLocalResult',{value:settle,configurable:false});
|
|
5
|
+
const host=window.shennian||{};host.personal=Object.freeze({service});window.shennian=host;})();`}export{n as LOCAL_APP_MAX_BYTES,a as localAppSdk,i as localServicePath,o as personalServiceInput};
|
|
@@ -91,6 +91,35 @@ var Character;
|
|
|
91
91
|
Character.IsNumeric = IsNumeric;
|
|
92
92
|
})(Character || (Character = {}));
|
|
93
93
|
// ------------------------------------------------------------------
|
|
94
|
+
// MemberExpression
|
|
95
|
+
// ------------------------------------------------------------------
|
|
96
|
+
var MemberExpression;
|
|
97
|
+
(function (MemberExpression) {
|
|
98
|
+
function IsFirstCharacterNumeric(value) {
|
|
99
|
+
if (value.length === 0)
|
|
100
|
+
return false;
|
|
101
|
+
return Character.IsNumeric(value.charCodeAt(0));
|
|
102
|
+
}
|
|
103
|
+
function IsAccessor(value) {
|
|
104
|
+
if (IsFirstCharacterNumeric(value))
|
|
105
|
+
return false;
|
|
106
|
+
for (let i = 0; i < value.length; i++) {
|
|
107
|
+
const code = value.charCodeAt(i);
|
|
108
|
+
const check = Character.IsAlpha(code) || Character.IsNumeric(code) || Character.DollarSign(code) || Character.IsUnderscore(code);
|
|
109
|
+
if (!check)
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
function EscapeHyphen(key) {
|
|
115
|
+
return key.replace(/'/g, "\\'");
|
|
116
|
+
}
|
|
117
|
+
function Encode(object, key) {
|
|
118
|
+
return IsAccessor(key) ? `${object}.${key}` : `${object}['${EscapeHyphen(key)}']`;
|
|
119
|
+
}
|
|
120
|
+
MemberExpression.Encode = Encode;
|
|
121
|
+
})(MemberExpression || (MemberExpression = {}));
|
|
122
|
+
// ------------------------------------------------------------------
|
|
94
123
|
// Identifier
|
|
95
124
|
// ------------------------------------------------------------------
|
|
96
125
|
var Identifier;
|
|
@@ -111,21 +140,15 @@ var Identifier;
|
|
|
111
140
|
Identifier.Encode = Encode;
|
|
112
141
|
})(Identifier || (Identifier = {}));
|
|
113
142
|
// ------------------------------------------------------------------
|
|
114
|
-
//
|
|
143
|
+
// LiteralString
|
|
115
144
|
// ------------------------------------------------------------------
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
// ------------------------------------------------------------------
|
|
124
|
-
// MemberExpression
|
|
125
|
-
// ------------------------------------------------------------------
|
|
126
|
-
function MemberExpression(value, key) {
|
|
127
|
-
return `${value}[${StringConstant(key)}]`;
|
|
128
|
-
}
|
|
145
|
+
var LiteralString;
|
|
146
|
+
(function (LiteralString) {
|
|
147
|
+
function Escape(content) {
|
|
148
|
+
return content.replace(/'/g, "\\'");
|
|
149
|
+
}
|
|
150
|
+
LiteralString.Escape = Escape;
|
|
151
|
+
})(LiteralString || (LiteralString = {}));
|
|
129
152
|
// ------------------------------------------------------------------
|
|
130
153
|
// Errors
|
|
131
154
|
// ------------------------------------------------------------------
|
|
@@ -149,7 +172,7 @@ exports.TypeCompilerTypeGuardError = TypeCompilerTypeGuardError;
|
|
|
149
172
|
var Policy;
|
|
150
173
|
(function (Policy) {
|
|
151
174
|
function IsExactOptionalProperty(value, key, expression) {
|
|
152
|
-
return index_3.TypeSystemPolicy.ExactOptionalPropertyTypes ? `(${
|
|
175
|
+
return index_3.TypeSystemPolicy.ExactOptionalPropertyTypes ? `('${key}' in ${value} ? ${expression} : true)` : `(${MemberExpression.Encode(value, key)} !== undefined ? ${expression} : true)`;
|
|
153
176
|
}
|
|
154
177
|
Policy.IsExactOptionalProperty = IsExactOptionalProperty;
|
|
155
178
|
function IsObjectLike(value) {
|
|
@@ -294,11 +317,8 @@ var TypeCompiler;
|
|
|
294
317
|
if (typeof schema.const === 'number' || typeof schema.const === 'boolean') {
|
|
295
318
|
yield `(${value} === ${schema.const})`;
|
|
296
319
|
}
|
|
297
|
-
else if (typeof schema.const === 'string') {
|
|
298
|
-
yield `(${value} === ${StringConstant(schema.const)})`;
|
|
299
|
-
}
|
|
300
320
|
else {
|
|
301
|
-
|
|
321
|
+
yield `(${value} === '${LiteralString.Escape(schema.const)}')`;
|
|
302
322
|
}
|
|
303
323
|
}
|
|
304
324
|
function* FromNever(schema, references, value) {
|
|
@@ -332,12 +352,12 @@ var TypeCompiler;
|
|
|
332
352
|
yield `Object.getOwnPropertyNames(${value}).length <= ${schema.maxProperties}`;
|
|
333
353
|
const knownKeys = Object.getOwnPropertyNames(schema.properties);
|
|
334
354
|
for (const knownKey of knownKeys) {
|
|
335
|
-
const memberExpression = MemberExpression(value, knownKey);
|
|
355
|
+
const memberExpression = MemberExpression.Encode(value, knownKey);
|
|
336
356
|
const property = schema.properties[knownKey];
|
|
337
357
|
if (schema.required && schema.required.includes(knownKey)) {
|
|
338
358
|
yield* Visit(property, references, memberExpression);
|
|
339
359
|
if ((0, extends_undefined_1.ExtendsUndefinedCheck)(property) || IsAnyOrUnknown(property))
|
|
340
|
-
yield `(${
|
|
360
|
+
yield `('${knownKey}' in ${value})`;
|
|
341
361
|
}
|
|
342
362
|
else {
|
|
343
363
|
const expression = CreateExpression(property, references, memberExpression);
|
|
@@ -349,13 +369,13 @@ var TypeCompiler;
|
|
|
349
369
|
yield `Object.getOwnPropertyNames(${value}).length === ${knownKeys.length}`;
|
|
350
370
|
}
|
|
351
371
|
else {
|
|
352
|
-
const keys = `[${knownKeys.map((key) =>
|
|
372
|
+
const keys = `[${knownKeys.map((key) => `'${key}'`).join(', ')}]`;
|
|
353
373
|
yield `Object.getOwnPropertyNames(${value}).every(key => ${keys}.includes(key))`;
|
|
354
374
|
}
|
|
355
375
|
}
|
|
356
376
|
if (typeof schema.additionalProperties === 'object') {
|
|
357
377
|
const expression = CreateExpression(schema.additionalProperties, references, `${value}[key]`);
|
|
358
|
-
const keys = `[${knownKeys.map((key) =>
|
|
378
|
+
const keys = `[${knownKeys.map((key) => `'${key}'`).join(', ')}]`;
|
|
359
379
|
yield `(Object.getOwnPropertyNames(${value}).every(key => ${keys}.includes(key) || ${expression}))`;
|
|
360
380
|
}
|
|
361
381
|
}
|
|
@@ -403,7 +423,7 @@ var TypeCompiler;
|
|
|
403
423
|
yield `${variable}.test(${value})`;
|
|
404
424
|
}
|
|
405
425
|
if (schema.format !== undefined) {
|
|
406
|
-
yield `format(${
|
|
426
|
+
yield `format('${schema.format}', ${value})`;
|
|
407
427
|
}
|
|
408
428
|
}
|
|
409
429
|
function* FromSymbol(schema, references, value) {
|
|
@@ -451,7 +471,7 @@ var TypeCompiler;
|
|
|
451
471
|
function* FromKind(schema, references, value) {
|
|
452
472
|
const instance = state.instances.size;
|
|
453
473
|
state.instances.set(instance, schema);
|
|
454
|
-
yield `kind(${
|
|
474
|
+
yield `kind('${schema[index_7.Kind]}', ${instance}, ${value})`;
|
|
455
475
|
}
|
|
456
476
|
function* Visit(schema, references, value, useHoisting = true) {
|
|
457
477
|
const references_ = (0, index_12.IsString)(schema.$id) ? [...references, schema] : references;
|
|
@@ -625,7 +645,7 @@ var TypeCompiler;
|
|
|
625
645
|
/** Compiles a TypeBox type for optimal runtime type checking. Types must be valid TypeBox types of TSchema */
|
|
626
646
|
function Compile(schema, references = []) {
|
|
627
647
|
const generatedCode = Code(schema, references, { language: 'javascript' });
|
|
628
|
-
const compiledFunction =
|
|
648
|
+
const compiledFunction = globalThis.Function('kind', 'format', 'hash', generatedCode);
|
|
629
649
|
const instances = new Map(state.instances);
|
|
630
650
|
function typeRegistryFunction(kind, instance, value) {
|
|
631
651
|
if (!index_8.TypeRegistry.Has(kind) || !instances.has(instance))
|
|
@@ -20,4 +20,4 @@ export declare function IsTuple(value: unknown): value is ITuple;
|
|
|
20
20
|
/** Returns true if the value is a Union Parser */
|
|
21
21
|
export declare function IsUnion(value: unknown): value is IUnion;
|
|
22
22
|
/** Returns true if the value is a Parser */
|
|
23
|
-
export declare function IsParser(value: unknown): value is
|
|
23
|
+
export declare function IsParser(value: unknown): value is IContext<unknown> | IUnion<unknown> | IArray<unknown> | IConst<unknown> | IIdent<unknown> | INumber<unknown> | IOptional<unknown> | IRef<unknown> | IString<unknown> | ITuple<unknown>;
|
|
@@ -3,6 +3,6 @@ export declare function Const(value: string, code: string): [] | [string, string
|
|
|
3
3
|
/** Scans for the next Ident token */
|
|
4
4
|
export declare function Ident(code: string): [] | [string, string];
|
|
5
5
|
/** Scans for the next number token */
|
|
6
|
-
export declare function Number(code: string): [] | [
|
|
6
|
+
export declare function Number(code: string): [string, string] | [];
|
|
7
7
|
/** Scans the next Literal String value */
|
|
8
|
-
export declare function String(options: string[], code: string): [] | [
|
|
8
|
+
export declare function String(options: string[], code: string): [string, string] | [];
|
|
@@ -121,7 +121,7 @@ export declare function AsyncIteratorMapping(input: [unknown, unknown, unknown,
|
|
|
121
121
|
export type TIteratorMapping<Input extends [unknown, unknown, unknown, unknown], Context extends T.TProperties> = Input extends ['Iterator', '<', infer Type extends T.TSchema, '>'] ? T.TIterator<Type> : never;
|
|
122
122
|
export declare function IteratorMapping(input: [unknown, unknown, unknown, unknown], context: unknown): T.TIterator<T.TSchema>;
|
|
123
123
|
export type TArgumentMapping<Input extends [unknown, unknown, unknown, unknown], Context extends T.TProperties> = Input extends ['Argument', '<', infer Type extends T.TSchema, '>'] ? Type extends T.TLiteral<infer Index extends number> ? T.TArgument<Index> : T.TNever : never;
|
|
124
|
-
export declare function ArgumentMapping(input: [unknown, unknown, unknown, unknown], context: unknown): T.
|
|
124
|
+
export declare function ArgumentMapping(input: [unknown, unknown, unknown, unknown], context: unknown): T.TNever | T.TArgument<number>;
|
|
125
125
|
export type TAwaitedMapping<Input extends [unknown, unknown, unknown, unknown], Context extends T.TProperties> = Input extends ['Awaited', '<', infer Type extends T.TSchema, '>'] ? T.TAwaited<Type> : never;
|
|
126
126
|
export declare function AwaitedMapping(input: [unknown, unknown, unknown, unknown], context: unknown): T.TSchema;
|
|
127
127
|
export type TArrayMapping<Input extends [unknown, unknown, unknown, unknown], Context extends T.TProperties> = Input extends ['Array', '<', infer Type extends T.TSchema, '>'] ? T.TArray<Type> : never;
|
|
@@ -15,6 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
16
|
};
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
__exportStar(require("./evaluate"), exports);
|
|
19
18
|
__exportStar(require("./policy"), exports);
|
|
20
19
|
__exportStar(require("./system"), exports);
|
|
@@ -45,7 +45,7 @@ export interface TObject<T extends TProperties = TProperties> extends TSchema, O
|
|
|
45
45
|
required: TRequiredArray<T>;
|
|
46
46
|
}
|
|
47
47
|
/** `[Json]` Creates an Object type */
|
|
48
|
-
declare function
|
|
48
|
+
declare function _Object<T extends TProperties>(properties: T, options?: ObjectOptions): TObject<T>;
|
|
49
49
|
/** `[Json]` Creates an Object type */
|
|
50
|
-
export declare var Object: typeof
|
|
50
|
+
export declare var Object: typeof _Object;
|
|
51
51
|
export {};
|
|
@@ -13,26 +13,10 @@ function RequiredArray(properties) {
|
|
|
13
13
|
return globalThis.Object.keys(properties).filter((key) => !(0, kind_1.IsOptional)(properties[key]));
|
|
14
14
|
}
|
|
15
15
|
/** `[Json]` Creates an Object type */
|
|
16
|
-
function
|
|
16
|
+
function _Object(properties, options) {
|
|
17
17
|
const required = RequiredArray(properties);
|
|
18
18
|
const schema = required.length > 0 ? { [index_1.Kind]: 'Object', type: 'object', required, properties } : { [index_1.Kind]: 'Object', type: 'object', properties };
|
|
19
19
|
return (0, type_1.CreateType)(schema, options);
|
|
20
20
|
}
|
|
21
|
-
// ------------------------------------------------------------------
|
|
22
|
-
// TypeScript 7: CommonJS TS2441
|
|
23
|
-
//
|
|
24
|
-
// TypeScript generates a CommonJS shim that patches local variables
|
|
25
|
-
// via an unqualified reference to Object (e.g. the __esModule shim's
|
|
26
|
-
// Object.defineProperty call). Other compiler tools have been
|
|
27
|
-
// observed patching in the same way, but TypeScript 7 has correctly
|
|
28
|
-
// begun flagging variables named Object in CommonJS, since they
|
|
29
|
-
// conflict with the shim and can cause "used before definition"
|
|
30
|
-
// errors. This is CommonJS-specific; no such shim exists for ESM.
|
|
31
|
-
//
|
|
32
|
-
// TypeBox works around this using a `var` declaration, which is
|
|
33
|
-
// known to avoid use-before-definition errors. TypeBox 1.x employs
|
|
34
|
-
// a similar strategy.
|
|
35
|
-
// ------------------------------------------------------------------
|
|
36
21
|
/** `[Json]` Creates an Object type */
|
|
37
|
-
|
|
38
|
-
exports.Object = _Object_;
|
|
22
|
+
exports.Object = _Object;
|
|
@@ -11,7 +11,7 @@ export declare namespace ParseRegistry {
|
|
|
11
11
|
function Set(key: string, callback: TParseFunction): void;
|
|
12
12
|
function Get(key: string): TParseFunction | undefined;
|
|
13
13
|
}
|
|
14
|
-
export declare const ParseDefault: readonly [
|
|
14
|
+
export declare const ParseDefault: readonly ["Clone", "Clean", "Default", "Convert", "Assert", "Decode"];
|
|
15
15
|
/** Parses a value using the default parse pipeline. Will throws an `AssertError` if invalid. */
|
|
16
16
|
export declare function Parse<Type extends TSchema, Output = StaticDecode<Type>, Result extends Output = Output>(schema: Type, references: TSchema[], value: unknown): Result;
|
|
17
17
|
/** Parses a value using the default parse pipeline. Will throws an `AssertError` if invalid. */
|