@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,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Amodal Labs, Inc.
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
import { readFile, readdir } from 'node:fs/promises';
|
|
7
|
+
import * as path from 'node:path';
|
|
8
|
+
import { ZodError } from 'zod';
|
|
9
|
+
import { PackageError } from './package-error.js';
|
|
10
|
+
import { PackageManifestSchema } from './package-types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Read and validate the amodal manifest from an installed package directory.
|
|
13
|
+
*/
|
|
14
|
+
export async function readPackageManifest(packageDir) {
|
|
15
|
+
const pkgJsonPath = path.join(packageDir, 'package.json');
|
|
16
|
+
let content;
|
|
17
|
+
try {
|
|
18
|
+
content = await readFile(pkgJsonPath, 'utf-8');
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
22
|
+
if (err.code === 'ENOENT') {
|
|
23
|
+
throw new PackageError('NOT_FOUND', `Missing package.json in ${packageDir}`);
|
|
24
|
+
}
|
|
25
|
+
throw new PackageError('PARSE_FAILED', `Failed to read ${pkgJsonPath}`, err);
|
|
26
|
+
}
|
|
27
|
+
let raw;
|
|
28
|
+
try {
|
|
29
|
+
raw = JSON.parse(content);
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
throw new PackageError('PARSE_FAILED', `Invalid JSON in ${pkgJsonPath}`, err);
|
|
33
|
+
}
|
|
34
|
+
if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {
|
|
35
|
+
throw new PackageError('PARSE_FAILED', `package.json is not an object in ${packageDir}`);
|
|
36
|
+
}
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
38
|
+
const pkg = raw;
|
|
39
|
+
const amodal = pkg['amodal'];
|
|
40
|
+
if (!amodal || typeof amodal !== 'object') {
|
|
41
|
+
throw new PackageError('VALIDATION_FAILED', `Missing or invalid "amodal" block in ${pkgJsonPath}`);
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
return PackageManifestSchema.parse(amodal);
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
if (err instanceof ZodError) {
|
|
48
|
+
const issues = err.issues
|
|
49
|
+
.map((i) => `${i.path.join('.')}: ${i.message}`)
|
|
50
|
+
.join('; ');
|
|
51
|
+
throw new PackageError('VALIDATION_FAILED', `Invalid amodal manifest in ${pkgJsonPath}: ${issues}`, err);
|
|
52
|
+
}
|
|
53
|
+
throw new PackageError('VALIDATION_FAILED', `Manifest validation failed in ${packageDir}`, err);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Read a specific file from a package directory.
|
|
58
|
+
* Returns null if the file doesn't exist.
|
|
59
|
+
*/
|
|
60
|
+
export async function readPackageFile(packageDir, filename) {
|
|
61
|
+
const filePath = path.join(packageDir, filename);
|
|
62
|
+
try {
|
|
63
|
+
return await readFile(filePath, 'utf-8');
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
67
|
+
if (err.code === 'ENOENT') {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
throw new PackageError('NOT_FOUND', `Failed to read ${filePath}`, err);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* List all files in a package directory.
|
|
75
|
+
*/
|
|
76
|
+
export async function listPackageFiles(packageDir) {
|
|
77
|
+
try {
|
|
78
|
+
const entries = await readdir(packageDir, { withFileTypes: true });
|
|
79
|
+
return entries
|
|
80
|
+
.filter((e) => e.isFile())
|
|
81
|
+
.map((e) => e.name);
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
85
|
+
if (err.code === 'ENOENT') {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
throw new PackageError('NOT_FOUND', `Failed to list files in ${packageDir}`, err);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=manifest-reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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,GAAG,EAAE,CAAC;QACb,uEAAuE;QACvE,IAAK,GAA6B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACrD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,IAAI,YAAY,CAAC,WAAW,EAAE,kBAAkB,QAAQ,EAAE,EAAE,GAAG,CAAC,CAAC;IACzE,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,UAAkB;IACvD,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,EAAE,EAAC,aAAa,EAAE,IAAI,EAAC,CAAC,CAAC;QACjE,OAAO,OAAO;aACX,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;aACzB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,uEAAuE;QACvE,IAAK,GAA6B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACrD,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,IAAI,YAAY,CAAC,WAAW,EAAE,2BAA2B,UAAU,EAAE,EAAE,GAAG,CAAC,CAAC;IACpF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Amodal Labs, Inc.
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
import type { AccessConfig } from '../repo/connection-schemas.js';
|
|
7
|
+
import type { ConnectionSpec } from '../repo/connection-schemas.js';
|
|
8
|
+
import type { SurfaceEndpoint } from '../repo/connection-types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Deep merge two objects. Local values win. Arrays are replaced entirely.
|
|
11
|
+
*/
|
|
12
|
+
export declare function deepMergeLocalWins(base: Record<string, unknown>, local: Record<string, unknown>): Record<string, unknown>;
|
|
13
|
+
/**
|
|
14
|
+
* Merge a local spec.json override on top of a package base.
|
|
15
|
+
*/
|
|
16
|
+
export declare function mergeSpecJson(baseJson: string, localJson: string): ConnectionSpec;
|
|
17
|
+
type ConfirmTier = undefined | true | 'review' | 'never';
|
|
18
|
+
/**
|
|
19
|
+
* Filter endpoints by only/exclude lists from frontmatter.
|
|
20
|
+
*/
|
|
21
|
+
export declare function filterEndpoints(endpoints: SurfaceEndpoint[], frontmatter: Record<string, unknown>): SurfaceEndpoint[];
|
|
22
|
+
/**
|
|
23
|
+
* Merge a local surface.md override on top of a package base.
|
|
24
|
+
*/
|
|
25
|
+
export declare function mergeSurface(baseMd: string, localMd: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Return the tighter of two confirmation tiers.
|
|
28
|
+
*/
|
|
29
|
+
export declare function tighterConfirm(base: ConfirmTier, local: ConfirmTier): ConfirmTier;
|
|
30
|
+
type FieldPolicy = 'role_gated' | 'retrieve_but_redact' | 'never_retrieve';
|
|
31
|
+
/**
|
|
32
|
+
* Return the tighter of two field restriction policies.
|
|
33
|
+
*/
|
|
34
|
+
export declare function tighterPolicy(base: FieldPolicy, local: FieldPolicy): FieldPolicy;
|
|
35
|
+
/**
|
|
36
|
+
* Narrow roles by intersection. undefined means "no restriction" (all roles).
|
|
37
|
+
*/
|
|
38
|
+
export declare function narrowRoles(base?: string[], local?: string[]): string[] | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Merge a local access.json override on top of a package base.
|
|
41
|
+
* Local overrides take precedence — the user's repo is the final word.
|
|
42
|
+
*/
|
|
43
|
+
export declare function mergeAccessJson(baseJson: string, localJson: string): AccessConfig;
|
|
44
|
+
/**
|
|
45
|
+
* Extract ### heading sections from markdown content.
|
|
46
|
+
* Returns a Map of heading text → section content (without the heading line).
|
|
47
|
+
* Also returns the preamble (content before the first ### heading).
|
|
48
|
+
*/
|
|
49
|
+
export declare function extractHeadingSections(content: string): {
|
|
50
|
+
preamble: string;
|
|
51
|
+
sections: Map<string, string>;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Merge entities.md: local ### sections replace matching base sections.
|
|
55
|
+
* Unmatched base sections pass through.
|
|
56
|
+
*/
|
|
57
|
+
export declare function mergeEntities(baseMd: string, localMd: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Concatenate package base with local additions.
|
|
60
|
+
* Package content first, blank line separator, local body (frontmatter stripped).
|
|
61
|
+
*/
|
|
62
|
+
export declare function mergeConcatenation(baseMd: string, localMd: string): string;
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Amodal Labs, Inc.
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
import { AccessConfigSchema, ConnectionSpecSchema } from '../repo/connection-schemas.js';
|
|
7
|
+
import { parseSurface } from '../repo/surface-parser.js';
|
|
8
|
+
import { parseJsonImport, parseMarkdownFrontmatter, validateSurfaceFrontmatter } from './frontmatter.js';
|
|
9
|
+
import { PackageError } from './package-error.js';
|
|
10
|
+
// --- spec.json merge: deep merge, local wins, arrays replaced ---
|
|
11
|
+
/**
|
|
12
|
+
* Deep merge two objects. Local values win. Arrays are replaced entirely.
|
|
13
|
+
*/
|
|
14
|
+
export function deepMergeLocalWins(base, local) {
|
|
15
|
+
const result = { ...base };
|
|
16
|
+
for (const key of Object.keys(local)) {
|
|
17
|
+
const baseVal = base[key];
|
|
18
|
+
const localVal = local[key];
|
|
19
|
+
if (localVal !== null &&
|
|
20
|
+
typeof localVal === 'object' &&
|
|
21
|
+
!Array.isArray(localVal) &&
|
|
22
|
+
baseVal !== null &&
|
|
23
|
+
typeof baseVal === 'object' &&
|
|
24
|
+
!Array.isArray(baseVal)) {
|
|
25
|
+
// Recurse for nested objects
|
|
26
|
+
result[key] = deepMergeLocalWins(
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
28
|
+
baseVal,
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
30
|
+
localVal);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// Local wins (arrays replaced entirely)
|
|
34
|
+
result[key] = localVal;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Merge a local spec.json override on top of a package base.
|
|
41
|
+
*/
|
|
42
|
+
export function mergeSpecJson(baseJson, localJson) {
|
|
43
|
+
const { data: localData } = parseJsonImport(localJson);
|
|
44
|
+
let baseRaw;
|
|
45
|
+
try {
|
|
46
|
+
baseRaw = JSON.parse(baseJson);
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
throw new PackageError('PARSE_FAILED', 'Invalid JSON in base spec.json', err);
|
|
50
|
+
}
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
52
|
+
const merged = deepMergeLocalWins(baseRaw, localData);
|
|
53
|
+
return ConnectionSpecSchema.parse(merged);
|
|
54
|
+
}
|
|
55
|
+
const CONFIRM_RANK = {
|
|
56
|
+
undefined: 0,
|
|
57
|
+
true: 1,
|
|
58
|
+
review: 2,
|
|
59
|
+
never: 3,
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Filter endpoints by only/exclude lists from frontmatter.
|
|
63
|
+
*/
|
|
64
|
+
export function filterEndpoints(endpoints, frontmatter) {
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
66
|
+
const only = frontmatter['only'];
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
68
|
+
const exclude = frontmatter['exclude'];
|
|
69
|
+
if (Array.isArray(only) && only.length > 0) {
|
|
70
|
+
const set = new Set(only);
|
|
71
|
+
return endpoints.filter((ep) => set.has(`${ep.method} ${ep.path}`));
|
|
72
|
+
}
|
|
73
|
+
if (Array.isArray(exclude) && exclude.length > 0) {
|
|
74
|
+
const set = new Set(exclude);
|
|
75
|
+
return endpoints.filter((ep) => !set.has(`${ep.method} ${ep.path}`));
|
|
76
|
+
}
|
|
77
|
+
return endpoints;
|
|
78
|
+
}
|
|
79
|
+
const ENDPOINT_HEADING_RE = /^###\s+(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\s+(\S+)/;
|
|
80
|
+
/**
|
|
81
|
+
* Merge a local surface.md override on top of a package base.
|
|
82
|
+
*/
|
|
83
|
+
export function mergeSurface(baseMd, localMd) {
|
|
84
|
+
const { frontmatter, body } = parseMarkdownFrontmatter(localMd);
|
|
85
|
+
if (frontmatter) {
|
|
86
|
+
validateSurfaceFrontmatter(frontmatter);
|
|
87
|
+
}
|
|
88
|
+
// Parse and filter base endpoints
|
|
89
|
+
let baseEndpoints = parseSurface(baseMd);
|
|
90
|
+
if (frontmatter) {
|
|
91
|
+
baseEndpoints = filterEndpoints(baseEndpoints, frontmatter);
|
|
92
|
+
}
|
|
93
|
+
// Build local endpoint sections
|
|
94
|
+
const localSections = new Map();
|
|
95
|
+
let currentKey = null;
|
|
96
|
+
const currentLines = [];
|
|
97
|
+
const nonEndpointLines = [];
|
|
98
|
+
let foundEndpoint = false;
|
|
99
|
+
for (const line of body.split('\n')) {
|
|
100
|
+
const match = ENDPOINT_HEADING_RE.exec(line);
|
|
101
|
+
if (match) {
|
|
102
|
+
if (currentKey) {
|
|
103
|
+
localSections.set(currentKey, currentLines.join('\n').trim());
|
|
104
|
+
currentLines.length = 0;
|
|
105
|
+
}
|
|
106
|
+
currentKey = `${match[1]} ${match[2]}`;
|
|
107
|
+
foundEndpoint = true;
|
|
108
|
+
}
|
|
109
|
+
else if (currentKey) {
|
|
110
|
+
currentLines.push(line);
|
|
111
|
+
}
|
|
112
|
+
else if (!foundEndpoint) {
|
|
113
|
+
// Lines before any ### endpoint heading
|
|
114
|
+
nonEndpointLines.push(line);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (currentKey) {
|
|
118
|
+
localSections.set(currentKey, currentLines.join('\n').trim());
|
|
119
|
+
}
|
|
120
|
+
// Build output
|
|
121
|
+
const outputParts = [];
|
|
122
|
+
// Render base endpoints, appending local additions if they match
|
|
123
|
+
for (const ep of baseEndpoints) {
|
|
124
|
+
const key = `${ep.method} ${ep.path}`;
|
|
125
|
+
let section = `### ${ep.method} ${ep.path}`;
|
|
126
|
+
if (ep.description) {
|
|
127
|
+
section += `\n${ep.description}`;
|
|
128
|
+
}
|
|
129
|
+
const localAddition = localSections.get(key);
|
|
130
|
+
if (localAddition) {
|
|
131
|
+
section += `\n${localAddition}`;
|
|
132
|
+
localSections.delete(key);
|
|
133
|
+
}
|
|
134
|
+
outputParts.push(section);
|
|
135
|
+
}
|
|
136
|
+
// Append remaining local sections that didn't match base endpoints
|
|
137
|
+
for (const [key, content] of localSections) {
|
|
138
|
+
let section = `### ${key}`;
|
|
139
|
+
if (content) {
|
|
140
|
+
section += `\n${content}`;
|
|
141
|
+
}
|
|
142
|
+
outputParts.push(section);
|
|
143
|
+
}
|
|
144
|
+
let result = outputParts.join('\n\n');
|
|
145
|
+
// Prepend non-endpoint content from local body
|
|
146
|
+
const preamble = nonEndpointLines.join('\n').trim();
|
|
147
|
+
if (preamble) {
|
|
148
|
+
result = preamble + '\n\n' + result;
|
|
149
|
+
}
|
|
150
|
+
return result.trim();
|
|
151
|
+
}
|
|
152
|
+
// --- access.json merge: additive, restrictions only tighten ---
|
|
153
|
+
function confirmRank(tier) {
|
|
154
|
+
return CONFIRM_RANK[String(tier)] ?? 0;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Return the tighter of two confirmation tiers.
|
|
158
|
+
*/
|
|
159
|
+
export function tighterConfirm(base, local) {
|
|
160
|
+
if (confirmRank(local) > confirmRank(base))
|
|
161
|
+
return local;
|
|
162
|
+
return base;
|
|
163
|
+
}
|
|
164
|
+
const POLICY_RANK = {
|
|
165
|
+
role_gated: 0,
|
|
166
|
+
retrieve_but_redact: 1,
|
|
167
|
+
never_retrieve: 2,
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Return the tighter of two field restriction policies.
|
|
171
|
+
*/
|
|
172
|
+
export function tighterPolicy(base, local) {
|
|
173
|
+
const baseRank = POLICY_RANK[base] ?? 0;
|
|
174
|
+
const localRank = POLICY_RANK[local] ?? 0;
|
|
175
|
+
return localRank > baseRank ? local : base;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Narrow roles by intersection. undefined means "no restriction" (all roles).
|
|
179
|
+
*/
|
|
180
|
+
export function narrowRoles(base, local) {
|
|
181
|
+
if (!base)
|
|
182
|
+
return local;
|
|
183
|
+
if (!local)
|
|
184
|
+
return base;
|
|
185
|
+
// Intersection
|
|
186
|
+
const baseSet = new Set(base);
|
|
187
|
+
return local.filter((r) => baseSet.has(r));
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Merge a local access.json override on top of a package base.
|
|
191
|
+
* Local overrides take precedence — the user's repo is the final word.
|
|
192
|
+
*/
|
|
193
|
+
export function mergeAccessJson(baseJson, localJson) {
|
|
194
|
+
const { data: localData } = parseJsonImport(localJson);
|
|
195
|
+
let baseRaw;
|
|
196
|
+
try {
|
|
197
|
+
baseRaw = JSON.parse(baseJson);
|
|
198
|
+
}
|
|
199
|
+
catch (err) {
|
|
200
|
+
throw new PackageError('PARSE_FAILED', 'Invalid JSON in base access.json', err);
|
|
201
|
+
}
|
|
202
|
+
const base = AccessConfigSchema.parse(baseRaw);
|
|
203
|
+
// Merge endpoints
|
|
204
|
+
const mergedEndpoints = { ...base.endpoints };
|
|
205
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
206
|
+
const localEndpoints = localData['endpoints'];
|
|
207
|
+
if (localEndpoints) {
|
|
208
|
+
for (const [ep, localAccess] of Object.entries(localEndpoints)) {
|
|
209
|
+
const baseAccess = mergedEndpoints[ep];
|
|
210
|
+
if (!baseAccess) {
|
|
211
|
+
// New endpoint — add it directly (local defines new restrictions)
|
|
212
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
213
|
+
mergedEndpoints[ep] = localAccess;
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
// Local override wins — merge base fields, then apply local on top
|
|
217
|
+
mergedEndpoints[ep] = {
|
|
218
|
+
...baseAccess,
|
|
219
|
+
...localAccess,
|
|
220
|
+
};
|
|
221
|
+
// If local explicitly omits confirm (undefined), remove it from merged
|
|
222
|
+
if (localAccess.confirm === undefined && 'confirm' in localAccess) {
|
|
223
|
+
delete mergedEndpoints[ep].confirm;
|
|
224
|
+
}
|
|
225
|
+
else if (localAccess.confirm !== undefined) {
|
|
226
|
+
mergedEndpoints[ep].confirm = localAccess.confirm;
|
|
227
|
+
}
|
|
228
|
+
if (localAccess.thresholds) {
|
|
229
|
+
mergedEndpoints[ep].thresholds = [
|
|
230
|
+
...(baseAccess.thresholds ?? []),
|
|
231
|
+
...localAccess.thresholds,
|
|
232
|
+
];
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
// Merge field restrictions
|
|
238
|
+
const baseRestrictions = base.fieldRestrictions ?? [];
|
|
239
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
240
|
+
const localRestrictions = (localData['fieldRestrictions'] ?? []);
|
|
241
|
+
const mergedRestrictions = [...baseRestrictions];
|
|
242
|
+
for (const localRestr of localRestrictions) {
|
|
243
|
+
const entity = String(localRestr['entity'] ?? '');
|
|
244
|
+
const field = String(localRestr['field'] ?? '');
|
|
245
|
+
// Find matching base restriction
|
|
246
|
+
const existingIdx = mergedRestrictions.findIndex((r) => r.entity === entity && r.field === field);
|
|
247
|
+
if (existingIdx >= 0) {
|
|
248
|
+
const existing = mergedRestrictions[existingIdx];
|
|
249
|
+
// Local override wins for policy and roles
|
|
250
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
251
|
+
const newPolicy = localRestr['policy'] ?? existing.policy;
|
|
252
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
253
|
+
const newRoles = localRestr['allowedRoles'] ?? existing.allowedRoles;
|
|
254
|
+
mergedRestrictions[existingIdx] = {
|
|
255
|
+
...existing,
|
|
256
|
+
policy: newPolicy,
|
|
257
|
+
allowedRoles: newRoles,
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
// New restriction — add it
|
|
262
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
263
|
+
mergedRestrictions.push(localRestr);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
const result = {
|
|
267
|
+
...base,
|
|
268
|
+
endpoints: mergedEndpoints,
|
|
269
|
+
fieldRestrictions: mergedRestrictions.length > 0 ? mergedRestrictions : undefined,
|
|
270
|
+
};
|
|
271
|
+
// Merge delegations if local provides them
|
|
272
|
+
if (localData['delegations']) {
|
|
273
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
274
|
+
result.delegations = localData['delegations'];
|
|
275
|
+
}
|
|
276
|
+
// Merge alternativeLookups additively
|
|
277
|
+
if (localData['alternativeLookups']) {
|
|
278
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
279
|
+
const localLookups = localData['alternativeLookups'];
|
|
280
|
+
result.alternativeLookups = [
|
|
281
|
+
...(base.alternativeLookups ?? []),
|
|
282
|
+
...(localLookups ?? []),
|
|
283
|
+
];
|
|
284
|
+
}
|
|
285
|
+
return result;
|
|
286
|
+
}
|
|
287
|
+
// --- entities.md merge: section-level by ### heading ---
|
|
288
|
+
/**
|
|
289
|
+
* Extract ### heading sections from markdown content.
|
|
290
|
+
* Returns a Map of heading text → section content (without the heading line).
|
|
291
|
+
* Also returns the preamble (content before the first ### heading).
|
|
292
|
+
*/
|
|
293
|
+
export function extractHeadingSections(content) {
|
|
294
|
+
const lines = content.split('\n');
|
|
295
|
+
const sections = new Map();
|
|
296
|
+
const preambleLines = [];
|
|
297
|
+
let currentHeading = null;
|
|
298
|
+
const currentLines = [];
|
|
299
|
+
for (const line of lines) {
|
|
300
|
+
const headingMatch = /^###\s+(.+)/.exec(line);
|
|
301
|
+
if (headingMatch) {
|
|
302
|
+
if (currentHeading) {
|
|
303
|
+
sections.set(currentHeading, currentLines.join('\n').trim());
|
|
304
|
+
currentLines.length = 0;
|
|
305
|
+
}
|
|
306
|
+
currentHeading = headingMatch[1].trim();
|
|
307
|
+
}
|
|
308
|
+
else if (currentHeading) {
|
|
309
|
+
currentLines.push(line);
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
preambleLines.push(line);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (currentHeading) {
|
|
316
|
+
sections.set(currentHeading, currentLines.join('\n').trim());
|
|
317
|
+
}
|
|
318
|
+
return { preamble: preambleLines.join('\n').trim(), sections };
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Merge entities.md: local ### sections replace matching base sections.
|
|
322
|
+
* Unmatched base sections pass through.
|
|
323
|
+
*/
|
|
324
|
+
export function mergeEntities(baseMd, localMd) {
|
|
325
|
+
const { body } = parseMarkdownFrontmatter(localMd);
|
|
326
|
+
const baseParsed = extractHeadingSections(baseMd);
|
|
327
|
+
const localParsed = extractHeadingSections(body);
|
|
328
|
+
// Start with base sections, replace with local where present
|
|
329
|
+
const mergedSections = new Map(baseParsed.sections);
|
|
330
|
+
for (const [heading, content] of localParsed.sections) {
|
|
331
|
+
mergedSections.set(heading, content);
|
|
332
|
+
}
|
|
333
|
+
const parts = [];
|
|
334
|
+
if (baseParsed.preamble) {
|
|
335
|
+
parts.push(baseParsed.preamble);
|
|
336
|
+
}
|
|
337
|
+
for (const [heading, content] of mergedSections) {
|
|
338
|
+
parts.push(`### ${heading}\n${content}`);
|
|
339
|
+
}
|
|
340
|
+
return parts.join('\n\n').trim();
|
|
341
|
+
}
|
|
342
|
+
// --- Concatenation merge (rules, skills, automations, knowledge) ---
|
|
343
|
+
/**
|
|
344
|
+
* Concatenate package base with local additions.
|
|
345
|
+
* Package content first, blank line separator, local body (frontmatter stripped).
|
|
346
|
+
*/
|
|
347
|
+
export function mergeConcatenation(baseMd, localMd) {
|
|
348
|
+
const { body } = parseMarkdownFrontmatter(localMd);
|
|
349
|
+
const baseContent = baseMd.trim();
|
|
350
|
+
const localContent = body.trim();
|
|
351
|
+
if (!localContent)
|
|
352
|
+
return baseContent;
|
|
353
|
+
if (!baseContent)
|
|
354
|
+
return localContent;
|
|
355
|
+
return `${baseContent}\n\n${localContent}`;
|
|
356
|
+
}
|
|
357
|
+
//# sourceMappingURL=merge-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-engine.js","sourceRoot":"","sources":["../../../src/packages/merge-engine.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAC,kBAAkB,EAAE,oBAAoB,EAAC,MAAM,+BAA+B,CAAC;AAGvF,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAC,eAAe,EAAE,wBAAwB,EAAE,0BAA0B,EAAC,MAAM,kBAAkB,CAAC;AACvG,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAEhD,mEAAmE;AAEnE;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAA6B,EAC7B,KAA8B;IAE9B,MAAM,MAAM,GAA4B,EAAC,GAAG,IAAI,EAAC,CAAC;IAElD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QAE5B,IACE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K,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IACD,KAAK,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,cAAc,EAAE,CAAC;QAChD,KAAK,CAAC,IAAI,CAAC,OAAO,OAAO,KAAK,OAAO,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;AACnC,CAAC;AAED,sEAAsE;AAEtE;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAc,EAAE,OAAe;IAChE,MAAM,EAAC,IAAI,EAAC,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACjD,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IAClC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAEjC,IAAI,CAAC,YAAY;QAAE,OAAO,WAAW,CAAC;IACtC,IAAI,CAAC,WAAW;QAAE,OAAO,YAAY,CAAC;IAEtC,OAAO,GAAG,WAAW,OAAO,YAAY,EAAE,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Amodal Labs, Inc.
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
import type { LockFile, PackageRef } from './package-types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Paths for the hidden npm context.
|
|
9
|
+
*/
|
|
10
|
+
export interface NpmContextPaths {
|
|
11
|
+
root: string;
|
|
12
|
+
npmDir: string;
|
|
13
|
+
npmrc: string;
|
|
14
|
+
packageJson: string;
|
|
15
|
+
nodeModules: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get the standard paths for the hidden npm context.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getNpmContextPaths(repoPath: string): NpmContextPaths;
|
|
21
|
+
/**
|
|
22
|
+
* Ensure the hidden npm context exists. Idempotent.
|
|
23
|
+
*/
|
|
24
|
+
export declare function ensureNpmContext(repoPath: string, registryUrl?: string): Promise<NpmContextPaths>;
|
|
25
|
+
/**
|
|
26
|
+
* Run `npm install` for a specific package.
|
|
27
|
+
*/
|
|
28
|
+
export declare function npmInstall(paths: NpmContextPaths, npmName: string, version?: string, timeout?: number): Promise<{
|
|
29
|
+
version: string;
|
|
30
|
+
integrity: string;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Run `npm install` to restore all packages from package.json.
|
|
34
|
+
*/
|
|
35
|
+
export declare function npmInstallAll(paths: NpmContextPaths, timeout?: number): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Run `npm uninstall` for a specific package.
|
|
38
|
+
*/
|
|
39
|
+
export declare function npmUninstall(paths: NpmContextPaths, npmName: string, timeout?: number): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Generate package.json dependencies from a lock file.
|
|
42
|
+
*/
|
|
43
|
+
export declare function generatePackageJson(lockFile: LockFile): Record<string, unknown>;
|
|
44
|
+
/**
|
|
45
|
+
* Create or repair a symlink from the clean path to the npm node_modules path.
|
|
46
|
+
*/
|
|
47
|
+
export declare function ensureSymlink(paths: NpmContextPaths, ref: PackageRef): Promise<string>;
|
|
48
|
+
/**
|
|
49
|
+
* Create symlinks for all packages in a lock file.
|
|
50
|
+
*/
|
|
51
|
+
export declare function ensureAllSymlinks(paths: NpmContextPaths, lockFile: LockFile): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Get the resolved package directory for an installed package.
|
|
54
|
+
* Returns null if the package is not installed or the symlink is broken.
|
|
55
|
+
*/
|
|
56
|
+
export declare function getPackageDir(repoPath: string, ref: PackageRef): Promise<string | null>;
|