opencode-rehydar 0.14.2 → 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 +6 -4
- package/package.json +19 -5
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode plugin option normalization.
|
|
3
|
+
*
|
|
4
|
+
* OpenCode passes plugin options as untrusted, untyped data. These helpers
|
|
5
|
+
* validate the shape against {@link RehydraPluginOptions}, drop unknown or
|
|
6
|
+
* malformed fields, apply the plugin's documented defaults, and never throw.
|
|
7
|
+
*
|
|
8
|
+
* The resolved helpers mirror the behaviour of the original plugin:
|
|
9
|
+
* - {@link anonymizerConfigFromOptions} defaults `secrets.envBaseDirectory` to
|
|
10
|
+
* the project directory.
|
|
11
|
+
* - {@link policyFromOptions} keeps URL/IP_ADDRESS disabled by default while
|
|
12
|
+
* re-adding the opt-in secret types the anonymizer enables internally.
|
|
13
|
+
*/
|
|
14
|
+
import type { AnonymizerConfig } from "../../core/anonymizer.js";
|
|
15
|
+
import type { AnonymizationPolicy } from "../../types/index.js";
|
|
16
|
+
import type { RehydraPluginOptions } from "../types.js";
|
|
17
|
+
/**
|
|
18
|
+
* Resolves the canonical OpenCode config directory (`$XDG_CONFIG_HOME/opencode`
|
|
19
|
+
* or `$HOME/.config/opencode`). Returns `undefined` when no usable path can be
|
|
20
|
+
* derived. Honours `XDG_CONFIG_HOME` on every platform so distros overriding
|
|
21
|
+
* the spec keep working, and falls back to `~/.config/opencode` per the
|
|
22
|
+
* OpenCode XDG spec.
|
|
23
|
+
*/
|
|
24
|
+
export declare function opencodeConfigDirectory(env?: NodeJS.ProcessEnv, homedirFn?: () => string): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Heuristic: returns `true` when `projectDir` is somewhere underneath (or equal
|
|
27
|
+
* to) `opencodeConfigDir`. Mirrors a directory-equality check rather than
|
|
28
|
+
* relying on a separator-suffix workaround.
|
|
29
|
+
*/
|
|
30
|
+
export declare function shouldUseOpencodeConfigDir(projectDir: string, opencodeConfigDir: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Validates and normalizes raw OpenCode plugin options.
|
|
33
|
+
*
|
|
34
|
+
* Unknown or malformed fields are ignored and missing fields fall back to the
|
|
35
|
+
* plugin defaults. When no `anonymizer` is supplied, one is derived from the
|
|
36
|
+
* top-level secrets fields.
|
|
37
|
+
*
|
|
38
|
+
* @param raw - Untrusted options from OpenCode configuration.
|
|
39
|
+
* @param ctxDirectory - Project directory, used as `secrets.envBaseDirectory`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function normalizePluginOptions(raw: unknown, ctxDirectory: string): RehydraPluginOptions;
|
|
42
|
+
/**
|
|
43
|
+
* Resolves the anonymizer configuration.
|
|
44
|
+
*
|
|
45
|
+
* The base directory for `envFiles` paths is picked in this order:
|
|
46
|
+
* 1. `anonymizer.secrets.envBaseDirectory` if the user configured it.
|
|
47
|
+
* 2. The OpenCode config directory (`~/.config/opencode` on every supported
|
|
48
|
+
* platform) — when the user has not configured their own `anonymizer`
|
|
49
|
+
* block. This means a single `~/.config/opencode/.env` shared across all
|
|
50
|
+
* projects works without per-project paths, while project-local discovery
|
|
51
|
+
* stays opt-in by setting `secrets.envBaseDirectory` explicitly.
|
|
52
|
+
*
|
|
53
|
+
* 3. The project directory (final fallback).
|
|
54
|
+
*/
|
|
55
|
+
export declare function anonymizerConfigFromOptions(options: RehydraPluginOptions, ctxDirectory: string, env?: NodeJS.ProcessEnv, homedirFn?: () => string): AnonymizerConfig;
|
|
56
|
+
/**
|
|
57
|
+
* Builds the policy override implied by `disableTypes`.
|
|
58
|
+
*
|
|
59
|
+
* Returns `options.policy` unchanged when nothing is disabled (or the caller
|
|
60
|
+
* explicitly disabled nothing), matching the original plugin behaviour.
|
|
61
|
+
*/
|
|
62
|
+
export declare function policyFromOptions(options: RehydraPluginOptions): Partial<AnonymizationPolicy> | undefined;
|
|
63
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/opencode-plugin/v2/options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAMjE,OAAO,KAAK,EAAE,mBAAmB,EAA4B,MAAM,sBAAsB,CAAC;AAC1F,OAAO,KAAK,EAAe,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAMrE;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,SAAS,GAAE,MAAM,MAAgB,GAChC,MAAM,GAAG,SAAS,CAYpB;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,MAAM,EAClB,iBAAiB,EAAE,MAAM,GACxB,OAAO,CAKT;AA8CD;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,OAAO,EACZ,YAAY,EAAE,MAAM,GACnB,oBAAoB,CA2BtB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,oBAAoB,EAC7B,YAAY,EAAE,MAAM,EACpB,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,SAAS,GAAE,MAAM,MAAgB,GAChC,gBAAgB,CAuBlB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,GAAG,SAAS,CAuB1C"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode plugin option normalization.
|
|
3
|
+
*
|
|
4
|
+
* OpenCode passes plugin options as untrusted, untyped data. These helpers
|
|
5
|
+
* validate the shape against {@link RehydraPluginOptions}, drop unknown or
|
|
6
|
+
* malformed fields, apply the plugin's documented defaults, and never throw.
|
|
7
|
+
*
|
|
8
|
+
* The resolved helpers mirror the behaviour of the original plugin:
|
|
9
|
+
* - {@link anonymizerConfigFromOptions} defaults `secrets.envBaseDirectory` to
|
|
10
|
+
* the project directory.
|
|
11
|
+
* - {@link policyFromOptions} keeps URL/IP_ADDRESS disabled by default while
|
|
12
|
+
* re-adding the opt-in secret types the anonymizer enables internally.
|
|
13
|
+
*/
|
|
14
|
+
import { homedir } from "node:os";
|
|
15
|
+
import { join } from "node:path";
|
|
16
|
+
import { PIIType, SECRET_PII_TYPES, createDefaultPolicy, } from "../../types/index.js";
|
|
17
|
+
const DEFAULT_DISABLE_TYPES = ["URL", "IP_ADDRESS"];
|
|
18
|
+
const DEFAULT_ENV_FILES = ["**/.env*"];
|
|
19
|
+
const DEFAULT_MIN_VALUE_LENGTH = 4;
|
|
20
|
+
/**
|
|
21
|
+
* Resolves the canonical OpenCode config directory (`$XDG_CONFIG_HOME/opencode`
|
|
22
|
+
* or `$HOME/.config/opencode`). Returns `undefined` when no usable path can be
|
|
23
|
+
* derived. Honours `XDG_CONFIG_HOME` on every platform so distros overriding
|
|
24
|
+
* the spec keep working, and falls back to `~/.config/opencode` per the
|
|
25
|
+
* OpenCode XDG spec.
|
|
26
|
+
*/
|
|
27
|
+
export function opencodeConfigDirectory(env = process.env, homedirFn = homedir) {
|
|
28
|
+
const xdg = env.XDG_CONFIG_HOME;
|
|
29
|
+
if (typeof xdg === "string" && xdg.trim().length > 0) {
|
|
30
|
+
return join(xdg, "opencode");
|
|
31
|
+
}
|
|
32
|
+
const candidates = [env.HOME, env.USERPROFILE, homedirFn()];
|
|
33
|
+
for (const candidate of candidates) {
|
|
34
|
+
if (typeof candidate === "string" && candidate.trim().length > 0) {
|
|
35
|
+
return join(candidate, ".config", "opencode");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Heuristic: returns `true` when `projectDir` is somewhere underneath (or equal
|
|
42
|
+
* to) `opencodeConfigDir`. Mirrors a directory-equality check rather than
|
|
43
|
+
* relying on a separator-suffix workaround.
|
|
44
|
+
*/
|
|
45
|
+
export function shouldUseOpencodeConfigDir(projectDir, opencodeConfigDir) {
|
|
46
|
+
if (projectDir === opencodeConfigDir)
|
|
47
|
+
return false;
|
|
48
|
+
const withSep = opencodeConfigDir.replace(/[\/\\]+$/, "") + "/";
|
|
49
|
+
const candidate = projectDir.replace(/[\/\\]+$/, "");
|
|
50
|
+
return candidate.startsWith(withSep);
|
|
51
|
+
}
|
|
52
|
+
function isRecord(value) {
|
|
53
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
54
|
+
}
|
|
55
|
+
function asStringArray(value) {
|
|
56
|
+
if (!Array.isArray(value))
|
|
57
|
+
return undefined;
|
|
58
|
+
return value.filter((item) => typeof item === "string");
|
|
59
|
+
}
|
|
60
|
+
function asPIITypeNames(value) {
|
|
61
|
+
if (!Array.isArray(value))
|
|
62
|
+
return undefined;
|
|
63
|
+
const known = new Set(Object.values(PIIType));
|
|
64
|
+
return value.filter((item) => typeof item === "string" && known.has(item));
|
|
65
|
+
}
|
|
66
|
+
function asPositiveInteger(value) {
|
|
67
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
function asTagFormat(value) {
|
|
73
|
+
if (!isRecord(value))
|
|
74
|
+
return undefined;
|
|
75
|
+
if (typeof value.open !== "string" || typeof value.close !== "string") {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
const keyword = typeof value.keyword === "string" ? value.keyword : undefined;
|
|
79
|
+
return { open: value.open, close: value.close, keyword };
|
|
80
|
+
}
|
|
81
|
+
function defaultSecretsConfig(options) {
|
|
82
|
+
return {
|
|
83
|
+
enabled: true,
|
|
84
|
+
envFiles: options.envFiles ?? DEFAULT_ENV_FILES,
|
|
85
|
+
redactValues: options.redactValues,
|
|
86
|
+
minValueLength: options.minValueLength ?? DEFAULT_MIN_VALUE_LENGTH,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Validates and normalizes raw OpenCode plugin options.
|
|
91
|
+
*
|
|
92
|
+
* Unknown or malformed fields are ignored and missing fields fall back to the
|
|
93
|
+
* plugin defaults. When no `anonymizer` is supplied, one is derived from the
|
|
94
|
+
* top-level secrets fields.
|
|
95
|
+
*
|
|
96
|
+
* @param raw - Untrusted options from OpenCode configuration.
|
|
97
|
+
* @param ctxDirectory - Project directory, used as `secrets.envBaseDirectory`.
|
|
98
|
+
*/
|
|
99
|
+
export function normalizePluginOptions(raw, ctxDirectory) {
|
|
100
|
+
const source = isRecord(raw) ? raw : {};
|
|
101
|
+
const normalized = {
|
|
102
|
+
envFiles: asStringArray(source.envFiles) ?? DEFAULT_ENV_FILES,
|
|
103
|
+
redactValues: asStringArray(source.redactValues),
|
|
104
|
+
minValueLength: asPositiveInteger(source.minValueLength) ?? DEFAULT_MIN_VALUE_LENGTH,
|
|
105
|
+
disableTypes: asPIITypeNames(source.disableTypes) ?? DEFAULT_DISABLE_TYPES,
|
|
106
|
+
vcsIdentities: typeof source.vcsIdentities === "boolean" ? source.vcsIdentities : false,
|
|
107
|
+
locale: typeof source.locale === "string" ? source.locale : undefined,
|
|
108
|
+
tagFormat: asTagFormat(source.tagFormat),
|
|
109
|
+
};
|
|
110
|
+
if (isRecord(source.policy)) {
|
|
111
|
+
normalized.policy = source.policy;
|
|
112
|
+
}
|
|
113
|
+
// Only forward `anonymizer` when the user actually configured one.
|
|
114
|
+
// Leaving it `undefined` lets {@link anonymizerConfigFromOptions} distinguish
|
|
115
|
+
// "user did not configure" from "user configured an empty block", which is
|
|
116
|
+
// required to honour the global `~/.config/opencode` default for
|
|
117
|
+
// `secrets.envBaseDirectory`.
|
|
118
|
+
normalized.anonymizer = isRecord(source.anonymizer)
|
|
119
|
+
? source.anonymizer
|
|
120
|
+
: undefined;
|
|
121
|
+
return normalized;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Resolves the anonymizer configuration.
|
|
125
|
+
*
|
|
126
|
+
* The base directory for `envFiles` paths is picked in this order:
|
|
127
|
+
* 1. `anonymizer.secrets.envBaseDirectory` if the user configured it.
|
|
128
|
+
* 2. The OpenCode config directory (`~/.config/opencode` on every supported
|
|
129
|
+
* platform) — when the user has not configured their own `anonymizer`
|
|
130
|
+
* block. This means a single `~/.config/opencode/.env` shared across all
|
|
131
|
+
* projects works without per-project paths, while project-local discovery
|
|
132
|
+
* stays opt-in by setting `secrets.envBaseDirectory` explicitly.
|
|
133
|
+
*
|
|
134
|
+
* 3. The project directory (final fallback).
|
|
135
|
+
*/
|
|
136
|
+
export function anonymizerConfigFromOptions(options, ctxDirectory, env = process.env, homedirFn = homedir) {
|
|
137
|
+
const userProvided = options.anonymizer !== undefined;
|
|
138
|
+
const base = userProvided
|
|
139
|
+
? options.anonymizer
|
|
140
|
+
: { secrets: defaultSecretsConfig(options) };
|
|
141
|
+
if (base.secrets === undefined) {
|
|
142
|
+
return base;
|
|
143
|
+
}
|
|
144
|
+
const envBaseDirectory = base.secrets.envBaseDirectory ?? (userProvided
|
|
145
|
+
? ctxDirectory
|
|
146
|
+
: (opencodeConfigDirectory(env, homedirFn) ?? ctxDirectory));
|
|
147
|
+
return {
|
|
148
|
+
...base,
|
|
149
|
+
secrets: {
|
|
150
|
+
...base.secrets,
|
|
151
|
+
envBaseDirectory,
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Builds the policy override implied by `disableTypes`.
|
|
157
|
+
*
|
|
158
|
+
* Returns `options.policy` unchanged when nothing is disabled (or the caller
|
|
159
|
+
* explicitly disabled nothing), matching the original plugin behaviour.
|
|
160
|
+
*/
|
|
161
|
+
export function policyFromOptions(options) {
|
|
162
|
+
const disableTypes = options.disableTypes ?? DEFAULT_DISABLE_TYPES;
|
|
163
|
+
if (disableTypes.length === 0) {
|
|
164
|
+
return options.policy;
|
|
165
|
+
}
|
|
166
|
+
const base = createDefaultPolicy();
|
|
167
|
+
const disableSet = new Set(disableTypes);
|
|
168
|
+
const regexEnabledTypes = new Set(base.regexEnabledTypes);
|
|
169
|
+
const nerEnabledTypes = new Set(base.nerEnabledTypes);
|
|
170
|
+
// createDefaultPolicy() excludes secret types (opt-in via AnonymizerConfig
|
|
171
|
+
// .secrets); add them back so this partial policy does not drop the secret
|
|
172
|
+
// types the anonymizer registers internally.
|
|
173
|
+
for (const secretType of SECRET_PII_TYPES) {
|
|
174
|
+
regexEnabledTypes.add(secretType);
|
|
175
|
+
}
|
|
176
|
+
for (const type of disableSet) {
|
|
177
|
+
const piiType = type;
|
|
178
|
+
regexEnabledTypes.delete(piiType);
|
|
179
|
+
nerEnabledTypes.delete(piiType);
|
|
180
|
+
}
|
|
181
|
+
return { ...options.policy, regexEnabledTypes, nerEnabledTypes };
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/opencode-plugin/v2/options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EACL,OAAO,EACP,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAI9B,MAAM,qBAAqB,GAAkB,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;AACnE,MAAM,iBAAiB,GAAa,CAAC,UAAU,CAAC,CAAC;AACjD,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAEnC;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAAyB,OAAO,CAAC,GAAG,EACpC,YAA0B,OAAO;IAEjC,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC;IAChC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrD,OAAO,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAC/B,CAAC;IACD,MAAM,UAAU,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC;IAC5D,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,OAAO,SAAS,KAAK,Q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CAAC;IAClC,CAAC;IAED,OAAO,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,iBAAiB,EAAE,eAAe,EAAE,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin V2 hook registration.
|
|
3
|
+
*
|
|
4
|
+
* Every hook is defensive: a tool rehydrate failure is logged and swallowed so
|
|
5
|
+
* OpenCode keeps running. Scrub failures are the exception — they are logged
|
|
6
|
+
* and rethrown so OpenCode aborts the request instead of forwarding raw PII.
|
|
7
|
+
*
|
|
8
|
+
* Each hook is registered independently: a single rejected registration is
|
|
9
|
+
* logged and skipped without blocking the others.
|
|
10
|
+
*/
|
|
11
|
+
import type { ScrubMessagesOptions } from "./scrub-messages.js";
|
|
12
|
+
import type { AnonymizationState } from "./anon-state.js";
|
|
13
|
+
import type { HookRegistration, RehydraPluginContext, SessionResolver, V2Logger } from "./types.js";
|
|
14
|
+
export interface RegisterHooksDeps {
|
|
15
|
+
readonly logger: V2Logger;
|
|
16
|
+
readonly resolveSession: SessionResolver;
|
|
17
|
+
readonly state: AnonymizationState;
|
|
18
|
+
readonly rehydraInstruction: string;
|
|
19
|
+
readonly tagPrefix: string;
|
|
20
|
+
readonly scrubOptions: ScrubMessagesOptions;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Registers the `context`, `compaction`, and `generate` session hooks. Each
|
|
24
|
+
* scrubs the request messages in place and, once anything was anonymized,
|
|
25
|
+
* appends the rehydra instruction to the system prompt.
|
|
26
|
+
*/
|
|
27
|
+
export declare function registerSessionContextHook(ctx: RehydraPluginContext, deps: RegisterHooksDeps): Promise<HookRegistration[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Registers the `title` hook. Only the messages are scrubbed; no system
|
|
30
|
+
* instruction is injected so title generation is unaffected.
|
|
31
|
+
*/
|
|
32
|
+
export declare function registerSessionTitleHook(ctx: RehydraPluginContext, deps: RegisterHooksDeps): Promise<HookRegistration[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Registers `tool.hook("execute.before")`, restoring PII tags in tool
|
|
35
|
+
* arguments in place before the tool runs locally.
|
|
36
|
+
*/
|
|
37
|
+
export declare function registerToolBeforeHook(ctx: RehydraPluginContext, deps: RegisterHooksDeps): Promise<HookRegistration[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Registers `tool.hook("execute.after")`, restoring PII tags in a completed
|
|
40
|
+
* tool result. Failed executions are skipped.
|
|
41
|
+
*/
|
|
42
|
+
export declare function registerToolAfterHook(ctx: RehydraPluginContext, deps: RegisterHooksDeps): Promise<HookRegistration[]>;
|
|
43
|
+
//# sourceMappingURL=register-hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-hooks.d.ts","sourceRoot":"","sources":["../../../src/opencode-plugin/v2/register-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,QAAQ,EACT,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,QAAQ,CAAC,cAAc,EAAE,eAAe,CAAC;IACzC,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC;IACnC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;CAC7C;AAkBD;;;;GAIG;AACH,wBAAsB,0BAA0B,CAC9C,GAAG,EAAE,oBAAoB,EACzB,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAoC7B;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,oBAAoB,EACzB,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CA0B7B;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,oBAAoB,EACzB,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CA0B7B;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,oBAAoB,EACzB,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CA2B7B"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin V2 hook registration.
|
|
3
|
+
*
|
|
4
|
+
* Every hook is defensive: a tool rehydrate failure is logged and swallowed so
|
|
5
|
+
* OpenCode keeps running. Scrub failures are the exception — they are logged
|
|
6
|
+
* and rethrown so OpenCode aborts the request instead of forwarding raw PII.
|
|
7
|
+
*
|
|
8
|
+
* Each hook is registered independently: a single rejected registration is
|
|
9
|
+
* logged and skipped without blocking the others.
|
|
10
|
+
*/
|
|
11
|
+
import { deepRehydrate } from "./deep-rehydrate.js";
|
|
12
|
+
import { scrubMessages } from "./scrub-messages.js";
|
|
13
|
+
const CONTEXT_HOOK_NAMES = ["context", "compaction", "generate"];
|
|
14
|
+
/** Normalizes an unknown thrown value into a loggable message. */
|
|
15
|
+
function errorMessage(error) {
|
|
16
|
+
return error instanceof Error ? error.message : String(error);
|
|
17
|
+
}
|
|
18
|
+
/** Serializes a value for change detection without throwing on cycles. */
|
|
19
|
+
function stringify(value) {
|
|
20
|
+
try {
|
|
21
|
+
return JSON.stringify(value);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Registers the `context`, `compaction`, and `generate` session hooks. Each
|
|
29
|
+
* scrubs the request messages in place and, once anything was anonymized,
|
|
30
|
+
* appends the rehydra instruction to the system prompt.
|
|
31
|
+
*/
|
|
32
|
+
export async function registerSessionContextHook(ctx, deps) {
|
|
33
|
+
const registrations = [];
|
|
34
|
+
for (const name of CONTEXT_HOOK_NAMES) {
|
|
35
|
+
try {
|
|
36
|
+
const registration = await ctx.session.hook(name, async (event) => {
|
|
37
|
+
try {
|
|
38
|
+
await scrubMessages(event.messages, { sessionID: event.sessionID, logger: deps.logger }, deps.resolveSession, deps.state, deps.scrubOptions);
|
|
39
|
+
if (deps.state.hasAnonymized) {
|
|
40
|
+
event.system.push({
|
|
41
|
+
type: "text",
|
|
42
|
+
text: deps.rehydraInstruction,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
deps.logger.error(`rehydra session ${name} hook failed`, {
|
|
48
|
+
error: errorMessage(error),
|
|
49
|
+
});
|
|
50
|
+
// Fail closed: surface the scrub failure so OpenCode aborts the
|
|
51
|
+
// request instead of sending unscrubbed messages to the model.
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
registrations.push(registration);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
deps.logger.error(`failed to register rehydra session ${name} hook`, {
|
|
59
|
+
error: errorMessage(error),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return registrations;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Registers the `title` hook. Only the messages are scrubbed; no system
|
|
67
|
+
* instruction is injected so title generation is unaffected.
|
|
68
|
+
*/
|
|
69
|
+
export async function registerSessionTitleHook(ctx, deps) {
|
|
70
|
+
try {
|
|
71
|
+
const registration = await ctx.session.hook("title", async (event) => {
|
|
72
|
+
try {
|
|
73
|
+
await scrubMessages(event.messages, { sessionID: event.sessionID, logger: deps.logger }, deps.resolveSession, deps.state, deps.scrubOptions);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
deps.logger.error("rehydra session title hook failed", {
|
|
77
|
+
error: errorMessage(error),
|
|
78
|
+
});
|
|
79
|
+
// Fail closed, as above.
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
return [registration];
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
deps.logger.error("failed to register rehydra session title hook", {
|
|
87
|
+
error: errorMessage(error),
|
|
88
|
+
});
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Registers `tool.hook("execute.before")`, restoring PII tags in tool
|
|
94
|
+
* arguments in place before the tool runs locally.
|
|
95
|
+
*/
|
|
96
|
+
export async function registerToolBeforeHook(ctx, deps) {
|
|
97
|
+
try {
|
|
98
|
+
const registration = await ctx.tool.hook("execute.before", async (event) => {
|
|
99
|
+
try {
|
|
100
|
+
const session = deps.resolveSession(event.sessionID);
|
|
101
|
+
const before = stringify(event.input);
|
|
102
|
+
event.input = await deepRehydrate(event.input, session, deps.tagPrefix);
|
|
103
|
+
if (stringify(event.input) !== before) {
|
|
104
|
+
deps.logger.info("rehydrated PII tags in tool args", {
|
|
105
|
+
tool: event.tool,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
deps.logger.error("rehydra tool execute.before hook failed", {
|
|
111
|
+
tool: event.tool,
|
|
112
|
+
error: errorMessage(error),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
return [registration];
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
deps.logger.error("failed to register rehydra tool execute.before hook", {
|
|
120
|
+
error: errorMessage(error),
|
|
121
|
+
});
|
|
122
|
+
return [];
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Registers `tool.hook("execute.after")`, restoring PII tags in a completed
|
|
127
|
+
* tool result. Failed executions are skipped.
|
|
128
|
+
*/
|
|
129
|
+
export async function registerToolAfterHook(ctx, deps) {
|
|
130
|
+
try {
|
|
131
|
+
const registration = await ctx.tool.hook("execute.after", async (event) => {
|
|
132
|
+
try {
|
|
133
|
+
if (event.status !== "completed")
|
|
134
|
+
return;
|
|
135
|
+
const session = deps.resolveSession(event.sessionID);
|
|
136
|
+
const before = stringify(event.result);
|
|
137
|
+
event.result = await deepRehydrate(event.result, session, deps.tagPrefix);
|
|
138
|
+
if (stringify(event.result) !== before) {
|
|
139
|
+
deps.logger.info("rehydrated PII tags in tool result", {
|
|
140
|
+
tool: event.tool,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
deps.logger.error("rehydra tool execute.after hook failed", {
|
|
146
|
+
tool: event.tool,
|
|
147
|
+
error: errorMessage(error),
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
return [registration];
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
deps.logger.error("failed to register rehydra tool execute.after hook", {
|
|
155
|
+
error: errorMessage(error),
|
|
156
|
+
});
|
|
157
|
+
return [];
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=register-hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-hooks.js","sourceRoot":"","sources":["../../../src/opencode-plugin/v2/register-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAmBpD,MAAM,kBAAkB,GAAG,CAAC,SAAS,EAAE,YAAY,EAAE,UAAU,CAAU,CAAC;AAE1E,kEAAkE;AAClE,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,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output arrives in fragments: a single `<PII .../>` tag can be split
|
|
5
|
+
* across SSE events, WebSocket byte chunks, or JSON delta frames. Rehydrating
|
|
6
|
+
* a fragment in isolation would emit an unterminated tag (or worse, drop the
|
|
7
|
+
* real value), so incomplete fragments are held back and prepended to the next
|
|
8
|
+
* fragment of the same stream.
|
|
9
|
+
*
|
|
10
|
+
* Two buffers are maintained per session:
|
|
11
|
+
* - a byte/text tail for raw text payloads (SSE `data:` bodies, non-JSON WS
|
|
12
|
+
* frames),
|
|
13
|
+
* - a JSON pointer tail so each string field of a JSON delta frame continues
|
|
14
|
+
* from the fragment left by the previous frame.
|
|
15
|
+
*/
|
|
16
|
+
/** Longest PII tag fragment we hold back while awaiting its closing delimiter. */
|
|
17
|
+
export declare const MAX_TAG_TAIL_LENGTH = 256;
|
|
18
|
+
/** Default tag prefix, matching `DEFAULT_TAG_FORMAT`. */
|
|
19
|
+
export declare const DEFAULT_TAG_PREFIX = "<PII";
|
|
20
|
+
/** Default tag close delimiter. */
|
|
21
|
+
export declare const DEFAULT_TAG_CLOSE = "/>";
|
|
22
|
+
/**
|
|
23
|
+
* Per-session storage for fragments held back between streamed payloads.
|
|
24
|
+
*
|
|
25
|
+
* Text tails are keyed by session; JSON tails are keyed by session and a JSON
|
|
26
|
+
* pointer so a tag split inside a delta field is reassembled on the matching
|
|
27
|
+
* field of the next frame.
|
|
28
|
+
*/
|
|
29
|
+
export interface RehydrateTailStore {
|
|
30
|
+
/** Returns the held text fragment for a session (empty when none). */
|
|
31
|
+
get(sessionID: string): string;
|
|
32
|
+
/** Replaces the held text fragment; an empty string clears it. */
|
|
33
|
+
set(sessionID: string, tail: string): void;
|
|
34
|
+
/** Returns the held fragment for a JSON pointer (empty when none). */
|
|
35
|
+
getJsonTail(sessionID: string, pointer: string): string;
|
|
36
|
+
/** Replaces a JSON-pointer fragment; an empty string clears it. */
|
|
37
|
+
setJsonTail(sessionID: string, pointer: string, tail: string): void;
|
|
38
|
+
/** Clears every fragment (text and JSON) for a session. */
|
|
39
|
+
delete(sessionID: string): void;
|
|
40
|
+
/** Clears every fragment for every session. */
|
|
41
|
+
clear(): void;
|
|
42
|
+
}
|
|
43
|
+
/** Default in-memory tail store. */
|
|
44
|
+
export declare class InMemoryRehydrateTailStore implements RehydrateTailStore {
|
|
45
|
+
private readonly textTails;
|
|
46
|
+
private readonly jsonTails;
|
|
47
|
+
get(sessionID: string): string;
|
|
48
|
+
set(sessionID: string, tail: string): void;
|
|
49
|
+
getJsonTail(sessionID: string, pointer: string): string;
|
|
50
|
+
setJsonTail(sessionID: string, pointer: string, tail: string): void;
|
|
51
|
+
delete(sessionID: string): void;
|
|
52
|
+
clear(): void;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Finds the start of a trailing, unterminated PII tag fragment.
|
|
56
|
+
*
|
|
57
|
+
* Returns `-1` when the text has no incomplete tag, so a caller can safely
|
|
58
|
+
* emit it. When a fragment is found, the caller must hold it back (prepending
|
|
59
|
+
* it to the next fragment) instead of emitting a truncated tag.
|
|
60
|
+
*/
|
|
61
|
+
export declare function incompleteTagStart(text: string, tagPrefix: string, tagClose: string): number;
|
|
62
|
+
/** Result of splitting a restored string into emit-safe text and a held tail. */
|
|
63
|
+
export interface TagTailSplit {
|
|
64
|
+
/** Text safe to emit now. */
|
|
65
|
+
emitted: string;
|
|
66
|
+
/** Unterminated tag fragment to carry to the next payload. */
|
|
67
|
+
tail: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Splits a restored string at its trailing unterminated tag fragment.
|
|
71
|
+
*
|
|
72
|
+
* When the fragment is longer than {@link MAX_TAG_TAIL_LENGTH} the whole string
|
|
73
|
+
* is emitted: holding an unbounded fragment risks stalling the stream, so the
|
|
74
|
+
* cap forces a flush.
|
|
75
|
+
*/
|
|
76
|
+
export declare function splitTrailingTag(text: string, tagPrefix: string, tagClose: string): TagTailSplit;
|
|
77
|
+
/** Context shared by every string leaf of one JSON frame. */
|
|
78
|
+
export interface JsonTailContext {
|
|
79
|
+
readonly store: RehydrateTailStore;
|
|
80
|
+
readonly sessionID: string;
|
|
81
|
+
/** Namespace preventing different surfaces from sharing pointer keys. */
|
|
82
|
+
readonly pointerPrefix: string;
|
|
83
|
+
readonly tagPrefix: string;
|
|
84
|
+
readonly tagClose: string;
|
|
85
|
+
}
|
|
86
|
+
/** Outcome of walking a JSON value with per-pointer tail handling. */
|
|
87
|
+
export interface WalkJsonTailResult<T> {
|
|
88
|
+
value: T;
|
|
89
|
+
changed: boolean;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Walks a JSON value, restoring every string leaf.
|
|
93
|
+
*
|
|
94
|
+
* Each leaf is prefixed with the fragment previously held for its JSON pointer
|
|
95
|
+
* (so a tag split across delta frames is reassembled), then any trailing
|
|
96
|
+
* unterminated fragment is held back for the next frame. `changed` reports
|
|
97
|
+
* whether any leaf differs from the original, letting callers keep the frame
|
|
98
|
+
* byte-for-byte when nothing needed rewriting.
|
|
99
|
+
*/
|
|
100
|
+
export declare function walkJsonWithTail<T>(value: T, rehydrate: (input: string) => Promise<string>, ctx: JsonTailContext, pointer?: string): Promise<WalkJsonTailResult<T>>;
|
|
101
|
+
//# sourceMappingURL=rehydrate-tail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rehydrate-tail.d.ts","sourceRoot":"","sources":["../../../src/opencode-plugin/v2/rehydrate-tail.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,kFAAkF;AAClF,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC,yDAAyD;AACzD,eAAO,MAAM,kBAAkB,SAAS,CAAC;AAEzC,mCAAmC;AACnC,eAAO,MAAM,iBAAiB,OAAO,CAAC;AAEtC;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,sEAAsE;IACtE,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,kEAAkE;IAClE,GAAG,CAA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