@rarog/server 0.0.0-stage → 1.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +161 -2
- package/THIRD-PARTY-NOTICES +2110 -0
- package/bin/rarog.mjs +146 -0
- package/node_modules/@rarog/shared/LICENSE +21 -0
- package/node_modules/@rarog/shared/package.json +43 -0
- package/node_modules/@rarog/shared/src/data-dir.d.mts +49 -0
- package/node_modules/@rarog/shared/src/data-dir.mjs +120 -0
- package/node_modules/@rarog/shared/src/decode.js +381 -0
- package/node_modules/@rarog/shared/src/iroh.js +13 -0
- package/node_modules/@rarog/shared/src/notify-copy.js +12 -0
- package/node_modules/@rarog/shared/src/pairing-link.js +246 -0
- package/node_modules/@rarog/shared/src/protocol/activity.js +42 -0
- package/node_modules/@rarog/shared/src/protocol/attachments.js +192 -0
- package/node_modules/@rarog/shared/src/protocol/background.js +89 -0
- package/node_modules/@rarog/shared/src/protocol/commands.js +34 -0
- package/node_modules/@rarog/shared/src/protocol/consent.js +28 -0
- package/node_modules/@rarog/shared/src/protocol/dictation.js +23 -0
- package/node_modules/@rarog/shared/src/protocol/diff.js +78 -0
- package/node_modules/@rarog/shared/src/protocol/directories.js +44 -0
- package/node_modules/@rarog/shared/src/protocol/files.js +33 -0
- package/node_modules/@rarog/shared/src/protocol/git.js +23 -0
- package/node_modules/@rarog/shared/src/protocol/herdr.js +23 -0
- package/node_modules/@rarog/shared/src/protocol/inbox.js +38 -0
- package/node_modules/@rarog/shared/src/protocol/model.js +214 -0
- package/node_modules/@rarog/shared/src/protocol/notes.js +91 -0
- package/node_modules/@rarog/shared/src/protocol/resume.js +57 -0
- package/node_modules/@rarog/shared/src/protocol/terminal.js +259 -0
- package/node_modules/@rarog/shared/src/protocol.js +864 -0
- package/node_modules/@rarog/shared/src/relay-auth.js +231 -0
- package/node_modules/@rarog/shared/src/relay.js +103 -0
- package/node_modules/@rarog/shared/src/rest.js +898 -0
- package/node_modules/@rarog/shared/src/sentences/commands.js +203 -0
- package/node_modules/@rarog/shared/src/sentences/demo.js +10 -0
- package/node_modules/@rarog/shared/src/sentences/dialogs.js +103 -0
- package/node_modules/@rarog/shared/src/sentences/herdr.js +111 -0
- package/node_modules/@rarog/shared/src/sentences/index.js +362 -0
- package/node_modules/@rarog/shared/src/sentences/model.js +73 -0
- package/node_modules/@rarog/shared/src/sentences/push.js +56 -0
- package/node_modules/@rarog/shared/src/sentences/rest.js +140 -0
- package/node_modules/@rarog/shared/src/sentences/restart.js +71 -0
- package/node_modules/@rarog/shared/src/sentences/session.js +133 -0
- package/node_modules/@rarog/shared/src/sentences/state.js +15 -0
- package/node_modules/@rarog/shared/src/sentences/term.js +34 -0
- package/node_modules/@rarog/shared/src/sentences/transcript.js +24 -0
- package/node_modules/@rarog/shared/src/sentences/uploads.js +32 -0
- package/node_modules/@rarog/shared/src/workflow-phases.js +45 -0
- package/node_modules/ansi-regex/index.d.ts +37 -0
- package/node_modules/ansi-regex/index.js +10 -0
- package/node_modules/ansi-regex/license +9 -0
- package/node_modules/ansi-regex/package.json +55 -0
- package/node_modules/ansi-regex/readme.md +78 -0
- package/node_modules/ansi-styles/index.d.ts +345 -0
- package/node_modules/ansi-styles/index.js +163 -0
- package/node_modules/ansi-styles/license +9 -0
- package/node_modules/ansi-styles/package.json +56 -0
- package/node_modules/ansi-styles/readme.md +152 -0
- package/node_modules/camelcase/index.d.ts +63 -0
- package/node_modules/camelcase/index.js +76 -0
- package/node_modules/camelcase/license +9 -0
- package/node_modules/camelcase/package.json +43 -0
- package/node_modules/camelcase/readme.md +99 -0
- package/node_modules/cliui/LICENSE.txt +14 -0
- package/node_modules/cliui/README.md +115 -0
- package/node_modules/cliui/index.js +354 -0
- package/node_modules/cliui/package.json +65 -0
- package/node_modules/color-convert/LICENSE +21 -0
- package/node_modules/color-convert/README.md +68 -0
- package/node_modules/color-convert/conversions.js +839 -0
- package/node_modules/color-convert/index.js +81 -0
- package/node_modules/color-convert/package.json +48 -0
- package/node_modules/color-convert/route.js +97 -0
- package/node_modules/color-name/LICENSE +8 -0
- package/node_modules/color-name/README.md +11 -0
- package/node_modules/color-name/index.js +152 -0
- package/node_modules/color-name/package.json +28 -0
- package/node_modules/decamelize/index.js +13 -0
- package/node_modules/decamelize/license +21 -0
- package/node_modules/decamelize/package.json +38 -0
- package/node_modules/decamelize/readme.md +48 -0
- package/node_modules/dijkstrajs/.travis.yml +4 -0
- package/node_modules/dijkstrajs/CONTRIBUTING.md +8 -0
- package/node_modules/dijkstrajs/LICENSE.md +19 -0
- package/node_modules/dijkstrajs/README.md +18 -0
- package/node_modules/dijkstrajs/dijkstra.js +165 -0
- package/node_modules/dijkstrajs/package.json +60 -0
- package/node_modules/dijkstrajs/test/dijkstra.test.js +96 -0
- package/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
- package/node_modules/emoji-regex/README.md +73 -0
- package/node_modules/emoji-regex/es2015/index.js +6 -0
- package/node_modules/emoji-regex/es2015/text.js +6 -0
- package/node_modules/emoji-regex/index.d.ts +23 -0
- package/node_modules/emoji-regex/index.js +6 -0
- package/node_modules/emoji-regex/package.json +50 -0
- package/node_modules/emoji-regex/text.js +6 -0
- package/node_modules/find-up/index.d.ts +137 -0
- package/node_modules/find-up/index.js +89 -0
- package/node_modules/find-up/license +9 -0
- package/node_modules/find-up/package.json +53 -0
- package/node_modules/find-up/readme.md +156 -0
- package/node_modules/get-caller-file/LICENSE.md +6 -0
- package/node_modules/get-caller-file/README.md +41 -0
- package/node_modules/get-caller-file/index.d.ts +2 -0
- package/node_modules/get-caller-file/index.js +22 -0
- package/node_modules/get-caller-file/index.js.map +1 -0
- package/node_modules/get-caller-file/package.json +42 -0
- package/node_modules/is-fullwidth-code-point/index.d.ts +17 -0
- package/node_modules/is-fullwidth-code-point/index.js +50 -0
- package/node_modules/is-fullwidth-code-point/license +9 -0
- package/node_modules/is-fullwidth-code-point/package.json +42 -0
- package/node_modules/is-fullwidth-code-point/readme.md +39 -0
- package/node_modules/locate-path/index.d.ts +83 -0
- package/node_modules/locate-path/index.js +65 -0
- package/node_modules/locate-path/license +9 -0
- package/node_modules/locate-path/package.json +45 -0
- package/node_modules/locate-path/readme.md +122 -0
- package/node_modules/p-limit/index.d.ts +38 -0
- package/node_modules/p-limit/index.js +57 -0
- package/node_modules/p-limit/license +9 -0
- package/node_modules/p-limit/package.json +52 -0
- package/node_modules/p-limit/readme.md +101 -0
- package/node_modules/p-locate/index.d.ts +64 -0
- package/node_modules/p-locate/index.js +52 -0
- package/node_modules/p-locate/license +9 -0
- package/node_modules/p-locate/package.json +53 -0
- package/node_modules/p-locate/readme.md +90 -0
- package/node_modules/p-try/index.d.ts +39 -0
- package/node_modules/p-try/index.js +9 -0
- package/node_modules/p-try/license +9 -0
- package/node_modules/p-try/package.json +42 -0
- package/node_modules/p-try/readme.md +58 -0
- package/node_modules/path-exists/index.d.ts +28 -0
- package/node_modules/path-exists/index.js +23 -0
- package/node_modules/path-exists/license +9 -0
- package/node_modules/path-exists/package.json +39 -0
- package/node_modules/path-exists/readme.md +52 -0
- package/node_modules/pngjs/.eslintignore +2 -0
- package/node_modules/pngjs/.eslintrc.json +19 -0
- package/node_modules/pngjs/.prettierignore +3 -0
- package/node_modules/pngjs/LICENSE +20 -0
- package/node_modules/pngjs/README.md +429 -0
- package/node_modules/pngjs/browser.js +16096 -0
- package/node_modules/pngjs/coverage/lcov-report/base.css +354 -0
- package/node_modules/pngjs/coverage/lcov-report/bitmapper.js.html +881 -0
- package/node_modules/pngjs/coverage/lcov-report/bitpacker.js.html +554 -0
- package/node_modules/pngjs/coverage/lcov-report/block-navigation.js +77 -0
- package/node_modules/pngjs/coverage/lcov-report/chunkstream.js.html +647 -0
- package/node_modules/pngjs/coverage/lcov-report/constants.js.html +176 -0
- package/node_modules/pngjs/coverage/lcov-report/crc.js.html +200 -0
- package/node_modules/pngjs/coverage/lcov-report/favicon.png +0 -0
- package/node_modules/pngjs/coverage/lcov-report/filter-pack.js.html +593 -0
- package/node_modules/pngjs/coverage/lcov-report/filter-parse-async.js.html +152 -0
- package/node_modules/pngjs/coverage/lcov-report/filter-parse-sync.js.html +143 -0
- package/node_modules/pngjs/coverage/lcov-report/filter-parse.js.html +611 -0
- package/node_modules/pngjs/coverage/lcov-report/format-normaliser.js.html +359 -0
- package/node_modules/pngjs/coverage/lcov-report/index.html +426 -0
- package/node_modules/pngjs/coverage/lcov-report/interlace.js.html +365 -0
- package/node_modules/pngjs/coverage/lcov-report/packer-async.js.html +230 -0
- package/node_modules/pngjs/coverage/lcov-report/packer-sync.js.html +248 -0
- package/node_modules/pngjs/coverage/lcov-report/packer.js.html +467 -0
- package/node_modules/pngjs/coverage/lcov-report/paeth-predictor.js.html +128 -0
- package/node_modules/pngjs/coverage/lcov-report/parser-async.js.html +575 -0
- package/node_modules/pngjs/coverage/lcov-report/parser-sync.js.html +404 -0
- package/node_modules/pngjs/coverage/lcov-report/parser.js.html +950 -0
- package/node_modules/pngjs/coverage/lcov-report/png-sync.js.html +116 -0
- package/node_modules/pngjs/coverage/lcov-report/png.js.html +662 -0
- package/node_modules/pngjs/coverage/lcov-report/prettify.css +101 -0
- package/node_modules/pngjs/coverage/lcov-report/prettify.js +1007 -0
- package/node_modules/pngjs/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/node_modules/pngjs/coverage/lcov-report/sorter.js +169 -0
- package/node_modules/pngjs/coverage/lcov-report/sync-inflate.js.html +584 -0
- package/node_modules/pngjs/coverage/lcov-report/sync-reader.js.html +215 -0
- package/node_modules/pngjs/coverage/lcov.info +2177 -0
- package/node_modules/pngjs/lib/bitmapper.js +267 -0
- package/node_modules/pngjs/lib/bitpacker.js +158 -0
- package/node_modules/pngjs/lib/chunkstream.js +189 -0
- package/node_modules/pngjs/lib/constants.js +32 -0
- package/node_modules/pngjs/lib/crc.js +40 -0
- package/node_modules/pngjs/lib/filter-pack.js +171 -0
- package/node_modules/pngjs/lib/filter-parse-async.js +24 -0
- package/node_modules/pngjs/lib/filter-parse-sync.js +21 -0
- package/node_modules/pngjs/lib/filter-parse.js +177 -0
- package/node_modules/pngjs/lib/format-normaliser.js +93 -0
- package/node_modules/pngjs/lib/interlace.js +95 -0
- package/node_modules/pngjs/lib/packer-async.js +50 -0
- package/node_modules/pngjs/lib/packer-sync.js +56 -0
- package/node_modules/pngjs/lib/packer.js +129 -0
- package/node_modules/pngjs/lib/paeth-predictor.js +16 -0
- package/node_modules/pngjs/lib/parser-async.js +165 -0
- package/node_modules/pngjs/lib/parser-sync.js +108 -0
- package/node_modules/pngjs/lib/parser.js +290 -0
- package/node_modules/pngjs/lib/png-sync.js +12 -0
- package/node_modules/pngjs/lib/png.js +194 -0
- package/node_modules/pngjs/lib/sync-inflate.js +168 -0
- package/node_modules/pngjs/lib/sync-reader.js +45 -0
- package/node_modules/pngjs/package.json +73 -0
- package/node_modules/qrcode/README.md +770 -0
- package/node_modules/qrcode/bin/qrcode +159 -0
- package/node_modules/qrcode/helper/to-sjis-browser.js +2 -0
- package/node_modules/qrcode/helper/to-sjis.js +105 -0
- package/node_modules/qrcode/lib/browser.js +76 -0
- package/node_modules/qrcode/lib/can-promise.js +7 -0
- package/node_modules/qrcode/lib/core/alignment-pattern.js +83 -0
- package/node_modules/qrcode/lib/core/alphanumeric-data.js +59 -0
- package/node_modules/qrcode/lib/core/bit-buffer.js +37 -0
- package/node_modules/qrcode/lib/core/bit-matrix.js +65 -0
- package/node_modules/qrcode/lib/core/byte-data.js +30 -0
- package/node_modules/qrcode/lib/core/error-correction-code.js +135 -0
- package/node_modules/qrcode/lib/core/error-correction-level.js +50 -0
- package/node_modules/qrcode/lib/core/finder-pattern.js +22 -0
- package/node_modules/qrcode/lib/core/format-info.js +29 -0
- package/node_modules/qrcode/lib/core/galois-field.js +69 -0
- package/node_modules/qrcode/lib/core/kanji-data.js +54 -0
- package/node_modules/qrcode/lib/core/mask-pattern.js +234 -0
- package/node_modules/qrcode/lib/core/mode.js +167 -0
- package/node_modules/qrcode/lib/core/numeric-data.js +43 -0
- package/node_modules/qrcode/lib/core/polynomial.js +62 -0
- package/node_modules/qrcode/lib/core/qrcode.js +495 -0
- package/node_modules/qrcode/lib/core/reed-solomon-encoder.js +56 -0
- package/node_modules/qrcode/lib/core/regex.js +31 -0
- package/node_modules/qrcode/lib/core/segments.js +330 -0
- package/node_modules/qrcode/lib/core/utils.js +63 -0
- package/node_modules/qrcode/lib/core/version-check.js +9 -0
- package/node_modules/qrcode/lib/core/version.js +163 -0
- package/node_modules/qrcode/lib/index.js +12 -0
- package/node_modules/qrcode/lib/renderer/canvas.js +63 -0
- package/node_modules/qrcode/lib/renderer/png.js +78 -0
- package/node_modules/qrcode/lib/renderer/svg-tag.js +81 -0
- package/node_modules/qrcode/lib/renderer/svg.js +19 -0
- package/node_modules/qrcode/lib/renderer/terminal/terminal-small.js +85 -0
- package/node_modules/qrcode/lib/renderer/terminal/terminal.js +49 -0
- package/node_modules/qrcode/lib/renderer/terminal.js +9 -0
- package/node_modules/qrcode/lib/renderer/utf8.js +71 -0
- package/node_modules/qrcode/lib/renderer/utils.js +99 -0
- package/node_modules/qrcode/lib/server.js +138 -0
- package/node_modules/qrcode/license +10 -0
- package/node_modules/qrcode/package.json +77 -0
- package/node_modules/require-directory/.jshintrc +67 -0
- package/node_modules/require-directory/.npmignore +1 -0
- package/node_modules/require-directory/.travis.yml +3 -0
- package/node_modules/require-directory/LICENSE +22 -0
- package/node_modules/require-directory/README.markdown +184 -0
- package/node_modules/require-directory/index.js +86 -0
- package/node_modules/require-directory/package.json +40 -0
- package/node_modules/require-main-filename/LICENSE.txt +14 -0
- package/node_modules/require-main-filename/README.md +26 -0
- package/node_modules/require-main-filename/index.js +18 -0
- package/node_modules/require-main-filename/package.json +35 -0
- package/node_modules/set-blocking/LICENSE.txt +14 -0
- package/node_modules/set-blocking/README.md +31 -0
- package/node_modules/set-blocking/index.js +7 -0
- package/node_modules/set-blocking/package.json +42 -0
- package/node_modules/string-width/index.d.ts +29 -0
- package/node_modules/string-width/index.js +47 -0
- package/node_modules/string-width/license +9 -0
- package/node_modules/string-width/package.json +56 -0
- package/node_modules/string-width/readme.md +50 -0
- package/node_modules/strip-ansi/index.d.ts +17 -0
- package/node_modules/strip-ansi/index.js +4 -0
- package/node_modules/strip-ansi/license +9 -0
- package/node_modules/strip-ansi/package.json +54 -0
- package/node_modules/strip-ansi/readme.md +46 -0
- package/node_modules/which-module/LICENSE +13 -0
- package/node_modules/which-module/README.md +58 -0
- package/node_modules/which-module/index.js +9 -0
- package/node_modules/which-module/package.json +41 -0
- package/node_modules/wrap-ansi/index.js +186 -0
- package/node_modules/wrap-ansi/license +9 -0
- package/node_modules/wrap-ansi/package.json +61 -0
- package/node_modules/wrap-ansi/readme.md +97 -0
- package/node_modules/ws/LICENSE +20 -0
- package/node_modules/ws/README.md +548 -0
- package/node_modules/ws/browser.js +8 -0
- package/node_modules/ws/index.js +22 -0
- package/node_modules/ws/lib/buffer-util.js +131 -0
- package/node_modules/ws/lib/constants.js +19 -0
- package/node_modules/ws/lib/event-target.js +292 -0
- package/node_modules/ws/lib/extension.js +203 -0
- package/node_modules/ws/lib/limiter.js +55 -0
- package/node_modules/ws/lib/permessage-deflate.js +530 -0
- package/node_modules/ws/lib/receiver.js +743 -0
- package/node_modules/ws/lib/sender.js +607 -0
- package/node_modules/ws/lib/stream.js +161 -0
- package/node_modules/ws/lib/subprotocol.js +62 -0
- package/node_modules/ws/lib/validation.js +152 -0
- package/node_modules/ws/lib/websocket-server.js +562 -0
- package/node_modules/ws/lib/websocket.js +1407 -0
- package/node_modules/ws/package.json +74 -0
- package/node_modules/ws/wrapper.mjs +21 -0
- package/node_modules/y18n/LICENSE +13 -0
- package/node_modules/y18n/README.md +109 -0
- package/node_modules/y18n/index.js +188 -0
- package/node_modules/y18n/package.json +39 -0
- package/node_modules/yargs/LICENSE +21 -0
- package/node_modules/yargs/README.md +140 -0
- package/node_modules/yargs/build/lib/apply-extends.d.ts +2 -0
- package/node_modules/yargs/build/lib/apply-extends.js +65 -0
- package/node_modules/yargs/build/lib/argsert.d.ts +2 -0
- package/node_modules/yargs/build/lib/argsert.js +65 -0
- package/node_modules/yargs/build/lib/command.d.ts +64 -0
- package/node_modules/yargs/build/lib/command.js +416 -0
- package/node_modules/yargs/build/lib/common-types.d.ts +36 -0
- package/node_modules/yargs/build/lib/common-types.js +25 -0
- package/node_modules/yargs/build/lib/completion-templates.d.ts +2 -0
- package/node_modules/yargs/build/lib/completion-templates.js +50 -0
- package/node_modules/yargs/build/lib/completion.d.ts +21 -0
- package/node_modules/yargs/build/lib/completion.js +135 -0
- package/node_modules/yargs/build/lib/is-promise.d.ts +1 -0
- package/node_modules/yargs/build/lib/is-promise.js +9 -0
- package/node_modules/yargs/build/lib/levenshtein.d.ts +1 -0
- package/node_modules/yargs/build/lib/levenshtein.js +58 -0
- package/node_modules/yargs/build/lib/middleware.d.ts +10 -0
- package/node_modules/yargs/build/lib/middleware.js +57 -0
- package/node_modules/yargs/build/lib/obj-filter.d.ts +1 -0
- package/node_modules/yargs/build/lib/obj-filter.js +14 -0
- package/node_modules/yargs/build/lib/parse-command.d.ts +11 -0
- package/node_modules/yargs/build/lib/parse-command.js +36 -0
- package/node_modules/yargs/build/lib/process-argv.d.ts +2 -0
- package/node_modules/yargs/build/lib/process-argv.js +31 -0
- package/node_modules/yargs/build/lib/usage.d.ts +49 -0
- package/node_modules/yargs/build/lib/usage.js +540 -0
- package/node_modules/yargs/build/lib/validation.d.ts +34 -0
- package/node_modules/yargs/build/lib/validation.js +330 -0
- package/node_modules/yargs/build/lib/yargs.d.ts +274 -0
- package/node_modules/yargs/build/lib/yargs.js +1190 -0
- package/node_modules/yargs/build/lib/yerror.d.ts +4 -0
- package/node_modules/yargs/build/lib/yerror.js +11 -0
- package/node_modules/yargs/index.js +40 -0
- package/node_modules/yargs/locales/be.json +46 -0
- package/node_modules/yargs/locales/de.json +46 -0
- package/node_modules/yargs/locales/en.json +51 -0
- package/node_modules/yargs/locales/es.json +46 -0
- package/node_modules/yargs/locales/fi.json +49 -0
- package/node_modules/yargs/locales/fr.json +53 -0
- package/node_modules/yargs/locales/hi.json +49 -0
- package/node_modules/yargs/locales/hu.json +46 -0
- package/node_modules/yargs/locales/id.json +50 -0
- package/node_modules/yargs/locales/it.json +46 -0
- package/node_modules/yargs/locales/ja.json +51 -0
- package/node_modules/yargs/locales/ko.json +49 -0
- package/node_modules/yargs/locales/nb.json +44 -0
- package/node_modules/yargs/locales/nl.json +49 -0
- package/node_modules/yargs/locales/nn.json +44 -0
- package/node_modules/yargs/locales/pirate.json +13 -0
- package/node_modules/yargs/locales/pl.json +49 -0
- package/node_modules/yargs/locales/pt.json +45 -0
- package/node_modules/yargs/locales/pt_BR.json +48 -0
- package/node_modules/yargs/locales/ru.json +46 -0
- package/node_modules/yargs/locales/th.json +46 -0
- package/node_modules/yargs/locales/tr.json +48 -0
- package/node_modules/yargs/locales/zh_CN.json +48 -0
- package/node_modules/yargs/locales/zh_TW.json +47 -0
- package/node_modules/yargs/package.json +92 -0
- package/node_modules/yargs/yargs.js +14 -0
- package/node_modules/yargs-parser/LICENSE.txt +14 -0
- package/node_modules/yargs-parser/README.md +449 -0
- package/node_modules/yargs-parser/index.js +1032 -0
- package/node_modules/yargs-parser/lib/tokenize-arg-string.js +40 -0
- package/node_modules/yargs-parser/package.json +46 -0
- package/node_modules/zod/LICENSE +21 -0
- package/node_modules/zod/README.md +191 -0
- package/node_modules/zod/index.cjs +33 -0
- package/node_modules/zod/index.d.cts +4 -0
- package/node_modules/zod/index.d.ts +4 -0
- package/node_modules/zod/index.js +4 -0
- package/node_modules/zod/locales/index.cjs +17 -0
- package/node_modules/zod/locales/index.d.cts +1 -0
- package/node_modules/zod/locales/index.d.ts +1 -0
- package/node_modules/zod/locales/index.js +1 -0
- package/node_modules/zod/locales/package.json +7 -0
- package/node_modules/zod/mini/index.cjs +32 -0
- package/node_modules/zod/mini/index.d.cts +3 -0
- package/node_modules/zod/mini/index.d.ts +3 -0
- package/node_modules/zod/mini/index.js +3 -0
- package/node_modules/zod/mini/package.json +7 -0
- package/node_modules/zod/package.json +135 -0
- package/node_modules/zod/src/index.ts +4 -0
- package/node_modules/zod/src/locales/index.ts +1 -0
- package/node_modules/zod/src/mini/index.ts +3 -0
- package/node_modules/zod/src/v3/ZodError.ts +330 -0
- package/node_modules/zod/src/v3/benchmarks/datetime.ts +58 -0
- package/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +80 -0
- package/node_modules/zod/src/v3/benchmarks/index.ts +59 -0
- package/node_modules/zod/src/v3/benchmarks/ipv4.ts +57 -0
- package/node_modules/zod/src/v3/benchmarks/object.ts +69 -0
- package/node_modules/zod/src/v3/benchmarks/primitives.ts +162 -0
- package/node_modules/zod/src/v3/benchmarks/realworld.ts +63 -0
- package/node_modules/zod/src/v3/benchmarks/string.ts +55 -0
- package/node_modules/zod/src/v3/benchmarks/union.ts +80 -0
- package/node_modules/zod/src/v3/errors.ts +13 -0
- package/node_modules/zod/src/v3/external.ts +6 -0
- package/node_modules/zod/src/v3/helpers/enumUtil.ts +17 -0
- package/node_modules/zod/src/v3/helpers/errorUtil.ts +8 -0
- package/node_modules/zod/src/v3/helpers/parseUtil.ts +176 -0
- package/node_modules/zod/src/v3/helpers/partialUtil.ts +34 -0
- package/node_modules/zod/src/v3/helpers/typeAliases.ts +2 -0
- package/node_modules/zod/src/v3/helpers/util.ts +224 -0
- package/node_modules/zod/src/v3/index.ts +4 -0
- package/node_modules/zod/src/v3/locales/en.ts +124 -0
- package/node_modules/zod/src/v3/standard-schema.ts +113 -0
- package/node_modules/zod/src/v3/tests/Mocker.ts +54 -0
- package/node_modules/zod/src/v3/tests/all-errors.test.ts +157 -0
- package/node_modules/zod/src/v3/tests/anyunknown.test.ts +28 -0
- package/node_modules/zod/src/v3/tests/array.test.ts +71 -0
- package/node_modules/zod/src/v3/tests/async-parsing.test.ts +388 -0
- package/node_modules/zod/src/v3/tests/async-refinements.test.ts +46 -0
- package/node_modules/zod/src/v3/tests/base.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/bigint.test.ts +55 -0
- package/node_modules/zod/src/v3/tests/branded.test.ts +53 -0
- package/node_modules/zod/src/v3/tests/catch.test.ts +220 -0
- package/node_modules/zod/src/v3/tests/coerce.test.ts +133 -0
- package/node_modules/zod/src/v3/tests/complex.test.ts +70 -0
- package/node_modules/zod/src/v3/tests/custom.test.ts +31 -0
- package/node_modules/zod/src/v3/tests/date.test.ts +32 -0
- package/node_modules/zod/src/v3/tests/deepmasking.test.ts +186 -0
- package/node_modules/zod/src/v3/tests/default.test.ts +112 -0
- package/node_modules/zod/src/v3/tests/description.test.ts +33 -0
- package/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +315 -0
- package/node_modules/zod/src/v3/tests/enum.test.ts +80 -0
- package/node_modules/zod/src/v3/tests/error.test.ts +551 -0
- package/node_modules/zod/src/v3/tests/firstparty.test.ts +87 -0
- package/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +21 -0
- package/node_modules/zod/src/v3/tests/function.test.ts +261 -0
- package/node_modules/zod/src/v3/tests/generics.test.ts +48 -0
- package/node_modules/zod/src/v3/tests/instanceof.test.ts +37 -0
- package/node_modules/zod/src/v3/tests/intersection.test.ts +110 -0
- package/node_modules/zod/src/v3/tests/language-server.source.ts +76 -0
- package/node_modules/zod/src/v3/tests/language-server.test.ts +207 -0
- package/node_modules/zod/src/v3/tests/literal.test.ts +36 -0
- package/node_modules/zod/src/v3/tests/map.test.ts +110 -0
- package/node_modules/zod/src/v3/tests/masking.test.ts +4 -0
- package/node_modules/zod/src/v3/tests/mocker.test.ts +19 -0
- package/node_modules/zod/src/v3/tests/nan.test.ts +24 -0
- package/node_modules/zod/src/v3/tests/nativeEnum.test.ts +87 -0
- package/node_modules/zod/src/v3/tests/nullable.test.ts +42 -0
- package/node_modules/zod/src/v3/tests/number.test.ts +176 -0
- package/node_modules/zod/src/v3/tests/object-augmentation.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/object.test.ts +434 -0
- package/node_modules/zod/src/v3/tests/optional.test.ts +42 -0
- package/node_modules/zod/src/v3/tests/parseUtil.test.ts +23 -0
- package/node_modules/zod/src/v3/tests/parser.test.ts +41 -0
- package/node_modules/zod/src/v3/tests/partials.test.ts +243 -0
- package/node_modules/zod/src/v3/tests/pickomit.test.ts +111 -0
- package/node_modules/zod/src/v3/tests/pipeline.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/preprocess.test.ts +186 -0
- package/node_modules/zod/src/v3/tests/primitive.test.ts +440 -0
- package/node_modules/zod/src/v3/tests/promise.test.ts +90 -0
- package/node_modules/zod/src/v3/tests/readonly.test.ts +194 -0
- package/node_modules/zod/src/v3/tests/record.test.ts +171 -0
- package/node_modules/zod/src/v3/tests/recursive.test.ts +197 -0
- package/node_modules/zod/src/v3/tests/refine.test.ts +313 -0
- package/node_modules/zod/src/v3/tests/safeparse.test.ts +27 -0
- package/node_modules/zod/src/v3/tests/set.test.ts +142 -0
- package/node_modules/zod/src/v3/tests/standard-schema.test.ts +83 -0
- package/node_modules/zod/src/v3/tests/string.test.ts +916 -0
- package/node_modules/zod/src/v3/tests/transformer.test.ts +233 -0
- package/node_modules/zod/src/v3/tests/tuple.test.ts +90 -0
- package/node_modules/zod/src/v3/tests/unions.test.ts +57 -0
- package/node_modules/zod/src/v3/tests/validations.test.ts +133 -0
- package/node_modules/zod/src/v3/tests/void.test.ts +15 -0
- package/node_modules/zod/src/v3/types.ts +5138 -0
- package/node_modules/zod/src/v4/classic/checks.ts +32 -0
- package/node_modules/zod/src/v4/classic/coerce.ts +27 -0
- package/node_modules/zod/src/v4/classic/compat.ts +70 -0
- package/node_modules/zod/src/v4/classic/errors.ts +82 -0
- package/node_modules/zod/src/v4/classic/external.ts +52 -0
- package/node_modules/zod/src/v4/classic/from-json-schema.ts +659 -0
- package/node_modules/zod/src/v4/classic/index.ts +5 -0
- package/node_modules/zod/src/v4/classic/iso.ts +90 -0
- package/node_modules/zod/src/v4/classic/parse.ts +82 -0
- package/node_modules/zod/src/v4/classic/schemas.ts +2672 -0
- package/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +26 -0
- package/node_modules/zod/src/v4/classic/tests/apply.test.ts +59 -0
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +264 -0
- package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +216 -0
- package/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +381 -0
- package/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +68 -0
- package/node_modules/zod/src/v4/classic/tests/base.test.ts +7 -0
- package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +54 -0
- package/node_modules/zod/src/v4/classic/tests/brand.test.ts +106 -0
- package/node_modules/zod/src/v4/classic/tests/catch.test.ts +326 -0
- package/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +20 -0
- package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +573 -0
- package/node_modules/zod/src/v4/classic/tests/codec.test.ts +703 -0
- package/node_modules/zod/src/v4/classic/tests/coerce.test.ts +160 -0
- package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +374 -0
- package/node_modules/zod/src/v4/classic/tests/custom.test.ts +40 -0
- package/node_modules/zod/src/v4/classic/tests/date.test.ts +62 -0
- package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +302 -0
- package/node_modules/zod/src/v4/classic/tests/default.test.ts +409 -0
- package/node_modules/zod/src/v4/classic/tests/describe-meta-checks.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/description.test.ts +32 -0
- package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +197 -0
- package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +694 -0
- package/node_modules/zod/src/v4/classic/tests/enum.test.ts +285 -0
- package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +807 -0
- package/node_modules/zod/src/v4/classic/tests/error.test.ts +711 -0
- package/node_modules/zod/src/v4/classic/tests/file.test.ts +96 -0
- package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +179 -0
- package/node_modules/zod/src/v4/classic/tests/fix-json-issue.test.ts +26 -0
- package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +895 -0
- package/node_modules/zod/src/v4/classic/tests/function.test.ts +360 -0
- package/node_modules/zod/src/v4/classic/tests/generics.test.ts +72 -0
- package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +39 -0
- package/node_modules/zod/src/v4/classic/tests/hash.test.ts +68 -0
- package/node_modules/zod/src/v4/classic/tests/index.test.ts +939 -0
- package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +60 -0
- package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +198 -0
- package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +46 -0
- package/node_modules/zod/src/v4/classic/tests/json.test.ts +109 -0
- package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +227 -0
- package/node_modules/zod/src/v4/classic/tests/literal.test.ts +117 -0
- package/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +29 -0
- package/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +24 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +330 -0
- package/node_modules/zod/src/v4/classic/tests/nan.test.ts +21 -0
- package/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +168 -0
- package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +101 -0
- package/node_modules/zod/src/v4/classic/tests/nullable.test.ts +22 -0
- package/node_modules/zod/src/v4/classic/tests/number.test.ts +325 -0
- package/node_modules/zod/src/v4/classic/tests/object.test.ts +717 -0
- package/node_modules/zod/src/v4/classic/tests/optional.test.ts +333 -0
- package/node_modules/zod/src/v4/classic/tests/partial.test.ts +450 -0
- package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +211 -0
- package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +101 -0
- package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +74 -0
- package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +26 -0
- package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +351 -0
- package/node_modules/zod/src/v4/classic/tests/primitive.test.ts +175 -0
- package/node_modules/zod/src/v4/classic/tests/promise.test.ts +81 -0
- package/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +23 -0
- package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +252 -0
- package/node_modules/zod/src/v4/classic/tests/record.test.ts +717 -0
- package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +631 -0
- package/node_modules/zod/src/v4/classic/tests/refine.test.ts +633 -0
- package/node_modules/zod/src/v4/classic/tests/registries.test.ts +243 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +181 -0
- package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +134 -0
- package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +125 -0
- package/node_modules/zod/src/v4/classic/tests/string.test.ts +1224 -0
- package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +106 -0
- package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +771 -0
- package/node_modules/zod/src/v4/classic/tests/to-json-schema-methods.test.ts +438 -0
- package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +3125 -0
- package/node_modules/zod/src/v4/classic/tests/transform.test.ts +378 -0
- package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +496 -0
- package/node_modules/zod/src/v4/classic/tests/union.test.ts +273 -0
- package/node_modules/zod/src/v4/classic/tests/url.test.ts +13 -0
- package/node_modules/zod/src/v4/classic/tests/validations.test.ts +283 -0
- package/node_modules/zod/src/v4/classic/tests/void.test.ts +12 -0
- package/node_modules/zod/src/v4/core/api.ts +1823 -0
- package/node_modules/zod/src/v4/core/checks.ts +1293 -0
- package/node_modules/zod/src/v4/core/config.ts +15 -0
- package/node_modules/zod/src/v4/core/core.ts +153 -0
- package/node_modules/zod/src/v4/core/doc.ts +44 -0
- package/node_modules/zod/src/v4/core/errors.ts +455 -0
- package/node_modules/zod/src/v4/core/index.ts +16 -0
- package/node_modules/zod/src/v4/core/json-schema-generator.ts +126 -0
- package/node_modules/zod/src/v4/core/json-schema-processors.ts +666 -0
- package/node_modules/zod/src/v4/core/json-schema.ts +147 -0
- package/node_modules/zod/src/v4/core/parse.ts +195 -0
- package/node_modules/zod/src/v4/core/regexes.ts +190 -0
- package/node_modules/zod/src/v4/core/registries.ts +105 -0
- package/node_modules/zod/src/v4/core/schemas.ts +4730 -0
- package/node_modules/zod/src/v4/core/standard-schema.ts +159 -0
- package/node_modules/zod/src/v4/core/tests/extend.test.ts +59 -0
- package/node_modules/zod/src/v4/core/tests/index.test.ts +46 -0
- package/node_modules/zod/src/v4/core/tests/locales/be.test.ts +124 -0
- package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +215 -0
- package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +22 -0
- package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +181 -0
- package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +72 -0
- package/node_modules/zod/src/v4/core/tests/locales/he.test.ts +379 -0
- package/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +163 -0
- package/node_modules/zod/src/v4/core/tests/locales/nl.test.ts +46 -0
- package/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +128 -0
- package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +69 -0
- package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +105 -0
- package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +125 -0
- package/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts +45 -0
- package/node_modules/zod/src/v4/core/to-json-schema.ts +622 -0
- package/node_modules/zod/src/v4/core/util.ts +983 -0
- package/node_modules/zod/src/v4/core/versions.ts +5 -0
- package/node_modules/zod/src/v4/core/zsf.ts +323 -0
- package/node_modules/zod/src/v4/index.ts +4 -0
- package/node_modules/zod/src/v4/locales/ar.ts +115 -0
- package/node_modules/zod/src/v4/locales/az.ts +111 -0
- package/node_modules/zod/src/v4/locales/be.ts +176 -0
- package/node_modules/zod/src/v4/locales/bg.ts +128 -0
- package/node_modules/zod/src/v4/locales/ca.ts +116 -0
- package/node_modules/zod/src/v4/locales/cs.ts +118 -0
- package/node_modules/zod/src/v4/locales/da.ts +123 -0
- package/node_modules/zod/src/v4/locales/de.ts +116 -0
- package/node_modules/zod/src/v4/locales/el.ts +121 -0
- package/node_modules/zod/src/v4/locales/en.ts +123 -0
- package/node_modules/zod/src/v4/locales/eo.ts +118 -0
- package/node_modules/zod/src/v4/locales/es.ts +141 -0
- package/node_modules/zod/src/v4/locales/fa.ts +126 -0
- package/node_modules/zod/src/v4/locales/fi.ts +121 -0
- package/node_modules/zod/src/v4/locales/fr-CA.ts +116 -0
- package/node_modules/zod/src/v4/locales/fr.ts +132 -0
- package/node_modules/zod/src/v4/locales/he.ts +246 -0
- package/node_modules/zod/src/v4/locales/hr.ts +131 -0
- package/node_modules/zod/src/v4/locales/hu.ts +117 -0
- package/node_modules/zod/src/v4/locales/hy.ts +164 -0
- package/node_modules/zod/src/v4/locales/id.ts +115 -0
- package/node_modules/zod/src/v4/locales/index.ts +52 -0
- package/node_modules/zod/src/v4/locales/is.ts +119 -0
- package/node_modules/zod/src/v4/locales/it.ts +116 -0
- package/node_modules/zod/src/v4/locales/ja.ts +114 -0
- package/node_modules/zod/src/v4/locales/ka.ts +123 -0
- package/node_modules/zod/src/v4/locales/kh.ts +7 -0
- package/node_modules/zod/src/v4/locales/km.ts +119 -0
- package/node_modules/zod/src/v4/locales/ko.ts +121 -0
- package/node_modules/zod/src/v4/locales/lt.ts +239 -0
- package/node_modules/zod/src/v4/locales/mk.ts +118 -0
- package/node_modules/zod/src/v4/locales/ms.ts +115 -0
- package/node_modules/zod/src/v4/locales/nl.ts +121 -0
- package/node_modules/zod/src/v4/locales/no.ts +116 -0
- package/node_modules/zod/src/v4/locales/ota.ts +117 -0
- package/node_modules/zod/src/v4/locales/pl.ts +118 -0
- package/node_modules/zod/src/v4/locales/ps.ts +126 -0
- package/node_modules/zod/src/v4/locales/pt.ts +116 -0
- package/node_modules/zod/src/v4/locales/ro.ts +129 -0
- package/node_modules/zod/src/v4/locales/ru.ts +176 -0
- package/node_modules/zod/src/v4/locales/sl.ts +118 -0
- package/node_modules/zod/src/v4/locales/sv.ts +119 -0
- package/node_modules/zod/src/v4/locales/ta.ts +118 -0
- package/node_modules/zod/src/v4/locales/th.ts +119 -0
- package/node_modules/zod/src/v4/locales/tr.ts +111 -0
- package/node_modules/zod/src/v4/locales/ua.ts +7 -0
- package/node_modules/zod/src/v4/locales/uk.ts +117 -0
- package/node_modules/zod/src/v4/locales/ur.ts +119 -0
- package/node_modules/zod/src/v4/locales/uz.ts +117 -0
- package/node_modules/zod/src/v4/locales/vi.ts +117 -0
- package/node_modules/zod/src/v4/locales/yo.ts +124 -0
- package/node_modules/zod/src/v4/locales/zh-CN.ts +116 -0
- package/node_modules/zod/src/v4/locales/zh-TW.ts +115 -0
- package/node_modules/zod/src/v4/mini/checks.ts +32 -0
- package/node_modules/zod/src/v4/mini/coerce.ts +27 -0
- package/node_modules/zod/src/v4/mini/external.ts +41 -0
- package/node_modules/zod/src/v4/mini/index.ts +3 -0
- package/node_modules/zod/src/v4/mini/iso.ts +66 -0
- package/node_modules/zod/src/v4/mini/parse.ts +14 -0
- package/node_modules/zod/src/v4/mini/schemas.ts +1947 -0
- package/node_modules/zod/src/v4/mini/tests/apply.test.ts +24 -0
- package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +129 -0
- package/node_modules/zod/src/v4/mini/tests/brand.test.ts +94 -0
- package/node_modules/zod/src/v4/mini/tests/checks.test.ts +144 -0
- package/node_modules/zod/src/v4/mini/tests/codec.test.ts +548 -0
- package/node_modules/zod/src/v4/mini/tests/computed.test.ts +36 -0
- package/node_modules/zod/src/v4/mini/tests/error.test.ts +22 -0
- package/node_modules/zod/src/v4/mini/tests/functions.test.ts +5 -0
- package/node_modules/zod/src/v4/mini/tests/index.test.ts +993 -0
- package/node_modules/zod/src/v4/mini/tests/number.test.ts +95 -0
- package/node_modules/zod/src/v4/mini/tests/object.test.ts +227 -0
- package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +43 -0
- package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +325 -0
- package/node_modules/zod/src/v4/mini/tests/standard-schema.test.ts +50 -0
- package/node_modules/zod/src/v4/mini/tests/string.test.ts +352 -0
- package/node_modules/zod/src/v4-mini/index.ts +3 -0
- package/node_modules/zod/v3/ZodError.cjs +138 -0
- package/node_modules/zod/v3/ZodError.d.cts +164 -0
- package/node_modules/zod/v3/ZodError.d.ts +164 -0
- package/node_modules/zod/v3/ZodError.js +133 -0
- package/node_modules/zod/v3/errors.cjs +17 -0
- package/node_modules/zod/v3/errors.d.cts +5 -0
- package/node_modules/zod/v3/errors.d.ts +5 -0
- package/node_modules/zod/v3/errors.js +9 -0
- package/node_modules/zod/v3/external.cjs +22 -0
- package/node_modules/zod/v3/external.d.cts +6 -0
- package/node_modules/zod/v3/external.d.ts +6 -0
- package/node_modules/zod/v3/external.js +6 -0
- package/node_modules/zod/v3/helpers/enumUtil.cjs +2 -0
- package/node_modules/zod/v3/helpers/enumUtil.d.cts +8 -0
- package/node_modules/zod/v3/helpers/enumUtil.d.ts +8 -0
- package/node_modules/zod/v3/helpers/enumUtil.js +1 -0
- package/node_modules/zod/v3/helpers/errorUtil.cjs +9 -0
- package/node_modules/zod/v3/helpers/errorUtil.d.cts +9 -0
- package/node_modules/zod/v3/helpers/errorUtil.d.ts +9 -0
- package/node_modules/zod/v3/helpers/errorUtil.js +6 -0
- package/node_modules/zod/v3/helpers/parseUtil.cjs +124 -0
- package/node_modules/zod/v3/helpers/parseUtil.d.cts +78 -0
- package/node_modules/zod/v3/helpers/parseUtil.d.ts +78 -0
- package/node_modules/zod/v3/helpers/parseUtil.js +109 -0
- package/node_modules/zod/v3/helpers/partialUtil.cjs +2 -0
- package/node_modules/zod/v3/helpers/partialUtil.d.cts +8 -0
- package/node_modules/zod/v3/helpers/partialUtil.d.ts +8 -0
- package/node_modules/zod/v3/helpers/partialUtil.js +1 -0
- package/node_modules/zod/v3/helpers/typeAliases.cjs +2 -0
- package/node_modules/zod/v3/helpers/typeAliases.d.cts +2 -0
- package/node_modules/zod/v3/helpers/typeAliases.d.ts +2 -0
- package/node_modules/zod/v3/helpers/typeAliases.js +1 -0
- package/node_modules/zod/v3/helpers/util.cjs +137 -0
- package/node_modules/zod/v3/helpers/util.d.cts +85 -0
- package/node_modules/zod/v3/helpers/util.d.ts +85 -0
- package/node_modules/zod/v3/helpers/util.js +133 -0
- package/node_modules/zod/v3/index.cjs +33 -0
- package/node_modules/zod/v3/index.d.cts +4 -0
- package/node_modules/zod/v3/index.d.ts +4 -0
- package/node_modules/zod/v3/index.js +4 -0
- package/node_modules/zod/v3/locales/en.cjs +112 -0
- package/node_modules/zod/v3/locales/en.d.cts +3 -0
- package/node_modules/zod/v3/locales/en.d.ts +3 -0
- package/node_modules/zod/v3/locales/en.js +109 -0
- package/node_modules/zod/v3/package.json +7 -0
- package/node_modules/zod/v3/standard-schema.cjs +2 -0
- package/node_modules/zod/v3/standard-schema.d.cts +102 -0
- package/node_modules/zod/v3/standard-schema.d.ts +102 -0
- package/node_modules/zod/v3/standard-schema.js +1 -0
- package/node_modules/zod/v3/types.cjs +3777 -0
- package/node_modules/zod/v3/types.d.cts +1034 -0
- package/node_modules/zod/v3/types.d.ts +1034 -0
- package/node_modules/zod/v3/types.js +3695 -0
- package/node_modules/zod/v4/classic/checks.cjs +33 -0
- package/node_modules/zod/v4/classic/checks.d.cts +1 -0
- package/node_modules/zod/v4/classic/checks.d.ts +1 -0
- package/node_modules/zod/v4/classic/checks.js +1 -0
- package/node_modules/zod/v4/classic/coerce.cjs +47 -0
- package/node_modules/zod/v4/classic/coerce.d.cts +17 -0
- package/node_modules/zod/v4/classic/coerce.d.ts +17 -0
- package/node_modules/zod/v4/classic/coerce.js +17 -0
- package/node_modules/zod/v4/classic/compat.cjs +61 -0
- package/node_modules/zod/v4/classic/compat.d.cts +50 -0
- package/node_modules/zod/v4/classic/compat.d.ts +50 -0
- package/node_modules/zod/v4/classic/compat.js +31 -0
- package/node_modules/zod/v4/classic/errors.cjs +74 -0
- package/node_modules/zod/v4/classic/errors.d.cts +30 -0
- package/node_modules/zod/v4/classic/errors.d.ts +30 -0
- package/node_modules/zod/v4/classic/errors.js +48 -0
- package/node_modules/zod/v4/classic/external.cjs +73 -0
- package/node_modules/zod/v4/classic/external.d.cts +16 -0
- package/node_modules/zod/v4/classic/external.d.ts +16 -0
- package/node_modules/zod/v4/classic/external.js +20 -0
- package/node_modules/zod/v4/classic/from-json-schema.cjs +625 -0
- package/node_modules/zod/v4/classic/from-json-schema.d.cts +12 -0
- package/node_modules/zod/v4/classic/from-json-schema.d.ts +12 -0
- package/node_modules/zod/v4/classic/from-json-schema.js +599 -0
- package/node_modules/zod/v4/classic/index.cjs +33 -0
- package/node_modules/zod/v4/classic/index.d.cts +4 -0
- package/node_modules/zod/v4/classic/index.d.ts +4 -0
- package/node_modules/zod/v4/classic/index.js +4 -0
- package/node_modules/zod/v4/classic/iso.cjs +60 -0
- package/node_modules/zod/v4/classic/iso.d.cts +22 -0
- package/node_modules/zod/v4/classic/iso.d.ts +22 -0
- package/node_modules/zod/v4/classic/iso.js +30 -0
- package/node_modules/zod/v4/classic/package.json +7 -0
- package/node_modules/zod/v4/classic/parse.cjs +41 -0
- package/node_modules/zod/v4/classic/parse.d.cts +31 -0
- package/node_modules/zod/v4/classic/parse.d.ts +31 -0
- package/node_modules/zod/v4/classic/parse.js +15 -0
- package/node_modules/zod/v4/classic/schemas.cjs +1511 -0
- package/node_modules/zod/v4/classic/schemas.d.cts +767 -0
- package/node_modules/zod/v4/classic/schemas.d.ts +767 -0
- package/node_modules/zod/v4/classic/schemas.js +1395 -0
- package/node_modules/zod/v4/core/api.cjs +1227 -0
- package/node_modules/zod/v4/core/api.d.cts +325 -0
- package/node_modules/zod/v4/core/api.d.ts +325 -0
- package/node_modules/zod/v4/core/api.js +1087 -0
- package/node_modules/zod/v4/core/checks.cjs +601 -0
- package/node_modules/zod/v4/core/checks.d.cts +278 -0
- package/node_modules/zod/v4/core/checks.d.ts +278 -0
- package/node_modules/zod/v4/core/checks.js +575 -0
- package/node_modules/zod/v4/core/core.cjs +85 -0
- package/node_modules/zod/v4/core/core.d.cts +70 -0
- package/node_modules/zod/v4/core/core.d.ts +70 -0
- package/node_modules/zod/v4/core/core.js +78 -0
- package/node_modules/zod/v4/core/doc.cjs +39 -0
- package/node_modules/zod/v4/core/doc.d.cts +14 -0
- package/node_modules/zod/v4/core/doc.d.ts +14 -0
- package/node_modules/zod/v4/core/doc.js +35 -0
- package/node_modules/zod/v4/core/errors.cjs +216 -0
- package/node_modules/zod/v4/core/errors.d.cts +221 -0
- package/node_modules/zod/v4/core/errors.d.ts +221 -0
- package/node_modules/zod/v4/core/errors.js +185 -0
- package/node_modules/zod/v4/core/index.cjs +47 -0
- package/node_modules/zod/v4/core/index.d.cts +16 -0
- package/node_modules/zod/v4/core/index.d.ts +16 -0
- package/node_modules/zod/v4/core/index.js +16 -0
- package/node_modules/zod/v4/core/json-schema-generator.cjs +99 -0
- package/node_modules/zod/v4/core/json-schema-generator.d.cts +65 -0
- package/node_modules/zod/v4/core/json-schema-generator.d.ts +65 -0
- package/node_modules/zod/v4/core/json-schema-generator.js +95 -0
- package/node_modules/zod/v4/core/json-schema-processors.cjs +644 -0
- package/node_modules/zod/v4/core/json-schema-processors.d.cts +49 -0
- package/node_modules/zod/v4/core/json-schema-processors.d.ts +49 -0
- package/node_modules/zod/v4/core/json-schema-processors.js +601 -0
- package/node_modules/zod/v4/core/json-schema.cjs +2 -0
- package/node_modules/zod/v4/core/json-schema.d.cts +88 -0
- package/node_modules/zod/v4/core/json-schema.d.ts +88 -0
- package/node_modules/zod/v4/core/json-schema.js +1 -0
- package/node_modules/zod/v4/core/package.json +7 -0
- package/node_modules/zod/v4/core/parse.cjs +131 -0
- package/node_modules/zod/v4/core/parse.d.cts +49 -0
- package/node_modules/zod/v4/core/parse.d.ts +49 -0
- package/node_modules/zod/v4/core/parse.js +93 -0
- package/node_modules/zod/v4/core/regexes.cjs +172 -0
- package/node_modules/zod/v4/core/regexes.d.cts +85 -0
- package/node_modules/zod/v4/core/regexes.d.ts +85 -0
- package/node_modules/zod/v4/core/regexes.js +139 -0
- package/node_modules/zod/v4/core/registries.cjs +56 -0
- package/node_modules/zod/v4/core/registries.d.cts +35 -0
- package/node_modules/zod/v4/core/registries.d.ts +35 -0
- package/node_modules/zod/v4/core/registries.js +51 -0
- package/node_modules/zod/v4/core/schemas.cjs +2270 -0
- package/node_modules/zod/v4/core/schemas.d.cts +1184 -0
- package/node_modules/zod/v4/core/schemas.d.ts +1184 -0
- package/node_modules/zod/v4/core/schemas.js +2239 -0
- package/node_modules/zod/v4/core/standard-schema.cjs +2 -0
- package/node_modules/zod/v4/core/standard-schema.d.cts +126 -0
- package/node_modules/zod/v4/core/standard-schema.d.ts +126 -0
- package/node_modules/zod/v4/core/standard-schema.js +1 -0
- package/node_modules/zod/v4/core/to-json-schema.cjs +457 -0
- package/node_modules/zod/v4/core/to-json-schema.d.cts +114 -0
- package/node_modules/zod/v4/core/to-json-schema.d.ts +114 -0
- package/node_modules/zod/v4/core/to-json-schema.js +448 -0
- package/node_modules/zod/v4/core/util.cjs +734 -0
- package/node_modules/zod/v4/core/util.d.cts +200 -0
- package/node_modules/zod/v4/core/util.d.ts +200 -0
- package/node_modules/zod/v4/core/util.js +674 -0
- package/node_modules/zod/v4/core/versions.cjs +8 -0
- package/node_modules/zod/v4/core/versions.d.cts +5 -0
- package/node_modules/zod/v4/core/versions.d.ts +5 -0
- package/node_modules/zod/v4/core/versions.js +5 -0
- package/node_modules/zod/v4/index.cjs +22 -0
- package/node_modules/zod/v4/index.d.cts +3 -0
- package/node_modules/zod/v4/index.d.ts +3 -0
- package/node_modules/zod/v4/index.js +3 -0
- package/node_modules/zod/v4/locales/ar.cjs +133 -0
- package/node_modules/zod/v4/locales/ar.d.cts +5 -0
- package/node_modules/zod/v4/locales/ar.d.ts +4 -0
- package/node_modules/zod/v4/locales/ar.js +106 -0
- package/node_modules/zod/v4/locales/az.cjs +132 -0
- package/node_modules/zod/v4/locales/az.d.cts +5 -0
- package/node_modules/zod/v4/locales/az.d.ts +4 -0
- package/node_modules/zod/v4/locales/az.js +105 -0
- package/node_modules/zod/v4/locales/be.cjs +183 -0
- package/node_modules/zod/v4/locales/be.d.cts +5 -0
- package/node_modules/zod/v4/locales/be.d.ts +4 -0
- package/node_modules/zod/v4/locales/be.js +156 -0
- package/node_modules/zod/v4/locales/bg.cjs +147 -0
- package/node_modules/zod/v4/locales/bg.d.cts +5 -0
- package/node_modules/zod/v4/locales/bg.d.ts +4 -0
- package/node_modules/zod/v4/locales/bg.js +120 -0
- package/node_modules/zod/v4/locales/ca.cjs +134 -0
- package/node_modules/zod/v4/locales/ca.d.cts +5 -0
- package/node_modules/zod/v4/locales/ca.d.ts +4 -0
- package/node_modules/zod/v4/locales/ca.js +107 -0
- package/node_modules/zod/v4/locales/cs.cjs +138 -0
- package/node_modules/zod/v4/locales/cs.d.cts +5 -0
- package/node_modules/zod/v4/locales/cs.d.ts +4 -0
- package/node_modules/zod/v4/locales/cs.js +111 -0
- package/node_modules/zod/v4/locales/da.cjs +142 -0
- package/node_modules/zod/v4/locales/da.d.cts +5 -0
- package/node_modules/zod/v4/locales/da.d.ts +4 -0
- package/node_modules/zod/v4/locales/da.js +115 -0
- package/node_modules/zod/v4/locales/de.cjs +135 -0
- package/node_modules/zod/v4/locales/de.d.cts +5 -0
- package/node_modules/zod/v4/locales/de.d.ts +4 -0
- package/node_modules/zod/v4/locales/de.js +108 -0
- package/node_modules/zod/v4/locales/el.cjs +136 -0
- package/node_modules/zod/v4/locales/el.d.cts +5 -0
- package/node_modules/zod/v4/locales/el.d.ts +4 -0
- package/node_modules/zod/v4/locales/el.js +109 -0
- package/node_modules/zod/v4/locales/en.cjs +140 -0
- package/node_modules/zod/v4/locales/en.d.cts +5 -0
- package/node_modules/zod/v4/locales/en.d.ts +4 -0
- package/node_modules/zod/v4/locales/en.js +113 -0
- package/node_modules/zod/v4/locales/eo.cjs +136 -0
- package/node_modules/zod/v4/locales/eo.d.cts +5 -0
- package/node_modules/zod/v4/locales/eo.d.ts +4 -0
- package/node_modules/zod/v4/locales/eo.js +109 -0
- package/node_modules/zod/v4/locales/es.cjs +159 -0
- package/node_modules/zod/v4/locales/es.d.cts +5 -0
- package/node_modules/zod/v4/locales/es.d.ts +4 -0
- package/node_modules/zod/v4/locales/es.js +132 -0
- package/node_modules/zod/v4/locales/fa.cjs +141 -0
- package/node_modules/zod/v4/locales/fa.d.cts +5 -0
- package/node_modules/zod/v4/locales/fa.d.ts +4 -0
- package/node_modules/zod/v4/locales/fa.js +114 -0
- package/node_modules/zod/v4/locales/fi.cjs +139 -0
- package/node_modules/zod/v4/locales/fi.d.cts +5 -0
- package/node_modules/zod/v4/locales/fi.d.ts +4 -0
- package/node_modules/zod/v4/locales/fi.js +112 -0
- package/node_modules/zod/v4/locales/fr-CA.cjs +134 -0
- package/node_modules/zod/v4/locales/fr-CA.d.cts +5 -0
- package/node_modules/zod/v4/locales/fr-CA.d.ts +4 -0
- package/node_modules/zod/v4/locales/fr-CA.js +107 -0
- package/node_modules/zod/v4/locales/fr.cjs +152 -0
- package/node_modules/zod/v4/locales/fr.d.cts +5 -0
- package/node_modules/zod/v4/locales/fr.d.ts +4 -0
- package/node_modules/zod/v4/locales/fr.js +125 -0
- package/node_modules/zod/v4/locales/he.cjs +241 -0
- package/node_modules/zod/v4/locales/he.d.cts +5 -0
- package/node_modules/zod/v4/locales/he.d.ts +4 -0
- package/node_modules/zod/v4/locales/he.js +214 -0
- package/node_modules/zod/v4/locales/hr.cjs +149 -0
- package/node_modules/zod/v4/locales/hr.d.cts +5 -0
- package/node_modules/zod/v4/locales/hr.d.ts +4 -0
- package/node_modules/zod/v4/locales/hr.js +122 -0
- package/node_modules/zod/v4/locales/hu.cjs +135 -0
- package/node_modules/zod/v4/locales/hu.d.cts +5 -0
- package/node_modules/zod/v4/locales/hu.d.ts +4 -0
- package/node_modules/zod/v4/locales/hu.js +108 -0
- package/node_modules/zod/v4/locales/hy.cjs +174 -0
- package/node_modules/zod/v4/locales/hy.d.cts +5 -0
- package/node_modules/zod/v4/locales/hy.d.ts +4 -0
- package/node_modules/zod/v4/locales/hy.js +147 -0
- package/node_modules/zod/v4/locales/id.cjs +133 -0
- package/node_modules/zod/v4/locales/id.d.cts +5 -0
- package/node_modules/zod/v4/locales/id.d.ts +4 -0
- package/node_modules/zod/v4/locales/id.js +106 -0
- package/node_modules/zod/v4/locales/index.cjs +111 -0
- package/node_modules/zod/v4/locales/index.d.cts +52 -0
- package/node_modules/zod/v4/locales/index.d.ts +52 -0
- package/node_modules/zod/v4/locales/index.js +52 -0
- package/node_modules/zod/v4/locales/is.cjs +136 -0
- package/node_modules/zod/v4/locales/is.d.cts +5 -0
- package/node_modules/zod/v4/locales/is.d.ts +4 -0
- package/node_modules/zod/v4/locales/is.js +109 -0
- package/node_modules/zod/v4/locales/it.cjs +135 -0
- package/node_modules/zod/v4/locales/it.d.cts +5 -0
- package/node_modules/zod/v4/locales/it.d.ts +4 -0
- package/node_modules/zod/v4/locales/it.js +108 -0
- package/node_modules/zod/v4/locales/ja.cjs +134 -0
- package/node_modules/zod/v4/locales/ja.d.cts +5 -0
- package/node_modules/zod/v4/locales/ja.d.ts +4 -0
- package/node_modules/zod/v4/locales/ja.js +107 -0
- package/node_modules/zod/v4/locales/ka.cjs +139 -0
- package/node_modules/zod/v4/locales/ka.d.cts +5 -0
- package/node_modules/zod/v4/locales/ka.d.ts +4 -0
- package/node_modules/zod/v4/locales/ka.js +112 -0
- package/node_modules/zod/v4/locales/kh.cjs +12 -0
- package/node_modules/zod/v4/locales/kh.d.cts +5 -0
- package/node_modules/zod/v4/locales/kh.d.ts +5 -0
- package/node_modules/zod/v4/locales/kh.js +5 -0
- package/node_modules/zod/v4/locales/km.cjs +137 -0
- package/node_modules/zod/v4/locales/km.d.cts +5 -0
- package/node_modules/zod/v4/locales/km.d.ts +4 -0
- package/node_modules/zod/v4/locales/km.js +110 -0
- package/node_modules/zod/v4/locales/ko.cjs +138 -0
- package/node_modules/zod/v4/locales/ko.d.cts +5 -0
- package/node_modules/zod/v4/locales/ko.d.ts +4 -0
- package/node_modules/zod/v4/locales/ko.js +111 -0
- package/node_modules/zod/v4/locales/lt.cjs +230 -0
- package/node_modules/zod/v4/locales/lt.d.cts +5 -0
- package/node_modules/zod/v4/locales/lt.d.ts +4 -0
- package/node_modules/zod/v4/locales/lt.js +203 -0
- package/node_modules/zod/v4/locales/mk.cjs +136 -0
- package/node_modules/zod/v4/locales/mk.d.cts +5 -0
- package/node_modules/zod/v4/locales/mk.d.ts +4 -0
- package/node_modules/zod/v4/locales/mk.js +109 -0
- package/node_modules/zod/v4/locales/ms.cjs +134 -0
- package/node_modules/zod/v4/locales/ms.d.cts +5 -0
- package/node_modules/zod/v4/locales/ms.d.ts +4 -0
- package/node_modules/zod/v4/locales/ms.js +107 -0
- package/node_modules/zod/v4/locales/nl.cjs +137 -0
- package/node_modules/zod/v4/locales/nl.d.cts +5 -0
- package/node_modules/zod/v4/locales/nl.d.ts +4 -0
- package/node_modules/zod/v4/locales/nl.js +110 -0
- package/node_modules/zod/v4/locales/no.cjs +135 -0
- package/node_modules/zod/v4/locales/no.d.cts +5 -0
- package/node_modules/zod/v4/locales/no.d.ts +4 -0
- package/node_modules/zod/v4/locales/no.js +108 -0
- package/node_modules/zod/v4/locales/ota.cjs +136 -0
- package/node_modules/zod/v4/locales/ota.d.cts +5 -0
- package/node_modules/zod/v4/locales/ota.d.ts +4 -0
- package/node_modules/zod/v4/locales/ota.js +109 -0
- package/node_modules/zod/v4/locales/package.json +7 -0
- package/node_modules/zod/v4/locales/pl.cjs +136 -0
- package/node_modules/zod/v4/locales/pl.d.cts +5 -0
- package/node_modules/zod/v4/locales/pl.d.ts +4 -0
- package/node_modules/zod/v4/locales/pl.js +109 -0
- package/node_modules/zod/v4/locales/ps.cjs +141 -0
- package/node_modules/zod/v4/locales/ps.d.cts +5 -0
- package/node_modules/zod/v4/locales/ps.d.ts +4 -0
- package/node_modules/zod/v4/locales/ps.js +114 -0
- package/node_modules/zod/v4/locales/pt.cjs +135 -0
- package/node_modules/zod/v4/locales/pt.d.cts +5 -0
- package/node_modules/zod/v4/locales/pt.d.ts +4 -0
- package/node_modules/zod/v4/locales/pt.js +108 -0
- package/node_modules/zod/v4/locales/ro.cjs +146 -0
- package/node_modules/zod/v4/locales/ro.d.cts +5 -0
- package/node_modules/zod/v4/locales/ro.d.ts +4 -0
- package/node_modules/zod/v4/locales/ro.js +119 -0
- package/node_modules/zod/v4/locales/ru.cjs +183 -0
- package/node_modules/zod/v4/locales/ru.d.cts +5 -0
- package/node_modules/zod/v4/locales/ru.d.ts +4 -0
- package/node_modules/zod/v4/locales/ru.js +156 -0
- package/node_modules/zod/v4/locales/sl.cjs +136 -0
- package/node_modules/zod/v4/locales/sl.d.cts +5 -0
- package/node_modules/zod/v4/locales/sl.d.ts +4 -0
- package/node_modules/zod/v4/locales/sl.js +109 -0
- package/node_modules/zod/v4/locales/sv.cjs +137 -0
- package/node_modules/zod/v4/locales/sv.d.cts +5 -0
- package/node_modules/zod/v4/locales/sv.d.ts +4 -0
- package/node_modules/zod/v4/locales/sv.js +110 -0
- package/node_modules/zod/v4/locales/ta.cjs +137 -0
- package/node_modules/zod/v4/locales/ta.d.cts +5 -0
- package/node_modules/zod/v4/locales/ta.d.ts +4 -0
- package/node_modules/zod/v4/locales/ta.js +110 -0
- package/node_modules/zod/v4/locales/th.cjs +137 -0
- package/node_modules/zod/v4/locales/th.d.cts +5 -0
- package/node_modules/zod/v4/locales/th.d.ts +4 -0
- package/node_modules/zod/v4/locales/th.js +110 -0
- package/node_modules/zod/v4/locales/tr.cjs +132 -0
- package/node_modules/zod/v4/locales/tr.d.cts +5 -0
- package/node_modules/zod/v4/locales/tr.d.ts +4 -0
- package/node_modules/zod/v4/locales/tr.js +105 -0
- package/node_modules/zod/v4/locales/ua.cjs +12 -0
- package/node_modules/zod/v4/locales/ua.d.cts +5 -0
- package/node_modules/zod/v4/locales/ua.d.ts +5 -0
- package/node_modules/zod/v4/locales/ua.js +5 -0
- package/node_modules/zod/v4/locales/uk.cjs +135 -0
- package/node_modules/zod/v4/locales/uk.d.cts +5 -0
- package/node_modules/zod/v4/locales/uk.d.ts +4 -0
- package/node_modules/zod/v4/locales/uk.js +108 -0
- package/node_modules/zod/v4/locales/ur.cjs +137 -0
- package/node_modules/zod/v4/locales/ur.d.cts +5 -0
- package/node_modules/zod/v4/locales/ur.d.ts +4 -0
- package/node_modules/zod/v4/locales/ur.js +110 -0
- package/node_modules/zod/v4/locales/uz.cjs +137 -0
- package/node_modules/zod/v4/locales/uz.d.cts +5 -0
- package/node_modules/zod/v4/locales/uz.d.ts +4 -0
- package/node_modules/zod/v4/locales/uz.js +110 -0
- package/node_modules/zod/v4/locales/vi.cjs +135 -0
- package/node_modules/zod/v4/locales/vi.d.cts +5 -0
- package/node_modules/zod/v4/locales/vi.d.ts +4 -0
- package/node_modules/zod/v4/locales/vi.js +108 -0
- package/node_modules/zod/v4/locales/yo.cjs +134 -0
- package/node_modules/zod/v4/locales/yo.d.cts +5 -0
- package/node_modules/zod/v4/locales/yo.d.ts +4 -0
- package/node_modules/zod/v4/locales/yo.js +107 -0
- package/node_modules/zod/v4/locales/zh-CN.cjs +136 -0
- package/node_modules/zod/v4/locales/zh-CN.d.cts +5 -0
- package/node_modules/zod/v4/locales/zh-CN.d.ts +4 -0
- package/node_modules/zod/v4/locales/zh-CN.js +109 -0
- package/node_modules/zod/v4/locales/zh-TW.cjs +134 -0
- package/node_modules/zod/v4/locales/zh-TW.d.cts +5 -0
- package/node_modules/zod/v4/locales/zh-TW.d.ts +4 -0
- package/node_modules/zod/v4/locales/zh-TW.js +107 -0
- package/node_modules/zod/v4/mini/checks.cjs +34 -0
- package/node_modules/zod/v4/mini/checks.d.cts +1 -0
- package/node_modules/zod/v4/mini/checks.d.ts +1 -0
- package/node_modules/zod/v4/mini/checks.js +1 -0
- package/node_modules/zod/v4/mini/coerce.cjs +52 -0
- package/node_modules/zod/v4/mini/coerce.d.cts +7 -0
- package/node_modules/zod/v4/mini/coerce.d.ts +7 -0
- package/node_modules/zod/v4/mini/coerce.js +22 -0
- package/node_modules/zod/v4/mini/external.cjs +63 -0
- package/node_modules/zod/v4/mini/external.d.cts +13 -0
- package/node_modules/zod/v4/mini/external.d.ts +13 -0
- package/node_modules/zod/v4/mini/external.js +14 -0
- package/node_modules/zod/v4/mini/index.cjs +32 -0
- package/node_modules/zod/v4/mini/index.d.cts +3 -0
- package/node_modules/zod/v4/mini/index.d.ts +3 -0
- package/node_modules/zod/v4/mini/index.js +3 -0
- package/node_modules/zod/v4/mini/iso.cjs +64 -0
- package/node_modules/zod/v4/mini/iso.d.cts +22 -0
- package/node_modules/zod/v4/mini/iso.d.ts +22 -0
- package/node_modules/zod/v4/mini/iso.js +34 -0
- package/node_modules/zod/v4/mini/package.json +7 -0
- package/node_modules/zod/v4/mini/parse.cjs +16 -0
- package/node_modules/zod/v4/mini/parse.d.cts +1 -0
- package/node_modules/zod/v4/mini/parse.d.ts +1 -0
- package/node_modules/zod/v4/mini/parse.js +1 -0
- package/node_modules/zod/v4/mini/schemas.cjs +1083 -0
- package/node_modules/zod/v4/mini/schemas.d.cts +445 -0
- package/node_modules/zod/v4/mini/schemas.d.ts +445 -0
- package/node_modules/zod/v4/mini/schemas.js +961 -0
- package/node_modules/zod/v4/package.json +7 -0
- package/node_modules/zod/v4-mini/index.cjs +32 -0
- package/node_modules/zod/v4-mini/index.d.cts +3 -0
- package/node_modules/zod/v4-mini/index.d.ts +3 -0
- package/node_modules/zod/v4-mini/index.js +3 -0
- package/node_modules/zod/v4-mini/package.json +7 -0
- package/package.json +49 -4
- package/scripts/hooks/canon.mjs +45 -0
- package/scripts/hooks/consent.mjs +728 -0
- package/scripts/hooks/rarog-context.mjs +163 -0
- package/scripts/hooks/rarog-pending.mjs +1498 -0
- package/scripts/hooks/rarog-statusline.mjs +258 -0
- package/scripts/hooks/tall-dialog.mjs +400 -0
- package/scripts/hooks/work-area.mjs +138 -0
- package/scripts/restart.sh +393 -0
- package/server/src/auth/admin.js +272 -0
- package/server/src/auth/consent-socket.js +89 -0
- package/server/src/auth/device.js +81 -0
- package/server/src/auth/devices-store.js +544 -0
- package/server/src/auth/index.js +26 -0
- package/server/src/auth/limiter.js +95 -0
- package/server/src/auth/origin.js +13 -0
- package/server/src/auth/pairing.js +201 -0
- package/server/src/auth/principal.js +28 -0
- package/server/src/auth/redact.js +78 -0
- package/server/src/auth/unix-socket.js +156 -0
- package/server/src/bootstrap/alive-sessions.js +22 -0
- package/server/src/bootstrap/consent.js +453 -0
- package/server/src/bootstrap/devices.js +43 -0
- package/server/src/bootstrap/health.js +45 -0
- package/server/src/bootstrap/herdr.js +25 -0
- package/server/src/bootstrap/hook-files.js +97 -0
- package/server/src/bootstrap/http.js +70 -0
- package/server/src/bootstrap/inbox.js +54 -0
- package/server/src/bootstrap/iroh.js +26 -0
- package/server/src/bootstrap/manager.js +51 -0
- package/server/src/bootstrap/pr-status.js +35 -0
- package/server/src/bootstrap/push.js +88 -0
- package/server/src/bootstrap/sse.js +32 -0
- package/server/src/bootstrap/term.js +54 -0
- package/server/src/bootstrap/versions.js +45 -0
- package/server/src/cli/child-output.js +214 -0
- package/server/src/cli/claude-settings.js +905 -0
- package/server/src/cli/config-rewrite.js +147 -0
- package/server/src/cli/devices.js +417 -0
- package/server/src/cli/dialogs.js +212 -0
- package/server/src/cli/dictation.js +87 -0
- package/server/src/cli/doctor-no-hook.js +162 -0
- package/server/src/cli/doctor-pr-status.js +77 -0
- package/server/src/cli/doctor-write-block.js +65 -0
- package/server/src/cli/doctor.js +1530 -0
- package/server/src/cli/hooks.js +734 -0
- package/server/src/cli/io.js +61 -0
- package/server/src/cli/launchd-loaded.js +82 -0
- package/server/src/cli/lock.js +170 -0
- package/server/src/cli/main.js +129 -0
- package/server/src/cli/restart.js +842 -0
- package/server/src/cli/screen/ask.js +55 -0
- package/server/src/cli/screen/log.js +136 -0
- package/server/src/cli/screen/prose.js +74 -0
- package/server/src/cli/screen/steps.js +528 -0
- package/server/src/cli/screen/style.js +161 -0
- package/server/src/cli/secret-input.js +212 -0
- package/server/src/cli/secrets-file.js +288 -0
- package/server/src/cli/serve.js +687 -0
- package/server/src/cli/service.js +1375 -0
- package/server/src/cli/setup-check.js +287 -0
- package/server/src/cli/setup-config.js +192 -0
- package/server/src/cli/setup-context.js +174 -0
- package/server/src/cli/setup-herdr-agent.js +503 -0
- package/server/src/cli/setup-herdr-unit.js +437 -0
- package/server/src/cli/setup-plan.js +85 -0
- package/server/src/cli/setup-screen.js +372 -0
- package/server/src/cli/setup-secrets.js +179 -0
- package/server/src/cli/setup-settings.js +305 -0
- package/server/src/cli/setup-tailscale-add.js +235 -0
- package/server/src/cli/setup-tailscale-only.js +81 -0
- package/server/src/cli/setup-tailscale-port.js +276 -0
- package/server/src/cli/setup-transport.js +417 -0
- package/server/src/cli/setup-voice.js +174 -0
- package/server/src/cli/setup.js +1191 -0
- package/server/src/cli/systemd-unit.js +370 -0
- package/server/src/cli/templates/herdr-agent.plist +34 -0
- package/server/src/cli/templates/launchd.plist +35 -0
- package/server/src/cli/templates/rarog.service +25 -0
- package/server/src/cli/update-channel.js +100 -0
- package/server/src/cli/update-lock.js +148 -0
- package/server/src/cli/update-provenance.js +303 -0
- package/server/src/cli/update-registry.js +628 -0
- package/server/src/cli/update.js +451 -0
- package/server/src/cli/voice-agent.js +235 -0
- package/server/src/cli/voice-keys.js +71 -0
- package/server/src/cli-store.js +38 -0
- package/server/src/cli-version.js +442 -0
- package/server/src/client-log.js +121 -0
- package/server/src/companion/ask.js +165 -0
- package/server/src/companion/asks-owner.js +205 -0
- package/server/src/companion/catalog.js +22 -0
- package/server/src/companion/cli-literals.js +84 -0
- package/server/src/companion/cli.js +235 -0
- package/server/src/companion/condense.js +274 -0
- package/server/src/companion/conversation.js +21 -0
- package/server/src/companion/index.js +46 -0
- package/server/src/companion/mask.js +37 -0
- package/server/src/companion/openai-token.js +129 -0
- package/server/src/companion/prompt.js +102 -0
- package/server/src/companion/turns-settle.js +33 -0
- package/server/src/companion/turns.js +132 -0
- package/server/src/config/claude-account.js +101 -0
- package/server/src/config/clients.js +45 -0
- package/server/src/config/demo.js +97 -0
- package/server/src/config/files.js +32 -0
- package/server/src/config/flags.js +152 -0
- package/server/src/config/herdr.js +129 -0
- package/server/src/config/listen.js +122 -0
- package/server/src/config/protected-dirs.js +79 -0
- package/server/src/config/push.js +72 -0
- package/server/src/config/roots.js +259 -0
- package/server/src/config/terminal.js +86 -0
- package/server/src/config/voice.js +21 -0
- package/server/src/config/work-area.js +168 -0
- package/server/src/config-env.js +530 -0
- package/server/src/config.js +749 -0
- package/server/src/demo/content/en.js +673 -0
- package/server/src/demo/content/index.js +16 -0
- package/server/src/demo/content/named-set.js +59 -0
- package/server/src/demo/content/pl.js +691 -0
- package/server/src/demo/content/types.js +1 -0
- package/server/src/demo/control.js +574 -0
- package/server/src/demo/files.js +49 -0
- package/server/src/demo/inbox.js +73 -0
- package/server/src/demo/mac.js +20 -0
- package/server/src/demo/mock-herdr.js +251 -0
- package/server/src/demo/notes.js +60 -0
- package/server/src/demo/review-routes.js +101 -0
- package/server/src/demo/scenarios.js +338 -0
- package/server/src/demo/seeds.js +480 -0
- package/server/src/demo/usage.js +29 -0
- package/server/src/demo/voice.js +24 -0
- package/server/src/device-effects.js +39 -0
- package/server/src/drivers/herdr/audit-fields.js +27 -0
- package/server/src/drivers/herdr/cli-reserve.js +238 -0
- package/server/src/drivers/herdr/command-dialog-settle.js +90 -0
- package/server/src/drivers/herdr/commands.js +751 -0
- package/server/src/drivers/herdr/consent-channel.js +231 -0
- package/server/src/drivers/herdr/consent-no-hook-io.js +89 -0
- package/server/src/drivers/herdr/consent-no-hook.js +316 -0
- package/server/src/drivers/herdr/consent-registry-read.js +45 -0
- package/server/src/drivers/herdr/form-reserve.js +203 -0
- package/server/src/drivers/herdr/layer2-card.js +302 -0
- package/server/src/drivers/herdr/layer2-step.js +199 -0
- package/server/src/drivers/herdr/prompt-gates.js +118 -0
- package/server/src/drivers/herdr/prompt-paste.js +106 -0
- package/server/src/drivers/herdr/prompt-queue-store.js +284 -0
- package/server/src/drivers/herdr/prompt-queue.js +921 -0
- package/server/src/drivers/herdr/pull-request-poll.js +61 -0
- package/server/src/drivers/herdr/queue-take-back.js +429 -0
- package/server/src/drivers/herdr/refusals.js +226 -0
- package/server/src/drivers/herdr/returned-prompt.js +172 -0
- package/server/src/drivers/herdr/scheduled-task-poll.js +120 -0
- package/server/src/drivers/herdr/stale-block.js +33 -0
- package/server/src/drivers/herdr/take-back-field.js +311 -0
- package/server/src/drivers/herdr/transcript.js +186 -0
- package/server/src/drivers/herdr/turn-guard.js +328 -0
- package/server/src/drivers/herdr-driver.js +4332 -0
- package/server/src/drivers/mock-driver.js +541 -0
- package/server/src/drivers/runtime.js +76 -0
- package/server/src/drivers/tool-summary.js +95 -0
- package/server/src/drivers/tool-text.js +206 -0
- package/server/src/drivers/types.js +15 -0
- package/server/src/files/file-index.js +246 -0
- package/server/src/files/ignored.js +119 -0
- package/server/src/files/listing.js +76 -0
- package/server/src/files/path-rule.js +145 -0
- package/server/src/files/refusals.js +36 -0
- package/server/src/files/send-file.js +115 -0
- package/server/src/files/session-download.js +51 -0
- package/server/src/files/session-files.js +38 -0
- package/server/src/files/session-gate.js +48 -0
- package/server/src/fs-browse.js +268 -0
- package/server/src/fs-mkdir-child.js +86 -0
- package/server/src/fs-mkdir.js +161 -0
- package/server/src/git-config-guard.js +72 -0
- package/server/src/git-diff.js +356 -0
- package/server/src/git-sandbox.js +100 -0
- package/server/src/git-stats.js +61 -0
- package/server/src/git-status.js +1073 -0
- package/server/src/git-watch.js +299 -0
- package/server/src/git-work-tree.js +33 -0
- package/server/src/health.js +167 -0
- package/server/src/herdr/answer-recheck.js +85 -0
- package/server/src/herdr/argv.js +234 -0
- package/server/src/herdr/audit.js +520 -0
- package/server/src/herdr/background/agent-file.js +411 -0
- package/server/src/herdr/background/artifacts.js +173 -0
- package/server/src/herdr/background/cli-shapes.js +442 -0
- package/server/src/herdr/background/ids.js +29 -0
- package/server/src/herdr/background/incremental-read.js +70 -0
- package/server/src/herdr/background/index.js +93 -0
- package/server/src/herdr/background/jsonl-lines.js +68 -0
- package/server/src/herdr/background/main-scan.js +229 -0
- package/server/src/herdr/background/merge.js +336 -0
- package/server/src/herdr/background/notice.js +110 -0
- package/server/src/herdr/background/notification.js +267 -0
- package/server/src/herdr/background/pull-request-files.js +257 -0
- package/server/src/herdr/background/pull-requests.js +684 -0
- package/server/src/herdr/background/queued-prompt.js +52 -0
- package/server/src/herdr/background/reducer.js +682 -0
- package/server/src/herdr/background/satellite.js +73 -0
- package/server/src/herdr/background/scheduled-task-file.js +118 -0
- package/server/src/herdr/background/scheduled-tasks.js +251 -0
- package/server/src/herdr/background/work.js +134 -0
- package/server/src/herdr/background/workflow-run.js +417 -0
- package/server/src/herdr/client.js +894 -0
- package/server/src/herdr/commands/catalog.js +179 -0
- package/server/src/herdr/commands/discover.js +605 -0
- package/server/src/herdr/commands/guard.js +192 -0
- package/server/src/herdr/commands/index.js +35 -0
- package/server/src/herdr/commands/registry.js +496 -0
- package/server/src/herdr/commands/shape.js +240 -0
- package/server/src/herdr/commands/transcript.js +261 -0
- package/server/src/herdr/consent-evidence.js +592 -0
- package/server/src/herdr/consent-step.js +44 -0
- package/server/src/herdr/consent-subagent.js +423 -0
- package/server/src/herdr/dialogs/cards/build.js +445 -0
- package/server/src/herdr/dialogs/cards/ids.js +101 -0
- package/server/src/herdr/dialogs/cards/roles.js +22 -0
- package/server/src/herdr/dialogs/consent-gate.js +62 -0
- package/server/src/herdr/dialogs/copy.js +97 -0
- package/server/src/herdr/dialogs/cross-check.js +500 -0
- package/server/src/herdr/dialogs/decide/decide.js +825 -0
- package/server/src/herdr/dialogs/decide/input.js +1 -0
- package/server/src/herdr/dialogs/decide/reasons.js +60 -0
- package/server/src/herdr/dialogs/decide/sources.js +322 -0
- package/server/src/herdr/dialogs/hook/answers.js +190 -0
- package/server/src/herdr/dialogs/hook/canon.js +28 -0
- package/server/src/herdr/dialogs/hook/contract.js +232 -0
- package/server/src/herdr/dialogs/hook/dump.js +350 -0
- package/server/src/herdr/dialogs/hook/suggestions.js +75 -0
- package/server/src/herdr/dialogs/hook/target.js +99 -0
- package/server/src/herdr/dialogs/index.js +208 -0
- package/server/src/herdr/dialogs/layer1/always.js +71 -0
- package/server/src/herdr/dialogs/layer1/bind.js +193 -0
- package/server/src/herdr/dialogs/layer1/card.js +190 -0
- package/server/src/herdr/dialogs/layer1/cards.js +37 -0
- package/server/src/herdr/dialogs/layer1/contract.js +399 -0
- package/server/src/herdr/dialogs/layer1/cycle.js +1746 -0
- package/server/src/herdr/dialogs/layer1/desk-reason.js +119 -0
- package/server/src/herdr/dialogs/layer1/desk.js +190 -0
- package/server/src/herdr/dialogs/layer1/frames.js +118 -0
- package/server/src/herdr/dialogs/layer1/hook-list/hook-list.js +1049 -0
- package/server/src/herdr/dialogs/layer1/hook-list/session-facts.js +135 -0
- package/server/src/herdr/dialogs/layer1/mode.js +93 -0
- package/server/src/herdr/dialogs/layer1/observe.js +419 -0
- package/server/src/herdr/dialogs/layer1/proof.js +454 -0
- package/server/src/herdr/dialogs/layer1/receipt.js +71 -0
- package/server/src/herdr/dialogs/layer1/records.js +236 -0
- package/server/src/herdr/dialogs/layer1/registry.js +274 -0
- package/server/src/herdr/dialogs/layer1/resume.js +178 -0
- package/server/src/herdr/dialogs/layer1/sign.js +182 -0
- package/server/src/herdr/dialogs/layer1/top.js +264 -0
- package/server/src/herdr/dialogs/layer1/turns.js +251 -0
- package/server/src/herdr/dialogs/layer1/version-gate.js +162 -0
- package/server/src/herdr/dialogs/layer2/card.js +109 -0
- package/server/src/herdr/dialogs/layer2/match.js +98 -0
- package/server/src/herdr/dialogs/layer2/read-block.js +153 -0
- package/server/src/herdr/dialogs/layer2/shapes.js +61 -0
- package/server/src/herdr/dialogs/layer2/stability.js +104 -0
- package/server/src/herdr/dialogs/layer2/verdict.js +282 -0
- package/server/src/herdr/dialogs/no-hook.js +63 -0
- package/server/src/herdr/dialogs/policy/consent.js +29 -0
- package/server/src/herdr/dialogs/policy/escalation.js +115 -0
- package/server/src/herdr/dialogs/policy/exit-tasks.js +34 -0
- package/server/src/herdr/dialogs/policy/measured-consent.js +123 -0
- package/server/src/herdr/dialogs/policy/option-policy.js +22 -0
- package/server/src/herdr/dialogs/policy/options.js +79 -0
- package/server/src/herdr/dialogs/policy/pause.js +18 -0
- package/server/src/herdr/dialogs/policy/terminal.js +93 -0
- package/server/src/herdr/dialogs/presence.js +49 -0
- package/server/src/herdr/dialogs/refusals.js +271 -0
- package/server/src/herdr/dialogs/router.js +137 -0
- package/server/src/herdr/dialogs/screen/auto-deny.js +31 -0
- package/server/src/herdr/dialogs/screen/bash-zone.js +161 -0
- package/server/src/herdr/dialogs/screen/block-visible.js +60 -0
- package/server/src/herdr/dialogs/screen/block.js +296 -0
- package/server/src/herdr/dialogs/screen/confirm.js +83 -0
- package/server/src/herdr/dialogs/screen/dialog-bottom.js +54 -0
- package/server/src/herdr/dialogs/screen/edit-frame.js +391 -0
- package/server/src/herdr/dialogs/screen/edit-zone.js +33 -0
- package/server/src/herdr/dialogs/screen/excerpt.js +48 -0
- package/server/src/herdr/dialogs/screen/file-dialog.js +38 -0
- package/server/src/herdr/dialogs/screen/form.js +199 -0
- package/server/src/herdr/dialogs/screen/identity.js +23 -0
- package/server/src/herdr/dialogs/screen/kinds.js +39 -0
- package/server/src/herdr/dialogs/screen/known.js +101 -0
- package/server/src/herdr/dialogs/screen/mode-footer.js +90 -0
- package/server/src/herdr/dialogs/screen/operation.js +196 -0
- package/server/src/herdr/dialogs/screen/option-run.js +62 -0
- package/server/src/herdr/dialogs/screen/options.js +534 -0
- package/server/src/herdr/dialogs/screen/parse.js +368 -0
- package/server/src/herdr/dialogs/screen/plan-file.js +53 -0
- package/server/src/herdr/dialogs/screen/queue.js +59 -0
- package/server/src/herdr/dialogs/screen/region.js +92 -0
- package/server/src/herdr/dialogs/screen/resolve.js +305 -0
- package/server/src/herdr/dialogs/screen/review.js +118 -0
- package/server/src/herdr/dialogs/screen/signatures.js +1030 -0
- package/server/src/herdr/dialogs/screen/snippet.js +49 -0
- package/server/src/herdr/dialogs/screen/text.js +50 -0
- package/server/src/herdr/dialogs/screen/trust-arrow.js +122 -0
- package/server/src/herdr/dialogs/screen/write-zone.js +41 -0
- package/server/src/herdr/dialogs/screen-unavailable.js +52 -0
- package/server/src/herdr/dialogs/send/form-submit.js +72 -0
- package/server/src/herdr/dialogs/send/key-row.js +29 -0
- package/server/src/herdr/dialogs/send/keys.js +75 -0
- package/server/src/herdr/dialogs/send/prompt-submit.js +35 -0
- package/server/src/herdr/dialogs/send/take-back-keys.js +33 -0
- package/server/src/herdr/dialogs/send/trust-step.js +52 -0
- package/server/src/herdr/dialogs/shadow/alive-log.js +100 -0
- package/server/src/herdr/dialogs/shadow/alive.js +211 -0
- package/server/src/herdr/dialogs/shadow/atomic.js +55 -0
- package/server/src/herdr/dialogs/shadow/channel.js +321 -0
- package/server/src/herdr/dialogs/shadow/evidence.js +322 -0
- package/server/src/herdr/dialogs/shadow/files.js +375 -0
- package/server/src/herdr/dialogs/shadow/liveness.js +145 -0
- package/server/src/herdr/dialogs/shadow/sweep.js +220 -0
- package/server/src/herdr/dialogs/timing.js +88 -0
- package/server/src/herdr/history-steps.js +190 -0
- package/server/src/herdr/hook-commands.js +355 -0
- package/server/src/herdr/hook-config.js +1468 -0
- package/server/src/herdr/identity.js +277 -0
- package/server/src/herdr/index.js +27 -0
- package/server/src/herdr/input-segments.js +135 -0
- package/server/src/herdr/jsonl-activity.js +122 -0
- package/server/src/herdr/jsonl-follow.js +2358 -0
- package/server/src/herdr/jsonl-pending.js +551 -0
- package/server/src/herdr/jsonl-queue.js +133 -0
- package/server/src/herdr/jsonl-usage.js +174 -0
- package/server/src/herdr/launcher.js +574 -0
- package/server/src/herdr/line-diff.js +104 -0
- package/server/src/herdr/mode-cycle.js +78 -0
- package/server/src/herdr/project-workspace.js +131 -0
- package/server/src/herdr/provenance.js +204 -0
- package/server/src/herdr/session-pulse.js +536 -0
- package/server/src/herdr/socket.js +1003 -0
- package/server/src/herdr/statusline.js +348 -0
- package/server/src/herdr/supervisor.js +1934 -0
- package/server/src/herdr/transcript-path.js +123 -0
- package/server/src/herdr/trust.js +201 -0
- package/server/src/herdr/types.js +163 -0
- package/server/src/herdr/ultracode.js +132 -0
- package/server/src/herdr/uploads-registry.js +173 -0
- package/server/src/herdr/uploads.js +642 -0
- package/server/src/herdr/workspace-resolver.js +219 -0
- package/server/src/hidden-chars.js +52 -0
- package/server/src/inbox/card.js +130 -0
- package/server/src/inbox/dialogs.js +150 -0
- package/server/src/inbox/heads.js +55 -0
- package/server/src/inbox/inbox.js +440 -0
- package/server/src/inbox/index.js +21 -0
- package/server/src/inbox/removals.js +181 -0
- package/server/src/inbox/segments.js +37 -0
- package/server/src/index.js +800 -0
- package/server/src/install/data-dir.js +103 -0
- package/server/src/install/evidence.js +66 -0
- package/server/src/install/mode.js +37 -0
- package/server/src/install/repair.js +223 -0
- package/server/src/install/sdk-lock.json +153 -0
- package/server/src/install/sdk-package.json +7 -0
- package/server/src/install/sdk-probe.js +18 -0
- package/server/src/install/sdk.js +624 -0
- package/server/src/install/service-target.js +106 -0
- package/server/src/iroh/adapter.js +294 -0
- package/server/src/iroh/duplex.js +169 -0
- package/server/src/iroh/endpoint.js +17 -0
- package/server/src/iroh/listener.js +422 -0
- package/server/src/iroh/log-budget.js +70 -0
- package/server/src/iroh/module-probe.js +17 -0
- package/server/src/iroh/path-log.js +96 -0
- package/server/src/iroh/socket.js +89 -0
- package/server/src/live-sessions.js +162 -0
- package/server/src/log-timestamps-install.js +8 -0
- package/server/src/log-timestamps.js +63 -0
- package/server/src/mac-stats.js +261 -0
- package/server/src/notes/store.js +248 -0
- package/server/src/notify/apns-channel.js +70 -0
- package/server/src/notify/apns-devices.js +477 -0
- package/server/src/notify/apns-payload.js +267 -0
- package/server/src/notify/apns-sink.js +207 -0
- package/server/src/notify/apns.js +307 -0
- package/server/src/notify/consent-canary-push.js +163 -0
- package/server/src/notify/content.js +328 -0
- package/server/src/notify/fanout.js +44 -0
- package/server/src/notify/index.js +505 -0
- package/server/src/notify/live-activity-limits.js +126 -0
- package/server/src/notify/live-activity-state.js +176 -0
- package/server/src/notify/live-activity.js +581 -0
- package/server/src/notify/policy.js +273 -0
- package/server/src/notify/presence.js +176 -0
- package/server/src/notify/push-crypto.js +95 -0
- package/server/src/notify/relay-pass.js +487 -0
- package/server/src/notify/relay-sender.js +206 -0
- package/server/src/notify/sender.js +117 -0
- package/server/src/notify/weekly-limit.js +204 -0
- package/server/src/notify/workflow-phase.js +11 -0
- package/server/src/permissions.js +239 -0
- package/server/src/pr-status/gh.js +270 -0
- package/server/src/pr-status/index.js +12 -0
- package/server/src/pr-status/source.js +22 -0
- package/server/src/pr-status/tracker.js +204 -0
- package/server/src/risk.js +100 -0
- package/server/src/router.js +603 -0
- package/server/src/routes/context.js +8 -0
- package/server/src/routes/devices.js +246 -0
- package/server/src/routes/inbox.js +91 -0
- package/server/src/routes/limits.js +41 -0
- package/server/src/routes/notes.js +105 -0
- package/server/src/routes/projects.js +189 -0
- package/server/src/routes/push.js +252 -0
- package/server/src/routes/sessions.js +878 -0
- package/server/src/routes/system.js +275 -0
- package/server/src/routes/terminal.js +140 -0
- package/server/src/safe-read.js +203 -0
- package/server/src/session-label.js +48 -0
- package/server/src/session-list.js +166 -0
- package/server/src/sessions/activity-clocks.js +47 -0
- package/server/src/sessions/attach-slots.js +64 -0
- package/server/src/sessions/claim-window.js +132 -0
- package/server/src/sessions/cli-registry.js +233 -0
- package/server/src/sessions/companion-scope.js +103 -0
- package/server/src/sessions/consent-cards.js +509 -0
- package/server/src/sessions/context-usage.js +23 -0
- package/server/src/sessions/conversation-lists.js +68 -0
- package/server/src/sessions/demo-modules.js +16 -0
- package/server/src/sessions/dialog-timing.js +57 -0
- package/server/src/sessions/diff-measure.js +30 -0
- package/server/src/sessions/driver-events.js +282 -0
- package/server/src/sessions/errors.js +64 -0
- package/server/src/sessions/fallback-label.js +38 -0
- package/server/src/sessions/held-echo.js +258 -0
- package/server/src/sessions/herdr-lifecycle.js +453 -0
- package/server/src/sessions/interrupt-windows.js +141 -0
- package/server/src/sessions/launch-gate.js +299 -0
- package/server/src/sessions/manager-api.js +1 -0
- package/server/src/sessions/manager.js +3957 -0
- package/server/src/sessions/pr-status-link.js +50 -0
- package/server/src/sessions/project-scan.js +48 -0
- package/server/src/sessions/question-card.js +137 -0
- package/server/src/sessions/recent-projects.js +55 -0
- package/server/src/sessions/ring-buffer.js +211 -0
- package/server/src/sessions/seen-marks.js +434 -0
- package/server/src/sessions/send-registry.js +275 -0
- package/server/src/sessions/session-git.js +304 -0
- package/server/src/sessions/session-restart.js +420 -0
- package/server/src/sessions/session-scope.js +30 -0
- package/server/src/sessions/session-take-back.js +118 -0
- package/server/src/sessions/session.js +743 -0
- package/server/src/sessions/state-machine.js +145 -0
- package/server/src/sessions/state-sentences.js +642 -0
- package/server/src/sessions/waiting-line.js +72 -0
- package/server/src/shutdown.js +20 -0
- package/server/src/sse.js +611 -0
- package/server/src/tailnet.js +169 -0
- package/server/src/term/backend.js +59 -0
- package/server/src/term/herdr-backend.js +1649 -0
- package/server/src/term/herdr-stream.js +109 -0
- package/server/src/term/index.js +338 -0
- package/server/src/term/lifecycle.js +182 -0
- package/server/src/term/paste.js +139 -0
- package/server/src/term/registry.js +1032 -0
- package/server/src/term/ws.js +306 -0
- package/server/src/text.js +102 -0
- package/server/src/transcript-import.js +579 -0
- package/server/src/usage.js +255 -0
- package/server/src/version-watch.js +243 -0
- package/server/src/version.js +102 -0
- package/server/src/voice/soniox.js +301 -0
|
@@ -0,0 +1,1934 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prawda o tym, jakie agenty `claude` żyją w herdr, w jakim są stanie i trybie.
|
|
3
|
+
*
|
|
4
|
+
* Supervisor NIE ZNA managera, a manager nie zna socketu. Styk to `HerdrSupervisor`
|
|
5
|
+
* (kontrakt z `types.ts`) plus `SessionDriver` zwracany z `attach()`. Dwa strumienie są
|
|
6
|
+
* rozłączne i to jest reguła, a nie szczegół: `events` niesie CYKL ŻYCIA dla managera
|
|
7
|
+
* (kto się pojawił, zniknął, wrócił), a uchwyty niosą zdarzenia JEDNEGO panelu dla drivera.
|
|
8
|
+
*
|
|
9
|
+
* Model subskrypcji (zweryfikowany na żywym serwerze):
|
|
10
|
+
* - `events.subscribe` przyjmuje listę wpisów: globalne (`pane.created`, `pane.closed`,
|
|
11
|
+
* `pane.exited`, `pane.moved`, `pane.agent_detected`) i per panel
|
|
12
|
+
* (`pane.agent_status_changed` z `pane_id` — GLOBALNEJ wersji nie ma),
|
|
13
|
+
* - nie ma `events.unsubscribe` ani `events.update`, więc każda zmiana składu paneli to
|
|
14
|
+
* ZAMKNIĘCIE połączenia i ponowna subskrypcja pełną listą (debounce 500 ms — przy
|
|
15
|
+
* `herdr update --handoff` leci burza zdarzeń),
|
|
16
|
+
* - ramki wracają z PODKREŚLENIAMI (`pane_exited`), choć subskrybuje się je z KROPKAMI;
|
|
17
|
+
* normalizacja siedzi w `socket.normalizeEventKind`.
|
|
18
|
+
*
|
|
19
|
+
* Push tylko WYPRZEDZA prawdę — źródłem prawdy jest pełny `agent.list` (start, każdy reconnect,
|
|
20
|
+
* tick co 30 s). Wzorzec z collie: „a missed event costs one interval, never correctness".
|
|
21
|
+
*/
|
|
22
|
+
import { homedir } from 'node:os';
|
|
23
|
+
import { basename } from 'node:path';
|
|
24
|
+
import { KNOWN_CONTEXT_LIMITS } from '@rarog/shared';
|
|
25
|
+
import { HERDR_IDLE_GRACE_MS, HERDR_MODE_FRESH_MS, HERDR_RESYNC_MS, HERDR_WORKING_GRACE_MS, HERDR_TRUST_REEXEC_GRACE_MS, } from '../config.js';
|
|
26
|
+
import { inWorkAreaOnDisk } from '../config/work-area.js';
|
|
27
|
+
import { isServerSentence, say, textOf } from '@rarog/shared/sentences';
|
|
28
|
+
import { AsyncEventQueue, systemScheduler } from '../drivers/runtime.js';
|
|
29
|
+
import { createAnswerRecheck } from './answer-recheck.js';
|
|
30
|
+
import { createHerdrAuditLog } from './audit.js';
|
|
31
|
+
import { createHerdrClient, createHerdrLaunchClient } from './client.js';
|
|
32
|
+
import { createHiddenStore, sessionIdFor } from './identity.js';
|
|
33
|
+
import { createSendThrottle } from './commands/index.js';
|
|
34
|
+
import { claudePaneLabel, labelTrace, parsePaneLabel, projectKey, realProjectPath, sanitizePaneTitle, sanitizeTabLabel, } from './provenance.js';
|
|
35
|
+
import { standingConsentDialog } from './dialogs/index.js';
|
|
36
|
+
import { collapseFooterMode, parseModeFooter } from './dialogs/screen/mode-footer.js';
|
|
37
|
+
import { HerdrUnavailableError, createHerdrSocket } from './socket.js';
|
|
38
|
+
import { HERDR_PANE_CAP_MESSAGE, sentenceOfError, HerdrGoneError, HerdrLaunchTimeoutError, HerdrNotOwnedError, HerdrReadOnlyError, isBareShellForeground, } from './types.js';
|
|
39
|
+
/**
|
|
40
|
+
* Launcher nie został wstrzyknięty (np. `RAROG_HERDR_LAUNCH=0` albo wersja bez modułu).
|
|
41
|
+
* Rzucamy zamiast udawać sukces: cicha odmowa zostawiłaby telefon ze spinnerem, a `false`
|
|
42
|
+
* z `canLaunch` i tak nie powinien dopuścić tu żądania.
|
|
43
|
+
*/
|
|
44
|
+
const LAUNCH_NOT_WIRED = say('herdr.launch-off-panels');
|
|
45
|
+
/**
|
|
46
|
+
* Odmowa `closeTab` na panelu Codexa — bliźniaczka `HERDR_CODEX_CLOSE_MESSAGE`
|
|
47
|
+
* z managera: ten sam kod zdania z rejestru, bez importu z warstwy sesji (nadzorca importuje
|
|
48
|
+
* z niej wyłącznie typy i ta zależność miałaby iść w drugą stronę).
|
|
49
|
+
*/
|
|
50
|
+
const CODEX_CLOSE_MESSAGE = say('session.codex-close');
|
|
51
|
+
/** Odmowa operacji na kluczu, którego nadzorca nie zna (panel zniknął z herdr). */
|
|
52
|
+
const agentGone = (key) => new HerdrGoneError(say('herdr.agent-gone', { key }));
|
|
53
|
+
/**
|
|
54
|
+
* Ile czekamy na `attach()` po zarejestrowaniu świeżo założonego panelu.
|
|
55
|
+
*
|
|
56
|
+
* Po tym czasie panel wraca do normalnego cyklu życia jako `appeared` — bo skoro manager go
|
|
57
|
+
* nie podpiął (awaria w trakcie startu), to nikt nim się nie opiekuje, a panel ŻYJE i musi
|
|
58
|
+
* być widoczny na liście. Reguła 11.9: nic, co Rarog stworzył, nie zostaje po cichu.
|
|
59
|
+
*/
|
|
60
|
+
export const LAUNCH_ADOPT_TIMEOUT_MS = 30_000;
|
|
61
|
+
/*
|
|
62
|
+
* Resync i karencja są zapisane w `config.ts` razem z resztą liczb-bezpieczników integracji
|
|
63
|
+
* (jedno źródło); tutaj tylko re-eksport, żeby import `herdr/index.ts` dalej działał.
|
|
64
|
+
*/
|
|
65
|
+
export { HERDR_IDLE_GRACE_MS, HERDR_RESYNC_MS, HERDR_TRUST_REEXEC_GRACE_MS, HERDR_WORKING_GRACE_MS, };
|
|
66
|
+
/** Debounce ponownej subskrypcji — burza zdarzeń ma dać JEDNO re-subscribe, nie N. */
|
|
67
|
+
export const RESUBSCRIBE_DEBOUNCE_MS = 500;
|
|
68
|
+
/** Najczęstszy odczyt stopki trybu dla jednego panelu przy zmianach statusu. */
|
|
69
|
+
export const MODE_READ_MIN_INTERVAL_MS = 10_000;
|
|
70
|
+
/**
|
|
71
|
+
* Debounce synchronizacji etykiety taba z kartą, osobno dla każdego klucza.
|
|
72
|
+
*
|
|
73
|
+
* Etykieta karty zmienia się seriami: auto-tytuł konwersacji potrafi przeskoczyć kilka razy
|
|
74
|
+
* w ciągu sekundy, a start Raroga ogłasza naraz wszystkie panele. Każda zmiana etykiety taba to
|
|
75
|
+
* `tab.rename` i zapis snapshotu herdr — więc liczy się OSTATNIA etykieta z okna, nie każda.
|
|
76
|
+
*/
|
|
77
|
+
export const TAB_LABEL_DEBOUNCE_MS = 2_000;
|
|
78
|
+
/**
|
|
79
|
+
* Odstęp ponowień niedokończonej synchronizacji etykiety taba: pierwsze
|
|
80
|
+
* przy najbliższym udanym resyncu, drugie po tym minimum, każde kolejne dwa razy później — do
|
|
81
|
+
* sufitu. Przeszkoda przejściowa (herdr chwilowo niedostępny, zgubiona odpowiedź) nie gubi zmiany
|
|
82
|
+
* etykiety, a uporczywa nie robi z nadzorcy pompy odczytów.
|
|
83
|
+
*/
|
|
84
|
+
export const TAB_LABEL_RETRY_MIN_MS = 30_000;
|
|
85
|
+
export const TAB_LABEL_RETRY_MAX_MS = 30 * 60_000;
|
|
86
|
+
/** Globalne wpisy subskrypcji — wszystko, co zmienia SKŁAD paneli. */
|
|
87
|
+
const GLOBAL_SUBSCRIPTIONS = [
|
|
88
|
+
{ type: 'pane.created' },
|
|
89
|
+
{ type: 'pane.closed' },
|
|
90
|
+
{ type: 'pane.exited' },
|
|
91
|
+
{ type: 'pane.moved' },
|
|
92
|
+
{ type: 'pane.agent_detected' },
|
|
93
|
+
];
|
|
94
|
+
/** Zdarzenia, po których pytamy o pełną listę (skład paneli mógł się zmienić). */
|
|
95
|
+
const COMPOSITION_EVENTS = new Set([
|
|
96
|
+
'pane_created', 'pane_closed', 'pane_exited', 'pane_moved', 'pane_agent_detected',
|
|
97
|
+
]);
|
|
98
|
+
/** `pane.updated` (firehose ~10 ramek/s) świadomie NIE jest subskrybowane. */
|
|
99
|
+
const STATUS_EVENT = 'pane_agent_status_changed';
|
|
100
|
+
/**
|
|
101
|
+
* POWÓD, DLA KTÓREGO RAROG NIE ZAŁOŻY TERAZ SESJI — jako zdanie, nie jako flaga.
|
|
102
|
+
*
|
|
103
|
+
* Klient wygasza „+" i „Nową sesję" na podstawie samego `canLaunch`, a zdanie bierze z `detail`.
|
|
104
|
+
* Gdyby `detail` niósł wyłącznie głos transportu, przy PEŁNYM SUFICIE paneli
|
|
105
|
+
* użytkownik dostawałby zapasowe copy klienta: „zakładanie jest wyłączone" —
|
|
106
|
+
* nieprawdę (killswitcha nie ma) prowadzącą donikąd (nie mówi, że wystarczy zamknąć panel).
|
|
107
|
+
*
|
|
108
|
+
* Dwie zasady, obie wynikają z tego jednego zdarzenia:
|
|
109
|
+
*
|
|
110
|
+
* 1. **Transport ma pierwszeństwo.** Gdy herdr milczy albo mówi nieznanym protokołem, to jest
|
|
111
|
+
* większa prawda niż sufit — a przy niedostępnym herdr sufit i tak nic nie znaczy.
|
|
112
|
+
* 2. **Sufit pokazujemy TYLKO wtedy, gdy jest jedynym powodem.** Przy `RAROG_HERDR_LAUNCH=0`
|
|
113
|
+
* zdanie „zamknij którąś sesję" byłoby radą, która niczego nie odblokuje: zamknięcie
|
|
114
|
+
* panelu nie włączy killswitcha. Wtedy `undefined` jest uczciwsze — klient powie własne,
|
|
115
|
+
* ogólne zdanie o wyłączonym zakładaniu i tym razem będzie to prawda.
|
|
116
|
+
*/
|
|
117
|
+
export function launchDetail(input) {
|
|
118
|
+
if (input.transportDetail !== undefined)
|
|
119
|
+
return input.transportDetail;
|
|
120
|
+
if (input.otherwiseCanLaunch && input.paneCapReached)
|
|
121
|
+
return HERDR_PANE_CAP_MESSAGE;
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
/** Własne gniazdo jest tworzone tylko wtedy, gdy wołający nie podał obu zależności. */
|
|
125
|
+
function requireSocket(socket) {
|
|
126
|
+
if (socket === null) {
|
|
127
|
+
throw new Error('herdr: brak transportu — podaj `transport` i `client` albo żaden z nich.');
|
|
128
|
+
}
|
|
129
|
+
return socket;
|
|
130
|
+
}
|
|
131
|
+
export function createHerdrSupervisor(config, deps) {
|
|
132
|
+
const scheduler = deps.scheduler ?? systemScheduler;
|
|
133
|
+
const now = config.now ?? (() => Date.now());
|
|
134
|
+
const home = config.home ?? homedir();
|
|
135
|
+
const log = config.logger ?? (() => { });
|
|
136
|
+
const socket = deps.transport === undefined || deps.client === undefined
|
|
137
|
+
? createHerdrSocket({ socketPath: config.socketPath, sendEnabled: config.sendEnabled })
|
|
138
|
+
: null;
|
|
139
|
+
const transport = deps.transport ?? requireSocket(socket);
|
|
140
|
+
const client = deps.client
|
|
141
|
+
?? createHerdrClient(requireSocket(socket), {
|
|
142
|
+
codexStatus: config.codexStatusEnabled === true,
|
|
143
|
+
});
|
|
144
|
+
/*
|
|
145
|
+
* Kanał TWORZENIA powstaje tylko wtedy, gdy jest z czego: bez własnego gniazda i bez jawnie
|
|
146
|
+
* podanej fasady supervisor nie ma jak (i nie ma prawa) niczego tworzyć — `closeTab`
|
|
147
|
+
* odmawia wtedy zamiast zgadywać.
|
|
148
|
+
*/
|
|
149
|
+
const launchClient = deps.launchClient
|
|
150
|
+
?? (socket !== null ? createHerdrLaunchClient(socket) : null);
|
|
151
|
+
const maxPanes = config.maxPanes ?? Number.POSITIVE_INFINITY;
|
|
152
|
+
/*
|
|
153
|
+
* Launcher powstaje TYLKO przy jawnym opt-inie (`RAROG_HERDR_LAUNCH=1`). Jego brak to nie
|
|
154
|
+
* jest awaria: to jest domyślny stan Raroga, w którym kanał tworzenia po prostu nie istnieje
|
|
155
|
+
* — `canLaunch` jest wtedy `false`, a `launch()` rzuca zamiast udawać.
|
|
156
|
+
*/
|
|
157
|
+
const launcher = deps.launcher
|
|
158
|
+
?? (config.launchEnabled === true && deps.createLauncher !== undefined && launchClient !== null
|
|
159
|
+
? deps.createLauncher({
|
|
160
|
+
client: launchClient,
|
|
161
|
+
/*
|
|
162
|
+
* Rezerwacja panelu i nadanie klucza. Musi być SYNCHRONICZNA i musi nastąpić przed
|
|
163
|
+
* `agent.start` — dopóki żyje, resync i push nie emitują `appeared` dla tego panelu,
|
|
164
|
+
* więc nie powstaje DRUGA sesja Raroga na tym samym adresie.
|
|
165
|
+
*
|
|
166
|
+
* Funkcje zamykają się nad `registerLaunched` i `agents`, które powstają NIŻEJ w tej
|
|
167
|
+
* samej funkcji. To jest bezpieczne, bo fabryka ich tu nie woła — woła je dopiero
|
|
168
|
+
* launcher, w trakcie `launch()`.
|
|
169
|
+
*/
|
|
170
|
+
registerLaunch: (reg) => {
|
|
171
|
+
const key = registerLaunched(reg, reg.label);
|
|
172
|
+
// Do `paneLabelled` (albo rozstrzygnięcia `ready`) panel nie ma jeszcze etykiety
|
|
173
|
+
// pochodzenia — synchronizacja etykiety taba z kartą czeka.
|
|
174
|
+
provenancePending.add(key);
|
|
175
|
+
return key;
|
|
176
|
+
},
|
|
177
|
+
paneLabelled: (key) => { releaseProvenance(key); },
|
|
178
|
+
/*
|
|
179
|
+
* `detection`, nie `visible`, i to nie jest kosmetyka. Ogon ekranu z launchera wchodzi
|
|
180
|
+
* do treści błędu, a stamtąd do `stateDetail` sesji i po SSE na kartę — czyli jest
|
|
181
|
+
* ZAPISYWANY. `docs/security-model.md` punkt 11 pozwala na to wyłącznie wycinkowi
|
|
182
|
+
* `--source detection`; z `visible` wolno wyprowadzić tylko rozpoznany TRYB ze stopki
|
|
183
|
+
* (tak robi `readMode` niżej), nigdy tekstu. Nic na tym nie tracimy: zmierzone
|
|
184
|
+
* na żywym panelu — oba źródła oddały ten sam ekran co do bajta.
|
|
185
|
+
*/
|
|
186
|
+
readScreen: async (paneId) => ((await client.readScreen(paneId, 'detection')).text),
|
|
187
|
+
logger: log,
|
|
188
|
+
})
|
|
189
|
+
: undefined);
|
|
190
|
+
const audit = deps.audit ?? createHerdrAuditLog({ dataDir: config.dataDir });
|
|
191
|
+
const hidden = deps.hidden ?? createHiddenStore({ dataDir: config.dataDir });
|
|
192
|
+
const throttle = deps.throttle ?? createSendThrottle({ now });
|
|
193
|
+
const lifecycle = new AsyncEventQueue();
|
|
194
|
+
const agents = new Map();
|
|
195
|
+
const byPane = new Map();
|
|
196
|
+
const bySession = new Map();
|
|
197
|
+
/**
|
|
198
|
+
* Klucze agentów `claude` uruchomionych przez TEN proces Raroga.
|
|
199
|
+
*
|
|
200
|
+
* Drugie źródło własności obok nazwy agenta `rarog-<6 hex>` z odpowiedzi herdr — i jedyne,
|
|
201
|
+
* gdy nazwy brak (rekord startu wygasł, herdr wykrył agenta sam). Wpis żyje TYLE, CO AGENT:
|
|
202
|
+
* `forget` go kasuje, bo `freshKey` oddaje kolejnemu agentowi w tym samym panelu ten sam
|
|
203
|
+
* klucz, a ręczny `claude` po `/exit` nie ma prawa dziedziczyć chipa ani miejsca w suficie.
|
|
204
|
+
* Gdy następca wstaje bez pustej migawki pomiędzy (ten sam wpis, nowy uuid), kasuje go
|
|
205
|
+
* `applyInfo` po utracie nazwy `rarog-*` — patrz `AgentEntry.namedByRarog`.
|
|
206
|
+
* Unia dotyczy wyłącznie silnika `claude` — Rarog nie uruchamia Codexa.
|
|
207
|
+
*/
|
|
208
|
+
const launchedKeys = new Set();
|
|
209
|
+
/** `RAROG_HERDR_TAB_LABELS` — brak pola = włączone, jak domyślne w `config.ts`. */
|
|
210
|
+
const tabLabelsEnabled = config.tabLabels !== false;
|
|
211
|
+
/** Synchronizacje etykiet tabów z kartami, po kluczu agenta. */
|
|
212
|
+
const tabLabels = new Map();
|
|
213
|
+
/**
|
|
214
|
+
* Klucze świeżo założone przez launchera, którym etykieta pochodzenia panelu jeszcze nie
|
|
215
|
+
* powstała (`pane.rename` idzie po `agent.start`). Sync przed nią nie ma dowodu pochodzenia,
|
|
216
|
+
* a migracja starych etykiet nadałaby panelowi etykietę równolegle z launcherem — więc czeka.
|
|
217
|
+
*/
|
|
218
|
+
const provenancePending = new Set();
|
|
219
|
+
/** Linie logu synchronizacji etykiet, które już padły — linia raz na proces, nie lawina. */
|
|
220
|
+
const tabLabelLogged = new Set();
|
|
221
|
+
/** `pane.list` w locie — przebiegi kilku kluczy naraz (start Raroga) dzielą jeden odczyt. */
|
|
222
|
+
let panesInFlight = null;
|
|
223
|
+
let subscription = null;
|
|
224
|
+
let subscribedPanes = [];
|
|
225
|
+
let resyncTimer = null;
|
|
226
|
+
let refreshTimer = null;
|
|
227
|
+
let disposed = false;
|
|
228
|
+
let unavailable = false;
|
|
229
|
+
/** Status recheck after a dialog answer, so a lost `idle` push does not leave the card standing until the resync. */
|
|
230
|
+
const answerRecheck = createAnswerRecheck({ scheduler, refresh: (paneId) => refreshPane(paneId), log });
|
|
231
|
+
/** The client every driver gets: the same as `client`, with the recheck after each accepted dialog answer. */
|
|
232
|
+
const answerClient = answerRecheck.wrap(client);
|
|
233
|
+
/**
|
|
234
|
+
* Pokolenie rejestru AGENTÓW — bezpiecznik przeciw spóźnionym migawkom: resynce nakładają się (tick, debounce po zdarzeniach, reconnect), a `agent.list`
|
|
235
|
+
* idzie po osobnych gniazdach BEZ gwarancji kolejności odpowiedzi (socket: „zero
|
|
236
|
+
* pipeliningu"). Spóźniona STARSZA migawka bez świeżo odkrytego panelu ogłaszałaby mu
|
|
237
|
+
* `gone` (karta żywej sesji w `closed` na do 30 s), a migawka sprzed `closeTab`
|
|
238
|
+
* wskrzeszałaby zamknięty wpis jako drugą kartę. Rośnie przy każdej zmianie SKŁADU map
|
|
239
|
+
* (`newEntry`, `forget`); `resync` porównuje wartość sprzed i zza awaita `agent.list`
|
|
240
|
+
* i przy rozjeździe odpuszcza CAŁY przebieg — następny obrót pracuje na świeżej parze.
|
|
241
|
+
*/
|
|
242
|
+
let agentsEpoch = 0;
|
|
243
|
+
const emitPane = (entry, ev) => {
|
|
244
|
+
for (const listener of [...entry.listeners]) {
|
|
245
|
+
try {
|
|
246
|
+
listener(ev);
|
|
247
|
+
}
|
|
248
|
+
catch (err) {
|
|
249
|
+
// Wyjątek jednego drivera nie ma prawa zatrzymać aktualizacji pozostałych 16 paneli.
|
|
250
|
+
log(`herdr: pane listener threw an error: ${err.message}`);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
const markUnavailable = (reason) => {
|
|
255
|
+
if (unavailable)
|
|
256
|
+
return;
|
|
257
|
+
unavailable = true;
|
|
258
|
+
// Jedna linia na awarię (strażnik wyżej): bez niej restart herdr nie zostawiał w logu Raroga
|
|
259
|
+
// żadnego śladu, a powód (`events_lost`, EOF, timeout) szedł wyłącznie na baner w PWA.
|
|
260
|
+
log(`herdr: unavailable — ${textOf(reason)}`);
|
|
261
|
+
for (const entry of agents.values()) {
|
|
262
|
+
if (entry.attached)
|
|
263
|
+
entry.needsReattach = true;
|
|
264
|
+
// Dotyczy WSZYSTKICH wpisów, także nieprzypiętych: licznik zeruje serwer, nie manager.
|
|
265
|
+
entry.resyncWins = true;
|
|
266
|
+
}
|
|
267
|
+
lifecycle.push({ type: 'unavailable', reason });
|
|
268
|
+
};
|
|
269
|
+
/** Ile ŻYWYCH paneli należy do Raroga — sufit `RAROG_MAX_PANES`. */
|
|
270
|
+
const rarogPanes = () => [...agents.values()]
|
|
271
|
+
.filter((entry) => entry.agent.launchedByRarog).length;
|
|
272
|
+
/** Własność wpisu: nazwa agenta z herdr ALBO klucz tego procesu — ten drugi tylko dla `claude`. */
|
|
273
|
+
const ownedByRarog = (info, key) => info.launchedByRarog
|
|
274
|
+
|| (info.engine === 'claude' && launchedKeys.has(key));
|
|
275
|
+
const markAvailable = () => {
|
|
276
|
+
if (!unavailable)
|
|
277
|
+
return;
|
|
278
|
+
unavailable = false;
|
|
279
|
+
log('herdr: available again');
|
|
280
|
+
lifecycle.push({ type: 'available' });
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* Klucz tożsamości = `pane_id` z chwili PIERWSZEGO zobaczenia agenta.
|
|
284
|
+
*
|
|
285
|
+
* Kolizja jest realna, choć rzadka: agent A wyjeżdża z `w9:p72` (`pane move`), a chwilę
|
|
286
|
+
* później herdr tworzy nowy panel pod tym samym adresem. Bez sufiksu nowy agent przejąłby
|
|
287
|
+
* tożsamość — i deep-link — starego.
|
|
288
|
+
*/
|
|
289
|
+
const freshKey = (paneId) => {
|
|
290
|
+
if (!agents.has(paneId))
|
|
291
|
+
return paneId;
|
|
292
|
+
let n = 1;
|
|
293
|
+
while (agents.has(`${paneId}#${n}`))
|
|
294
|
+
n += 1;
|
|
295
|
+
return `${paneId}#${n}`;
|
|
296
|
+
};
|
|
297
|
+
/**
|
|
298
|
+
* Panel zniknął — chyba że go właśnie ZAKŁADAMY.
|
|
299
|
+
*
|
|
300
|
+
* Świeżo zarejestrowanego panelu NIE MA w `agent.list` przez pierwsze ~2 s: `agent.start`
|
|
301
|
+
* leci dopiero jeden obrót pętli po `tab.create`, a `agent_session` herdr wypełnia jeszcze
|
|
302
|
+
* później — do tego czasu `normalizeAgentInfo` odrzuca wpis w całości (filtr „claude z sesją
|
|
303
|
+
* po id"). Pierwszy resync w tym oknie zobaczyłby więc klucz bez odpowiednika na liście
|
|
304
|
+
* i ogłosił `gone` PANELOWI, KTÓRY DOPIERO WSTAJE.
|
|
305
|
+
*
|
|
306
|
+
* Skutek był widoczny na żywo: sesja szła `starting → done → starting → waiting-input`,
|
|
307
|
+
* a `#finishLaunch` w managerze trafiał na odpięty driver i po cichu GUBIŁ PROMPT STARTOWY
|
|
308
|
+
* — czyli pierwsze zdanie z telefonu nigdy nie docierało do panelu. `launching` chroniło
|
|
309
|
+
* dotąd tylko przed `appeared`; ta sama rejestracja musi chronić przed `gone`.
|
|
310
|
+
*
|
|
311
|
+
* Sierota po awarii managera nie jest tym chroniona: `launching` gaśnie po
|
|
312
|
+
* {@link LAUNCH_ADOPT_TIMEOUT_MS} i panel wraca do normalnego cyklu (reguła 11.9).
|
|
313
|
+
*/
|
|
314
|
+
/**
|
|
315
|
+
* Panel zniknął TUŻ PO dialogu zaufania — to re-eksekucja, nie zamknięcie.
|
|
316
|
+
*
|
|
317
|
+
* Zamiast ogłaszać `gone`, wracamy do stanu „czekam na agenta": wpis zostaje w mapach (więc
|
|
318
|
+
* `applyInfo` rozpozna wracający `agent_session` jako TĘ SAMĄ sesję), a po karencji, jeśli
|
|
319
|
+
* nikt nie wrócił, znika normalną drogą. Sesja przypięta dostaje wtedy `re-attached` —
|
|
320
|
+
* po re-eksekucji plik transkryptu bywa NOWY, więc świeże podpięcie jest tu dodatkową
|
|
321
|
+
* wartością, a nie kosztem.
|
|
322
|
+
*/
|
|
323
|
+
const holdForTrustReexec = (key, entry) => {
|
|
324
|
+
entry.awaitingAgent = true;
|
|
325
|
+
if (entry.attached)
|
|
326
|
+
entry.needsReattach = true;
|
|
327
|
+
log(`herdr: ${entry.agent.paneId} disappeared after the trust dialog — waiting for it to return`);
|
|
328
|
+
scheduler.setTimeout(() => {
|
|
329
|
+
const current = agents.get(key);
|
|
330
|
+
if (current === undefined || !current.awaitingAgent)
|
|
331
|
+
return;
|
|
332
|
+
// Nie wrócił w oknie karencji: od tej chwili brak agenta znaczy brak agenta.
|
|
333
|
+
current.awaitingAgent = false;
|
|
334
|
+
current.trustSeenAt = 0;
|
|
335
|
+
forget(key);
|
|
336
|
+
}, HERDR_TRUST_REEXEC_GRACE_MS);
|
|
337
|
+
};
|
|
338
|
+
// -------------------------------------------------------------------------
|
|
339
|
+
// Etykieta taba = etykieta karty
|
|
340
|
+
// -------------------------------------------------------------------------
|
|
341
|
+
const logTabLabelOnce = (tag, message) => {
|
|
342
|
+
if (tabLabelLogged.has(tag))
|
|
343
|
+
return;
|
|
344
|
+
tabLabelLogged.add(tag);
|
|
345
|
+
log(message);
|
|
346
|
+
};
|
|
347
|
+
/** Klucz zniknął — jego synchronizacja i czekanie na etykietę pochodzenia też. */
|
|
348
|
+
const dropTabLabel = (key) => {
|
|
349
|
+
provenancePending.delete(key);
|
|
350
|
+
const state = tabLabels.get(key);
|
|
351
|
+
if (state === undefined)
|
|
352
|
+
return;
|
|
353
|
+
if (state.timer !== null)
|
|
354
|
+
scheduler.clearTimeout(state.timer);
|
|
355
|
+
tabLabels.delete(key);
|
|
356
|
+
};
|
|
357
|
+
/** Jeden `pane.list` na wiele przebiegów naraz — tylko sklejenie żądań w locie, bez cache'u. */
|
|
358
|
+
const freshPanes = (client) => {
|
|
359
|
+
if (panesInFlight !== null)
|
|
360
|
+
return panesInFlight;
|
|
361
|
+
const pending = client.listPanes();
|
|
362
|
+
panesInFlight = pending;
|
|
363
|
+
const clear = () => {
|
|
364
|
+
if (panesInFlight === pending)
|
|
365
|
+
panesInFlight = null;
|
|
366
|
+
};
|
|
367
|
+
pending.then(clear, clear);
|
|
368
|
+
return pending;
|
|
369
|
+
};
|
|
370
|
+
/**
|
|
371
|
+
* Stara etykieta taba, którą wolno przejąć MIGRACJĄ: to, co nadawał stary launcher
|
|
372
|
+
* (`sanitizePaneTitle(basename(cwd))` — katalog agenta albo panelu, `cd` w powłoce bywa), albo
|
|
373
|
+
* „1" z `workspace.create`. Heurystyka, nie dowód autorstwa: pomyłka to zmiana nazwy taba,
|
|
374
|
+
* w którym stoi agent Raroga (`rarog-*`). Każda inna etykieta zostaje nietknięta.
|
|
375
|
+
*/
|
|
376
|
+
const isLegacyClaudeTabLabel = (label, cwds) => {
|
|
377
|
+
if (label === '1')
|
|
378
|
+
return true;
|
|
379
|
+
return cwds.some((cwd) => {
|
|
380
|
+
const dir = basename(cwd);
|
|
381
|
+
return dir !== '' && label === sanitizePaneTitle(dir, dir);
|
|
382
|
+
});
|
|
383
|
+
};
|
|
384
|
+
/**
|
|
385
|
+
* Odstęp kolejnego ponowienia po przeszkodzie przejściowej: pierwsze przy najbliższym udanym
|
|
386
|
+
* resyncu, potem {@link TAB_LABEL_RETRY_MIN_MS} podwajane do {@link TAB_LABEL_RETRY_MAX_MS}.
|
|
387
|
+
* Trwała odmowa (bramka zapisu) kończy się `done`, więc nie ma pętli.
|
|
388
|
+
*/
|
|
389
|
+
const tabLabelRetryDelay = (failures) => (failures <= 1 ? 0 : Math.min(TAB_LABEL_RETRY_MIN_MS * 2 ** (failures - 2), TAB_LABEL_RETRY_MAX_MS));
|
|
390
|
+
/**
|
|
391
|
+
* ŚWIEŻY `pane.list` tuż przed zapisem: pod tym adresem nadal stoi panel
|
|
392
|
+
* z oczekiwaną etykietą (`null` = bez etykiety, przy migracji), w tym tabie, i jest w nim SAM.
|
|
393
|
+
* Adresy herdr są pozycyjne, a od odczytu, na którym stoi decyzja, minęły co najmniej `tab.get`
|
|
394
|
+
* i ewentualne zapisy. Bez sklejania z `freshPanes`: odczyt w locie mógł wyjść przed zapisem.
|
|
395
|
+
*/
|
|
396
|
+
const confirmPane = async (client, paneId, tabId, label) => {
|
|
397
|
+
let panes;
|
|
398
|
+
try {
|
|
399
|
+
panes = await client.listPanes();
|
|
400
|
+
}
|
|
401
|
+
catch {
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
const here = panes.find((candidate) => candidate.paneId === paneId);
|
|
405
|
+
if (here === undefined || here.tabId !== tabId || here.label !== label)
|
|
406
|
+
return false;
|
|
407
|
+
return panes.filter((candidate) => candidate.tabId === tabId).length === 1;
|
|
408
|
+
};
|
|
409
|
+
/** Odmowa bramki zapisu jest trwała (`done`, jedna linia na proces), każdy inny błąd — `retry`. */
|
|
410
|
+
const writeFailed = (err, what) => {
|
|
411
|
+
if (err instanceof HerdrReadOnlyError) {
|
|
412
|
+
logTabLabelOnce('read-only', `herdr: tab labels without write access — ${err.message}`);
|
|
413
|
+
return 'done';
|
|
414
|
+
}
|
|
415
|
+
log(`herdr: ${what} (${err.message})`);
|
|
416
|
+
return 'retry';
|
|
417
|
+
};
|
|
418
|
+
/**
|
|
419
|
+
* JEDEN przebieg synchronizacji etykiety taba z kartą.
|
|
420
|
+
*
|
|
421
|
+
* Rarog nazywa tab WYŁĄCZNIE gdy: lokator to agent `claude` (Codex nigdy), tab jest
|
|
422
|
+
* jednopanelowy (`tab.get`, za każdym razem — panel mógł zostać przeniesiony albo tab
|
|
423
|
+
* podzielony), a panel nosi etykietę pochodzenia `rarog-claude <klucz> <ślad>`. Bieżąca etykieta
|
|
424
|
+
* taba jest „Raroga", gdy jej skrót równa się śladowi z etykiety panelu (trwałe — przeżywa
|
|
425
|
+
* restart Raroga i herdr) albo gdy ten proces sam ją tam zostawił (`written`, RAM). Każda inna
|
|
426
|
+
* = nadana ręcznie i NIETKNIĘTA — liczone przy każdym przebiegu od nowa, bez „ręcznej na zawsze".
|
|
427
|
+
*
|
|
428
|
+
* The pane label leads with the tab label (`<tab label> · rarog-claude <key> <trace>`): with
|
|
429
|
+
* Rarog's tab label it carries that label's trace, with a name given by hand it carries that
|
|
430
|
+
* name and the old trace. The pane label it already has = no write.
|
|
431
|
+
*
|
|
432
|
+
* Migracja starych etykiet: panel BEZ ŻADNEJ etykiety (niepusta etykieta spoza wzorców Raroga
|
|
433
|
+
* to nazwa człowieka — blokuje), agent z nazwą `rarog-*` (`namedByRarog`), tab jednopanelowy
|
|
434
|
+
* z etykietą katalogu albo „1" → najpierw etykieta panelu ze śladem BIEŻĄCEJ etykiety taba,
|
|
435
|
+
* potem zwykła ścieżka.
|
|
436
|
+
*
|
|
437
|
+
* ADRES przebiegu (panel i tab wpisu) jest zapamiętany na starcie i sprawdzany po KAŻDYM
|
|
438
|
+
* `await`: `applyInfo` przestawia żywy wpis przy `pane move`, a pod starym adresem staje wtedy
|
|
439
|
+
* cudzy panel. Zmiana adresu = koniec przebiegu i nowy pod nowym adresem. Każdy zapis poprzedza
|
|
440
|
+
* świeży odczyt ({@link confirmPane}).
|
|
441
|
+
*/
|
|
442
|
+
const syncTabLabelOnce = async (key, state) => {
|
|
443
|
+
const entry = agents.get(key);
|
|
444
|
+
if (entry === undefined) {
|
|
445
|
+
dropTabLabel(key);
|
|
446
|
+
return 'done';
|
|
447
|
+
}
|
|
448
|
+
if (entry.agent.engine !== 'claude' || launchClient === null)
|
|
449
|
+
return 'done';
|
|
450
|
+
// herdr chwilowo niedostępny — przebieg wraca po udanym resyncu (`retryPendingTabLabels`).
|
|
451
|
+
if (unavailable)
|
|
452
|
+
return 'retry';
|
|
453
|
+
const client = launchClient;
|
|
454
|
+
/*
|
|
455
|
+
* Kanał zapisu zamknięty (`RAROG_HERDR_SEND=0`, nieznany protokół): bramka gniazda i tak
|
|
456
|
+
* odbiłaby `tab.rename`, ale bez tego warunku każdy klucz płaciłby odczyty i linię logu.
|
|
457
|
+
* Jedna linia na proces mówi, czemu taby nie idą za kartami.
|
|
458
|
+
*/
|
|
459
|
+
if (!config.sendEnabled || transport.status().readOnly) {
|
|
460
|
+
logTabLabelOnce('read-only', 'herdr: tab labels on hold — write channel closed '
|
|
461
|
+
+ '(RAROG_HERDR_SEND=0 or unknown protocol)');
|
|
462
|
+
return 'done';
|
|
463
|
+
}
|
|
464
|
+
// Manager podaje etykietę już po `normalizeSessionLabel`; tu ta sama funkcja (idempotentna)
|
|
465
|
+
// i ten sam fallback co karta panelu zastanego: nazwa katalogu.
|
|
466
|
+
const target = sanitizeTabLabel(state.label, basename(entry.agent.cwd));
|
|
467
|
+
if (state.settled === target)
|
|
468
|
+
return 'done';
|
|
469
|
+
const paneId = entry.agent.paneId;
|
|
470
|
+
const entryTabId = entry.agent.tabId;
|
|
471
|
+
const interrupted = () => {
|
|
472
|
+
if (disposed || agents.get(key) !== entry)
|
|
473
|
+
return 'done';
|
|
474
|
+
return entry.agent.paneId !== paneId || entry.agent.tabId !== entryTabId ? 'moved' : null;
|
|
475
|
+
};
|
|
476
|
+
const panes = await freshPanes(client);
|
|
477
|
+
const afterList = interrupted();
|
|
478
|
+
if (afterList !== null)
|
|
479
|
+
return afterList;
|
|
480
|
+
const pane = panes.find((candidate) => candidate.paneId === paneId);
|
|
481
|
+
// Panel odsiany z listy (zubożony wiersz) albo właśnie znikający — rozstrzygnie resync.
|
|
482
|
+
if (pane === undefined)
|
|
483
|
+
return 'retry';
|
|
484
|
+
let provenance = parsePaneLabel(pane.label);
|
|
485
|
+
// Panel terminala Raroga (ktoś odpalił `claude` w powłoce z Raroga): jego tab nazywa terminal.
|
|
486
|
+
if (provenance?.kind === 'term')
|
|
487
|
+
return 'done';
|
|
488
|
+
if (provenance === null) {
|
|
489
|
+
// Etykieta człowieka (niepusta, spoza wzorców Raroga) — panel cudzy, migracja też nie.
|
|
490
|
+
if (pane.label !== null && pane.label.trim() !== '')
|
|
491
|
+
return 'done';
|
|
492
|
+
// Bez etykiety jedyną drogą jest migracja — a ta wymaga agenta z nazwą Raroga.
|
|
493
|
+
if (!entry.namedByRarog)
|
|
494
|
+
return 'done';
|
|
495
|
+
}
|
|
496
|
+
const tab = await client.getTab(pane.tabId);
|
|
497
|
+
const afterTab = interrupted();
|
|
498
|
+
if (afterTab !== null)
|
|
499
|
+
return afterTab;
|
|
500
|
+
if (tab.paneCount !== 1)
|
|
501
|
+
return 'done';
|
|
502
|
+
/*
|
|
503
|
+
* The label every write gate must find on the pane: the one read from `pane.list` in this
|
|
504
|
+
* pass, verbatim (it may carry a leading description), or the one this pass wrote itself.
|
|
505
|
+
* Rebuilding it from key and trace would miss a described label and skip every write.
|
|
506
|
+
*/
|
|
507
|
+
let expectedLabel = pane.label;
|
|
508
|
+
if (provenance === null) {
|
|
509
|
+
if (!isLegacyClaudeTabLabel(tab.label, [entry.agent.cwd, pane.cwd]))
|
|
510
|
+
return 'done';
|
|
511
|
+
const project = projectKey(await realProjectPath(entry.agent.cwd));
|
|
512
|
+
if (!(await confirmPane(client, paneId, tab.tabId, pane.label))) {
|
|
513
|
+
log(`herdr: pane ${paneId} changed before the label migration — skipping`);
|
|
514
|
+
return interrupted() ?? 'retry';
|
|
515
|
+
}
|
|
516
|
+
const beforeMigration = interrupted();
|
|
517
|
+
if (beforeMigration !== null)
|
|
518
|
+
return beforeMigration;
|
|
519
|
+
const migrated = claudePaneLabel(project, labelTrace(tab.label), tab.label);
|
|
520
|
+
try {
|
|
521
|
+
await client.renamePane(paneId, migrated);
|
|
522
|
+
}
|
|
523
|
+
catch (err) {
|
|
524
|
+
return writeFailed(err, `label migration of pane ${paneId} failed`);
|
|
525
|
+
}
|
|
526
|
+
log(`herdr: migration — pane ${paneId} got a provenance label (tab ${tab.tabId})`);
|
|
527
|
+
provenance = { kind: 'claude', value: project, trace: labelTrace(tab.label) };
|
|
528
|
+
expectedLabel = migrated;
|
|
529
|
+
}
|
|
530
|
+
const owned = provenance;
|
|
531
|
+
/** Etykieta panelu, którą zapis zastać MUSI — inaczej panel zmienił się pod tym adresem. */
|
|
532
|
+
const ownLabel = expectedLabel;
|
|
533
|
+
/**
|
|
534
|
+
* One `pane.rename` behind a fresh confirmation of the label read in this pass; `null` =
|
|
535
|
+
* written. A timeout is an unknown result: `retry`, and the next pass reads the label anew.
|
|
536
|
+
*/
|
|
537
|
+
const writePane = async (label, what) => {
|
|
538
|
+
if (!(await confirmPane(client, paneId, tab.tabId, ownLabel))) {
|
|
539
|
+
log(`herdr: pane ${paneId} changed before writing ${what} — skipping`);
|
|
540
|
+
return interrupted() ?? 'retry';
|
|
541
|
+
}
|
|
542
|
+
const beforeWrite = interrupted();
|
|
543
|
+
if (beforeWrite !== null)
|
|
544
|
+
return beforeWrite;
|
|
545
|
+
try {
|
|
546
|
+
await client.renamePane(paneId, label);
|
|
547
|
+
}
|
|
548
|
+
catch (err) {
|
|
549
|
+
return writeFailed(err, `failed to write ${what} on pane ${paneId}`);
|
|
550
|
+
}
|
|
551
|
+
return null;
|
|
552
|
+
};
|
|
553
|
+
/** The pane label Rarog's own tab label calls for: the card label first, its trace last. */
|
|
554
|
+
const targetLabel = claudePaneLabel(owned.value, labelTrace(target), target);
|
|
555
|
+
/** Nowy ślad po etykiecie, którą Rarog zostawił na tabie; `settled` tylko po udanym zapisie. */
|
|
556
|
+
const writeTrace = async () => {
|
|
557
|
+
const failed = await writePane(targetLabel, 'the tab label trace');
|
|
558
|
+
if (failed !== null)
|
|
559
|
+
return failed;
|
|
560
|
+
state.settled = target;
|
|
561
|
+
return 'done';
|
|
562
|
+
};
|
|
563
|
+
if (tab.label === target) {
|
|
564
|
+
// Tab już ma etykietę karty. Rozjechany ślad (zgubione `pane.rename` po udanym
|
|
565
|
+
// `tab.rename`) dopisujemy — inaczej następna zmiana karty wzięłaby własną etykietę
|
|
566
|
+
// za ręczną. A bare label (or another description) gets the card label the same way.
|
|
567
|
+
state.written = target;
|
|
568
|
+
if (ownLabel === targetLabel) {
|
|
569
|
+
state.settled = target;
|
|
570
|
+
return 'done';
|
|
571
|
+
}
|
|
572
|
+
return await writeTrace();
|
|
573
|
+
}
|
|
574
|
+
const ours = labelTrace(tab.label) === owned.trace || tab.label === state.written;
|
|
575
|
+
if (!ours) {
|
|
576
|
+
logTabLabelOnce(`manual|${key}|${tab.tabId}|${labelTrace(tab.label)}`, `herdr: tab ${tab.tabId} named by hand — the card label does not overwrite it`);
|
|
577
|
+
/*
|
|
578
|
+
* The tab stays the human's, but the pane label leads with that name, so herdr's Go-to
|
|
579
|
+
* shows it instead of hashes. The trace stays the old one: it proves Rarog's own tab
|
|
580
|
+
* label, and the name given by hand must not pass for Rarog's on the next card change.
|
|
581
|
+
*/
|
|
582
|
+
const manual = claudePaneLabel(owned.value, owned.trace, tab.label);
|
|
583
|
+
if (ownLabel === manual)
|
|
584
|
+
return 'done';
|
|
585
|
+
return await writePane(manual, 'the hand-given tab name') ?? 'done';
|
|
586
|
+
}
|
|
587
|
+
if (!(await confirmPane(client, paneId, tab.tabId, ownLabel))) {
|
|
588
|
+
log(`herdr: pane ${paneId} changed before the label change of tab ${tab.tabId} — skipping`);
|
|
589
|
+
return interrupted() ?? 'retry';
|
|
590
|
+
}
|
|
591
|
+
const beforeRename = interrupted();
|
|
592
|
+
if (beforeRename !== null)
|
|
593
|
+
return beforeRename;
|
|
594
|
+
try {
|
|
595
|
+
await client.renameTab(tab.tabId, target);
|
|
596
|
+
}
|
|
597
|
+
catch (err) {
|
|
598
|
+
if (err instanceof HerdrReadOnlyError)
|
|
599
|
+
return writeFailed(err, '');
|
|
600
|
+
/*
|
|
601
|
+
* Timeout nie mówi, czy `tab.rename` się wykonał (socket.ts). Świeży `tab.get` rozstrzyga:
|
|
602
|
+
* nowa etykieta stoi = sukces z zagubioną odpowiedzią (dopisujemy ślad), inaczej ponowienie.
|
|
603
|
+
* Bez tego własna etykieta po zgubionej odpowiedzi wyglądałaby jak ręczna.
|
|
604
|
+
*/
|
|
605
|
+
let after = null;
|
|
606
|
+
try {
|
|
607
|
+
after = await client.getTab(tab.tabId);
|
|
608
|
+
}
|
|
609
|
+
catch {
|
|
610
|
+
after = null;
|
|
611
|
+
}
|
|
612
|
+
const afterCheck = interrupted();
|
|
613
|
+
if (afterCheck !== null)
|
|
614
|
+
return afterCheck;
|
|
615
|
+
if (after?.label !== target) {
|
|
616
|
+
log(`herdr: failed to set the card label on tab ${tab.tabId} (${err.message})`);
|
|
617
|
+
return 'retry';
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
state.written = target;
|
|
621
|
+
log(`herdr: tab ${tab.tabId} got the card label (${key})`);
|
|
622
|
+
return await writeTrace();
|
|
623
|
+
};
|
|
624
|
+
const runTabLabel = async (key, state) => {
|
|
625
|
+
if (disposed || tabLabels.get(key) !== state)
|
|
626
|
+
return;
|
|
627
|
+
// Launcher jeszcze nie nadał etykiety pochodzenia — `paneLabelled` odliczy od nowa.
|
|
628
|
+
if (provenancePending.has(key))
|
|
629
|
+
return;
|
|
630
|
+
if (state.running) {
|
|
631
|
+
state.again = true;
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
state.running = true;
|
|
635
|
+
let outcome;
|
|
636
|
+
try {
|
|
637
|
+
outcome = await syncTabLabelOnce(key, state);
|
|
638
|
+
}
|
|
639
|
+
catch (err) {
|
|
640
|
+
log(`herdr: tab label sync failed for ${key} (${err.message})`);
|
|
641
|
+
outcome = 'retry';
|
|
642
|
+
}
|
|
643
|
+
finally {
|
|
644
|
+
state.running = false;
|
|
645
|
+
}
|
|
646
|
+
if (disposed || tabLabels.get(key) !== state)
|
|
647
|
+
return;
|
|
648
|
+
if (outcome === 'retry') {
|
|
649
|
+
// Niedokończony sync NIE ginie: wraca po udanym resyncu, z rosnącym odstępem.
|
|
650
|
+
state.pending = true;
|
|
651
|
+
state.failures += 1;
|
|
652
|
+
state.retryAt = now() + tabLabelRetryDelay(state.failures);
|
|
653
|
+
}
|
|
654
|
+
else {
|
|
655
|
+
state.pending = false;
|
|
656
|
+
state.failures = 0;
|
|
657
|
+
}
|
|
658
|
+
if (outcome === 'moved' || state.again) {
|
|
659
|
+
state.again = false;
|
|
660
|
+
armTabLabel(key, state);
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
const armTabLabel = (key, state) => {
|
|
664
|
+
if (state.timer !== null)
|
|
665
|
+
scheduler.clearTimeout(state.timer);
|
|
666
|
+
state.timer = scheduler.setTimeout(() => {
|
|
667
|
+
state.timer = null;
|
|
668
|
+
void runTabLabel(key, state);
|
|
669
|
+
}, TAB_LABEL_DEBOUNCE_MS);
|
|
670
|
+
};
|
|
671
|
+
/**
|
|
672
|
+
* Niedokończone synchronizacje po udanym resyncu: przebieg pominięty
|
|
673
|
+
* przy niedostępnym herdr albo zakończony przeszkodą przejściową NIE ginie, choć manager nie
|
|
674
|
+
* zawoła drugi raz z tym samym tytułem. Każdy wraca, gdy minie jego odstęp.
|
|
675
|
+
*/
|
|
676
|
+
const retryPendingTabLabels = () => {
|
|
677
|
+
if (disposed)
|
|
678
|
+
return;
|
|
679
|
+
const at = now();
|
|
680
|
+
for (const [key, state] of tabLabels) {
|
|
681
|
+
if (!state.pending || state.running || state.timer !== null || at < state.retryAt)
|
|
682
|
+
continue;
|
|
683
|
+
if (provenancePending.has(key))
|
|
684
|
+
continue;
|
|
685
|
+
armTabLabel(key, state);
|
|
686
|
+
}
|
|
687
|
+
};
|
|
688
|
+
/** Etykieta pochodzenia gotowa (albo start się rozstrzygnął) — odłożona synchronizacja rusza. */
|
|
689
|
+
const releaseProvenance = (key) => {
|
|
690
|
+
if (!provenancePending.delete(key))
|
|
691
|
+
return;
|
|
692
|
+
const state = tabLabels.get(key);
|
|
693
|
+
if (state !== undefined && !disposed)
|
|
694
|
+
armTabLabel(key, state);
|
|
695
|
+
};
|
|
696
|
+
/**
|
|
697
|
+
* @param reason `'missing'` — brak na `agent.list` (podlega WSZYSTKIM karencjom);
|
|
698
|
+
* `'closed'` — to MY zamknęliśmy tab (żadna karencja nie ma czego chronić);
|
|
699
|
+
* `'pane-gone'` — świeży `pane.list` nie zna PANELU tego wpisu, czyli tab naprawdę
|
|
700
|
+
* zniknął: bramki `blocked && !seenInList` i karencja re-eksekucji ustępują (chronią
|
|
701
|
+
* przed słabością dowodu z `agent.list`, a tu dowód jest o panel, nie o agenta),
|
|
702
|
+
* ale okno zakładania zostaje — migawka sprzed `tab.create` nie zna świeżego taba.
|
|
703
|
+
* `'engine-changed'` — w tym panelu stoi już INNY silnik: wpis nie ma czego opisywać,
|
|
704
|
+
* a jego następca powstaje w tej samej chwili, więc żadna karencja nie ma tu zastosowania.
|
|
705
|
+
*/
|
|
706
|
+
const forget = (key, reason = 'missing') => {
|
|
707
|
+
const entry = agents.get(key);
|
|
708
|
+
if (entry === undefined)
|
|
709
|
+
return;
|
|
710
|
+
// `'closed'` znaczy „to MY właśnie zamknęliśmy ten tab", `'engine-changed'` — „ten panel
|
|
711
|
+
// jest już czyimś innym". W obu okno zakładania jest zamknięte z definicji i ochrona przed
|
|
712
|
+
// przedwczesnym `gone` nie ma czego chronić.
|
|
713
|
+
if (reason !== 'closed' && reason !== 'engine-changed' && entry.awaitingAgent)
|
|
714
|
+
return;
|
|
715
|
+
/*
|
|
716
|
+
* Panel STOJĄCY NA DIALOGU, którego agenta `agent.list` nigdy nie pokazał.
|
|
717
|
+
*
|
|
718
|
+
* Dialog zaufania blokuje `claude` ZANIM powstanie `agent_session`, więc filtr wejściowy
|
|
719
|
+
* odrzuca ten panel przy każdym resyncu — a brak na liście nie jest tu dowodem zniknięcia,
|
|
720
|
+
* tylko skutkiem tego, że nie miał jak się na niej znaleźć. Dialog potrafi stać minutami
|
|
721
|
+
* (człowiek decyduje z telefonu), czyli znacznie dłużej niż karencja re-eksekucji.
|
|
722
|
+
*
|
|
723
|
+
* Bez tego warunku sesja szła w `done` + `stale`, driver się odpinał, a „Zatwierdź"
|
|
724
|
+
* z telefonu odpowiadało `ok` i nie robiło NIC — zmierzone na żywo w `rarog-spike`.
|
|
725
|
+
* `'closed'` przechodzi dalej: tab zamknięty przez Raroga znika normalną drogą.
|
|
726
|
+
*/
|
|
727
|
+
if (reason === 'missing' && !entry.seenInList && entry.agent.status === 'blocked')
|
|
728
|
+
return;
|
|
729
|
+
if (reason === 'missing'
|
|
730
|
+
&& entry.trustSeenAt > 0 && now() - entry.trustSeenAt <= HERDR_TRUST_REEXEC_GRACE_MS) {
|
|
731
|
+
holdForTrustReexec(key, entry);
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
// Odłożone „ruszył" umiera razem z wpisem — zegar bez wpisu nie ma czego zastosować.
|
|
735
|
+
if (entry.workingTimer !== null) {
|
|
736
|
+
scheduler.clearTimeout(entry.workingTimer);
|
|
737
|
+
entry.workingTimer = null;
|
|
738
|
+
entry.workingInfo = null;
|
|
739
|
+
}
|
|
740
|
+
agents.delete(key);
|
|
741
|
+
answerRecheck.cancel(entry.agent.paneId);
|
|
742
|
+
// Własność odchodzi RAZEM z agentem: następca w tym panelu dostanie od `freshKey`
|
|
743
|
+
// ten sam klucz, a jego własność ma wynikać z jego nazwy, nie z RAM po poprzedniku.
|
|
744
|
+
launchedKeys.delete(key);
|
|
745
|
+
// Synchronizacja etykiety taba żyje tyle, co agent: następca pod tym kluczem zaczyna od zera.
|
|
746
|
+
dropTabLabel(key);
|
|
747
|
+
agentsEpoch += 1;
|
|
748
|
+
deps.onAgentsChanged?.();
|
|
749
|
+
if (byPane.get(entry.agent.paneId) === key)
|
|
750
|
+
byPane.delete(entry.agent.paneId);
|
|
751
|
+
if (bySession.get(entry.agent.agentSessionId) === key) {
|
|
752
|
+
bySession.delete(entry.agent.agentSessionId);
|
|
753
|
+
}
|
|
754
|
+
emitPane(entry, { type: 'gone' });
|
|
755
|
+
entry.listeners.clear();
|
|
756
|
+
lifecycle.push({ type: 'gone', key });
|
|
757
|
+
};
|
|
758
|
+
/**
|
|
759
|
+
* Odczyt stopki trybu. Błąd odczytu ZOSTAWIA poprzedni tryb — zgadywanie byłoby gorsze.
|
|
760
|
+
*
|
|
761
|
+
* @returns wynik TEGO odczytu, dokładny (`acceptEdits` osobno): `unknown` przy błędzie,
|
|
762
|
+
* panelu Codexa i stopce niewidocznej. Wpis nadzorcy dostaje wartość ZLANĄ (`HerdrMode`).
|
|
763
|
+
* Zwracana jest wartość własna, a nie stan wpisu, bo dwa odczyty potrafią mieć ten sam
|
|
764
|
+
* znacznik `now()` — porównanie znaczników nie dowodzi niczego.
|
|
765
|
+
*/
|
|
766
|
+
const readMode = async (entry, onUnknown) => {
|
|
767
|
+
/*
|
|
768
|
+
* PANEL CODEXA NIE JEST CZYTANY — bramka stoi TUTAJ, a nie u wołających.
|
|
769
|
+
*
|
|
770
|
+
* `readMode` ma trzy wyzwalacze (nowy agent, tik resyncu, push `pane_agent_status_changed`
|
|
771
|
+
* → `refreshPane`) plus `ensureFreshMode`; bramka w wołających zamknęłaby część z nich
|
|
772
|
+
* i pierwszy nowy wołający otworzyłby dziurę z powrotem. Powody są dwa i oba są twarde:
|
|
773
|
+
* `parseMode` nie zna stopki Codexa, a `standingConsentDialog` na obcym ekranie potrafi
|
|
774
|
+
* rozpoznać fałszywy dialog zgody — czyli sztuczny `blocked` i push o czymś, czego nie ma.
|
|
775
|
+
* A przede wszystkim: to jest ODCZYT TREŚCI cudzego panelu, którego wpis Codexa nie
|
|
776
|
+
* obiecuje. Tryb zostaje `unknown`, więc bramka wysyłki jest fail-closed z definicji.
|
|
777
|
+
*/
|
|
778
|
+
if (entry.agent.engine === 'codex')
|
|
779
|
+
return 'unknown';
|
|
780
|
+
entry.lastModeReadAt = now();
|
|
781
|
+
let exact;
|
|
782
|
+
let consent;
|
|
783
|
+
let screenText;
|
|
784
|
+
try {
|
|
785
|
+
const screen = await client.readScreen(entry.agent.paneId, 'visible');
|
|
786
|
+
screenText = screen.text;
|
|
787
|
+
exact = parseModeFooter(screen.text);
|
|
788
|
+
consent = standingConsentDialog(screen.text);
|
|
789
|
+
}
|
|
790
|
+
catch (err) {
|
|
791
|
+
if (err instanceof HerdrGoneError)
|
|
792
|
+
return 'unknown';
|
|
793
|
+
log(`herdr: failed to read the mode of ${entry.agent.paneId}: ${err.message}`);
|
|
794
|
+
onUnknown?.(null);
|
|
795
|
+
return 'unknown';
|
|
796
|
+
}
|
|
797
|
+
const mode = collapseFooterMode(exact);
|
|
798
|
+
/*
|
|
799
|
+
* Dialog zgody CLI sprawdzamy PRZED bramką `unknown`: to on zasłania stopkę trybu,
|
|
800
|
+
* więc za nią nigdy byśmy go nie zobaczyli. Zapamiętany jest sam identyfikator z zamkniętej
|
|
801
|
+
* listy, nigdy tekst ekranu.
|
|
802
|
+
*/
|
|
803
|
+
if (consent !== entry.consentDialog) {
|
|
804
|
+
entry.consentDialog = consent;
|
|
805
|
+
emitPane(entry, { type: 'consent-dialog', dialog: consent });
|
|
806
|
+
}
|
|
807
|
+
/*
|
|
808
|
+
* `unknown` znaczy „stopki nie widać" (nakładka `/status`, pełnoekranowy dialog), a nie
|
|
809
|
+
* „tryb się zmienił". Nadpisanie nim znanego trybu kasowałoby chip `bypass` RAZEM
|
|
810
|
+
* z blokadą `RAROG_YOLO_ROOTS` — czyli akurat w chwili, gdy panel coś pokazuje, Rarog
|
|
811
|
+
* przestawałby wiedzieć, komu pisze. Reguła 11.3: nieznane → zostaw poprzednie.
|
|
812
|
+
*
|
|
813
|
+
* `modeReadAt` przesuwamy WYŁĄCZNIE przy odczycie, który tryb POTWIERDZIŁ: to pole jest
|
|
814
|
+
* bramką wysyłki, a „widziałem ekran, ale nie widziałem stopki" nie jest wiedzą
|
|
815
|
+
* o trybie. Nieprzesunięcie znacznika zostawia panel jako nieświeży, czyli fail-closed.
|
|
816
|
+
*/
|
|
817
|
+
if (mode === 'unknown') {
|
|
818
|
+
onUnknown?.(screenText);
|
|
819
|
+
return 'unknown';
|
|
820
|
+
}
|
|
821
|
+
entry.agent.modeReadAt = entry.lastModeReadAt;
|
|
822
|
+
if (mode !== entry.agent.mode) {
|
|
823
|
+
entry.agent.mode = mode;
|
|
824
|
+
emitPane(entry, { type: 'mode', mode });
|
|
825
|
+
}
|
|
826
|
+
return exact;
|
|
827
|
+
};
|
|
828
|
+
/** Czy tryb tego panelu był potwierdzony odczytem nie starszym niż `HERDR_MODE_FRESH_MS`? */
|
|
829
|
+
const modeIsFresh = (entry) => entry.agent.mode !== 'unknown'
|
|
830
|
+
&& entry.agent.modeReadAt > 0
|
|
831
|
+
&& now() - entry.agent.modeReadAt < HERDR_MODE_FRESH_MS;
|
|
832
|
+
/**
|
|
833
|
+
* ZAKRES wpisu — jedna funkcja dla obu miejsc, w których się go liczy.
|
|
834
|
+
*
|
|
835
|
+
* Codex ma `false` NA SZTYWNO, niezależnie od `RAROG_HERDR_ROOTS`: ścieżka `!inScope`
|
|
836
|
+
* w driverze robi dokładnie „stan bez treści" (bez followera jsonl, bez pulsu, bez odczytu
|
|
837
|
+
* ekranu przy `blocked`), a pliku transkryptu dla Codexa nie ma. Wspólna funkcja jest tu
|
|
838
|
+
* warunkiem poprawności, a nie estetyką: gałąź zmiany `cwd` liczyła zakres wyłącznie
|
|
839
|
+
* z korzeni, więc `cd` pod korzeń włączyłby Codexowi followera pliku, którego nie ma.
|
|
840
|
+
* The roots count as the work area: no hidden entry of a root, no macOS-protected folder of home, as written
|
|
841
|
+
* and on disk, so a link into such a folder or a root that is a symlink to home does not open it.
|
|
842
|
+
*/
|
|
843
|
+
const scopeOf = (info) => (info.engine === 'codex' ? false : inWorkAreaOnDisk(info.cwd, config.roots, home));
|
|
844
|
+
/**
|
|
845
|
+
* Nowy wpis agenta w mapach supervisora.
|
|
846
|
+
*
|
|
847
|
+
* Wspólne dla dwóch dróg, którymi agent trafia do Raroga: odkrycia w `agent.list`
|
|
848
|
+
* i rejestracji świeżo założonego panelu. Jedno miejsce, w którym powstaje `HerdrAgent`,
|
|
849
|
+
* jest warunkiem tego, żeby te dwie drogi nie rozjechały się o jedno pole.
|
|
850
|
+
*/
|
|
851
|
+
const newEntry = (key, info) => {
|
|
852
|
+
const agent = {
|
|
853
|
+
key,
|
|
854
|
+
paneId: info.paneId,
|
|
855
|
+
tabId: info.tabId,
|
|
856
|
+
agentSessionId: info.agentSessionId,
|
|
857
|
+
engine: info.engine,
|
|
858
|
+
termId: info.termId,
|
|
859
|
+
cwd: info.cwd,
|
|
860
|
+
status: info.status,
|
|
861
|
+
title: info.title,
|
|
862
|
+
stateChangeSeq: info.stateChangeSeq,
|
|
863
|
+
mode: 'unknown',
|
|
864
|
+
modeReadAt: 0,
|
|
865
|
+
inScope: scopeOf(info),
|
|
866
|
+
launchedByRarog: ownedByRarog(info, key),
|
|
867
|
+
interactiveReady: info.interactiveReady,
|
|
868
|
+
};
|
|
869
|
+
const entry = {
|
|
870
|
+
agent,
|
|
871
|
+
listeners: new Set(),
|
|
872
|
+
appliedSeq: info.stateChangeSeq,
|
|
873
|
+
lastModeReadAt: 0,
|
|
874
|
+
sentAt: 0,
|
|
875
|
+
trustSeenAt: 0,
|
|
876
|
+
consentDialog: null,
|
|
877
|
+
// Wpis z `agent.list` zapala flagę od razu; rejestracja launchera zostaje na `false`,
|
|
878
|
+
// dopóki agent naprawdę nie pokaże się na liście.
|
|
879
|
+
seenInList: false,
|
|
880
|
+
// Rejestracja launchera NIE jest dowodem nazwy — zapala ją dopiero informacja z herdr.
|
|
881
|
+
namedByRarog: false,
|
|
882
|
+
attached: false,
|
|
883
|
+
needsReattach: false,
|
|
884
|
+
resyncWins: false,
|
|
885
|
+
launching: false,
|
|
886
|
+
awaitingAgent: false,
|
|
887
|
+
workingInfo: null,
|
|
888
|
+
workingTimer: null,
|
|
889
|
+
};
|
|
890
|
+
agents.set(key, entry);
|
|
891
|
+
byPane.set(info.paneId, key);
|
|
892
|
+
bySession.set(info.agentSessionId, key);
|
|
893
|
+
agentsEpoch += 1;
|
|
894
|
+
deps.onAgentsChanged?.();
|
|
895
|
+
return entry;
|
|
896
|
+
};
|
|
897
|
+
/**
|
|
898
|
+
* Rejestruje świeżo założony panel, ZANIM zobaczy go `agent.list`.
|
|
899
|
+
*
|
|
900
|
+
* Bez tego kroku pierwszy resync po `tab.create` zobaczyłby nowy panel jako nieznany
|
|
901
|
+
* i wypchnął `appeared` — czyli DRUGĄ kartę Raroga na ten sam panel (manager ma już sesję,
|
|
902
|
+
* bo dostał `key` z `launch()`). Rejestracja gaśnie przy `attach()`; jeśli nikt nie
|
|
903
|
+
* podepnie się w {@link LAUNCH_ADOPT_TIMEOUT_MS}, panel wraca do normalnego cyklu jako
|
|
904
|
+
* `appeared` — sierota po awarii managera ma być WIDOCZNA, nie ukryta (reguła 11.9).
|
|
905
|
+
*/
|
|
906
|
+
const registerLaunched = (reg, label) => {
|
|
907
|
+
const key = freshKey(reg.paneId);
|
|
908
|
+
launchedKeys.add(key);
|
|
909
|
+
const entry = newEntry(key, {
|
|
910
|
+
paneId: reg.paneId,
|
|
911
|
+
tabId: reg.tabId,
|
|
912
|
+
agentSessionId: reg.agentSessionId,
|
|
913
|
+
// Launcher zakłada WYŁĄCZNIE panele Claude (`agent.start(kind: 'claude')`) — Codex
|
|
914
|
+
// z klienta jest poza zakresem. Panel launchera nie jest terminalem Raroga (własny tab
|
|
915
|
+
// z etykietą `rarog-claude`), więc tokenu terminala nie ma.
|
|
916
|
+
engine: 'claude',
|
|
917
|
+
termId: null,
|
|
918
|
+
cwd: reg.cwd,
|
|
919
|
+
// `unknown`, a nie `idle`: panel istnieje, ale agent w nim jeszcze nie wstał, więc
|
|
920
|
+
// każdy inny status byłby zgadywaniem (reguła 11.3).
|
|
921
|
+
status: 'unknown',
|
|
922
|
+
title: label,
|
|
923
|
+
stateChangeSeq: 0,
|
|
924
|
+
launchedByRarog: true,
|
|
925
|
+
// Do `interactive_ready` wysyłka zwróciłaby `agent_not_ready` — manager i tak czeka
|
|
926
|
+
// z promptem startowym na `handle.ready`.
|
|
927
|
+
interactiveReady: false,
|
|
928
|
+
});
|
|
929
|
+
entry.launching = true;
|
|
930
|
+
entry.awaitingAgent = true;
|
|
931
|
+
// The new pane joins the event subscription now: otherwise its pushes (the `idle` after the trust dialog answer)
|
|
932
|
+
// would be lost until a composition event or the resync tick renews the subscription.
|
|
933
|
+
resubscribeIfNeeded();
|
|
934
|
+
scheduler.setTimeout(() => {
|
|
935
|
+
const current = agents.get(key);
|
|
936
|
+
if (current === undefined)
|
|
937
|
+
return;
|
|
938
|
+
/*
|
|
939
|
+
* Koniec okna „zakładam". Od tej chwili brak agenta na liście znaczy brak agenta —
|
|
940
|
+
* inaczej panel, w którym `claude` nigdy nie wstał, wisiałby w Rarogu bez końca jako
|
|
941
|
+
* sesja, której nie da się ani ruszyć, ani zamknąć.
|
|
942
|
+
*/
|
|
943
|
+
current.awaitingAgent = false;
|
|
944
|
+
if (!current.launching)
|
|
945
|
+
return;
|
|
946
|
+
current.launching = false;
|
|
947
|
+
lifecycle.push({ type: 'appeared', agent: current.agent });
|
|
948
|
+
}, LAUNCH_ADOPT_TIMEOUT_MS);
|
|
949
|
+
return key;
|
|
950
|
+
};
|
|
951
|
+
/**
|
|
952
|
+
* Jedna aktualizacja stanu panelu — WSPÓLNA ścieżka dla resyncu i dla pushu.
|
|
953
|
+
*
|
|
954
|
+
* Push (`pane.agent_status_changed`) nie niesie ani `agent_session`, ani `state_change_seq`,
|
|
955
|
+
* więc driver i tak musi zapytać `agent.get` (0,2 ms). Dzięki temu istnieje dokładnie jedno
|
|
956
|
+
* miejsce, w którym rozstrzyga się tożsamość, kolejność i karencja — a nie dwa, które muszą
|
|
957
|
+
* się zgadzać.
|
|
958
|
+
*/
|
|
959
|
+
/** Czy ten status znaczy „panel stoi"? Tylko z takiego wejście w pracę podlega karencji. */
|
|
960
|
+
const quietNow = (status) => status === 'idle' || status === 'done';
|
|
961
|
+
/**
|
|
962
|
+
* @param opts.reconcile wywołanie z PEŁNEGO resyncu — status jedzie do drivera także wtedy,
|
|
963
|
+
* gdy nadzorca nie widzi u siebie zmiany (patrz komentarz przy emisji niżej)
|
|
964
|
+
*/
|
|
965
|
+
const applyInfo = (info, opts) => {
|
|
966
|
+
const at = now();
|
|
967
|
+
/*
|
|
968
|
+
* ZMIANA SILNIKA W PANELU = koniec jednej sesji i początek drugiej, nigdy mutacja
|
|
969
|
+
* wpisu.
|
|
970
|
+
*
|
|
971
|
+
* Człowiek wychodzi z `claude` i odpala w tym samym panelu `codex` (albo odwrotnie).
|
|
972
|
+
* Przepięcie uuid w miejscu zostawiłoby kartę z prawami POPRZEDNIKA: wpis Codexa
|
|
973
|
+
* z `inScope` po korzeniach, podpiętym followerem jsonl i composerem, albo sesję Claude
|
|
974
|
+
* bez transkryptu. Zdejmujemy więc oba wpisy wskazywane przez indeksy (uuid i panel mogą
|
|
975
|
+
* pokazywać na różne) i pozwalamy gałęzi „3. Nowy agent" zbudować wpis od zera — manager
|
|
976
|
+
* dostaje `gone` + `appeared`, czyli jedyną parę zdarzeń, którą umie obsłużyć bez domysłów.
|
|
977
|
+
*/
|
|
978
|
+
const staleEngines = [];
|
|
979
|
+
for (const stale of [bySession.get(info.agentSessionId), byPane.get(info.paneId)]) {
|
|
980
|
+
if (stale === undefined || staleEngines.some(([key]) => key === stale))
|
|
981
|
+
continue;
|
|
982
|
+
const prior = agents.get(stale);
|
|
983
|
+
if (prior === undefined || prior.agent.engine === info.engine)
|
|
984
|
+
continue;
|
|
985
|
+
staleEngines.push([stale, prior]);
|
|
986
|
+
}
|
|
987
|
+
/*
|
|
988
|
+
* STRAŻNIK KOLEJNOŚCI MUSI ZADZIAŁAĆ PRZED `forget`.
|
|
989
|
+
*
|
|
990
|
+
* `refreshPane` waits on `agent.get`, and meanwhile a resync can find a SECOND engine in
|
|
991
|
+
* the same pane and rebuild the entry. A late answer about the previous engine would then
|
|
992
|
+
* hit the "engine changed" branch, delete the FRESH entry and build a new one, and the guard
|
|
993
|
+
* below (`info.stateChangeSeq < entry.appliedSeq`) would have nothing left to defend, because
|
|
994
|
+
* the entry was replaced. Result: a Claude entry with `inScope: true` on a pane where Codex
|
|
995
|
+
* actually sits, and `readMode` → `readScreen` over its screen — exactly the boundary that
|
|
996
|
+
* Codex panes must never cross.
|
|
997
|
+
*
|
|
998
|
+
* The condition is CHARACTER FOR CHARACTER the one in the guard below, including the
|
|
999
|
+
* `resyncWins` exception (a herdr server restart resets `state_change_seq`, so a full resync
|
|
1000
|
+
* is then the source of truth). Outside that exception an older snapshot loses on every
|
|
1001
|
+
* channel, resync included: this branch deletes and creates entries, so a mistake costs more
|
|
1002
|
+
* than at the `status` field guard, and a late list comes back on the next turn anyway.
|
|
1003
|
+
*/
|
|
1004
|
+
for (const [stale, prior] of staleEngines) {
|
|
1005
|
+
if (info.stateChangeSeq < prior.appliedSeq && !prior.resyncWins) {
|
|
1006
|
+
log(`herdr: dropped a late update for ${info.paneId} (seq ${info.stateChangeSeq}, `
|
|
1007
|
+
+ `engine ${info.engine} vs ${prior.agent.engine})`);
|
|
1008
|
+
return { key: stale };
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
for (const [stale] of staleEngines) {
|
|
1012
|
+
log(`herdr: ${info.paneId} changed engine to ${info.engine} — the entry starts over`);
|
|
1013
|
+
forget(stale, 'engine-changed');
|
|
1014
|
+
}
|
|
1015
|
+
let key = bySession.get(info.agentSessionId);
|
|
1016
|
+
let entry = key === undefined ? undefined : agents.get(key);
|
|
1017
|
+
/*
|
|
1018
|
+
* Panel jest FIZYCZNĄ kotwicą tożsamości: jeden panel = jeden agent. Gdy oba indeksy
|
|
1019
|
+
* wskazują RÓŻNE wpisy (uuid znany pod innym panelem, a ten panel ma własny wpis),
|
|
1020
|
+
* wierzymy panelowi — to `/resume` wpisane w terminalu: panel przełączył się na sesję,
|
|
1021
|
+
* którą nadzorca zna skądinąd. Ślepa gałąź „pane move" przepinałaby CUDZY wpis na ten
|
|
1022
|
+
* panel, a jego własny wpis zostawałby bez zdarzenia — karta w Rarogu milczałaby mimo
|
|
1023
|
+
* zmiany rozmowy w panelu.
|
|
1024
|
+
*/
|
|
1025
|
+
const paneKey = byPane.get(info.paneId);
|
|
1026
|
+
if (entry !== undefined && key !== undefined && (paneKey === undefined || paneKey === key)) {
|
|
1027
|
+
// 1. Znany `agent_session` → ten sam agent. Zmiana `pane_id` = `pane move`.
|
|
1028
|
+
if (entry.agent.paneId !== info.paneId) {
|
|
1029
|
+
if (byPane.get(entry.agent.paneId) === key)
|
|
1030
|
+
byPane.delete(entry.agent.paneId);
|
|
1031
|
+
entry.agent.paneId = info.paneId;
|
|
1032
|
+
byPane.set(info.paneId, key);
|
|
1033
|
+
emitPane(entry, { type: 'pane-changed', paneId: info.paneId });
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
else {
|
|
1037
|
+
key = paneKey;
|
|
1038
|
+
entry = key === undefined ? undefined : agents.get(key);
|
|
1039
|
+
if (entry !== undefined && key !== undefined) {
|
|
1040
|
+
// 2. Znany `pane_id`, nowy uuid sesji → `/clear` albo `/resume` w tym samym panelu.
|
|
1041
|
+
if (entry.agent.agentSessionId !== info.agentSessionId) {
|
|
1042
|
+
bySession.delete(entry.agent.agentSessionId);
|
|
1043
|
+
entry.agent.agentSessionId = info.agentSessionId;
|
|
1044
|
+
// `set` nadpisuje też ewentualny wpis cudzego panelu pod tym uuid (kolizja wyżej):
|
|
1045
|
+
// od teraz sesję silnika ma TEN panel; tamten wpis zniknie z listy swoim trybem.
|
|
1046
|
+
bySession.set(info.agentSessionId, key);
|
|
1047
|
+
emitPane(entry, { type: 'session-changed', agentSessionId: info.agentSessionId });
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
else {
|
|
1051
|
+
// 3. Nowy agent. Flaga „widziany w rejestrze" zapala się TUTAJ, nie w `newEntry`:
|
|
1052
|
+
// wpis odkryty przez `applyInfo` z definicji przyszedł z `agent.list`/`agent.get`,
|
|
1053
|
+
// a wpis launchera ma zostać na `false` do pierwszego potwierdzenia listą. Bez tej
|
|
1054
|
+
// linii wczesny `return` omijał zapalenie niżej i świeżo odkryty panel w `blocked`
|
|
1055
|
+
// wpadał pod bramkę `!seenInList` w `forget` — wpis nie do zdjęcia do restartu.
|
|
1056
|
+
key = freshKey(info.paneId);
|
|
1057
|
+
entry = newEntry(key, info);
|
|
1058
|
+
entry.seenInList = true;
|
|
1059
|
+
entry.namedByRarog = info.launchedByRarog;
|
|
1060
|
+
lifecycle.push({ type: 'appeared', agent: entry.agent });
|
|
1061
|
+
return { key, modeRead: readMode(entry) };
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
// Agent JEST już na liście — okno „zakładam, jeszcze mnie nie widać" się zamknęło
|
|
1065
|
+
// i od tej chwili zniknięcie z `agent.list` znaczy zniknięcie naprawdę.
|
|
1066
|
+
entry.awaitingAgent = false;
|
|
1067
|
+
entry.seenInList = true;
|
|
1068
|
+
// Pola z odpowiedzi herdr, które NIE podlegają strażnikowi kolejności, bo nie są stanem:
|
|
1069
|
+
// adres taba (zmienia się przy przenoszeniu panelu), gotowość na wysyłkę i własność.
|
|
1070
|
+
entry.agent.tabId = info.tabId;
|
|
1071
|
+
entry.agent.interactiveReady = info.interactiveReady;
|
|
1072
|
+
// `termId` podąża za migawką z tego samego powodu co `tabId`: token `rarog-term` jest
|
|
1073
|
+
// metadaną panelu i pojawia się (albo znika) niezależnie od stanu agenta. Zmiana idzie do
|
|
1074
|
+
// managera osobnym zdarzeniem: od `termId` zależy, czy klient pokazuje agenta w terminalu,
|
|
1075
|
+
// a restart serwera herdr odtwarza Claude w panelu, ZANIM terminal odzyska token z etykiety.
|
|
1076
|
+
// Odłożone potwierdzenie pracy (`confirmWorking`) niesie migawkę sprzed karencji: potwierdza
|
|
1077
|
+
// STATUS, a nowszy resync mógł już przynieść token, którego ta migawka nie zna.
|
|
1078
|
+
if (opts.confirmWorking !== true && entry.agent.termId !== info.termId) {
|
|
1079
|
+
entry.agent.termId = info.termId;
|
|
1080
|
+
lifecycle.push({ type: 'term-changed', agent: entry.agent });
|
|
1081
|
+
}
|
|
1082
|
+
// UNIA dwóch źródeł własności: nazwa agenta z herdr ALBO klucz tego procesu. Nazwy
|
|
1083
|
+
// bywa brak (wygasły rekord startu), a `launchedKeys` ginie przy restarcie Raroga — żadne
|
|
1084
|
+
// z nich samo nie wystarcza, a fałszywe `false` znaczy tylko brak chipa i miejsca w suficie.
|
|
1085
|
+
/*
|
|
1086
|
+
* Agent z nazwą Raroga zniknął z tego panelu, a w jego miejscu stoi proces bez nazwy
|
|
1087
|
+
* (`/exit` + ręczny `claude` w jednej przerwie między migawkami): klucz z RAM odchodzi
|
|
1088
|
+
* tak, jak odszedłby w `forget`. Granica znana i przyjęta: agent Raroga, który nazwy nie
|
|
1089
|
+
* miał NIGDY (wygasły rekord startu), po `/clear` wygląda dokładnie jak zastąpiony — nowy
|
|
1090
|
+
* uuid, brak nazwy — i bez PID procesu nie da się tych dwóch przypadków rozróżnić. Wtedy
|
|
1091
|
+
* własność z RAM zostaje: pomyłka kosztuje chip i miejsce w suficie, zero władzy.
|
|
1092
|
+
*/
|
|
1093
|
+
if (entry.namedByRarog && !info.launchedByRarog)
|
|
1094
|
+
launchedKeys.delete(entry.agent.key);
|
|
1095
|
+
entry.namedByRarog = info.launchedByRarog;
|
|
1096
|
+
entry.agent.launchedByRarog = ownedByRarog(info, entry.agent.key);
|
|
1097
|
+
// `cwd` panelu potrafi się zmienić (`cd` w powłoce pod agentem) — zakres liczymy na nowo.
|
|
1098
|
+
if (entry.agent.cwd !== info.cwd) {
|
|
1099
|
+
entry.agent.cwd = info.cwd;
|
|
1100
|
+
// TA SAMA funkcja co w `newEntry`: bez niej `cd` Codexa pod `RAROG_HERDR_ROOTS`
|
|
1101
|
+
// zlecałby reattach z followerem pliku jsonl, którego dla Codexa nie ma.
|
|
1102
|
+
const inScope = scopeOf(info);
|
|
1103
|
+
/*
|
|
1104
|
+
* Zmiana ZAKRESU to zmiana praw karty (transkrypt, wysyłka), a driver kopiuje
|
|
1105
|
+
* `inScope` przy podpięciu i decyduje nim o followerze — samo nadpisanie pola
|
|
1106
|
+
* w RAM nie zmieniało więc NICZEGO do najbliższego przypadkowego reattachu:
|
|
1107
|
+
* panel po `cd` poza `RAROG_HERDR_ROOTS` dalej oddawał transkrypt i przyjmował
|
|
1108
|
+
* wysyłkę (reguła 6 `docs/security-model.md`). Reattach jest tą
|
|
1109
|
+
* drogą, która przebudowuje driver od zera — z followerem albo bez.
|
|
1110
|
+
*/
|
|
1111
|
+
if (inScope !== entry.agent.inScope) {
|
|
1112
|
+
entry.agent.inScope = inScope;
|
|
1113
|
+
if (entry.attached)
|
|
1114
|
+
entry.needsReattach = true;
|
|
1115
|
+
log(`herdr: ${entry.agent.paneId} changed scope (inScope=${String(inScope)}) after cd to ${info.cwd}`);
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
// Tytuł NIE podlega strażnikowi kolejności: auto-tytuł konwersacji zmienia się w trakcie
|
|
1119
|
+
// pracy, bez zmiany stanu, więc `state_change_seq` nie ma o nim nic do powiedzenia.
|
|
1120
|
+
let titleChanged = false;
|
|
1121
|
+
if (entry.agent.title !== info.title) {
|
|
1122
|
+
entry.agent.title = info.title;
|
|
1123
|
+
titleChanged = true;
|
|
1124
|
+
}
|
|
1125
|
+
const inGrace = at - entry.sentAt < HERDR_IDLE_GRACE_MS;
|
|
1126
|
+
const quiet = info.status === 'idle' || info.status === 'done';
|
|
1127
|
+
/*
|
|
1128
|
+
* KARENCJA NA WEJŚCIE W PRACĘ.
|
|
1129
|
+
*
|
|
1130
|
+
* Agent główny w trakcie workflow drga: rozstawia subagentów, przez moment jest `working`,
|
|
1131
|
+
* po czym wraca do czekania. Bez karencji Rarog łapałby te błyski i malował kartę na zielono
|
|
1132
|
+
* razem z wyzerowaniem timera — panel wyglądałby na „ciągle pracujący", a herdr obejrzany
|
|
1133
|
+
* sekundę później pokazywałby „skończony".
|
|
1134
|
+
*
|
|
1135
|
+
* Odkładamy WYŁĄCZNIE przejście cisza → `working` i wyłącznie o {@link
|
|
1136
|
+
* HERDR_WORKING_GRACE_MS}. Kierunek jest tu wszystkim: opóźnienie sygnału „gotowe"
|
|
1137
|
+
* kosztowałoby przy każdej turze, bo to na niego czeka człowiek z telefonem. Powrót do
|
|
1138
|
+
* ciszy rozbraja zegar, a jeśli praca się utrzyma, zegar woła `applyInfo` z tą samą
|
|
1139
|
+
* migawką i `confirmWorking` — dalej normalną ścieżką, z tym samym strażnikiem kolejności.
|
|
1140
|
+
*
|
|
1141
|
+
* Karencja obejmuje WYŁĄCZNIE kanał pushowy. Pełny resync jest źródłem prawdy (nagłówek
|
|
1142
|
+
* pliku: „push tylko wyprzedza prawdę") — skoro `agent.list` mówi `working`, to panel pracuje
|
|
1143
|
+
* teraz, a nie błysnął. Dzięki temu odsiewamy szum, nie opóźniając niczego, co pewne.
|
|
1144
|
+
*
|
|
1145
|
+
* `blocked` NIE podlega karencji nigdzie: dialog musi być widoczny natychmiast.
|
|
1146
|
+
*/
|
|
1147
|
+
const holdWorking = info.status === 'working' && quietNow(entry.agent.status)
|
|
1148
|
+
&& opts.confirmWorking !== true && opts.reconcile !== true;
|
|
1149
|
+
if (info.status !== 'working' && entry.workingTimer !== null) {
|
|
1150
|
+
// Wrócił do ciszy — nie ma czego potwierdzać.
|
|
1151
|
+
scheduler.clearTimeout(entry.workingTimer);
|
|
1152
|
+
entry.workingTimer = null;
|
|
1153
|
+
entry.workingInfo = null;
|
|
1154
|
+
}
|
|
1155
|
+
let statusChanged = false;
|
|
1156
|
+
if (holdWorking) {
|
|
1157
|
+
// Zegar zbrojony RAZ: kolejne migawki tej samej pracy tylko odświeżają, co zastosujemy.
|
|
1158
|
+
entry.workingInfo = info;
|
|
1159
|
+
if (entry.workingTimer === null) {
|
|
1160
|
+
entry.workingTimer = scheduler.setTimeout(() => {
|
|
1161
|
+
entry.workingTimer = null;
|
|
1162
|
+
const pending = entry.workingInfo;
|
|
1163
|
+
entry.workingInfo = null;
|
|
1164
|
+
if (disposed || pending === null || !agents.has(key))
|
|
1165
|
+
return;
|
|
1166
|
+
void applyInfo(pending, { forceModeRead: false, confirmWorking: true });
|
|
1167
|
+
}, HERDR_WORKING_GRACE_MS);
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
else if (inGrace && quiet) {
|
|
1171
|
+
// Karencja: NIE zapisujemy `appliedSeq`, żeby ta sama migawka po karencji weszła
|
|
1172
|
+
// normalnie (inaczej strażnik kolejności odrzuciłby ją jako „starą").
|
|
1173
|
+
log(`herdr: post-send grace period skips ${info.status} for ${info.paneId}`);
|
|
1174
|
+
}
|
|
1175
|
+
else if (info.stateChangeSeq < entry.appliedSeq && !entry.resyncWins) {
|
|
1176
|
+
// Strażnik kolejności: `agent.list` zwraca migawkę sprzed odpowiedzi, więc resync
|
|
1177
|
+
// potrafiłby cofnąć świeższy push i przestawić kartę w inną sekcję listy.
|
|
1178
|
+
//
|
|
1179
|
+
// Wyjątek `needsReattach`: pierwsza aktualizacja po POWROCIE gniazda pochodzi z pełnego
|
|
1180
|
+
// resynca, a restart serwera herdr ZERUJE `state_change_seq` (zmierzone:
|
|
1181
|
+
// po `session stop` + `session attach` licznik wraca do 0). Bez tego wyjątku strażnik
|
|
1182
|
+
// odrzucałby wszystko, dopóki panel nie „dorobi" starego numeru, czyli Rarog pokazywałby
|
|
1183
|
+
// zamrożone stany kart po każdym restarcie herdr. Resync jest źródłem prawdy,
|
|
1184
|
+
// więc to on wygrywa — nie zapamiętany licznik sprzed awarii.
|
|
1185
|
+
log(`herdr: dropped a late update for ${info.paneId} (seq ${info.stateChangeSeq})`);
|
|
1186
|
+
}
|
|
1187
|
+
else {
|
|
1188
|
+
entry.resyncWins = false;
|
|
1189
|
+
entry.appliedSeq = info.stateChangeSeq;
|
|
1190
|
+
entry.agent.stateChangeSeq = info.stateChangeSeq;
|
|
1191
|
+
if (entry.agent.status !== info.status) {
|
|
1192
|
+
entry.agent.status = info.status;
|
|
1193
|
+
statusChanged = true;
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
// `unknown` znaczy dokładnie „nie wiem" i NIE MA prawa wywołać przejścia stanu sesji
|
|
1197
|
+
// (reguła domyślna 11.3: nigdy nie zgaduj „skończył"). Migawka agenta zostaje prawdziwa,
|
|
1198
|
+
// ale driver nie dostaje o tym zdarzenia — sesja trzyma ostatni znany stan.
|
|
1199
|
+
const known = entry.agent.status !== 'unknown';
|
|
1200
|
+
const meaningful = statusChanged && known;
|
|
1201
|
+
/*
|
|
1202
|
+
* RESYNC POWTARZA STATUS, nawet gdy nadzorca nie widzi u siebie zmiany.
|
|
1203
|
+
*
|
|
1204
|
+
* Do tej pory zdarzenie leciało WYŁĄCZNIE przy zmianie `entry.agent.status` — czyli
|
|
1205
|
+
* nadzorca milczał zawsze, gdy jego własna migawka się zgadzała. Problem w tym, że stan
|
|
1206
|
+
* SESJI potrafi się rozjechać z migawką bez udziału herdr: Rarog ustawia `running`
|
|
1207
|
+
* optymistycznie zaraz po wysyłce, a karencja `HERDR_IDLE_GRACE_MS` celowo połyka
|
|
1208
|
+
* `idle`/`done` z pierwszych 3 s. Jeśli agent skończył w tym oknie, a nadzorca pamiętał
|
|
1209
|
+
* `idle` już wcześniej, to KAŻDY kolejny odczyt jest „bez zmiany" — i manager zostaje
|
|
1210
|
+
* z `running` do restartu Raroga.
|
|
1211
|
+
*
|
|
1212
|
+
* Resync jest źródłem prawdy, więc niech ją POWTARZA. Zdarzenie jest idempotentne:
|
|
1213
|
+
* przejście na ten sam stan to tożsamość, a manager rozgłasza `session-changed` tylko
|
|
1214
|
+
* wtedy, gdy naprawdę coś się zmieniło — więc powtórka nic nie kosztuje.
|
|
1215
|
+
*/
|
|
1216
|
+
if (meaningful || titleChanged || (opts.reconcile === true && known)) {
|
|
1217
|
+
emitPane(entry, {
|
|
1218
|
+
type: 'status',
|
|
1219
|
+
status: entry.agent.status,
|
|
1220
|
+
stateChangeSeq: entry.agent.stateChangeSeq,
|
|
1221
|
+
title: entry.agent.title,
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1224
|
+
if (entry.needsReattach) {
|
|
1225
|
+
entry.needsReattach = false;
|
|
1226
|
+
lifecycle.push({ type: 're-attached', agent: entry.agent });
|
|
1227
|
+
}
|
|
1228
|
+
/*
|
|
1229
|
+
* `MODE_READ_MIN_INTERVAL_MS` obowiązuje KAŻDĄ drogę odczytu, także `forceModeRead`.
|
|
1230
|
+
*
|
|
1231
|
+
* Bez tego resync (jedyny wołający z `forceModeRead`) czytałby ekran KAŻDEGO panelu
|
|
1232
|
+
* bezwarunkowo — a resync leci nie tylko z tikiem `HERDR_RESYNC_MS`, ale i z debounce
|
|
1233
|
+
* 500 ms po `COMPOSITION_EVENTS`. Burza `pane_created`/`pane_moved` (zakładanie panelu,
|
|
1234
|
+
* przenoszenie taba na Macu) dawałaby więc serię pełnych odczytów × liczba paneli w oknie,
|
|
1235
|
+
* w którym stopka trybu nie ma prawa się zmienić.
|
|
1236
|
+
*
|
|
1237
|
+
* Świeżości NIE psuje: przy tiku 30 s odstęp 10 s niczego nie odcina, nowy panel idzie
|
|
1238
|
+
* ścieżką „3. Nowy agent" (czyta bezwarunkowo), a bramka wysyłki ma własne `ensureFreshMode`
|
|
1239
|
+
* (fail-closed) — więc nawet zaległy odczyt nie przepuści promptu w nieznanym trybie.
|
|
1240
|
+
*/
|
|
1241
|
+
const staleMode = at - entry.lastModeReadAt >= MODE_READ_MIN_INTERVAL_MS;
|
|
1242
|
+
/*
|
|
1243
|
+
* Panel BEZCZYNNY z podpiętym driverem czytamy też BEZ zmiany statusu: dialog zgody
|
|
1244
|
+
* CLI staje po turze i nie zmienia statusu herdr, więc bez tego odczytu telefon dowiadywałby
|
|
1245
|
+
* się o nim dopiero przy próbie wysyłki. Koszt: jeden `agent.read` (0,2 ms) na panel
|
|
1246
|
+
* na tik resyncu, ograniczony tym samym odstępem co odczyt trybu.
|
|
1247
|
+
*/
|
|
1248
|
+
const idleWatch = entry.attached && entry.agent.status === 'idle';
|
|
1249
|
+
if (staleMode && (opts.forceModeRead || statusChanged || idleWatch)) {
|
|
1250
|
+
return { key, modeRead: readMode(entry) };
|
|
1251
|
+
}
|
|
1252
|
+
return { key };
|
|
1253
|
+
};
|
|
1254
|
+
/**
|
|
1255
|
+
* Zdjęcie wpisów, których bramka `blocked && !seenInList` broni przed `agent.list`,
|
|
1256
|
+
* gdy świeży `pane.list` dowodzi, że PANELU już nie ma.
|
|
1257
|
+
*
|
|
1258
|
+
* Bramka w `forget` jest świadomie ślepa na czas (dialog zaufania potrafi stać
|
|
1259
|
+
* godzinami), więc panel zamknięty ręcznie W TRAKCIE dialogu zostawał w mapach na
|
|
1260
|
+
* zawsze: liczył się do sufitu `RAROG_MAX_PANES` („Nowa sesja" gasła na stałe),
|
|
1261
|
+
* a jego martwy `pane_id` jechał w każdej kolejnej subskrypcji. Zegar byłby tu złym
|
|
1262
|
+
* lekarstwem (ubijałby też legalny, długo stojący dialog) — dowód istnienia panelu
|
|
1263
|
+
* jest precyzyjny: pobieramy luźny inwentarz `pane_id` tylko przy kandydatach.
|
|
1264
|
+
*/
|
|
1265
|
+
const sweepBlockedOrphans = (alive) => {
|
|
1266
|
+
for (const [key, entry] of [...agents]) {
|
|
1267
|
+
if (entry.seenInList || entry.agent.status !== 'blocked')
|
|
1268
|
+
continue;
|
|
1269
|
+
if (alive.has(entry.agent.paneId))
|
|
1270
|
+
continue;
|
|
1271
|
+
forget(key, 'pane-gone');
|
|
1272
|
+
}
|
|
1273
|
+
};
|
|
1274
|
+
/** Czy w mapach siedzi kandydat na sierotę? Bez kandydata nie ma po co pobierać inwentarza. */
|
|
1275
|
+
const hasBlockedOrphanCandidates = () => [...agents.values()]
|
|
1276
|
+
.some((entry) => !entry.seenInList && entry.agent.status === 'blocked');
|
|
1277
|
+
/** Pełny `agent.list` — źródło prawdy. Push tylko go wyprzedza. */
|
|
1278
|
+
const resync = async () => {
|
|
1279
|
+
if (disposed)
|
|
1280
|
+
return;
|
|
1281
|
+
const epoch = agentsEpoch;
|
|
1282
|
+
let infos;
|
|
1283
|
+
try {
|
|
1284
|
+
infos = await client.listAgents();
|
|
1285
|
+
}
|
|
1286
|
+
catch (err) {
|
|
1287
|
+
markUnavailable(sentenceOfError(err));
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
markAvailable();
|
|
1291
|
+
/*
|
|
1292
|
+
* Skład map zmienił się W TRAKCIE odczytu (równoległy resync coś odkrył, `closeTab`
|
|
1293
|
+
* coś zdjął): ta migawka `agent.list` jest starsza od rejestru, więc pętla `forget`
|
|
1294
|
+
* ogłosiłaby `gone` wpisowi, którego w migawce jeszcze nie ma, a pętla `applyInfo`
|
|
1295
|
+
* wskrzesiła wpis, którego już nie ma. Odpuszczamy CAŁY przebieg (patrz
|
|
1296
|
+
* {@link agentsEpoch}) — i zbroimy debounce, żeby świeża para rejestr+lista poszła
|
|
1297
|
+
* za ~pół sekundy, a nie dopiero z tickiem za 30 s.
|
|
1298
|
+
*/
|
|
1299
|
+
if (epoch !== agentsEpoch) {
|
|
1300
|
+
scheduleRefresh();
|
|
1301
|
+
return;
|
|
1302
|
+
}
|
|
1303
|
+
const seen = new Set();
|
|
1304
|
+
const modeReads = [];
|
|
1305
|
+
for (const info of infos) {
|
|
1306
|
+
const outcome = applyInfo(info, { forceModeRead: true, reconcile: true });
|
|
1307
|
+
seen.add(outcome.key);
|
|
1308
|
+
if (outcome.modeRead !== undefined)
|
|
1309
|
+
modeReads.push(outcome.modeRead);
|
|
1310
|
+
}
|
|
1311
|
+
for (const key of [...agents.keys()]) {
|
|
1312
|
+
if (!seen.has(key))
|
|
1313
|
+
forget(key);
|
|
1314
|
+
}
|
|
1315
|
+
// herdr odpowiada, wpisy są świeże — niedokończone synchronizacje etykiet tabów wracają.
|
|
1316
|
+
retryPendingTabLabels();
|
|
1317
|
+
const epochAfterApply = agentsEpoch;
|
|
1318
|
+
/*
|
|
1319
|
+
* Sprzątanie sierot na PEŁNYM inwentarzu `pane_id` (`listPaneIds`), nie na liście po
|
|
1320
|
+
* filtrze przydatności (`parsePaneList` odsiewa wiersze bez
|
|
1321
|
+
* `cwd`/`tab_id`, a wiersz zubożony przez minor herdr to wciąż ISTNIEJĄCY panel —
|
|
1322
|
+
* sweep po liście filtrowanej ogłosiłby mu `pane-gone` mimo bramek). Inwentarz pobieramy
|
|
1323
|
+
* TYLKO przy kandydatach (zwykle zero — zero dodatkowych RPC) i tylko na stabilnym
|
|
1324
|
+
* składzie: wpis dodany w trakcie odczytu mógłby nie zdążyć do migawki. Błąd odczytu
|
|
1325
|
+
* = nie sprzątamy wcale (fail-closed w stronę widoczności).
|
|
1326
|
+
*/
|
|
1327
|
+
if (launchClient !== null && epochAfterApply === agentsEpoch && hasBlockedOrphanCandidates()) {
|
|
1328
|
+
try {
|
|
1329
|
+
const alive = await launchClient.listPaneIds();
|
|
1330
|
+
if (epochAfterApply === agentsEpoch)
|
|
1331
|
+
sweepBlockedOrphans(alive);
|
|
1332
|
+
}
|
|
1333
|
+
catch (err) {
|
|
1334
|
+
log(`herdr: orphan cleanup skipped, \`pane.list\` failed: ${err.message}`);
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
// Odczyty trybu jadą RÓWNOLEGLE (sufit równoległości pilnuje socket), bo szeregowo
|
|
1338
|
+
// 17 paneli × timeout to minuty, a nie milisekundy.
|
|
1339
|
+
await Promise.allSettled(modeReads);
|
|
1340
|
+
resubscribeIfNeeded();
|
|
1341
|
+
};
|
|
1342
|
+
const desiredSubscriptions = () => [
|
|
1343
|
+
...GLOBAL_SUBSCRIPTIONS.map((s) => ({ ...s })),
|
|
1344
|
+
...[...agents.values()].map((entry) => ({
|
|
1345
|
+
type: 'pane.agent_status_changed',
|
|
1346
|
+
pane_id: entry.agent.paneId,
|
|
1347
|
+
})),
|
|
1348
|
+
];
|
|
1349
|
+
/**
|
|
1350
|
+
* @param catchUp a stream renewed on purpose (`resubscribeIfNeeded`) runs one resync at its `connected`: events of
|
|
1351
|
+
* the panes it already covered are lost between closing the old stream and the start of the new one. Bounded:
|
|
1352
|
+
* that resync renews the stream again only when the set of panes changed. The first stream does not need it,
|
|
1353
|
+
* because `ready` runs the first resync right after it opens.
|
|
1354
|
+
*/
|
|
1355
|
+
const openSubscription = (catchUp = false) => {
|
|
1356
|
+
if (disposed)
|
|
1357
|
+
return;
|
|
1358
|
+
const subs = desiredSubscriptions();
|
|
1359
|
+
subscribedPanes = subs
|
|
1360
|
+
.map((s) => s.pane_id)
|
|
1361
|
+
.filter((pane) => pane !== undefined)
|
|
1362
|
+
.sort();
|
|
1363
|
+
const opened = transport.subscribe(subs);
|
|
1364
|
+
subscription = opened;
|
|
1365
|
+
void pump(opened, catchUp).catch((err) => {
|
|
1366
|
+
log(`herdr: subscription stream ended with an error: ${err.message}`);
|
|
1367
|
+
});
|
|
1368
|
+
};
|
|
1369
|
+
/**
|
|
1370
|
+
* Ponowna subskrypcja pełną listą — jedyny sposób na zmianę zestawu paneli, bo w API herdr
|
|
1371
|
+
* NIE MA `events.unsubscribe` ani `events.update` (sprawdzone w schemacie).
|
|
1372
|
+
*/
|
|
1373
|
+
const resubscribeIfNeeded = () => {
|
|
1374
|
+
if (disposed)
|
|
1375
|
+
return;
|
|
1376
|
+
const panes = [...agents.values()].map((entry) => entry.agent.paneId).sort();
|
|
1377
|
+
const same = panes.length === subscribedPanes.length
|
|
1378
|
+
&& panes.every((p, i) => p === subscribedPanes[i]);
|
|
1379
|
+
if (same && subscription !== null)
|
|
1380
|
+
return;
|
|
1381
|
+
subscription?.close();
|
|
1382
|
+
subscription = null;
|
|
1383
|
+
openSubscription(true);
|
|
1384
|
+
};
|
|
1385
|
+
const scheduleRefresh = () => {
|
|
1386
|
+
if (disposed || refreshTimer !== null)
|
|
1387
|
+
return;
|
|
1388
|
+
refreshTimer = scheduler.setTimeout(() => {
|
|
1389
|
+
refreshTimer = null;
|
|
1390
|
+
void resync();
|
|
1391
|
+
}, RESUBSCRIBE_DEBOUNCE_MS);
|
|
1392
|
+
};
|
|
1393
|
+
/** Push o zmianie statusu → `agent.get`, bo ramka nie niesie ani sesji, ani `seq`. */
|
|
1394
|
+
const refreshPane = async (paneId) => {
|
|
1395
|
+
const key = byPane.get(paneId);
|
|
1396
|
+
if (key === undefined) {
|
|
1397
|
+
// Nieznany panel: mógł właśnie dostać agenta. Niech rozstrzygnie pełna lista.
|
|
1398
|
+
scheduleRefresh();
|
|
1399
|
+
return;
|
|
1400
|
+
}
|
|
1401
|
+
const entry = agents.get(key);
|
|
1402
|
+
// An answer is applied only to the entry it was asked for: after `closeTab`, `forget` or `dispose` during the
|
|
1403
|
+
// `agent.get` it would take the "new agent" branch and bring the closed pane back as a second card.
|
|
1404
|
+
const stale = () => disposed || byPane.get(paneId) !== key || agents.get(key) !== entry;
|
|
1405
|
+
let info;
|
|
1406
|
+
try {
|
|
1407
|
+
info = await client.getAgent(paneId);
|
|
1408
|
+
}
|
|
1409
|
+
catch (err) {
|
|
1410
|
+
if (stale())
|
|
1411
|
+
return;
|
|
1412
|
+
if (err instanceof HerdrGoneError) {
|
|
1413
|
+
forget(key);
|
|
1414
|
+
return;
|
|
1415
|
+
}
|
|
1416
|
+
if (err instanceof HerdrUnavailableError) {
|
|
1417
|
+
markUnavailable(err.sentence);
|
|
1418
|
+
return;
|
|
1419
|
+
}
|
|
1420
|
+
log(`herdr: status refresh for ${paneId} failed: ${err.message}`);
|
|
1421
|
+
return;
|
|
1422
|
+
}
|
|
1423
|
+
if (stale())
|
|
1424
|
+
return;
|
|
1425
|
+
const outcome = applyInfo(info, { forceModeRead: false });
|
|
1426
|
+
if (outcome.modeRead !== undefined)
|
|
1427
|
+
await outcome.modeRead;
|
|
1428
|
+
};
|
|
1429
|
+
const handleStream = (ev) => {
|
|
1430
|
+
if (ev.type === 'connected') {
|
|
1431
|
+
if (unavailable) {
|
|
1432
|
+
markAvailable();
|
|
1433
|
+
void resync();
|
|
1434
|
+
}
|
|
1435
|
+
return;
|
|
1436
|
+
}
|
|
1437
|
+
if (ev.type === 'disconnected') {
|
|
1438
|
+
markUnavailable(ev.reason);
|
|
1439
|
+
return;
|
|
1440
|
+
}
|
|
1441
|
+
if (ev.kind === STATUS_EVENT) {
|
|
1442
|
+
const paneId = ev.data['pane_id'];
|
|
1443
|
+
if (typeof paneId === 'string')
|
|
1444
|
+
void refreshPane(paneId);
|
|
1445
|
+
return;
|
|
1446
|
+
}
|
|
1447
|
+
if (COMPOSITION_EVENTS.has(ev.kind)) {
|
|
1448
|
+
scheduleRefresh();
|
|
1449
|
+
}
|
|
1450
|
+
};
|
|
1451
|
+
const pump = async (source, catchUp) => {
|
|
1452
|
+
let pending = catchUp;
|
|
1453
|
+
for await (const ev of source.events) {
|
|
1454
|
+
if (disposed)
|
|
1455
|
+
return;
|
|
1456
|
+
// `connected` after unavailability resyncs in `handleStream` already; one resync is enough.
|
|
1457
|
+
const resyncNow = pending && ev.type === 'connected' && !unavailable && subscription === source;
|
|
1458
|
+
if (ev.type === 'connected')
|
|
1459
|
+
pending = false;
|
|
1460
|
+
handleStream(ev);
|
|
1461
|
+
if (resyncNow) {
|
|
1462
|
+
void resync().catch((err) => {
|
|
1463
|
+
log(`herdr: catch-up resync threw an error — ${err.message}`);
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
};
|
|
1468
|
+
/** Wersja programu herdr dla `deps.onVersion` — nigdy nie rzuca; bez odbiorcy nie pyta wcale. */
|
|
1469
|
+
const reportVersion = async () => {
|
|
1470
|
+
const onVersion = deps.onVersion;
|
|
1471
|
+
if (onVersion === undefined || disposed)
|
|
1472
|
+
return;
|
|
1473
|
+
let version;
|
|
1474
|
+
try {
|
|
1475
|
+
({ version } = await client.ping());
|
|
1476
|
+
}
|
|
1477
|
+
catch {
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
if (disposed)
|
|
1481
|
+
return;
|
|
1482
|
+
try {
|
|
1483
|
+
onVersion(version);
|
|
1484
|
+
}
|
|
1485
|
+
catch (err) {
|
|
1486
|
+
log(`herdr: version observer threw an error — ${err.message}`);
|
|
1487
|
+
}
|
|
1488
|
+
};
|
|
1489
|
+
const armResync = () => {
|
|
1490
|
+
if (disposed)
|
|
1491
|
+
return;
|
|
1492
|
+
resyncTimer = scheduler.setTimeout(() => {
|
|
1493
|
+
resyncTimer = null;
|
|
1494
|
+
// `catch` po `finally`: rzut spoza własnych `catch`ów resyncu (np. `subscribe`
|
|
1495
|
+
// z `resubscribeIfNeeded`) przeszedłby przez `finally` do NIEOBSŁUŻONEJ obietnicy,
|
|
1496
|
+
// a ta w Node domyślnie wywraca cały proces. Tick i tak jest już uzbrojony. `ping` wersji
|
|
1497
|
+
// idzie po uzbrojeniu, więc wolna odpowiedź herdr nie opóźnia następnego ticku.
|
|
1498
|
+
void resync().finally(() => {
|
|
1499
|
+
armResync();
|
|
1500
|
+
void reportVersion();
|
|
1501
|
+
}).catch((err) => {
|
|
1502
|
+
log(`herdr: tick resync threw an error — ${err.message}`);
|
|
1503
|
+
});
|
|
1504
|
+
}, HERDR_RESYNC_MS);
|
|
1505
|
+
};
|
|
1506
|
+
openSubscription();
|
|
1507
|
+
// `ready` spełnia się TAKŻE po nieudanym pierwszym resyncu: brak herdr to stan „baner
|
|
1508
|
+
// niedostępności", a nie awaria startu Raroga (fail-closed, ale bez wywracania procesu).
|
|
1509
|
+
// Wersja herdr idzie obok, bez czekania: `ready` nie zależy od `ping`.
|
|
1510
|
+
const ready = resync().then(() => {
|
|
1511
|
+
void reportVersion();
|
|
1512
|
+
armResync();
|
|
1513
|
+
}, (err) => {
|
|
1514
|
+
log(`herdr: first resync failed — ${err.message}`);
|
|
1515
|
+
armResync();
|
|
1516
|
+
});
|
|
1517
|
+
return {
|
|
1518
|
+
events: lifecycle,
|
|
1519
|
+
ready,
|
|
1520
|
+
hidden,
|
|
1521
|
+
audit,
|
|
1522
|
+
async ping() {
|
|
1523
|
+
// Po dispose gniazdo jest zamknięte — pytanie o nie byłoby pytaniem o zwłoki.
|
|
1524
|
+
if (disposed)
|
|
1525
|
+
return false;
|
|
1526
|
+
try {
|
|
1527
|
+
await client.ping();
|
|
1528
|
+
return true;
|
|
1529
|
+
}
|
|
1530
|
+
catch {
|
|
1531
|
+
return false;
|
|
1532
|
+
}
|
|
1533
|
+
},
|
|
1534
|
+
status() {
|
|
1535
|
+
const raw = transport.status();
|
|
1536
|
+
const readOnly = raw.readOnly || !config.sendEnabled;
|
|
1537
|
+
/*
|
|
1538
|
+
* `canLaunch` gaśnie z CZTERECH niezależnych powodów i każdy z nich jest osobną
|
|
1539
|
+
* władzą: brak opt-inu (`RAROG_HERDR_LAUNCH=0` → brak launchera), tryb tylko do
|
|
1540
|
+
* odczytu (nieznany protokół albo `RAROG_HERDR_SEND=0` — bo `agent.start` jest
|
|
1541
|
+
* w `MUTATING_METHODS`), niedostępny herdr i osiągnięty sufit paneli Raroga.
|
|
1542
|
+
*
|
|
1543
|
+
* Rozbite na dwie liczby, bo sufit jako JEDYNY ma dla człowieka wyjście („zamknij
|
|
1544
|
+
* którąś sesję") i tylko wtedy wolno je pokazać — patrz `launchDetail`.
|
|
1545
|
+
*/
|
|
1546
|
+
const paneCapReached = rarogPanes() >= maxPanes;
|
|
1547
|
+
const otherwiseCanLaunch = launcher !== undefined
|
|
1548
|
+
&& raw.available
|
|
1549
|
+
&& !readOnly
|
|
1550
|
+
&& !disposed;
|
|
1551
|
+
const out = {
|
|
1552
|
+
available: raw.available && !disposed,
|
|
1553
|
+
agentCount: agents.size,
|
|
1554
|
+
readOnly,
|
|
1555
|
+
canLaunch: otherwiseCanLaunch && !paneCapReached,
|
|
1556
|
+
};
|
|
1557
|
+
if (raw.version !== undefined)
|
|
1558
|
+
out.version = raw.version;
|
|
1559
|
+
if (raw.protocol !== undefined)
|
|
1560
|
+
out.protocol = raw.protocol;
|
|
1561
|
+
const detail = launchDetail({
|
|
1562
|
+
transportDetail: raw.detail,
|
|
1563
|
+
paneCapReached,
|
|
1564
|
+
otherwiseCanLaunch,
|
|
1565
|
+
});
|
|
1566
|
+
// Tu zdanie schodzi na drut (`HerdrStatus.detail`): tekst, a zdanie z `say()` także kod obok (`detailRef`).
|
|
1567
|
+
if (detail !== undefined)
|
|
1568
|
+
out.detail = textOf(detail);
|
|
1569
|
+
if (detail !== undefined && isServerSentence(detail))
|
|
1570
|
+
out.detailRef = detail.ref;
|
|
1571
|
+
return out;
|
|
1572
|
+
},
|
|
1573
|
+
launchAvailable() {
|
|
1574
|
+
// `canLaunch` BEZ sufitu paneli — restart zastępuje panel, więc sufit liczy sam,
|
|
1575
|
+
// a wyłączony launcher schowany za pełnym sufitem odmawiałby dopiero po `/exit`.
|
|
1576
|
+
const raw = transport.status();
|
|
1577
|
+
return launcher !== undefined && raw.available && !raw.readOnly && config.sendEnabled
|
|
1578
|
+
&& !disposed;
|
|
1579
|
+
},
|
|
1580
|
+
async launch(req) {
|
|
1581
|
+
if (launcher === undefined)
|
|
1582
|
+
throw new HerdrLaunchTimeoutError(LAUNCH_NOT_WIRED);
|
|
1583
|
+
const handle = await launcher.launch(req);
|
|
1584
|
+
/*
|
|
1585
|
+
* Klucz nadaje WYŁĄCZNIE supervisor — to on jest właścicielem tożsamości agentów
|
|
1586
|
+
* i tylko on wie, czy pod tym adresem panelu żył już kiedyś inny agent (`freshKey`).
|
|
1587
|
+
*
|
|
1588
|
+
* Prawdziwy launcher robi to przez `registerLaunch` PRZED `agent.start`,
|
|
1589
|
+
* więc wpis już tu jest i klucz jest jego. Atrapa w testach oddaje klucz z powietrza —
|
|
1590
|
+
* wtedy rejestrujemy tutaj. Jedno i drugie kończy się wpisem w `agents`, nigdy dwoma.
|
|
1591
|
+
*/
|
|
1592
|
+
const key = agents.has(handle.key)
|
|
1593
|
+
? handle.key
|
|
1594
|
+
: registerLaunched({ ...handle, cwd: req.cwd, label: req.label ?? '' }, req.label ?? '');
|
|
1595
|
+
const limit = req.model === undefined ? undefined : KNOWN_CONTEXT_LIMITS[req.model];
|
|
1596
|
+
const launched = agents.get(key);
|
|
1597
|
+
if (launched !== undefined && limit !== undefined)
|
|
1598
|
+
launched.knownContextLimit = limit;
|
|
1599
|
+
const ready = handle.ready.then((result) => {
|
|
1600
|
+
/*
|
|
1601
|
+
* Wpis `launch` jest jedyną odpowiedzią na pytanie „co Rarog uruchomił na tym Macu"
|
|
1602
|
+
* (`docs/security-model.md`, „Starting sessions from the phone: three powers”).
|
|
1603
|
+
* Zapisujemy go PO gotowości, bo dopiero wtedy znamy `argv` z odpowiedzi
|
|
1604
|
+
* herdr — czyli dokładną linię, którą wpisano do powłoki panelu. Promptu tam nie ma.
|
|
1605
|
+
*/
|
|
1606
|
+
audit.log({
|
|
1607
|
+
sessionId: sessionIdFor(key),
|
|
1608
|
+
key,
|
|
1609
|
+
paneId: result.paneId,
|
|
1610
|
+
cwd: req.cwd,
|
|
1611
|
+
method: 'launch',
|
|
1612
|
+
mode: 'unknown',
|
|
1613
|
+
tabId: result.tabId,
|
|
1614
|
+
argv: result.argv,
|
|
1615
|
+
});
|
|
1616
|
+
const entry = agents.get(key);
|
|
1617
|
+
if (entry !== undefined) {
|
|
1618
|
+
// `agent.start` mógł dostać INNY uuid, niż Rarog podał w `--session-id` (launcher
|
|
1619
|
+
// to sprawdza i wtedy rzuca) — tu tylko domykamy indeks tym, co naprawdę wyszło.
|
|
1620
|
+
if (entry.agent.agentSessionId !== result.agentSessionId) {
|
|
1621
|
+
bySession.delete(entry.agent.agentSessionId);
|
|
1622
|
+
entry.agent.agentSessionId = result.agentSessionId;
|
|
1623
|
+
bySession.set(result.agentSessionId, key);
|
|
1624
|
+
}
|
|
1625
|
+
entry.agent.interactiveReady = result.interactiveReady;
|
|
1626
|
+
/*
|
|
1627
|
+
* Status ZAOBSERWOWANY przez launcher — jedyna droga, którą `blocked` dialogu
|
|
1628
|
+
* zaufania w ogóle dociera do drivera.
|
|
1629
|
+
*
|
|
1630
|
+
* Panel stojący na tym dialogu nie ma `agent_session`, więc `normalizeAgentInfo`
|
|
1631
|
+
* odrzuca go i ani resync, ani push nie powiedzą o nim nic — wpis z `registerLaunched`
|
|
1632
|
+
* zostawał na `unknown` bez końca, a driver nie miał z czego zrobić karty. Emitujemy
|
|
1633
|
+
* przez `emitPane` z tym samym kształtem co zwykła zmiana statusu, żeby driver miał
|
|
1634
|
+
* JEDNĄ ścieżkę wejścia w blokadę, niezależnie od tego, kto ją zauważył.
|
|
1635
|
+
*
|
|
1636
|
+
* `unknown` świadomie pomijamy (reguła 11.3: nie zgadujemy stanu sesji).
|
|
1637
|
+
*/
|
|
1638
|
+
if (result.status !== 'unknown' && entry.agent.status !== result.status) {
|
|
1639
|
+
entry.agent.status = result.status;
|
|
1640
|
+
emitPane(entry, {
|
|
1641
|
+
type: 'status',
|
|
1642
|
+
status: entry.agent.status,
|
|
1643
|
+
stateChangeSeq: entry.agent.stateChangeSeq,
|
|
1644
|
+
title: entry.agent.title,
|
|
1645
|
+
});
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
return { ...result, key };
|
|
1649
|
+
});
|
|
1650
|
+
// Odrzucenie `ready` obsługuje manager (przestawia sesję w `error`); tutaj tylko
|
|
1651
|
+
// pilnujemy, żeby nieobsłużona obietnica nie wywróciła procesu, gdy manager już zniknął.
|
|
1652
|
+
ready.catch(() => undefined);
|
|
1653
|
+
/*
|
|
1654
|
+
* Siatka pod `paneLabelled`: start rozstrzygnięty w KAŻDĄ stronę (także porażką przed
|
|
1655
|
+
* krokiem etykiety — nieudany `agent.start`) zwalnia czekającą synchronizację etykiety taba.
|
|
1656
|
+
* Bez tego klucz, któremu launcher nie doszedł do `pane.rename`, czekałby do `forget`.
|
|
1657
|
+
*/
|
|
1658
|
+
const release = () => { releaseProvenance(key); };
|
|
1659
|
+
handle.ready.then(release, release);
|
|
1660
|
+
return {
|
|
1661
|
+
key,
|
|
1662
|
+
paneId: handle.paneId,
|
|
1663
|
+
tabId: handle.tabId,
|
|
1664
|
+
agentSessionId: handle.agentSessionId,
|
|
1665
|
+
// Ostrzeżenie o dialogu zaufania jedzie NIETKNIĘTE do managera: to launcher
|
|
1666
|
+
// czytał `~/.claude.json`, a supervisor nie ma tej wiedzy skąd odtworzyć.
|
|
1667
|
+
...(handle.trustPrompt === true ? { trustPrompt: true } : {}),
|
|
1668
|
+
ready,
|
|
1669
|
+
};
|
|
1670
|
+
},
|
|
1671
|
+
async closeTab(key) {
|
|
1672
|
+
const entry = agents.get(key);
|
|
1673
|
+
if (entry === undefined)
|
|
1674
|
+
throw agentGone(key);
|
|
1675
|
+
/*
|
|
1676
|
+
* "×" closes EVERY pane, including one Rarog did not create: Rarog and herdr are one
|
|
1677
|
+
* person's tools, so there is no multi-user caution to honour. Two technical conditions
|
|
1678
|
+
* remain: a known tab address and an attached write channel.
|
|
1679
|
+
*/
|
|
1680
|
+
/*
|
|
1681
|
+
* Wpis Codexa daje STAN i nic poza stanem — także wtedy, gdy klucz przyszedł
|
|
1682
|
+
* z karty, która w managerze wygląda na kartę Claude. Po zmianie silnika w panelu
|
|
1683
|
+
* następca dostaje TEN SAM `key` (`freshKey(paneId)`), więc historyczna karta Claude
|
|
1684
|
+
* przenosiłaby swoją władzę na cudzy panel. Manager ma własną
|
|
1685
|
+
* bramkę na ten scenariusz; ta jest drugą warstwą i stoi na prawdzie nadzorcy — bo to
|
|
1686
|
+
* on, a nie karta, wie, jaki silnik naprawdę siedzi w panelu.
|
|
1687
|
+
*/
|
|
1688
|
+
if (entry.agent.engine === 'codex')
|
|
1689
|
+
throw new HerdrNotOwnedError(CODEX_CLOSE_MESSAGE);
|
|
1690
|
+
if (entry.agent.tabId === '') {
|
|
1691
|
+
throw new HerdrNotOwnedError(say('herdr.tab-unknown'));
|
|
1692
|
+
}
|
|
1693
|
+
if (launchClient === null)
|
|
1694
|
+
throw new HerdrNotOwnedError(LAUNCH_NOT_WIRED);
|
|
1695
|
+
await launchClient.closeTab(entry.agent.tabId);
|
|
1696
|
+
audit.log({
|
|
1697
|
+
sessionId: sessionIdFor(key),
|
|
1698
|
+
key,
|
|
1699
|
+
paneId: entry.agent.paneId,
|
|
1700
|
+
cwd: entry.agent.cwd,
|
|
1701
|
+
method: 'close_tab',
|
|
1702
|
+
mode: entry.agent.mode,
|
|
1703
|
+
tabId: entry.agent.tabId,
|
|
1704
|
+
});
|
|
1705
|
+
// Nie czekamy na `pane.closed` z subskrypcji: karta ma zniknąć w tej samej chwili,
|
|
1706
|
+
// w której użytkownik potwierdził zamknięcie. Spóźnione zdarzenie trafi w pustkę.
|
|
1707
|
+
forget(key, 'closed');
|
|
1708
|
+
},
|
|
1709
|
+
async closeShellTab(tabId, cwd) {
|
|
1710
|
+
/*
|
|
1711
|
+
* Stary tab po restarcie sesji: `claude` wyszedł `/exit`em, w panelu została goła
|
|
1712
|
+
* powłoka, a rozmowa stoi już w NOWYM tabie. Zamykamy go wyłącznie wtedy, gdy świeży
|
|
1713
|
+
* `pane.list` pokazuje w tym tabie DOKŁADNIE jeden panel, `tab.get` potwierdza, że innego
|
|
1714
|
+
* tam nie ma, i nie siedzi w nim żaden agent — split z panelem użytkownika albo `claude`
|
|
1715
|
+
* odpalony ręcznie w tej powłoce zostają.
|
|
1716
|
+
* Każda niepewność (brak klienta, błąd odczytu) = tab zostaje; to jest sprzątanie, nie
|
|
1717
|
+
* bramka bezpieczeństwa, więc pomyłka w stronę „zostaw" kosztuje jeden tab.
|
|
1718
|
+
*/
|
|
1719
|
+
if (launchClient === null || tabId === '')
|
|
1720
|
+
return false;
|
|
1721
|
+
const inTab = (await launchClient.listPanes()).filter((pane) => pane.tabId === tabId);
|
|
1722
|
+
const pane = inTab[0];
|
|
1723
|
+
if (inTab.length !== 1 || pane === undefined || byPane.has(pane.paneId))
|
|
1724
|
+
return false;
|
|
1725
|
+
/*
|
|
1726
|
+
* Liczba paneli z `tab.get`, nie z samego `pane.list`: `listPanes` odsiewa panel, którego
|
|
1727
|
+
* herdr nie odtworzył (`restore_error`), a ten wciąż stoi w tabie — `tab.close` zamknąłby
|
|
1728
|
+
* go razem z powłoką, czyli split z cudzym panelem.
|
|
1729
|
+
*/
|
|
1730
|
+
try {
|
|
1731
|
+
if ((await launchClient.getTab(tabId)).paneCount !== 1)
|
|
1732
|
+
return false;
|
|
1733
|
+
}
|
|
1734
|
+
catch {
|
|
1735
|
+
return false;
|
|
1736
|
+
}
|
|
1737
|
+
try {
|
|
1738
|
+
await client.getAgent(pane.paneId);
|
|
1739
|
+
return false;
|
|
1740
|
+
}
|
|
1741
|
+
catch (error) {
|
|
1742
|
+
if (!(error instanceof HerdrGoneError))
|
|
1743
|
+
return false;
|
|
1744
|
+
}
|
|
1745
|
+
/*
|
|
1746
|
+
* Brak agenta to jeszcze nie „goła powłoka": po `claude; nvim plik` na pierwszym planie
|
|
1747
|
+
* stoi edytor. Zamykamy wyłącznie wtedy, gdy JEDYNYM procesem
|
|
1748
|
+
* pierwszego planu jest sama powłoka — zmierzone: goła powłoka daje dokładnie
|
|
1749
|
+
* `[zsh]`, program na pierwszym planie daje swoją nazwę. Nazwa procesu nie trafia nigdzie
|
|
1750
|
+
* poza to porównanie (ta sama reguła co przy etykiecie taba terminala).
|
|
1751
|
+
*/
|
|
1752
|
+
let foreground;
|
|
1753
|
+
try {
|
|
1754
|
+
foreground = (await launchClient.readPaneProcess(pane.paneId)).processes;
|
|
1755
|
+
}
|
|
1756
|
+
catch {
|
|
1757
|
+
return false;
|
|
1758
|
+
}
|
|
1759
|
+
if (!isBareShellForeground(foreground))
|
|
1760
|
+
return false;
|
|
1761
|
+
await launchClient.closeTab(tabId);
|
|
1762
|
+
audit.log({
|
|
1763
|
+
key: pane.paneId, paneId: pane.paneId, cwd, method: 'close_tab', mode: 'unknown', tabId,
|
|
1764
|
+
});
|
|
1765
|
+
return true;
|
|
1766
|
+
},
|
|
1767
|
+
logRestart(key, reason, versions) {
|
|
1768
|
+
const entry = agents.get(key);
|
|
1769
|
+
if (entry === undefined)
|
|
1770
|
+
return;
|
|
1771
|
+
audit.log({
|
|
1772
|
+
sessionId: sessionIdFor(key),
|
|
1773
|
+
key,
|
|
1774
|
+
paneId: entry.agent.paneId,
|
|
1775
|
+
cwd: entry.agent.cwd,
|
|
1776
|
+
method: 'restart',
|
|
1777
|
+
mode: entry.agent.mode,
|
|
1778
|
+
tabId: entry.agent.tabId,
|
|
1779
|
+
reason,
|
|
1780
|
+
...(versions === undefined ? {} : { text: versions }),
|
|
1781
|
+
});
|
|
1782
|
+
},
|
|
1783
|
+
logCommandRefusal(key, cwd, command) {
|
|
1784
|
+
const entry = key === null ? undefined : agents.get(key);
|
|
1785
|
+
audit.log({
|
|
1786
|
+
...(key === null ? {} : { sessionId: sessionIdFor(key) }),
|
|
1787
|
+
key: key ?? '',
|
|
1788
|
+
paneId: entry?.agent.paneId ?? '',
|
|
1789
|
+
cwd: entry?.agent.cwd ?? cwd,
|
|
1790
|
+
method: 'refuse',
|
|
1791
|
+
reason: 'command-not-allowed',
|
|
1792
|
+
mode: entry?.agent.mode ?? 'unknown',
|
|
1793
|
+
command,
|
|
1794
|
+
});
|
|
1795
|
+
},
|
|
1796
|
+
rarogPaneCount: () => rarogPanes(),
|
|
1797
|
+
syncTabLabel(key, label) {
|
|
1798
|
+
/*
|
|
1799
|
+
* Wejście JEDYNE i nieblokujące: manager woła z `#setLabel` przy każdym powstaniu
|
|
1800
|
+
* i zmianie etykiety karty. Praca idzie po {@link TAB_LABEL_DEBOUNCE_MS} od OSTATNIEJ
|
|
1801
|
+
* zmiany; reguły prawa do `tab.rename` są w `syncTabLabelOnce`.
|
|
1802
|
+
*/
|
|
1803
|
+
if (!tabLabelsEnabled || disposed)
|
|
1804
|
+
return;
|
|
1805
|
+
let state = tabLabels.get(key);
|
|
1806
|
+
if (state === undefined) {
|
|
1807
|
+
state = {
|
|
1808
|
+
label, timer: null, running: false, again: false, written: null, settled: null,
|
|
1809
|
+
pending: false, failures: 0, retryAt: 0,
|
|
1810
|
+
};
|
|
1811
|
+
tabLabels.set(key, state);
|
|
1812
|
+
}
|
|
1813
|
+
state.label = label;
|
|
1814
|
+
armTabLabel(key, state);
|
|
1815
|
+
},
|
|
1816
|
+
agentFor: (key) => agents.get(key)?.agent,
|
|
1817
|
+
observedEngineSessions() {
|
|
1818
|
+
const out = [];
|
|
1819
|
+
for (const entry of agents.values()) {
|
|
1820
|
+
const agent = entry.agent;
|
|
1821
|
+
// Wyłącznie Claude w zakresie: hook czeka tylko w sesji, której karty Rarog pokazuje.
|
|
1822
|
+
if (agent.engine === 'claude' && agent.inScope && agent.agentSessionId !== '')
|
|
1823
|
+
out.push(agent.agentSessionId);
|
|
1824
|
+
}
|
|
1825
|
+
return out;
|
|
1826
|
+
},
|
|
1827
|
+
async liveEngineSessions() {
|
|
1828
|
+
/*
|
|
1829
|
+
* ŚWIEŻY odczyt, nie migawka w RAM. Indeks pisarzy w managerze gubi panele
|
|
1830
|
+
* UKRYTE — a ukryty panel dalej żyje i dalej pisze do swojego pliku jsonl. Sprawdzenie
|
|
1831
|
+
* po RAM przepuściłoby więc wznowienie sesji, którą właśnie ktoś pisze.
|
|
1832
|
+
*/
|
|
1833
|
+
/*
|
|
1834
|
+
* WYŁĄCZNIE `claude`. Ta bramka odpowiada na pytanie „czy tę sesję ktoś TERAZ
|
|
1835
|
+
* pisze", a pisarzem jest plik `~/.claude/projects/<slug>/<uuid>.jsonl`. Uuid Codexa
|
|
1836
|
+
* adresuje rollout w `~/.codex/sessions`, więc wpuszczony tutaj blokowałby wznowienie
|
|
1837
|
+
* sesji Claude, która przypadkiem ma ten sam identyfikator — i nie chroniłby niczego.
|
|
1838
|
+
*/
|
|
1839
|
+
const infos = await client.listAgents();
|
|
1840
|
+
return new Set(infos
|
|
1841
|
+
.filter((info) => info.engine === 'claude')
|
|
1842
|
+
.map((info) => info.agentSessionId));
|
|
1843
|
+
},
|
|
1844
|
+
async ensureFreshMode(key) {
|
|
1845
|
+
const entry = agents.get(key);
|
|
1846
|
+
if (entry === undefined)
|
|
1847
|
+
throw agentGone(key);
|
|
1848
|
+
if (modeIsFresh(entry))
|
|
1849
|
+
return entry.agent.mode;
|
|
1850
|
+
// Odczyt NA ŻĄDANIE, płacony tylko wtedy, gdy naprawdę o coś pytamy (0,2 ms).
|
|
1851
|
+
await readMode(entry, (screen) => {
|
|
1852
|
+
deps.dumpRefusal?.({
|
|
1853
|
+
reason: 'mode-unknown', sessionId: sessionIdFor(key), screen, hook: null, jsonl: null,
|
|
1854
|
+
});
|
|
1855
|
+
});
|
|
1856
|
+
return modeIsFresh(entry) ? entry.agent.mode : 'unknown';
|
|
1857
|
+
},
|
|
1858
|
+
attach(key) {
|
|
1859
|
+
const entry = agents.get(key);
|
|
1860
|
+
if (entry === undefined) {
|
|
1861
|
+
throw agentGone(key);
|
|
1862
|
+
}
|
|
1863
|
+
entry.attached = true;
|
|
1864
|
+
entry.needsReattach = false;
|
|
1865
|
+
// Manager zaopiekował się panelem — rejestracja „w trakcie zakładania" nie jest już
|
|
1866
|
+
// do niczego potrzebna i nie ma prawa wygasnąć w `appeared`.
|
|
1867
|
+
entry.launching = false;
|
|
1868
|
+
const handle = {
|
|
1869
|
+
agent: entry.agent,
|
|
1870
|
+
subscribe(listener) {
|
|
1871
|
+
entry.listeners.add(listener);
|
|
1872
|
+
return () => {
|
|
1873
|
+
entry.listeners.delete(listener);
|
|
1874
|
+
};
|
|
1875
|
+
},
|
|
1876
|
+
};
|
|
1877
|
+
return deps.createDriver({
|
|
1878
|
+
handle,
|
|
1879
|
+
client: answerClient,
|
|
1880
|
+
audit,
|
|
1881
|
+
sessionId: sessionIdFor(key),
|
|
1882
|
+
markSent: () => {
|
|
1883
|
+
entry.sentAt = now();
|
|
1884
|
+
},
|
|
1885
|
+
/*
|
|
1886
|
+
* WYMUSZONY odczyt stopki dla pętli zmiany trybu: `ensureFreshMode` oddałby
|
|
1887
|
+
* tryb sprzed `shift+tab` przez całe `HERDR_MODE_FRESH_MS`. Odczyt idzie przez
|
|
1888
|
+
* `readMode`, więc nowy tryb trafia tam, gdzie zawsze (wpis nadzorcy + zdarzenie
|
|
1889
|
+
* `mode` → driver → chip). Wynik TEGO odczytu, dokładny: `acceptEdits` osobno od
|
|
1890
|
+
* `auto`, `unknown`, gdy stopki nie widać.
|
|
1891
|
+
*/
|
|
1892
|
+
refreshMode: () => readMode(entry),
|
|
1893
|
+
markTrustDialog: () => {
|
|
1894
|
+
entry.trustSeenAt = now();
|
|
1895
|
+
},
|
|
1896
|
+
yoloRoots: config.yoloRoots,
|
|
1897
|
+
sendEnabled: config.sendEnabled,
|
|
1898
|
+
...(entry.knownContextLimit === undefined
|
|
1899
|
+
? {}
|
|
1900
|
+
: { knownContextLimit: entry.knownContextLimit }),
|
|
1901
|
+
});
|
|
1902
|
+
},
|
|
1903
|
+
markSent(key) {
|
|
1904
|
+
const entry = agents.get(key);
|
|
1905
|
+
if (entry !== undefined)
|
|
1906
|
+
entry.sentAt = now();
|
|
1907
|
+
},
|
|
1908
|
+
takeSendSlot: (key, opts) => throttle.takeSendSlot(key, opts),
|
|
1909
|
+
async focus(key) {
|
|
1910
|
+
const entry = agents.get(key);
|
|
1911
|
+
if (entry === undefined) {
|
|
1912
|
+
throw agentGone(key);
|
|
1913
|
+
}
|
|
1914
|
+
await client.focus(entry.agent.paneId);
|
|
1915
|
+
},
|
|
1916
|
+
dispose() {
|
|
1917
|
+
if (disposed)
|
|
1918
|
+
return;
|
|
1919
|
+
disposed = true;
|
|
1920
|
+
if (resyncTimer !== null)
|
|
1921
|
+
scheduler.clearTimeout(resyncTimer);
|
|
1922
|
+
if (refreshTimer !== null)
|
|
1923
|
+
scheduler.clearTimeout(refreshTimer);
|
|
1924
|
+
answerRecheck.dispose();
|
|
1925
|
+
for (const key of [...tabLabels.keys()])
|
|
1926
|
+
dropTabLabel(key);
|
|
1927
|
+
subscription?.close();
|
|
1928
|
+
subscription = null;
|
|
1929
|
+
lifecycle.close();
|
|
1930
|
+
// Panel należy do użytkownika: sprzątanie supervisora NIE wysyła do herdr niczego.
|
|
1931
|
+
socket?.dispose();
|
|
1932
|
+
},
|
|
1933
|
+
};
|
|
1934
|
+
}
|