@quantiya/codevibe-claude-plugin 1.0.13 → 1.0.15
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/.claude-plugin/plugin.json +1 -1
- package/node_modules/@quantiya/codevibe-core/README.md +179 -0
- package/node_modules/@quantiya/codevibe-core/bin/codevibe.js +7 -0
- package/node_modules/@quantiya/codevibe-core/dist/appsync/appsync-client.d.ts +132 -0
- package/node_modules/@quantiya/codevibe-core/dist/appsync/index.d.ts +2 -0
- package/node_modules/@quantiya/codevibe-core/dist/appsync/queries.d.ts +16 -0
- package/node_modules/@quantiya/codevibe-core/dist/auth/auth-cli.d.ts +5 -0
- package/node_modules/@quantiya/codevibe-core/dist/auth/auth-service.d.ts +87 -0
- package/node_modules/@quantiya/codevibe-core/dist/auth/fetch-helpers.d.ts +11 -0
- package/node_modules/@quantiya/codevibe-core/dist/auth/index.d.ts +2 -0
- package/node_modules/@quantiya/codevibe-core/dist/config/config.d.ts +53 -0
- package/node_modules/@quantiya/codevibe-core/dist/config/index.d.ts +2 -0
- package/node_modules/@quantiya/codevibe-core/dist/crypto/crypto-service.d.ts +118 -0
- package/node_modules/@quantiya/codevibe-core/dist/crypto/index.d.ts +1 -0
- package/node_modules/@quantiya/codevibe-core/dist/index.d.ts +14 -0
- package/node_modules/@quantiya/codevibe-core/dist/index.js +220 -0
- package/node_modules/@quantiya/codevibe-core/dist/keychain/index.d.ts +1 -0
- package/node_modules/@quantiya/codevibe-core/dist/keychain/keychain-backend.d.ts +3 -0
- package/node_modules/@quantiya/codevibe-core/dist/keychain/keychain-manager.d.ts +139 -0
- package/node_modules/@quantiya/codevibe-core/dist/logger/index.d.ts +1 -0
- package/node_modules/@quantiya/codevibe-core/dist/logger/logger.d.ts +35 -0
- package/node_modules/@quantiya/codevibe-core/dist/prompt-parser.d.ts +39 -0
- package/node_modules/@quantiya/codevibe-core/dist/session/index.d.ts +2 -0
- package/node_modules/@quantiya/codevibe-core/dist/session/session-resume.d.ts +55 -0
- package/node_modules/@quantiya/codevibe-core/dist/types/auth.d.ts +15 -0
- package/node_modules/@quantiya/codevibe-core/dist/types/encryption.d.ts +54 -0
- package/node_modules/@quantiya/codevibe-core/dist/types/events.d.ts +74 -0
- package/node_modules/@quantiya/codevibe-core/dist/types/index.d.ts +4 -0
- package/node_modules/@quantiya/codevibe-core/dist/types/session.d.ts +59 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/CHANGELOG.md +274 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/CONTRIBUTING.md +18 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/LICENSE.md +9 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/README.md +466 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/bin/uuid +2 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/commonjs-browser/index.js +79 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/commonjs-browser/md5.js +223 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/commonjs-browser/native.js +11 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/commonjs-browser/nil.js +8 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/commonjs-browser/parse.js +45 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/commonjs-browser/regex.js +8 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/commonjs-browser/rng.js +25 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/commonjs-browser/sha1.js +104 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/commonjs-browser/stringify.js +44 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/commonjs-browser/v1.js +107 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/commonjs-browser/v3.js +16 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/commonjs-browser/v35.js +80 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/commonjs-browser/v4.js +43 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/commonjs-browser/v5.js +16 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/commonjs-browser/validate.js +17 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/commonjs-browser/version.js +21 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-browser/index.js +9 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-browser/md5.js +215 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-browser/native.js +4 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-browser/nil.js +1 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-browser/parse.js +35 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-browser/regex.js +1 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-browser/rng.js +18 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-browser/sha1.js +96 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-browser/stringify.js +33 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-browser/v1.js +95 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-browser/v3.js +4 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-browser/v35.js +66 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-browser/v4.js +29 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-browser/v5.js +4 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-browser/validate.js +7 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-browser/version.js +11 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-node/index.js +9 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-node/md5.js +13 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-node/native.js +4 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-node/nil.js +1 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-node/parse.js +35 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-node/regex.js +1 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-node/rng.js +12 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-node/sha1.js +13 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-node/stringify.js +33 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-node/v1.js +95 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-node/v3.js +4 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-node/v35.js +66 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-node/v4.js +29 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-node/v5.js +4 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-node/validate.js +7 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/esm-node/version.js +11 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/index.js +79 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/md5-browser.js +223 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/md5.js +23 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/native-browser.js +11 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/native.js +15 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/nil.js +8 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/parse.js +45 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/regex.js +8 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/rng-browser.js +25 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/rng.js +24 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/sha1-browser.js +104 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/sha1.js +23 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/stringify.js +44 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/uuid-bin.js +85 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/v1.js +107 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/v3.js +16 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/v35.js +80 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/v4.js +43 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/v5.js +16 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/validate.js +17 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/dist/version.js +21 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/package.json +135 -0
- package/node_modules/@quantiya/codevibe-core/node_modules/uuid/wrapper.mjs +10 -0
- package/node_modules/@quantiya/codevibe-core/package.json +56 -0
- package/node_modules/base64-js/LICENSE +21 -0
- package/node_modules/base64-js/README.md +34 -0
- package/node_modules/base64-js/base64js.min.js +1 -0
- package/node_modules/base64-js/index.d.ts +3 -0
- package/node_modules/base64-js/index.js +150 -0
- package/node_modules/base64-js/package.json +47 -0
- package/node_modules/bl/.travis.yml +17 -0
- package/node_modules/bl/BufferList.js +396 -0
- package/node_modules/bl/LICENSE.md +13 -0
- package/node_modules/bl/README.md +247 -0
- package/node_modules/bl/bl.js +84 -0
- package/node_modules/bl/package.json +37 -0
- package/node_modules/bl/test/convert.js +21 -0
- package/node_modules/bl/test/indexOf.js +492 -0
- package/node_modules/bl/test/isBufferList.js +32 -0
- package/node_modules/bl/test/test.js +869 -0
- package/node_modules/buffer/AUTHORS.md +70 -0
- package/node_modules/buffer/LICENSE +21 -0
- package/node_modules/buffer/README.md +410 -0
- package/node_modules/buffer/index.d.ts +186 -0
- package/node_modules/buffer/index.js +1817 -0
- package/node_modules/buffer/package.json +96 -0
- package/node_modules/chownr/LICENSE +15 -0
- package/node_modules/chownr/README.md +3 -0
- package/node_modules/chownr/chownr.js +167 -0
- package/node_modules/chownr/package.json +29 -0
- package/node_modules/decompress-response/index.d.ts +22 -0
- package/node_modules/decompress-response/index.js +58 -0
- package/node_modules/decompress-response/license +9 -0
- package/node_modules/decompress-response/package.json +56 -0
- package/node_modules/decompress-response/readme.md +48 -0
- package/node_modules/deep-extend/CHANGELOG.md +46 -0
- package/node_modules/deep-extend/LICENSE +20 -0
- package/node_modules/deep-extend/README.md +91 -0
- package/node_modules/deep-extend/index.js +1 -0
- package/node_modules/deep-extend/lib/deep-extend.js +150 -0
- package/node_modules/deep-extend/package.json +62 -0
- package/node_modules/detect-libc/LICENSE +201 -0
- package/node_modules/detect-libc/README.md +163 -0
- package/node_modules/detect-libc/index.d.ts +14 -0
- package/node_modules/detect-libc/lib/detect-libc.js +313 -0
- package/node_modules/detect-libc/lib/elf.js +39 -0
- package/node_modules/detect-libc/lib/filesystem.js +51 -0
- package/node_modules/detect-libc/lib/process.js +24 -0
- package/node_modules/detect-libc/package.json +44 -0
- package/node_modules/end-of-stream/LICENSE +21 -0
- package/node_modules/end-of-stream/README.md +54 -0
- package/node_modules/end-of-stream/index.js +96 -0
- package/node_modules/end-of-stream/package.json +37 -0
- package/node_modules/expand-template/.travis.yml +6 -0
- package/node_modules/expand-template/LICENSE +21 -0
- package/node_modules/expand-template/README.md +43 -0
- package/node_modules/expand-template/index.js +26 -0
- package/node_modules/expand-template/package.json +29 -0
- package/node_modules/expand-template/test.js +67 -0
- package/node_modules/fs-constants/LICENSE +21 -0
- package/node_modules/fs-constants/README.md +26 -0
- package/node_modules/fs-constants/browser.js +1 -0
- package/node_modules/fs-constants/index.js +1 -0
- package/node_modules/fs-constants/package.json +19 -0
- package/node_modules/github-from-package/.travis.yml +4 -0
- package/node_modules/github-from-package/LICENSE +18 -0
- package/node_modules/github-from-package/example/package.json +8 -0
- package/node_modules/github-from-package/example/url.js +3 -0
- package/node_modules/github-from-package/index.js +17 -0
- package/node_modules/github-from-package/package.json +30 -0
- package/node_modules/github-from-package/readme.markdown +53 -0
- package/node_modules/github-from-package/test/a.json +8 -0
- package/node_modules/github-from-package/test/b.json +5 -0
- package/node_modules/github-from-package/test/c.json +5 -0
- package/node_modules/github-from-package/test/d.json +7 -0
- package/node_modules/github-from-package/test/e.json +5 -0
- package/node_modules/github-from-package/test/url.js +19 -0
- package/node_modules/ieee754/LICENSE +11 -0
- package/node_modules/ieee754/README.md +51 -0
- package/node_modules/ieee754/index.d.ts +10 -0
- package/node_modules/ieee754/index.js +85 -0
- package/node_modules/ieee754/package.json +52 -0
- package/node_modules/ini/LICENSE +15 -0
- package/node_modules/ini/README.md +102 -0
- package/node_modules/ini/ini.js +206 -0
- package/node_modules/ini/package.json +33 -0
- package/node_modules/keytar/LICENSE.md +20 -0
- package/node_modules/keytar/README.md +94 -0
- package/node_modules/keytar/binding.gyp +66 -0
- package/node_modules/keytar/build/Release/keytar.node +0 -0
- package/node_modules/keytar/keytar.d.ts +51 -0
- package/node_modules/keytar/lib/keytar.js +43 -0
- package/node_modules/keytar/package.json +66 -0
- package/node_modules/keytar/src/async.cc +242 -0
- package/node_modules/keytar/src/async.h +103 -0
- package/node_modules/keytar/src/credentials.h +13 -0
- package/node_modules/keytar/src/keytar.h +41 -0
- package/node_modules/keytar/src/keytar_mac.cc +296 -0
- package/node_modules/keytar/src/keytar_posix.cc +184 -0
- package/node_modules/keytar/src/keytar_win.cc +272 -0
- package/node_modules/keytar/src/main.cc +139 -0
- package/node_modules/mimic-response/index.d.ts +17 -0
- package/node_modules/mimic-response/index.js +77 -0
- package/node_modules/mimic-response/license +9 -0
- package/node_modules/mimic-response/package.json +42 -0
- package/node_modules/mimic-response/readme.md +78 -0
- package/node_modules/minimist/.eslintrc +29 -0
- package/node_modules/minimist/.github/FUNDING.yml +12 -0
- package/node_modules/minimist/.nycrc +14 -0
- package/node_modules/minimist/CHANGELOG.md +298 -0
- package/node_modules/minimist/LICENSE +18 -0
- package/node_modules/minimist/README.md +121 -0
- package/node_modules/minimist/example/parse.js +4 -0
- package/node_modules/minimist/index.js +263 -0
- package/node_modules/minimist/package.json +75 -0
- package/node_modules/minimist/test/all_bool.js +34 -0
- package/node_modules/minimist/test/bool.js +177 -0
- package/node_modules/minimist/test/dash.js +43 -0
- package/node_modules/minimist/test/default_bool.js +37 -0
- package/node_modules/minimist/test/dotted.js +24 -0
- package/node_modules/minimist/test/kv_short.js +32 -0
- package/node_modules/minimist/test/long.js +33 -0
- package/node_modules/minimist/test/num.js +38 -0
- package/node_modules/minimist/test/parse.js +209 -0
- package/node_modules/minimist/test/parse_modified.js +11 -0
- package/node_modules/minimist/test/proto.js +64 -0
- package/node_modules/minimist/test/short.js +69 -0
- package/node_modules/minimist/test/stop_early.js +17 -0
- package/node_modules/minimist/test/unknown.js +104 -0
- package/node_modules/minimist/test/whitespace.js +10 -0
- package/node_modules/mkdirp-classic/LICENSE +21 -0
- package/node_modules/mkdirp-classic/README.md +18 -0
- package/node_modules/mkdirp-classic/index.js +98 -0
- package/node_modules/mkdirp-classic/package.json +18 -0
- package/node_modules/napi-build-utils/.github/workflows/run-npm-tests.yml +31 -0
- package/node_modules/napi-build-utils/LICENSE +21 -0
- package/node_modules/napi-build-utils/README.md +52 -0
- package/node_modules/napi-build-utils/index.js +214 -0
- package/node_modules/napi-build-utils/index.md +0 -0
- package/node_modules/napi-build-utils/package.json +42 -0
- package/node_modules/node-abi/LICENSE +21 -0
- package/node_modules/node-abi/README.md +54 -0
- package/node_modules/node-abi/abi_registry.json +439 -0
- package/node_modules/node-abi/index.js +179 -0
- package/node_modules/node-abi/package.json +45 -0
- package/node_modules/node-addon-api/LICENSE.md +13 -0
- package/node_modules/node-addon-api/README.md +293 -0
- package/node_modules/node-addon-api/common.gypi +21 -0
- package/node_modules/node-addon-api/except.gypi +25 -0
- package/node_modules/node-addon-api/index.js +11 -0
- package/node_modules/node-addon-api/napi-inl.deprecated.h +192 -0
- package/node_modules/node-addon-api/napi-inl.h +6209 -0
- package/node_modules/node-addon-api/napi.h +2983 -0
- package/node_modules/node-addon-api/node_api.gyp +9 -0
- package/node_modules/node-addon-api/noexcept.gypi +26 -0
- package/node_modules/node-addon-api/nothing.c +0 -0
- package/node_modules/node-addon-api/package-support.json +21 -0
- package/node_modules/node-addon-api/package.json +399 -0
- package/node_modules/node-addon-api/tools/README.md +73 -0
- package/node_modules/node-addon-api/tools/check-napi.js +100 -0
- package/node_modules/node-addon-api/tools/clang-format.js +68 -0
- package/node_modules/node-addon-api/tools/conversion.js +309 -0
- package/node_modules/node-addon-api/tools/eslint-format.js +71 -0
- package/node_modules/prebuild-install/CHANGELOG.md +131 -0
- package/node_modules/prebuild-install/CONTRIBUTING.md +6 -0
- package/node_modules/prebuild-install/LICENSE +21 -0
- package/node_modules/prebuild-install/README.md +163 -0
- package/node_modules/prebuild-install/asset.js +44 -0
- package/node_modules/prebuild-install/bin.js +78 -0
- package/node_modules/prebuild-install/download.js +142 -0
- package/node_modules/prebuild-install/error.js +14 -0
- package/node_modules/prebuild-install/help.txt +16 -0
- package/node_modules/prebuild-install/index.js +1 -0
- package/node_modules/prebuild-install/log.js +33 -0
- package/node_modules/prebuild-install/package.json +67 -0
- package/node_modules/prebuild-install/proxy.js +35 -0
- package/node_modules/prebuild-install/rc.js +64 -0
- package/node_modules/prebuild-install/util.js +143 -0
- package/node_modules/pump/.github/FUNDING.yml +2 -0
- package/node_modules/pump/.travis.yml +5 -0
- package/node_modules/pump/LICENSE +21 -0
- package/node_modules/pump/README.md +74 -0
- package/node_modules/pump/SECURITY.md +5 -0
- package/node_modules/pump/empty.js +1 -0
- package/node_modules/pump/index.js +86 -0
- package/node_modules/pump/package.json +30 -0
- package/node_modules/pump/test-browser.js +66 -0
- package/node_modules/pump/test-node.js +53 -0
- package/node_modules/rc/LICENSE.APACHE2 +15 -0
- package/node_modules/rc/LICENSE.BSD +26 -0
- package/node_modules/rc/LICENSE.MIT +24 -0
- package/node_modules/rc/README.md +227 -0
- package/node_modules/rc/browser.js +7 -0
- package/node_modules/rc/cli.js +4 -0
- package/node_modules/rc/index.js +53 -0
- package/node_modules/rc/lib/utils.js +104 -0
- package/node_modules/rc/package.json +29 -0
- package/node_modules/rc/test/ini.js +16 -0
- package/node_modules/rc/test/nested-env-vars.js +50 -0
- package/node_modules/rc/test/test.js +59 -0
- package/node_modules/readable-stream/CONTRIBUTING.md +38 -0
- package/node_modules/readable-stream/GOVERNANCE.md +136 -0
- package/node_modules/readable-stream/LICENSE +47 -0
- package/node_modules/readable-stream/README.md +106 -0
- package/node_modules/readable-stream/errors-browser.js +127 -0
- package/node_modules/readable-stream/errors.js +116 -0
- package/node_modules/readable-stream/experimentalWarning.js +17 -0
- package/node_modules/readable-stream/lib/_stream_duplex.js +126 -0
- package/node_modules/readable-stream/lib/_stream_passthrough.js +37 -0
- package/node_modules/readable-stream/lib/_stream_readable.js +1027 -0
- package/node_modules/readable-stream/lib/_stream_transform.js +190 -0
- package/node_modules/readable-stream/lib/_stream_writable.js +641 -0
- package/node_modules/readable-stream/lib/internal/streams/async_iterator.js +180 -0
- package/node_modules/readable-stream/lib/internal/streams/buffer_list.js +183 -0
- package/node_modules/readable-stream/lib/internal/streams/destroy.js +96 -0
- package/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +86 -0
- package/node_modules/readable-stream/lib/internal/streams/from-browser.js +3 -0
- package/node_modules/readable-stream/lib/internal/streams/from.js +52 -0
- package/node_modules/readable-stream/lib/internal/streams/pipeline.js +86 -0
- package/node_modules/readable-stream/lib/internal/streams/state.js +22 -0
- package/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
- package/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
- package/node_modules/readable-stream/package.json +68 -0
- package/node_modules/readable-stream/readable-browser.js +9 -0
- package/node_modules/readable-stream/readable.js +16 -0
- package/node_modules/safe-buffer/LICENSE +21 -0
- package/node_modules/safe-buffer/README.md +584 -0
- package/node_modules/safe-buffer/index.d.ts +187 -0
- package/node_modules/safe-buffer/index.js +65 -0
- package/node_modules/safe-buffer/package.json +51 -0
- package/node_modules/semver/LICENSE +15 -0
- package/node_modules/semver/README.md +665 -0
- package/node_modules/semver/bin/semver.js +191 -0
- package/node_modules/semver/classes/comparator.js +143 -0
- package/node_modules/semver/classes/index.js +7 -0
- package/node_modules/semver/classes/range.js +557 -0
- package/node_modules/semver/classes/semver.js +333 -0
- package/node_modules/semver/functions/clean.js +8 -0
- package/node_modules/semver/functions/cmp.js +54 -0
- package/node_modules/semver/functions/coerce.js +62 -0
- package/node_modules/semver/functions/compare-build.js +9 -0
- package/node_modules/semver/functions/compare-loose.js +5 -0
- package/node_modules/semver/functions/compare.js +7 -0
- package/node_modules/semver/functions/diff.js +60 -0
- package/node_modules/semver/functions/eq.js +5 -0
- package/node_modules/semver/functions/gt.js +5 -0
- package/node_modules/semver/functions/gte.js +5 -0
- package/node_modules/semver/functions/inc.js +21 -0
- package/node_modules/semver/functions/lt.js +5 -0
- package/node_modules/semver/functions/lte.js +5 -0
- package/node_modules/semver/functions/major.js +5 -0
- package/node_modules/semver/functions/minor.js +5 -0
- package/node_modules/semver/functions/neq.js +5 -0
- package/node_modules/semver/functions/parse.js +18 -0
- package/node_modules/semver/functions/patch.js +5 -0
- package/node_modules/semver/functions/prerelease.js +8 -0
- package/node_modules/semver/functions/rcompare.js +5 -0
- package/node_modules/semver/functions/rsort.js +5 -0
- package/node_modules/semver/functions/satisfies.js +12 -0
- package/node_modules/semver/functions/sort.js +5 -0
- package/node_modules/semver/functions/valid.js +8 -0
- package/node_modules/semver/index.js +91 -0
- package/node_modules/semver/internal/constants.js +37 -0
- package/node_modules/semver/internal/debug.js +11 -0
- package/node_modules/semver/internal/identifiers.js +29 -0
- package/node_modules/semver/internal/lrucache.js +42 -0
- package/node_modules/semver/internal/parse-options.js +17 -0
- package/node_modules/semver/internal/re.js +223 -0
- package/node_modules/semver/package.json +78 -0
- package/node_modules/semver/preload.js +4 -0
- package/node_modules/semver/range.bnf +16 -0
- package/node_modules/semver/ranges/gtr.js +6 -0
- package/node_modules/semver/ranges/intersects.js +9 -0
- package/node_modules/semver/ranges/ltr.js +6 -0
- package/node_modules/semver/ranges/max-satisfying.js +27 -0
- package/node_modules/semver/ranges/min-satisfying.js +26 -0
- package/node_modules/semver/ranges/min-version.js +63 -0
- package/node_modules/semver/ranges/outside.js +82 -0
- package/node_modules/semver/ranges/simplify.js +49 -0
- package/node_modules/semver/ranges/subset.js +249 -0
- package/node_modules/semver/ranges/to-comparators.js +10 -0
- package/node_modules/semver/ranges/valid.js +13 -0
- package/node_modules/simple-concat/.travis.yml +3 -0
- package/node_modules/simple-concat/LICENSE +20 -0
- package/node_modules/simple-concat/README.md +44 -0
- package/node_modules/simple-concat/index.js +15 -0
- package/node_modules/simple-concat/package.json +47 -0
- package/node_modules/simple-concat/test/basic.js +41 -0
- package/node_modules/simple-get/.github/dependabot.yml +15 -0
- package/node_modules/simple-get/.github/workflows/ci.yml +23 -0
- package/node_modules/simple-get/LICENSE +20 -0
- package/node_modules/simple-get/README.md +333 -0
- package/node_modules/simple-get/index.js +108 -0
- package/node_modules/simple-get/package.json +67 -0
- package/node_modules/string_decoder/LICENSE +48 -0
- package/node_modules/string_decoder/README.md +47 -0
- package/node_modules/string_decoder/lib/string_decoder.js +296 -0
- package/node_modules/string_decoder/package.json +34 -0
- package/node_modules/strip-json-comments/index.js +70 -0
- package/node_modules/strip-json-comments/license +21 -0
- package/node_modules/strip-json-comments/package.json +42 -0
- package/node_modules/strip-json-comments/readme.md +64 -0
- package/node_modules/tar-fs/.travis.yml +6 -0
- package/node_modules/tar-fs/LICENSE +21 -0
- package/node_modules/tar-fs/README.md +165 -0
- package/node_modules/tar-fs/index.js +363 -0
- package/node_modules/tar-fs/package.json +41 -0
- package/node_modules/tar-fs/test/fixtures/a/hello.txt +1 -0
- package/node_modules/tar-fs/test/fixtures/b/a/test.txt +1 -0
- package/node_modules/tar-fs/test/fixtures/d/file1 +0 -0
- package/node_modules/tar-fs/test/fixtures/d/file2 +0 -0
- package/node_modules/tar-fs/test/fixtures/d/sub-dir/file5 +0 -0
- package/node_modules/tar-fs/test/fixtures/d/sub-files/file3 +0 -0
- package/node_modules/tar-fs/test/fixtures/d/sub-files/file4 +0 -0
- package/node_modules/tar-fs/test/fixtures/e/directory/.ignore +0 -0
- package/node_modules/tar-fs/test/fixtures/e/file +0 -0
- package/node_modules/tar-fs/test/fixtures/invalid.tar +0 -0
- package/node_modules/tar-fs/test/index.js +346 -0
- package/node_modules/tar-stream/LICENSE +21 -0
- package/node_modules/tar-stream/README.md +168 -0
- package/node_modules/tar-stream/extract.js +257 -0
- package/node_modules/tar-stream/headers.js +295 -0
- package/node_modules/tar-stream/index.js +2 -0
- package/node_modules/tar-stream/pack.js +255 -0
- package/node_modules/tar-stream/package.json +58 -0
- package/node_modules/tar-stream/sandbox.js +11 -0
- package/node_modules/tunnel-agent/LICENSE +55 -0
- package/node_modules/tunnel-agent/README.md +4 -0
- package/node_modules/tunnel-agent/index.js +244 -0
- package/node_modules/tunnel-agent/package.json +22 -0
- package/node_modules/util-deprecate/History.md +16 -0
- package/node_modules/util-deprecate/LICENSE +24 -0
- package/node_modules/util-deprecate/README.md +53 -0
- package/node_modules/util-deprecate/browser.js +67 -0
- package/node_modules/util-deprecate/node.js +6 -0
- package/node_modules/util-deprecate/package.json +27 -0
- package/package.json +3 -13
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";var Ze=Object.create;var Y=Object.defineProperty;var et=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames;var nt=Object.getPrototypeOf,rt=Object.prototype.hasOwnProperty;var E=(r,e)=>()=>(r&&(e=r(r=0)),e);var Te=(r,e)=>{for(var t in e)Y(r,t,{get:e[t],enumerable:!0})},xe=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of tt(e))!rt.call(r,s)&&s!==t&&Y(r,s,{get:()=>e[s],enumerable:!(n=et(e,s))||n.enumerable});return r};var y=(r,e,t)=>(t=r!=null?Ze(nt(r)):{},xe(e||!r||!r.__esModule?Y(t,"default",{value:r,enumerable:!0}):t,r)),st=r=>xe(Y({},"__esModule",{value:!0}),r);function it(r,e){if(e instanceof Error){let t={name:e.name,message:e.message};e.stack&&(t.stack=e.stack);for(let n of Object.keys(e))n in t||(t[n]=e[n]);return t}return e}function se(r){return new P(r)}var R,G,Ce,Ae,P,c,Pe=E(()=>{"use strict";R=y(require("fs")),G=y(require("path")),Ce=y(require("os")),Ae={debug:0,info:1,warn:2,error:3};P=class{constructor(e){this.name=e.name,this.logFile=e.logFile,this.level=e.level||"info",this.enableConsole=e.console??!1,this.logFile&&this.ensureLogDir()}ensureLogDir(){if(this.logFile){let e=G.dirname(this.logFile);R.existsSync(e)||R.mkdirSync(e,{recursive:!0})}}shouldLog(e){return Ae[e]>=Ae[this.level]}formatMessage(e,t,n){let s=new Date().toISOString(),i=e.toUpperCase().padEnd(5),o=`[${s}] [${i}] [${this.name}] ${t}`;return n!==void 0&&(n instanceof Error?(o+=` ${n.name}: ${n.message}`,n.stack&&(o+=`
|
|
2
|
+
${n.stack}`)):typeof n=="object"?o+=` ${JSON.stringify(n,it)}`:o+=` ${n}`),o}log(e,t,n){if(!this.shouldLog(e))return;let s=this.formatMessage(e,t,n);if(this.logFile)try{R.appendFileSync(this.logFile,s+`
|
|
3
|
+
`)}catch{}if(this.enableConsole)switch(e){case"error":console.error(s);break;case"warn":console.warn(s);break;default:console.log(s)}}debug(e,t){this.log("debug",e,t)}info(e,t){this.log("info",e,t)}warn(e,t){this.log("warn",e,t)}error(e,t){this.log("error",e,t)}setLevel(e){this.level=e}};c=new P({name:"codevibe-core",logFile:G.join(Ce.tmpdir(),"codevibe-core.log"),level:"info"})});var L=E(()=>{"use strict";Pe()});function ot(r){for(let e of r)try{process.stderr.write(e+`
|
|
4
|
+
`)}catch{}}function at(){if(D!==null||oe!==null)return;let keytarLoadError=null;try{let nodeRequire=eval("require");I=nodeRequire("keytar")}catch(r){keytarLoadError=r instanceof Error?r.message:String(r),I=null}if(I){D="keytar",c.info("[keychain-backend] Using keytar (OS-native keyring)");return}let optedIn=process.env.CODEVIBE_ALLOW_FILE_KEYCHAIN==="1";if(!optedIn){oe=new X(["CodeVibe could not load the OS-native keyring (keytar).",`Reason: ${keytarLoadError??"unknown"}`,"","Options to fix this:"," 1. (Linux) Install libsecret and a keyring daemon:"," sudo apt install libsecret-1-0 gnome-keyring"," Then unlock the keyring for your user session.",""," 2. (Headless / CI / Docker) Opt in to file-based credential"," storage at ~/.codevibe/ (0600 files). This is equivalent"," in trust to ~/.ssh/id_rsa \u2014 not the OS keyring:"," export CODEVIBE_ALLOW_FILE_KEYCHAIN=1"].join(`
|
|
5
|
+
`));return}ot(["","\u26A0 CodeVibe: OS keyring unavailable. Using file-based credential storage.","\u26A0 Location: ~/.codevibe/ (directory 0700, files 0600)","\u26A0 Trust level: equivalent to ~/.ssh/id_rsa \u2014 weaker than OS keyring.",`\u26A0 Keytar load error: ${keytarLoadError??"unknown"}`,"\u26A0 To use the OS keyring instead, unset CODEVIBE_ALLOW_FILE_KEYCHAIN and","\u26A0 install libsecret-1-0 + a running keyring daemon.",""]),c.warn(`[keychain-backend] Using file-based fallback at ~/.codevibe (CODEVIBE_ALLOW_FILE_KEYCHAIN=1). Keytar load error: ${keytarLoadError??"unknown"}`),ie=ae.join(De.homedir(),".codevibe");try{A.mkdirSync(ie,{recursive:!0,mode:448})}catch{}D="file"}function ct(r){return r.replace(/[^a-zA-Z0-9._-]/g,"_")}function Ke(r){return ae.join(ie,`${ct(r)}.json`)}function ce(r){try{let e=A.readFileSync(Ke(r),"utf-8"),t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function Oe(r,e){let t=Ke(r);A.writeFileSync(t,JSON.stringify(e,null,2),{mode:384});try{A.chmodSync(t,384)}catch{}}function de(){if(at(),D===null)throw oe??new X("Keychain backend not initialized")}async function le(r,e){return de(),D==="keytar"&&I?I.getPassword(r,e):ce(r)[e]??null}async function pe(r,e,t){if(de(),D==="keytar"&&I){await I.setPassword(r,e,t);return}let n=ce(r);n[e]=t,Oe(r,n)}async function ue(r,e){if(de(),D==="keytar"&&I)return I.deletePassword(r,e);let t=ce(r);return e in t?(delete t[e],Oe(r,t),!0):!1}var De,ae,A,X,D,I,ie,oe,$e=E(()=>{"use strict";De=y(require("os")),ae=y(require("path")),A=y(require("fs"));L();X=class extends Error{constructor(e){super(e),this.name="KeychainBackendUnavailableError"}},D=null,I=null,ie="",oe=null});var v,K,ge,lt,U,b,Ne=E(()=>{"use strict";v=y(require("crypto")),K=class extends Error{constructor(e){super(e),this.name="CryptoError"}},ge=1,lt="CodeVibe E2E v1",U=class r{constructor(){}static getInstance(){return r.instance||(r.instance=new r),r.instance}generateKeyPair(){let e=v.createECDH("prime256v1");e.generateKeys();let n=e.getPublicKey().subarray(1).toString("base64");return{privateKey:e.getPrivateKey().toString("base64"),publicKey:n}}generateSessionKey(){return v.randomBytes(32).toString("base64")}deriveSharedKey(e,t){try{let n=v.createECDH("prime256v1"),s=Buffer.from(e,"base64");n.setPrivateKey(s);let i=Buffer.concat([Buffer.from([4]),Buffer.from(t,"base64")]),o=n.computeSecret(i),a=v.hkdfSync("sha256",o,Buffer.alloc(0),Buffer.from(lt,"utf8"),32);return Buffer.from(a)}catch(n){throw new K(`Failed to derive shared key: ${n}`)}}encryptSessionKey(e,t){let n=this.generateKeyPair(),s=this.deriveSharedKey(n.privateKey,t),i=Buffer.from(e,"base64");return{encryptedKey:this.encrypt(i,s).toString("base64"),ephemeralPublicKey:n.publicKey}}decryptSessionKey(e,t){let n=this.deriveSharedKey(t,e.ephemeralPublicKey),s=Buffer.from(e.encryptedKey,"base64");return this.decrypt(s,n).toString("base64")}encryptContent(e,t){let n=Buffer.from(t,"base64"),s=Buffer.from(e,"utf8");return this.encrypt(s,n).toString("base64")}decryptContent(e,t){let n=Buffer.from(t,"base64"),s=Buffer.from(e,"base64");return this.decrypt(s,n).toString("utf8")}encryptMetadata(e,t){let n=JSON.stringify(e);return this.encryptContent(n,t)}decryptMetadata(e,t){let n=this.decryptContent(e,t);return JSON.parse(n)}encryptData(e,t){let n=Buffer.from(t,"base64");return this.encrypt(e,n)}decryptData(e,t){let n=Buffer.from(t,"base64");return this.decrypt(e,n)}encrypt(e,t){let n=v.randomBytes(12),s=v.createCipheriv("aes-256-gcm",t,n),i=Buffer.concat([s.update(e),s.final()]),o=s.getAuthTag();return Buffer.concat([n,i,o])}decrypt(e,t){let n=e.subarray(0,12),s=e.subarray(e.length-16),i=e.subarray(12,e.length-16),o=v.createDecipheriv("aes-256-gcm",t,n);o.setAuthTag(s);try{return Buffer.concat([o.update(i),o.final()])}catch{throw new K("Decryption failed: Invalid ciphertext or authentication tag")}}serializePrivateKey(e){return e}deserializePrivateKey(e){return e}},b=U.getInstance()});var Q=E(()=>{"use strict";Ne()});function h(){let r=process.env.ENVIRONMENT;return r==="development"||r==="production"?r:"production"}function ee(r){let e=r||h();return Z={...O[e],aws:{...O[e].aws,region:process.env.AWS_REGION||O[e].aws.region,appsyncUrl:process.env.APPSYNC_URL||O[e].aws.appsyncUrl,cognitoUserPoolId:process.env.COGNITO_USER_POOL_ID||O[e].aws.cognitoUserPoolId,cognitoClientId:process.env.COGNITO_CLIENT_ID||O[e].aws.cognitoClientId,cognitoDomain:process.env.COGNITO_DOMAIN||O[e].aws.cognitoDomain}},Re=!0,Z}function f(){return(!Re||!Z)&&ee(),Z}var V,W,O,Z,Re,Le=E(()=>{"use strict";V=y(require("os")),W=y(require("path")),O={development:{environment:"development",aws:{region:"us-east-1",appsyncUrl:"https://te6rjr37sbfpjc4fiunmb2tgy4.appsync-api.us-east-1.amazonaws.com/graphql",cognitoUserPoolId:"us-east-1_yVwWDPvvJ",cognitoClientId:"e9r5apv6v5uui3l928r2ris0r",cognitoDomain:"codevibe-development.auth.us-east-1.amazoncognito.com"},keychain:{serviceName:"ai.quantiya.app.codevibe"},server:{port:3456,host:"127.0.0.1",dynamicPort:!0},claude:{command:"claude",defaultTimeout:6e4},codex:{command:"codex",defaultTimeout:6e4,sessionsDir:W.default.join(V.default.homedir(),".codex","sessions"),approvalTimeoutMs:5e3},gemini:{command:"gemini",defaultTimeout:6e4,transcriptDir:W.default.join(V.default.homedir(),".gemini","tmp")}},production:{environment:"production",aws:{region:"us-east-1",appsyncUrl:"https://jwhyxq4sgrgcdosewp5k4ns5ca.appsync-api.us-east-1.amazonaws.com/graphql",cognitoUserPoolId:"us-east-1_mNRO0j5og",cognitoClientId:"5p04dbc9ojptc5r8n7605fg78f",cognitoDomain:"codevibe-production.auth.us-east-1.amazoncognito.com"},keychain:{serviceName:"ai.quantiya.app.codevibe"},server:{port:3456,host:"127.0.0.1",dynamicPort:!0},claude:{command:"claude",defaultTimeout:6e4},codex:{command:"codex",defaultTimeout:6e4,sessionsDir:W.default.join(V.default.homedir(),".codex","sessions"),approvalTimeoutMs:5e3},gemini:{command:"gemini",defaultTimeout:6e4,transcriptDir:W.default.join(V.default.homedir(),".gemini","tmp")}}},Z=null,Re=!1});var _=E(()=>{"use strict";Le()});var te,Ue,T,me,pt,$,g,_e=E(()=>{"use strict";te=y(require("os")),Ue=require("uuid");$e();Q();_();L();T=class extends Error{constructor(e){super(e),this.name="KeychainError"}},me="device-identity",pt="tokens-",$=class r{constructor(){this.deviceIdentity=null;this.sessionKeyCache=new Map;this.isRegistered=!1;this._serviceName=null}get serviceName(){return this._serviceName||(this._serviceName=f().keychain.serviceName),this._serviceName}static getInstance(){return r.instance||(r.instance=new r),r.instance}async getDeviceIdentity(){if(this.deviceIdentity)return this.deviceIdentity;let e=await le(this.serviceName,me);return e?(this.deviceIdentity=JSON.parse(e),c.info(`[KeychainManager] Loaded device identity: ${this.deviceIdentity.deviceId}`),this.deviceIdentity):null}async setDeviceIdentity(e){try{await pe(this.serviceName,me,JSON.stringify(e)),this.deviceIdentity=e,c.info(`[KeychainManager] Saved device identity: ${e.deviceId}`)}catch(t){throw c.error(`[KeychainManager] Failed to save device identity: ${t}`),new T(`Failed to save device identity: ${t}`)}}async getOrCreateDeviceIdentity(){let e=await this.getDeviceIdentity();if(e)return e;let t=b.generateKeyPair();return e={deviceId:(0,Ue.v4)().toUpperCase(),privateKey:t.privateKey,publicKey:t.publicKey,createdAt:new Date().toISOString()},await this.setDeviceIdentity(e),c.info(`[KeychainManager] Generated new device identity: ${e.deviceId}`),e}async getDeviceId(){return(await this.getOrCreateDeviceIdentity()).deviceId}async getDevicePublicKey(){return(await this.getOrCreateDeviceIdentity()).publicKey}async getDevicePrivateKey(){return(await this.getOrCreateDeviceIdentity()).privateKey}async hasDeviceIdentity(){return await this.getDeviceIdentity()!==null}async deleteDeviceIdentity(){try{await ue(this.serviceName,me),this.deviceIdentity=null,this.sessionKeyCache.clear(),this.isRegistered=!1,c.info("[KeychainManager] Deleted device identity")}catch(e){throw c.error(`[KeychainManager] Failed to delete device identity: ${e}`),new T(`Failed to delete device identity: ${e}`)}}getTokenAccount(e){return`${pt}${e}`}async getTokens(e="production"){let t=await le(this.serviceName,this.getTokenAccount(e));if(!t)return null;let n=JSON.parse(t);return c.debug(`[KeychainManager] Loaded tokens for ${e}`),n}async setTokens(e,t="production"){try{await pe(this.serviceName,this.getTokenAccount(t),JSON.stringify(e)),c.info(`[KeychainManager] Saved tokens for ${t}`,{userId:e.userId,email:e.email})}catch(n){throw c.error(`[KeychainManager] Failed to save tokens: ${n}`),new T(`Failed to save tokens: ${n}`)}}async deleteTokens(e="production"){try{let t=await ue(this.serviceName,this.getTokenAccount(e));return t&&c.info(`[KeychainManager] Deleted tokens for ${e}`),t}catch(t){return c.error(`[KeychainManager] Failed to delete tokens: ${t}`),!1}}isTokenExpired(e){return Date.now()>=e.expiresAt-3e5}async getSessionKey(e,t){let n=this.sessionKeyCache.get(e);if(n)return n;if(!t||t.length===0)return null;let s=await this.getDeviceId(),i=t.find(l=>l.deviceId===s);if(!i)return c.warn(`[KeychainManager] Device ${s} not found in encryptedKeys`),null;let o=await this.getDevicePrivateKey(),a=b.decryptSessionKey(i,o);return this.sessionKeyCache.set(e,a),c.info(`[KeychainManager] Decrypted and cached session key for ${e}`),a}createSessionKey(e){let t=b.generateSessionKey(),n=e.map(s=>{let i=b.encryptSessionKey(t,s.publicKey);return{deviceId:s.deviceId,encryptedKey:i.encryptedKey,ephemeralPublicKey:i.ephemeralPublicKey}});return c.info(`[KeychainManager] Created session key for ${e.length} devices`),{sessionKey:t,encryptedKeys:n}}cacheSessionKey(e,t){this.sessionKeyCache.set(e,t)}clearSessionKey(e){this.sessionKeyCache.delete(e)}clearAllSessionKeys(){this.sessionKeyCache.clear()}getIsRegistered(){return this.isRegistered}setIsRegistered(e){this.isRegistered=e}getDeviceName(){return te.hostname()||"CLI Client"}getDevicePlatform(){let e=te.platform();return e==="darwin"?"MACOS":e==="linux"?"LINUX":e==="win32"?"WINDOWS":"CLI"}async clearAllData(){await this.deleteDeviceIdentity(),await this.deleteTokens("development"),await this.deleteTokens("production"),this.sessionKeyCache.clear(),this.isRegistered=!1,c.info("[KeychainManager] Cleared all data")}},g=$.getInstance()});var Me={};Te(Me,{KeychainError:()=>T,KeychainManager:()=>$,keychainManager:()=>g});var M=E(()=>{"use strict";_e()});var At={};Te(At,{AgentType:()=>Ve,AppSyncClient:()=>J,AuthService:()=>q,CryptoError:()=>K,CryptoService:()=>U,DeliveryStatus:()=>He,ENCRYPTION_VERSION:()=>ge,EventSource:()=>ye,EventType:()=>qe,KeychainError:()=>T,KeychainManager:()=>$,Logger:()=>P,SessionStatus:()=>fe,authService:()=>x,createLogger:()=>se,cryptoService:()=>b,getConfig:()=>f,getEnvironment:()=>h,keychainManager:()=>g,loadConfig:()=>ee,logger:()=>c,mutations:()=>k,normalizeSnapshot:()=>Ee,parseInteractivePrompt:()=>Ye,prepareSessionEncryption:()=>re,queries:()=>N,resumeOrCreateSession:()=>Ie,runAuthCli:()=>ne,subscriptions:()=>j});module.exports=st(At);M();Q();var he=y(require("ws")),ve=require("uuid");_();L();M();var Be=y(require("dns")),Fe=y(require("fs"));if(ut())try{Be.setDefaultResultOrder("ipv4first")}catch{}function ut(){if(process.platform!=="linux")return!1;try{let r=Fe.readFileSync("/proc/sys/kernel/osrelease","utf8");return/microsoft|wsl/i.test(r)}catch{return!1}}async function B(r,e,t){try{return await fetch(r,e)}catch(n){let s=n?.cause?.code,i=n?.cause?.message,o=s||i||n?.message||"unknown",a=gt(s),l=t?`${t}: `:"",p=`Node ${process.version} on ${process.platform}`,m=[`${l}Cannot reach ${r}`,` Underlying error: ${o}`];a&&m.push(` Suggested fix: ${a}`),m.push(` Platform: ${p}`);let u=new Error(m.join(`
|
|
6
|
+
`));throw u.cause=n,u}}function gt(r){if(!r)return null;switch(r){case"ENOTFOUND":case"EAI_AGAIN":return'DNS resolution failed. On WSL Ubuntu, check /etc/resolv.conf, or try running with NODE_OPTIONS="--dns-result-order=ipv4first".';case"ETIMEDOUT":case"ECONNREFUSED":case"ECONNRESET":case"EHOSTUNREACH":case"ENETUNREACH":return`Network unreachable. On WSL Ubuntu, try NODE_OPTIONS="--dns-result-order=ipv4first" (WSL's IPv6 is often broken). If behind a corporate proxy, set HTTPS_PROXY.`;case"CERT_HAS_EXPIRED":case"CERT_NOT_YET_VALID":return"TLS certificate time error \u2014 likely system clock drift. On WSL, run `sudo hwclock -s`, or shut down WSL from PowerShell with `wsl --shutdown` and restart.";case"UNABLE_TO_GET_ISSUER_CERT_LOCALLY":case"SELF_SIGNED_CERT_IN_CHAIN":case"UNABLE_TO_VERIFY_LEAF_SIGNATURE":case"DEPTH_ZERO_SELF_SIGNED_CERT":return"Corporate HTTPS proxy detected \u2014 the TLS cert is not trusted by Node. Set NODE_EXTRA_CA_CERTS=/path/to/corporate-ca.pem, or configure HTTPS_PROXY if a proxy is required.";default:return null}}var N={getSession:`
|
|
7
|
+
query GetSession($sessionId: ID!) {
|
|
8
|
+
getSession(sessionId: $sessionId) {
|
|
9
|
+
sessionId
|
|
10
|
+
userId
|
|
11
|
+
agentType
|
|
12
|
+
projectPath
|
|
13
|
+
status
|
|
14
|
+
createdAt
|
|
15
|
+
updatedAt
|
|
16
|
+
metadata
|
|
17
|
+
isEncrypted
|
|
18
|
+
encryptedKeys {
|
|
19
|
+
deviceId
|
|
20
|
+
encryptedKey
|
|
21
|
+
ephemeralPublicKey
|
|
22
|
+
}
|
|
23
|
+
creatorDeviceId
|
|
24
|
+
encryptionVersion
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`,listEvents:`
|
|
28
|
+
query ListEvents($sessionId: ID!, $source: EventSource, $limit: Int) {
|
|
29
|
+
listEvents(sessionId: $sessionId, source: $source, limit: $limit) {
|
|
30
|
+
items {
|
|
31
|
+
eventId
|
|
32
|
+
sessionId
|
|
33
|
+
type
|
|
34
|
+
source
|
|
35
|
+
content
|
|
36
|
+
timestamp
|
|
37
|
+
metadata
|
|
38
|
+
promptId
|
|
39
|
+
attachments {
|
|
40
|
+
id
|
|
41
|
+
type
|
|
42
|
+
filename
|
|
43
|
+
s3Key
|
|
44
|
+
size
|
|
45
|
+
width
|
|
46
|
+
height
|
|
47
|
+
isEncrypted
|
|
48
|
+
}
|
|
49
|
+
deliveryStatus
|
|
50
|
+
deliveredAt
|
|
51
|
+
executedAt
|
|
52
|
+
isEncrypted
|
|
53
|
+
}
|
|
54
|
+
nextToken
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
`,listUserDeviceKeys:`
|
|
58
|
+
query ListUserDeviceKeys {
|
|
59
|
+
listUserDeviceKeys {
|
|
60
|
+
userId
|
|
61
|
+
deviceId
|
|
62
|
+
publicKey
|
|
63
|
+
platform
|
|
64
|
+
deviceName
|
|
65
|
+
createdAt
|
|
66
|
+
lastUsedAt
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`},k={createSession:`
|
|
70
|
+
mutation CreateSession($input: CreateSessionInput!) {
|
|
71
|
+
createSession(input: $input) {
|
|
72
|
+
sessionId
|
|
73
|
+
userId
|
|
74
|
+
agentType
|
|
75
|
+
projectPath
|
|
76
|
+
status
|
|
77
|
+
createdAt
|
|
78
|
+
updatedAt
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
`,updateSession:`
|
|
82
|
+
mutation UpdateSession($input: UpdateSessionInput!) {
|
|
83
|
+
updateSession(input: $input) {
|
|
84
|
+
sessionId
|
|
85
|
+
status
|
|
86
|
+
updatedAt
|
|
87
|
+
lastHeartbeatAt
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
`,createEvent:`
|
|
91
|
+
mutation CreateEvent($input: CreateEventInput!) {
|
|
92
|
+
createEvent(input: $input) {
|
|
93
|
+
eventId
|
|
94
|
+
sessionId
|
|
95
|
+
type
|
|
96
|
+
source
|
|
97
|
+
content
|
|
98
|
+
timestamp
|
|
99
|
+
metadata
|
|
100
|
+
promptId
|
|
101
|
+
deliveryStatus
|
|
102
|
+
deliveredAt
|
|
103
|
+
executedAt
|
|
104
|
+
isEncrypted
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
`,updateEventStatus:`
|
|
108
|
+
mutation UpdateEventStatus($input: UpdateEventStatusInput!) {
|
|
109
|
+
updateEventStatus(input: $input) {
|
|
110
|
+
eventId
|
|
111
|
+
sessionId
|
|
112
|
+
type
|
|
113
|
+
source
|
|
114
|
+
content
|
|
115
|
+
timestamp
|
|
116
|
+
metadata
|
|
117
|
+
promptId
|
|
118
|
+
deliveryStatus
|
|
119
|
+
deliveredAt
|
|
120
|
+
executedAt
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
`,registerDeviceKey:`
|
|
124
|
+
mutation RegisterDeviceKey($input: RegisterDeviceKeyInput!) {
|
|
125
|
+
registerDeviceKey(input: $input) {
|
|
126
|
+
userId
|
|
127
|
+
deviceId
|
|
128
|
+
publicKey
|
|
129
|
+
platform
|
|
130
|
+
deviceName
|
|
131
|
+
createdAt
|
|
132
|
+
lastUsedAt
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
`,getAttachmentDownloadUrl:`
|
|
136
|
+
mutation GetAttachmentDownloadUrl($s3Key: String!) {
|
|
137
|
+
getAttachmentDownloadUrl(s3Key: $s3Key) {
|
|
138
|
+
downloadUrl
|
|
139
|
+
expiresAt
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
`},j={onEventCreated:`
|
|
143
|
+
subscription OnEventCreated($sessionId: ID!) {
|
|
144
|
+
onEventCreated(sessionId: $sessionId) {
|
|
145
|
+
eventId
|
|
146
|
+
sessionId
|
|
147
|
+
type
|
|
148
|
+
source
|
|
149
|
+
content
|
|
150
|
+
timestamp
|
|
151
|
+
metadata
|
|
152
|
+
promptId
|
|
153
|
+
attachments {
|
|
154
|
+
id
|
|
155
|
+
type
|
|
156
|
+
filename
|
|
157
|
+
s3Key
|
|
158
|
+
size
|
|
159
|
+
width
|
|
160
|
+
height
|
|
161
|
+
isEncrypted
|
|
162
|
+
}
|
|
163
|
+
deliveryStatus
|
|
164
|
+
deliveredAt
|
|
165
|
+
executedAt
|
|
166
|
+
isEncrypted
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
`};var qe=(a=>(a.USER_PROMPT="USER_PROMPT",a.ASSISTANT_RESPONSE="ASSISTANT_RESPONSE",a.TOOL_USE="TOOL_USE",a.NOTIFICATION="NOTIFICATION",a.INTERACTIVE_PROMPT="INTERACTIVE_PROMPT",a.PROMPT_RESPONSE="PROMPT_RESPONSE",a.REASONING="REASONING",a))(qe||{}),ye=(t=>(t.DESKTOP="DESKTOP",t.MOBILE="MOBILE",t))(ye||{}),He=(n=>(n.SENT="SENT",n.DELIVERED="DELIVERED",n.EXECUTED="EXECUTED",n))(He||{});var fe=(n=>(n.ACTIVE="ACTIVE",n.INACTIVE="INACTIVE",n.PAUSED="PAUSED",n))(fe||{}),Ve=(n=>(n.CLAUDE="CLAUDE",n.GEMINI="GEMINI",n.CODEX="CODEX",n))(Ve||{});var F={urgentMaxAttempts:10,baseDelayMs:1e3,maxDelayMs:6e4,backoffMultiplier:2,persistentDelayMs:300*1e3},J=class{constructor(){this.authenticated=!1;this.currentUserId=null;this.currentEmail=null;this.tokens=null;this.activeSubscriptions=new Map;this.heartbeatTimers=new Map;this.environment=h(),c.info("[AppSyncClient] Initialized",{environment:this.environment})}getCurrentUserId(){if(!this.currentUserId)throw new Error("Not authenticated. Call authenticateWithStoredTokens() first.");return this.currentUserId}getCurrentUserEmail(){return this.currentEmail}async authenticateWithStoredTokens(){try{let e=await g.getTokens(this.environment);if(!e)return c.debug("[AppSyncClient] No stored tokens found"),!1;if(c.info("[AppSyncClient] Found stored OAuth tokens",{userId:e.userId,email:e.email,expired:g.isTokenExpired(e)}),g.isTokenExpired(e)){if(c.info("[AppSyncClient] Tokens expired, attempting refresh..."),!await this.refreshTokens(e))return c.warn("[AppSyncClient] Token refresh failed"),!1}else this.tokens=e;return this.currentUserId=this.tokens.userId,this.currentEmail=this.tokens.email,this.authenticated=!0,c.info("[AppSyncClient] Authenticated successfully",{userId:this.currentUserId,email:this.currentEmail}),!0}catch(e){return c.error("[AppSyncClient] Authentication failed:",e),!1}}async refreshTokens(e){try{let t=f(),n=`https://${t.aws.cognitoDomain}/oauth2/token`,s=new URLSearchParams({grant_type:"refresh_token",client_id:t.aws.cognitoClientId,refresh_token:e.refreshToken}),i=await B(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()},"Token refresh");if(!i.ok)return c.error("[AppSyncClient] Token refresh failed",{status:i.status}),!1;let o=await i.json(),a={...e,accessToken:o.access_token,idToken:o.id_token,expiresAt:Date.now()+o.expires_in*1e3};return await g.setTokens(a,this.environment),this.tokens=a,c.info("[AppSyncClient] Tokens refreshed",{expiresAt:new Date(a.expiresAt).toISOString()}),!0}catch(t){return c.error("[AppSyncClient] Token refresh error:",t),!1}}isAuthenticated(){return this.authenticated}signOut(){this.authenticated=!1,this.tokens=null,this.currentUserId=null,this.currentEmail=null,this.cleanupSubscriptions(),c.info("[AppSyncClient] Signed out")}async graphqlRequest(e,t,n=!1){let s=f();if(!this.tokens?.idToken)throw new Error('Not authenticated. Run "codevibe login" first.');let i={"Content-Type":"application/json",Authorization:this.tokens.idToken},o=await B(s.aws.appsyncUrl,{method:"POST",headers:i,body:JSON.stringify({query:e,variables:t})},"AppSync GraphQL request"),a=await o.json();if(o.status===401&&!n&&this.tokens){if(c.info("[AppSyncClient] 401 Unauthorized, refreshing token..."),await this.refreshTokens(this.tokens))return this.graphqlRequest(e,t,!0);throw new Error("Token expired and refresh failed")}if(!o.ok)throw new Error(`GraphQL request failed: ${o.status}`);if(a.errors?.length)throw new Error(`GraphQL error: ${a.errors[0].message}`);return a}async createSession(e){let t={...e,metadata:e.metadata?JSON.stringify(e.metadata):void 0},n=await this.graphqlRequest(k.createSession,{input:t});return c.info("[AppSyncClient] Session created",{sessionId:n.data.createSession.sessionId}),n.data.createSession}async updateSession(e){let t={...e,metadata:e.metadata?JSON.stringify(e.metadata):void 0},n=await this.graphqlRequest(k.updateSession,{input:t});return c.debug("[AppSyncClient] Session updated",{sessionId:n.data.updateSession.sessionId}),n.data.updateSession}async getSession(e){return(await this.graphqlRequest(N.getSession,{sessionId:e})).data.getSession}async createEvent(e){let t={...e,metadata:e.metadata?JSON.stringify(e.metadata):void 0},n=await this.graphqlRequest(k.createEvent,{input:t});return c.debug("[AppSyncClient] Event created",{eventId:n.data.createEvent.eventId,type:n.data.createEvent.type}),n.data.createEvent}async updateEventStatus(e){return(await this.graphqlRequest(k.updateEventStatus,{input:e})).data.updateEventStatus}async listEvents(e,t,n){return(await this.graphqlRequest(N.listEvents,{sessionId:e,source:t,limit:n})).data.listEvents.items}async listUserDeviceKeys(){return(await this.graphqlRequest(N.listUserDeviceKeys,{})).data.listUserDeviceKeys||[]}async registerDeviceKey(e,t,n,s){let i={deviceId:e,publicKey:t,platform:n,deviceName:s};await this.graphqlRequest(k.registerDeviceKey,{input:i}),c.info("[AppSyncClient] Device key registered",{deviceId:e,platform:n})}async getAttachmentDownloadUrl(e){return(await this.graphqlRequest(k.getAttachmentDownloadUrl,{s3Key:e})).data.getAttachmentDownloadUrl}subscribeToEvents(e,t,n){c.info("[AppSyncClient] Subscribing to events",{sessionId:e});let s=this.activeSubscriptions.get(e);s&&(this.cleanupSubscriptionState(s),this.activeSubscriptions.delete(e));let i={ws:null,subscriptionId:(0,ve.v4)(),sessionId:e,onEvent:t,onError:n,reconnectAttempts:0,isReconnecting:!1};return this.activeSubscriptions.set(e,i),this.createSubscription(i),()=>{this.cleanupSubscriptionState(i),this.activeSubscriptions.delete(e)}}buildRealtimeUrl(){let e=f(),t=e.aws.appsyncUrl.replace("https://","wss://").replace("appsync-api","appsync-realtime-api"),n={host:new URL(e.aws.appsyncUrl).host};this.tokens?.idToken&&(n.Authorization=this.tokens.idToken);let s=Buffer.from(JSON.stringify(n)).toString("base64"),i=Buffer.from(JSON.stringify({})).toString("base64");return`${t}?header=${s}&payload=${i}`}createSubscription(e){let{sessionId:t,subscriptionId:n,onEvent:s,onError:i}=e;try{let o=this.buildRealtimeUrl(),a=new he.default(o,["graphql-ws"]);a.on("open",()=>{c.info("[AppSyncClient] WebSocket connected",{sessionId:t}),a.send(JSON.stringify({type:"connection_init"}))}),a.on("message",l=>{try{let p=JSON.parse(l.toString());switch(p.type){case"connection_ack":this.sendSubscriptionStart(a,e);break;case"start_ack":c.info("[AppSyncClient] Subscription started",{sessionId:t}),e.isReconnecting=!1,e.reconnectAttempts=0,this.startHeartbeat(t);break;case"data":this.resetKeepAliveTimer(e);let m=p.payload?.data?.onEventCreated;m&&m.source==="MOBILE"&&s(m);break;case"ka":this.resetKeepAliveTimer(e);break;case"error":let u=p.payload?.errors?.[0]?.message||"Unknown error";this.handleSubscriptionError(e,new Error(u));break}}catch(p){c.error("[AppSyncClient] Failed to parse message",{error:p})}}),a.on("error",l=>{c.error("[AppSyncClient] WebSocket error",{sessionId:t,error:l.message}),this.handleSubscriptionError(e,l)}),a.on("close",(l,p)=>{c.info("[AppSyncClient] WebSocket closed",{sessionId:t,code:l}),e.keepAliveTimer&&clearTimeout(e.keepAliveTimer),this.activeSubscriptions.has(t)&&this.handleSubscriptionError(e,new Error(`WebSocket closed: ${l}`))}),e.ws=a,this.resetKeepAliveTimer(e)}catch(o){this.handleSubscriptionError(e,o)}}sendSubscriptionStart(e,t){let n=f(),{sessionId:s,subscriptionId:i}=t,o={host:new URL(n.aws.appsyncUrl).host};this.tokens?.idToken&&(o.Authorization=this.tokens.idToken),e.send(JSON.stringify({id:i,type:"start",payload:{data:JSON.stringify({query:j.onEventCreated,variables:{sessionId:s}}),extensions:{authorization:o}}}))}resetKeepAliveTimer(e){e.keepAliveTimer&&clearTimeout(e.keepAliveTimer),e.keepAliveTimer=setTimeout(()=>{this.handleSubscriptionError(e,new Error("Keep-alive timeout"))},300*1e3)}handleSubscriptionError(e,t){let{sessionId:n,onError:s}=e;if(e.isReconnecting||!this.activeSubscriptions.has(n))return;e.isReconnecting=!0,e.reconnectAttempts++,this.stopHeartbeat(n);let i=e.reconnectAttempts<=F.urgentMaxAttempts,o;if(i?o=Math.min(F.baseDelayMs*Math.pow(F.backoffMultiplier,e.reconnectAttempts-1),F.maxDelayMs):(o=F.persistentDelayMs,e.reconnectAttempts===F.urgentMaxAttempts+1&&c.info("[AppSyncClient] Switching to persistent reconnect (every 5min)",{sessionId:n})),c.info("[AppSyncClient] Scheduling reconnect",{sessionId:n,attempt:e.reconnectAttempts,phase:i?"urgent":"persistent",delayMs:o}),e.ws){try{e.ws.close(1e3)}catch{}e.ws=null}e.keepAliveTimer&&clearTimeout(e.keepAliveTimer),e.reconnectTimer=setTimeout(async()=>{if(e.isReconnecting=!1,!!this.activeSubscriptions.has(n)){try{let a=await g.getTokens(this.environment);a&&(g.isTokenExpired(a)?await this.refreshTokens(a)&&c.info("[AppSyncClient] Tokens refreshed before reconnect",{sessionId:n}):this.tokens=a)}catch{c.warn("[AppSyncClient] Token refresh failed before reconnect, using existing tokens",{sessionId:n})}e.subscriptionId=(0,ve.v4)(),this.createSubscription(e)}},o)}cleanupSubscriptionState(e){if(e.reconnectTimer&&clearTimeout(e.reconnectTimer),e.keepAliveTimer&&clearTimeout(e.keepAliveTimer),e.ws){try{e.ws.readyState===he.default.OPEN&&(e.ws.send(JSON.stringify({id:e.subscriptionId,type:"stop"})),e.ws.close(1e3))}catch{}e.ws=null}}startHeartbeat(e,t=120*1e3){this.stopHeartbeat(e),this.sendHeartbeat(e);let n=setInterval(()=>{this.sendHeartbeat(e)},t);this.heartbeatTimers.set(e,n),c.info("[AppSyncClient] Heartbeat started",{sessionId:e,intervalMs:t})}stopHeartbeat(e){let t=this.heartbeatTimers.get(e);t&&(clearInterval(t),this.heartbeatTimers.delete(e),c.info("[AppSyncClient] Heartbeat stopped",{sessionId:e}))}async sendHeartbeat(e){try{await this.updateSession({sessionId:e,lastHeartbeatAt:new Date().toISOString()}),c.debug("[AppSyncClient] Heartbeat sent",{sessionId:e})}catch(t){c.warn("[AppSyncClient] Heartbeat failed",{sessionId:e,error:t})}}cleanupSubscriptions(){this.activeSubscriptions.forEach(e=>{this.cleanupSubscriptionState(e)}),this.activeSubscriptions.clear(),this.heartbeatTimers.forEach(e=>clearInterval(e)),this.heartbeatTimers.clear()}};var We=y(require("crypto")),je=y(require("fs")),be=y(require("http")),Je=require("child_process");_();M();L();var z=8080,ze="/callback",Se=`http://localhost:${z}${ze}`,q=class r{constructor(){}static getInstance(){return r.instance||(r.instance=new r),r.instance}openBrowser(e){console.log(""),console.log("Opening your browser for sign-in..."),console.log("If your browser does not open automatically, visit this URL manually:"),console.log(` ${e}`),console.log("");let t=this.getBrowserCommands();this.tryBrowserCommand(t,e,0)}getBrowserCommands(){let e=process.platform;if(e==="darwin")return[{cmd:"open",fixedArgs:[]}];if(e==="win32")return[{cmd:"cmd",fixedArgs:["/c","start",""]}];let t=[];return this.isRunningInWSL()&&(t.push({cmd:"wslview",fixedArgs:[]}),t.push({cmd:"cmd.exe",fixedArgs:["/c","start",""]}),t.push({cmd:"powershell.exe",fixedArgs:["-NoProfile","-Command","Start-Process"]})),t.push({cmd:"xdg-open",fixedArgs:[]}),t}isRunningInWSL(){if(process.platform!=="linux")return!1;try{let e=je.readFileSync("/proc/sys/kernel/osrelease","utf8");return/microsoft|wsl/i.test(e)}catch{return!1}}tryBrowserCommand(e,t,n){if(n>=e.length){c.debug("[AuthService] No browser-opening command succeeded. User must open the sign-in URL manually (printed to stdout above).");return}let s=e[n],i=[...s.fixedArgs,t],o=!1,a=u=>{o||(o=!0,c.debug(`[AuthService] Browser command '${s.cmd}' ${u}; trying next fallback`),this.tryBrowserCommand(e,t,n+1))},l=u=>{o||(o=!0,c.debug(`[AuthService] Browser command '${s.cmd}' ${u}`))},p;try{p=(0,Je.spawn)(s.cmd,i,{detached:!0,stdio:"ignore"})}catch(u){a(`threw synchronously: ${u?.message||u}`);return}p.on("error",u=>{a(`failed to spawn: ${u?.message||u}`)}),p.on("exit",(u,C)=>{u===0?l("exited successfully"):a(C?`terminated by signal ${C}`:`exited with code ${u}`)}),setTimeout(()=>{l("still running after 3s, assuming success")},3e3).unref(),p.unref()}generateState(){return We.randomBytes(32).toString("hex")}buildAuthUrl(e){let t=f(),n=new URLSearchParams({client_id:t.aws.cognitoClientId,response_type:"code",scope:"email openid profile",redirect_uri:Se,state:e});return`https://${t.aws.cognitoDomain}/oauth2/authorize?${n.toString()}`}async exchangeCodeForTokens(e){let t=f(),n=`https://${t.aws.cognitoDomain}/oauth2/token`,s=new URLSearchParams({grant_type:"authorization_code",client_id:t.aws.cognitoClientId,code:e,redirect_uri:Se}),i=await B(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()},"Token exchange");if(!i.ok){let a=await i.text();throw new Error(`Token exchange failed: ${i.status} ${a}`)}let o=await i.json();return{accessToken:o.access_token,idToken:o.id_token,refreshToken:o.refresh_token,expiresIn:o.expires_in}}decodeJwt(e){let t=e.split(".");if(t.length!==3)throw new Error("Invalid JWT");return JSON.parse(Buffer.from(t[1],"base64").toString("utf-8"))}async refreshTokens(e){let t=f(),n=`https://${t.aws.cognitoDomain}/oauth2/token`,s=new URLSearchParams({grant_type:"refresh_token",client_id:t.aws.cognitoClientId,refresh_token:e}),i=await B(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()},"Token refresh");if(!i.ok)throw new Error(`Token refresh failed: ${i.status}`);let o=await i.json();return{accessToken:o.access_token,idToken:o.id_token,expiresIn:o.expires_in}}async login(){let e=await g.getTokens(h());if(e&&!g.isTokenExpired(e))return e;let t=this.generateState(),n=this.buildAuthUrl(t);return new Promise((s,i)=>{let o=be.createServer(async(a,l)=>{if(!a.url?.startsWith(ze)){l.writeHead(404),l.end("Not found");return}try{let p=new URL(a.url,`http://localhost:${z}`),m=p.searchParams.get("code"),u=p.searchParams.get("state"),C=p.searchParams.get("error");if(C)throw new Error(`OAuth error: ${C}`);if(u!==t)throw new Error("State mismatch");if(!m)throw new Error("No authorization code");let S=await this.exchangeCodeForTokens(m),H=this.decodeJwt(S.idToken),w={accessToken:S.accessToken,idToken:S.idToken,refreshToken:S.refreshToken,expiresAt:Date.now()+S.expiresIn*1e3,userId:H.sub,email:H.email||"unknown"};await g.setTokens(w,h()),l.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),l.end(`
|
|
170
|
+
<!DOCTYPE html>
|
|
171
|
+
<html>
|
|
172
|
+
<head><title>Success</title></head>
|
|
173
|
+
<body style="font-family: system-ui; max-width: 600px; margin: 50px auto; text-align: center;">
|
|
174
|
+
<h1 style="color: #22c55e;">✓ Authentication Successful</h1>
|
|
175
|
+
<p>You can close this window.</p>
|
|
176
|
+
</body>
|
|
177
|
+
</html>
|
|
178
|
+
`),setTimeout(()=>{o.close(()=>s(w))},500)}catch(p){let m=String(p?.message||p).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");l.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),l.end(`
|
|
179
|
+
<!DOCTYPE html>
|
|
180
|
+
<html>
|
|
181
|
+
<head><title>Error</title></head>
|
|
182
|
+
<body style="font-family: system-ui; max-width: 720px; margin: 50px auto; padding: 0 16px;">
|
|
183
|
+
<h1 style="color: #ef4444; text-align: center;">✗ Authentication Failed</h1>
|
|
184
|
+
<pre style="background: #f4f4f5; padding: 16px; border-radius: 8px; white-space: pre-wrap; word-wrap: break-word; font-size: 13px; line-height: 1.5;">${m}</pre>
|
|
185
|
+
<p style="text-align: center; color: #71717a; margin-top: 24px;">You can close this window and try again in your terminal.</p>
|
|
186
|
+
</body>
|
|
187
|
+
</html>
|
|
188
|
+
`),setTimeout(()=>{o.close(()=>i(p))},500)}});o.on("error",a=>{a.code==="EADDRINUSE"?i(new Error(`Port ${z} is in use`)):i(a)}),o.listen(z,"localhost",()=>{c.info("[AuthService] Callback server started"),this.openBrowser(n)}),setTimeout(()=>{o.close(()=>i(new Error("Login timeout")))},120*1e3)})}async logout(){let e=f(),t=await g.deleteTokens(h());return t&&new Promise(n=>{let s=be.createServer((i,o)=>{i.url?.startsWith("/signout")?(o.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),o.end(`
|
|
189
|
+
<!DOCTYPE html>
|
|
190
|
+
<html>
|
|
191
|
+
<head><title>Signed Out</title></head>
|
|
192
|
+
<body style="font-family: system-ui; max-width: 600px; margin: 50px auto; text-align: center;">
|
|
193
|
+
<h1 style="color: #22c55e;">✓ Signed Out</h1>
|
|
194
|
+
<p>You can close this window.</p>
|
|
195
|
+
</body>
|
|
196
|
+
</html>
|
|
197
|
+
`),setTimeout(()=>{s.close(()=>n(!0))},500)):(o.writeHead(404),o.end("Not found"))});s.on("error",()=>{n(!0)}),s.listen(z,"localhost",()=>{let i=`https://${e.aws.cognitoDomain}/logout?client_id=${e.aws.cognitoClientId}&logout_uri=${encodeURIComponent(Se.replace("/callback","/signout"))}`;this.openBrowser(i)}),setTimeout(()=>{s.close(()=>n(!0))},30*1e3)})}async getStatus(){let e=await g.getTokens(h());return e?{authenticated:!g.isTokenExpired(e),tokens:e}:{authenticated:!1}}},x=q.getInstance();_();var d={reset:"\x1B[0m",green:"\x1B[32m",red:"\x1B[31m",yellow:"\x1B[33m",cyan:"\x1B[36m",dim:"\x1B[2m"};async function mt(){console.log(`${d.cyan}CodeVibe Login${d.reset}
|
|
198
|
+
`);try{let r=await x.getStatus();if(r.authenticated&&r.tokens){console.log(`${d.yellow}Already logged in as: ${r.tokens.email}${d.reset}`),console.log(`Token expires: ${new Date(r.tokens.expiresAt).toLocaleString()}`),console.log(`
|
|
199
|
+
Run '${d.dim}codevibe logout${d.reset}' to sign out first.`),process.exit(0);return}console.log("Opening browser for authentication..."),console.log(`${d.dim}Waiting for callback...${d.reset}
|
|
200
|
+
`);let e=await x.login();e&&(console.log(`
|
|
201
|
+
${d.green}\u2713 Authentication successful!${d.reset}`),console.log(` User: ${e.email}`),console.log(` User ID: ${e.userId}`),console.log(` Expires: ${new Date(e.expiresAt).toLocaleString()}`)),process.exit(0)}catch(r){console.log(`
|
|
202
|
+
${d.red}\u2717 Authentication failed${d.reset}`),console.log(` Error: ${r.message}`),process.exit(1)}}async function yt(){console.log(`${d.cyan}CodeVibe Logout${d.reset}
|
|
203
|
+
`);try{let r=await x.getStatus();if(!r.authenticated){console.log(`${d.yellow}Not logged in.${d.reset}`),process.exit(0);return}let e=r.tokens?.email;await x.logout()?(console.log(`${d.green}\u2713 Logged out successfully.${d.reset}`),console.log(` Previous user: ${e}`),console.log(`
|
|
204
|
+
${d.dim}Clearing browser session...${d.reset}`)):console.log(`${d.red}\u2717 Failed to log out.${d.reset}`),process.exit(0)}catch(r){console.log(`${d.red}\u2717 Logout failed: ${r.message}${d.reset}`),process.exit(1)}}async function ft(){console.log(`${d.cyan}CodeVibe Auth Status${d.reset}
|
|
205
|
+
`);try{let r=await x.getStatus();if(!r.tokens){console.log(`${d.yellow}Not authenticated.${d.reset}`),console.log(`
|
|
206
|
+
Run '${d.dim}codevibe login${d.reset}' to sign in.`),process.exit(0);return}let e=!r.authenticated;console.log(e?`${d.yellow}\u26A0 Token expired${d.reset}`:`${d.green}\u2713 Authenticated${d.reset}`),console.log(` User: ${r.tokens.email}`),console.log(` User ID: ${r.tokens.userId}`),console.log(` Expires: ${new Date(r.tokens.expiresAt).toLocaleString()}`),e&&console.log(`
|
|
207
|
+
${d.dim}Token will be refreshed automatically.${d.reset}`),process.exit(0)}catch(r){console.log(`${d.red}\u2717 Status check failed: ${r.message}${d.reset}`),process.exit(1)}}async function ht(){console.log(`${d.cyan}CodeVibe Reset Device${d.reset}
|
|
208
|
+
`),console.log(`${d.red}\u26A0 WARNING: This will delete your device identity.${d.reset}`),console.log(`${d.red} Old encrypted sessions will become inaccessible.${d.reset}
|
|
209
|
+
`);let{keychainManager:r}=await Promise.resolve().then(()=>(M(),Me));try{await r.clearAllData(),console.log(`${d.green}\u2713 Device reset complete.${d.reset}`),console.log(` Run '${d.dim}codevibe login${d.reset}' to set up again.`),process.exit(0)}catch(e){console.log(`${d.red}\u2717 Reset failed: ${e.message}${d.reset}`),process.exit(1)}}function vt(){console.log(`CodeVibe Authentication
|
|
210
|
+
`),console.log("Usage:"),console.log(" codevibe login - Sign in via browser"),console.log(" codevibe logout - Sign out"),console.log(" codevibe status - Show auth status"),console.log(" codevibe reset-device - Reset device identity (destructive)"),console.log(`
|
|
211
|
+
Environment:`),console.log(' Set ENVIRONMENT env var to "development" or "production" (default)'),console.log(" Example: ENVIRONMENT=development codevibe login")}async function ne(r){let e=h();console.log(`${d.dim}Environment: ${e}${d.reset}
|
|
212
|
+
`);let n=r.slice(2).filter(s=>!s.startsWith("--"))[0];switch(n){case"login":await mt();break;case"logout":await yt();break;case"status":await ft();break;case"reset-device":await ht();break;default:vt(),process.exit(n?1:0)}}require.main===module&&ne(process.argv).catch(r=>{console.error("Error:",r),process.exit(1)});_();L();var St=/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g;function Ye(r){let e=Ee(r);if(!e)return null;let t=bt(e);if(t)return t;let n=wt(e);return n||null}function Ee(r){return r.replace(/\r/g,`
|
|
213
|
+
`).replace(St,"").replace(/[│┌┐└┘─├┤┬┴┼╌╎╭╮╯╰║═╔╗╚╝╠╣╦╩╬]/g," ").replace(/[ \t]+\n/g,`
|
|
214
|
+
`).replace(/\n{3,}/g,`
|
|
215
|
+
|
|
216
|
+
`).trim()}function bt(r){let e=r.split(`
|
|
217
|
+
`).map(m=>m.trim()),t=kt(e,m=>/\[(?:y\/n|Y\/n|y\/N)\]/.test(m)),n=t>=0?e[t]:null;if(!n)return null;let s=Xe(e,t),i=s.length>0?s.join(`
|
|
218
|
+
`):n,o=i.toLowerCase(),a=o.includes("what to change")||o.includes("what should")||o.includes("provide")||o.includes("instructions");return{kind:"yes_no",promptText:i,options:a?[{number:"1",text:"Yes"},{number:"2",text:"No, provide instructions"}]:[{number:"1",text:"Yes"},{number:"2",text:"No"}],submitMap:{1:"y",2:"n"},requiresFollowUpText:a}}function wt(r){let e=r.split(`
|
|
219
|
+
`).map(l=>l.trim()),t=Et(e);if(t.length<2)return null;let n=t.map(({line:l})=>Ge(l)).filter(l=>!!l),s={};for(let l of n)s[l.number]=l.number;let i=t[0]?.index??-1,o=Xe(e,i-1);return{kind:"numbered",promptText:o.length>0?o.join(`
|
|
220
|
+
`):"Select an option",options:n,submitMap:s}}function kt(r,e){for(let t=r.length-1;t>=0;t-=1)if(e(r[t]))return t;return-1}function Ge(r){let e=r.match(/^(?:[>›❯▸▶➜➤*●]\s*)?(\d+)\.\s+(.*)$/);return e?{number:e[1],text:e[2]}:null}function Et(r){let e=r.map((n,s)=>({index:s,line:n,parsed:Ge(n)})).filter(n=>!!n.parsed);if(e.length===0)return[];let t=[e[e.length-1]];for(let n=e.length-2;n>=0;n-=1){let s=e[n],i=t[0];if(s.index!==i.index-1)break;t.unshift(s)}return t.map(({index:n,line:s})=>({index:n,line:s}))}function Xe(r,e){if(e<0)return[];let t=we(r,e);if(t<0)return[];let{start:n,end:s}=ke(r,t),i=r.slice(n,s+1).filter(Boolean);if(Tt(i)){let u=It(r,n-1);return u.length>0?u:i}if(n<=1)return i;let o=n-1;if(o=we(r,o),o<0||o===n-1)return i;let{start:a,end:l}=ke(r,o),p=r.slice(a,l+1).filter(Boolean);return p.some(Qe)?[...p,...i]:i}function Qe(r){return/^(?:would you like to|do you want to|the model would like to|action required|confirm)\b/i.test(r)}function we(r,e){let t=e;for(;t>=0&&!r[t];)t-=1;return t}function ke(r,e){let t=e;for(;t>=0&&r[t];)t-=1;return{start:t+1,end:e}}function It(r,e){let t=[],n=e;for(;n>=0&&t.length<2&&(n=we(r,n),!(n<0));){let{start:i,end:o}=ke(r,n),a=r.slice(i,o+1).filter(Boolean);a.length>0&&t.unshift(a),n=i-1}if(t.length===0)return[];let s=t.findIndex(i=>i.some(Qe));return s>=0?t.slice(s).flat():t[t.length-1]}function Tt(r){return r.length===0?!1:r.filter(xt).length>=Math.max(2,Math.ceil(r.length/2))}function xt(r){return/^\d+\s/.test(r)}Q();M();async function re(r,e,t){try{let n=await e.listUserDeviceKeys();if(n.length===0)return t.info("No device keys found, session will not be encrypted"),null;t.info("Preparing session encryption",{sessionId:r,deviceCount:n.length});let{sessionKey:s,encryptedKeys:i}=g.createSessionKey(n);return t.info("Session encryption prepared",{sessionId:r,deviceCount:i.length}),{sessionKey:s,encryptedKeys:i}}catch(n){return t.warn("Failed to prepare session encryption:",n),null}}async function Ie(r,e,t){let{sessionId:n,userId:s,agentType:i,projectPath:o,metadata:a}=r,l=null;try{l=await e.getSession(n)}catch(S){t.warn("Failed to get session (will attempt to create new)",{sessionId:n,error:S})}if(l){t.info("Session exists in backend - reactivating",{sessionId:n,previousStatus:l.status});try{await e.updateSession({sessionId:n,status:"ACTIVE"})}catch(w){t.warn("Failed to reactivate existing session, will continue",{sessionId:n,error:w})}let S=null,H=l.encryptedKeys;if(l.isEncrypted&&H?.length)try{let w=await g.getSessionKey(n,H);w?(S=w,g.cacheSessionKey(n,w),t.info("Session key retrieved for resumed session",{sessionId:n})):t.warn("No encrypted key for this device; proceeding without decryption",{sessionId:n})}catch(w){t.warn("Failed to retrieve session key for resumed session",{sessionId:n,error:w})}return{resumed:!0,sessionKey:S}}let p=await re(n,e,t),m=o,u=a;p&&(m=b.encryptContent(o,p.sessionKey),u&&Object.keys(u).length>0&&(u={encrypted:b.encryptMetadata(u,p.sessionKey)}),t.info("Session data encrypted",{sessionId:n})),t.info("Creating new session in backend",{sessionId:n,userId:s,agentType:i,isEncrypted:!!p}),await e.createSession({sessionId:n,userId:s,agentType:i,projectPath:m,status:"ACTIVE",metadata:u,isEncrypted:p?!0:void 0,creatorDeviceId:p?await g.getDeviceId():void 0,encryptionVersion:p?1:void 0,encryptedKeys:p?.encryptedKeys});let C=p?.sessionKey||null;return p&&g.cacheSessionKey(n,p.sessionKey),t.info("Session created",{sessionId:n,userId:s,isEncrypted:!!p}),{resumed:!1,sessionKey:C}}0&&(module.exports={AgentType,AppSyncClient,AuthService,CryptoError,CryptoService,DeliveryStatus,ENCRYPTION_VERSION,EventSource,EventType,KeychainError,KeychainManager,Logger,SessionStatus,authService,createLogger,cryptoService,getConfig,getEnvironment,keychainManager,loadConfig,logger,mutations,normalizeSnapshot,parseInteractivePrompt,prepareSessionEncryption,queries,resumeOrCreateSession,runAuthCli,subscriptions});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { KeychainManager, keychainManager, KeychainError } from './keychain-manager';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function getPassword(service: string, account: string): Promise<string | null>;
|
|
2
|
+
export declare function setPassword(service: string, account: string, password: string): Promise<void>;
|
|
3
|
+
export declare function deletePassword(service: string, account: string): Promise<boolean>;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { DeviceIdentity, TokenData, EncryptedSessionKey } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Error class for keychain operations
|
|
4
|
+
*/
|
|
5
|
+
export declare class KeychainError extends Error {
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Manages device identity and OAuth tokens using native keychain
|
|
10
|
+
*/
|
|
11
|
+
export declare class KeychainManager {
|
|
12
|
+
private static instance;
|
|
13
|
+
private deviceIdentity;
|
|
14
|
+
private sessionKeyCache;
|
|
15
|
+
private isRegistered;
|
|
16
|
+
private _serviceName;
|
|
17
|
+
private constructor();
|
|
18
|
+
/**
|
|
19
|
+
* Get the keychain service name (lazy-loaded from config)
|
|
20
|
+
*/
|
|
21
|
+
private get serviceName();
|
|
22
|
+
static getInstance(): KeychainManager;
|
|
23
|
+
/**
|
|
24
|
+
* Get the device identity from keychain.
|
|
25
|
+
*
|
|
26
|
+
* Returns null ONLY when the backend read succeeded and no record exists
|
|
27
|
+
* (legitimate "not yet registered" state). Any other error — backend
|
|
28
|
+
* unavailable, corrupted payload, parse failure — propagates to the
|
|
29
|
+
* caller. Swallowing those errors here would let getOrCreateDeviceIdentity
|
|
30
|
+
* silently mint a new device ID and fork identity state, re-creating the
|
|
31
|
+
* exact bug the keychain-backend trust model is designed to prevent.
|
|
32
|
+
*/
|
|
33
|
+
getDeviceIdentity(): Promise<DeviceIdentity | null>;
|
|
34
|
+
/**
|
|
35
|
+
* Set the device identity in keychain
|
|
36
|
+
*/
|
|
37
|
+
setDeviceIdentity(identity: DeviceIdentity): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Get or create device identity
|
|
40
|
+
*/
|
|
41
|
+
getOrCreateDeviceIdentity(): Promise<DeviceIdentity>;
|
|
42
|
+
/**
|
|
43
|
+
* Get device ID (creates identity if needed)
|
|
44
|
+
*/
|
|
45
|
+
getDeviceId(): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Get device public key (creates identity if needed)
|
|
48
|
+
*/
|
|
49
|
+
getDevicePublicKey(): Promise<string>;
|
|
50
|
+
/**
|
|
51
|
+
* Get device private key (creates identity if needed)
|
|
52
|
+
*/
|
|
53
|
+
getDevicePrivateKey(): Promise<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Check if device identity exists
|
|
56
|
+
*/
|
|
57
|
+
hasDeviceIdentity(): Promise<boolean>;
|
|
58
|
+
/**
|
|
59
|
+
* Delete device identity (reset device)
|
|
60
|
+
*/
|
|
61
|
+
deleteDeviceIdentity(): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Get token account name for environment
|
|
64
|
+
*/
|
|
65
|
+
private getTokenAccount;
|
|
66
|
+
/**
|
|
67
|
+
* Get OAuth tokens for environment.
|
|
68
|
+
*
|
|
69
|
+
* Returns null ONLY when the backend read succeeded and no tokens exist
|
|
70
|
+
* (legitimate "not yet logged in" state). Any other error — backend
|
|
71
|
+
* unavailable, corrupted payload, parse failure — propagates to the
|
|
72
|
+
* caller. Swallowing backend errors here would look like a silent logout
|
|
73
|
+
* when it is actually a hard configuration failure the user needs to see
|
|
74
|
+
* and fix.
|
|
75
|
+
*/
|
|
76
|
+
getTokens(environment?: string): Promise<TokenData | null>;
|
|
77
|
+
/**
|
|
78
|
+
* Save OAuth tokens for environment
|
|
79
|
+
*/
|
|
80
|
+
setTokens(tokens: TokenData, environment?: string): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Delete OAuth tokens for environment
|
|
83
|
+
*/
|
|
84
|
+
deleteTokens(environment?: string): Promise<boolean>;
|
|
85
|
+
/**
|
|
86
|
+
* Check if token is expired
|
|
87
|
+
*/
|
|
88
|
+
isTokenExpired(tokens: TokenData): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Get session key for a session, decrypting from encryptedKeys if needed
|
|
91
|
+
*/
|
|
92
|
+
getSessionKey(sessionId: string, encryptedKeys?: EncryptedSessionKey[]): Promise<string | null>;
|
|
93
|
+
/**
|
|
94
|
+
* Generate and encrypt a new session key for all devices
|
|
95
|
+
*/
|
|
96
|
+
createSessionKey(devicePublicKeys: Array<{
|
|
97
|
+
deviceId: string;
|
|
98
|
+
publicKey: string;
|
|
99
|
+
}>): {
|
|
100
|
+
sessionKey: string;
|
|
101
|
+
encryptedKeys: EncryptedSessionKey[];
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Cache a session key
|
|
105
|
+
*/
|
|
106
|
+
cacheSessionKey(sessionId: string, sessionKey: string): void;
|
|
107
|
+
/**
|
|
108
|
+
* Clear cached session key
|
|
109
|
+
*/
|
|
110
|
+
clearSessionKey(sessionId: string): void;
|
|
111
|
+
/**
|
|
112
|
+
* Clear all cached session keys
|
|
113
|
+
*/
|
|
114
|
+
clearAllSessionKeys(): void;
|
|
115
|
+
/**
|
|
116
|
+
* Get registration status
|
|
117
|
+
*/
|
|
118
|
+
getIsRegistered(): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Set registration status
|
|
121
|
+
*/
|
|
122
|
+
setIsRegistered(registered: boolean): void;
|
|
123
|
+
/**
|
|
124
|
+
* Get device name for registration
|
|
125
|
+
*/
|
|
126
|
+
getDeviceName(): string;
|
|
127
|
+
/**
|
|
128
|
+
* Get platform for registration
|
|
129
|
+
*/
|
|
130
|
+
getDevicePlatform(): string;
|
|
131
|
+
/**
|
|
132
|
+
* Clear all data (device identity + all tokens)
|
|
133
|
+
*/
|
|
134
|
+
clearAllData(): Promise<void>;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Export singleton instance
|
|
138
|
+
*/
|
|
139
|
+
export declare const keychainManager: KeychainManager;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Logger, logger, createLogger } from './logger';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
2
|
+
interface LoggerOptions {
|
|
3
|
+
name: string;
|
|
4
|
+
logFile?: string;
|
|
5
|
+
level?: LogLevel;
|
|
6
|
+
console?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Simple logger for CodeVibe plugins
|
|
10
|
+
*/
|
|
11
|
+
export declare class Logger {
|
|
12
|
+
private name;
|
|
13
|
+
private logFile?;
|
|
14
|
+
private level;
|
|
15
|
+
private enableConsole;
|
|
16
|
+
constructor(options: LoggerOptions);
|
|
17
|
+
private ensureLogDir;
|
|
18
|
+
private shouldLog;
|
|
19
|
+
private formatMessage;
|
|
20
|
+
private log;
|
|
21
|
+
debug(message: string, data?: any): void;
|
|
22
|
+
info(message: string, data?: any): void;
|
|
23
|
+
warn(message: string, data?: any): void;
|
|
24
|
+
error(message: string, data?: any): void;
|
|
25
|
+
setLevel(level: LogLevel): void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Create a logger with custom options
|
|
29
|
+
*/
|
|
30
|
+
export declare function createLogger(options: LoggerOptions): Logger;
|
|
31
|
+
/**
|
|
32
|
+
* Default shared logger instance
|
|
33
|
+
*/
|
|
34
|
+
export declare const logger: Logger;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared prompt parser for interactive terminal prompts.
|
|
3
|
+
*
|
|
4
|
+
* Parses terminal snapshots (from tmux capture-pane) to extract
|
|
5
|
+
* interactive prompt options displayed by CLI tools (Gemini, Codex, etc.).
|
|
6
|
+
*
|
|
7
|
+
* Used by multiple plugins to dynamically capture options instead of hardcoding.
|
|
8
|
+
*/
|
|
9
|
+
export type PromptKind = 'yes_no' | 'numbered' | 'text';
|
|
10
|
+
export interface InteractivePromptOption {
|
|
11
|
+
number: string;
|
|
12
|
+
text: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ParsedInteractivePrompt {
|
|
15
|
+
kind: PromptKind;
|
|
16
|
+
promptText: string;
|
|
17
|
+
options: InteractivePromptOption[];
|
|
18
|
+
submitMap: Record<string, string>;
|
|
19
|
+
requiresFollowUpText?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Parse a terminal snapshot to extract interactive prompt options.
|
|
23
|
+
*
|
|
24
|
+
* Detects two prompt types:
|
|
25
|
+
* - Yes/No prompts: [y/n] patterns
|
|
26
|
+
* - Numbered prompts: "1. Allow once", "2. Allow for this session", etc.
|
|
27
|
+
*
|
|
28
|
+
* Returns null if no prompt is detected.
|
|
29
|
+
*/
|
|
30
|
+
export declare function parseInteractivePrompt(snapshot: string): ParsedInteractivePrompt | null;
|
|
31
|
+
/**
|
|
32
|
+
* Strip ANSI escape codes, box-drawing characters, and normalize whitespace
|
|
33
|
+
* from terminal output.
|
|
34
|
+
*
|
|
35
|
+
* Box-drawing characters (│, ┌, ┐, └, ┘, ─, etc.) are used by TUI apps like
|
|
36
|
+
* Gemini CLI to render bordered panels. Stripping them exposes the text content
|
|
37
|
+
* so the parser can match option lines inside boxes.
|
|
38
|
+
*/
|
|
39
|
+
export declare function normalizeSnapshot(snapshot: string): string;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized session resume/create logic for all CodeVibe plugins.
|
|
3
|
+
*
|
|
4
|
+
* All three plugins (Claude, Codex, Gemini) need the same pattern:
|
|
5
|
+
* 1. Check if session exists in backend (getSession)
|
|
6
|
+
* 2. If exists: reactivate + restore E2E session key from encryptedKeys
|
|
7
|
+
* 3. If not exists: generate encryption keys + create session
|
|
8
|
+
*
|
|
9
|
+
* This module eliminates the duplication across plugins.
|
|
10
|
+
*/
|
|
11
|
+
import { AppSyncClient } from '../appsync';
|
|
12
|
+
import { Logger } from '../logger';
|
|
13
|
+
import { AgentType, EncryptedSessionKey } from '../types';
|
|
14
|
+
export interface ResumeOrCreateSessionInput {
|
|
15
|
+
sessionId: string;
|
|
16
|
+
userId: string;
|
|
17
|
+
agentType: AgentType;
|
|
18
|
+
projectPath: string;
|
|
19
|
+
metadata?: Record<string, any>;
|
|
20
|
+
}
|
|
21
|
+
export interface ResumeOrCreateSessionResult {
|
|
22
|
+
/** Whether an existing session was found and reactivated */
|
|
23
|
+
resumed: boolean;
|
|
24
|
+
/** The E2E session key (for encrypting/decrypting events), or null if no encryption */
|
|
25
|
+
sessionKey: string | null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Prepare E2E encryption for a new session.
|
|
29
|
+
*
|
|
30
|
+
* Generates a random session key and encrypts it for all registered devices.
|
|
31
|
+
* Does NOT cache the session key — callers should cache only after the session
|
|
32
|
+
* is successfully created in the backend.
|
|
33
|
+
*
|
|
34
|
+
* @returns Encryption data or null if no device keys found / error
|
|
35
|
+
*/
|
|
36
|
+
export declare function prepareSessionEncryption(sessionId: string, appSyncClient: AppSyncClient, logger: Logger): Promise<{
|
|
37
|
+
sessionKey: string;
|
|
38
|
+
encryptedKeys: EncryptedSessionKey[];
|
|
39
|
+
} | null>;
|
|
40
|
+
/**
|
|
41
|
+
* Resume an existing session or create a new one.
|
|
42
|
+
*
|
|
43
|
+
* Resume path (session exists in backend):
|
|
44
|
+
* - Reactivates session (status → ACTIVE)
|
|
45
|
+
* - Restores E2E session key from encryptedKeys
|
|
46
|
+
*
|
|
47
|
+
* Create path (session does not exist):
|
|
48
|
+
* - Prepares E2E encryption (generates key, encrypts for all devices)
|
|
49
|
+
* - Encrypts projectPath and metadata
|
|
50
|
+
* - Creates session in backend
|
|
51
|
+
* - Caches session key only after successful creation
|
|
52
|
+
*
|
|
53
|
+
* @throws Propagates createSession errors (e.g., SESSION_LIMIT_EXCEEDED)
|
|
54
|
+
*/
|
|
55
|
+
export declare function resumeOrCreateSession(input: ResumeOrCreateSessionInput, appSyncClient: AppSyncClient, logger: Logger): Promise<ResumeOrCreateSessionResult>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stored OAuth tokens
|
|
3
|
+
*/
|
|
4
|
+
export interface TokenData {
|
|
5
|
+
accessToken: string;
|
|
6
|
+
idToken: string;
|
|
7
|
+
refreshToken: string;
|
|
8
|
+
expiresAt: number;
|
|
9
|
+
userId: string;
|
|
10
|
+
email: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Environment configuration
|
|
14
|
+
*/
|
|
15
|
+
export type Environment = 'development' | 'production';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encrypted session key for E2E encryption
|
|
3
|
+
*/
|
|
4
|
+
export interface EncryptedSessionKey {
|
|
5
|
+
deviceId: string;
|
|
6
|
+
encryptedKey: string;
|
|
7
|
+
ephemeralPublicKey: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Device key stored with backend
|
|
11
|
+
*/
|
|
12
|
+
export interface DeviceKey {
|
|
13
|
+
userId: string;
|
|
14
|
+
deviceId: string;
|
|
15
|
+
publicKey: string;
|
|
16
|
+
platform: string;
|
|
17
|
+
deviceName?: string;
|
|
18
|
+
createdAt: string;
|
|
19
|
+
lastUsedAt?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Key pair for ECDH
|
|
23
|
+
*/
|
|
24
|
+
export interface KeyPair {
|
|
25
|
+
privateKey: string;
|
|
26
|
+
publicKey: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Device identity stored in keychain
|
|
30
|
+
*/
|
|
31
|
+
export interface DeviceIdentity {
|
|
32
|
+
deviceId: string;
|
|
33
|
+
privateKey: string;
|
|
34
|
+
publicKey: string;
|
|
35
|
+
createdAt: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* GraphQL input for registering device key
|
|
39
|
+
*/
|
|
40
|
+
export interface RegisterDeviceKeyInput {
|
|
41
|
+
deviceId: string;
|
|
42
|
+
publicKey: string;
|
|
43
|
+
platform: string;
|
|
44
|
+
deviceName?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* GraphQL input for granting session key
|
|
48
|
+
*/
|
|
49
|
+
export interface GrantSessionKeyInput {
|
|
50
|
+
sessionId: string;
|
|
51
|
+
deviceId: string;
|
|
52
|
+
encryptedKey: string;
|
|
53
|
+
ephemeralPublicKey: string;
|
|
54
|
+
}
|