@cleocode/core 2026.6.11 → 2026.6.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/conduit/local-transport.d.ts +12 -0
- package/dist/conduit/local-transport.d.ts.map +1 -1
- package/dist/conduit/local-transport.js +53 -23
- package/dist/conduit/local-transport.js.map +1 -1
- package/dist/crypto/credentials.d.ts +37 -0
- package/dist/crypto/credentials.d.ts.map +1 -1
- package/dist/crypto/credentials.js +110 -0
- package/dist/crypto/credentials.js.map +1 -1
- package/dist/dispatch/contracts/derive-output-contract.d.ts +86 -0
- package/dist/dispatch/contracts/derive-output-contract.d.ts.map +1 -0
- package/dist/dispatch/contracts/derive-output-contract.js +347 -0
- package/dist/dispatch/contracts/derive-output-contract.js.map +1 -0
- package/dist/dispatch/contracts/ensures-schema.d.ts +77 -0
- package/dist/dispatch/contracts/ensures-schema.d.ts.map +1 -0
- package/dist/dispatch/contracts/ensures-schema.js +91 -0
- package/dist/dispatch/contracts/ensures-schema.js.map +1 -0
- package/dist/dispatch/contracts/output-contracts.d.ts +27 -5
- package/dist/dispatch/contracts/output-contracts.d.ts.map +1 -1
- package/dist/dispatch/contracts/output-contracts.js +29 -6
- package/dist/dispatch/contracts/output-contracts.js.map +1 -1
- package/dist/docs/export-document.js +2309 -1262
- package/dist/docs/export-document.js.map +3 -3
- package/dist/go/driver.d.ts +132 -7
- package/dist/go/driver.d.ts.map +1 -1
- package/dist/go/driver.js +135 -10
- package/dist/go/driver.js.map +1 -1
- package/dist/go/index.d.ts +1 -1
- package/dist/go/index.d.ts.map +1 -1
- package/dist/go/index.js +1 -1
- package/dist/go/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +13 -10
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +11 -11
- package/dist/internal.js.map +1 -1
- package/dist/lifecycle/engine-ops.d.ts.map +1 -1
- package/dist/lifecycle/engine-ops.js +7 -4
- package/dist/lifecycle/engine-ops.js.map +1 -1
- package/dist/lifecycle/ivtr-loop.d.ts +108 -183
- package/dist/lifecycle/ivtr-loop.d.ts.map +1 -1
- package/dist/lifecycle/ivtr-loop.js +207 -522
- package/dist/lifecycle/ivtr-loop.js.map +1 -1
- package/dist/llm/auxiliary-fallback.js +1 -1
- package/dist/llm/auxiliary-fallback.js.map +1 -1
- package/dist/llm/cli-ops.d.ts +14 -1
- package/dist/llm/cli-ops.d.ts.map +1 -1
- package/dist/llm/cli-ops.js +41 -12
- package/dist/llm/cli-ops.js.map +1 -1
- package/dist/llm/concrete-session.d.ts.map +1 -1
- package/dist/llm/concrete-session.js +4 -0
- package/dist/llm/concrete-session.js.map +1 -1
- package/dist/llm/credentials.d.ts +35 -0
- package/dist/llm/credentials.d.ts.map +1 -1
- package/dist/llm/credentials.js +49 -0
- package/dist/llm/credentials.js.map +1 -1
- package/dist/llm/index.d.ts +4 -0
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +4 -0
- package/dist/llm/index.js.map +1 -1
- package/dist/llm/pi/gondolin-loader.d.ts +241 -0
- package/dist/llm/pi/gondolin-loader.d.ts.map +1 -0
- package/dist/llm/pi/gondolin-loader.js +195 -0
- package/dist/llm/pi/gondolin-loader.js.map +1 -0
- package/dist/llm/pi/index.d.ts +28 -0
- package/dist/llm/pi/index.d.ts.map +1 -0
- package/dist/llm/pi/index.js +27 -0
- package/dist/llm/pi/index.js.map +1 -0
- package/dist/llm/pi/pi-agent-adapter.d.ts +135 -0
- package/dist/llm/pi/pi-agent-adapter.d.ts.map +1 -0
- package/dist/llm/pi/pi-agent-adapter.js +329 -0
- package/dist/llm/pi/pi-agent-adapter.js.map +1 -0
- package/dist/llm/pi/pi-errors.d.ts +161 -0
- package/dist/llm/pi/pi-errors.d.ts.map +1 -0
- package/dist/llm/pi/pi-errors.js +296 -0
- package/dist/llm/pi/pi-errors.js.map +1 -0
- package/dist/llm/pi/pi-execution-env.d.ts +286 -0
- package/dist/llm/pi/pi-execution-env.d.ts.map +1 -0
- package/dist/llm/pi/pi-execution-env.js +406 -0
- package/dist/llm/pi/pi-execution-env.js.map +1 -0
- package/dist/llm/pi/pi-gondolin-env.d.ts +227 -0
- package/dist/llm/pi/pi-gondolin-env.d.ts.map +1 -0
- package/dist/llm/pi/pi-gondolin-env.js +541 -0
- package/dist/llm/pi/pi-gondolin-env.js.map +1 -0
- package/dist/llm/pi/pi-session-storage.d.ts +154 -0
- package/dist/llm/pi/pi-session-storage.d.ts.map +1 -0
- package/dist/llm/pi/pi-session-storage.js +314 -0
- package/dist/llm/pi/pi-session-storage.js.map +1 -0
- package/dist/llm/pi/pi-stream-fn.d.ts +124 -0
- package/dist/llm/pi/pi-stream-fn.d.ts.map +1 -0
- package/dist/llm/pi/pi-stream-fn.js +504 -0
- package/dist/llm/pi/pi-stream-fn.js.map +1 -0
- package/dist/llm/pi/pi-tool-bridge.d.ts +99 -0
- package/dist/llm/pi/pi-tool-bridge.d.ts.map +1 -0
- package/dist/llm/pi/pi-tool-bridge.js +117 -0
- package/dist/llm/pi/pi-tool-bridge.js.map +1 -0
- package/dist/llm/pi/pi-types.d.ts +56 -0
- package/dist/llm/pi/pi-types.d.ts.map +1 -0
- package/dist/llm/pi/pi-types.js +16 -0
- package/dist/llm/pi/pi-types.js.map +1 -0
- package/dist/llm/pi/resolve-execution-env.d.ts +194 -0
- package/dist/llm/pi/resolve-execution-env.d.ts.map +1 -0
- package/dist/llm/pi/resolve-execution-env.js +132 -0
- package/dist/llm/pi/resolve-execution-env.js.map +1 -0
- package/dist/llm/plugin-facade.js +2253 -1151
- package/dist/llm/plugin-facade.js.map +3 -3
- package/dist/llm/role-executor.d.ts.map +1 -1
- package/dist/llm/role-executor.js +8 -5
- package/dist/llm/role-executor.js.map +1 -1
- package/dist/llm/role-resolver.d.ts +46 -14
- package/dist/llm/role-resolver.d.ts.map +1 -1
- package/dist/llm/role-resolver.js +178 -20
- package/dist/llm/role-resolver.js.map +1 -1
- package/dist/llm/sealed-credential.d.ts +125 -0
- package/dist/llm/sealed-credential.d.ts.map +1 -0
- package/dist/llm/sealed-credential.js +133 -0
- package/dist/llm/sealed-credential.js.map +1 -0
- package/dist/llm/session-factory.d.ts.map +1 -1
- package/dist/llm/session-factory.js +6 -2
- package/dist/llm/session-factory.js.map +1 -1
- package/dist/llm/system-key.d.ts +67 -0
- package/dist/llm/system-key.d.ts.map +1 -0
- package/dist/llm/system-key.js +87 -0
- package/dist/llm/system-key.js.map +1 -0
- package/dist/llm/system-of-use-registry.d.ts +119 -0
- package/dist/llm/system-of-use-registry.d.ts.map +1 -0
- package/dist/llm/system-of-use-registry.js +200 -0
- package/dist/llm/system-of-use-registry.js.map +1 -0
- package/dist/llm/system-resolver.d.ts +32 -10
- package/dist/llm/system-resolver.d.ts.map +1 -1
- package/dist/llm/system-resolver.js +70 -18
- package/dist/llm/system-resolver.js.map +1 -1
- package/dist/memory/brain-writer-thread.d.ts.map +1 -1
- package/dist/memory/brain-writer-thread.js +116 -11
- package/dist/memory/brain-writer-thread.js.map +1 -1
- package/dist/memory/claude-mem-migration.d.ts.map +1 -1
- package/dist/memory/claude-mem-migration.js +21 -0
- package/dist/memory/claude-mem-migration.js.map +1 -1
- package/dist/memory/graph-memory-bridge.d.ts.map +1 -1
- package/dist/memory/graph-memory-bridge.js +32 -25
- package/dist/memory/graph-memory-bridge.js.map +1 -1
- package/dist/memory/llm-backend-resolver.js +23 -5
- package/dist/memory/llm-backend-resolver.js.map +1 -1
- package/dist/nexus/migrations/M-split-graph.d.ts.map +1 -1
- package/dist/nexus/migrations/M-split-graph.js +60 -53
- package/dist/nexus/migrations/M-split-graph.js.map +1 -1
- package/dist/orchestrate/pivot.d.ts.map +1 -1
- package/dist/orchestrate/pivot.js +20 -2
- package/dist/orchestrate/pivot.js.map +1 -1
- package/dist/release/engine-ops.js +2 -2
- package/dist/release/engine-ops.js.map +1 -1
- package/dist/release/plan.d.ts +4 -6
- package/dist/release/plan.d.ts.map +1 -1
- package/dist/release/plan.js +10 -23
- package/dist/release/plan.js.map +1 -1
- package/dist/release/reconcile.d.ts +0 -2
- package/dist/release/reconcile.d.ts.map +1 -1
- package/dist/release/reconcile.js +43 -50
- package/dist/release/reconcile.js.map +1 -1
- package/dist/release/release-manifest.d.ts.map +1 -1
- package/dist/release/release-manifest.js +4 -1
- package/dist/release/release-manifest.js.map +1 -1
- package/dist/release/verify-provenance.js +20 -20
- package/dist/release/verify-provenance.js.map +1 -1
- package/dist/routing/capability-matrix.d.ts.map +1 -1
- package/dist/routing/capability-matrix.js +0 -57
- package/dist/routing/capability-matrix.js.map +1 -1
- package/dist/selfimprove/budget.d.ts +206 -0
- package/dist/selfimprove/budget.d.ts.map +1 -0
- package/dist/selfimprove/budget.js +203 -0
- package/dist/selfimprove/budget.js.map +1 -0
- package/dist/selfimprove/dhq-adapter.d.ts +105 -0
- package/dist/selfimprove/dhq-adapter.d.ts.map +1 -0
- package/dist/selfimprove/dhq-adapter.js +95 -0
- package/dist/selfimprove/dhq-adapter.js.map +1 -0
- package/dist/selfimprove/draft-pr.d.ts +129 -0
- package/dist/selfimprove/draft-pr.d.ts.map +1 -0
- package/dist/selfimprove/draft-pr.js +158 -0
- package/dist/selfimprove/draft-pr.js.map +1 -0
- package/dist/selfimprove/envelope-diff.d.ts +162 -0
- package/dist/selfimprove/envelope-diff.d.ts.map +1 -0
- package/dist/selfimprove/envelope-diff.js +321 -0
- package/dist/selfimprove/envelope-diff.js.map +1 -0
- package/dist/selfimprove/replay.d.ts +121 -0
- package/dist/selfimprove/replay.d.ts.map +1 -0
- package/dist/selfimprove/replay.js +109 -0
- package/dist/selfimprove/replay.js.map +1 -0
- package/dist/selfimprove/run-loop.d.ts +148 -0
- package/dist/selfimprove/run-loop.d.ts.map +1 -0
- package/dist/selfimprove/run-loop.js +240 -0
- package/dist/selfimprove/run-loop.js.map +1 -0
- package/dist/selfimprove/scenario.d.ts +145 -0
- package/dist/selfimprove/scenario.d.ts.map +1 -0
- package/dist/selfimprove/scenario.js +243 -0
- package/dist/selfimprove/scenario.js.map +1 -0
- package/dist/sentient/daemon-entry.js +5 -0
- package/dist/sentient/daemon-entry.js.map +1 -1
- package/dist/sentient/daemon.d.ts.map +1 -1
- package/dist/sentient/daemon.js +19 -0
- package/dist/sentient/daemon.js.map +1 -1
- package/dist/sentient/hygiene-scan.d.ts.map +1 -1
- package/dist/sentient/hygiene-scan.js +14 -6
- package/dist/sentient/hygiene-scan.js.map +1 -1
- package/dist/sessions/briefing.d.ts.map +1 -1
- package/dist/sessions/briefing.js +13 -9
- package/dist/sessions/briefing.js.map +1 -1
- package/dist/sessions/connection-session-handle.d.ts +161 -0
- package/dist/sessions/connection-session-handle.d.ts.map +1 -0
- package/dist/sessions/connection-session-handle.js +168 -0
- package/dist/sessions/connection-session-handle.js.map +1 -0
- package/dist/sessions/handoff.d.ts.map +1 -1
- package/dist/sessions/handoff.js +9 -0
- package/dist/sessions/handoff.js.map +1 -1
- package/dist/sessions/index.d.ts +4 -1
- package/dist/sessions/index.d.ts.map +1 -1
- package/dist/sessions/index.js +31 -1
- package/dist/sessions/index.js.map +1 -1
- package/dist/sessions/session-id.d.ts +34 -0
- package/dist/sessions/session-id.d.ts.map +1 -1
- package/dist/sessions/session-id.js +37 -0
- package/dist/sessions/session-id.js.map +1 -1
- package/dist/sessions/session-manifest-mirror.d.ts +115 -0
- package/dist/sessions/session-manifest-mirror.d.ts.map +1 -0
- package/dist/sessions/session-manifest-mirror.js +250 -0
- package/dist/sessions/session-manifest-mirror.js.map +1 -0
- package/dist/sessions/session-switch.d.ts.map +1 -1
- package/dist/sessions/session-switch.js +5 -2
- package/dist/sessions/session-switch.js.map +1 -1
- package/dist/store/converters.d.ts.map +1 -1
- package/dist/store/converters.js +2 -0
- package/dist/store/converters.js.map +1 -1
- package/dist/store/db-helpers.d.ts.map +1 -1
- package/dist/store/db-helpers.js +2 -0
- package/dist/store/db-helpers.js.map +1 -1
- package/dist/store/dual-scope-db.d.ts.map +1 -1
- package/dist/store/dual-scope-db.js +87 -47
- package/dist/store/dual-scope-db.js.map +1 -1
- package/dist/store/pi-session-store.d.ts +151 -0
- package/dist/store/pi-session-store.d.ts.map +1 -0
- package/dist/store/pi-session-store.js +166 -0
- package/dist/store/pi-session-store.js.map +1 -0
- package/dist/store/safety-data-accessor.d.ts +1 -0
- package/dist/store/safety-data-accessor.d.ts.map +1 -1
- package/dist/store/safety-data-accessor.js +5 -0
- package/dist/store/safety-data-accessor.js.map +1 -1
- package/dist/store/schema/cleo-global/accounts.d.ts +357 -0
- package/dist/store/schema/cleo-global/accounts.d.ts.map +1 -0
- package/dist/store/schema/cleo-global/accounts.js +136 -0
- package/dist/store/schema/cleo-global/accounts.js.map +1 -0
- package/dist/store/schema/cleo-global/index.d.ts +2 -0
- package/dist/store/schema/cleo-global/index.d.ts.map +1 -1
- package/dist/store/schema/cleo-global/index.js +2 -0
- package/dist/store/schema/cleo-global/index.js.map +1 -1
- package/dist/store/schema/cleo-global/session-manifest.d.ts +217 -0
- package/dist/store/schema/cleo-global/session-manifest.d.ts.map +1 -0
- package/dist/store/schema/cleo-global/session-manifest.js +99 -0
- package/dist/store/schema/cleo-global/session-manifest.js.map +1 -0
- package/dist/store/schema/cleo-project/tasks-core.d.ts +16 -0
- package/dist/store/schema/cleo-project/tasks-core.d.ts.map +1 -1
- package/dist/store/schema/cleo-project/tasks-core.js +14 -0
- package/dist/store/schema/cleo-project/tasks-core.js.map +1 -1
- package/dist/store/schema/tasks.d.ts +16 -0
- package/dist/store/schema/tasks.d.ts.map +1 -1
- package/dist/store/schema/tasks.js +10 -0
- package/dist/store/schema/tasks.js.map +1 -1
- package/dist/store/selfimprove-dhq-schema.d.ts +284 -0
- package/dist/store/selfimprove-dhq-schema.d.ts.map +1 -0
- package/dist/store/selfimprove-dhq-schema.js +128 -0
- package/dist/store/selfimprove-dhq-schema.js.map +1 -0
- package/dist/store/selfimprove-dhq-store.d.ts +175 -0
- package/dist/store/selfimprove-dhq-store.d.ts.map +1 -0
- package/dist/store/selfimprove-dhq-store.js +182 -0
- package/dist/store/selfimprove-dhq-store.js.map +1 -0
- package/dist/store/session-store.d.ts +52 -13
- package/dist/store/session-store.d.ts.map +1 -1
- package/dist/store/session-store.js +71 -13
- package/dist/store/session-store.js.map +1 -1
- package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
- package/dist/store/sqlite-data-accessor.js +7 -0
- package/dist/store/sqlite-data-accessor.js.map +1 -1
- package/dist/store/tasks-schema.d.ts +4 -0
- package/dist/store/tasks-schema.d.ts.map +1 -1
- package/dist/store/tasks-schema.js +14 -0
- package/dist/store/tasks-schema.js.map +1 -1
- package/dist/store/umbrella-data-accessor.d.ts +1 -0
- package/dist/store/umbrella-data-accessor.d.ts.map +1 -1
- package/dist/store/umbrella-data-accessor.js +5 -0
- package/dist/store/umbrella-data-accessor.js.map +1 -1
- package/dist/store/validation-schemas.d.ts +94 -62
- package/dist/store/validation-schemas.d.ts.map +1 -1
- package/dist/store/writer-lease-schema.d.ts +392 -0
- package/dist/store/writer-lease-schema.d.ts.map +1 -0
- package/dist/store/writer-lease-schema.js +142 -0
- package/dist/store/writer-lease-schema.js.map +1 -0
- package/dist/store/writer-lease.d.ts +368 -0
- package/dist/store/writer-lease.d.ts.map +1 -0
- package/dist/store/writer-lease.js +1002 -0
- package/dist/store/writer-lease.js.map +1 -0
- package/dist/task-tools/describe-schema.d.ts +4 -2
- package/dist/task-tools/describe-schema.d.ts.map +1 -1
- package/dist/task-tools/describe-schema.js +9 -3
- package/dist/task-tools/describe-schema.js.map +1 -1
- package/dist/tasks/backfill-child-projections.d.ts.map +1 -1
- package/dist/tasks/backfill-child-projections.js +14 -9
- package/dist/tasks/backfill-child-projections.js.map +1 -1
- package/dist/tasks/complete.d.ts.map +1 -1
- package/dist/tasks/complete.js +7 -10
- package/dist/tasks/complete.js.map +1 -1
- package/dist/tasks/duplicate-detector.d.ts.map +1 -1
- package/dist/tasks/duplicate-detector.js +14 -7
- package/dist/tasks/duplicate-detector.js.map +1 -1
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +10 -4
- package/dist/telemetry/index.js.map +1 -1
- package/dist/tools/agent-registry.d.ts +250 -0
- package/dist/tools/agent-registry.d.ts.map +1 -0
- package/dist/tools/agent-registry.js +292 -0
- package/dist/tools/agent-registry.js.map +1 -0
- package/dist/tools/agent-tool-families.d.ts +107 -0
- package/dist/tools/agent-tool-families.d.ts.map +1 -0
- package/dist/tools/agent-tool-families.js +527 -0
- package/dist/tools/agent-tool-families.js.map +1 -0
- package/dist/tools/browser-driver.d.ts +183 -0
- package/dist/tools/browser-driver.d.ts.map +1 -0
- package/dist/tools/browser-driver.js +242 -0
- package/dist/tools/browser-driver.js.map +1 -0
- package/dist/tools/builtin-agent-tools.d.ts +36 -0
- package/dist/tools/builtin-agent-tools.d.ts.map +1 -0
- package/dist/tools/builtin-agent-tools.js +150 -0
- package/dist/tools/builtin-agent-tools.js.map +1 -0
- package/dist/tools/dispatch.d.ts +370 -0
- package/dist/tools/dispatch.d.ts.map +1 -0
- package/dist/tools/dispatch.js +505 -0
- package/dist/tools/dispatch.js.map +1 -0
- package/dist/tools/env-scrub.d.ts +93 -0
- package/dist/tools/env-scrub.d.ts.map +1 -0
- package/dist/tools/env-scrub.js +176 -0
- package/dist/tools/env-scrub.js.map +1 -0
- package/dist/tools/fs.d.ts +30 -0
- package/dist/tools/fs.d.ts.map +1 -1
- package/dist/tools/fs.js +55 -2
- package/dist/tools/fs.js.map +1 -1
- package/dist/tools/guard.d.ts +15 -0
- package/dist/tools/guard.d.ts.map +1 -1
- package/dist/tools/guard.js +49 -12
- package/dist/tools/guard.js.map +1 -1
- package/dist/tools/index.d.ts +10 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +37 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/pty.d.ts +45 -0
- package/dist/tools/pty.d.ts.map +1 -0
- package/dist/tools/pty.js +166 -0
- package/dist/tools/pty.js.map +1 -0
- package/dist/tools/schema-gen.d.ts +57 -0
- package/dist/tools/schema-gen.d.ts.map +1 -0
- package/dist/tools/schema-gen.js +52 -0
- package/dist/tools/schema-gen.js.map +1 -0
- package/dist/tools/shell.d.ts +12 -0
- package/dist/tools/shell.d.ts.map +1 -1
- package/dist/tools/shell.js +14 -1
- package/dist/tools/shell.js.map +1 -1
- package/dist/tools/web-agent-tools.d.ts +72 -0
- package/dist/tools/web-agent-tools.d.ts.map +1 -0
- package/dist/tools/web-agent-tools.js +393 -0
- package/dist/tools/web-agent-tools.js.map +1 -0
- package/dist/tools/web-search-backends.d.ts +156 -0
- package/dist/tools/web-search-backends.d.ts.map +1 -0
- package/dist/tools/web-search-backends.js +290 -0
- package/dist/tools/web-search-backends.js.map +1 -0
- package/dist/validation/ops.d.ts +1 -15
- package/dist/validation/ops.d.ts.map +1 -1
- package/dist/validation/ops.js +0 -20
- package/dist/validation/ops.js.map +1 -1
- package/migrations/drizzle-cleo-global/20260607000000_t11891-writer-leases/migration.sql +55 -0
- package/migrations/drizzle-cleo-global/20260607010000_t11639-session-manifest/migration.sql +43 -0
- package/migrations/drizzle-cleo-global/20260608000000_t11899-pi-session-tree/migration.sql +52 -0
- package/migrations/drizzle-cleo-global/20260608010000_t11709-accounts-credential-pool/migration.sql +72 -0
- package/migrations/drizzle-cleo-global/20260608020000_t11889-selfimprove-dhq/migration.sql +64 -0
- package/migrations/drizzle-cleo-project/20260606000000_t11884-restore-prefixed-task-triggers/migration.sql +272 -0
- package/migrations/drizzle-cleo-project/20260606000000_t11884-restore-prefixed-task-triggers/revert.sql +29 -0
- package/migrations/drizzle-cleo-project/20260606000100_t11883-tasks-releases-version-unique/migration.sql +21 -0
- package/migrations/drizzle-cleo-project/20260606000100_t11883-tasks-releases-version-unique/revert.sql +4 -0
- package/migrations/drizzle-cleo-project/20260607000000_t11891-writer-leases/migration.sql +55 -0
- package/migrations/drizzle-cleo-project/20260607010000_t11639-session-parent/migration.sql +22 -0
- package/migrations/drizzle-cleo-project/20260608000000_t11899-pi-session-tree/migration.sql +52 -0
- package/migrations/drizzle-cleo-project/20260608020000_t11889-selfimprove-dhq/migration.sql +64 -0
- package/package.json +15 -13
- package/dist/lifecycle/chain-composition.d.ts +0 -30
- package/dist/lifecycle/chain-composition.d.ts.map +0 -1
- package/dist/lifecycle/chain-composition.js +0 -152
- package/dist/lifecycle/chain-composition.js.map +0 -1
- package/dist/lifecycle/chain-store.d.ts +0 -70
- package/dist/lifecycle/chain-store.d.ts.map +0 -1
- package/dist/lifecycle/chain-store.js +0 -246
- package/dist/lifecycle/chain-store.js.map +0 -1
- package/dist/lifecycle/default-chain.d.ts +0 -39
- package/dist/lifecycle/default-chain.d.ts.map +0 -1
- package/dist/lifecycle/default-chain.js +0 -176
- package/dist/lifecycle/default-chain.js.map +0 -1
- package/dist/lifecycle/tessera-engine.d.ts +0 -48
- package/dist/lifecycle/tessera-engine.d.ts.map +0 -1
- package/dist/lifecycle/tessera-engine.js +0 -249
- package/dist/lifecycle/tessera-engine.js.map +0 -1
- package/dist/release/provenance-fk.d.ts +0 -74
- package/dist/release/provenance-fk.d.ts.map +0 -1
- package/dist/release/provenance-fk.js +0 -122
- package/dist/release/provenance-fk.js.map +0 -1
- package/dist/validation/chain-validation.d.ts +0 -43
- package/dist/validation/chain-validation.d.ts.map +0 -1
- package/dist/validation/chain-validation.js +0 -146
- package/dist/validation/chain-validation.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role-executor.d.ts","sourceRoot":"","sources":["../../src/llm/role-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EACV,eAAe,EAEhB,MAAM,gDAAgD,CAAC;AAQxD,OAAO,KAAK,EAAE,cAAc,EA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,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,KAAK,EAAE,eAAe,CAAC;IACvB,uDAAuD;IACvD,QAAQ,EAAE,cAAc,CAAC;IACzB,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;CACf;AAKD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,QAAQ,EACd,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,EACnB,IAAI,GAAE,qBAA0B,GAC/B,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAmHtC"}
|
|
@@ -91,7 +91,7 @@ const DEFAULT_MAX_TOKENS = 1024;
|
|
|
91
91
|
*/
|
|
92
92
|
export async function executeForRole(role, systemPrompt, userContent, opts = {}) {
|
|
93
93
|
const llm = await resolveLLMForRole(role, { projectRoot: opts.projectRoot });
|
|
94
|
-
if (!llm.credential
|
|
94
|
+
if (!llm.sealedCredential || !llm.credential) {
|
|
95
95
|
// No usable credential for this role's resolved provider. Surface ONE
|
|
96
96
|
// actionable re-auth hint per (role, provider) tuple instead of a silent
|
|
97
97
|
// skip — the caller still degrades gracefully via the null return.
|
|
@@ -121,12 +121,15 @@ export async function executeForRole(role, systemPrompt, userContent, opts = {})
|
|
|
121
121
|
// transport blocks that had each drifted from `session-factory` (the
|
|
122
122
|
// anthropic block hardcoded the OAuth beta header; the others omitted it).
|
|
123
123
|
const authType = llm.credential.authType === 'oauth' ? 'oauth' : 'api_key';
|
|
124
|
+
// E10 (T11753): materialize the plaintext from the sealed handle ONLY here,
|
|
125
|
+
// at the wire — immediately before building the transport. The token is used
|
|
126
|
+
// for the kimi-code diagnostic and the transport credential, then goes out
|
|
127
|
+
// of scope; it is never returned, logged, or serialized.
|
|
128
|
+
const token = (await llm.sealedCredential.fetch()).value;
|
|
124
129
|
// Diagnostic (preserved): a non-`sk-kimi-`, non-OAuth key routed to
|
|
125
130
|
// kimi-code will likely fail — the legacy Moonshot `mk-*` path lives on the
|
|
126
131
|
// separate `moonshot` provider.
|
|
127
|
-
if (llm.provider === 'kimi-code' &&
|
|
128
|
-
authType !== 'oauth' &&
|
|
129
|
-
!isKimiCodeApiKey(llm.credential.apiKey)) {
|
|
132
|
+
if (llm.provider === 'kimi-code' && authType !== 'oauth' && !isKimiCodeApiKey(token)) {
|
|
130
133
|
console.warn(`[role-executor] kimi-code credential is not sk-kimi- prefixed and not OAuth; ` +
|
|
131
134
|
`the request may fail. Configure a coding-plan key from kimi.com/code or ` +
|
|
132
135
|
`switch the provider to 'moonshot' for legacy mk- keys.`);
|
|
@@ -135,7 +138,7 @@ export async function executeForRole(role, systemPrompt, userContent, opts = {})
|
|
|
135
138
|
const resolvedCredential = {
|
|
136
139
|
provider: llm.provider,
|
|
137
140
|
label: llm.credentialLabel ?? 'default',
|
|
138
|
-
token
|
|
141
|
+
token,
|
|
139
142
|
authType,
|
|
140
143
|
expiresAt: null,
|
|
141
144
|
refreshToken: null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role-executor.js","sourceRoot":"","sources":["../../src/llm/role-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAQH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,WAAW,EAA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YACxD,sEAAsE;YACtE,qEAAqE;YACrE,KAAK,IAAI,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC;iBAClC,aAAa,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,CAAC,UAAU,IAAI,GAAG,CAAC;iBAChE,KAAK,CAAC,GAAG,EAAE;gBACV,uDAAuD;YACzD,CAAC,CAAC,CAAC;YACL,eAAe,CACb,QAAQ,EACR,wBAAwB,IAAI,aAAa,GAAG,CAAC,QAAQ,UAAU,KAAK,GAAG;gBACrE,eAAe,eAAe,eAAe,UAAU,CAAC,UAAU,IAAI,GAAG,UAAU;gBACnF,wEAAwE;gBACxE,wBAAwB,IAAI,2CAA2C,CAC1E,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,oEAAoE;YACpE,oEAAoE;YACpE,eAAe,CACb,QAAQ,EACR,wBAAwB,IAAI,aAAa,GAAG,CAAC,QAAQ,UAAU,KAAK,iBAAiB,OAAO,EAAE,CAC/F,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -26,9 +26,8 @@
|
|
|
26
26
|
* @module llm/role-resolver
|
|
27
27
|
*/
|
|
28
28
|
import type { Anthropic } from '@anthropic-ai/sdk';
|
|
29
|
-
import type { ApiMode, ModelCaps, ResolutionSource, ResolveLLMForRoleOptions, RoleName } from '@cleocode/contracts';
|
|
29
|
+
import type { ApiMode, CredentialMetadataWire, ModelCaps, ResolutionSource, ResolveLLMForRoleOptions, RoleName, SealedCredential } from '@cleocode/contracts';
|
|
30
30
|
import type { OpenAI } from 'openai';
|
|
31
|
-
import { type CredentialResult } from './credentials.js';
|
|
32
31
|
import { IMPLICIT_FALLBACK_MODEL } from './fallback-model.js';
|
|
33
32
|
import type { ModelTransport } from './types-config.js';
|
|
34
33
|
/**
|
|
@@ -89,14 +88,24 @@ export type { ResolutionSource, ResolveLLMForRoleOptions };
|
|
|
89
88
|
*
|
|
90
89
|
* The contracts-level `ResolvedLLM` (from `@cleocode/contracts`) carries
|
|
91
90
|
* `client: unknown` to stay SDK-free. This core variant tightens the same
|
|
92
|
-
* envelope with the concrete SDK union (`LLMClient`)
|
|
93
|
-
*
|
|
91
|
+
* envelope with the concrete SDK union (`LLMClient`) — same shape, narrower
|
|
92
|
+
* `client` type.
|
|
94
93
|
*
|
|
95
|
-
* `client` is `null` only when
|
|
94
|
+
* `client` is `null` only when {@link sealedCredential} is also null — in which
|
|
96
95
|
* case the caller MUST fall back to its graceful-degradation path
|
|
97
96
|
* (return null / skip / log warn).
|
|
98
97
|
*
|
|
98
|
+
* ## E10 — no inline plaintext (T11753)
|
|
99
|
+
*
|
|
100
|
+
* The secret-bearing `credential.apiKey` field is **gone**. `credential` is now
|
|
101
|
+
* non-secret {@link CredentialMetadataWire} metadata (provider / source /
|
|
102
|
+
* authType) so callers can still branch on auth scheme and surface diagnostics.
|
|
103
|
+
* The plaintext token is reachable ONLY via {@link sealedCredential}'s `fetch()`
|
|
104
|
+
* at the wire (`transportForProvider` / `session-factory.ts`) or daemon
|
|
105
|
+
* worker-injection — it never crosses this envelope.
|
|
106
|
+
*
|
|
99
107
|
* @task T9255
|
|
108
|
+
* @task T11753
|
|
100
109
|
*/
|
|
101
110
|
export interface ResolvedLLM {
|
|
102
111
|
/** LLM provider transport that was resolved. */
|
|
@@ -110,10 +119,24 @@ export interface ResolvedLLM {
|
|
|
110
119
|
*/
|
|
111
120
|
client: LLMClient | null;
|
|
112
121
|
/**
|
|
113
|
-
* Resolved credential
|
|
114
|
-
*
|
|
122
|
+
* Resolved credential **metadata** (provider / source / authType) — NO
|
|
123
|
+
* plaintext. `null` when none of the 6 credential tiers produced a token
|
|
124
|
+
* (paired with `sealedCredential === null`). Callers MUST handle this case
|
|
125
|
+
* and obtain the secret via {@link sealedCredential}.
|
|
126
|
+
*
|
|
127
|
+
* @task T11753
|
|
128
|
+
*/
|
|
129
|
+
credential: CredentialMetadataWire | null;
|
|
130
|
+
/**
|
|
131
|
+
* Sealed credential handle — the canonical, on-demand credential surface
|
|
132
|
+
* (E10 · T11752 · T11753). `null` exactly when `credential` is `null`.
|
|
133
|
+
*
|
|
134
|
+
* The plaintext is materialized ONLY by `sealedCredential.fetch()` at the
|
|
135
|
+
* wire / daemon worker-injection — never returned up this envelope.
|
|
136
|
+
*
|
|
137
|
+
* @task T11753
|
|
115
138
|
*/
|
|
116
|
-
|
|
139
|
+
sealedCredential: SealedCredential | null;
|
|
117
140
|
/** Which config path produced this resolution. */
|
|
118
141
|
source: ResolutionSource;
|
|
119
142
|
/** When `roles[role].credentialLabel` was set, the label that was used. */
|
|
@@ -151,18 +174,27 @@ export interface ResolvedLLM {
|
|
|
151
174
|
*
|
|
152
175
|
* See module docs for the full resolution algorithm. Never throws — when
|
|
153
176
|
* no credential is reachable the caller receives
|
|
154
|
-
* `{ credential: null, client: null, ... }` and is
|
|
155
|
-
* graceful-degradation path (the previous Phase 1
|
|
156
|
-
* shortcut at the call-site).
|
|
177
|
+
* `{ credential: null, sealedCredential: null, client: null, ... }` and is
|
|
178
|
+
* responsible for its own graceful-degradation path (the previous Phase 1
|
|
179
|
+
* pattern was a `return null` shortcut at the call-site).
|
|
180
|
+
*
|
|
181
|
+
* E10 (T11753): the plaintext token never rides on the returned envelope.
|
|
182
|
+
* Materialize it ONLY at the wire by calling `llm.sealedCredential.fetch()`.
|
|
157
183
|
*
|
|
158
184
|
* @example
|
|
159
185
|
* ```ts
|
|
160
186
|
* const llm = await resolveLLMForRole('consolidation', { projectRoot });
|
|
161
|
-
* if (!llm.
|
|
187
|
+
* if (!llm.sealedCredential || !llm.client) {
|
|
162
188
|
* return null; // graceful no-op
|
|
163
189
|
* }
|
|
190
|
+
* // At the wire — the ONLY place the plaintext is materialized:
|
|
191
|
+
* const token = (await llm.sealedCredential.fetch()).value;
|
|
164
192
|
* const response = await fetch('https://api.anthropic.com/v1/messages', {
|
|
165
|
-
* headers: {
|
|
193
|
+
* headers: {
|
|
194
|
+
* 'Content-Type': 'application/json',
|
|
195
|
+
* ...authHeaders({ provider: llm.provider, apiKey: token,
|
|
196
|
+
* source: llm.credential?.source, authType: llm.credential?.authType ?? 'api_key' }),
|
|
197
|
+
* },
|
|
166
198
|
* body: JSON.stringify({ model: llm.model, ...rest }),
|
|
167
199
|
* });
|
|
168
200
|
* ```
|
|
@@ -172,6 +204,7 @@ export interface ResolvedLLM {
|
|
|
172
204
|
* @returns A {@link ResolvedLLM} envelope; never throws.
|
|
173
205
|
*
|
|
174
206
|
* @task T9255
|
|
207
|
+
* @task T11753
|
|
175
208
|
*/
|
|
176
209
|
export declare function resolveLLMForRole(role: RoleName, opts?: ResolveLLMForRoleOptions): Promise<ResolvedLLM>;
|
|
177
210
|
/**
|
|
@@ -208,6 +241,5 @@ export declare function resolveLLMForRole(role: RoleName, opts?: ResolveLLMForRo
|
|
|
208
241
|
export declare function resolveAnthropicForRole(role: RoleName, opts?: ResolveLLMForRoleOptions): Promise<{
|
|
209
242
|
client: Pick<Anthropic, 'messages'>;
|
|
210
243
|
model: string;
|
|
211
|
-
credential: CredentialResult;
|
|
212
244
|
} | null>;
|
|
213
245
|
//# sourceMappingURL=role-resolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role-resolver.d.ts","sourceRoot":"","sources":["../../src/llm/role-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EACV,OAAO,
|
|
1
|
+
{"version":3,"file":"role-resolver.d.ts","sourceRoot":"","sources":["../../src/llm/role-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EACV,OAAO,EAEP,sBAAsB,EAKtB,SAAS,EACT,gBAAgB,EAChB,wBAAwB,EACxB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IACH,YAAY,CAAC,EAAE,SAAS,CAAC;CAC1B;AAgTD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,QAAQ,EACd,IAAI,CAAC,EAAE,wBAAwB,GAC9B,OAAO,CAAC,WAAW,CAAC,CA2GtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,QAAQ,EACd,IAAI,CAAC,EAAE,wBAAwB,GAC9B,OAAO,CAAC;IACT,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,IAAI,CAAC,CAwBR"}
|
|
@@ -31,6 +31,8 @@ import { CredentialPool } from './credential-pool.js';
|
|
|
31
31
|
import { resolveCredentials } from './credentials.js';
|
|
32
32
|
import { getCredentialByLabel, pickCredentialForProvider } from './credentials-store.js';
|
|
33
33
|
import { IMPLICIT_FALLBACK_MODEL } from './fallback-model.js';
|
|
34
|
+
import { makeSealedCredential, tokenPreview } from './sealed-credential.js';
|
|
35
|
+
import { getRegisteredSystemDefault } from './system-of-use-registry.js';
|
|
34
36
|
import { buildAnthropicClient } from './transports/anthropic-client-factory.js';
|
|
35
37
|
/**
|
|
36
38
|
* Implicit fallback model used when no role-specific and no `default` entry is
|
|
@@ -98,6 +100,90 @@ function resolveNamedProfile(llm, name, source) {
|
|
|
98
100
|
source,
|
|
99
101
|
};
|
|
100
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Resolve a `llm.systems[systemKey]` {@link SystemBinding} into a
|
|
105
|
+
* {@link SelectedProviderModel}, or `undefined` when `systemKey` is unset, the
|
|
106
|
+
* key is absent, or the entry is structurally incomplete (neither a resolvable
|
|
107
|
+
* `profile` nor a complete inline `provider`+`model` tuple).
|
|
108
|
+
*
|
|
109
|
+
* A binding referencing a named profile wins over its inline tuple — mirroring
|
|
110
|
+
* {@link LlmRoleConfig.profile} precedence. The resolved profile keeps
|
|
111
|
+
* `source: 'system'` (not `'profile'`) so diagnostics attribute the resolution
|
|
112
|
+
* to the per-system override tier, while the profile's `credentialLabel` is
|
|
113
|
+
* preserved unless the binding pins its own.
|
|
114
|
+
*
|
|
115
|
+
* @param llm - The LLM config block (may be undefined).
|
|
116
|
+
* @param systemKey - Encoded system-of-use key (may be undefined).
|
|
117
|
+
* @task T11748
|
|
118
|
+
*/
|
|
119
|
+
function resolveSystemBinding(llm, systemKey) {
|
|
120
|
+
if (!systemKey)
|
|
121
|
+
return undefined;
|
|
122
|
+
const binding = llm?.systems?.[systemKey];
|
|
123
|
+
if (!binding)
|
|
124
|
+
return undefined;
|
|
125
|
+
// 1. Binding pinned to a named profile (wins over the inline tuple).
|
|
126
|
+
const bindingProfile = resolveNamedProfile(llm, binding.profile, 'system');
|
|
127
|
+
if (bindingProfile) {
|
|
128
|
+
// The binding may override the profile's credential label.
|
|
129
|
+
return {
|
|
130
|
+
...bindingProfile,
|
|
131
|
+
credentialLabel: binding.credentialLabel ?? bindingProfile.credentialLabel,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
// 2. Inline provider/model tuple on the binding.
|
|
135
|
+
if (binding.provider && binding.model) {
|
|
136
|
+
return {
|
|
137
|
+
provider: binding.provider,
|
|
138
|
+
model: binding.model,
|
|
139
|
+
credentialLabel: binding.credentialLabel,
|
|
140
|
+
source: 'system',
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
// Structurally incomplete — fall through to the next tier.
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Resolve the runtime-registered default for `systemKey` (registerSystemOfUse —
|
|
148
|
+
* T11751) into a {@link SelectedProviderModel}, or `undefined` when no system is
|
|
149
|
+
* registered under that key (or its default is structurally incomplete).
|
|
150
|
+
*
|
|
151
|
+
* Consulted ONLY after every user-config tier in {@link selectProviderModel} is
|
|
152
|
+
* exhausted — so a `registerSystemOfUse` default can NEVER override user config
|
|
153
|
+
* (`systems[key]` / `default` / `defaultProfile`). A registered binding that
|
|
154
|
+
* names a `profile` resolves it against `llm.profiles` (the profile wins over an
|
|
155
|
+
* inline tuple); the resolution is stamped `source: 'registered-default'` for
|
|
156
|
+
* diagnostics.
|
|
157
|
+
*
|
|
158
|
+
* @param llm - The LLM config block (may be undefined).
|
|
159
|
+
* @param systemKey - Encoded system-of-use key (may be undefined).
|
|
160
|
+
* @task T11751
|
|
161
|
+
*/
|
|
162
|
+
function resolveRegisteredSystemDefault(llm, systemKey) {
|
|
163
|
+
const defaults = getRegisteredSystemDefault(systemKey);
|
|
164
|
+
if (!defaults)
|
|
165
|
+
return undefined;
|
|
166
|
+
// 1. Default pinned to a named profile (wins over the inline tuple).
|
|
167
|
+
const profile = resolveNamedProfile(llm, defaults.profile, 'registered-default');
|
|
168
|
+
if (profile) {
|
|
169
|
+
return {
|
|
170
|
+
...profile,
|
|
171
|
+
credentialLabel: defaults.credentialLabel ?? profile.credentialLabel,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
// 2. Inline provider/model tuple on the default.
|
|
175
|
+
if (defaults.provider && defaults.model) {
|
|
176
|
+
return {
|
|
177
|
+
provider: defaults.provider,
|
|
178
|
+
model: defaults.model,
|
|
179
|
+
credentialLabel: defaults.credentialLabel,
|
|
180
|
+
source: 'registered-default',
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
// Structurally incomplete (getRegisteredSystemDefault already filters these,
|
|
184
|
+
// but stay defensive) — fall through to implicit fallback.
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
101
187
|
/**
|
|
102
188
|
* Pick provider/model/credentialLabel from the highest-priority configured
|
|
103
189
|
* tier. Always returns a value because the implicit fallback is unconditional.
|
|
@@ -105,20 +191,35 @@ function resolveNamedProfile(llm, name, source) {
|
|
|
105
191
|
* Resolution order:
|
|
106
192
|
* 1. `roles[role].profile` → named profile (`source: 'profile'`)
|
|
107
193
|
* 2. `roles[role]` inline `{provider, model}` (`source: 'role'`)
|
|
108
|
-
* 3. `
|
|
109
|
-
*
|
|
110
|
-
*
|
|
194
|
+
* 3. `systems[systemKey]` → per-system override (`source: 'system'`) — only
|
|
195
|
+
* consulted when `systemKey` is set (threaded by `resolveLLMForSystem`).
|
|
196
|
+
* 4. `default` (`source: 'default'`)
|
|
197
|
+
* 5. `defaultProfile` → named profile (`source: 'default-profile'`)
|
|
198
|
+
* 6. `registerSystemOfUse` default (`source: 'registered-default'`) — runtime
|
|
199
|
+
* registration, consulted strictly BELOW all user config (T11751).
|
|
200
|
+
* 7. implicit fallback (`source: 'implicit-fallback'`)
|
|
201
|
+
*
|
|
202
|
+
* Tiers 1–2 are the *explicit-arg* lane (per-role config / role override);
|
|
203
|
+
* tier 3 is the hermes *granular override* — consulted after the explicit
|
|
204
|
+
* choice but before the global base (`default` / `defaultProfile`), matching
|
|
205
|
+
* the E9 priority `explicit-arg → llm.systems[key] → llm.defaultProfile →
|
|
206
|
+
* registered-default → implicit fallback` (T11748 · T11751). The configurable
|
|
207
|
+
* `defaultProfile` is what lets background roles resolve to a user-selectable
|
|
208
|
+
* provider WITHOUT hardcoding the provider in code.
|
|
111
209
|
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
210
|
+
* @param llm - The LLM config block (may be undefined).
|
|
211
|
+
* @param role - The role used for `roles[role]` lookup.
|
|
212
|
+
* @param systemKey - Optional encoded system-of-use key activating tiers 3 + 6.
|
|
213
|
+
* @task T11748 (`systems[systemKey]` tier)
|
|
214
|
+
* @task T11751 (`registered-default` tier)
|
|
114
215
|
*/
|
|
115
|
-
function selectProviderModel(llm, role) {
|
|
216
|
+
function selectProviderModel(llm, role, systemKey) {
|
|
116
217
|
const roleEntry = llm?.roles?.[role];
|
|
117
|
-
// 1. Role pinned to a named profile.
|
|
218
|
+
// 1. Role pinned to a named profile (explicit-arg lane).
|
|
118
219
|
const roleProfile = resolveNamedProfile(llm, roleEntry?.profile, 'profile');
|
|
119
220
|
if (roleProfile)
|
|
120
221
|
return roleProfile;
|
|
121
|
-
// 2. Role with an inline provider/model tuple (
|
|
222
|
+
// 2. Role with an inline provider/model tuple (explicit-arg lane).
|
|
122
223
|
if (roleEntry?.provider && roleEntry.model) {
|
|
123
224
|
return {
|
|
124
225
|
provider: roleEntry.provider,
|
|
@@ -127,7 +228,11 @@ function selectProviderModel(llm, role) {
|
|
|
127
228
|
source: 'role',
|
|
128
229
|
};
|
|
129
230
|
}
|
|
130
|
-
// 3.
|
|
231
|
+
// 3. Per-system override (hermes granular override) — beats the global base.
|
|
232
|
+
const systemBinding = resolveSystemBinding(llm, systemKey);
|
|
233
|
+
if (systemBinding)
|
|
234
|
+
return systemBinding;
|
|
235
|
+
// 4. Canonical default tuple.
|
|
131
236
|
const defaultEntry = llm?.default;
|
|
132
237
|
if (defaultEntry?.provider && defaultEntry.model) {
|
|
133
238
|
return {
|
|
@@ -137,11 +242,17 @@ function selectProviderModel(llm, role) {
|
|
|
137
242
|
source: 'default',
|
|
138
243
|
};
|
|
139
244
|
}
|
|
140
|
-
//
|
|
245
|
+
// 5. Configurable default profile binding (user-selectable; not hardcoded).
|
|
141
246
|
const defaultProfile = resolveNamedProfile(llm, llm?.defaultProfile, 'default-profile');
|
|
142
247
|
if (defaultProfile)
|
|
143
248
|
return defaultProfile;
|
|
144
|
-
//
|
|
249
|
+
// 6. Runtime-registered default (registerSystemOfUse — T11751) — consulted
|
|
250
|
+
// strictly BELOW every user-config tier above, so the user ALWAYS wins. A
|
|
251
|
+
// plugin/extension default only binds when the user configured nothing.
|
|
252
|
+
const registeredDefault = resolveRegisteredSystemDefault(llm, systemKey);
|
|
253
|
+
if (registeredDefault)
|
|
254
|
+
return registeredDefault;
|
|
255
|
+
// 7. Implicit fallback (last resort).
|
|
145
256
|
return {
|
|
146
257
|
provider: IMPLICIT_FALLBACK_PROVIDER,
|
|
147
258
|
model: IMPLICIT_FALLBACK_MODEL,
|
|
@@ -230,18 +341,27 @@ async function resolveCredentialForRole(provider, credentialLabel, projectRoot)
|
|
|
230
341
|
*
|
|
231
342
|
* See module docs for the full resolution algorithm. Never throws — when
|
|
232
343
|
* no credential is reachable the caller receives
|
|
233
|
-
* `{ credential: null, client: null, ... }` and is
|
|
234
|
-
* graceful-degradation path (the previous Phase 1
|
|
235
|
-
* shortcut at the call-site).
|
|
344
|
+
* `{ credential: null, sealedCredential: null, client: null, ... }` and is
|
|
345
|
+
* responsible for its own graceful-degradation path (the previous Phase 1
|
|
346
|
+
* pattern was a `return null` shortcut at the call-site).
|
|
347
|
+
*
|
|
348
|
+
* E10 (T11753): the plaintext token never rides on the returned envelope.
|
|
349
|
+
* Materialize it ONLY at the wire by calling `llm.sealedCredential.fetch()`.
|
|
236
350
|
*
|
|
237
351
|
* @example
|
|
238
352
|
* ```ts
|
|
239
353
|
* const llm = await resolveLLMForRole('consolidation', { projectRoot });
|
|
240
|
-
* if (!llm.
|
|
354
|
+
* if (!llm.sealedCredential || !llm.client) {
|
|
241
355
|
* return null; // graceful no-op
|
|
242
356
|
* }
|
|
357
|
+
* // At the wire — the ONLY place the plaintext is materialized:
|
|
358
|
+
* const token = (await llm.sealedCredential.fetch()).value;
|
|
243
359
|
* const response = await fetch('https://api.anthropic.com/v1/messages', {
|
|
244
|
-
* headers: {
|
|
360
|
+
* headers: {
|
|
361
|
+
* 'Content-Type': 'application/json',
|
|
362
|
+
* ...authHeaders({ provider: llm.provider, apiKey: token,
|
|
363
|
+
* source: llm.credential?.source, authType: llm.credential?.authType ?? 'api_key' }),
|
|
364
|
+
* },
|
|
245
365
|
* body: JSON.stringify({ model: llm.model, ...rest }),
|
|
246
366
|
* });
|
|
247
367
|
* ```
|
|
@@ -251,6 +371,7 @@ async function resolveCredentialForRole(provider, credentialLabel, projectRoot)
|
|
|
251
371
|
* @returns A {@link ResolvedLLM} envelope; never throws.
|
|
252
372
|
*
|
|
253
373
|
* @task T9255
|
|
374
|
+
* @task T11753
|
|
254
375
|
*/
|
|
255
376
|
export async function resolveLLMForRole(role, opts) {
|
|
256
377
|
const projectRoot = resolveOrCwd(opts?.projectRoot);
|
|
@@ -267,8 +388,11 @@ export async function resolveLLMForRole(role, opts) {
|
|
|
267
388
|
config = undefined;
|
|
268
389
|
}
|
|
269
390
|
// Step 2 — pick provider/model/credentialLabel from the highest-priority tier.
|
|
391
|
+
// `opts.systemKey` (threaded by `resolveLLMForSystem`) activates the
|
|
392
|
+
// `llm.systems[key]` granular-override tier; role callers leave it unset and
|
|
393
|
+
// that tier is skipped — role resolution is unchanged (T11748).
|
|
270
394
|
const llmBlock = readLlmBlock(config);
|
|
271
|
-
const { provider, model, credentialLabel, source } = selectProviderModel(llmBlock, role);
|
|
395
|
+
const { provider, model, credentialLabel, source } = selectProviderModel(llmBlock, role, opts?.systemKey);
|
|
272
396
|
// Step 3 — resolve credential.
|
|
273
397
|
const { credential, usedLabel } = await resolveCredentialForRole(provider, credentialLabel, projectRoot);
|
|
274
398
|
// Step 4 — construct SDK client if we have a credential.
|
|
@@ -303,11 +427,40 @@ export async function resolveLLMForRole(role, opts) {
|
|
|
303
427
|
// is surfaced from the resolved credential (or null when none).
|
|
304
428
|
const authType = credential?.authType ?? null;
|
|
305
429
|
const wire = deriveApiWire(provider, authType);
|
|
430
|
+
// Step 6 — E10 (T11753): seal the credential. The plaintext token is captured
|
|
431
|
+
// in the handle's `fetch()` closure but is NOT placed on the returned
|
|
432
|
+
// envelope. `credential` becomes non-secret metadata; consumers reach the
|
|
433
|
+
// secret ONLY via `sealedCredential.fetch()` at the wire. No-credential
|
|
434
|
+
// resolution yields `{ credential: null, sealedCredential: null }`.
|
|
435
|
+
let credentialMetadata = null;
|
|
436
|
+
let sealedCredential = null;
|
|
437
|
+
if (credential?.apiKey) {
|
|
438
|
+
const token = credential.apiKey;
|
|
439
|
+
const wireAuthType = credential.authType === 'oauth' ? 'oauth' : 'api_key';
|
|
440
|
+
credentialMetadata = {
|
|
441
|
+
provider: credential.provider,
|
|
442
|
+
source: credential.source,
|
|
443
|
+
authType: wireAuthType,
|
|
444
|
+
};
|
|
445
|
+
sealedCredential = makeSealedCredential({
|
|
446
|
+
provider: credential.provider,
|
|
447
|
+
account: usedLabel ?? 'default',
|
|
448
|
+
// Non-secret redacted preview (≤ last 4 chars) computed ONCE at seal time
|
|
449
|
+
// — the only token-derived string allowed on a log/envelope/diagnostic
|
|
450
|
+
// (E10 · T11754 · AC3). The full plaintext is NOT retained for it.
|
|
451
|
+
tokenPreview: tokenPreview(token, wireAuthType),
|
|
452
|
+
// The already-resolved plaintext is captured in this closure and handed
|
|
453
|
+
// out ONLY when a wire boundary invokes fetch(); it is never surfaced on
|
|
454
|
+
// the envelope. T11754 swaps this thunk for an on-demand vault decrypt.
|
|
455
|
+
resolveToken: () => token,
|
|
456
|
+
});
|
|
457
|
+
}
|
|
306
458
|
return {
|
|
307
459
|
provider,
|
|
308
460
|
model,
|
|
309
461
|
client,
|
|
310
|
-
credential,
|
|
462
|
+
credential: credentialMetadata,
|
|
463
|
+
sealedCredential,
|
|
311
464
|
source,
|
|
312
465
|
credentialLabel: usedLabel,
|
|
313
466
|
apiMode: wire.apiMode,
|
|
@@ -356,7 +509,13 @@ export async function resolveAnthropicForRole(role, opts) {
|
|
|
356
509
|
}
|
|
357
510
|
if (llm.provider !== 'anthropic')
|
|
358
511
|
return null;
|
|
359
|
-
|
|
512
|
+
// E10 (T11753): gate on the sealed handle's presence — its existence is the
|
|
513
|
+
// post-resolution "a usable credential was found" signal, replacing the
|
|
514
|
+
// removed inline `credential.apiKey` truthiness check. The Anthropic SDK
|
|
515
|
+
// `client` was already wired from the plaintext inside `resolveLLMForRole`
|
|
516
|
+
// (the one allowed `new Anthropic(...)` chokepoint), so the secret does not
|
|
517
|
+
// need to cross this boundary again.
|
|
518
|
+
if (!llm.sealedCredential || !llm.client)
|
|
360
519
|
return null;
|
|
361
520
|
// Safe narrowing: provider === 'anthropic' and direct Anthropic construction
|
|
362
521
|
// in resolveLLMForRole guarantees the client is an Anthropic SDK instance.
|
|
@@ -366,7 +525,6 @@ export async function resolveAnthropicForRole(role, opts) {
|
|
|
366
525
|
return {
|
|
367
526
|
client: llm.client,
|
|
368
527
|
model: llm.model,
|
|
369
|
-
credential: llm.credential,
|
|
370
528
|
};
|
|
371
529
|
}
|
|
372
530
|
//# sourceMappingURL=role-resolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role-resolver.js","sourceRoot":"","sources":["../../src/llm/role-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;
|
|
1
|
+
{"version":3,"file":"role-resolver.js","sourceRoot":"","sources":["../../src/llm/role-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAmBH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAyB,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAGhF;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,uBAAuB,EAAE,CAAC;AAEnC;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAmB,WAAW,CAAC;AAEtE;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AA+G1D;;;GAGG;AACH,S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,OAAO;QACL,MAAM,EAAE,GAAG,CAAC,MAAmB;QAC/B,KAAK,EAAE,GAAG,CAAC,KAAK;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sealed credential handle — runtime implementation (E10 · T11753).
|
|
3
|
+
*
|
|
4
|
+
* The {@link SealedCredential} **type** lives in `@cleocode/contracts`
|
|
5
|
+
* (`llm/sealed-credential.ts`, types-only for Gate 10 purity). Its `fetch()` is
|
|
6
|
+
* a function-TYPED interface field; the concrete body — the on-demand
|
|
7
|
+
* materialization of the plaintext token — lives HERE in `@cleocode/core`.
|
|
8
|
+
*
|
|
9
|
+
* ## Why this module exists
|
|
10
|
+
*
|
|
11
|
+
* Before E10, {@link import('./role-resolver.js').resolveLLMForRole} returned
|
|
12
|
+
* the resolved credential's plaintext `apiKey` **inline** on its envelope. That
|
|
13
|
+
* bare secret string travelled up the entire resolution call stack
|
|
14
|
+
* (`resolveLLMForRole` → `resolveLLMForSystem` → consumers) where any layer that
|
|
15
|
+
* merely *routed* it to the wire could accidentally log it, serialize it into a
|
|
16
|
+
* LAFS envelope, or copy it into a diagnostic.
|
|
17
|
+
*
|
|
18
|
+
* {@link makeSealedCredential} inverts that. The resolver builds an opaque
|
|
19
|
+
* {@link SealedCredential} handle whose `fetch()` closure captures a
|
|
20
|
+
* `resolveToken` thunk. The plaintext is materialized **only** when a wire
|
|
21
|
+
* boundary (`transportForProvider` / `session-factory.ts`) or daemon
|
|
22
|
+
* worker-injection invokes `fetch()`. Between the resolver and those boundaries,
|
|
23
|
+
* NO layer holds a plaintext secret — it holds a handle.
|
|
24
|
+
*
|
|
25
|
+
* ## The brand chokepoint
|
|
26
|
+
*
|
|
27
|
+
* {@link brandDecryptedToken} is the SOLE place a {@link DecryptedToken} is
|
|
28
|
+
* minted from a raw string. Because `DecryptedToken` is a phantom-branded type
|
|
29
|
+
* (contracts), a plain `string` cannot be widened into one anywhere else — so an
|
|
30
|
+
* audit of "who mints a token" reduces to "who calls `brandDecryptedToken`",
|
|
31
|
+
* and that is exclusively this module (invoked inside `fetch()`).
|
|
32
|
+
*
|
|
33
|
+
* @module llm/sealed-credential
|
|
34
|
+
* @task T11753
|
|
35
|
+
* @epic T11746
|
|
36
|
+
* @see ADR-072 §Type lock-in
|
|
37
|
+
*/
|
|
38
|
+
import type { ProviderId, SealedCredential } from '@cleocode/contracts';
|
|
39
|
+
/**
|
|
40
|
+
* Build the non-secret, redacted preview of a credential string.
|
|
41
|
+
*
|
|
42
|
+
* SECURITY: this is the SOLE token→preview redaction chokepoint for the sealed
|
|
43
|
+
* handle. It reveals at most the last 4 characters of the token plus an
|
|
44
|
+
* auth-scheme marker (`oat-…` for OAuth, `…` otherwise) — never enough to
|
|
45
|
+
* reconstruct the secret. It is computed ONCE at seal time and stored on the
|
|
46
|
+
* handle's {@link SealedCredential.tokenPreview}; the full plaintext is NOT
|
|
47
|
+
* retained for it.
|
|
48
|
+
*
|
|
49
|
+
* The preview is the ONLY credential-derived string that may cross a
|
|
50
|
+
* logging/diagnostic/envelope boundary (E10 · T11754 · AC3); everything else
|
|
51
|
+
* goes through {@link SealedCredential.fetch} at the wire and is discarded.
|
|
52
|
+
*
|
|
53
|
+
* @param token - The plaintext secret (read transiently; not retained).
|
|
54
|
+
* @param authType - Auth scheme, used only to pick the cosmetic prefix.
|
|
55
|
+
* @returns A redacted preview safe to log and serialize.
|
|
56
|
+
* @task T11754
|
|
57
|
+
*/
|
|
58
|
+
export declare function tokenPreview(token: string, authType: 'api_key' | 'oauth'): string;
|
|
59
|
+
/**
|
|
60
|
+
* Parameters for {@link makeSealedCredential}.
|
|
61
|
+
*
|
|
62
|
+
* @task T11753
|
|
63
|
+
*/
|
|
64
|
+
export interface MakeSealedCredentialParams {
|
|
65
|
+
/** Provider this handle targets (e.g. `'anthropic'`). */
|
|
66
|
+
readonly provider: ProviderId;
|
|
67
|
+
/**
|
|
68
|
+
* Account / store-label this handle resolves against (e.g. `'default'`,
|
|
69
|
+
* `'work'`). Names *which* credential without revealing its secret — safe to
|
|
70
|
+
* log and serialize.
|
|
71
|
+
*/
|
|
72
|
+
readonly account: string;
|
|
73
|
+
/**
|
|
74
|
+
* Non-secret redacted preview (e.g. `'…6789'` / `'oat-…6789'`) computed once
|
|
75
|
+
* by the resolver via {@link tokenPreview}. Carried on the handle so
|
|
76
|
+
* diagnostics can *name* the credential without invoking {@link SealedCredential.fetch}.
|
|
77
|
+
* NEVER the full token.
|
|
78
|
+
*
|
|
79
|
+
* @task T11754
|
|
80
|
+
*/
|
|
81
|
+
readonly tokenPreview: string;
|
|
82
|
+
/**
|
|
83
|
+
* On-demand plaintext resolver. Invoked ONLY inside {@link SealedCredential.fetch}
|
|
84
|
+
* — i.e. at the wire / daemon worker-injection boundary. May be synchronous
|
|
85
|
+
* (today's in-process credential pool, which already holds the plaintext) or
|
|
86
|
+
* asynchronous (a future vault / daemon round-trip per T11754). Returns the
|
|
87
|
+
* raw plaintext string; {@link makeSealedCredential} brands it.
|
|
88
|
+
*
|
|
89
|
+
* MUST throw if the credential is unreachable so the caller's existing
|
|
90
|
+
* graceful-degradation path fires identically to the pre-E10 `apiKey === null`
|
|
91
|
+
* check.
|
|
92
|
+
*/
|
|
93
|
+
readonly resolveToken: () => string | Promise<string>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Build a {@link SealedCredential} handle from a provider/account and an
|
|
97
|
+
* on-demand token resolver.
|
|
98
|
+
*
|
|
99
|
+
* The returned handle carries ONLY the non-secret `provider` + `account`
|
|
100
|
+
* inline. Its `fetch()` closure captures {@link MakeSealedCredentialParams.resolveToken}
|
|
101
|
+
* and brands the result — the plaintext exists transiently inside `fetch()` and
|
|
102
|
+
* is NEVER attached to the handle object, so the handle can be logged or
|
|
103
|
+
* serialized without leaking the secret.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* // In the resolver — capture the already-resolved token in the closure but do
|
|
108
|
+
* // NOT place it on the returned envelope:
|
|
109
|
+
* const sealed = makeSealedCredential({
|
|
110
|
+
* provider: 'anthropic',
|
|
111
|
+
* account: usedLabel ?? 'default',
|
|
112
|
+
* tokenPreview: tokenPreview(token, authType), // non-secret; safe to log
|
|
113
|
+
* resolveToken: () => token, // captured, not surfaced
|
|
114
|
+
* });
|
|
115
|
+
* // At the wire — the ONLY place fetch() runs (via authHeadersFromSealed):
|
|
116
|
+
* const headers = await authHeadersFromSealed(sealed, authType);
|
|
117
|
+
* // the plaintext never escapes authHeadersFromSealed; only headers come out.
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* @param params - Provider, account label, and the on-demand token resolver.
|
|
121
|
+
* @returns An opaque sealed-credential handle.
|
|
122
|
+
* @task T11753
|
|
123
|
+
*/
|
|
124
|
+
export declare function makeSealedCredential(params: MakeSealedCredentialParams): SealedCredential;
|
|
125
|
+
//# sourceMappingURL=sealed-credential.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sealed-credential.d.ts","sourceRoot":"","sources":["../../src/llm/sealed-credential.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAkB,UAAU,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAExF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,CAKjF;AA0BD;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IACzC,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;;;;;OAOG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACvD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,0BAA0B,GAAG,gBAAgB,CAezF"}
|