@amodalai/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/.last_build +0 -0
- package/dist/src/amodal-config.d.ts +194 -0
- package/dist/src/amodal-config.js +326 -0
- package/dist/src/amodal-config.js.map +1 -0
- package/dist/src/audit/audit-logger.d.ts +52 -0
- package/dist/src/audit/audit-logger.js +137 -0
- package/dist/src/audit/audit-logger.js.map +1 -0
- package/dist/src/audit/audit-outputs.d.ts +34 -0
- package/dist/src/audit/audit-outputs.js +73 -0
- package/dist/src/audit/audit-outputs.js.map +1 -0
- package/dist/src/audit/audit-redact.d.ts +14 -0
- package/dist/src/audit/audit-redact.js +55 -0
- package/dist/src/audit/audit-redact.js.map +1 -0
- package/dist/src/audit/audit-types.d.ts +122 -0
- package/dist/src/audit/audit-types.js +64 -0
- package/dist/src/audit/audit-types.js.map +1 -0
- package/dist/src/audit/index.d.ts +10 -0
- package/dist/src/audit/index.js +10 -0
- package/dist/src/audit/index.js.map +1 -0
- package/dist/src/eval/eval-cost.d.ts +33 -0
- package/dist/src/eval/eval-cost.js +73 -0
- package/dist/src/eval/eval-cost.js.map +1 -0
- package/dist/src/eval/eval-diff.d.ts +11 -0
- package/dist/src/eval/eval-diff.js +97 -0
- package/dist/src/eval/eval-diff.js.map +1 -0
- package/dist/src/eval/eval-formatter.d.ts +23 -0
- package/dist/src/eval/eval-formatter.js +221 -0
- package/dist/src/eval/eval-formatter.js.map +1 -0
- package/dist/src/eval/eval-judge.d.ts +26 -0
- package/dist/src/eval/eval-judge.js +76 -0
- package/dist/src/eval/eval-judge.js.map +1 -0
- package/dist/src/eval/eval-run-builder.d.ts +25 -0
- package/dist/src/eval/eval-run-builder.js +78 -0
- package/dist/src/eval/eval-run-builder.js.map +1 -0
- package/dist/src/eval/eval-runner.d.ts +36 -0
- package/dist/src/eval/eval-runner.js +92 -0
- package/dist/src/eval/eval-runner.js.map +1 -0
- package/dist/src/eval/eval-session-provider.d.ts +40 -0
- package/dist/src/eval/eval-session-provider.js +46 -0
- package/dist/src/eval/eval-session-provider.js.map +1 -0
- package/dist/src/eval/eval-types.d.ts +146 -0
- package/dist/src/eval/eval-types.js +7 -0
- package/dist/src/eval/eval-types.js.map +1 -0
- package/dist/src/eval/experiment-runner.d.ts +16 -0
- package/dist/src/eval/experiment-runner.js +73 -0
- package/dist/src/eval/experiment-runner.js.map +1 -0
- package/dist/src/eval/experiment-types.d.ts +56 -0
- package/dist/src/eval/experiment-types.js +7 -0
- package/dist/src/eval/experiment-types.js.map +1 -0
- package/dist/src/eval/index.d.ts +22 -0
- package/dist/src/eval/index.js +18 -0
- package/dist/src/eval/index.js.map +1 -0
- package/dist/src/eval/multi-model-runner.d.ts +42 -0
- package/dist/src/eval/multi-model-runner.js +70 -0
- package/dist/src/eval/multi-model-runner.js.map +1 -0
- package/dist/src/eval/platform-eval-client.d.ts +105 -0
- package/dist/src/eval/platform-eval-client.js +155 -0
- package/dist/src/eval/platform-eval-client.js.map +1 -0
- package/dist/src/index.d.ts +41 -0
- package/dist/src/index.js +68 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/knowledge/index.d.ts +11 -0
- package/dist/src/knowledge/index.js +12 -0
- package/dist/src/knowledge/index.js.map +1 -0
- package/dist/src/knowledge/kb-formatter.d.ts +15 -0
- package/dist/src/knowledge/kb-formatter.js +78 -0
- package/dist/src/knowledge/kb-formatter.js.map +1 -0
- package/dist/src/knowledge/kb-index.d.ts +27 -0
- package/dist/src/knowledge/kb-index.js +66 -0
- package/dist/src/knowledge/kb-index.js.map +1 -0
- package/dist/src/knowledge/kb-types.d.ts +54 -0
- package/dist/src/knowledge/kb-types.js +7 -0
- package/dist/src/knowledge/kb-types.js.map +1 -0
- package/dist/src/knowledge/knowledge-store.d.ts +56 -0
- package/dist/src/knowledge/knowledge-store.js +141 -0
- package/dist/src/knowledge/knowledge-store.js.map +1 -0
- package/dist/src/knowledge/load-knowledge.d.ts +30 -0
- package/dist/src/knowledge/load-knowledge.js +161 -0
- package/dist/src/knowledge/load-knowledge.js.map +1 -0
- package/dist/src/knowledge/propose-kb-update.d.ts +32 -0
- package/dist/src/knowledge/propose-kb-update.js +148 -0
- package/dist/src/knowledge/propose-kb-update.js.map +1 -0
- package/dist/src/knowledge/propose-knowledge.d.ts +34 -0
- package/dist/src/knowledge/propose-knowledge.js +163 -0
- package/dist/src/knowledge/propose-knowledge.js.map +1 -0
- package/dist/src/mcp/index.d.ts +7 -0
- package/dist/src/mcp/index.js +7 -0
- package/dist/src/mcp/index.js.map +1 -0
- package/dist/src/mcp/mcp-manager.d.ts +96 -0
- package/dist/src/mcp/mcp-manager.js +192 -0
- package/dist/src/mcp/mcp-manager.js.map +1 -0
- package/dist/src/packages/config-deps.d.ts +20 -0
- package/dist/src/packages/config-deps.js +77 -0
- package/dist/src/packages/config-deps.js.map +1 -0
- package/dist/src/packages/env-file.d.ts +28 -0
- package/dist/src/packages/env-file.js +143 -0
- package/dist/src/packages/env-file.js.map +1 -0
- package/dist/src/packages/frontmatter.d.ts +28 -0
- package/dist/src/packages/frontmatter.js +77 -0
- package/dist/src/packages/frontmatter.js.map +1 -0
- package/dist/src/packages/index.d.ts +16 -0
- package/dist/src/packages/index.js +17 -0
- package/dist/src/packages/index.js.map +1 -0
- package/dist/src/packages/lock-file.d.ts +35 -0
- package/dist/src/packages/lock-file.js +117 -0
- package/dist/src/packages/lock-file.js.map +1 -0
- package/dist/src/packages/manifest-reader.d.ts +19 -0
- package/dist/src/packages/manifest-reader.js +91 -0
- package/dist/src/packages/manifest-reader.js.map +1 -0
- package/dist/src/packages/merge-engine.d.ts +63 -0
- package/dist/src/packages/merge-engine.js +357 -0
- package/dist/src/packages/merge-engine.js.map +1 -0
- package/dist/src/packages/npm-context.d.ts +56 -0
- package/dist/src/packages/npm-context.js +235 -0
- package/dist/src/packages/npm-context.js.map +1 -0
- package/dist/src/packages/npm-registry.d.ts +35 -0
- package/dist/src/packages/npm-registry.js +107 -0
- package/dist/src/packages/npm-registry.js.map +1 -0
- package/dist/src/packages/package-error.d.ts +16 -0
- package/dist/src/packages/package-error.js +17 -0
- package/dist/src/packages/package-error.js.map +1 -0
- package/dist/src/packages/package-types.d.ts +477 -0
- package/dist/src/packages/package-types.js +156 -0
- package/dist/src/packages/package-types.js.map +1 -0
- package/dist/src/packages/resolver.d.ts +41 -0
- package/dist/src/packages/resolver.js +353 -0
- package/dist/src/packages/resolver.js.map +1 -0
- package/dist/src/platform/config-builder.d.ts +24 -0
- package/dist/src/platform/config-builder.js +70 -0
- package/dist/src/platform/config-builder.js.map +1 -0
- package/dist/src/platform/index.d.ts +8 -0
- package/dist/src/platform/index.js +9 -0
- package/dist/src/platform/index.js.map +1 -0
- package/dist/src/platform/platform-client.d.ts +160 -0
- package/dist/src/platform/platform-client.js +486 -0
- package/dist/src/platform/platform-client.js.map +1 -0
- package/dist/src/platform/platform-types.d.ts +81 -0
- package/dist/src/platform/platform-types.js +18 -0
- package/dist/src/platform/platform-types.js.map +1 -0
- package/dist/src/providers/content-generator/google-to-llm.d.ts +87 -0
- package/dist/src/providers/content-generator/google-to-llm.js +226 -0
- package/dist/src/providers/content-generator/google-to-llm.js.map +1 -0
- package/dist/src/providers/content-generator/index.d.ts +10 -0
- package/dist/src/providers/content-generator/index.js +9 -0
- package/dist/src/providers/content-generator/index.js.map +1 -0
- package/dist/src/providers/content-generator/llm-to-google.d.ts +59 -0
- package/dist/src/providers/content-generator/llm-to-google.js +178 -0
- package/dist/src/providers/content-generator/llm-to-google.js.map +1 -0
- package/dist/src/providers/content-generator/multi-provider-content-generator.d.ts +61 -0
- package/dist/src/providers/content-generator/multi-provider-content-generator.js +144 -0
- package/dist/src/providers/content-generator/multi-provider-content-generator.js.map +1 -0
- package/dist/src/providers/runtime/anthropic-provider.d.ts +18 -0
- package/dist/src/providers/runtime/anthropic-provider.js +253 -0
- package/dist/src/providers/runtime/anthropic-provider.js.map +1 -0
- package/dist/src/providers/runtime/azure-provider.d.ts +25 -0
- package/dist/src/providers/runtime/azure-provider.js +206 -0
- package/dist/src/providers/runtime/azure-provider.js.map +1 -0
- package/dist/src/providers/runtime/bedrock-provider.d.ts +22 -0
- package/dist/src/providers/runtime/bedrock-provider.js +276 -0
- package/dist/src/providers/runtime/bedrock-provider.js.map +1 -0
- package/dist/src/providers/runtime/failover-provider.d.ts +30 -0
- package/dist/src/providers/runtime/failover-provider.js +124 -0
- package/dist/src/providers/runtime/failover-provider.js.map +1 -0
- package/dist/src/providers/runtime/google-provider.d.ts +17 -0
- package/dist/src/providers/runtime/google-provider.js +239 -0
- package/dist/src/providers/runtime/google-provider.js.map +1 -0
- package/dist/src/providers/runtime/index.d.ts +16 -0
- package/dist/src/providers/runtime/index.js +16 -0
- package/dist/src/providers/runtime/index.js.map +1 -0
- package/dist/src/providers/runtime/openai-provider.d.ts +21 -0
- package/dist/src/providers/runtime/openai-provider.js +266 -0
- package/dist/src/providers/runtime/openai-provider.js.map +1 -0
- package/dist/src/providers/runtime/provider-errors.d.ts +39 -0
- package/dist/src/providers/runtime/provider-errors.js +50 -0
- package/dist/src/providers/runtime/provider-errors.js.map +1 -0
- package/dist/src/providers/runtime/provider-factory.d.ts +19 -0
- package/dist/src/providers/runtime/provider-factory.js +45 -0
- package/dist/src/providers/runtime/provider-factory.js.map +1 -0
- package/dist/src/providers/runtime/runtime-provider-types.d.ts +63 -0
- package/dist/src/providers/runtime/runtime-provider-types.js +7 -0
- package/dist/src/providers/runtime/runtime-provider-types.js.map +1 -0
- package/dist/src/providers/runtime/streaming-types.d.ts +40 -0
- package/dist/src/providers/runtime/streaming-types.js +7 -0
- package/dist/src/providers/runtime/streaming-types.js.map +1 -0
- package/dist/src/repo/config-schema.d.ts +238 -0
- package/dist/src/repo/config-schema.js +155 -0
- package/dist/src/repo/config-schema.js.map +1 -0
- package/dist/src/repo/connection-schemas.d.ts +449 -0
- package/dist/src/repo/connection-schemas.js +109 -0
- package/dist/src/repo/connection-schemas.js.map +1 -0
- package/dist/src/repo/connection-types.d.ts +29 -0
- package/dist/src/repo/connection-types.js +7 -0
- package/dist/src/repo/connection-types.js.map +1 -0
- package/dist/src/repo/drift-detector.d.ts +26 -0
- package/dist/src/repo/drift-detector.js +66 -0
- package/dist/src/repo/drift-detector.js.map +1 -0
- package/dist/src/repo/graphql-drift-detector.d.ts +27 -0
- package/dist/src/repo/graphql-drift-detector.js +66 -0
- package/dist/src/repo/graphql-drift-detector.js.map +1 -0
- package/dist/src/repo/graphql-parser.d.ts +30 -0
- package/dist/src/repo/graphql-parser.js +125 -0
- package/dist/src/repo/graphql-parser.js.map +1 -0
- package/dist/src/repo/graphql-surface-parser.d.ts +20 -0
- package/dist/src/repo/graphql-surface-parser.js +74 -0
- package/dist/src/repo/graphql-surface-parser.js.map +1 -0
- package/dist/src/repo/index.d.ts +30 -0
- package/dist/src/repo/index.js +29 -0
- package/dist/src/repo/index.js.map +1 -0
- package/dist/src/repo/local-reader.d.ts +10 -0
- package/dist/src/repo/local-reader.js +299 -0
- package/dist/src/repo/local-reader.js.map +1 -0
- package/dist/src/repo/openapi-parser.d.ts +35 -0
- package/dist/src/repo/openapi-parser.js +93 -0
- package/dist/src/repo/openapi-parser.js.map +1 -0
- package/dist/src/repo/parsers.d.ts +91 -0
- package/dist/src/repo/parsers.js +454 -0
- package/dist/src/repo/parsers.js.map +1 -0
- package/dist/src/repo/platform-reader.d.ts +10 -0
- package/dist/src/repo/platform-reader.js +206 -0
- package/dist/src/repo/platform-reader.js.map +1 -0
- package/dist/src/repo/repo-loader.d.ts +14 -0
- package/dist/src/repo/repo-loader.js +25 -0
- package/dist/src/repo/repo-loader.js.map +1 -0
- package/dist/src/repo/repo-types.d.ts +159 -0
- package/dist/src/repo/repo-types.js +17 -0
- package/dist/src/repo/repo-types.js.map +1 -0
- package/dist/src/repo/spec-syncer.d.ts +30 -0
- package/dist/src/repo/spec-syncer.js +85 -0
- package/dist/src/repo/spec-syncer.js.map +1 -0
- package/dist/src/repo/store-loader.d.ts +19 -0
- package/dist/src/repo/store-loader.js +94 -0
- package/dist/src/repo/store-loader.js.map +1 -0
- package/dist/src/repo/store-schemas.d.ts +313 -0
- package/dist/src/repo/store-schemas.js +103 -0
- package/dist/src/repo/store-schemas.js.map +1 -0
- package/dist/src/repo/store-tool-schema.d.ts +29 -0
- package/dist/src/repo/store-tool-schema.js +103 -0
- package/dist/src/repo/store-tool-schema.js.map +1 -0
- package/dist/src/repo/store-types.d.ts +91 -0
- package/dist/src/repo/store-types.js +7 -0
- package/dist/src/repo/store-types.js.map +1 -0
- package/dist/src/repo/surface-parser.d.ts +17 -0
- package/dist/src/repo/surface-parser.js +75 -0
- package/dist/src/repo/surface-parser.js.map +1 -0
- package/dist/src/repo/tool-loader.d.ts +33 -0
- package/dist/src/repo/tool-loader.js +240 -0
- package/dist/src/repo/tool-loader.js.map +1 -0
- package/dist/src/repo/tool-types.d.ts +205 -0
- package/dist/src/repo/tool-types.js +61 -0
- package/dist/src/repo/tool-types.js.map +1 -0
- package/dist/src/roles/index.d.ts +7 -0
- package/dist/src/roles/index.js +8 -0
- package/dist/src/roles/index.js.map +1 -0
- package/dist/src/roles/role-filter.d.ts +33 -0
- package/dist/src/roles/role-filter.js +55 -0
- package/dist/src/roles/role-filter.js.map +1 -0
- package/dist/src/roles/role-types.d.ts +76 -0
- package/dist/src/roles/role-types.js +38 -0
- package/dist/src/roles/role-types.js.map +1 -0
- package/dist/src/runtime/connection-bridge.d.ts +19 -0
- package/dist/src/runtime/connection-bridge.js +103 -0
- package/dist/src/runtime/connection-bridge.js.map +1 -0
- package/dist/src/runtime/context-compiler.d.ts +35 -0
- package/dist/src/runtime/context-compiler.js +183 -0
- package/dist/src/runtime/context-compiler.js.map +1 -0
- package/dist/src/runtime/default-prompt.d.ts +28 -0
- package/dist/src/runtime/default-prompt.js +71 -0
- package/dist/src/runtime/default-prompt.js.map +1 -0
- package/dist/src/runtime/explore-tool.d.ts +96 -0
- package/dist/src/runtime/explore-tool.js +111 -0
- package/dist/src/runtime/explore-tool.js.map +1 -0
- package/dist/src/runtime/index.d.ts +26 -0
- package/dist/src/runtime/index.js +19 -0
- package/dist/src/runtime/index.js.map +1 -0
- package/dist/src/runtime/output-pipeline.d.ts +62 -0
- package/dist/src/runtime/output-pipeline.js +69 -0
- package/dist/src/runtime/output-pipeline.js.map +1 -0
- package/dist/src/runtime/plan-mode.d.ts +39 -0
- package/dist/src/runtime/plan-mode.js +81 -0
- package/dist/src/runtime/plan-mode.js.map +1 -0
- package/dist/src/runtime/preference-client.d.ts +39 -0
- package/dist/src/runtime/preference-client.js +70 -0
- package/dist/src/runtime/preference-client.js.map +1 -0
- package/dist/src/runtime/preference-detector.d.ts +22 -0
- package/dist/src/runtime/preference-detector.js +95 -0
- package/dist/src/runtime/preference-detector.js.map +1 -0
- package/dist/src/runtime/request-integration.d.ts +18 -0
- package/dist/src/runtime/request-integration.js +36 -0
- package/dist/src/runtime/request-integration.js.map +1 -0
- package/dist/src/runtime/runtime-types.d.ts +48 -0
- package/dist/src/runtime/runtime-types.js +7 -0
- package/dist/src/runtime/runtime-types.js.map +1 -0
- package/dist/src/runtime/session-setup.d.ts +53 -0
- package/dist/src/runtime/session-setup.js +90 -0
- package/dist/src/runtime/session-setup.js.map +1 -0
- package/dist/src/runtime/telemetry-client.d.ts +39 -0
- package/dist/src/runtime/telemetry-client.js +87 -0
- package/dist/src/runtime/telemetry-client.js.map +1 -0
- package/dist/src/runtime/telemetry-hooks.d.ts +47 -0
- package/dist/src/runtime/telemetry-hooks.js +115 -0
- package/dist/src/runtime/telemetry-hooks.js.map +1 -0
- package/dist/src/runtime/token-allocator.d.ts +34 -0
- package/dist/src/runtime/token-allocator.js +86 -0
- package/dist/src/runtime/token-allocator.js.map +1 -0
- package/dist/src/runtime/user-context.d.ts +49 -0
- package/dist/src/runtime/user-context.js +135 -0
- package/dist/src/runtime/user-context.js.map +1 -0
- package/dist/src/sdk.d.ts +57 -0
- package/dist/src/sdk.js +377 -0
- package/dist/src/sdk.js.map +1 -0
- package/dist/src/security/action-gate.d.ts +23 -0
- package/dist/src/security/action-gate.js +78 -0
- package/dist/src/security/action-gate.js.map +1 -0
- package/dist/src/security/field-scrubber.d.ts +27 -0
- package/dist/src/security/field-scrubber.js +152 -0
- package/dist/src/security/field-scrubber.js.map +1 -0
- package/dist/src/security/index.d.ts +14 -0
- package/dist/src/security/index.js +15 -0
- package/dist/src/security/index.js.map +1 -0
- package/dist/src/security/leak-detector.d.ts +23 -0
- package/dist/src/security/leak-detector.js +51 -0
- package/dist/src/security/leak-detector.js.map +1 -0
- package/dist/src/security/output-guard.d.ts +33 -0
- package/dist/src/security/output-guard.js +118 -0
- package/dist/src/security/output-guard.js.map +1 -0
- package/dist/src/security/pattern-scanner.d.ts +19 -0
- package/dist/src/security/pattern-scanner.js +66 -0
- package/dist/src/security/pattern-scanner.js.map +1 -0
- package/dist/src/security/scope-checker.d.ts +27 -0
- package/dist/src/security/scope-checker.js +52 -0
- package/dist/src/security/scope-checker.js.map +1 -0
- package/dist/src/security/scrub-tracker.d.ts +21 -0
- package/dist/src/security/scrub-tracker.js +39 -0
- package/dist/src/security/scrub-tracker.js.map +1 -0
- package/dist/src/security/security-types.d.ts +69 -0
- package/dist/src/security/security-types.js +17 -0
- package/dist/src/security/security-types.js.map +1 -0
- package/dist/src/security/threshold-evaluator.d.ts +13 -0
- package/dist/src/security/threshold-evaluator.js +44 -0
- package/dist/src/security/threshold-evaluator.js.map +1 -0
- package/dist/src/snapshot/index.d.ts +8 -0
- package/dist/src/snapshot/index.js +9 -0
- package/dist/src/snapshot/index.js.map +1 -0
- package/dist/src/snapshot/snapshot-builder.d.ts +37 -0
- package/dist/src/snapshot/snapshot-builder.js +152 -0
- package/dist/src/snapshot/snapshot-builder.js.map +1 -0
- package/dist/src/snapshot/snapshot-loader.d.ts +29 -0
- package/dist/src/snapshot/snapshot-loader.js +188 -0
- package/dist/src/snapshot/snapshot-loader.js.map +1 -0
- package/dist/src/snapshot/snapshot-types.d.ts +1940 -0
- package/dist/src/snapshot/snapshot-types.js +145 -0
- package/dist/src/snapshot/snapshot-types.js.map +1 -0
- package/dist/src/stores/index.d.ts +6 -0
- package/dist/src/stores/index.js +7 -0
- package/dist/src/stores/index.js.map +1 -0
- package/dist/src/stores/store-backend.d.ts +135 -0
- package/dist/src/stores/store-backend.js +7 -0
- package/dist/src/stores/store-backend.js.map +1 -0
- package/dist/src/templates/connections.d.ts +14 -0
- package/dist/src/templates/connections.js +7 -0
- package/dist/src/templates/connections.js.map +1 -0
- package/dist/src/templates/index.d.ts +7 -0
- package/dist/src/templates/index.js +8 -0
- package/dist/src/templates/index.js.map +1 -0
- package/dist/src/templates/template-resolver.d.ts +45 -0
- package/dist/src/templates/template-resolver.js +121 -0
- package/dist/src/templates/template-resolver.js.map +1 -0
- package/dist/src/tool-context.d.ts +33 -0
- package/dist/src/tool-context.js +7 -0
- package/dist/src/tool-context.js.map +1 -0
- package/dist/src/tool-registration.d.ts +14 -0
- package/dist/src/tool-registration.js +51 -0
- package/dist/src/tool-registration.js.map +1 -0
- package/dist/src/tools/amodal-tool-errors.d.ts +24 -0
- package/dist/src/tools/amodal-tool-errors.js +28 -0
- package/dist/src/tools/amodal-tool-errors.js.map +1 -0
- package/dist/src/tools/amodal-tool-names.d.ts +14 -0
- package/dist/src/tools/amodal-tool-names.js +15 -0
- package/dist/src/tools/amodal-tool-names.js.map +1 -0
- package/dist/src/tools/chain-tool-registry.d.ts +20 -0
- package/dist/src/tools/chain-tool-registry.js +49 -0
- package/dist/src/tools/chain-tool-registry.js.map +1 -0
- package/dist/src/tools/chain-tool-types.d.ts +190 -0
- package/dist/src/tools/chain-tool-types.js +50 -0
- package/dist/src/tools/chain-tool-types.js.map +1 -0
- package/dist/src/tools/chain-tool.d.ts +34 -0
- package/dist/src/tools/chain-tool.js +294 -0
- package/dist/src/tools/chain-tool.js.map +1 -0
- package/dist/src/tools/custom-tool-registrar.d.ts +8 -0
- package/dist/src/tools/custom-tool-registrar.js +10 -0
- package/dist/src/tools/custom-tool-registrar.js.map +1 -0
- package/dist/src/tools/definitions/amodal-tools.d.ts +9 -0
- package/dist/src/tools/definitions/amodal-tools.js +192 -0
- package/dist/src/tools/definitions/amodal-tools.js.map +1 -0
- package/dist/src/tools/function-tool-registry.d.ts +22 -0
- package/dist/src/tools/function-tool-registry.js +45 -0
- package/dist/src/tools/function-tool-registry.js.map +1 -0
- package/dist/src/tools/function-tool-types.d.ts +76 -0
- package/dist/src/tools/function-tool-types.js +27 -0
- package/dist/src/tools/function-tool-types.js.map +1 -0
- package/dist/src/tools/function-tool.d.ts +34 -0
- package/dist/src/tools/function-tool.js +97 -0
- package/dist/src/tools/function-tool.js.map +1 -0
- package/dist/src/tools/http-tool-registry.d.ts +20 -0
- package/dist/src/tools/http-tool-registry.js +34 -0
- package/dist/src/tools/http-tool-registry.js.map +1 -0
- package/dist/src/tools/http-tool-types.d.ts +92 -0
- package/dist/src/tools/http-tool-types.js +44 -0
- package/dist/src/tools/http-tool-types.js.map +1 -0
- package/dist/src/tools/http-tool.d.ts +32 -0
- package/dist/src/tools/http-tool.js +176 -0
- package/dist/src/tools/http-tool.js.map +1 -0
- package/dist/src/tools/merge-template.d.ts +33 -0
- package/dist/src/tools/merge-template.js +65 -0
- package/dist/src/tools/merge-template.js.map +1 -0
- package/dist/src/tools/request-tool-types.d.ts +46 -0
- package/dist/src/tools/request-tool-types.js +20 -0
- package/dist/src/tools/request-tool-types.js.map +1 -0
- package/dist/src/tools/request-tool.d.ts +29 -0
- package/dist/src/tools/request-tool.js +268 -0
- package/dist/src/tools/request-tool.js.map +1 -0
- package/dist/src/tools/store-query-tool.d.ts +29 -0
- package/dist/src/tools/store-query-tool.js +82 -0
- package/dist/src/tools/store-query-tool.js.map +1 -0
- package/dist/src/tools/store-write-tool.d.ts +26 -0
- package/dist/src/tools/store-write-tool.js +84 -0
- package/dist/src/tools/store-write-tool.js.map +1 -0
- package/dist/src/tools/tool-definition-types.d.ts +21 -0
- package/dist/src/tools/tool-definition-types.js +7 -0
- package/dist/src/tools/tool-definition-types.js.map +1 -0
- package/dist/src/tools/tool-utils.d.ts +29 -0
- package/dist/src/tools/tool-utils.js +66 -0
- package/dist/src/tools/tool-utils.js.map +1 -0
- package/dist/src/versions/bundle-loader.d.ts +37 -0
- package/dist/src/versions/bundle-loader.js +99 -0
- package/dist/src/versions/bundle-loader.js.map +1 -0
- package/dist/src/versions/dependency-manager.d.ts +54 -0
- package/dist/src/versions/dependency-manager.js +132 -0
- package/dist/src/versions/dependency-manager.js.map +1 -0
- package/dist/src/versions/handler-loader.d.ts +27 -0
- package/dist/src/versions/handler-loader.js +62 -0
- package/dist/src/versions/handler-loader.js.map +1 -0
- package/dist/src/versions/index.d.ts +10 -0
- package/dist/src/versions/index.js +11 -0
- package/dist/src/versions/index.js.map +1 -0
- package/dist/src/versions/version-bundle-types.d.ts +1278 -0
- package/dist/src/versions/version-bundle-types.js +207 -0
- package/dist/src/versions/version-bundle-types.js.map +1 -0
- package/dist/src/versions/version-manager.d.ts +89 -0
- package/dist/src/versions/version-manager.js +124 -0
- package/dist/src/versions/version-manager.js.map +1 -0
- package/dist/src/widgets/index.d.ts +8 -0
- package/dist/src/widgets/index.js +8 -0
- package/dist/src/widgets/index.js.map +1 -0
- package/dist/src/widgets/present-tool.d.ts +21 -0
- package/dist/src/widgets/present-tool.js +107 -0
- package/dist/src/widgets/present-tool.js.map +1 -0
- package/dist/src/widgets/widget-types.d.ts +78 -0
- package/dist/src/widgets/widget-types.js +28 -0
- package/dist/src/widgets/widget-types.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Amodal Labs, Inc.
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
import type { LLMChatRequest, LLMMessage, LLMToolDefinition } from '../runtime/runtime-provider-types.js';
|
|
7
|
+
/** @google/genai Content */
|
|
8
|
+
interface GContent {
|
|
9
|
+
role?: string;
|
|
10
|
+
parts?: GPart[];
|
|
11
|
+
}
|
|
12
|
+
/** @google/genai Part */
|
|
13
|
+
interface GPart {
|
|
14
|
+
text?: string;
|
|
15
|
+
functionCall?: GFunctionCall;
|
|
16
|
+
functionResponse?: GFunctionResponse;
|
|
17
|
+
thought?: boolean;
|
|
18
|
+
thoughtSignature?: string;
|
|
19
|
+
inlineData?: {
|
|
20
|
+
mimeType?: string;
|
|
21
|
+
data?: string;
|
|
22
|
+
};
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
/** @google/genai FunctionCall */
|
|
26
|
+
interface GFunctionCall {
|
|
27
|
+
id?: string;
|
|
28
|
+
name?: string;
|
|
29
|
+
args?: Record<string, unknown>;
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
}
|
|
32
|
+
/** @google/genai FunctionResponse */
|
|
33
|
+
interface GFunctionResponse {
|
|
34
|
+
id?: string;
|
|
35
|
+
name?: string;
|
|
36
|
+
response?: Record<string, unknown>;
|
|
37
|
+
[key: string]: unknown;
|
|
38
|
+
}
|
|
39
|
+
/** Subset of GenerateContentConfig we care about */
|
|
40
|
+
interface GGenerateContentConfig {
|
|
41
|
+
systemInstruction?: unknown;
|
|
42
|
+
tools?: unknown[];
|
|
43
|
+
maxOutputTokens?: number;
|
|
44
|
+
temperature?: number;
|
|
45
|
+
topP?: number;
|
|
46
|
+
topK?: number;
|
|
47
|
+
abortSignal?: AbortSignal;
|
|
48
|
+
[key: string]: unknown;
|
|
49
|
+
}
|
|
50
|
+
/** Subset of GenerateContentParameters */
|
|
51
|
+
export interface GGenerateContentParams {
|
|
52
|
+
model: string;
|
|
53
|
+
contents: unknown;
|
|
54
|
+
config?: GGenerateContentConfig;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Convert a Google GenerateContentParameters into our LLMChatRequest.
|
|
58
|
+
*/
|
|
59
|
+
export declare function convertGenerateContentParams(request: GGenerateContentParams): LLMChatRequest;
|
|
60
|
+
/**
|
|
61
|
+
* Normalize ContentListUnion to Content[].
|
|
62
|
+
*
|
|
63
|
+
* ContentListUnion can be:
|
|
64
|
+
* - Content (single object with role + parts)
|
|
65
|
+
* - Content[] (array)
|
|
66
|
+
* - string (bare text)
|
|
67
|
+
* - Part (single part)
|
|
68
|
+
* - Part[] (array of parts)
|
|
69
|
+
*/
|
|
70
|
+
export declare function normalizeContents(contents: unknown): GContent[];
|
|
71
|
+
/**
|
|
72
|
+
* Extract system prompt text from systemInstruction.
|
|
73
|
+
* Can be a string, Content, or Part[].
|
|
74
|
+
*/
|
|
75
|
+
export declare function extractSystemPrompt(instruction: unknown): string;
|
|
76
|
+
/**
|
|
77
|
+
* Convert Content[] to LLMMessage[].
|
|
78
|
+
*
|
|
79
|
+
* A single Content can produce multiple LLMMessages when it contains
|
|
80
|
+
* both text parts and functionResponse parts (tool results).
|
|
81
|
+
*/
|
|
82
|
+
export declare function contentsToMessages(contents: GContent[]): LLMMessage[];
|
|
83
|
+
/**
|
|
84
|
+
* Extract LLMToolDefinition[] from Google Tool[].
|
|
85
|
+
*/
|
|
86
|
+
export declare function extractTools(tools: unknown[] | undefined): LLMToolDefinition[];
|
|
87
|
+
export {};
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Amodal Labs, Inc.
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Converts Google @google/genai types (GenerateContentParameters)
|
|
8
|
+
* into our provider-neutral LLM types (LLMChatRequest).
|
|
9
|
+
*
|
|
10
|
+
* This is the "input" side of the ContentGenerator adapter — it translates
|
|
11
|
+
* the request format that the upstream GeminiClient produces into what our
|
|
12
|
+
* RuntimeProvider implementations expect.
|
|
13
|
+
*/
|
|
14
|
+
import { randomUUID } from 'node:crypto';
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// Public conversion function
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
/**
|
|
19
|
+
* Convert a Google GenerateContentParameters into our LLMChatRequest.
|
|
20
|
+
*/
|
|
21
|
+
export function convertGenerateContentParams(request) {
|
|
22
|
+
const contents = normalizeContents(request.contents);
|
|
23
|
+
const messages = contentsToMessages(contents);
|
|
24
|
+
const systemPrompt = extractSystemPrompt(request.config?.systemInstruction);
|
|
25
|
+
const tools = extractTools(request.config?.tools);
|
|
26
|
+
return {
|
|
27
|
+
model: request.model,
|
|
28
|
+
systemPrompt,
|
|
29
|
+
messages,
|
|
30
|
+
tools,
|
|
31
|
+
maxTokens: request.config?.maxOutputTokens,
|
|
32
|
+
signal: request.config?.abortSignal,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
// Content normalization
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
/**
|
|
39
|
+
* Normalize ContentListUnion to Content[].
|
|
40
|
+
*
|
|
41
|
+
* ContentListUnion can be:
|
|
42
|
+
* - Content (single object with role + parts)
|
|
43
|
+
* - Content[] (array)
|
|
44
|
+
* - string (bare text)
|
|
45
|
+
* - Part (single part)
|
|
46
|
+
* - Part[] (array of parts)
|
|
47
|
+
*/
|
|
48
|
+
export function normalizeContents(contents) {
|
|
49
|
+
if (!contents)
|
|
50
|
+
return [];
|
|
51
|
+
// String → single user message
|
|
52
|
+
if (typeof contents === 'string') {
|
|
53
|
+
return [{ role: 'user', parts: [{ text: contents }] }];
|
|
54
|
+
}
|
|
55
|
+
// Array
|
|
56
|
+
if (Array.isArray(contents)) {
|
|
57
|
+
if (contents.length === 0)
|
|
58
|
+
return [];
|
|
59
|
+
// Check if first element looks like Content (has 'role' or 'parts')
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Gemini SDK content normalization
|
|
61
|
+
const first = contents[0];
|
|
62
|
+
if (first && (typeof first['role'] === 'string' || Array.isArray(first['parts']))) {
|
|
63
|
+
// Content[]
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Gemini SDK content normalization
|
|
65
|
+
return contents;
|
|
66
|
+
}
|
|
67
|
+
// Part[] — wrap as single user message
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Gemini SDK content normalization
|
|
69
|
+
return [{ role: 'user', parts: contents }];
|
|
70
|
+
}
|
|
71
|
+
// Single object
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Gemini SDK content normalization
|
|
73
|
+
const obj = contents;
|
|
74
|
+
if (typeof obj['role'] === 'string' || Array.isArray(obj['parts'])) {
|
|
75
|
+
// Single Content
|
|
76
|
+
return [contents];
|
|
77
|
+
}
|
|
78
|
+
// Single Part — wrap as user message
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Gemini SDK content normalization
|
|
80
|
+
return [{ role: 'user', parts: [contents] }];
|
|
81
|
+
}
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
// System prompt extraction
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
/**
|
|
86
|
+
* Extract system prompt text from systemInstruction.
|
|
87
|
+
* Can be a string, Content, or Part[].
|
|
88
|
+
*/
|
|
89
|
+
export function extractSystemPrompt(instruction) {
|
|
90
|
+
if (!instruction)
|
|
91
|
+
return '';
|
|
92
|
+
if (typeof instruction === 'string')
|
|
93
|
+
return instruction;
|
|
94
|
+
// Content with parts
|
|
95
|
+
const content = instruction;
|
|
96
|
+
if (Array.isArray(content.parts)) {
|
|
97
|
+
return extractTextFromParts(content.parts);
|
|
98
|
+
}
|
|
99
|
+
// Part[] directly
|
|
100
|
+
if (Array.isArray(instruction)) {
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Gemini SDK content normalization
|
|
102
|
+
return extractTextFromParts(instruction);
|
|
103
|
+
}
|
|
104
|
+
// Single Part
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Gemini SDK content normalization
|
|
106
|
+
const part = instruction;
|
|
107
|
+
if (typeof part.text === 'string')
|
|
108
|
+
return part.text;
|
|
109
|
+
return '';
|
|
110
|
+
}
|
|
111
|
+
function extractTextFromParts(parts) {
|
|
112
|
+
return parts
|
|
113
|
+
.filter((p) => typeof p.text === 'string' && !p.thought)
|
|
114
|
+
.map((p) => p.text)
|
|
115
|
+
.join('\n');
|
|
116
|
+
}
|
|
117
|
+
// ---------------------------------------------------------------------------
|
|
118
|
+
// Contents → Messages
|
|
119
|
+
// ---------------------------------------------------------------------------
|
|
120
|
+
/**
|
|
121
|
+
* Convert Content[] to LLMMessage[].
|
|
122
|
+
*
|
|
123
|
+
* A single Content can produce multiple LLMMessages when it contains
|
|
124
|
+
* both text parts and functionResponse parts (tool results).
|
|
125
|
+
*/
|
|
126
|
+
export function contentsToMessages(contents) {
|
|
127
|
+
const messages = [];
|
|
128
|
+
for (const content of contents) {
|
|
129
|
+
const parts = content.parts ?? [];
|
|
130
|
+
const role = content.role ?? 'user';
|
|
131
|
+
if (role === 'model') {
|
|
132
|
+
// Model turn → assistant message with response blocks
|
|
133
|
+
const blocks = partsToResponseBlocks(parts);
|
|
134
|
+
if (blocks.length > 0) {
|
|
135
|
+
messages.push({ role: 'assistant', content: blocks });
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
// User turn — may contain text, functionResponse, or both
|
|
140
|
+
const textParts = parts.filter((p) => typeof p.text === 'string' && !p.thought && !p.functionResponse && !p.functionCall);
|
|
141
|
+
const functionResponses = parts.filter((p) => p.functionResponse);
|
|
142
|
+
// Text parts → user message
|
|
143
|
+
if (textParts.length > 0) {
|
|
144
|
+
const text = textParts.map((p) => p.text).join('\n');
|
|
145
|
+
messages.push({ role: 'user', content: text });
|
|
146
|
+
}
|
|
147
|
+
// Function responses → tool result messages
|
|
148
|
+
for (const part of functionResponses) {
|
|
149
|
+
const fr = part.functionResponse;
|
|
150
|
+
messages.push({
|
|
151
|
+
role: 'tool_result',
|
|
152
|
+
toolCallId: fr.id ?? fr.name ?? randomUUID(),
|
|
153
|
+
content: fr.response ? JSON.stringify(fr.response) : '',
|
|
154
|
+
isError: false,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
// If no text and no function responses, but there are parts with text (including thoughts)
|
|
158
|
+
// still send something so the conversation doesn't break
|
|
159
|
+
if (textParts.length === 0 && functionResponses.length === 0 && parts.length > 0) {
|
|
160
|
+
const anyText = parts.find((p) => typeof p.text === 'string');
|
|
161
|
+
if (anyText) {
|
|
162
|
+
messages.push({ role: 'user', content: anyText.text ?? '' });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return messages;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Convert model parts to LLMResponseBlock[].
|
|
171
|
+
*/
|
|
172
|
+
function partsToResponseBlocks(parts) {
|
|
173
|
+
const blocks = [];
|
|
174
|
+
for (const part of parts) {
|
|
175
|
+
// Skip thought parts (but not functionCall parts that happen to have thoughtSignature)
|
|
176
|
+
if (part.thought && !part.functionCall)
|
|
177
|
+
continue;
|
|
178
|
+
// Skip pure thought signature parts (no other content)
|
|
179
|
+
if (part.thoughtSignature && !part.functionCall && !part.text)
|
|
180
|
+
continue;
|
|
181
|
+
if (part.functionCall) {
|
|
182
|
+
blocks.push({
|
|
183
|
+
type: 'tool_use',
|
|
184
|
+
id: part.functionCall.id ?? randomUUID(),
|
|
185
|
+
name: part.functionCall.name ?? '',
|
|
186
|
+
input: part.functionCall.args ?? {},
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
else if (typeof part.text === 'string') {
|
|
190
|
+
blocks.push({ type: 'text', text: part.text });
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return blocks;
|
|
194
|
+
}
|
|
195
|
+
// ---------------------------------------------------------------------------
|
|
196
|
+
// Tools extraction
|
|
197
|
+
// ---------------------------------------------------------------------------
|
|
198
|
+
/**
|
|
199
|
+
* Extract LLMToolDefinition[] from Google Tool[].
|
|
200
|
+
*/
|
|
201
|
+
export function extractTools(tools) {
|
|
202
|
+
if (!tools || tools.length === 0)
|
|
203
|
+
return [];
|
|
204
|
+
const defs = [];
|
|
205
|
+
for (const tool of tools) {
|
|
206
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Gemini SDK tool types
|
|
207
|
+
const gTool = tool;
|
|
208
|
+
if (!gTool.functionDeclarations)
|
|
209
|
+
continue;
|
|
210
|
+
for (const fd of gTool.functionDeclarations) {
|
|
211
|
+
// Upstream uses parametersJsonSchema; standard @google/genai uses parameters
|
|
212
|
+
const params = fd.parametersJsonSchema ?? fd.parameters ?? {};
|
|
213
|
+
// Ensure parameters always has type: 'object' — Anthropic requires this
|
|
214
|
+
if (!params['type']) {
|
|
215
|
+
params['type'] = 'object';
|
|
216
|
+
}
|
|
217
|
+
defs.push({
|
|
218
|
+
name: fd.name ?? '',
|
|
219
|
+
description: fd.description ?? '',
|
|
220
|
+
parameters: params,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return defs;
|
|
225
|
+
}
|
|
226
|
+
//# sourceMappingURL=google-to-llm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-to-llm.js","sourceRoot":"","sources":["../../../../src/providers/content-generator/google-to-llm.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA+EzC,8EAA8E;AAC9E,6BAA6B;AAC7B,8EAA8E;AAE9E;;GAEG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAA+B;IAE/B,MAAM,QAAQ,GAAG,iBAAiB,CAAC,OAAO,CAAC,QAAQ,CA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EAAE,CAAC;QACzB,gGAAgG;QAChG,MAAM,KAAK,GAAG,IAAa,CAAC;QAC5B,IAAI,CAAC,KAAK,CAAC,oBAAoB;YAAE,SAAS;QAE1C,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,oBAAoB,EAAE,CAAC;YAC5C,6EAA6E;YAC7E,MAAM,MAAM,GAAG,EAAE,CAAC,oBAAoB,IAAI,EAAE,CAAC,UAAU,IAAI,EAAE,CAAC;YAC9D,wEAAwE;YACxE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;gBACpB,MAAM,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC;YAC5B,CAAC;YACD,IAAI,CAAC,IAAI,CAAC;gBACR,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,EAAE;gBACnB,WAAW,EAAE,EAAE,CAAC,WAAW,IAAI,EAAE;gBACjC,UAAU,EAAE,MAAM;aACnB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Amodal Labs, Inc.
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
export { MultiProviderContentGenerator } from './multi-provider-content-generator.js';
|
|
7
|
+
export { convertGenerateContentParams, normalizeContents, extractSystemPrompt, extractTools } from './google-to-llm.js';
|
|
8
|
+
export { convertLLMResponse, convertStreamEvent } from './llm-to-google.js';
|
|
9
|
+
export type { GGenerateContentParams } from './google-to-llm.js';
|
|
10
|
+
export type { GGenerateContentResponse } from './llm-to-google.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Amodal Labs, Inc.
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
export { MultiProviderContentGenerator } from './multi-provider-content-generator.js';
|
|
7
|
+
export { convertGenerateContentParams, normalizeContents, extractSystemPrompt, extractTools } from './google-to-llm.js';
|
|
8
|
+
export { convertLLMResponse, convertStreamEvent } from './llm-to-google.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/providers/content-generator/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,4BAA4B,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACxH,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Amodal Labs, Inc.
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Converts our provider-neutral LLM types (LLMChatResponse, LLMStreamEvent)
|
|
8
|
+
* back into Google @google/genai types (GenerateContentResponse).
|
|
9
|
+
*
|
|
10
|
+
* This is the "output" side of the ContentGenerator adapter — it translates
|
|
11
|
+
* responses from our RuntimeProvider implementations into the format that
|
|
12
|
+
* the upstream GeminiClient expects.
|
|
13
|
+
*/
|
|
14
|
+
import type { LLMChatResponse } from '../runtime/runtime-provider-types.js';
|
|
15
|
+
import type { LLMStreamEvent } from '../runtime/streaming-types.js';
|
|
16
|
+
interface GContent {
|
|
17
|
+
role?: string;
|
|
18
|
+
parts?: GPart[];
|
|
19
|
+
}
|
|
20
|
+
interface GPart {
|
|
21
|
+
text?: string;
|
|
22
|
+
functionCall?: {
|
|
23
|
+
id?: string;
|
|
24
|
+
name?: string;
|
|
25
|
+
args?: Record<string, unknown>;
|
|
26
|
+
};
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}
|
|
29
|
+
interface GCandidate {
|
|
30
|
+
content?: GContent;
|
|
31
|
+
finishReason?: string;
|
|
32
|
+
index?: number;
|
|
33
|
+
}
|
|
34
|
+
interface GUsageMetadata {
|
|
35
|
+
promptTokenCount?: number;
|
|
36
|
+
candidatesTokenCount?: number;
|
|
37
|
+
totalTokenCount?: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Structural match for GenerateContentResponse.
|
|
41
|
+
* We construct plain objects matching this shape and cast to the real class.
|
|
42
|
+
*/
|
|
43
|
+
export interface GGenerateContentResponse {
|
|
44
|
+
candidates?: GCandidate[];
|
|
45
|
+
usageMetadata?: GUsageMetadata;
|
|
46
|
+
responseId?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Convert an LLMChatResponse to a GenerateContentResponse.
|
|
50
|
+
*/
|
|
51
|
+
export declare function convertLLMResponse(response: LLMChatResponse): GGenerateContentResponse;
|
|
52
|
+
/**
|
|
53
|
+
* Convert a single LLMStreamEvent into a GenerateContentResponse chunk.
|
|
54
|
+
*
|
|
55
|
+
* Returns null for events that should be skipped (e.g., tool_use_delta
|
|
56
|
+
* which is accumulated by the caller).
|
|
57
|
+
*/
|
|
58
|
+
export declare function convertStreamEvent(event: LLMStreamEvent): GGenerateContentResponse | null;
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Amodal Labs, Inc.
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
// Non-streaming conversion
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
/**
|
|
10
|
+
* Convert an LLMChatResponse to a GenerateContentResponse.
|
|
11
|
+
*/
|
|
12
|
+
export function convertLLMResponse(response) {
|
|
13
|
+
const parts = response.content.map(blockToPart);
|
|
14
|
+
const result = {
|
|
15
|
+
candidates: [
|
|
16
|
+
{
|
|
17
|
+
content: { role: 'model', parts },
|
|
18
|
+
finishReason: mapFinishReason(response.stopReason),
|
|
19
|
+
index: 0,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
};
|
|
23
|
+
if (response.usage) {
|
|
24
|
+
result.usageMetadata = {
|
|
25
|
+
promptTokenCount: response.usage.inputTokens,
|
|
26
|
+
candidatesTokenCount: response.usage.outputTokens,
|
|
27
|
+
totalTokenCount: response.usage.inputTokens + response.usage.outputTokens,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
attachFunctionCallsGetter(result);
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
// Streaming conversion
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
/**
|
|
37
|
+
* Convert a single LLMStreamEvent into a GenerateContentResponse chunk.
|
|
38
|
+
*
|
|
39
|
+
* Returns null for events that should be skipped (e.g., tool_use_delta
|
|
40
|
+
* which is accumulated by the caller).
|
|
41
|
+
*/
|
|
42
|
+
export function convertStreamEvent(event) {
|
|
43
|
+
let chunk;
|
|
44
|
+
switch (event.type) {
|
|
45
|
+
case 'text_delta':
|
|
46
|
+
chunk = {
|
|
47
|
+
candidates: [
|
|
48
|
+
{
|
|
49
|
+
content: {
|
|
50
|
+
role: 'model',
|
|
51
|
+
parts: [{ text: event.text }],
|
|
52
|
+
},
|
|
53
|
+
index: 0,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
};
|
|
57
|
+
break;
|
|
58
|
+
case 'tool_use_start':
|
|
59
|
+
// Skip — we'll emit the complete function call on tool_use_end.
|
|
60
|
+
// The caller must track the name from this event.
|
|
61
|
+
return null;
|
|
62
|
+
case 'tool_use_delta':
|
|
63
|
+
// Skip — deltas are accumulated by the provider; args come in tool_use_end
|
|
64
|
+
return null;
|
|
65
|
+
case 'tool_use_end':
|
|
66
|
+
// Emit the complete function call with parsed args.
|
|
67
|
+
// The caller should have set the name from tool_use_start via toolNameMap.
|
|
68
|
+
chunk = {
|
|
69
|
+
candidates: [
|
|
70
|
+
{
|
|
71
|
+
content: {
|
|
72
|
+
role: 'model',
|
|
73
|
+
parts: [
|
|
74
|
+
{
|
|
75
|
+
functionCall: {
|
|
76
|
+
id: event.id,
|
|
77
|
+
name: '', // Caller must patch this with the name from tool_use_start
|
|
78
|
+
args: event.input,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
index: 0,
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
};
|
|
87
|
+
break;
|
|
88
|
+
case 'message_end':
|
|
89
|
+
chunk = {
|
|
90
|
+
candidates: [
|
|
91
|
+
{
|
|
92
|
+
content: { role: 'model', parts: [] },
|
|
93
|
+
finishReason: mapFinishReason(event.stopReason),
|
|
94
|
+
index: 0,
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
};
|
|
98
|
+
if (event.usage) {
|
|
99
|
+
chunk.usageMetadata = {
|
|
100
|
+
promptTokenCount: event.usage.inputTokens,
|
|
101
|
+
candidatesTokenCount: event.usage.outputTokens,
|
|
102
|
+
totalTokenCount: event.usage.inputTokens + event.usage.outputTokens,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
default:
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
if (chunk) {
|
|
110
|
+
attachFunctionCallsGetter(chunk);
|
|
111
|
+
}
|
|
112
|
+
return chunk;
|
|
113
|
+
}
|
|
114
|
+
// ---------------------------------------------------------------------------
|
|
115
|
+
// Helpers
|
|
116
|
+
// ---------------------------------------------------------------------------
|
|
117
|
+
/**
|
|
118
|
+
* Attach a `functionCalls` getter to a response object.
|
|
119
|
+
*
|
|
120
|
+
* The upstream GeminiChat uses `resp.functionCalls` (a class getter) to extract
|
|
121
|
+
* function calls from responses. Our plain objects don't have this getter,
|
|
122
|
+
* so we must add it manually.
|
|
123
|
+
*/
|
|
124
|
+
function attachFunctionCallsGetter(resp) {
|
|
125
|
+
Object.defineProperty(resp, 'functionCalls', {
|
|
126
|
+
get() {
|
|
127
|
+
const parts = resp.candidates?.[0]?.content?.parts;
|
|
128
|
+
if (!parts)
|
|
129
|
+
return undefined;
|
|
130
|
+
const calls = parts
|
|
131
|
+
.filter((p) => p.functionCall)
|
|
132
|
+
.map((p) => p.functionCall);
|
|
133
|
+
return calls.length > 0 ? calls : undefined;
|
|
134
|
+
},
|
|
135
|
+
enumerable: false,
|
|
136
|
+
configurable: true,
|
|
137
|
+
});
|
|
138
|
+
// Also add `text` getter used by some upstream code
|
|
139
|
+
Object.defineProperty(resp, 'text', {
|
|
140
|
+
get() {
|
|
141
|
+
const parts = resp.candidates?.[0]?.content?.parts;
|
|
142
|
+
if (!parts)
|
|
143
|
+
return undefined;
|
|
144
|
+
const texts = parts.filter((p) => p.text).map((p) => p.text);
|
|
145
|
+
return texts.length > 0 ? texts.join('') : undefined;
|
|
146
|
+
},
|
|
147
|
+
enumerable: false,
|
|
148
|
+
configurable: true,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function blockToPart(block) {
|
|
152
|
+
if (block.type === 'text') {
|
|
153
|
+
return { text: block.text };
|
|
154
|
+
}
|
|
155
|
+
// tool_use
|
|
156
|
+
return {
|
|
157
|
+
functionCall: {
|
|
158
|
+
id: block.id,
|
|
159
|
+
name: block.name,
|
|
160
|
+
args: block.input,
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function mapFinishReason(stopReason) {
|
|
165
|
+
switch (stopReason) {
|
|
166
|
+
case 'end_turn':
|
|
167
|
+
return 'STOP';
|
|
168
|
+
case 'tool_use':
|
|
169
|
+
return 'STOP';
|
|
170
|
+
case 'max_tokens':
|
|
171
|
+
return 'MAX_TOKENS';
|
|
172
|
+
case 'error':
|
|
173
|
+
return 'FINISH_REASON_UNSPECIFIED';
|
|
174
|
+
default:
|
|
175
|
+
return 'STOP';
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=llm-to-google.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-to-google.js","sourceRoot":"","sources":["../../../../src/providers/content-generator/llm-to-google.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAmDH,8EAA8E;AAC9E,2BAA2B;AAC3B,8EAA8E;AAE9E;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAyB;IAC1D,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAEhD,MAAM,MAAM,GAA6B;QACvC,UAAU,EAAE;YACV;gBACE,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE;gBACjC,YAAY,EAAE,eAAe,CAAC,QAAQ,CAAC,UAAU,CAAC;gBAClD,KAAK,EAAE,CAAC;aACT;SACF;KACF,CAAC;IAEF,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;QACnB,MAAM,CAAC,aAAa,GAAG;YACrB,gBAAgB,EAAE,QAAQ,CAAC,KAAK,CAAC,WAAW;YAC5C,oBAAoB,EAAE,QAAQ,CAAC,KAAK,CAAC,YAAY;YACjD,eAAe,EAAE,QAAQ,CAAC,KAAK,CAAC,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC,YAAY;SAC1E,CAAC;IACJ,CAAC;IAED,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAClC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,8EAA8E;AAC9E,uBAAuB;AACvB,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAqB;IACtD,IAAI,KAAsC,CAAC;IAE3C,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,YAAY;YACf,KAAK,GAAG;gBACN,UAAU,EAAE;oBACV;wBACE,OAAO,EAAE;4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C,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACvD,CAAC;QACD,UAAU,EAAE,KAAK;QACjB,YAAY,EAAE,IAAI;KACnB,CAAC,CAAC;AACL,CAAC;AAED,SAAS,WAAW,CAAC,KAAuB;IAC1C,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC1B,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;IAC9B,CAAC;IACD,WAAW;IACX,OAAO;QACL,YAAY,EAAE;YACZ,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,KAAK;SAClB;KACF,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CACtB,UAAyC;IAEzC,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,UAAU;YACb,OAAO,MAAM,CAAC;QAChB,KAAK,UAAU;YACb,OAAO,MAAM,CAAC;QAChB,KAAK,YAAY;YACf,OAAO,YAAY,CAAC;QACtB,KAAK,OAAO;YACV,OAAO,2BAA2B,CAAC;QACrC;YACE,OAAO,MAAM,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Amodal Labs, Inc.
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A ContentGenerator implementation that delegates to our existing
|
|
8
|
+
* RuntimeProvider implementations (Anthropic, OpenAI, Bedrock, Azure, etc.)
|
|
9
|
+
*
|
|
10
|
+
* This bridges the upstream gemini-cli-core's ContentGenerator interface
|
|
11
|
+
* (which uses @google/genai types) with our provider-neutral RuntimeProvider
|
|
12
|
+
* system. The upstream GeminiClient calls this instead of the Gemini API,
|
|
13
|
+
* so all its orchestration logic (compression, loop detection, hooks,
|
|
14
|
+
* tool execution) continues to work with any LLM provider.
|
|
15
|
+
*/
|
|
16
|
+
import type { ModelConfig } from '../../repo/config-schema.js';
|
|
17
|
+
import { type GGenerateContentParams } from './google-to-llm.js';
|
|
18
|
+
import { type GGenerateContentResponse } from './llm-to-google.js';
|
|
19
|
+
/**
|
|
20
|
+
* ContentGenerator that routes LLM calls through our RuntimeProvider system.
|
|
21
|
+
*
|
|
22
|
+
* Implements the upstream ContentGenerator interface structurally — the
|
|
23
|
+
* actual type comes from @google/gemini-cli-core which we don't import
|
|
24
|
+
* directly. The upstream Config accepts any object matching the interface.
|
|
25
|
+
*/
|
|
26
|
+
export declare class MultiProviderContentGenerator {
|
|
27
|
+
private readonly provider;
|
|
28
|
+
constructor(modelConfig: ModelConfig);
|
|
29
|
+
/**
|
|
30
|
+
* Non-streaming content generation.
|
|
31
|
+
*/
|
|
32
|
+
generateContent(request: GGenerateContentParams, _userPromptId: string, _role: unknown): Promise<GGenerateContentResponse>;
|
|
33
|
+
/**
|
|
34
|
+
* Streaming content generation.
|
|
35
|
+
*
|
|
36
|
+
* Returns an async generator that yields GenerateContentResponse chunks
|
|
37
|
+
* as our RuntimeProvider streams events.
|
|
38
|
+
*/
|
|
39
|
+
generateContentStream(request: GGenerateContentParams, _userPromptId: string, _role: unknown): Promise<AsyncGenerator<GGenerateContentResponse>>;
|
|
40
|
+
/**
|
|
41
|
+
* Estimate token count based on character length.
|
|
42
|
+
*
|
|
43
|
+
* Provider-specific tokenizers could be added later; for now a rough
|
|
44
|
+
* estimate (chars / 4) is sufficient since this is only used for
|
|
45
|
+
* context window overflow checks.
|
|
46
|
+
*/
|
|
47
|
+
countTokens(request: {
|
|
48
|
+
contents: unknown;
|
|
49
|
+
model?: string;
|
|
50
|
+
}): Promise<{
|
|
51
|
+
totalTokens: number;
|
|
52
|
+
}>;
|
|
53
|
+
/**
|
|
54
|
+
* Embeddings are not supported for non-Google providers.
|
|
55
|
+
*/
|
|
56
|
+
embedContent(_request: unknown): Promise<{
|
|
57
|
+
embeddings: never[];
|
|
58
|
+
}>;
|
|
59
|
+
private streamFromProvider;
|
|
60
|
+
private fakeStream;
|
|
61
|
+
}
|