bantou 0.1.0 → 0.2.0
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/.output/nitro.json +13 -0
- package/.output/public/_nuxt/BmGsA4i2.js +1 -0
- package/.output/public/_nuxt/D_G6gzEa.js +1 -0
- package/.output/public/_nuxt/builds/latest.json +1 -0
- package/.output/public/_nuxt/builds/meta/1a8fc623-6671-445b-bdd3-c3d073520a3a.json +1 -0
- package/.output/public/_nuxt/entry.CZSvzYhH.css +1 -0
- package/.output/public/_nuxt/error-404.C3wqHTJz.css +1 -0
- package/.output/public/_nuxt/error-500.D6rBzoDj.css +1 -0
- package/.output/public/_nuxt/pdFQkwM_.js +4 -0
- package/.output/server/chunks/_/error-500.mjs +20 -0
- package/.output/server/chunks/_/error-500.mjs.map +1 -0
- package/.output/server/chunks/nitro/nitro.mjs +5870 -0
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -0
- package/.output/server/chunks/routes/mcp.mjs +22 -0
- package/.output/server/chunks/routes/mcp.mjs.map +1 -0
- package/.output/server/chunks/routes/renderer.mjs +462 -0
- package/.output/server/chunks/routes/renderer.mjs.map +1 -0
- package/.output/server/chunks/virtual/_virtual_spa-template.mjs +4 -0
- package/.output/server/chunks/virtual/_virtual_spa-template.mjs.map +1 -0
- package/.output/server/chunks/virtual/precomputed.mjs +4 -0
- package/.output/server/chunks/virtual/precomputed.mjs.map +1 -0
- package/.output/server/index.mjs +18 -0
- package/.output/server/index.mjs.map +1 -0
- package/.output/server/node_modules/@babel/parser/lib/index.js +14657 -0
- package/.output/server/node_modules/@babel/parser/package.json +50 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js +64 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js +16 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js +32 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js +246 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/package.json +1 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js +41 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +429 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js +971 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/requestBody.js +58 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js +13 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js +961 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +228 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js +51 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js +57 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js +1137 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js +92 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/uriTemplate.js +239 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js +2065 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js +87 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/package.json +165 -0
- package/.output/server/node_modules/@parcel/watcher-wasm/index.mjs +349 -0
- package/.output/server/node_modules/@parcel/watcher-wasm/package.json +44 -0
- package/.output/server/node_modules/@parcel/watcher-wasm/watcher.wasm +0 -0
- package/.output/server/node_modules/@parcel/watcher-wasm/wrapper.js +88 -0
- package/.output/server/node_modules/@unagents/messenger-broker/dist/index.mjs +12 -0
- package/.output/server/node_modules/@unagents/messenger-broker/dist/shared/messenger-broker.B8W77sqB.mjs +1177 -0
- package/.output/server/node_modules/@unagents/messenger-broker/package.json +37 -0
- package/.output/server/node_modules/@unagents/messenger-client/dist/index.mjs +9 -0
- package/.output/server/node_modules/@unagents/messenger-client/dist/shared/messenger-client.CfQVmH_Z.mjs +975 -0
- package/.output/server/node_modules/@unagents/messenger-client/dist/shared/messenger-client.CoDKzubj.mjs +1000 -0
- package/.output/server/node_modules/@unagents/messenger-client/package.json +37 -0
- package/.output/server/node_modules/@unagents/messenger-protocol/dist/index.mjs +103 -0
- package/.output/server/node_modules/@unagents/messenger-protocol/package.json +29 -0
- package/.output/server/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6802 -0
- package/.output/server/node_modules/@vue/compiler-core/package.json +58 -0
- package/.output/server/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +729 -0
- package/.output/server/node_modules/@vue/compiler-dom/package.json +57 -0
- package/.output/server/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +1420 -0
- package/.output/server/node_modules/@vue/compiler-ssr/package.json +34 -0
- package/.output/server/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js +1933 -0
- package/.output/server/node_modules/@vue/reactivity/package.json +55 -0
- package/.output/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js +7085 -0
- package/.output/server/node_modules/@vue/runtime-core/package.json +52 -0
- package/.output/server/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +1917 -0
- package/.output/server/node_modules/@vue/runtime-dom/package.json +60 -0
- package/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js +951 -0
- package/.output/server/node_modules/@vue/server-renderer/package.json +53 -0
- package/.output/server/node_modules/@vue/shared/dist/shared.cjs.prod.js +655 -0
- package/.output/server/node_modules/@vue/shared/package.json +47 -0
- package/.output/server/node_modules/ajv/dist/ajv.js +50 -0
- package/.output/server/node_modules/ajv/dist/compile/codegen/code.js +156 -0
- package/.output/server/node_modules/ajv/dist/compile/codegen/index.js +697 -0
- package/.output/server/node_modules/ajv/dist/compile/codegen/scope.js +143 -0
- package/.output/server/node_modules/ajv/dist/compile/errors.js +123 -0
- package/.output/server/node_modules/ajv/dist/compile/index.js +242 -0
- package/.output/server/node_modules/ajv/dist/compile/names.js +28 -0
- package/.output/server/node_modules/ajv/dist/compile/ref_error.js +12 -0
- package/.output/server/node_modules/ajv/dist/compile/resolve.js +155 -0
- package/.output/server/node_modules/ajv/dist/compile/rules.js +26 -0
- package/.output/server/node_modules/ajv/dist/compile/util.js +178 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/applicability.js +19 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/boolSchema.js +50 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/dataType.js +203 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/defaults.js +35 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/index.js +520 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/keyword.js +124 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/subschema.js +81 -0
- package/.output/server/node_modules/ajv/dist/core.js +618 -0
- package/.output/server/node_modules/ajv/dist/refs/data.json +13 -0
- package/.output/server/node_modules/ajv/dist/refs/json-schema-draft-07.json +151 -0
- package/.output/server/node_modules/ajv/dist/runtime/equal.js +7 -0
- package/.output/server/node_modules/ajv/dist/runtime/ucs2length.js +24 -0
- package/.output/server/node_modules/ajv/dist/runtime/uri.js +6 -0
- package/.output/server/node_modules/ajv/dist/runtime/validation_error.js +11 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +49 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +106 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/allOf.js +23 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +12 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/contains.js +95 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +85 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/if.js +66 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/index.js +44 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/items.js +52 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/items2020.js +30 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/not.js +26 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +60 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +75 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +12 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/properties.js +54 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +38 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +13 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/code.js +131 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/core/id.js +10 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/core/index.js +16 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/core/ref.js +122 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/discriminator/index.js +104 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/discriminator/types.js +9 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/draft7.js +17 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/format/format.js +92 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/format/index.js +6 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/metadata.js +18 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/const.js +25 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/enum.js +48 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/index.js +33 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/limitItems.js +24 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/limitLength.js +27 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +27 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +24 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +26 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/pattern.js +33 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/required.js +79 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +64 -0
- package/.output/server/node_modules/ajv/package.json +126 -0
- package/.output/server/node_modules/ajv-formats/dist/formats.js +208 -0
- package/.output/server/node_modules/ajv-formats/dist/index.js +37 -0
- package/.output/server/node_modules/ajv-formats/dist/limit.js +69 -0
- package/.output/server/node_modules/ajv-formats/package.json +74 -0
- package/.output/server/node_modules/consola/dist/chunks/prompt.mjs +280 -0
- package/.output/server/node_modules/consola/dist/core.mjs +512 -0
- package/.output/server/node_modules/consola/dist/index.mjs +651 -0
- package/.output/server/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +72 -0
- package/.output/server/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +288 -0
- package/.output/server/node_modules/consola/dist/utils.mjs +54 -0
- package/.output/server/node_modules/consola/package.json +136 -0
- package/.output/server/node_modules/content-type/index.js +225 -0
- package/.output/server/node_modules/content-type/package.json +42 -0
- package/.output/server/node_modules/cookie-es/dist/index.mjs +268 -0
- package/.output/server/node_modules/cookie-es/package.json +46 -0
- package/.output/server/node_modules/crossws/dist/_chunks/_request.mjs +83 -0
- package/.output/server/node_modules/crossws/dist/_chunks/adapter.mjs +234 -0
- package/.output/server/node_modules/crossws/dist/_chunks/error.mjs +7 -0
- package/.output/server/node_modules/crossws/dist/_chunks/libs/ws.mjs +6 -0
- package/.output/server/node_modules/crossws/dist/_chunks/node.mjs +220 -0
- package/.output/server/node_modules/crossws/dist/_chunks/peer.mjs +208 -0
- package/.output/server/node_modules/crossws/dist/adapters/node.mjs +1 -0
- package/.output/server/node_modules/crossws/package.json +115 -0
- package/.output/server/node_modules/defu/dist/defu.mjs +69 -0
- package/.output/server/node_modules/defu/package.json +48 -0
- package/.output/server/node_modules/destr/dist/index.mjs +72 -0
- package/.output/server/node_modules/destr/package.json +47 -0
- package/.output/server/node_modules/devalue/index.js +17 -0
- package/.output/server/node_modules/devalue/package.json +39 -0
- package/.output/server/node_modules/devalue/src/base64.js +60 -0
- package/.output/server/node_modules/devalue/src/constants.js +12 -0
- package/.output/server/node_modules/devalue/src/operations.js +221 -0
- package/.output/server/node_modules/devalue/src/parse.js +279 -0
- package/.output/server/node_modules/devalue/src/stringify.js +433 -0
- package/.output/server/node_modules/devalue/src/uneval.js +698 -0
- package/.output/server/node_modules/devalue/src/utils.js +190 -0
- package/.output/server/node_modules/entities/dist/commonjs/decode-codepoint.js +77 -0
- package/.output/server/node_modules/entities/dist/commonjs/decode.js +568 -0
- package/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-html.js +7 -0
- package/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-xml.js +7 -0
- package/.output/server/node_modules/entities/dist/commonjs/internal/bin-trie-flags.js +21 -0
- package/.output/server/node_modules/entities/dist/commonjs/internal/decode-shared.js +31 -0
- package/.output/server/node_modules/entities/dist/commonjs/package.json +3 -0
- package/.output/server/node_modules/entities/package.json +120 -0
- package/.output/server/node_modules/estree-walker/dist/umd/estree-walker.js +344 -0
- package/.output/server/node_modules/estree-walker/package.json +37 -0
- package/.output/server/node_modules/fast-deep-equal/index.js +46 -0
- package/.output/server/node_modules/fast-deep-equal/package.json +61 -0
- package/.output/server/node_modules/fast-uri/index.js +711 -0
- package/.output/server/node_modules/fast-uri/lib/schemes.js +272 -0
- package/.output/server/node_modules/fast-uri/lib/utils.js +799 -0
- package/.output/server/node_modules/fast-uri/package.json +68 -0
- package/.output/server/node_modules/get-port-please/dist/index.mjs +430 -0
- package/.output/server/node_modules/get-port-please/package.json +39 -0
- package/.output/server/node_modules/h3/dist/index.mjs +2498 -0
- package/.output/server/node_modules/h3/package.json +75 -0
- package/.output/server/node_modules/hookable/dist/index.mjs +257 -0
- package/.output/server/node_modules/hookable/package.json +54 -0
- package/.output/server/node_modules/http-shutdown/index.js +85 -0
- package/.output/server/node_modules/http-shutdown/package.json +32 -0
- package/.output/server/node_modules/iron-webcrypto/dist/index.js +298 -0
- package/.output/server/node_modules/iron-webcrypto/package.json +72 -0
- package/.output/server/node_modules/is-extglob/index.js +20 -0
- package/.output/server/node_modules/is-extglob/package.json +69 -0
- package/.output/server/node_modules/is-glob/index.js +150 -0
- package/.output/server/node_modules/is-glob/package.json +81 -0
- package/.output/server/node_modules/jiti/dist/jiti.cjs +1 -0
- package/.output/server/node_modules/jiti/lib/jiti.mjs +29 -0
- package/.output/server/node_modules/jiti/package.json +146 -0
- package/.output/server/node_modules/json-schema-traverse/index.js +93 -0
- package/.output/server/node_modules/json-schema-traverse/package.json +43 -0
- package/.output/server/node_modules/listhen/dist/chunks/xdg-open.mjs +1069 -0
- package/.output/server/node_modules/listhen/dist/index.mjs +19 -0
- package/.output/server/node_modules/listhen/dist/shared/listhen.tqe5I1Rl.mjs +1040 -0
- package/.output/server/node_modules/listhen/package.json +84 -0
- package/.output/server/node_modules/napi-wasm/index.mjs +1371 -0
- package/.output/server/node_modules/napi-wasm/package.json +33 -0
- package/.output/server/node_modules/node-forge/lib/aes.js +1091 -0
- package/.output/server/node_modules/node-forge/lib/aesCipherSuites.js +282 -0
- package/.output/server/node_modules/node-forge/lib/asn1-validator.js +91 -0
- package/.output/server/node_modules/node-forge/lib/asn1.js +1522 -0
- package/.output/server/node_modules/node-forge/lib/baseN.js +186 -0
- package/.output/server/node_modules/node-forge/lib/cipher.js +230 -0
- package/.output/server/node_modules/node-forge/lib/cipherModes.js +1027 -0
- package/.output/server/node_modules/node-forge/lib/des.js +496 -0
- package/.output/server/node_modules/node-forge/lib/ed25519.js +1091 -0
- package/.output/server/node_modules/node-forge/lib/forge.js +13 -0
- package/.output/server/node_modules/node-forge/lib/hmac.js +146 -0
- package/.output/server/node_modules/node-forge/lib/index.js +33 -0
- package/.output/server/node_modules/node-forge/lib/jsbn.js +1294 -0
- package/.output/server/node_modules/node-forge/lib/kem.js +168 -0
- package/.output/server/node_modules/node-forge/lib/log.js +319 -0
- package/.output/server/node_modules/node-forge/lib/md.all.js +13 -0
- package/.output/server/node_modules/node-forge/lib/md.js +11 -0
- package/.output/server/node_modules/node-forge/lib/md5.js +289 -0
- package/.output/server/node_modules/node-forge/lib/mgf.js +12 -0
- package/.output/server/node_modules/node-forge/lib/mgf1.js +57 -0
- package/.output/server/node_modules/node-forge/lib/oids.js +180 -0
- package/.output/server/node_modules/node-forge/lib/pbe.js +1029 -0
- package/.output/server/node_modules/node-forge/lib/pbkdf2.js +211 -0
- package/.output/server/node_modules/node-forge/lib/pem.js +413 -0
- package/.output/server/node_modules/node-forge/lib/pkcs1.js +276 -0
- package/.output/server/node_modules/node-forge/lib/pkcs12.js +1081 -0
- package/.output/server/node_modules/node-forge/lib/pkcs7.js +1260 -0
- package/.output/server/node_modules/node-forge/lib/pkcs7asn1.js +410 -0
- package/.output/server/node_modules/node-forge/lib/pki.js +102 -0
- package/.output/server/node_modules/node-forge/lib/prime.js +297 -0
- package/.output/server/node_modules/node-forge/lib/prng.js +419 -0
- package/.output/server/node_modules/node-forge/lib/pss.js +241 -0
- package/.output/server/node_modules/node-forge/lib/random.js +191 -0
- package/.output/server/node_modules/node-forge/lib/rc2.js +410 -0
- package/.output/server/node_modules/node-forge/lib/rsa.js +2014 -0
- package/.output/server/node_modules/node-forge/lib/sha1.js +319 -0
- package/.output/server/node_modules/node-forge/lib/sha256.js +327 -0
- package/.output/server/node_modules/node-forge/lib/sha512.js +561 -0
- package/.output/server/node_modules/node-forge/lib/ssh.js +236 -0
- package/.output/server/node_modules/node-forge/lib/tls.js +4334 -0
- package/.output/server/node_modules/node-forge/lib/util.js +2652 -0
- package/.output/server/node_modules/node-forge/lib/x509.js +3257 -0
- package/.output/server/node_modules/node-forge/package.json +123 -0
- package/.output/server/node_modules/node-mock-http/dist/_polyfill/buffer/node.mjs +1 -0
- package/.output/server/node_modules/node-mock-http/dist/_polyfill/events/node.mjs +1 -0
- package/.output/server/node_modules/node-mock-http/dist/index.mjs +1 -0
- package/.output/server/node_modules/node-mock-http/package.json +63 -0
- package/.output/server/node_modules/nostics/dist/formatters/ansi.mjs +19 -0
- package/.output/server/node_modules/nostics/dist/index.mjs +194 -0
- package/.output/server/node_modules/nostics/package.json +126 -0
- package/.output/server/node_modules/pathe/dist/index.mjs +19 -0
- package/.output/server/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +249 -0
- package/.output/server/node_modules/pathe/package.json +61 -0
- package/.output/server/node_modules/picomatch/index.js +17 -0
- package/.output/server/node_modules/picomatch/lib/constants.js +184 -0
- package/.output/server/node_modules/picomatch/lib/parse.js +1425 -0
- package/.output/server/node_modules/picomatch/lib/picomatch.js +361 -0
- package/.output/server/node_modules/picomatch/lib/scan.js +403 -0
- package/.output/server/node_modules/picomatch/lib/utils.js +72 -0
- package/.output/server/node_modules/picomatch/package.json +83 -0
- package/.output/server/node_modules/radix3/dist/index.mjs +262 -0
- package/.output/server/node_modules/radix3/package.json +52 -0
- package/.output/server/node_modules/source-map-js/lib/array-set.js +121 -0
- package/.output/server/node_modules/source-map-js/lib/base64-vlq.js +140 -0
- package/.output/server/node_modules/source-map-js/lib/base64.js +67 -0
- package/.output/server/node_modules/source-map-js/lib/binary-search.js +111 -0
- package/.output/server/node_modules/source-map-js/lib/mapping-list.js +79 -0
- package/.output/server/node_modules/source-map-js/lib/quick-sort.js +141 -0
- package/.output/server/node_modules/source-map-js/lib/source-map-consumer.js +1236 -0
- package/.output/server/node_modules/source-map-js/lib/source-map-generator.js +446 -0
- package/.output/server/node_modules/source-map-js/lib/source-node.js +420 -0
- package/.output/server/node_modules/source-map-js/lib/util.js +594 -0
- package/.output/server/node_modules/source-map-js/package.json +71 -0
- package/.output/server/node_modules/source-map-js/source-map.js +8 -0
- package/.output/server/node_modules/std-env/dist/index.mjs +1 -0
- package/.output/server/node_modules/std-env/package.json +43 -0
- package/.output/server/node_modules/tinyclip/dist/index.js +143 -0
- package/.output/server/node_modules/tinyclip/package.json +48 -0
- package/.output/server/node_modules/ufo/dist/index.mjs +645 -0
- package/.output/server/node_modules/ufo/package.json +48 -0
- package/.output/server/node_modules/uncrypto/dist/crypto.node.mjs +16 -0
- package/.output/server/node_modules/uncrypto/package.json +60 -0
- package/.output/server/node_modules/unhead/dist/client.mjs +22 -0
- package/.output/server/node_modules/unhead/dist/legacy.mjs +33 -0
- package/.output/server/node_modules/unhead/dist/minify.mjs +183 -0
- package/.output/server/node_modules/unhead/dist/parser.mjs +518 -0
- package/.output/server/node_modules/unhead/dist/plugins.mjs +782 -0
- package/.output/server/node_modules/unhead/dist/server.mjs +99 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.BEmVMkeA.mjs +673 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.Bf_fPVYA.mjs +6 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.Bm4Y6XQI.mjs +17 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.C5Bksi2B.mjs +49 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.CGPOfp5O.mjs +32 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.CHEy9ana.mjs +7 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.C_7zwq8E.mjs +11 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.CaeaMM5q.mjs +19 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.D7HkBzZn.mjs +59 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.D9VfQWNo.mjs +240 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DD4N5B4k.mjs +224 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DGl9jcjg.mjs +196 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DJuZwX9c.mjs +400 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DkxnqlHC.mjs +264 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DspMpm6y.mjs +48 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.o8j9utSy.mjs +208 -0
- package/.output/server/node_modules/unhead/dist/stream/client.mjs +33 -0
- package/.output/server/node_modules/unhead/dist/stream/iife.mjs +2 -0
- package/.output/server/node_modules/unhead/dist/stream/server.mjs +446 -0
- package/.output/server/node_modules/unhead/dist/utils.mjs +7 -0
- package/.output/server/node_modules/unhead/package.json +179 -0
- package/.output/server/node_modules/untun/dist/_chunks/cloudflared.mjs +179 -0
- package/.output/server/node_modules/untun/dist/_chunks/log.mjs +27 -0
- package/.output/server/node_modules/untun/dist/index.mjs +47 -0
- package/.output/server/node_modules/untun/package.json +44 -0
- package/.output/server/node_modules/uqr/dist/index.mjs +739 -0
- package/.output/server/node_modules/uqr/package.json +69 -0
- package/.output/server/node_modules/vue/dist/vue.cjs.js +80 -0
- package/.output/server/node_modules/vue/dist/vue.cjs.prod.js +66 -0
- package/.output/server/node_modules/vue/index.js +7 -0
- package/.output/server/node_modules/vue/index.mjs +1 -0
- package/.output/server/node_modules/vue/package.json +112 -0
- package/.output/server/node_modules/vue/server-renderer/index.mjs +1 -0
- package/.output/server/node_modules/vue-bundle-renderer/dist/runtime.mjs +687 -0
- package/.output/server/node_modules/vue-bundle-renderer/package.json +66 -0
- package/.output/server/node_modules/zod/index.js +7 -0
- package/.output/server/node_modules/zod/package.json +147 -0
- package/.output/server/node_modules/zod/v3/ZodError.js +143 -0
- package/.output/server/node_modules/zod/v3/errors.js +9 -0
- package/.output/server/node_modules/zod/v3/external.js +6 -0
- package/.output/server/node_modules/zod/v3/helpers/errorUtil.js +6 -0
- package/.output/server/node_modules/zod/v3/helpers/parseUtil.js +109 -0
- package/.output/server/node_modules/zod/v3/helpers/typeAliases.js +1 -0
- package/.output/server/node_modules/zod/v3/helpers/util.js +133 -0
- package/.output/server/node_modules/zod/v3/index.js +4 -0
- package/.output/server/node_modules/zod/v3/locales/en.js +109 -0
- package/.output/server/node_modules/zod/v3/package.json +7 -0
- package/.output/server/node_modules/zod/v3/types.js +3697 -0
- package/.output/server/node_modules/zod/v4/classic/checks.js +1 -0
- package/.output/server/node_modules/zod/v4/classic/coerce.js +17 -0
- package/.output/server/node_modules/zod/v4/classic/compat.js +31 -0
- package/.output/server/node_modules/zod/v4/classic/deep-partial.js +13 -0
- package/.output/server/node_modules/zod/v4/classic/errors.js +57 -0
- package/.output/server/node_modules/zod/v4/classic/external.js +17 -0
- package/.output/server/node_modules/zod/v4/classic/from-json-schema.js +881 -0
- package/.output/server/node_modules/zod/v4/classic/in-out.js +36 -0
- package/.output/server/node_modules/zod/v4/classic/index.js +4 -0
- package/.output/server/node_modules/zod/v4/classic/iso.js +15 -0
- package/.output/server/node_modules/zod/v4/classic/package.json +7 -0
- package/.output/server/node_modules/zod/v4/classic/parse.js +16 -0
- package/.output/server/node_modules/zod/v4/classic/schemas.js +1535 -0
- package/.output/server/node_modules/zod/v4/core/api.js +1107 -0
- package/.output/server/node_modules/zod/v4/core/checks.js +516 -0
- package/.output/server/node_modules/zod/v4/core/compile.js +1866 -0
- package/.output/server/node_modules/zod/v4/core/core.js +141 -0
- package/.output/server/node_modules/zod/v4/core/doc.js +38 -0
- package/.output/server/node_modules/zod/v4/core/errors.js +267 -0
- package/.output/server/node_modules/zod/v4/core/index.js +19 -0
- package/.output/server/node_modules/zod/v4/core/json-schema-generator.js +99 -0
- package/.output/server/node_modules/zod/v4/core/json-schema-processors.js +843 -0
- package/.output/server/node_modules/zod/v4/core/json-schema.js +1 -0
- package/.output/server/node_modules/zod/v4/core/memoizer.js +311 -0
- package/.output/server/node_modules/zod/v4/core/package.json +7 -0
- package/.output/server/node_modules/zod/v4/core/parse.js +175 -0
- package/.output/server/node_modules/zod/v4/core/regexes.js +156 -0
- package/.output/server/node_modules/zod/v4/core/registries.js +51 -0
- package/.output/server/node_modules/zod/v4/core/schemas.js +2636 -0
- package/.output/server/node_modules/zod/v4/core/to-json-schema.js +651 -0
- package/.output/server/node_modules/zod/v4/core/util.js +873 -0
- package/.output/server/node_modules/zod/v4/core/versions.js +5 -0
- package/.output/server/node_modules/zod/v4/core/visit.js +169 -0
- package/.output/server/node_modules/zod/v4/index.js +4 -0
- package/.output/server/node_modules/zod/v4/locales/ar.js +111 -0
- package/.output/server/node_modules/zod/v4/locales/az.js +110 -0
- package/.output/server/node_modules/zod/v4/locales/be.js +168 -0
- package/.output/server/node_modules/zod/v4/locales/bg.js +125 -0
- package/.output/server/node_modules/zod/v4/locales/bn.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/ca.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/ckb.js +133 -0
- package/.output/server/node_modules/zod/v4/locales/cs.js +116 -0
- package/.output/server/node_modules/zod/v4/locales/da.js +120 -0
- package/.output/server/node_modules/zod/v4/locales/de.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/el.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/en.js +125 -0
- package/.output/server/node_modules/zod/v4/locales/eo.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/es.js +136 -0
- package/.output/server/node_modules/zod/v4/locales/fa.js +119 -0
- package/.output/server/node_modules/zod/v4/locales/fi.js +117 -0
- package/.output/server/node_modules/zod/v4/locales/fr-CA.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/fr.js +129 -0
- package/.output/server/node_modules/zod/v4/locales/gu.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/he.js +221 -0
- package/.output/server/node_modules/zod/v4/locales/hi.js +111 -0
- package/.output/server/node_modules/zod/v4/locales/hr.js +126 -0
- package/.output/server/node_modules/zod/v4/locales/hu.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/hy.js +158 -0
- package/.output/server/node_modules/zod/v4/locales/id.js +111 -0
- package/.output/server/node_modules/zod/v4/locales/index.js +63 -0
- package/.output/server/node_modules/zod/v4/locales/is.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/it.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/ja.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/ka.js +117 -0
- package/.output/server/node_modules/zod/v4/locales/kh.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/km.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/kn.js +116 -0
- package/.output/server/node_modules/zod/v4/locales/ko.js +116 -0
- package/.output/server/node_modules/zod/v4/locales/lt.js +207 -0
- package/.output/server/node_modules/zod/v4/locales/mk.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/ms.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/ne.js +111 -0
- package/.output/server/node_modules/zod/v4/locales/nl.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/nn.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/no.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/ota.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/package.json +7 -0
- package/.output/server/node_modules/zod/v4/locales/pl.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/ps.js +119 -0
- package/.output/server/node_modules/zod/v4/locales/pt-BR.js +143 -0
- package/.output/server/node_modules/zod/v4/locales/pt.js +142 -0
- package/.output/server/node_modules/zod/v4/locales/ro.js +122 -0
- package/.output/server/node_modules/zod/v4/locales/ru.js +168 -0
- package/.output/server/node_modules/zod/v4/locales/sk.js +116 -0
- package/.output/server/node_modules/zod/v4/locales/sl.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/sv.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/ta.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/tg.js +117 -0
- package/.output/server/node_modules/zod/v4/locales/th.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/tk.js +107 -0
- package/.output/server/node_modules/zod/v4/locales/tr.js +110 -0
- package/.output/server/node_modules/zod/v4/locales/ua.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/uk.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/ur.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/uz.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/vi.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/yo.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/zh-CN.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/zh-TW.js +112 -0
- package/.output/server/node_modules/zod/v4/mini/checks.js +1 -0
- package/.output/server/node_modules/zod/v4/mini/coerce.js +22 -0
- package/.output/server/node_modules/zod/v4/mini/deep-partial.js +13 -0
- package/.output/server/node_modules/zod/v4/mini/external.js +16 -0
- package/.output/server/node_modules/zod/v4/mini/in-out.js +36 -0
- package/.output/server/node_modules/zod/v4/mini/iso.js +34 -0
- package/.output/server/node_modules/zod/v4/mini/package.json +7 -0
- package/.output/server/node_modules/zod/v4/mini/parse.js +1 -0
- package/.output/server/node_modules/zod/v4/mini/schemas.js +1002 -0
- package/.output/server/node_modules/zod/v4/package.json +7 -0
- package/.output/server/node_modules/zod/v4-mini/index.js +3 -0
- package/.output/server/node_modules/zod/v4-mini/package.json +7 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/Options.js +46 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/Refs.js +22 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/errorMessages.js +14 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js +8 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/index.js +40 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/package.json +1 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parseDef.js +62 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parseTypes.js +1 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/any.js +17 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/array.js +26 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js +49 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js +5 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js +4 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js +4 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/date.js +46 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/default.js +7 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js +7 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js +6 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js +52 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js +21 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/map.js +26 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js +16 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/never.js +11 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/null.js +10 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js +33 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/number.js +52 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/object.js +72 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js +21 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js +20 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js +4 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js +4 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/record.js +61 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/set.js +20 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +352 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js +32 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js +6 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/union.js +80 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js +4 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/selectParser.js +105 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js +87 -0
- package/.output/server/node_modules/zod-to-json-schema/package.json +85 -0
- package/.output/server/package.json +64 -0
- package/README.md +227 -24
- package/bin/bantou.mjs +33 -0
- package/package.json +18 -8
- package/protocol/PROTOCOL.md +26 -0
- package/protocol/protocol.json +92 -0
- package/dist/cap.js +0 -7
- package/dist/cli.js +0 -27
- package/dist/config.js +0 -23
- package/dist/daemon.js +0 -23
- package/dist/session.js +0 -7
- package/dist/workspace.js +0 -8
|
@@ -0,0 +1,975 @@
|
|
|
1
|
+
import { existsSync, statSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import * as crypto from 'node:crypto';
|
|
4
|
+
|
|
5
|
+
const DEFAULT_HTTP_PORT = 7901;
|
|
6
|
+
const DEFAULT_DISCOVERY_PORT = 7902;
|
|
7
|
+
const DEFAULT_DISCOVERY_TIMEOUT_MS = 1e3;
|
|
8
|
+
const HEARTBEAT_INTERVAL_MS = 15e3;
|
|
9
|
+
const POLL_INTERVAL_MS = 1e3;
|
|
10
|
+
const LOCAL_HOSTS = ["127.0.0.1", "localhost", "::1"];
|
|
11
|
+
const ENV = {
|
|
12
|
+
HOST: "AGENT_MESSENGER_HOST",
|
|
13
|
+
PORT: "AGENT_MESSENGER_PORT",
|
|
14
|
+
BIND: "AGENT_MESSENGER_BIND",
|
|
15
|
+
TOKEN: "AGENT_MESSENGER_TOKEN",
|
|
16
|
+
NAME: "AGENT_MESSENGER_NAME",
|
|
17
|
+
BROKER_ID: "AGENT_MESSENGER_BROKER_ID",
|
|
18
|
+
STATE: "AGENT_MESSENGER_STATE",
|
|
19
|
+
CONFIG: "AGENT_MESSENGER_CONFIG",
|
|
20
|
+
DISCOVERY: "AGENT_MESSENGER_DISCOVERY",
|
|
21
|
+
DISCOVERY_PORT: "AGENT_MESSENGER_DISCOVERY_PORT",
|
|
22
|
+
DISCOVERY_ADDR: "AGENT_MESSENGER_DISCOVERY_ADDR",
|
|
23
|
+
DISCOVERY_TIMEOUT_MS: "AGENT_MESSENGER_DISCOVERY_TIMEOUT_MS",
|
|
24
|
+
HEARTBEAT_MS: "AGENT_MESSENGER_HEARTBEAT_MS",
|
|
25
|
+
DELIVERY: "AGENT_MESSENGER_DELIVERY"
|
|
26
|
+
};
|
|
27
|
+
const BROKER_CMD_ENV = "AGENT_MESSENGER_BROKER_CMD";
|
|
28
|
+
const DEFAULT_BROKER_CMD = "npx -y @unagents/messenger broker";
|
|
29
|
+
const FALLBACK_ENV = "AGENT_MESSENGER_FALLBACK";
|
|
30
|
+
const GRACE_MS_ENV = "AGENT_MESSENGER_GRACE_MS";
|
|
31
|
+
const DEFAULT_GRACE_MS = 3e4;
|
|
32
|
+
const RESOLVE_RETRY_MS = 5e3;
|
|
33
|
+
const SESSION_SOCKET_ENV = "CLAUDE_CODE_MESSAGING_SOCKET";
|
|
34
|
+
const SESSION_TOKEN_ENV = "CLAUDE_CODE_MESSAGING_TOKEN";
|
|
35
|
+
const HEALTH_ROUTE = "/health";
|
|
36
|
+
const DISCOVERY_KEY = "agent-messenger";
|
|
37
|
+
const DISCOVERY_PROBE_VALUE = "probe";
|
|
38
|
+
const DISCOVERY_REPLY_VALUE = "broker";
|
|
39
|
+
const DISCOVERY_BROADCAST_ADDR = "255.255.255.255";
|
|
40
|
+
const PROTOCOL_MANIFEST_MAX_BYTES = 64 * 1024;
|
|
41
|
+
const PROTOCOL_DOC_MAX_BYTES = 64 * 1024;
|
|
42
|
+
const PROTOCOL_TOTAL_MAX_BYTES = 128 * 1024;
|
|
43
|
+
const PROTOCOL_META_MAX_LENGTH = 128;
|
|
44
|
+
const PROTOCOL_NAME_PATTERN = /^[a-z0-9][a-z0-9._-]{0,63}$/;
|
|
45
|
+
|
|
46
|
+
function protocolError(code, detail) {
|
|
47
|
+
const e = new Error(`${code}: ${detail}`);
|
|
48
|
+
e.code = code;
|
|
49
|
+
return e;
|
|
50
|
+
}
|
|
51
|
+
function protocolErrorCode(e) {
|
|
52
|
+
if (e instanceof Error) {
|
|
53
|
+
const c = e.code;
|
|
54
|
+
if (typeof c === "string" && e.message.startsWith(`${c}: `)) return c;
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
function errorMessage$1(e) {
|
|
59
|
+
return e instanceof Error ? e.message : String(e);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function canonicalJSON(value) {
|
|
63
|
+
if (value === null || typeof value !== "object") {
|
|
64
|
+
return JSON.stringify(value) ?? "null";
|
|
65
|
+
}
|
|
66
|
+
if (Array.isArray(value)) {
|
|
67
|
+
return `[${value.map((v) => canonicalJSON(v)).join(",")}]`;
|
|
68
|
+
}
|
|
69
|
+
const obj = value;
|
|
70
|
+
const parts = [];
|
|
71
|
+
for (const k of Object.keys(obj).sort()) {
|
|
72
|
+
const v = obj[k];
|
|
73
|
+
if (v === void 0 || typeof v === "function" || typeof v === "symbol") continue;
|
|
74
|
+
parts.push(`${JSON.stringify(k)}:${canonicalJSON(v)}`);
|
|
75
|
+
}
|
|
76
|
+
return `{${parts.join(",")}}`;
|
|
77
|
+
}
|
|
78
|
+
function protocolHash(manifest, doc) {
|
|
79
|
+
return crypto.createHash("sha256").update(canonicalJSON({ manifest, doc })).digest("hex");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function normalizeVersion(v) {
|
|
83
|
+
const t = v.trim();
|
|
84
|
+
return t.startsWith("v") ? t.slice(1) : t;
|
|
85
|
+
}
|
|
86
|
+
function isNumeric(s) {
|
|
87
|
+
return /^[0-9]+$/.test(s);
|
|
88
|
+
}
|
|
89
|
+
function noLeadingZero(s) {
|
|
90
|
+
return s.length === 1 || s.charAt(0) !== "0";
|
|
91
|
+
}
|
|
92
|
+
function parseSemver(v) {
|
|
93
|
+
let rest = v;
|
|
94
|
+
const plus = rest.indexOf("+");
|
|
95
|
+
if (plus !== -1) {
|
|
96
|
+
const build = rest.slice(plus + 1);
|
|
97
|
+
if (build === "") return null;
|
|
98
|
+
for (const id of build.split(".")) if (!/^[0-9A-Za-z-]+$/.test(id)) return null;
|
|
99
|
+
rest = rest.slice(0, plus);
|
|
100
|
+
}
|
|
101
|
+
let pre = [];
|
|
102
|
+
const dash = rest.indexOf("-");
|
|
103
|
+
if (dash !== -1) {
|
|
104
|
+
const p = rest.slice(dash + 1);
|
|
105
|
+
if (p === "") return null;
|
|
106
|
+
pre = p.split(".");
|
|
107
|
+
for (const id of pre) {
|
|
108
|
+
if (!/^[0-9A-Za-z-]+$/.test(id)) return null;
|
|
109
|
+
if (isNumeric(id) && !noLeadingZero(id)) return null;
|
|
110
|
+
}
|
|
111
|
+
rest = rest.slice(0, dash);
|
|
112
|
+
}
|
|
113
|
+
const nums = rest.split(".");
|
|
114
|
+
if (nums.length !== 3) return null;
|
|
115
|
+
for (const n of nums) if (!isNumeric(n) || !noLeadingZero(n)) return null;
|
|
116
|
+
return { major: nums[0], minor: nums[1], patch: nums[2], pre };
|
|
117
|
+
}
|
|
118
|
+
function cmpDigits(a, b) {
|
|
119
|
+
if (a.length !== b.length) return a.length < b.length ? -1 : 1;
|
|
120
|
+
return a === b ? 0 : a < b ? -1 : 1;
|
|
121
|
+
}
|
|
122
|
+
function compareSemver(a, b) {
|
|
123
|
+
let c = cmpDigits(a.major, b.major);
|
|
124
|
+
if (c !== 0) return c;
|
|
125
|
+
c = cmpDigits(a.minor, b.minor);
|
|
126
|
+
if (c !== 0) return c;
|
|
127
|
+
c = cmpDigits(a.patch, b.patch);
|
|
128
|
+
if (c !== 0) return c;
|
|
129
|
+
if (a.pre.length === 0 && b.pre.length === 0) return 0;
|
|
130
|
+
if (a.pre.length === 0) return 1;
|
|
131
|
+
if (b.pre.length === 0) return -1;
|
|
132
|
+
const n = Math.min(a.pre.length, b.pre.length);
|
|
133
|
+
for (let i = 0; i < n; i++) {
|
|
134
|
+
const x = a.pre[i];
|
|
135
|
+
const y = b.pre[i];
|
|
136
|
+
const nx = isNumeric(x);
|
|
137
|
+
const ny = isNumeric(y);
|
|
138
|
+
if (nx && ny) {
|
|
139
|
+
c = cmpDigits(x, y);
|
|
140
|
+
if (c !== 0) return c;
|
|
141
|
+
} else if (nx !== ny) {
|
|
142
|
+
return nx ? -1 : 1;
|
|
143
|
+
} else if (x !== y) {
|
|
144
|
+
return x < y ? -1 : 1;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return a.pre.length === b.pre.length ? 0 : a.pre.length < b.pre.length ? -1 : 1;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const FETCH_TIMEOUT_MS = 15e3;
|
|
151
|
+
const defaultFetcher = (url) => new Promise((resolve, reject) => {
|
|
152
|
+
const timer = setTimeout(() => reject(new Error(`timeout after ${FETCH_TIMEOUT_MS}ms`)), FETCH_TIMEOUT_MS);
|
|
153
|
+
fetch(url).then(async (res) => {
|
|
154
|
+
const text = await res.text();
|
|
155
|
+
clearTimeout(timer);
|
|
156
|
+
resolve({ status: res.status, text });
|
|
157
|
+
}).catch((e) => {
|
|
158
|
+
clearTimeout(timer);
|
|
159
|
+
reject(e instanceof Error ? e : new Error(String(e)));
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
const ACCEPTED = "https://github.com/<owner>/<repo>, <owner>/<repo>, github:<owner>/<repo>, gitea:<base-url>/<owner>/<repo>, https://<gitea-host>/<owner>/<repo>, /abs/path, ./rel/path, file:///abs/path";
|
|
163
|
+
function unsupported(arg, why = "") {
|
|
164
|
+
return protocolError("UNSUPPORTED_REPO", `cannot use "${arg}" as a protocol repo${why ? ` (${why})` : ""}. Accepted forms: ${ACCEPTED}`);
|
|
165
|
+
}
|
|
166
|
+
const NAME_PART = /^[A-Za-z0-9_.-]+$/;
|
|
167
|
+
function normalizePath(p) {
|
|
168
|
+
const stack = [];
|
|
169
|
+
for (const seg of p.split("/")) {
|
|
170
|
+
if (seg === "" || seg === ".") continue;
|
|
171
|
+
if (seg === "..") stack.pop();
|
|
172
|
+
else stack.push(seg);
|
|
173
|
+
}
|
|
174
|
+
return "/" + stack.join("/");
|
|
175
|
+
}
|
|
176
|
+
function local(dir) {
|
|
177
|
+
const d = normalizePath(dir);
|
|
178
|
+
return { kind: "local", dir: d, source: `file:${d}` };
|
|
179
|
+
}
|
|
180
|
+
function cleanRepoName(r) {
|
|
181
|
+
return r.length > 4 && r.endsWith(".git") ? r.slice(0, r.length - 4) : r;
|
|
182
|
+
}
|
|
183
|
+
function github(owner, repo, arg) {
|
|
184
|
+
const r = cleanRepoName(repo);
|
|
185
|
+
if (!NAME_PART.test(owner) || !NAME_PART.test(r)) throw unsupported(arg, "owner / repo contain unsupported characters");
|
|
186
|
+
return { kind: "github", owner, repo: r, source: `github:${owner}/${r}` };
|
|
187
|
+
}
|
|
188
|
+
function parseHttp(s, allowHttp, arg) {
|
|
189
|
+
let u;
|
|
190
|
+
try {
|
|
191
|
+
u = new URL(s);
|
|
192
|
+
} catch {
|
|
193
|
+
throw unsupported(arg, "not a URL");
|
|
194
|
+
}
|
|
195
|
+
if (u.protocol !== "https:" && !(allowHttp && u.protocol === "http:")) throw unsupported(arg, "https is required");
|
|
196
|
+
return { host: u.host, protocol: u.protocol, segs: u.pathname.split("/").filter((x) => x !== "") };
|
|
197
|
+
}
|
|
198
|
+
function gitea(s, allowHttp, verified, arg) {
|
|
199
|
+
const { host, protocol, segs } = parseHttp(s, allowHttp, arg);
|
|
200
|
+
if (segs.length < 2) throw unsupported(arg, "expected <base-url>/<owner>/<repo>");
|
|
201
|
+
const owner = segs[segs.length - 2];
|
|
202
|
+
const repo = cleanRepoName(segs[segs.length - 1]);
|
|
203
|
+
if (!NAME_PART.test(owner) || !NAME_PART.test(repo)) throw unsupported(arg, "owner / repo contain unsupported characters");
|
|
204
|
+
const prefix = segs.length > 2 ? `/${segs.slice(0, segs.length - 2).join("/")}` : "";
|
|
205
|
+
const base = `${protocol}//${host}${prefix}`;
|
|
206
|
+
return { kind: "gitea", base, owner, repo, source: `gitea:${base}/${owner}/${repo}`, verified };
|
|
207
|
+
}
|
|
208
|
+
function parseRepoArg(arg, cwd) {
|
|
209
|
+
const s = arg.trim();
|
|
210
|
+
if (s === "") throw unsupported(arg, "empty");
|
|
211
|
+
if (s.startsWith("file://")) {
|
|
212
|
+
const p = s.slice(7);
|
|
213
|
+
if (!p.startsWith("/")) throw unsupported(arg, "file:// needs an absolute path (file:///abs/path)");
|
|
214
|
+
let dir;
|
|
215
|
+
try {
|
|
216
|
+
dir = decodeURIComponent(p);
|
|
217
|
+
} catch {
|
|
218
|
+
throw unsupported(arg, "bad escape in file URL");
|
|
219
|
+
}
|
|
220
|
+
return local(dir);
|
|
221
|
+
}
|
|
222
|
+
if (s.startsWith("/")) return local(s);
|
|
223
|
+
if (s === "." || s === ".." || s.startsWith("./") || s.startsWith("../")) return local(`${cwd}/${s}`);
|
|
224
|
+
if (s.startsWith("github:")) {
|
|
225
|
+
const parts2 = s.slice(7).split("/");
|
|
226
|
+
if (parts2.length !== 2) throw unsupported(arg, "expected github:<owner>/<repo>");
|
|
227
|
+
return github(parts2[0], parts2[1], arg);
|
|
228
|
+
}
|
|
229
|
+
if (s.startsWith("gitea:")) return gitea(s.slice(6), true, true, arg);
|
|
230
|
+
if (s.startsWith("https://") || s.startsWith("http://")) {
|
|
231
|
+
const { host, segs } = parseHttp(s, false, arg);
|
|
232
|
+
if (host === "github.com" || host === "www.github.com") {
|
|
233
|
+
if (segs.length !== 2) throw unsupported(arg, "expected https://github.com/<owner>/<repo>");
|
|
234
|
+
return github(segs[0], segs[1], arg);
|
|
235
|
+
}
|
|
236
|
+
return gitea(s, false, false, arg);
|
|
237
|
+
}
|
|
238
|
+
const parts = s.split("/");
|
|
239
|
+
if (parts.length === 2 && NAME_PART.test(parts[0]) && NAME_PART.test(parts[1])) return github(parts[0], parts[1], arg);
|
|
240
|
+
throw unsupported(arg);
|
|
241
|
+
}
|
|
242
|
+
function apiBase(r) {
|
|
243
|
+
return r.kind === "github" ? "https://api.github.com" : `${r.base}/api/v1`;
|
|
244
|
+
}
|
|
245
|
+
async function fetchText(fetcher, url) {
|
|
246
|
+
try {
|
|
247
|
+
return await fetcher(url);
|
|
248
|
+
} catch (e) {
|
|
249
|
+
throw protocolError("REPO_UNREACHABLE", `${url}: ${errorMessage$1(e)}`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function httpFail(url, status) {
|
|
253
|
+
let hint = "";
|
|
254
|
+
if (status === 401 || status === 403 || status === 404) {
|
|
255
|
+
hint = ` (repository not found or private; private repositories are not supported${status === 403 ? ", or the API rate limit is reached" : ""})`;
|
|
256
|
+
}
|
|
257
|
+
return protocolError("REPO_UNREACHABLE", `${url} returned HTTP ${status}${hint}`);
|
|
258
|
+
}
|
|
259
|
+
async function getJson(fetcher, url) {
|
|
260
|
+
const r = await fetchText(fetcher, url);
|
|
261
|
+
if (r.status < 200 || r.status >= 300) throw httpFail(url, r.status);
|
|
262
|
+
try {
|
|
263
|
+
return JSON.parse(r.text);
|
|
264
|
+
} catch {
|
|
265
|
+
throw protocolError("REPO_UNREACHABLE", `${url} did not return JSON`);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
async function verifyGitea(r, arg, fetcher) {
|
|
269
|
+
const url = `${r.base}/api/v1/version`;
|
|
270
|
+
let res;
|
|
271
|
+
try {
|
|
272
|
+
res = await fetcher(url);
|
|
273
|
+
} catch (e) {
|
|
274
|
+
throw unsupported(arg, `${url} is not reachable: ${errorMessage$1(e)}`);
|
|
275
|
+
}
|
|
276
|
+
let ok = false;
|
|
277
|
+
if (res.status === 200) {
|
|
278
|
+
try {
|
|
279
|
+
const v = JSON.parse(res.text);
|
|
280
|
+
ok = typeof v === "object" && v !== null && typeof v.version === "string";
|
|
281
|
+
} catch {
|
|
282
|
+
ok = false;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (!ok) throw unsupported(arg, `${url} does not answer like Gitea (HTTP ${res.status}); use github:/gitea: or a local path`);
|
|
286
|
+
}
|
|
287
|
+
const MAX_TAG_PAGES = 20;
|
|
288
|
+
async function listTags(r, fetcher) {
|
|
289
|
+
const names = [];
|
|
290
|
+
let prevFirst = "";
|
|
291
|
+
for (let page = 1; page <= MAX_TAG_PAGES; page++) {
|
|
292
|
+
const q = r.kind === "github" ? `per_page=100&page=${page}` : `limit=50&page=${page}`;
|
|
293
|
+
const arr = await getJson(fetcher, `${apiBase(r)}/repos/${r.owner}/${r.repo}/tags?${q}`);
|
|
294
|
+
if (!Array.isArray(arr) || arr.length === 0) break;
|
|
295
|
+
const first = String(arr[0]?.name ?? "");
|
|
296
|
+
if (first === prevFirst) break;
|
|
297
|
+
prevFirst = first;
|
|
298
|
+
for (const t of arr) {
|
|
299
|
+
const n = t?.name;
|
|
300
|
+
if (typeof n === "string") names.push(n);
|
|
301
|
+
}
|
|
302
|
+
if (r.kind === "github" && arr.length < 100) break;
|
|
303
|
+
}
|
|
304
|
+
return names;
|
|
305
|
+
}
|
|
306
|
+
async function headSha(r, fetcher) {
|
|
307
|
+
const api = apiBase(r);
|
|
308
|
+
const info = await getJson(fetcher, `${api}/repos/${r.owner}/${r.repo}`);
|
|
309
|
+
const branch = info?.default_branch;
|
|
310
|
+
if (typeof branch !== "string" || branch === "") {
|
|
311
|
+
throw protocolError("REPO_UNREACHABLE", `${r.source}: the repository info has no default_branch`);
|
|
312
|
+
}
|
|
313
|
+
const commit = await getJson(fetcher, `${api}/repos/${r.owner}/${r.repo}/commits/${encodeURIComponent(branch)}`);
|
|
314
|
+
const sha = commit?.sha;
|
|
315
|
+
if (typeof sha !== "string" || !/^[0-9a-f]{7,64}$/.test(sha)) {
|
|
316
|
+
throw protocolError("REPO_UNREACHABLE", `${r.source}: no commit sha for branch ${branch}`);
|
|
317
|
+
}
|
|
318
|
+
return sha;
|
|
319
|
+
}
|
|
320
|
+
function rawUrl(r, ref, file) {
|
|
321
|
+
if (r.kind === "github") return `https://raw.githubusercontent.com/${r.owner}/${r.repo}/${encodeURIComponent(ref)}/${file}`;
|
|
322
|
+
return `${r.base}/api/v1/repos/${r.owner}/${r.repo}/raw/${file}?ref=${encodeURIComponent(ref)}`;
|
|
323
|
+
}
|
|
324
|
+
async function fetchFile(r, ref, file, fetcher) {
|
|
325
|
+
const url = rawUrl(r, ref, file);
|
|
326
|
+
const res = await fetchText(fetcher, url);
|
|
327
|
+
if (res.status === 404) return null;
|
|
328
|
+
if (res.status < 200 || res.status >= 300) throw httpFail(url, res.status);
|
|
329
|
+
return res.text;
|
|
330
|
+
}
|
|
331
|
+
const RAW_MAX_CHARS = 1024 * 1024;
|
|
332
|
+
function isPlainObject(v) {
|
|
333
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
334
|
+
}
|
|
335
|
+
function invalid(detail) {
|
|
336
|
+
return protocolError("INVALID_DEFINITION", detail);
|
|
337
|
+
}
|
|
338
|
+
function buildLoaded(manifestText, doc, source, ref, ver) {
|
|
339
|
+
if (manifestText.length > RAW_MAX_CHARS) {
|
|
340
|
+
throw protocolError("TOO_LARGE", `protocol.json is over ${RAW_MAX_CHARS} characters (limit ${PROTOCOL_MANIFEST_MAX_BYTES} bytes)`);
|
|
341
|
+
}
|
|
342
|
+
if (doc.length > RAW_MAX_CHARS) {
|
|
343
|
+
throw protocolError("TOO_LARGE", `PROTOCOL.md is over ${RAW_MAX_CHARS} characters (limit ${PROTOCOL_DOC_MAX_BYTES} bytes)`);
|
|
344
|
+
}
|
|
345
|
+
let parsed;
|
|
346
|
+
try {
|
|
347
|
+
parsed = JSON.parse(manifestText);
|
|
348
|
+
} catch (e) {
|
|
349
|
+
throw invalid(`protocol.json is not valid JSON (${errorMessage$1(e)})`);
|
|
350
|
+
}
|
|
351
|
+
if (!isPlainObject(parsed)) throw invalid("protocol.json must be a JSON object");
|
|
352
|
+
const manifest = parsed;
|
|
353
|
+
const name = manifest.name;
|
|
354
|
+
if (typeof name !== "string" || !PROTOCOL_NAME_PATTERN.test(name)) {
|
|
355
|
+
throw invalid(`protocol.json "name" is missing or does not match ${String(PROTOCOL_NAME_PATTERN)}`);
|
|
356
|
+
}
|
|
357
|
+
if (typeof manifest.description !== "string") throw invalid('protocol.json "description" is missing (a string is required)');
|
|
358
|
+
if (manifest.messages !== void 0) {
|
|
359
|
+
if (!isPlainObject(manifest.messages)) throw invalid('protocol.json "messages" must be an object');
|
|
360
|
+
for (const k of Object.keys(manifest.messages)) {
|
|
361
|
+
if (!isPlainObject(manifest.messages[k])) throw invalid(`protocol.json messages.${k} must be an object (JSON Schema)`);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
let version;
|
|
365
|
+
if (ver.mode === "tagless") {
|
|
366
|
+
version = ver.version;
|
|
367
|
+
} else {
|
|
368
|
+
const mv = manifest.version;
|
|
369
|
+
if (typeof mv !== "string" || parseSemver(mv) === null) {
|
|
370
|
+
throw invalid('protocol.json "version" is missing or not a semver (e.g. 1.2.0)');
|
|
371
|
+
}
|
|
372
|
+
if (ver.mode === "tag") {
|
|
373
|
+
if (mv !== ver.version) throw protocolError("VERSION_MISMATCH", `protocol.json version is ${mv} but the tag is ${ver.version}`);
|
|
374
|
+
version = ver.version;
|
|
375
|
+
} else {
|
|
376
|
+
if (ver.requested !== void 0 && normalizeVersion(ver.requested) !== mv) {
|
|
377
|
+
throw protocolError("VERSION_MISMATCH", `version ${ver.requested} was requested but protocol.json (local path) says ${mv}`);
|
|
378
|
+
}
|
|
379
|
+
version = mv;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
const manifestBytes = Buffer.byteLength(JSON.stringify(manifest));
|
|
383
|
+
const docBytes = Buffer.byteLength(doc);
|
|
384
|
+
if (manifestBytes > PROTOCOL_MANIFEST_MAX_BYTES) {
|
|
385
|
+
throw protocolError("TOO_LARGE", `protocol.json is ${manifestBytes} bytes (limit ${PROTOCOL_MANIFEST_MAX_BYTES})`);
|
|
386
|
+
}
|
|
387
|
+
if (docBytes > PROTOCOL_DOC_MAX_BYTES) {
|
|
388
|
+
throw protocolError("TOO_LARGE", `PROTOCOL.md is ${docBytes} bytes (limit ${PROTOCOL_DOC_MAX_BYTES})`);
|
|
389
|
+
}
|
|
390
|
+
if (manifestBytes + docBytes > PROTOCOL_TOTAL_MAX_BYTES) {
|
|
391
|
+
throw protocolError("TOO_LARGE", `the definition is ${manifestBytes + docBytes} bytes (limit ${PROTOCOL_TOTAL_MAX_BYTES})`);
|
|
392
|
+
}
|
|
393
|
+
return { name, version, hash: protocolHash(manifest, doc), definition: { manifest, doc, source, ref } };
|
|
394
|
+
}
|
|
395
|
+
function loadLocal(r, requested) {
|
|
396
|
+
let isDir = false;
|
|
397
|
+
try {
|
|
398
|
+
isDir = existsSync(r.dir) && statSync(r.dir).isDirectory();
|
|
399
|
+
} catch {
|
|
400
|
+
isDir = false;
|
|
401
|
+
}
|
|
402
|
+
if (!isDir) throw protocolError("REPO_UNREACHABLE", `${r.dir} is not a directory`);
|
|
403
|
+
const manifestPath = join(r.dir, "protocol.json");
|
|
404
|
+
if (!existsSync(manifestPath)) throw invalid(`protocol.json not found in ${r.dir}`);
|
|
405
|
+
const manifestText = readFileSync(manifestPath, "utf8");
|
|
406
|
+
const docPath = join(r.dir, "PROTOCOL.md");
|
|
407
|
+
const doc = existsSync(docPath) ? readFileSync(docPath, "utf8") : "";
|
|
408
|
+
return buildLoaded(manifestText, doc, r.source, "local", { mode: "local", requested });
|
|
409
|
+
}
|
|
410
|
+
async function loadRemote(r, requested, fetcher) {
|
|
411
|
+
const tags = [];
|
|
412
|
+
for (const name of await listTags(r, fetcher)) {
|
|
413
|
+
const version = normalizeVersion(name);
|
|
414
|
+
const sv = parseSemver(version);
|
|
415
|
+
if (sv !== null) tags.push({ name, version, sv });
|
|
416
|
+
}
|
|
417
|
+
const newestFirst = tags.slice().sort((a, b) => compareSemver(b.sv, a.sv));
|
|
418
|
+
let ref;
|
|
419
|
+
let ver;
|
|
420
|
+
if (requested === void 0) {
|
|
421
|
+
const stable = newestFirst.find((t) => t.sv.pre.length === 0);
|
|
422
|
+
if (stable !== void 0) {
|
|
423
|
+
ref = stable.name;
|
|
424
|
+
ver = { mode: "tag", version: stable.version };
|
|
425
|
+
} else {
|
|
426
|
+
const sha = await headSha(r, fetcher);
|
|
427
|
+
ref = sha;
|
|
428
|
+
ver = { mode: "tagless", version: `0.0.0+${sha.slice(0, 7)}` };
|
|
429
|
+
}
|
|
430
|
+
} else {
|
|
431
|
+
const want = normalizeVersion(requested);
|
|
432
|
+
const hit = tags.find((t) => t.version === want);
|
|
433
|
+
if (hit === void 0) {
|
|
434
|
+
const cand = newestFirst.slice(0, 5).map((t) => t.name);
|
|
435
|
+
throw protocolError(
|
|
436
|
+
"VERSION_NOT_FOUND",
|
|
437
|
+
`version "${requested}" has no tag in ${r.source}. ${cand.length > 0 ? `Candidates: ${cand.join(", ")}` : "The repository has no semver tags."}`
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
ref = hit.name;
|
|
441
|
+
ver = { mode: "tag", version: hit.version };
|
|
442
|
+
}
|
|
443
|
+
const manifestText = await fetchFile(r, ref, "protocol.json", fetcher);
|
|
444
|
+
if (manifestText === null) throw invalid(`protocol.json not found in ${r.source} at ${ref}`);
|
|
445
|
+
const doc = await fetchFile(r, ref, "PROTOCOL.md", fetcher) ?? "";
|
|
446
|
+
return buildLoaded(manifestText, doc, r.source, ref, ver);
|
|
447
|
+
}
|
|
448
|
+
async function loadProtocol(repoArg, requested, cwd, fetcher) {
|
|
449
|
+
const req = requested === void 0 || requested.trim() === "" ? void 0 : requested.trim();
|
|
450
|
+
const ref = parseRepoArg(repoArg, cwd);
|
|
451
|
+
if (ref.kind === "local") return loadLocal(ref, req);
|
|
452
|
+
if (ref.kind === "gitea" && !ref.verified) await verifyGitea(ref, repoArg, fetcher);
|
|
453
|
+
return loadRemote(ref, req, fetcher);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
function createProtocolState(fetcher = defaultFetcher) {
|
|
457
|
+
return { declared: [], seen: [], fetcher, reregister: null };
|
|
458
|
+
}
|
|
459
|
+
const SEEN_MAX = 100;
|
|
460
|
+
function requireId(env) {
|
|
461
|
+
if (!env.peer.id) throw new Error("Not registered with broker yet");
|
|
462
|
+
return env.peer.id;
|
|
463
|
+
}
|
|
464
|
+
async function brokerUnsupported(env, what) {
|
|
465
|
+
let version = "unknown";
|
|
466
|
+
try {
|
|
467
|
+
if (typeof env.broker.health === "function") {
|
|
468
|
+
const h = await env.broker.health();
|
|
469
|
+
if (h) version = h.version;
|
|
470
|
+
}
|
|
471
|
+
} catch {
|
|
472
|
+
}
|
|
473
|
+
return protocolError("BROKER_UNSUPPORTED", `the broker (version ${version}) does not support ${what}; use a broker of 0.10.0 or later`);
|
|
474
|
+
}
|
|
475
|
+
async function postRoute(env, path, body) {
|
|
476
|
+
try {
|
|
477
|
+
return await env.broker.post(path, body);
|
|
478
|
+
} catch (e) {
|
|
479
|
+
if (errorMessage$1(e).startsWith(`Broker error (${path}): 404`)) throw await brokerUnsupported(env, "protocols");
|
|
480
|
+
throw e;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
function responseError(r) {
|
|
484
|
+
if (typeof r.code === "string") {
|
|
485
|
+
return protocolError(r.code, r.error);
|
|
486
|
+
}
|
|
487
|
+
return new Error(`Failed: ${r.error}`);
|
|
488
|
+
}
|
|
489
|
+
function isUnknownPeer(r) {
|
|
490
|
+
return r.code === void 0 && r.error.startsWith("unknown peer");
|
|
491
|
+
}
|
|
492
|
+
function declareLocally(state, d) {
|
|
493
|
+
const i = state.declared.findIndex((x) => x.decl.name === d.decl.name);
|
|
494
|
+
if (i === -1) state.declared.push(d);
|
|
495
|
+
else state.declared[i] = d;
|
|
496
|
+
}
|
|
497
|
+
async function setProtocol(env, repo, version) {
|
|
498
|
+
requireId(env);
|
|
499
|
+
const loaded = await loadProtocol(repo, version, env.peer.cwd, env.protocols.fetcher);
|
|
500
|
+
const body = () => ({
|
|
501
|
+
id: env.peer.id,
|
|
502
|
+
name: loaded.name,
|
|
503
|
+
version: loaded.version,
|
|
504
|
+
hash: loaded.hash,
|
|
505
|
+
definition: loaded.definition
|
|
506
|
+
});
|
|
507
|
+
let r = await postRoute(env, "/set-protocol", body());
|
|
508
|
+
if (!r.ok && isUnknownPeer(r) && env.protocols.reregister) {
|
|
509
|
+
await env.protocols.reregister();
|
|
510
|
+
requireId(env);
|
|
511
|
+
r = await postRoute(env, "/set-protocol", body());
|
|
512
|
+
}
|
|
513
|
+
if (!r.ok) throw responseError(r);
|
|
514
|
+
declareLocally(env.protocols, {
|
|
515
|
+
decl: { name: loaded.name, version: loaded.version, hash: loaded.hash },
|
|
516
|
+
definition: loaded.definition
|
|
517
|
+
});
|
|
518
|
+
return {
|
|
519
|
+
name: loaded.name,
|
|
520
|
+
version: loaded.version,
|
|
521
|
+
hash: loaded.hash,
|
|
522
|
+
source: loaded.definition.source,
|
|
523
|
+
ref: loaded.definition.ref
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
async function unsetProtocol(env, name) {
|
|
527
|
+
requireId(env);
|
|
528
|
+
const body = () => name === void 0 ? { id: env.peer.id } : { id: env.peer.id, name };
|
|
529
|
+
let r = await postRoute(env, "/unset-protocol", body());
|
|
530
|
+
if (!r.ok && isUnknownPeer(r) && env.protocols.reregister) {
|
|
531
|
+
await env.protocols.reregister();
|
|
532
|
+
requireId(env);
|
|
533
|
+
r = await postRoute(env, "/unset-protocol", body());
|
|
534
|
+
}
|
|
535
|
+
if (!r.ok) throw responseError(r);
|
|
536
|
+
const st = env.protocols;
|
|
537
|
+
st.declared = name === void 0 ? [] : st.declared.filter((d) => d.decl.name !== name);
|
|
538
|
+
return r.removed;
|
|
539
|
+
}
|
|
540
|
+
async function getProtocol(env, name, version) {
|
|
541
|
+
const v = version === void 0 || version.trim() === "" ? void 0 : normalizeVersion(version);
|
|
542
|
+
const r = await postRoute(env, "/get-protocol", v === void 0 ? { name } : { name, version: v });
|
|
543
|
+
if (!r.ok) throw responseError(r);
|
|
544
|
+
const p = r.protocol;
|
|
545
|
+
return {
|
|
546
|
+
name: p.name,
|
|
547
|
+
version: p.version,
|
|
548
|
+
hash: p.hash,
|
|
549
|
+
servers: r.servers,
|
|
550
|
+
manifest: p.definition.manifest,
|
|
551
|
+
doc: p.definition.doc,
|
|
552
|
+
source: p.definition.source,
|
|
553
|
+
ref: p.definition.ref
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
async function listPeers(env, scope, filter) {
|
|
557
|
+
const body = {
|
|
558
|
+
scope,
|
|
559
|
+
cwd: env.peer.cwd,
|
|
560
|
+
git_root: env.peer.gitRoot,
|
|
561
|
+
hostname: env.peer.hostname,
|
|
562
|
+
exclude_id: env.peer.id ?? void 0
|
|
563
|
+
};
|
|
564
|
+
const protocol = filter?.protocol === void 0 || filter.protocol === "" ? void 0 : filter.protocol;
|
|
565
|
+
if (protocol !== void 0) {
|
|
566
|
+
body.protocol = protocol;
|
|
567
|
+
if (filter?.version !== void 0 && filter.version.trim() !== "") body.version = normalizeVersion(filter.version);
|
|
568
|
+
}
|
|
569
|
+
const peers = await env.broker.post("/list-peers", body);
|
|
570
|
+
if (protocol !== void 0 && peers.some((p) => !Array.isArray(p.protocols))) {
|
|
571
|
+
throw await brokerUnsupported(env, "the protocol filter of list_peers");
|
|
572
|
+
}
|
|
573
|
+
return peers;
|
|
574
|
+
}
|
|
575
|
+
function parseMeta(raw) {
|
|
576
|
+
if (raw === void 0) return void 0;
|
|
577
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
578
|
+
throw protocolError("INVALID_META", "meta must be an object {protocol, version}");
|
|
579
|
+
}
|
|
580
|
+
const m = raw;
|
|
581
|
+
if (typeof m.protocol !== "string" || m.protocol === "" || typeof m.version !== "string" || m.version === "") {
|
|
582
|
+
throw protocolError("INVALID_META", "meta needs both protocol and version (non-empty strings)");
|
|
583
|
+
}
|
|
584
|
+
if (m.protocol.length > PROTOCOL_META_MAX_LENGTH || m.version.length > PROTOCOL_META_MAX_LENGTH) {
|
|
585
|
+
throw protocolError("INVALID_META", `meta.protocol and meta.version are at most ${PROTOCOL_META_MAX_LENGTH} characters`);
|
|
586
|
+
}
|
|
587
|
+
return { protocol: m.protocol, version: m.version };
|
|
588
|
+
}
|
|
589
|
+
function planOutgoing(state, to, text, meta) {
|
|
590
|
+
for (let i = state.seen.length - 1; i >= 0; i--) {
|
|
591
|
+
const s = state.seen[i];
|
|
592
|
+
if (s.peerId !== to && (s.peerName === "" || s.peerName !== to)) continue;
|
|
593
|
+
const mine = state.declared.find((d) => d.decl.name === s.meta.protocol);
|
|
594
|
+
if (mine === void 0) break;
|
|
595
|
+
if (normalizeVersion(s.meta.version) === mine.decl.version) break;
|
|
596
|
+
if (meta !== void 0 && meta.protocol !== s.meta.protocol) break;
|
|
597
|
+
const warning = `[agent-messenger warning] protocol version mismatch: you sent ${s.meta.protocol}@${s.meta.version}, this server serves ${s.meta.protocol}@${mine.decl.version}`;
|
|
598
|
+
return { text: `${warning}
|
|
599
|
+
${text}`, meta: { protocol: s.meta.protocol, version: mine.decl.version }, warning };
|
|
600
|
+
}
|
|
601
|
+
return meta === void 0 ? { text } : { text, meta };
|
|
602
|
+
}
|
|
603
|
+
function recordSeen(state, peerId, peerName, meta) {
|
|
604
|
+
const i = state.seen.findIndex((s) => s.peerId === peerId);
|
|
605
|
+
if (i !== -1) state.seen.splice(i, 1);
|
|
606
|
+
state.seen.push({ peerId, peerName, meta });
|
|
607
|
+
while (state.seen.length > SEEN_MAX) state.seen.shift();
|
|
608
|
+
}
|
|
609
|
+
function describeMeta(state, meta) {
|
|
610
|
+
const base = `Protocol: ${meta.protocol}@${meta.version}`;
|
|
611
|
+
const mine = state.declared.find((d) => d.decl.name === meta.protocol);
|
|
612
|
+
if (mine === void 0) return `${base} (not served here)`;
|
|
613
|
+
if (normalizeVersion(meta.version) === mine.decl.version) return base;
|
|
614
|
+
return `${base} (this server: ${mine.decl.version}, mismatch)`;
|
|
615
|
+
}
|
|
616
|
+
function wireDecls(state) {
|
|
617
|
+
if (state.declared.length === 0) return void 0;
|
|
618
|
+
return state.declared.map((d) => ({ name: d.decl.name, version: d.decl.version, hash: d.decl.hash }));
|
|
619
|
+
}
|
|
620
|
+
async function resendDefinitions(env, log, keys) {
|
|
621
|
+
const id = env.peer.id;
|
|
622
|
+
if (!id) return;
|
|
623
|
+
for (const d of env.protocols.declared.slice()) {
|
|
624
|
+
const key = `${d.decl.name}@${d.decl.version}`;
|
|
625
|
+
if (keys !== void 0 && !keys.includes(key)) continue;
|
|
626
|
+
try {
|
|
627
|
+
const r = await postRoute(env, "/set-protocol", {
|
|
628
|
+
id,
|
|
629
|
+
name: d.decl.name,
|
|
630
|
+
version: d.decl.version,
|
|
631
|
+
hash: d.decl.hash,
|
|
632
|
+
definition: d.definition
|
|
633
|
+
});
|
|
634
|
+
if (r.ok) log(`Protocol ${key} re-sent to the broker`);
|
|
635
|
+
else log(`Protocol ${key} re-send rejected: ${r.error}`);
|
|
636
|
+
} catch (e) {
|
|
637
|
+
log(`Protocol ${key} re-send failed: ${errorMessage$1(e)}`);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
const VERSION = "0.10.0";
|
|
643
|
+
|
|
644
|
+
const INSTRUCTIONS = `agent-messenger v${VERSION}
|
|
645
|
+
|
|
646
|
+
You are connected to agent-messenger. Other Claude Code sessions on this machine AND on remote hosts can find you and send you messages.
|
|
647
|
+
|
|
648
|
+
Inbound traffic arrives in the conversation as one of:
|
|
649
|
+
- "[agent-messenger] \u672A\u8AAD N \u4EF6\uFF08from <name>@<host>\uFF09\u2026" \u2014 an unread notice. Call check_messages to read the text, reply with send_message if needed, then resume your work.
|
|
650
|
+
- "[agent-messenger] ping\uFF08from <name>@<host>\uFF09" or "\u2026\uFF09: <subject>" \u2014 the sender is alive and working (subject = what it is working on, if given). Nothing to read, no reply needed.
|
|
651
|
+
- "[agent-messenger] message from <name>@<host>" followed by the text \u2014 sent with delivery "push". Reply with send_message if needed, then resume your work.
|
|
652
|
+
|
|
653
|
+
Tools:
|
|
654
|
+
- list_peers: discover sessions (scope: all / host / directory / repo)
|
|
655
|
+
- send_message: send to a peer by name or id (cross-host). delivery "pull" (default) = the receiver sees only an unread notice; "push" = the text is shown directly
|
|
656
|
+
- send_ping: send a liveness signal, optionally with a one-line subject such as the task id (e.g. periodically while working, so the orchestrator can tell progress from a stall)
|
|
657
|
+
- set_name: give this session a stable name (e.g. "master-cap", "agent-messenger") so others can address it by name
|
|
658
|
+
- set_summary: describe what you are working on (visible in list_peers)
|
|
659
|
+
- check_messages: read unread message texts. Notices are delivered into the conversation automatically (via the session inbox socket, or via channel push when Claude Code was started with --dangerously-load-development-channels server:agent-messenger); call check_messages any time to read.
|
|
660
|
+
- set_protocol: declare that this session serves a protocol (a public GitHub / Gitea repo or a local path holding protocol.json and PROTOCOL.md), so peers can find it with list_peers(protocol)
|
|
661
|
+
- unset_protocol: stop serving a protocol (all of them when no name is given)
|
|
662
|
+
- get_protocol: read a protocol definition held by the broker (protocol.json and PROTOCOL.md) to speak it
|
|
663
|
+
- list_peers(protocol, version): only the sessions that serve that protocol (and version)
|
|
664
|
+
- send_message(meta): meta = {protocol, version} tags the message with the protocol it follows; the receiver is warned when its served version differs
|
|
665
|
+
|
|
666
|
+
On start, call set_name (if not already named) and set_summary.`;
|
|
667
|
+
function text$1(t, isError = false) {
|
|
668
|
+
return isError ? { content: [{ type: "text", text: t }], isError: true } : { content: [{ type: "text", text: t }] };
|
|
669
|
+
}
|
|
670
|
+
async function guarded(fn) {
|
|
671
|
+
try {
|
|
672
|
+
return await fn();
|
|
673
|
+
} catch (e) {
|
|
674
|
+
if (protocolErrorCode(e) !== null) return text$1(errorMessage$1(e), true);
|
|
675
|
+
throw e;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
function formatPeer(p) {
|
|
679
|
+
const parts = [`ID: ${p.id}`];
|
|
680
|
+
if (p.name) parts.push(`Name: ${p.name}`);
|
|
681
|
+
parts.push(`Host: ${p.hostname}`, `PID: ${p.pid}`, `CWD: ${p.cwd}`);
|
|
682
|
+
if (p.git_root) parts.push(`Repo: ${p.git_root}`);
|
|
683
|
+
if (p.tty) parts.push(`TTY: ${p.tty}`);
|
|
684
|
+
if (p.summary) parts.push(`Summary: ${p.summary}`);
|
|
685
|
+
for (const d of p.protocols ?? []) parts.push(`Protocol: ${d.name}@${d.version}`);
|
|
686
|
+
parts.push(`Last seen: ${p.last_seen}`);
|
|
687
|
+
return parts.join("\n ");
|
|
688
|
+
}
|
|
689
|
+
function formatMessage(m) {
|
|
690
|
+
const who = m.from_name ? `${m.from_name} (${m.from_id})` : m.from_id;
|
|
691
|
+
const host = m.from_hostname ? `@${m.from_hostname}` : "";
|
|
692
|
+
return `From ${who}${host} at ${m.sent_at}:
|
|
693
|
+
${m.protocol_line ? `${m.protocol_line}
|
|
694
|
+
` : ""}${m.text}`;
|
|
695
|
+
}
|
|
696
|
+
const TOOL_DEFS = [
|
|
697
|
+
{
|
|
698
|
+
name: "list_peers",
|
|
699
|
+
description: "List other Claude Code sessions connected to the broker (id, name, hostname, cwd, repo, summary).",
|
|
700
|
+
inputSchema: {
|
|
701
|
+
type: "object",
|
|
702
|
+
properties: {
|
|
703
|
+
scope: {
|
|
704
|
+
type: "string",
|
|
705
|
+
enum: ["all", "host", "directory", "repo"],
|
|
706
|
+
description: '"all" = every host (default). "host" = same hostname. "directory" = same cwd. "repo" = same git repository.'
|
|
707
|
+
},
|
|
708
|
+
protocol: {
|
|
709
|
+
type: "string",
|
|
710
|
+
description: "Only sessions that serve this protocol (set_protocol). Combines with scope."
|
|
711
|
+
},
|
|
712
|
+
version: {
|
|
713
|
+
type: "string",
|
|
714
|
+
description: "Only with protocol: only sessions that serve exactly this version (a leading v is ignored)."
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
},
|
|
718
|
+
requiresRegistration: false,
|
|
719
|
+
handler(args, ctx) {
|
|
720
|
+
return guarded(async () => {
|
|
721
|
+
const scope = typeof args.scope === "string" ? args.scope : "all";
|
|
722
|
+
const protocol = args.protocol === void 0 || args.protocol === "" ? void 0 : String(args.protocol);
|
|
723
|
+
const version = protocol === void 0 || args.version === void 0 || args.version === "" ? void 0 : normalizeVersion(String(args.version));
|
|
724
|
+
const peers = await listPeers(ctx, scope, { protocol, version });
|
|
725
|
+
if (protocol !== void 0) {
|
|
726
|
+
if (peers.length === 0) return text$1(`No server for protocol "${protocol}" (version: ${version ?? "any"}).`);
|
|
727
|
+
return text$1(
|
|
728
|
+
`Found ${peers.length} peer(s) (scope: ${scope}, protocol: ${protocol}, version: ${version ?? "any"}):
|
|
729
|
+
|
|
730
|
+
${peers.map(formatPeer).join("\n\n")}`
|
|
731
|
+
);
|
|
732
|
+
}
|
|
733
|
+
if (peers.length === 0) return text$1(`No other sessions found (scope: ${scope}).`);
|
|
734
|
+
return text$1(`Found ${peers.length} peer(s) (scope: ${scope}):
|
|
735
|
+
|
|
736
|
+
${peers.map(formatPeer).join("\n\n")}`);
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
},
|
|
740
|
+
{
|
|
741
|
+
name: "send_message",
|
|
742
|
+
description: "Send a message to another Claude Code session by peer name or id (from list_peers). Works across hosts.",
|
|
743
|
+
inputSchema: {
|
|
744
|
+
type: "object",
|
|
745
|
+
properties: {
|
|
746
|
+
to: { type: "string", description: "Target peer name or id" },
|
|
747
|
+
message: { type: "string", description: "Message text" },
|
|
748
|
+
delivery: {
|
|
749
|
+
type: "string",
|
|
750
|
+
enum: ["pull", "push"],
|
|
751
|
+
description: `"pull" (default) = the receiver sees only an unread notice (sender shown) and reads the text with check_messages. "push" = the text is shown in the receiver's conversation directly.`
|
|
752
|
+
},
|
|
753
|
+
meta: {
|
|
754
|
+
type: "object",
|
|
755
|
+
description: "Optional protocol tag of this message: which protocol (see get_protocol) and version it follows. Both fields are required when meta is given.",
|
|
756
|
+
properties: {
|
|
757
|
+
protocol: { type: "string", description: "Protocol name" },
|
|
758
|
+
version: { type: "string", description: "Protocol version" }
|
|
759
|
+
},
|
|
760
|
+
required: ["protocol", "version"]
|
|
761
|
+
}
|
|
762
|
+
},
|
|
763
|
+
required: ["to", "message"]
|
|
764
|
+
},
|
|
765
|
+
requiresRegistration: true,
|
|
766
|
+
handler(args, ctx) {
|
|
767
|
+
return guarded(async () => {
|
|
768
|
+
const delivery = args.delivery === void 0 ? "pull" : String(args.delivery);
|
|
769
|
+
if (delivery !== "pull" && delivery !== "push") return text$1(`Invalid delivery: ${delivery} (use "pull" or "push")`, true);
|
|
770
|
+
const meta = parseMeta(args.meta);
|
|
771
|
+
const to = String(args.to);
|
|
772
|
+
const plan = planOutgoing(ctx.protocols, to, String(args.message), meta);
|
|
773
|
+
const r = await ctx.broker.post("/send-message", {
|
|
774
|
+
from_id: ctx.peer.id ?? void 0,
|
|
775
|
+
from_name: ctx.peer.name,
|
|
776
|
+
to,
|
|
777
|
+
text: plan.text,
|
|
778
|
+
mode: delivery,
|
|
779
|
+
...plan.meta === void 0 ? {} : { meta: plan.meta }
|
|
780
|
+
});
|
|
781
|
+
if (!r.ok) return text$1(`Failed to send: ${r.error}`, true);
|
|
782
|
+
const label = r.to_name ? `${r.to_name} (${r.to_id})` : r.to_id;
|
|
783
|
+
return text$1(`Message sent to ${label} (delivery: ${delivery}).${plan.warning ? `
|
|
784
|
+
${plan.warning}` : ""}`);
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
name: "send_ping",
|
|
790
|
+
description: "Send a liveness signal to a peer, optionally with a one-line subject (e.g. the task id or name being worked on). The receiver sees a one-line ping notice (sender and subject shown), nothing to read or reply to. Use it periodically during long work so the orchestrator can tell progress from a stall.",
|
|
791
|
+
inputSchema: {
|
|
792
|
+
type: "object",
|
|
793
|
+
properties: {
|
|
794
|
+
to: { type: "string", description: "Target peer name or id" },
|
|
795
|
+
subject: {
|
|
796
|
+
type: "string",
|
|
797
|
+
description: "Optional one-line subject, e.g. the task id or name being worked on. Delivered as the message text."
|
|
798
|
+
}
|
|
799
|
+
},
|
|
800
|
+
required: ["to"]
|
|
801
|
+
},
|
|
802
|
+
requiresRegistration: true,
|
|
803
|
+
async handler(args, ctx) {
|
|
804
|
+
const r = await ctx.broker.post("/send-message", {
|
|
805
|
+
from_id: ctx.peer.id ?? void 0,
|
|
806
|
+
from_name: ctx.peer.name,
|
|
807
|
+
to: String(args.to),
|
|
808
|
+
text: args.subject === void 0 ? "" : String(args.subject),
|
|
809
|
+
mode: "ping"
|
|
810
|
+
});
|
|
811
|
+
if (!r.ok) return text$1(`Failed to send: ${r.error}`, true);
|
|
812
|
+
const label = r.to_name ? `${r.to_name} (${r.to_id})` : r.to_id;
|
|
813
|
+
return text$1(`Ping sent to ${label}.`);
|
|
814
|
+
}
|
|
815
|
+
},
|
|
816
|
+
{
|
|
817
|
+
name: "set_name",
|
|
818
|
+
description: "Set a stable name for this session so other peers can address it by name.",
|
|
819
|
+
inputSchema: {
|
|
820
|
+
type: "object",
|
|
821
|
+
properties: { name: { type: "string", description: "Name, e.g. the session name" } },
|
|
822
|
+
required: ["name"]
|
|
823
|
+
},
|
|
824
|
+
requiresRegistration: true,
|
|
825
|
+
async handler(args, ctx) {
|
|
826
|
+
const newName = String(args.name);
|
|
827
|
+
const r = await ctx.broker.post("/set-name", { id: ctx.peer.id, name: newName });
|
|
828
|
+
if (!r.ok) return text$1(`Failed: ${r.error}`, true);
|
|
829
|
+
ctx.peer.name = newName;
|
|
830
|
+
return text$1(`Name set: "${newName}"`);
|
|
831
|
+
}
|
|
832
|
+
},
|
|
833
|
+
{
|
|
834
|
+
name: "set_summary",
|
|
835
|
+
description: "Set a 1-2 sentence summary of what this session is working on (visible in list_peers).",
|
|
836
|
+
inputSchema: {
|
|
837
|
+
type: "object",
|
|
838
|
+
properties: { summary: { type: "string" } },
|
|
839
|
+
required: ["summary"]
|
|
840
|
+
},
|
|
841
|
+
requiresRegistration: true,
|
|
842
|
+
async handler(args, ctx) {
|
|
843
|
+
const summary = String(args.summary);
|
|
844
|
+
const r = await ctx.broker.post("/set-summary", { id: ctx.peer.id, summary });
|
|
845
|
+
if (!r.ok) return text$1(`Failed: ${r.error}`, true);
|
|
846
|
+
ctx.peer.summary = summary;
|
|
847
|
+
return text$1(`Summary updated: "${summary}"`);
|
|
848
|
+
}
|
|
849
|
+
},
|
|
850
|
+
{
|
|
851
|
+
name: "check_messages",
|
|
852
|
+
description: "Read and acknowledge unread messages from other sessions (the text behind an unread notice). Safe to call any time.",
|
|
853
|
+
inputSchema: { type: "object", properties: {} },
|
|
854
|
+
requiresRegistration: true,
|
|
855
|
+
async handler(_args, ctx) {
|
|
856
|
+
const list = await ctx.inbox.checkMessages();
|
|
857
|
+
if (list.length === 0) return text$1("No new messages.");
|
|
858
|
+
return text$1(`${list.length} message(s):
|
|
859
|
+
|
|
860
|
+
${list.map(formatMessage).join("\n\n---\n\n")}`);
|
|
861
|
+
}
|
|
862
|
+
},
|
|
863
|
+
{
|
|
864
|
+
name: "set_protocol",
|
|
865
|
+
description: "Declare that this session serves a protocol: read protocol.json (and PROTOCOL.md) from a protocol repo, register the definition at the broker, and become findable with list_peers(protocol). Declaring a name again replaces its version. Public GitHub / Gitea repos and local paths only.",
|
|
866
|
+
inputSchema: {
|
|
867
|
+
type: "object",
|
|
868
|
+
properties: {
|
|
869
|
+
repo: {
|
|
870
|
+
type: "string",
|
|
871
|
+
description: "Protocol repo: https://github.com/<owner>/<repo>, <owner>/<repo>, github:<owner>/<repo>, gitea:<base-url>/<owner>/<repo>, https://<gitea-host>/<owner>/<repo>, or a local path (/abs/path, ./rel/path, file:///abs/path)."
|
|
872
|
+
},
|
|
873
|
+
version: {
|
|
874
|
+
type: "string",
|
|
875
|
+
description: 'Tag to use, e.g. "1.2.0" or "v1.2.0". Default: the latest release tag (or the default branch head for a repo without tags). Ignored for local paths except as a check.'
|
|
876
|
+
}
|
|
877
|
+
},
|
|
878
|
+
required: ["repo"]
|
|
879
|
+
},
|
|
880
|
+
requiresRegistration: true,
|
|
881
|
+
handler(args, ctx) {
|
|
882
|
+
return guarded(async () => {
|
|
883
|
+
const info = await setProtocol(ctx, String(args.repo), args.version === void 0 ? void 0 : String(args.version));
|
|
884
|
+
return text$1(`Protocol set: ${info.name}@${info.version} (sha256 ${info.hash.slice(0, 8)}\u2026, from ${info.source})`);
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
},
|
|
888
|
+
{
|
|
889
|
+
name: "unset_protocol",
|
|
890
|
+
description: "Stop serving a protocol declared with set_protocol. Without a name, all protocols of this session are unset.",
|
|
891
|
+
inputSchema: {
|
|
892
|
+
type: "object",
|
|
893
|
+
properties: {
|
|
894
|
+
name: { type: "string", description: "Protocol name to unset (default: all)" }
|
|
895
|
+
}
|
|
896
|
+
},
|
|
897
|
+
requiresRegistration: true,
|
|
898
|
+
handler(args, ctx) {
|
|
899
|
+
return guarded(async () => {
|
|
900
|
+
const name = args.name === void 0 ? void 0 : String(args.name);
|
|
901
|
+
const removed = await unsetProtocol(ctx, name);
|
|
902
|
+
if (removed === 0) return text$1("No protocol set.");
|
|
903
|
+
return text$1(name === void 0 ? `Protocol unset: (all, ${removed})` : `Protocol unset: ${name}`);
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
},
|
|
907
|
+
{
|
|
908
|
+
name: "get_protocol",
|
|
909
|
+
description: "Show the definition of a protocol held by the broker (protocol.json and PROTOCOL.md) so you can speak it. Latest version when version is omitted.",
|
|
910
|
+
inputSchema: {
|
|
911
|
+
type: "object",
|
|
912
|
+
properties: {
|
|
913
|
+
name: { type: "string", description: "Protocol name (see list_peers)" },
|
|
914
|
+
version: { type: "string", description: 'Version, e.g. "1.2.0" or "v1.2.0". Default: the latest the broker holds.' }
|
|
915
|
+
},
|
|
916
|
+
required: ["name"]
|
|
917
|
+
},
|
|
918
|
+
requiresRegistration: false,
|
|
919
|
+
handler(args, ctx) {
|
|
920
|
+
return guarded(async () => {
|
|
921
|
+
const p = await getProtocol(
|
|
922
|
+
ctx,
|
|
923
|
+
String(args.name),
|
|
924
|
+
args.version === void 0 ? void 0 : String(args.version)
|
|
925
|
+
);
|
|
926
|
+
const description = p.manifest.description;
|
|
927
|
+
const lines = [
|
|
928
|
+
`${p.name}@${p.version} (sha256 ${p.hash.slice(0, 8)}\u2026, servers: ${p.servers})`,
|
|
929
|
+
`Description: ${typeof description === "string" ? description : ""}`,
|
|
930
|
+
"",
|
|
931
|
+
"protocol.json:",
|
|
932
|
+
JSON.stringify(p.manifest, null, 2),
|
|
933
|
+
"",
|
|
934
|
+
"PROTOCOL.md:",
|
|
935
|
+
p.doc === "" ? "(none)" : p.doc
|
|
936
|
+
];
|
|
937
|
+
return text$1(lines.join("\n"));
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
];
|
|
942
|
+
|
|
943
|
+
function text(t, isError = false) {
|
|
944
|
+
return isError ? { content: [{ type: "text", text: t }], isError: true } : { content: [{ type: "text", text: t }] };
|
|
945
|
+
}
|
|
946
|
+
function errorMessage(e) {
|
|
947
|
+
return e instanceof Error ? e.message : String(e);
|
|
948
|
+
}
|
|
949
|
+
function toolDescriptors(defs = TOOL_DEFS) {
|
|
950
|
+
return defs.map((d) => ({
|
|
951
|
+
name: d.name,
|
|
952
|
+
description: `[agent-messenger v${VERSION}] ${d.description}`,
|
|
953
|
+
inputSchema: d.inputSchema,
|
|
954
|
+
annotations: { title: `${d.name} (v${VERSION})` }
|
|
955
|
+
}));
|
|
956
|
+
}
|
|
957
|
+
const TOOLS = toolDescriptors();
|
|
958
|
+
function createToolRegistry(input, defs = TOOL_DEFS) {
|
|
959
|
+
const ctx = { ...input, protocols: input.protocols ?? createProtocolState() };
|
|
960
|
+
return {
|
|
961
|
+
list: () => toolDescriptors(defs),
|
|
962
|
+
async call(name, args) {
|
|
963
|
+
const def = defs.find((d) => d.name === name);
|
|
964
|
+
if (!ctx.peer.id && (def === void 0 || def.requiresRegistration)) return text("Not registered with broker yet", true);
|
|
965
|
+
if (def === void 0) return text(`Unknown tool: ${name}`, true);
|
|
966
|
+
try {
|
|
967
|
+
return await def.handler(args ?? {}, ctx);
|
|
968
|
+
} catch (e) {
|
|
969
|
+
return text(`Error (${name}): ${errorMessage(e)}`, true);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
export { parseMeta as A, BROKER_CMD_ENV as B, createProtocolState as C, DEFAULT_BROKER_CMD as D, ENV as E, FALLBACK_ENV as F, GRACE_MS_ENV as G, HEALTH_ROUTE as H, INSTRUCTIONS as I, planOutgoing as J, wireDecls as K, LOCAL_HOSTS as L, resendDefinitions as M, POLL_INTERVAL_MS as P, RESOLVE_RETRY_MS as R, SESSION_SOCKET_ENV as S, TOOLS as T, VERSION as V, DEFAULT_DISCOVERY_PORT as a, DEFAULT_DISCOVERY_TIMEOUT_MS as b, DEFAULT_GRACE_MS as c, DEFAULT_HTTP_PORT as d, DISCOVERY_BROADCAST_ADDR as e, DISCOVERY_KEY as f, DISCOVERY_PROBE_VALUE as g, DISCOVERY_REPLY_VALUE as h, HEARTBEAT_INTERVAL_MS as i, PROTOCOL_DOC_MAX_BYTES as j, PROTOCOL_MANIFEST_MAX_BYTES as k, PROTOCOL_META_MAX_LENGTH as l, PROTOCOL_NAME_PATTERN as m, PROTOCOL_TOTAL_MAX_BYTES as n, SESSION_TOKEN_ENV as o, TOOL_DEFS as p, createToolRegistry as q, formatMessage as r, formatPeer as s, toolDescriptors as t, recordSeen as u, describeMeta as v, getProtocol as w, unsetProtocol as x, setProtocol as y, listPeers as z };
|