opencode-rehydar 0.14.1 → 0.14.3
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/dist/browser.d.ts +54 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +74 -0
- package/dist/browser.js.map +1 -0
- package/dist/core/anonymizer.d.ts +309 -0
- package/dist/core/anonymizer.d.ts.map +1 -0
- package/dist/core/anonymizer.js +555 -0
- package/dist/core/anonymizer.js.map +1 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +6 -0
- package/dist/core/index.js.map +1 -0
- package/dist/crypto/index.d.ts +6 -0
- package/dist/crypto/index.d.ts.map +1 -0
- package/dist/crypto/index.js +6 -0
- package/dist/crypto/index.js.map +1 -0
- package/dist/crypto/pii-map-crypto.d.ts +114 -0
- package/dist/crypto/pii-map-crypto.d.ts.map +1 -0
- package/dist/crypto/pii-map-crypto.js +228 -0
- package/dist/crypto/pii-map-crypto.js.map +1 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +72 -0
- package/dist/index.js.map +1 -0
- package/dist/ner/bio-decoder.d.ts +64 -0
- package/dist/ner/bio-decoder.d.ts.map +1 -0
- package/dist/ner/bio-decoder.js +218 -0
- package/dist/ner/bio-decoder.js.map +1 -0
- package/dist/ner/index.d.ts +12 -0
- package/dist/ner/index.d.ts.map +1 -0
- package/dist/ner/index.js +12 -0
- package/dist/ner/index.js.map +1 -0
- package/dist/ner/inference-server-client.d.ts +81 -0
- package/dist/ner/inference-server-client.d.ts.map +1 -0
- package/dist/ner/inference-server-client.js +120 -0
- package/dist/ner/inference-server-client.js.map +1 -0
- package/dist/ner/inference-server-ner-model.d.ts +43 -0
- package/dist/ner/inference-server-ner-model.d.ts.map +1 -0
- package/dist/ner/inference-server-ner-model.js +119 -0
- package/dist/ner/inference-server-ner-model.js.map +1 -0
- package/dist/ner/model-manager.d.ts +111 -0
- package/dist/ner/model-manager.d.ts.map +1 -0
- package/dist/ner/model-manager.js +334 -0
- package/dist/ner/model-manager.js.map +1 -0
- package/dist/ner/ner-model.d.ts +172 -0
- package/dist/ner/ner-model.d.ts.map +1 -0
- package/dist/ner/ner-model.js +514 -0
- package/dist/ner/ner-model.js.map +1 -0
- package/dist/ner/onnx-runtime.browser.d.ts +46 -0
- package/dist/ner/onnx-runtime.browser.d.ts.map +1 -0
- package/dist/ner/onnx-runtime.browser.js +90 -0
- package/dist/ner/onnx-runtime.browser.js.map +1 -0
- package/dist/ner/onnx-runtime.d.ts +72 -0
- package/dist/ner/onnx-runtime.d.ts.map +1 -0
- package/dist/ner/onnx-runtime.js +132 -0
- package/dist/ner/onnx-runtime.js.map +1 -0
- package/dist/ner/token-window.d.ts +19 -0
- package/dist/ner/token-window.d.ts.map +1 -0
- package/dist/ner/token-window.js +101 -0
- package/dist/ner/token-window.js.map +1 -0
- package/dist/ner/tokenizer.d.ts +142 -0
- package/dist/ner/tokenizer.d.ts.map +1 -0
- package/dist/ner/tokenizer.js +362 -0
- package/dist/ner/tokenizer.js.map +1 -0
- package/dist/opencode-plugin/git-identity.d.ts +3 -0
- package/dist/opencode-plugin/git-identity.d.ts.map +1 -0
- package/dist/opencode-plugin/git-identity.js +37 -0
- package/dist/opencode-plugin/git-identity.js.map +1 -0
- package/dist/opencode-plugin/github-username.d.ts +3 -0
- package/dist/opencode-plugin/github-username.d.ts.map +1 -0
- package/dist/opencode-plugin/github-username.js +41 -0
- package/dist/opencode-plugin/github-username.js.map +1 -0
- package/dist/opencode-plugin/identity-recognizer.d.ts +5 -0
- package/dist/opencode-plugin/identity-recognizer.d.ts.map +1 -0
- package/dist/opencode-plugin/identity-recognizer.js +21 -0
- package/dist/opencode-plugin/identity-recognizer.js.map +1 -0
- package/dist/opencode-plugin/index.d.ts +7 -0
- package/dist/opencode-plugin/index.d.ts.map +1 -0
- package/dist/opencode-plugin/index.js +6 -0
- package/dist/opencode-plugin/index.js.map +1 -0
- package/dist/opencode-plugin/plugin.d.ts +39 -0
- package/dist/opencode-plugin/plugin.d.ts.map +1 -0
- package/dist/opencode-plugin/plugin.js +294 -0
- package/dist/opencode-plugin/plugin.js.map +1 -0
- package/dist/opencode-plugin/types.d.ts +33 -0
- package/dist/opencode-plugin/types.d.ts.map +1 -0
- package/dist/opencode-plugin/types.js +5 -0
- package/dist/opencode-plugin/types.js.map +1 -0
- package/dist/opencode-plugin/v2/anon-state.d.ts +12 -0
- package/dist/opencode-plugin/v2/anon-state.d.ts.map +1 -0
- package/dist/opencode-plugin/v2/anon-state.js +14 -0
- package/dist/opencode-plugin/v2/anon-state.js.map +1 -0
- package/dist/opencode-plugin/v2/deep-rehydrate.d.ts +13 -0
- package/dist/opencode-plugin/v2/deep-rehydrate.d.ts.map +1 -0
- package/dist/opencode-plugin/v2/deep-rehydrate.js +33 -0
- package/dist/opencode-plugin/v2/deep-rehydrate.js.map +1 -0
- package/dist/opencode-plugin/v2/index.d.ts +17 -0
- package/dist/opencode-plugin/v2/index.d.ts.map +1 -0
- package/dist/opencode-plugin/v2/index.js +17 -0
- package/dist/opencode-plugin/v2/index.js.map +1 -0
- package/dist/opencode-plugin/v2/logger.d.ts +24 -0
- package/dist/opencode-plugin/v2/logger.d.ts.map +1 -0
- package/dist/opencode-plugin/v2/logger.js +73 -0
- package/dist/opencode-plugin/v2/logger.js.map +1 -0
- package/dist/opencode-plugin/v2/options.d.ts +63 -0
- package/dist/opencode-plugin/v2/options.d.ts.map +1 -0
- package/dist/opencode-plugin/v2/options.js +183 -0
- package/dist/opencode-plugin/v2/options.js.map +1 -0
- package/dist/opencode-plugin/v2/register-hooks.d.ts +43 -0
- package/dist/opencode-plugin/v2/register-hooks.d.ts.map +1 -0
- package/dist/opencode-plugin/v2/register-hooks.js +160 -0
- package/dist/opencode-plugin/v2/register-hooks.js.map +1 -0
- package/dist/opencode-plugin/v2/rehydrate-tail.d.ts +101 -0
- package/dist/opencode-plugin/v2/rehydrate-tail.d.ts.map +1 -0
- package/dist/opencode-plugin/v2/rehydrate-tail.js +147 -0
- package/dist/opencode-plugin/v2/rehydrate-tail.js.map +1 -0
- package/dist/opencode-plugin/v2/response-rehydrate.d.ts +78 -0
- package/dist/opencode-plugin/v2/response-rehydrate.d.ts.map +1 -0
- package/dist/opencode-plugin/v2/response-rehydrate.js +210 -0
- package/dist/opencode-plugin/v2/response-rehydrate.js.map +1 -0
- package/dist/opencode-plugin/v2/scrub-messages.d.ts +39 -0
- package/dist/opencode-plugin/v2/scrub-messages.d.ts.map +1 -0
- package/dist/opencode-plugin/v2/scrub-messages.js +260 -0
- package/dist/opencode-plugin/v2/scrub-messages.js.map +1 -0
- package/dist/opencode-plugin/v2/sessions.d.ts +17 -0
- package/dist/opencode-plugin/v2/sessions.d.ts.map +1 -0
- package/dist/opencode-plugin/v2/sessions.js +23 -0
- package/dist/opencode-plugin/v2/sessions.js.map +1 -0
- package/dist/opencode-plugin/v2/sse.d.ts +101 -0
- package/dist/opencode-plugin/v2/sse.d.ts.map +1 -0
- package/dist/opencode-plugin/v2/sse.js +235 -0
- package/dist/opencode-plugin/v2/sse.js.map +1 -0
- package/dist/opencode-plugin/v2/types.d.ts +188 -0
- package/dist/opencode-plugin/v2/types.d.ts.map +1 -0
- package/dist/opencode-plugin/v2/types.js +10 -0
- package/dist/opencode-plugin/v2/types.js.map +1 -0
- package/dist/opencode-plugin/vcs-command.d.ts +3 -0
- package/dist/opencode-plugin/vcs-command.d.ts.map +1 -0
- package/dist/opencode-plugin/vcs-command.js +34 -0
- package/dist/opencode-plugin/vcs-command.js.map +1 -0
- package/dist/pipeline/index.d.ts +12 -0
- package/dist/pipeline/index.d.ts.map +1 -0
- package/dist/pipeline/index.js +12 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/prenormalize.d.ts +48 -0
- package/dist/pipeline/prenormalize.d.ts.map +1 -0
- package/dist/pipeline/prenormalize.js +94 -0
- package/dist/pipeline/prenormalize.js.map +1 -0
- package/dist/pipeline/resolver.d.ts +56 -0
- package/dist/pipeline/resolver.d.ts.map +1 -0
- package/dist/pipeline/resolver.js +239 -0
- package/dist/pipeline/resolver.js.map +1 -0
- package/dist/pipeline/semantic-data-loader.d.ts +171 -0
- package/dist/pipeline/semantic-data-loader.d.ts.map +1 -0
- package/dist/pipeline/semantic-data-loader.js +677 -0
- package/dist/pipeline/semantic-data-loader.js.map +1 -0
- package/dist/pipeline/semantic-enricher.d.ts +112 -0
- package/dist/pipeline/semantic-enricher.d.ts.map +1 -0
- package/dist/pipeline/semantic-enricher.js +322 -0
- package/dist/pipeline/semantic-enricher.js.map +1 -0
- package/dist/pipeline/tagger.d.ts +121 -0
- package/dist/pipeline/tagger.d.ts.map +1 -0
- package/dist/pipeline/tagger.js +545 -0
- package/dist/pipeline/tagger.js.map +1 -0
- package/dist/pipeline/title-extractor.d.ts +79 -0
- package/dist/pipeline/title-extractor.d.ts.map +1 -0
- package/dist/pipeline/title-extractor.js +801 -0
- package/dist/pipeline/title-extractor.js.map +1 -0
- package/dist/pipeline/validator.d.ts +65 -0
- package/dist/pipeline/validator.d.ts.map +1 -0
- package/dist/pipeline/validator.js +292 -0
- package/dist/pipeline/validator.js.map +1 -0
- package/dist/proxy/index.d.ts +13 -0
- package/dist/proxy/index.d.ts.map +1 -0
- package/dist/proxy/index.js +12 -0
- package/dist/proxy/index.js.map +1 -0
- package/dist/proxy/providers/anthropic.d.ts +28 -0
- package/dist/proxy/providers/anthropic.d.ts.map +1 -0
- package/dist/proxy/providers/anthropic.js +265 -0
- package/dist/proxy/providers/anthropic.js.map +1 -0
- package/dist/proxy/providers/index.d.ts +19 -0
- package/dist/proxy/providers/index.d.ts.map +1 -0
- package/dist/proxy/providers/index.js +41 -0
- package/dist/proxy/providers/index.js.map +1 -0
- package/dist/proxy/providers/openai.d.ts +27 -0
- package/dist/proxy/providers/openai.d.ts.map +1 -0
- package/dist/proxy/providers/openai.js +203 -0
- package/dist/proxy/providers/openai.js.map +1 -0
- package/dist/proxy/providers/streaming-tool-loop.d.ts +12 -0
- package/dist/proxy/providers/streaming-tool-loop.d.ts.map +1 -0
- package/dist/proxy/providers/streaming-tool-loop.js +223 -0
- package/dist/proxy/providers/streaming-tool-loop.js.map +1 -0
- package/dist/proxy/providers/types.d.ts +109 -0
- package/dist/proxy/providers/types.d.ts.map +1 -0
- package/dist/proxy/providers/types.js +2 -0
- package/dist/proxy/providers/types.js.map +1 -0
- package/dist/proxy/proxy-server.d.ts +61 -0
- package/dist/proxy/proxy-server.d.ts.map +1 -0
- package/dist/proxy/proxy-server.js +146 -0
- package/dist/proxy/proxy-server.js.map +1 -0
- package/dist/proxy/rehydra-fetch.d.ts +35 -0
- package/dist/proxy/rehydra-fetch.d.ts.map +1 -0
- package/dist/proxy/rehydra-fetch.js +631 -0
- package/dist/proxy/rehydra-fetch.js.map +1 -0
- package/dist/proxy/rehydra-proxy.d.ts +40 -0
- package/dist/proxy/rehydra-proxy.d.ts.map +1 -0
- package/dist/proxy/rehydra-proxy.js +150 -0
- package/dist/proxy/rehydra-proxy.js.map +1 -0
- package/dist/proxy/sse-parser.d.ts +59 -0
- package/dist/proxy/sse-parser.d.ts.map +1 -0
- package/dist/proxy/sse-parser.js +112 -0
- package/dist/proxy/sse-parser.js.map +1 -0
- package/dist/proxy/system-instruction.d.ts +19 -0
- package/dist/proxy/system-instruction.d.ts.map +1 -0
- package/dist/proxy/system-instruction.js +33 -0
- package/dist/proxy/system-instruction.js.map +1 -0
- package/dist/proxy/tool-loop-stream.d.ts +7 -0
- package/dist/proxy/tool-loop-stream.d.ts.map +1 -0
- package/dist/proxy/tool-loop-stream.js +65 -0
- package/dist/proxy/tool-loop-stream.js.map +1 -0
- package/dist/proxy/types.d.ts +138 -0
- package/dist/proxy/types.d.ts.map +1 -0
- package/dist/proxy/types.js +5 -0
- package/dist/proxy/types.js.map +1 -0
- package/dist/proxy/wrap-client.d.ts +47 -0
- package/dist/proxy/wrap-client.d.ts.map +1 -0
- package/dist/proxy/wrap-client.js +70 -0
- package/dist/proxy/wrap-client.js.map +1 -0
- package/dist/recognizers/address.d.ts +2 -0
- package/dist/recognizers/address.d.ts.map +1 -0
- package/dist/recognizers/address.js +23 -0
- package/dist/recognizers/address.js.map +1 -0
- package/dist/recognizers/base.d.ts +78 -0
- package/dist/recognizers/base.d.ts.map +1 -0
- package/dist/recognizers/base.js +100 -0
- package/dist/recognizers/base.js.map +1 -0
- package/dist/recognizers/bic-swift.d.ts +10 -0
- package/dist/recognizers/bic-swift.d.ts.map +1 -0
- package/dist/recognizers/bic-swift.js +107 -0
- package/dist/recognizers/bic-swift.js.map +1 -0
- package/dist/recognizers/credit-card.d.ts +32 -0
- package/dist/recognizers/credit-card.d.ts.map +1 -0
- package/dist/recognizers/credit-card.js +160 -0
- package/dist/recognizers/credit-card.js.map +1 -0
- package/dist/recognizers/custom-id.d.ts +28 -0
- package/dist/recognizers/custom-id.d.ts.map +1 -0
- package/dist/recognizers/custom-id.js +116 -0
- package/dist/recognizers/custom-id.js.map +1 -0
- package/dist/recognizers/date.d.ts +10 -0
- package/dist/recognizers/date.d.ts.map +1 -0
- package/dist/recognizers/date.js +228 -0
- package/dist/recognizers/date.js.map +1 -0
- package/dist/recognizers/email.d.ts +10 -0
- package/dist/recognizers/email.d.ts.map +1 -0
- package/dist/recognizers/email.js +75 -0
- package/dist/recognizers/email.js.map +1 -0
- package/dist/recognizers/iban.d.ts +14 -0
- package/dist/recognizers/iban.d.ts.map +1 -0
- package/dist/recognizers/iban.js +67 -0
- package/dist/recognizers/iban.js.map +1 -0
- package/dist/recognizers/index.d.ts +25 -0
- package/dist/recognizers/index.d.ts.map +1 -0
- package/dist/recognizers/index.js +53 -0
- package/dist/recognizers/index.js.map +1 -0
- package/dist/recognizers/ip-address.d.ts +14 -0
- package/dist/recognizers/ip-address.d.ts.map +1 -0
- package/dist/recognizers/ip-address.js +183 -0
- package/dist/recognizers/ip-address.js.map +1 -0
- package/dist/recognizers/phone.d.ts +10 -0
- package/dist/recognizers/phone.d.ts.map +1 -0
- package/dist/recognizers/phone.js +145 -0
- package/dist/recognizers/phone.js.map +1 -0
- package/dist/recognizers/postal-code.d.ts +16 -0
- package/dist/recognizers/postal-code.d.ts.map +1 -0
- package/dist/recognizers/postal-code.js +42 -0
- package/dist/recognizers/postal-code.js.map +1 -0
- package/dist/recognizers/registry.d.ts +59 -0
- package/dist/recognizers/registry.d.ts.map +1 -0
- package/dist/recognizers/registry.js +113 -0
- package/dist/recognizers/registry.js.map +1 -0
- package/dist/recognizers/secrets/api-key.d.ts +6 -0
- package/dist/recognizers/secrets/api-key.d.ts.map +1 -0
- package/dist/recognizers/secrets/api-key.js +40 -0
- package/dist/recognizers/secrets/api-key.js.map +1 -0
- package/dist/recognizers/secrets/aws-credentials.d.ts +7 -0
- package/dist/recognizers/secrets/aws-credentials.d.ts.map +1 -0
- package/dist/recognizers/secrets/aws-credentials.js +68 -0
- package/dist/recognizers/secrets/aws-credentials.js.map +1 -0
- package/dist/recognizers/secrets/config-secret.d.ts +8 -0
- package/dist/recognizers/secrets/config-secret.d.ts.map +1 -0
- package/dist/recognizers/secrets/config-secret.js +59 -0
- package/dist/recognizers/secrets/config-secret.js.map +1 -0
- package/dist/recognizers/secrets/connection-string.d.ts +6 -0
- package/dist/recognizers/secrets/connection-string.d.ts.map +1 -0
- package/dist/recognizers/secrets/connection-string.js +40 -0
- package/dist/recognizers/secrets/connection-string.js.map +1 -0
- package/dist/recognizers/secrets/env-var.d.ts +8 -0
- package/dist/recognizers/secrets/env-var.d.ts.map +1 -0
- package/dist/recognizers/secrets/env-var.js +54 -0
- package/dist/recognizers/secrets/env-var.js.map +1 -0
- package/dist/recognizers/secrets/index.d.ts +22 -0
- package/dist/recognizers/secrets/index.d.ts.map +1 -0
- package/dist/recognizers/secrets/index.js +41 -0
- package/dist/recognizers/secrets/index.js.map +1 -0
- package/dist/recognizers/secrets/jwt.d.ts +6 -0
- package/dist/recognizers/secrets/jwt.d.ts.map +1 -0
- package/dist/recognizers/secrets/jwt.js +47 -0
- package/dist/recognizers/secrets/jwt.js.map +1 -0
- package/dist/recognizers/secrets/key-patterns.d.ts +10 -0
- package/dist/recognizers/secrets/key-patterns.d.ts.map +1 -0
- package/dist/recognizers/secrets/key-patterns.js +15 -0
- package/dist/recognizers/secrets/key-patterns.js.map +1 -0
- package/dist/recognizers/secrets/literal-value.d.ts +10 -0
- package/dist/recognizers/secrets/literal-value.d.ts.map +1 -0
- package/dist/recognizers/secrets/literal-value.js +48 -0
- package/dist/recognizers/secrets/literal-value.js.map +1 -0
- package/dist/recognizers/secrets/private-key.d.ts +6 -0
- package/dist/recognizers/secrets/private-key.d.ts.map +1 -0
- package/dist/recognizers/secrets/private-key.js +16 -0
- package/dist/recognizers/secrets/private-key.js.map +1 -0
- package/dist/recognizers/url.d.ts +14 -0
- package/dist/recognizers/url.d.ts.map +1 -0
- package/dist/recognizers/url.js +121 -0
- package/dist/recognizers/url.js.map +1 -0
- package/dist/storage/browser.d.ts +13 -0
- package/dist/storage/browser.d.ts.map +1 -0
- package/dist/storage/browser.js +13 -0
- package/dist/storage/browser.js.map +1 -0
- package/dist/storage/in-memory.d.ts +60 -0
- package/dist/storage/in-memory.d.ts.map +1 -0
- package/dist/storage/in-memory.js +108 -0
- package/dist/storage/in-memory.js.map +1 -0
- package/dist/storage/index.d.ts +11 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +11 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/indexeddb.d.ts +69 -0
- package/dist/storage/indexeddb.d.ts.map +1 -0
- package/dist/storage/indexeddb.js +274 -0
- package/dist/storage/indexeddb.js.map +1 -0
- package/dist/storage/session-base.d.ts +34 -0
- package/dist/storage/session-base.d.ts.map +1 -0
- package/dist/storage/session-base.js +122 -0
- package/dist/storage/session-base.js.map +1 -0
- package/dist/storage/session.d.ts +19 -0
- package/dist/storage/session.d.ts.map +1 -0
- package/dist/storage/session.js +31 -0
- package/dist/storage/session.js.map +1 -0
- package/dist/storage/sqlite.d.ts +80 -0
- package/dist/storage/sqlite.d.ts.map +1 -0
- package/dist/storage/sqlite.js +255 -0
- package/dist/storage/sqlite.js.map +1 -0
- package/dist/storage/types.d.ts +208 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/storage/types.js +6 -0
- package/dist/storage/types.js.map +1 -0
- package/dist/streaming/anonymizer-stream.d.ts +63 -0
- package/dist/streaming/anonymizer-stream.d.ts.map +1 -0
- package/dist/streaming/anonymizer-stream.js +184 -0
- package/dist/streaming/anonymizer-stream.js.map +1 -0
- package/dist/streaming/index.d.ts +9 -0
- package/dist/streaming/index.d.ts.map +1 -0
- package/dist/streaming/index.js +8 -0
- package/dist/streaming/index.js.map +1 -0
- package/dist/streaming/sentence-buffer.d.ts +78 -0
- package/dist/streaming/sentence-buffer.d.ts.map +1 -0
- package/dist/streaming/sentence-buffer.js +239 -0
- package/dist/streaming/sentence-buffer.js.map +1 -0
- package/dist/streaming/stream-factory.d.ts +38 -0
- package/dist/streaming/stream-factory.d.ts.map +1 -0
- package/dist/streaming/stream-factory.js +69 -0
- package/dist/streaming/stream-factory.js.map +1 -0
- package/dist/streaming/types.d.ts +121 -0
- package/dist/streaming/types.d.ts.map +1 -0
- package/dist/streaming/types.js +5 -0
- package/dist/streaming/types.js.map +1 -0
- package/dist/types/index.d.ts +269 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +95 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/pii-types.d.ts +64 -0
- package/dist/types/pii-types.d.ts.map +1 -0
- package/dist/types/pii-types.js +153 -0
- package/dist/types/pii-types.js.map +1 -0
- package/dist/utils/iban-checksum.d.ts +23 -0
- package/dist/utils/iban-checksum.d.ts.map +1 -0
- package/dist/utils/iban-checksum.js +106 -0
- package/dist/utils/iban-checksum.js.map +1 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +11 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/json-walk.d.ts +21 -0
- package/dist/utils/json-walk.d.ts.map +1 -0
- package/dist/utils/json-walk.js +44 -0
- package/dist/utils/json-walk.js.map +1 -0
- package/dist/utils/luhn.d.ts +17 -0
- package/dist/utils/luhn.d.ts.map +1 -0
- package/dist/utils/luhn.js +55 -0
- package/dist/utils/luhn.js.map +1 -0
- package/dist/utils/offsets.d.ts +86 -0
- package/dist/utils/offsets.d.ts.map +1 -0
- package/dist/utils/offsets.js +124 -0
- package/dist/utils/offsets.js.map +1 -0
- package/dist/utils/path.d.ts +34 -0
- package/dist/utils/path.d.ts.map +1 -0
- package/dist/utils/path.js +96 -0
- package/dist/utils/path.js.map +1 -0
- package/dist/utils/regex.d.ts +11 -0
- package/dist/utils/regex.d.ts.map +1 -0
- package/dist/utils/regex.js +14 -0
- package/dist/utils/regex.js.map +1 -0
- package/dist/utils/storage-browser.d.ts +51 -0
- package/dist/utils/storage-browser.d.ts.map +1 -0
- package/dist/utils/storage-browser.js +381 -0
- package/dist/utils/storage-browser.js.map +1 -0
- package/dist/utils/storage-node.d.ts +51 -0
- package/dist/utils/storage-node.d.ts.map +1 -0
- package/dist/utils/storage-node.js +153 -0
- package/dist/utils/storage-node.js.map +1 -0
- package/dist/utils/storage.browser.d.ts +75 -0
- package/dist/utils/storage.browser.d.ts.map +1 -0
- package/dist/utils/storage.browser.js +69 -0
- package/dist/utils/storage.browser.js.map +1 -0
- package/dist/utils/storage.d.ts +73 -0
- package/dist/utils/storage.d.ts.map +1 -0
- package/dist/utils/storage.js +69 -0
- package/dist/utils/storage.js.map +1 -0
- package/index.js +14 -13
- package/package.json +19 -5
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rehydra OpenCode Plugin — Plugin V2.
|
|
3
|
+
*
|
|
4
|
+
* Uses OpenCode Plugin V2 hooks to anonymize secrets before they reach the LLM
|
|
5
|
+
* and rehydrate PII tags before local tool execution:
|
|
6
|
+
* - session.hook("context" | "compaction" | "generate") — anonymize all request
|
|
7
|
+
* messages in place and inject the rehydra instruction when needed.
|
|
8
|
+
* - session.hook("title") — anonymize the title request messages only.
|
|
9
|
+
* - tool.hook("execute.before") — rehydrate PII tags in tool arguments.
|
|
10
|
+
* - tool.hook("execute.after") — rehydrate PII tags in completed tool results.
|
|
11
|
+
* - session.hook("http.response") — rehydrate PII tags in the primary answer
|
|
12
|
+
* body (JSON and SSE) before OpenCode renders it.
|
|
13
|
+
* - session.hook("experimental.ws.receive") — rehydrate PII tags in WebSocket
|
|
14
|
+
* frames carrying model output.
|
|
15
|
+
*/
|
|
16
|
+
import { createAnonymizer } from "../core/anonymizer.js";
|
|
17
|
+
import { AnonymizerSessionImpl } from "../storage/session-base.js";
|
|
18
|
+
import { InMemoryPIIStorageProvider } from "../storage/in-memory.js";
|
|
19
|
+
import { InMemoryKeyProvider } from "../crypto/index.js";
|
|
20
|
+
import { DEFAULT_TAG_FORMAT, SECRET_PII_TYPES, createDefaultPolicy, } from "../types/index.js";
|
|
21
|
+
import { buildPIISystemInstruction } from "../proxy/system-instruction.js";
|
|
22
|
+
import { buildTagPrefix } from "../utils/regex.js";
|
|
23
|
+
import { githubUsernameRecognizer } from "./github-username.js";
|
|
24
|
+
import { protectIdentityTags } from "./identity-recognizer.js";
|
|
25
|
+
import { gitIdentityRecognizer } from "./git-identity.js";
|
|
26
|
+
import { AnonymizationState } from "./v2/anon-state.js";
|
|
27
|
+
import { createLogger } from "./v2/logger.js";
|
|
28
|
+
import { anonymizerConfigFromOptions, normalizePluginOptions, policyFromOptions, } from "./v2/options.js";
|
|
29
|
+
import { SessionStore } from "./v2/sessions.js";
|
|
30
|
+
import { registerSessionContextHook, registerSessionTitleHook, registerToolAfterHook, registerToolBeforeHook, } from "./v2/register-hooks.js";
|
|
31
|
+
import { InMemoryRehydrateTailStore, rehydrateHttpResponse, rehydrateWsFrame, } from "./v2/response-rehydrate.js";
|
|
32
|
+
/**
|
|
33
|
+
* Resolves the project directory from the V2 context, falling back through the
|
|
34
|
+
* legacy V1 fields and finally the process working directory.
|
|
35
|
+
*/
|
|
36
|
+
export function directoryFromContext(ctx) {
|
|
37
|
+
const location = ctx.location?.directory;
|
|
38
|
+
if (typeof location === "string" && location.length > 0)
|
|
39
|
+
return location;
|
|
40
|
+
if (typeof ctx.directory === "string" && ctx.directory.length > 0) {
|
|
41
|
+
return ctx.directory;
|
|
42
|
+
}
|
|
43
|
+
if (typeof ctx.worktree === "string" && ctx.worktree.length > 0) {
|
|
44
|
+
return ctx.worktree;
|
|
45
|
+
}
|
|
46
|
+
return process.cwd();
|
|
47
|
+
}
|
|
48
|
+
/** Normalizes an unknown thrown value into a loggable message. */
|
|
49
|
+
function errorMessage(error) {
|
|
50
|
+
return error instanceof Error ? error.message : String(error);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Registers the response-side hooks that restore PII tags in model output.
|
|
54
|
+
*
|
|
55
|
+
* Both registrations are best-effort: if OpenCode does not expose a hook (or
|
|
56
|
+
* rejects it), the failure is logged and the remaining hooks still work.
|
|
57
|
+
*/
|
|
58
|
+
async function registerResponseHooks(ctx, registrations, logger, resolveSession, responseDeps) {
|
|
59
|
+
try {
|
|
60
|
+
const httpRegistration = await ctx.session.hook("http.response", async (event) => {
|
|
61
|
+
try {
|
|
62
|
+
const session = resolveSession(event.sessionID);
|
|
63
|
+
await rehydrateHttpResponse(event, {
|
|
64
|
+
rehydrate: (input) => session.rehydrate(input),
|
|
65
|
+
log: logger,
|
|
66
|
+
sessionID: event.sessionID,
|
|
67
|
+
kind: event.kind,
|
|
68
|
+
tagPrefix: responseDeps.tagPrefix,
|
|
69
|
+
tagClose: responseDeps.tagClose,
|
|
70
|
+
tailStore: responseDeps.tailStore,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
logger.error("rehydra http.response hook failed", {
|
|
75
|
+
error: errorMessage(error),
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
registrations.push(httpRegistration);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
logger.error("failed to register rehydra http.response hook", {
|
|
83
|
+
error: errorMessage(error),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
const wsRegistration = await ctx.session.hook("experimental.ws.receive", async (event) => {
|
|
88
|
+
try {
|
|
89
|
+
const session = resolveSession(event.sessionID);
|
|
90
|
+
await rehydrateWsFrame(event, {
|
|
91
|
+
rehydrate: (input) => session.rehydrate(input),
|
|
92
|
+
log: logger,
|
|
93
|
+
sessionID: event.sessionID,
|
|
94
|
+
tagPrefix: responseDeps.tagPrefix,
|
|
95
|
+
tagClose: responseDeps.tagClose,
|
|
96
|
+
tailStore: responseDeps.tailStore,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
logger.error("rehydra experimental.ws.receive hook failed", {
|
|
101
|
+
error: errorMessage(error),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
registrations.push(wsRegistration);
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
logger.error("failed to register rehydra experimental.ws.receive hook", {
|
|
109
|
+
error: errorMessage(error),
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Creates a Rehydra plugin for OpenCode.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* // .opencode/plugins/rehydra.ts
|
|
119
|
+
* import { createRehydraPlugin } from "rehydra/opencode-plugin";
|
|
120
|
+
* export default createRehydraPlugin({
|
|
121
|
+
* envFiles: [".env", ".env.local"],
|
|
122
|
+
* });
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export function createRehydraPlugin(options) {
|
|
126
|
+
return {
|
|
127
|
+
id: "rehydra",
|
|
128
|
+
async setup(ctx) {
|
|
129
|
+
const directory = directoryFromContext(ctx);
|
|
130
|
+
const logger = createLogger(ctx, "rehydra");
|
|
131
|
+
const registrations = [];
|
|
132
|
+
const tailStore = new InMemoryRehydrateTailStore();
|
|
133
|
+
let anonymizer;
|
|
134
|
+
// Releases every resource acquired by this setup. It is idempotent and
|
|
135
|
+
// isolates each dispose so one throwing registration cannot strand the
|
|
136
|
+
// others or the anonymizer. Called by the returned cleanup and by the
|
|
137
|
+
// failure path below.
|
|
138
|
+
let disposed = false;
|
|
139
|
+
const disposeAll = async () => {
|
|
140
|
+
if (disposed)
|
|
141
|
+
return;
|
|
142
|
+
disposed = true;
|
|
143
|
+
const pending = registrations.splice(0, registrations.length);
|
|
144
|
+
await Promise.all(pending.map(async (registration) => {
|
|
145
|
+
try {
|
|
146
|
+
await registration.dispose();
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
logger.warn("failed to dispose rehydra hook", {
|
|
150
|
+
error: errorMessage(error),
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}));
|
|
154
|
+
tailStore.clear();
|
|
155
|
+
if (anonymizer !== undefined) {
|
|
156
|
+
try {
|
|
157
|
+
await anonymizer.dispose();
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
logger.warn("failed to dispose rehydra anonymizer", {
|
|
161
|
+
error: errorMessage(error),
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
let succeeded = false;
|
|
167
|
+
try {
|
|
168
|
+
// Constructor options (local config scripts) take precedence over
|
|
169
|
+
// options supplied by OpenCode itself; both are untrusted and normalized
|
|
170
|
+
// below.
|
|
171
|
+
const resolved = normalizePluginOptions({ ...ctx.options, ...options }, directory);
|
|
172
|
+
const anonymizerConfig = anonymizerConfigFromOptions(resolved, directory);
|
|
173
|
+
const tagFormat = anonymizerConfig.tagFormat ?? resolved.tagFormat ?? DEFAULT_TAG_FORMAT;
|
|
174
|
+
const tagPrefix = buildTagPrefix(tagFormat);
|
|
175
|
+
const rehydraInstruction = `<rehydra>\n${buildPIISystemInstruction(tagFormat)}\n</rehydra>`;
|
|
176
|
+
const keyProvider = new InMemoryKeyProvider();
|
|
177
|
+
const piiStorage = new InMemoryPIIStorageProvider();
|
|
178
|
+
const createdAnonymizer = createAnonymizer({
|
|
179
|
+
...anonymizerConfig,
|
|
180
|
+
tagFormat,
|
|
181
|
+
keyProvider,
|
|
182
|
+
piiStorageProvider: piiStorage,
|
|
183
|
+
});
|
|
184
|
+
anonymizer = createdAnonymizer;
|
|
185
|
+
if (resolved.vcsIdentities === true) {
|
|
186
|
+
createdAnonymizer
|
|
187
|
+
.getRegistry()
|
|
188
|
+
.register(protectIdentityTags(githubUsernameRecognizer, tagFormat));
|
|
189
|
+
createdAnonymizer
|
|
190
|
+
.getRegistry()
|
|
191
|
+
.register(protectIdentityTags(gitIdentityRecognizer, tagFormat));
|
|
192
|
+
}
|
|
193
|
+
await createdAnonymizer.initialize();
|
|
194
|
+
// Base policy: URL and IP_ADDRESS disabled by default.
|
|
195
|
+
// `policyFromOptions` re-adds the opt-in secret types the anonymizer
|
|
196
|
+
// registers internally.
|
|
197
|
+
const disableTypes = resolved.disableTypes ?? ["URL", "IP_ADDRESS"];
|
|
198
|
+
const policy = policyFromOptions(resolved);
|
|
199
|
+
const locale = resolved.locale;
|
|
200
|
+
const identityPolicy = (types) => {
|
|
201
|
+
const defaults = createDefaultPolicy();
|
|
202
|
+
const configPolicy = anonymizerConfig.defaultPolicy;
|
|
203
|
+
const enabledTypes = new Set(policy?.enabledTypes ??
|
|
204
|
+
configPolicy?.enabledTypes ??
|
|
205
|
+
defaults.enabledTypes);
|
|
206
|
+
const regexEnabledTypes = new Set(policy?.regexEnabledTypes ??
|
|
207
|
+
configPolicy?.regexEnabledTypes ??
|
|
208
|
+
defaults.regexEnabledTypes);
|
|
209
|
+
if (anonymizerConfig.secrets?.enabled === true) {
|
|
210
|
+
for (const type of SECRET_PII_TYPES) {
|
|
211
|
+
if (!disableTypes.includes(type)) {
|
|
212
|
+
enabledTypes.add(type);
|
|
213
|
+
regexEnabledTypes.add(type);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
for (const type of types) {
|
|
218
|
+
if (!disableTypes.includes(type)) {
|
|
219
|
+
enabledTypes.add(type);
|
|
220
|
+
regexEnabledTypes.add(type);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
...policy,
|
|
225
|
+
enabledTypes,
|
|
226
|
+
regexEnabledTypes,
|
|
227
|
+
reuseIdsForRepeatedPII: true,
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
// One session per OpenCode session, keyed by sessionID.
|
|
231
|
+
const sessionStore = new SessionStore();
|
|
232
|
+
const resolveSession = (sessionID) => sessionStore.get(sessionID, () => new AnonymizerSessionImpl(createdAnonymizer, sessionID, piiStorage, keyProvider));
|
|
233
|
+
const state = new AnonymizationState();
|
|
234
|
+
const scrubOptions = {
|
|
235
|
+
locale,
|
|
236
|
+
policy,
|
|
237
|
+
vcsIdentities: resolved.vcsIdentities === true,
|
|
238
|
+
identityPolicy,
|
|
239
|
+
};
|
|
240
|
+
const deps = {
|
|
241
|
+
logger,
|
|
242
|
+
resolveSession,
|
|
243
|
+
state,
|
|
244
|
+
rehydraInstruction,
|
|
245
|
+
tagPrefix,
|
|
246
|
+
scrubOptions,
|
|
247
|
+
};
|
|
248
|
+
// Register each hook group independently: a rejected registration must
|
|
249
|
+
// not prevent the remaining groups from being installed.
|
|
250
|
+
const registerGroup = async (label, register) => {
|
|
251
|
+
try {
|
|
252
|
+
const registered = await register();
|
|
253
|
+
if (registered !== undefined) {
|
|
254
|
+
registrations.push(...registered);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
logger.error(`failed to register rehydra ${label} hooks`, {
|
|
259
|
+
error: errorMessage(error),
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
await registerGroup("session context", () => registerSessionContextHook(ctx, deps));
|
|
264
|
+
await registerGroup("session title", () => registerSessionTitleHook(ctx, deps));
|
|
265
|
+
await registerGroup("tool execute.before", () => registerToolBeforeHook(ctx, deps));
|
|
266
|
+
await registerGroup("tool execute.after", () => registerToolAfterHook(ctx, deps));
|
|
267
|
+
// Response hooks restore the real values in model output before
|
|
268
|
+
// OpenCode renders them. Registration is best-effort: an unavailable
|
|
269
|
+
// hook must not prevent the plugin (and OpenCode) from starting.
|
|
270
|
+
await registerGroup("response", () => registerResponseHooks(ctx, registrations, logger, resolveSession, {
|
|
271
|
+
tagPrefix,
|
|
272
|
+
tagClose: tagFormat.close,
|
|
273
|
+
tailStore,
|
|
274
|
+
}));
|
|
275
|
+
logger.info("plugin initialized", {
|
|
276
|
+
envFiles: anonymizerConfig.secrets?.envFiles,
|
|
277
|
+
redactValueCount: resolved.redactValues?.length ?? 0,
|
|
278
|
+
disableTypes,
|
|
279
|
+
});
|
|
280
|
+
succeeded = true;
|
|
281
|
+
return disposeAll;
|
|
282
|
+
}
|
|
283
|
+
finally {
|
|
284
|
+
if (!succeeded) {
|
|
285
|
+
await disposeAll();
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
/** Default plugin instance used by `opencode.json`. */
|
|
292
|
+
export const plugin = createRehydraPlugin();
|
|
293
|
+
export default plugin;
|
|
294
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/opencode-plugin/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,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ACF,MAAM,aAAa,CAAC,qBAAqB,EAAE,GAAG,EAAE,CAC9C,sBAAsB,CAAC,GAAG,EAAE,IAAI,CAAC,CAClC,CAAC;gBACF,MAAM,aAAa,CAAC,oBAAoB,EAAE,GAAG,EAAE,CAC7C,qBAAqB,CAAC,GAAG,EAAE,IAAI,CAAC,CACjC,CAAC;gBAEF,gEAAgE;gBAChE,qEAAqE;gBACrE,iEAAiE;gBACjE,MAAM,aAAa,CAAC,UAAU,EAAE,GAAG,EAAE,CACnC,qBAAqB,CAAC,GAAG,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE;oBAChE,SAAS;oBACT,QAAQ,EAAE,SAAS,CAAC,KAAK;oBACzB,SAAS;iBACV,CAAC,CACH,CAAC;gBAEF,MAAM,CAAC,IAAI,CAAC,oBAAoB,EAAE;oBAChC,QAAQ,EAAE,gBAAgB,CAAC,OAAO,EAAE,QAAQ;oBAC5C,gBAAgB,EAAE,QAAQ,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC;oBACpD,YAAY;iBACb,CAAC,CAAC;gBAEH,SAAS,GAAG,IAAI,CAAC;gBACjB,OAAO,UAAU,CAAC;YACpB,CAAC;oBAAS,CAAC;gBACT,IAAI,CAAC,SAAS,EAAE,CAAC;oBACf,MAAM,UAAU,EAAE,CAAC;gBACrB,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,uDAAuD;AACvD,MAAM,CAAC,MAAM,MAAM,GAAW,mBAAmB,EAAE,CAAC;AAEpD,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode Plugin Configuration Types
|
|
3
|
+
*/
|
|
4
|
+
import type { AnonymizerConfig } from "../core/anonymizer.js";
|
|
5
|
+
import type { AnonymizationPolicy, TagFormat } from "../types/index.js";
|
|
6
|
+
import type { PIIType } from "../types/pii-types.js";
|
|
7
|
+
/** PII type names as strings, for convenience in plugin config */
|
|
8
|
+
export type PIITypeName = `${PIIType}`;
|
|
9
|
+
/**
|
|
10
|
+
* Configuration options for the Rehydra OpenCode plugin.
|
|
11
|
+
*/
|
|
12
|
+
export interface RehydraPluginOptions {
|
|
13
|
+
/** Paths/globs relative to the OpenCode project directory. Defaults to recursive .env discovery.
|
|
14
|
+
* Skips node_modules, .git, and symlinks. Pass [] to disable file loading. */
|
|
15
|
+
envFiles?: string[];
|
|
16
|
+
/** Explicit values to always redact */
|
|
17
|
+
redactValues?: string[];
|
|
18
|
+
/** Minimum value length to consider as a secret (default: 4) */
|
|
19
|
+
minValueLength?: number;
|
|
20
|
+
/** PII types to disable (default: ["URL", "IP_ADDRESS"]). Pass [] to enable all types. */
|
|
21
|
+
disableTypes?: PIITypeName[];
|
|
22
|
+
/** Locale hint for anonymization */
|
|
23
|
+
locale?: string;
|
|
24
|
+
/** Redact identities found in Git and GitHub CLI output */
|
|
25
|
+
vcsIdentities?: boolean;
|
|
26
|
+
/** Policy overrides */
|
|
27
|
+
policy?: Partial<AnonymizationPolicy>;
|
|
28
|
+
/** Advanced: full anonymizer config (overrides envFiles/redactValues/minValueLength) */
|
|
29
|
+
anonymizer?: AnonymizerConfig;
|
|
30
|
+
/** Tag format configuration (shorthand — also available via anonymizer.tagFormat) */
|
|
31
|
+
tagFormat?: TagFormat;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/opencode-plugin/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD,kEAAkE;AAClE,MAAM,MAAM,WAAW,GAAG,GAAG,OAAO,EAAE,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;kFAC8E;IAC9E,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAEpB,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB,gEAAgE;IAChE,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,0FAA0F;IAC1F,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IAE7B,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,2DAA2D;IAC3D,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,uBAAuB;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAEtC,wFAAwF;IACxF,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAE9B,qFAAqF;IACrF,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/opencode-plugin/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tracks whether any anonymization has occurred during a plugin's lifetime.
|
|
3
|
+
*
|
|
4
|
+
* The system-prompt instruction is only injected once anonymization has
|
|
5
|
+
* actually happened, so the flag lives outside the individual hooks.
|
|
6
|
+
*/
|
|
7
|
+
export declare class AnonymizationState {
|
|
8
|
+
hasAnonymized: boolean;
|
|
9
|
+
/** Clears the flag, e.g. when a fresh plugin instance takes over. */
|
|
10
|
+
reset(): void;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=anon-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anon-state.d.ts","sourceRoot":"","sources":["../../../src/opencode-plugin/v2/anon-state.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,kBAAkB;IAC7B,aAAa,UAAS;IAEtB,qEAAqE;IACrE,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tracks whether any anonymization has occurred during a plugin's lifetime.
|
|
3
|
+
*
|
|
4
|
+
* The system-prompt instruction is only injected once anonymization has
|
|
5
|
+
* actually happened, so the flag lives outside the individual hooks.
|
|
6
|
+
*/
|
|
7
|
+
export class AnonymizationState {
|
|
8
|
+
hasAnonymized = false;
|
|
9
|
+
/** Clears the flag, e.g. when a fresh plugin instance takes over. */
|
|
10
|
+
reset() {
|
|
11
|
+
this.hasAnonymized = false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=anon-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anon-state.js","sourceRoot":"","sources":["../../../src/opencode-plugin/v2/anon-state.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,kBAAkB;IAC7B,aAAa,GAAG,KAAK,CAAC;IAEtB,qEAAqE;IACrE,KAAK;QACH,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PII tag rehydration for OpenCode Plugin V2 tool hooks.
|
|
3
|
+
*/
|
|
4
|
+
import type { AnonymizerSessionImpl } from "../../storage/session-base.js";
|
|
5
|
+
/**
|
|
6
|
+
* Recursively rehydrate all string values containing PII tags.
|
|
7
|
+
* Returns a new value (for strings/arrays) or the same object mutated in-place
|
|
8
|
+
* (for plain objects). The in-place mutation is required because OpenCode's
|
|
9
|
+
* tool hooks use the original reference for execution — replacing the object
|
|
10
|
+
* wholesale has no effect.
|
|
11
|
+
*/
|
|
12
|
+
export declare function deepRehydrate(value: unknown, session: AnonymizerSessionImpl, tagPrefix: string): Promise<unknown>;
|
|
13
|
+
//# sourceMappingURL=deep-rehydrate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-rehydrate.d.ts","sourceRoot":"","sources":["../../../src/opencode-plugin/v2/deep-rehydrate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAE3E;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,qBAAqB,EAC9B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,OAAO,CAAC,CAqBlB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PII tag rehydration for OpenCode Plugin V2 tool hooks.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Recursively rehydrate all string values containing PII tags.
|
|
6
|
+
* Returns a new value (for strings/arrays) or the same object mutated in-place
|
|
7
|
+
* (for plain objects). The in-place mutation is required because OpenCode's
|
|
8
|
+
* tool hooks use the original reference for execution — replacing the object
|
|
9
|
+
* wholesale has no effect.
|
|
10
|
+
*/
|
|
11
|
+
export async function deepRehydrate(value, session, tagPrefix) {
|
|
12
|
+
if (typeof value === "string") {
|
|
13
|
+
if (value.includes(tagPrefix)) {
|
|
14
|
+
return session.rehydrate(value);
|
|
15
|
+
}
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
if (Array.isArray(value)) {
|
|
19
|
+
for (let i = 0; i < value.length; i++) {
|
|
20
|
+
value[i] = await deepRehydrate(value[i], session, tagPrefix);
|
|
21
|
+
}
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
if (value !== null && typeof value === "object") {
|
|
25
|
+
const obj = value;
|
|
26
|
+
for (const key of Object.keys(obj)) {
|
|
27
|
+
obj[key] = await deepRehydrate(obj[key], session, tagPrefix);
|
|
28
|
+
}
|
|
29
|
+
return obj;
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=deep-rehydr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in shared helpers.
|
|
3
|
+
*
|
|
4
|
+
* Barrel export so the plugin entry point can import every helper from a
|
|
5
|
+
* single path.
|
|
6
|
+
*/
|
|
7
|
+
export * from "./types.js";
|
|
8
|
+
export * from "./logger.js";
|
|
9
|
+
export * from "./options.js";
|
|
10
|
+
export * from "./sessions.js";
|
|
11
|
+
export * from "./anon-state.js";
|
|
12
|
+
export * from "./deep-rehydrate.js";
|
|
13
|
+
export * from "./scrub-messages.js";
|
|
14
|
+
export * from "./register-hooks.js";
|
|
15
|
+
export * from "./sse.js";
|
|
16
|
+
export * from "./response-rehydrate.js";
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/opencode-plugin/v2/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V2 OpenCode plugin shared helpers.
|
|
3
|
+
*
|
|
4
|
+
* Barrel export so the plugin entry point can import every helper from a
|
|
5
|
+
* single path.
|
|
6
|
+
*/
|
|
7
|
+
export * from "./types.js";
|
|
8
|
+
export * from "./logger.js";
|
|
9
|
+
export * from "./options.js";
|
|
10
|
+
export * from "./sessions.js";
|
|
11
|
+
export * from "./anon-state.js";
|
|
12
|
+
export * from "./deep-rehydrate.js";
|
|
13
|
+
export * from "./scrub-messages.js";
|
|
14
|
+
export * from "./register-hooks.js";
|
|
15
|
+
export * from "./sse.js";
|
|
16
|
+
export * from "./response-rehydrate.js";
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/opencode-plugin/v2/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode plugin logger.
|
|
3
|
+
*
|
|
4
|
+
* Accommodates both client shapes the plugin may receive:
|
|
5
|
+
* - V2: `ctx.client.app.log({ body: { service, level, message, extra? } })`,
|
|
6
|
+
* where `client` / `app` may be absent entirely.
|
|
7
|
+
* - V1: a raw client exposing `app.log(...)`.
|
|
8
|
+
*
|
|
9
|
+
* When no usable sink exists — or the sink throws / rejects — the message is
|
|
10
|
+
* emitted to `console.warn` / `console.error` so swallowed hook failures stay
|
|
11
|
+
* observable in development and tests.
|
|
12
|
+
*
|
|
13
|
+
* Logging is best-effort: it must never propagate into plugin hook execution.
|
|
14
|
+
*/
|
|
15
|
+
import type { V2Logger } from "./types.js";
|
|
16
|
+
/**
|
|
17
|
+
* Creates a logger bound to a plugin context (or raw OpenCode client).
|
|
18
|
+
*
|
|
19
|
+
* @param source - Plugin context (`ctx.client.app.log`) or a raw client
|
|
20
|
+
* (`source.app.log`). Either shape may be missing.
|
|
21
|
+
* @param service - Service tag reported to OpenCode's log stream.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createLogger(source: unknown, service?: string): V2Logger;
|
|
24
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/opencode-plugin/v2/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA6B3C;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,SAAY,GAAG,QAAQ,CAkD3E"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode plugin logger.
|
|
3
|
+
*
|
|
4
|
+
* Accommodates both client shapes the plugin may receive:
|
|
5
|
+
* - V2: `ctx.client.app.log({ body: { service, level, message, extra? } })`,
|
|
6
|
+
* where `client` / `app` may be absent entirely.
|
|
7
|
+
* - V1: a raw client exposing `app.log(...)`.
|
|
8
|
+
*
|
|
9
|
+
* When no usable sink exists — or the sink throws / rejects — the message is
|
|
10
|
+
* emitted to `console.warn` / `console.error` so swallowed hook failures stay
|
|
11
|
+
* observable in development and tests.
|
|
12
|
+
*
|
|
13
|
+
* Logging is best-effort: it must never propagate into plugin hook execution.
|
|
14
|
+
*/
|
|
15
|
+
/** Serializes extra context without ever throwing. */
|
|
16
|
+
function safeStringify(value) {
|
|
17
|
+
try {
|
|
18
|
+
return JSON.stringify(value) ?? String(value);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return String(value);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates a logger bound to a plugin context (or raw OpenCode client).
|
|
26
|
+
*
|
|
27
|
+
* @param source - Plugin context (`ctx.client.app.log`) or a raw client
|
|
28
|
+
* (`source.app.log`). Either shape may be missing.
|
|
29
|
+
* @param service - Service tag reported to OpenCode's log stream.
|
|
30
|
+
*/
|
|
31
|
+
export function createLogger(source, service = "rehydra") {
|
|
32
|
+
const candidate = source;
|
|
33
|
+
const app = candidate?.client?.app ?? candidate?.app;
|
|
34
|
+
function fallback(level, message, extra) {
|
|
35
|
+
const suffix = extra === undefined ? "" : ` extra=${safeStringify(extra)}`;
|
|
36
|
+
const line = `service=${service} level=${level} message=${message}${suffix}`;
|
|
37
|
+
if (level === "error") {
|
|
38
|
+
// eslint-disable-next-line no-console
|
|
39
|
+
console.error(line);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// eslint-disable-next-line no-console
|
|
43
|
+
console.warn(line);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function log(level, message, extra) {
|
|
47
|
+
const logFn = app?.log;
|
|
48
|
+
if (typeof logFn !== "function") {
|
|
49
|
+
fallback(level, message, extra);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
const result = logFn.call(app, {
|
|
54
|
+
body: { service, level, message, extra },
|
|
55
|
+
});
|
|
56
|
+
if (result instanceof Promise) {
|
|
57
|
+
result.catch(() => {
|
|
58
|
+
fallback(level, message, extra);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
fallback(level, message, extra);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
debug: (message, extra) => log("debug", message, extra),
|
|
68
|
+
info: (message, extra) => log("info", message, extra),
|
|
69
|
+
warn: (message, extra) => log("warn", message, extra),
|
|
70
|
+
error: (message, extra) => log("error", message, extra),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/opencode-plugin/v2/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAsBH,sDAAsD;AACtD,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAAC,MA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