@cleocode/core 2026.6.13 → 2026.6.14
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/admin/ops.d.ts +4 -0
- package/dist/admin/ops.d.ts.map +1 -1
- package/dist/check/index.d.ts +12 -0
- package/dist/check/index.d.ts.map +1 -0
- package/dist/check/index.js +12 -0
- package/dist/check/index.js.map +1 -0
- package/dist/check/pr-gate.d.ts +179 -0
- package/dist/check/pr-gate.d.ts.map +1 -0
- package/dist/check/pr-gate.js +366 -0
- package/dist/check/pr-gate.js.map +1 -0
- package/dist/conduit/delivery-router.d.ts +134 -0
- package/dist/conduit/delivery-router.d.ts.map +1 -0
- package/dist/conduit/delivery-router.js +0 -0
- package/dist/conduit/delivery-router.js.map +1 -0
- package/dist/conduit/index.d.ts +5 -2
- package/dist/conduit/index.d.ts.map +1 -1
- package/dist/conduit/index.js +5 -2
- package/dist/conduit/index.js.map +1 -1
- package/dist/conduit/local-tui-adapter.d.ts +89 -0
- package/dist/conduit/local-tui-adapter.d.ts.map +1 -0
- package/dist/conduit/local-tui-adapter.js +225 -0
- package/dist/conduit/local-tui-adapter.js.map +1 -0
- package/dist/config/registry.d.ts +54 -0
- package/dist/config/registry.d.ts.map +1 -1
- package/dist/config/registry.js +94 -2
- package/dist/config/registry.js.map +1 -1
- package/dist/deriver/queue-manager.d.ts +30 -2
- package/dist/deriver/queue-manager.d.ts.map +1 -1
- package/dist/deriver/queue-manager.js +54 -9
- package/dist/deriver/queue-manager.js.map +1 -1
- package/dist/dispatch/config-domain-handler.d.ts +125 -0
- package/dist/dispatch/config-domain-handler.d.ts.map +1 -0
- package/dist/dispatch/config-domain-handler.js +160 -0
- package/dist/dispatch/config-domain-handler.js.map +1 -0
- package/dist/dispatch/contracts/input-contracts.d.ts.map +1 -1
- package/dist/dispatch/contracts/input-contracts.js +19 -1
- package/dist/dispatch/contracts/input-contracts.js.map +1 -1
- package/dist/docs/export-document.js +3704 -680
- package/dist/docs/export-document.js.map +3 -3
- package/dist/gateway-client/client.d.ts +123 -0
- package/dist/gateway-client/client.d.ts.map +1 -0
- package/dist/gateway-client/client.js +93 -0
- package/dist/gateway-client/client.js.map +1 -0
- package/dist/gateway-client/generated/client/client.gen.d.ts +3 -0
- package/dist/gateway-client/generated/client/client.gen.d.ts.map +1 -0
- package/dist/gateway-client/generated/client/client.gen.js +217 -0
- package/dist/gateway-client/generated/client/client.gen.js.map +1 -0
- package/dist/gateway-client/generated/client/index.d.ts +11 -0
- package/dist/gateway-client/generated/client/index.d.ts.map +1 -0
- package/dist/gateway-client/generated/client/index.js +7 -0
- package/dist/gateway-client/generated/client/index.js.map +1 -0
- package/dist/gateway-client/generated/client/types.gen.d.ts +121 -0
- package/dist/gateway-client/generated/client/types.gen.d.ts.map +1 -0
- package/dist/gateway-client/generated/client/types.gen.js +3 -0
- package/dist/gateway-client/generated/client/types.gen.js.map +1 -0
- package/dist/gateway-client/generated/client/utils.gen.d.ts +38 -0
- package/dist/gateway-client/generated/client/utils.gen.d.ts.map +1 -0
- package/dist/gateway-client/generated/client/utils.gen.js +229 -0
- package/dist/gateway-client/generated/client/utils.gen.js.map +1 -0
- package/dist/gateway-client/generated/client.gen.d.ts +13 -0
- package/dist/gateway-client/generated/client.gen.d.ts.map +1 -0
- package/dist/gateway-client/generated/client.gen.js +4 -0
- package/dist/gateway-client/generated/client.gen.js.map +1 -0
- package/dist/gateway-client/generated/core/auth.gen.d.ts +26 -0
- package/dist/gateway-client/generated/core/auth.gen.d.ts.map +1 -0
- package/dist/gateway-client/generated/core/auth.gen.js +15 -0
- package/dist/gateway-client/generated/core/auth.gen.js.map +1 -0
- package/dist/gateway-client/generated/core/bodySerializer.gen.d.ts +26 -0
- package/dist/gateway-client/generated/core/bodySerializer.gen.d.ts.map +1 -0
- package/dist/gateway-client/generated/core/bodySerializer.gen.js +58 -0
- package/dist/gateway-client/generated/core/bodySerializer.gen.js.map +1 -0
- package/dist/gateway-client/generated/core/params.gen.d.ts +44 -0
- package/dist/gateway-client/generated/core/params.gen.d.ts.map +1 -0
- package/dist/gateway-client/generated/core/params.gen.js +101 -0
- package/dist/gateway-client/generated/core/params.gen.js.map +1 -0
- package/dist/gateway-client/generated/core/pathSerializer.gen.d.ts +34 -0
- package/dist/gateway-client/generated/core/pathSerializer.gen.d.ts.map +1 -0
- package/dist/gateway-client/generated/core/pathSerializer.gen.js +107 -0
- package/dist/gateway-client/generated/core/pathSerializer.gen.js.map +1 -0
- package/dist/gateway-client/generated/core/queryKeySerializer.gen.d.ts +19 -0
- package/dist/gateway-client/generated/core/queryKeySerializer.gen.d.ts.map +1 -0
- package/dist/gateway-client/generated/core/queryKeySerializer.gen.js +93 -0
- package/dist/gateway-client/generated/core/queryKeySerializer.gen.js.map +1 -0
- package/dist/gateway-client/generated/core/serverSentEvents.gen.d.ts +72 -0
- package/dist/gateway-client/generated/core/serverSentEvents.gen.d.ts.map +1 -0
- package/dist/gateway-client/generated/core/serverSentEvents.gen.js +133 -0
- package/dist/gateway-client/generated/core/serverSentEvents.gen.js.map +1 -0
- package/dist/gateway-client/generated/core/types.gen.d.ts +84 -0
- package/dist/gateway-client/generated/core/types.gen.d.ts.map +1 -0
- package/dist/gateway-client/generated/core/types.gen.js +3 -0
- package/dist/gateway-client/generated/core/types.gen.js.map +1 -0
- package/dist/gateway-client/generated/core/utils.gen.d.ts +20 -0
- package/dist/gateway-client/generated/core/utils.gen.d.ts.map +1 -0
- package/dist/gateway-client/generated/core/utils.gen.js +88 -0
- package/dist/gateway-client/generated/core/utils.gen.js.map +1 -0
- package/dist/gateway-client/generated/index.d.ts +3 -0
- package/dist/gateway-client/generated/index.d.ts.map +1 -0
- package/dist/gateway-client/generated/index.js +3 -0
- package/dist/gateway-client/generated/index.js.map +1 -0
- package/dist/gateway-client/generated/namespaces.gen.d.ts +512 -0
- package/dist/gateway-client/generated/namespaces.gen.d.ts.map +1 -0
- package/dist/gateway-client/generated/namespaces.gen.js +521 -0
- package/dist/gateway-client/generated/namespaces.gen.js.map +1 -0
- package/dist/gateway-client/generated/sdk.gen.d.ts +1780 -0
- package/dist/gateway-client/generated/sdk.gen.d.ts.map +1 -0
- package/dist/gateway-client/generated/sdk.gen.js +3811 -0
- package/dist/gateway-client/generated/sdk.gen.js.map +1 -0
- package/dist/gateway-client/generated/types.gen.d.ts +14681 -0
- package/dist/gateway-client/generated/types.gen.d.ts.map +1 -0
- package/dist/gateway-client/generated/types.gen.js +3 -0
- package/dist/gateway-client/generated/types.gen.js.map +1 -0
- package/dist/gateway-client/index.d.ts +27 -0
- package/dist/gateway-client/index.d.ts.map +1 -0
- package/dist/gateway-client/index.js +25 -0
- package/dist/gateway-client/index.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +28 -0
- package/dist/init.js.map +1 -1
- package/dist/internal.d.ts +10 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +18 -1
- package/dist/internal.js.map +1 -1
- package/dist/llm/catalog-model-resolver.d.ts +19 -0
- package/dist/llm/catalog-model-resolver.d.ts.map +1 -1
- package/dist/llm/catalog-model-resolver.js +36 -0
- package/dist/llm/catalog-model-resolver.js.map +1 -1
- package/dist/llm/catalog-resolver.d.ts +112 -0
- package/dist/llm/catalog-resolver.d.ts.map +1 -0
- package/dist/llm/catalog-resolver.js +207 -0
- package/dist/llm/catalog-resolver.js.map +1 -0
- package/dist/llm/catalog-seeder.d.ts +96 -0
- package/dist/llm/catalog-seeder.d.ts.map +1 -0
- package/dist/llm/catalog-seeder.js +189 -0
- package/dist/llm/catalog-seeder.js.map +1 -0
- package/dist/llm/cli-ops.js +5 -5
- package/dist/llm/cli-ops.js.map +1 -1
- package/dist/llm/complexity-classifier.d.ts +208 -0
- package/dist/llm/complexity-classifier.d.ts.map +1 -0
- package/dist/llm/complexity-classifier.js +359 -0
- package/dist/llm/complexity-classifier.js.map +1 -0
- package/dist/llm/credential-pool.d.ts +2 -0
- package/dist/llm/credential-pool.d.ts.map +1 -1
- package/dist/llm/credential-pool.js +5 -2
- package/dist/llm/credential-pool.js.map +1 -1
- package/dist/llm/credentials-store.d.ts +10 -14
- package/dist/llm/credentials-store.d.ts.map +1 -1
- package/dist/llm/credentials-store.js.map +1 -1
- package/dist/llm/entity-ops.d.ts +299 -0
- package/dist/llm/entity-ops.d.ts.map +1 -0
- package/dist/llm/entity-ops.js +441 -0
- package/dist/llm/entity-ops.js.map +1 -0
- package/dist/llm/index.d.ts +15 -0
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +8 -0
- package/dist/llm/index.js.map +1 -1
- package/dist/llm/llm-queue-admit.d.ts +118 -0
- package/dist/llm/llm-queue-admit.d.ts.map +1 -0
- package/dist/llm/llm-queue-admit.js +275 -0
- package/dist/llm/llm-queue-admit.js.map +1 -0
- package/dist/llm/oauth/device-code.d.ts.map +1 -1
- package/dist/llm/oauth/device-code.js +2 -8
- package/dist/llm/oauth/device-code.js.map +1 -1
- package/dist/llm/oauth/google-pkce.d.ts.map +1 -1
- package/dist/llm/oauth/google-pkce.js +2 -18
- package/dist/llm/oauth/google-pkce.js.map +1 -1
- package/dist/llm/oauth/pkce.d.ts +70 -0
- package/dist/llm/oauth/pkce.d.ts.map +1 -1
- package/dist/llm/oauth/pkce.js +106 -29
- package/dist/llm/oauth/pkce.js.map +1 -1
- package/dist/llm/onboarding/front-door.d.ts +146 -0
- package/dist/llm/onboarding/front-door.d.ts.map +1 -0
- package/dist/llm/onboarding/front-door.js +153 -0
- package/dist/llm/onboarding/front-door.js.map +1 -0
- package/dist/llm/onboarding/login-engine.d.ts +175 -0
- package/dist/llm/onboarding/login-engine.d.ts.map +1 -0
- package/dist/llm/onboarding/login-engine.js +286 -0
- package/dist/llm/onboarding/login-engine.js.map +1 -0
- package/dist/llm/pi/pi-gondolin-env.d.ts +23 -0
- package/dist/llm/pi/pi-gondolin-env.d.ts.map +1 -1
- package/dist/llm/pi/pi-gondolin-env.js +2 -2
- package/dist/llm/pi/pi-gondolin-env.js.map +1 -1
- package/dist/llm/plugin-facade.js +3853 -814
- package/dist/llm/plugin-facade.js.map +3 -3
- package/dist/llm/provider-registry/builtin/anthropic.d.ts.map +1 -1
- package/dist/llm/provider-registry/builtin/anthropic.js +23 -10
- package/dist/llm/provider-registry/builtin/anthropic.js.map +1 -1
- package/dist/llm/provider-registry/provider-alias.d.ts +62 -0
- package/dist/llm/provider-registry/provider-alias.d.ts.map +1 -0
- package/dist/llm/provider-registry/provider-alias.js +85 -0
- package/dist/llm/provider-registry/provider-alias.js.map +1 -0
- package/dist/llm/provider-registry/provider-defs.d.ts +45 -0
- package/dist/llm/provider-registry/provider-defs.d.ts.map +1 -0
- package/dist/llm/provider-registry/provider-defs.js +145 -0
- package/dist/llm/provider-registry/provider-defs.js.map +1 -0
- package/dist/llm/provider-registry/provider-seed.d.ts +78 -0
- package/dist/llm/provider-registry/provider-seed.d.ts.map +1 -0
- package/dist/llm/provider-registry/provider-seed.js +113 -0
- package/dist/llm/provider-registry/provider-seed.js.map +1 -0
- package/dist/llm/role-executor.d.ts.map +1 -1
- package/dist/llm/role-executor.js +36 -0
- package/dist/llm/role-executor.js.map +1 -1
- package/dist/llm/role-resolver.d.ts.map +1 -1
- package/dist/llm/role-resolver.js +9 -2
- package/dist/llm/role-resolver.js.map +1 -1
- package/dist/llm/system-resolver.d.ts.map +1 -1
- package/dist/llm/system-resolver.js +73 -22
- package/dist/llm/system-resolver.js.map +1 -1
- package/dist/memory/learnings.d.ts +4 -0
- package/dist/memory/learnings.d.ts.map +1 -1
- package/dist/memory/patterns.d.ts +4 -0
- package/dist/memory/patterns.d.ts.map +1 -1
- package/dist/metrics/index.d.ts +2 -0
- package/dist/metrics/index.d.ts.map +1 -1
- package/dist/metrics/index.js +1 -0
- package/dist/metrics/index.js.map +1 -1
- package/dist/orchestration/spawn.d.ts +89 -0
- package/dist/orchestration/spawn.d.ts.map +1 -1
- package/dist/orchestration/spawn.js +68 -0
- package/dist/orchestration/spawn.js.map +1 -1
- package/dist/playbooks/cantbook-profile.d.ts +96 -0
- package/dist/playbooks/cantbook-profile.d.ts.map +1 -0
- package/dist/playbooks/cantbook-profile.js +97 -0
- package/dist/playbooks/cantbook-profile.js.map +1 -0
- package/dist/playbooks/guarded-deterministic-runner.d.ts +153 -0
- package/dist/playbooks/guarded-deterministic-runner.d.ts.map +1 -0
- package/dist/playbooks/guarded-deterministic-runner.js +155 -0
- package/dist/playbooks/guarded-deterministic-runner.js.map +1 -0
- package/dist/playbooks/index.d.ts +2 -0
- package/dist/playbooks/index.d.ts.map +1 -1
- package/dist/playbooks/index.js +10 -0
- package/dist/playbooks/index.js.map +1 -1
- package/dist/playbooks/pi-runner-wiring.d.ts +75 -0
- package/dist/playbooks/pi-runner-wiring.d.ts.map +1 -0
- package/dist/playbooks/pi-runner-wiring.js +82 -0
- package/dist/playbooks/pi-runner-wiring.js.map +1 -0
- package/dist/runtime/openapi/generate-openapi.d.ts +211 -0
- package/dist/runtime/openapi/generate-openapi.d.ts.map +1 -0
- package/dist/runtime/openapi/generate-openapi.js +300 -0
- package/dist/runtime/openapi/generate-openapi.js.map +1 -0
- package/dist/runtime/openapi/index.d.ts +16 -0
- package/dist/runtime/openapi/index.d.ts.map +1 -0
- package/dist/runtime/openapi/index.js +16 -0
- package/dist/runtime/openapi/index.js.map +1 -0
- package/dist/selfimprove/scenarios/dhq-replay-find/golden.json +32 -0
- package/dist/selfimprove/scenarios/dhq-replay-find/scenario.json +18 -0
- package/dist/setup/config-json-merge.d.ts.map +1 -1
- package/dist/setup/config-json-merge.js +14 -0
- package/dist/setup/config-json-merge.js.map +1 -1
- package/dist/setup/index.d.ts +23 -11
- package/dist/setup/index.d.ts.map +1 -1
- package/dist/setup/index.js +25 -12
- package/dist/setup/index.js.map +1 -1
- package/dist/setup/sections/llm.d.ts +28 -1
- package/dist/setup/sections/llm.d.ts.map +1 -1
- package/dist/setup/sections/llm.js +27 -6
- package/dist/setup/sections/llm.js.map +1 -1
- package/dist/setup/sections/models-roles.d.ts +40 -0
- package/dist/setup/sections/models-roles.d.ts.map +1 -0
- package/dist/setup/sections/models-roles.js +219 -0
- package/dist/setup/sections/models-roles.js.map +1 -0
- package/dist/setup/wizard.d.ts +19 -1
- package/dist/setup/wizard.d.ts.map +1 -1
- package/dist/setup/wizard.js.map +1 -1
- package/dist/store/schedule-schema.d.ts +195 -0
- package/dist/store/schedule-schema.d.ts.map +1 -0
- package/dist/store/schedule-schema.js +84 -0
- package/dist/store/schedule-schema.js.map +1 -0
- package/dist/store/schedule-store.d.ts +144 -0
- package/dist/store/schedule-store.d.ts.map +1 -0
- package/dist/store/schedule-store.js +162 -0
- package/dist/store/schedule-store.js.map +1 -0
- package/dist/store/schema/attachments.d.ts +1 -1
- package/dist/store/schema/cleo-global/index.d.ts +3 -0
- package/dist/store/schema/cleo-global/index.d.ts.map +1 -1
- package/dist/store/schema/cleo-global/index.js +5 -0
- package/dist/store/schema/cleo-global/index.js.map +1 -1
- package/dist/store/schema/cleo-global/models-catalog.d.ts +359 -0
- package/dist/store/schema/cleo-global/models-catalog.d.ts.map +1 -0
- package/dist/store/schema/cleo-global/models-catalog.js +114 -0
- package/dist/store/schema/cleo-global/models-catalog.js.map +1 -0
- package/dist/store/schema/cleo-global/providers.d.ts +279 -0
- package/dist/store/schema/cleo-global/providers.d.ts.map +1 -0
- package/dist/store/schema/cleo-global/providers.js +94 -0
- package/dist/store/schema/cleo-global/providers.js.map +1 -0
- package/dist/store/schema/cleo-global/services.d.ts +493 -0
- package/dist/store/schema/cleo-global/services.d.ts.map +1 -0
- package/dist/store/schema/cleo-global/services.js +200 -0
- package/dist/store/schema/cleo-global/services.js.map +1 -0
- package/dist/store/schema/cleo-project/docs.d.ts +1 -1
- package/dist/store/schema/cleo-project/provenance-rest.d.ts +1 -1
- package/dist/store/schema/cleo-shared/brain.d.ts +2 -2
- package/dist/store/schema/memory-schema.d.ts +182 -2
- package/dist/store/schema/memory-schema.d.ts.map +1 -1
- package/dist/store/schema/memory-schema.js +111 -2
- package/dist/store/schema/memory-schema.js.map +1 -1
- package/dist/store/schema/provenance/releases.d.ts +1 -1
- package/dist/store/service-connections-accessor.d.ts +313 -0
- package/dist/store/service-connections-accessor.d.ts.map +1 -0
- package/dist/store/service-connections-accessor.js +464 -0
- package/dist/store/service-connections-accessor.js.map +1 -0
- package/dist/store/service-host-matcher.d.ts +70 -0
- package/dist/store/service-host-matcher.d.ts.map +1 -0
- package/dist/store/service-host-matcher.js +127 -0
- package/dist/store/service-host-matcher.js.map +1 -0
- package/dist/store/service-injection.d.ts +152 -0
- package/dist/store/service-injection.d.ts.map +1 -0
- package/dist/store/service-injection.js +225 -0
- package/dist/store/service-injection.js.map +1 -0
- package/dist/store/service-oauth.d.ts +287 -0
- package/dist/store/service-oauth.d.ts.map +1 -0
- package/dist/store/service-oauth.js +524 -0
- package/dist/store/service-oauth.js.map +1 -0
- package/dist/store/service-trust-gate.d.ts +164 -0
- package/dist/store/service-trust-gate.d.ts.map +1 -0
- package/dist/store/service-trust-gate.js +122 -0
- package/dist/store/service-trust-gate.js.map +1 -0
- package/dist/store/validation-schemas.d.ts +4 -4
- package/dist/tasks/agent-lifecycle-lane.d.ts +175 -0
- package/dist/tasks/agent-lifecycle-lane.d.ts.map +1 -0
- package/dist/tasks/agent-lifecycle-lane.js +176 -0
- package/dist/tasks/agent-lifecycle-lane.js.map +1 -0
- package/dist/tasks/complete.d.ts +17 -0
- package/dist/tasks/complete.d.ts.map +1 -1
- package/dist/tasks/complete.js +53 -10
- package/dist/tasks/complete.js.map +1 -1
- package/dist/tasks/depends-waiver-audit.d.ts +52 -0
- package/dist/tasks/depends-waiver-audit.d.ts.map +1 -0
- package/dist/tasks/depends-waiver-audit.js +36 -0
- package/dist/tasks/depends-waiver-audit.js.map +1 -0
- package/dist/tasks/engine-wrap.d.ts +36 -2
- package/dist/tasks/engine-wrap.d.ts.map +1 -1
- package/dist/tasks/engine-wrap.js +44 -2
- package/dist/tasks/engine-wrap.js.map +1 -1
- package/dist/tasks/index.d.ts +1 -0
- package/dist/tasks/index.d.ts.map +1 -1
- package/dist/tasks/index.js +1 -0
- package/dist/tasks/index.js.map +1 -1
- package/dist/tasks/ops.d.ts +3 -0
- package/dist/tasks/ops.d.ts.map +1 -1
- package/dist/tasks/task-ops.d.ts +1 -1
- package/dist/tasks/task-ops.d.ts.map +1 -1
- package/dist/tasks/task-ops.js +3 -1
- package/dist/tasks/task-ops.js.map +1 -1
- package/dist/tasks/task-reparent.d.ts +90 -0
- package/dist/tasks/task-reparent.d.ts.map +1 -1
- package/dist/tasks/task-reparent.js +171 -0
- package/dist/tasks/task-reparent.js.map +1 -1
- package/dist/tools/builtin-agent-tools.d.ts.map +1 -1
- package/dist/tools/builtin-agent-tools.js +41 -0
- package/dist/tools/builtin-agent-tools.js.map +1 -1
- package/dist/tools/exec-code-agent-tool.d.ts +179 -0
- package/dist/tools/exec-code-agent-tool.d.ts.map +1 -0
- package/dist/tools/exec-code-agent-tool.js +239 -0
- package/dist/tools/exec-code-agent-tool.js.map +1 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +15 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/mcp-agent-tool.d.ts +189 -0
- package/dist/tools/mcp-agent-tool.d.ts.map +1 -0
- package/dist/tools/mcp-agent-tool.js +243 -0
- package/dist/tools/mcp-agent-tool.js.map +1 -0
- package/dist/tools/media-agent-tools.d.ts +105 -0
- package/dist/tools/media-agent-tools.d.ts.map +1 -0
- package/dist/tools/media-agent-tools.js +255 -0
- package/dist/tools/media-agent-tools.js.map +1 -0
- package/dist/tools/memory-agent-tools.d.ts +99 -0
- package/dist/tools/memory-agent-tools.d.ts.map +1 -0
- package/dist/tools/memory-agent-tools.js +190 -0
- package/dist/tools/memory-agent-tools.js.map +1 -0
- package/dist/tools/schedule-agent-tools.d.ts +151 -0
- package/dist/tools/schedule-agent-tools.d.ts.map +1 -0
- package/dist/tools/schedule-agent-tools.js +238 -0
- package/dist/tools/schedule-agent-tools.js.map +1 -0
- package/dist/tools/skill-agent-tool.d.ts +108 -0
- package/dist/tools/skill-agent-tool.d.ts.map +1 -0
- package/dist/tools/skill-agent-tool.js +135 -0
- package/dist/tools/skill-agent-tool.js.map +1 -0
- package/dist/validation/engine-ops.d.ts.map +1 -1
- package/dist/validation/engine-ops.js +17 -1
- package/dist/validation/engine-ops.js.map +1 -1
- package/migrations/drizzle-brain/20260610000001_t10405-bitemporal-network-columns/migration.sql +71 -0
- package/migrations/drizzle-cleo-global/20260609000000_t11937-service-vault/migration.sql +93 -0
- package/migrations/drizzle-cleo-global/20260609010000_t11733-models-catalog/migration.sql +65 -0
- package/migrations/drizzle-cleo-global/20260609020000_t11703-providers/migration.sql +52 -0
- package/migrations/drizzle-cleo-global/20260610000000_t11962-schedules/migration.sql +48 -0
- package/migrations/drizzle-cleo-project/20260610000000_t11962-schedules/migration.sql +48 -0
- package/package.json +23 -13
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* L1 complexity classifier — a prompt-complexity **tier proposer** for the E9
|
|
3
|
+
* LLM chokepoint.
|
|
4
|
+
*
|
|
5
|
+
* ## What this is
|
|
6
|
+
*
|
|
7
|
+
* A faithful TypeScript port of the deleted Rust `cant-router` Layer-1
|
|
8
|
+
* classifier (`crates/cant-router/src/features.rs` + `classifier.rs`, retired
|
|
9
|
+
* in T11807 / D11137). It converts a raw prompt string into five auditable
|
|
10
|
+
* heuristic features, scores them with a fixed linear model, and maps the
|
|
11
|
+
* scalar score to a three-level complexity tier (`low` / `mid` / `high`).
|
|
12
|
+
*
|
|
13
|
+
* The classifier is a **proposer** that COMPLEMENTS — never replaces — the E9
|
|
14
|
+
* resolver {@link resolveLLMForSystem}. The flow is:
|
|
15
|
+
*
|
|
16
|
+
* ```text
|
|
17
|
+
* classifyComplexity(prompt) -> ComplexityTier ('low'|'mid'|'high')
|
|
18
|
+
* complexityTierToRole(tier) -> RoleName (cheap → capable ladder)
|
|
19
|
+
* resolveLLMForSystem({ kind:'role', id }) -> model + credential
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* So when a caller has NO explicit tier/role, it can derive one from the
|
|
23
|
+
* prompt's complexity and feed it to the chokepoint.
|
|
24
|
+
*
|
|
25
|
+
* ## What this is NOT (Gate-13 LLM Chokepoint Guard — T11783)
|
|
26
|
+
*
|
|
27
|
+
* - It NEVER constructs a transport or SDK client.
|
|
28
|
+
* - It NEVER reads `*_API_KEY` (no credential I/O at all).
|
|
29
|
+
* - It NEVER hardcodes a model-id literal. The tier→model mapping is the E9
|
|
30
|
+
* resolver's job; this module stops at proposing a {@link RoleName}.
|
|
31
|
+
*
|
|
32
|
+
* It returns a TIER (and, via the helper, a role). The provider, model, and
|
|
33
|
+
* credential are resolved exclusively by {@link resolveLLMForSystem}.
|
|
34
|
+
*
|
|
35
|
+
* The classifier is a pure, deterministic function with no I/O and no module
|
|
36
|
+
* side effects — safe to import anywhere in the chokepoint.
|
|
37
|
+
*
|
|
38
|
+
* @module llm/complexity-classifier
|
|
39
|
+
* @task T11906
|
|
40
|
+
* @epic T11745
|
|
41
|
+
* @see {@link resolveLLMForSystem} — the E9 chokepoint this proposer feeds.
|
|
42
|
+
*/
|
|
43
|
+
import type { RoleName } from '@cleocode/contracts';
|
|
44
|
+
/**
|
|
45
|
+
* The three-level complexity ladder proposed by {@link classifyComplexity}.
|
|
46
|
+
*
|
|
47
|
+
* Ported verbatim from the Rust `Tier` enum (`low` / `mid` / `high`, in
|
|
48
|
+
* lowercase serde rename order). It is distinct from the dispatch
|
|
49
|
+
* `Tier = 0 | 1 | 2` in `@cleocode/contracts`: this ladder describes prompt
|
|
50
|
+
* complexity, not dispatch privilege.
|
|
51
|
+
*
|
|
52
|
+
* - `low` — fastest, cheapest models. Short, simple prompts.
|
|
53
|
+
* - `mid` — balanced cost/latency/capability. The default workhorse.
|
|
54
|
+
* - `high` — most capable, most expensive models. Complex reasoning.
|
|
55
|
+
*/
|
|
56
|
+
export type ComplexityTier = 'low' | 'mid' | 'high';
|
|
57
|
+
/**
|
|
58
|
+
* The five heuristic features extracted from a prompt — the inputs to the
|
|
59
|
+
* linear classifier.
|
|
60
|
+
*
|
|
61
|
+
* Each field corresponds to one of the five signals defined in the deleted
|
|
62
|
+
* Rust `PromptFeatures` struct (ULTRAPLAN §11.1). Pure heuristics, no ML
|
|
63
|
+
* runtime — each extractor is a small, auditable signal.
|
|
64
|
+
*/
|
|
65
|
+
export interface PromptFeatures {
|
|
66
|
+
/** Raw whitespace-delimited token count of the prompt. */
|
|
67
|
+
tokenCount: number;
|
|
68
|
+
/** Syntactic complexity in `[0.0, 1.0]` — proxied by nested bracket depth. */
|
|
69
|
+
syntacticComplexity: number;
|
|
70
|
+
/** Count of reasoning keywords (why / should / compare / decide / …). */
|
|
71
|
+
reasoningDepth: number;
|
|
72
|
+
/** Domain-specificity in `[0.0, 1.0]` — proxied by CamelCase identifier density. */
|
|
73
|
+
domainSpecificity: number;
|
|
74
|
+
/** Number of file references detected in the prompt. */
|
|
75
|
+
touchesFilesCount: number;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A classification result — the tier recommended for a prompt, plus the raw
|
|
79
|
+
* score and feature vector that produced it.
|
|
80
|
+
*
|
|
81
|
+
* Mirrors the deleted Rust `Classification` struct so downstream consumers can
|
|
82
|
+
* inspect the signals behind the decision.
|
|
83
|
+
*/
|
|
84
|
+
export interface Classification {
|
|
85
|
+
/** Scalar complexity score in `[0.0, 1.0]` produced by the weighted sum. */
|
|
86
|
+
score: number;
|
|
87
|
+
/** The tier chosen by threshold-mapping `score`. */
|
|
88
|
+
tier: ComplexityTier;
|
|
89
|
+
/** The raw feature vector that produced this classification. */
|
|
90
|
+
features: PromptFeatures;
|
|
91
|
+
}
|
|
92
|
+
/** Weight applied to the normalized `tokenCount` feature. */
|
|
93
|
+
export declare const WEIGHT_TOKEN_COUNT = 0.15;
|
|
94
|
+
/** Weight applied to the normalized `syntacticComplexity` feature. */
|
|
95
|
+
export declare const WEIGHT_SYNTACTIC_COMPLEXITY = 0.25;
|
|
96
|
+
/** Weight applied to the normalized `reasoningDepth` feature. */
|
|
97
|
+
export declare const WEIGHT_REASONING_DEPTH = 0.3;
|
|
98
|
+
/** Weight applied to the normalized `domainSpecificity` feature. */
|
|
99
|
+
export declare const WEIGHT_DOMAIN_SPECIFICITY = 0.2;
|
|
100
|
+
/** Weight applied to the normalized `touchesFilesCount` feature. */
|
|
101
|
+
export declare const WEIGHT_TOUCHES_FILES_COUNT = 0.1;
|
|
102
|
+
/** Score at or above which the classifier returns the `high` tier. */
|
|
103
|
+
export declare const THRESHOLD_HIGH = 0.75;
|
|
104
|
+
/**
|
|
105
|
+
* Score at or above which the classifier returns the `mid` tier.
|
|
106
|
+
*
|
|
107
|
+
* Scores strictly below this threshold are mapped to `low`.
|
|
108
|
+
*/
|
|
109
|
+
export declare const THRESHOLD_MID = 0.35;
|
|
110
|
+
/**
|
|
111
|
+
* Extract a {@link PromptFeatures} vector from a raw prompt string.
|
|
112
|
+
*
|
|
113
|
+
* Pure heuristics, no ML runtime — the Layer-1 input stage. Each field is a
|
|
114
|
+
* small, auditable signal that feeds {@link classify}.
|
|
115
|
+
*
|
|
116
|
+
* @param prompt - The raw prompt string.
|
|
117
|
+
* @returns The five-feature vector for `prompt`.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* const f = extractFeatures('Refactor auth.ts to use JWT tokens.');
|
|
122
|
+
* f.tokenCount; // > 0
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export declare function extractFeatures(prompt: string): PromptFeatures;
|
|
126
|
+
/**
|
|
127
|
+
* Classify a feature vector into a {@link Classification} result.
|
|
128
|
+
*
|
|
129
|
+
* Applies the linear weighted sum from ULTRAPLAN §11.1 and maps the resulting
|
|
130
|
+
* score to a tier via {@link THRESHOLD_HIGH} and {@link THRESHOLD_MID}. The
|
|
131
|
+
* input {@link PromptFeatures} is preserved so downstream consumers can inspect
|
|
132
|
+
* the raw signals that produced the decision.
|
|
133
|
+
*
|
|
134
|
+
* @param features - The five-feature vector to score.
|
|
135
|
+
* @returns The score, tier, and preserved feature vector.
|
|
136
|
+
*/
|
|
137
|
+
export declare function classify(features: PromptFeatures): Classification;
|
|
138
|
+
/**
|
|
139
|
+
* Classify a raw prompt into a complexity {@link ComplexityTier}.
|
|
140
|
+
*
|
|
141
|
+
* The one-call entry point: `extractFeatures` → `classify` → tier. This is the
|
|
142
|
+
* **proposer** half of the L1 router — it stops at a tier and never touches a
|
|
143
|
+
* model, transport, or credential (Gate-13 compliant).
|
|
144
|
+
*
|
|
145
|
+
* @param prompt - The raw prompt string to classify.
|
|
146
|
+
* @returns The proposed complexity tier (`low` / `mid` / `high`).
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* classifyComplexity('list files'); // 'low'
|
|
151
|
+
* classifyComplexity('Why should we compare these and decide the trade-off?'); // 'mid'+
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
export declare function classifyComplexity(prompt: string): ComplexityTier;
|
|
155
|
+
/**
|
|
156
|
+
* The next tier up for escalation — ported from the Rust `Tier::escalate`.
|
|
157
|
+
*
|
|
158
|
+
* Returns `null` when already at `high`, signalling the caller that no further
|
|
159
|
+
* escalation is possible.
|
|
160
|
+
*
|
|
161
|
+
* @param tier - The current complexity tier.
|
|
162
|
+
* @returns The next tier up, or `null` at the top of the ladder.
|
|
163
|
+
*/
|
|
164
|
+
export declare function escalateTier(tier: ComplexityTier): ComplexityTier | null;
|
|
165
|
+
/**
|
|
166
|
+
* Map a complexity {@link ComplexityTier} to the {@link RoleName} that
|
|
167
|
+
* {@link resolveLLMForSystem} should resolve when no explicit tier/role was
|
|
168
|
+
* given.
|
|
169
|
+
*
|
|
170
|
+
* This is the wiring contract (AC2) that lets a tier flow into the E9
|
|
171
|
+
* chokepoint: the classifier proposes a tier, this maps it to a role, and
|
|
172
|
+
* `resolveLLMForSystem({ kind: 'role', id })` performs the actual model +
|
|
173
|
+
* credential resolution. The mapping is a cheap → capable ladder over the
|
|
174
|
+
* canonical {@link RoleName} set — it pins NO model literal of its own.
|
|
175
|
+
*
|
|
176
|
+
* - `low` → `hygiene` — cheapest single-turn cleanup-class role.
|
|
177
|
+
* - `mid` → `consolidation` — the default workhorse role.
|
|
178
|
+
* - `high` → `judgement` — the most-capable reasoning role.
|
|
179
|
+
*
|
|
180
|
+
* @param tier - The proposed complexity tier.
|
|
181
|
+
* @returns The {@link RoleName} to feed into the E9 resolver.
|
|
182
|
+
*/
|
|
183
|
+
export declare function complexityTierToRole(tier: ComplexityTier): RoleName;
|
|
184
|
+
/**
|
|
185
|
+
* Propose the {@link RoleName} for a raw prompt by classifying its complexity
|
|
186
|
+
* and mapping the resulting tier to a role.
|
|
187
|
+
*
|
|
188
|
+
* Convenience composition of {@link classifyComplexity} and
|
|
189
|
+
* {@link complexityTierToRole} — the single call a caller uses to derive a role
|
|
190
|
+
* for {@link resolveLLMForSystem} when it has no explicit tier/role.
|
|
191
|
+
*
|
|
192
|
+
* The returned role is intended to be passed as the structured descriptor:
|
|
193
|
+
* `resolveLLMForSystem({ kind: 'role', id: proposeRoleForPrompt(prompt) })`.
|
|
194
|
+
*
|
|
195
|
+
* @param prompt - The raw prompt string.
|
|
196
|
+
* @returns The proposed {@link RoleName} for the E9 chokepoint.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* import { proposeRoleForPrompt } from './complexity-classifier.js';
|
|
201
|
+
* import { resolveLLMForSystem } from './system-resolver.js';
|
|
202
|
+
*
|
|
203
|
+
* const role = proposeRoleForPrompt(userPrompt);
|
|
204
|
+
* const llm = await resolveLLMForSystem({ kind: 'role', id: role }, { projectRoot });
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
export declare function proposeRoleForPrompt(prompt: string): RoleName;
|
|
208
|
+
//# sourceMappingURL=complexity-classifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complexity-classifier.d.ts","sourceRoot":"","sources":["../../src/llm/complexity-classifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAMpD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,mBAAmB,EAAE,MAAM,CAAC;IAC5B,yEAAyE;IACzE,cAAc,EAAE,MAAM,CAAC;IACvB,oFAAoF;IACpF,iBAAiB,EAAE,MAAM,CAAC;IAC1B,wDAAwD;IACxD,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,IAAI,EAAE,cAAc,CAAC;IACrB,gEAAgE;IAChE,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAMD,6DAA6D;AAC7D,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAEvC,sEAAsE;AACtE,eAAO,MAAM,2BAA2B,OAAO,CAAC;AAEhD,iEAAiE;AACjE,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,oEAAoE;AACpE,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAE7C,oEAAoE;AACpE,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C,sEAAsE;AACtE,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC;;;;GAIG;AACH,eAAO,MAAM,aAAa,OAAO,CAAC;AA2IlC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAQ9D;AAyCD;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,cAAc,GAAG,cAAc,CAajE;AAMD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAEjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,cAAc,GAAG,IAAI,CASxE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,cAAc,GAAG,QAAQ,CASnE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,CAE7D"}
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* L1 complexity classifier — a prompt-complexity **tier proposer** for the E9
|
|
3
|
+
* LLM chokepoint.
|
|
4
|
+
*
|
|
5
|
+
* ## What this is
|
|
6
|
+
*
|
|
7
|
+
* A faithful TypeScript port of the deleted Rust `cant-router` Layer-1
|
|
8
|
+
* classifier (`crates/cant-router/src/features.rs` + `classifier.rs`, retired
|
|
9
|
+
* in T11807 / D11137). It converts a raw prompt string into five auditable
|
|
10
|
+
* heuristic features, scores them with a fixed linear model, and maps the
|
|
11
|
+
* scalar score to a three-level complexity tier (`low` / `mid` / `high`).
|
|
12
|
+
*
|
|
13
|
+
* The classifier is a **proposer** that COMPLEMENTS — never replaces — the E9
|
|
14
|
+
* resolver {@link resolveLLMForSystem}. The flow is:
|
|
15
|
+
*
|
|
16
|
+
* ```text
|
|
17
|
+
* classifyComplexity(prompt) -> ComplexityTier ('low'|'mid'|'high')
|
|
18
|
+
* complexityTierToRole(tier) -> RoleName (cheap → capable ladder)
|
|
19
|
+
* resolveLLMForSystem({ kind:'role', id }) -> model + credential
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* So when a caller has NO explicit tier/role, it can derive one from the
|
|
23
|
+
* prompt's complexity and feed it to the chokepoint.
|
|
24
|
+
*
|
|
25
|
+
* ## What this is NOT (Gate-13 LLM Chokepoint Guard — T11783)
|
|
26
|
+
*
|
|
27
|
+
* - It NEVER constructs a transport or SDK client.
|
|
28
|
+
* - It NEVER reads `*_API_KEY` (no credential I/O at all).
|
|
29
|
+
* - It NEVER hardcodes a model-id literal. The tier→model mapping is the E9
|
|
30
|
+
* resolver's job; this module stops at proposing a {@link RoleName}.
|
|
31
|
+
*
|
|
32
|
+
* It returns a TIER (and, via the helper, a role). The provider, model, and
|
|
33
|
+
* credential are resolved exclusively by {@link resolveLLMForSystem}.
|
|
34
|
+
*
|
|
35
|
+
* The classifier is a pure, deterministic function with no I/O and no module
|
|
36
|
+
* side effects — safe to import anywhere in the chokepoint.
|
|
37
|
+
*
|
|
38
|
+
* @module llm/complexity-classifier
|
|
39
|
+
* @task T11906
|
|
40
|
+
* @epic T11745
|
|
41
|
+
* @see {@link resolveLLMForSystem} — the E9 chokepoint this proposer feeds.
|
|
42
|
+
*/
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
// Classifier weights + thresholds (ULTRAPLAN §11.1 — ported from classifier.rs)
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
/** Weight applied to the normalized `tokenCount` feature. */
|
|
47
|
+
export const WEIGHT_TOKEN_COUNT = 0.15;
|
|
48
|
+
/** Weight applied to the normalized `syntacticComplexity` feature. */
|
|
49
|
+
export const WEIGHT_SYNTACTIC_COMPLEXITY = 0.25;
|
|
50
|
+
/** Weight applied to the normalized `reasoningDepth` feature. */
|
|
51
|
+
export const WEIGHT_REASONING_DEPTH = 0.3;
|
|
52
|
+
/** Weight applied to the normalized `domainSpecificity` feature. */
|
|
53
|
+
export const WEIGHT_DOMAIN_SPECIFICITY = 0.2;
|
|
54
|
+
/** Weight applied to the normalized `touchesFilesCount` feature. */
|
|
55
|
+
export const WEIGHT_TOUCHES_FILES_COUNT = 0.1;
|
|
56
|
+
/** Score at or above which the classifier returns the `high` tier. */
|
|
57
|
+
export const THRESHOLD_HIGH = 0.75;
|
|
58
|
+
/**
|
|
59
|
+
* Score at or above which the classifier returns the `mid` tier.
|
|
60
|
+
*
|
|
61
|
+
* Scores strictly below this threshold are mapped to `low`.
|
|
62
|
+
*/
|
|
63
|
+
export const THRESHOLD_MID = 0.35;
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
// Feature extraction (ported from features.rs — five pure heuristics)
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
/**
|
|
68
|
+
* Estimate syntactic complexity by counting nested bracket depth.
|
|
69
|
+
*
|
|
70
|
+
* Walks the string once tracking the running depth of `(`, `{`, `[` (and their
|
|
71
|
+
* matching closers). The maximum depth observed is divided by 5 and clamped to
|
|
72
|
+
* `[0.0, 1.0]`, so a prompt with no brackets scores 0 and one with 5+ nested
|
|
73
|
+
* brackets scores 1.
|
|
74
|
+
*
|
|
75
|
+
* @param s - The raw prompt string.
|
|
76
|
+
* @returns A syntactic-complexity score in `[0.0, 1.0]`.
|
|
77
|
+
*/
|
|
78
|
+
function estimateSyntacticComplexity(s) {
|
|
79
|
+
let depth = 0;
|
|
80
|
+
let maxDepth = 0;
|
|
81
|
+
for (const c of s) {
|
|
82
|
+
if (c === '(' || c === '{' || c === '[') {
|
|
83
|
+
depth += 1;
|
|
84
|
+
if (depth > maxDepth)
|
|
85
|
+
maxDepth = depth;
|
|
86
|
+
}
|
|
87
|
+
else if (c === ')' || c === '}' || c === ']') {
|
|
88
|
+
depth = Math.max(depth - 1, 0);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return Math.min(maxDepth / 5.0, 1.0);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Reasoning-signal keywords — terms that correlate with multi-step reasoning.
|
|
95
|
+
*
|
|
96
|
+
* Intentionally short and biased; ported verbatim from the Rust `KEYWORDS`
|
|
97
|
+
* slice in `count_reasoning_keywords`.
|
|
98
|
+
*/
|
|
99
|
+
const REASONING_KEYWORDS = [
|
|
100
|
+
'why',
|
|
101
|
+
'should',
|
|
102
|
+
'compare',
|
|
103
|
+
'decide',
|
|
104
|
+
'explain',
|
|
105
|
+
'analyze',
|
|
106
|
+
'evaluate',
|
|
107
|
+
'consider',
|
|
108
|
+
'trade-off',
|
|
109
|
+
'tradeoff',
|
|
110
|
+
];
|
|
111
|
+
/**
|
|
112
|
+
* Count reasoning-signal keyword occurrences in the prompt (case-insensitive,
|
|
113
|
+
* counting every (possibly overlapping-free) occurrence, matching the Rust
|
|
114
|
+
* `str::matches` semantics).
|
|
115
|
+
*
|
|
116
|
+
* @param s - The raw prompt string.
|
|
117
|
+
* @returns The total number of reasoning-keyword occurrences.
|
|
118
|
+
*/
|
|
119
|
+
function countReasoningKeywords(s) {
|
|
120
|
+
const lower = s.toLowerCase();
|
|
121
|
+
let total = 0;
|
|
122
|
+
for (const keyword of REASONING_KEYWORDS) {
|
|
123
|
+
let from = 0;
|
|
124
|
+
for (;;) {
|
|
125
|
+
const idx = lower.indexOf(keyword, from);
|
|
126
|
+
if (idx === -1)
|
|
127
|
+
break;
|
|
128
|
+
total += 1;
|
|
129
|
+
// Rust's `str::matches` advances past each non-overlapping match.
|
|
130
|
+
from = idx + keyword.length;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return total;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Count the uppercase characters in a token (used by the CamelCase proxy).
|
|
137
|
+
*
|
|
138
|
+
* @param w - A single whitespace-delimited token.
|
|
139
|
+
* @returns The number of uppercase characters in `w`.
|
|
140
|
+
*/
|
|
141
|
+
function uppercaseCount(w) {
|
|
142
|
+
let n = 0;
|
|
143
|
+
for (const c of w) {
|
|
144
|
+
// An uppercase letter is one that differs from its lowercase form and equals
|
|
145
|
+
// its own uppercase form (excludes digits/punctuation, mirroring Rust's
|
|
146
|
+
// `char::is_uppercase`).
|
|
147
|
+
if (c !== c.toLowerCase() && c === c.toUpperCase())
|
|
148
|
+
n += 1;
|
|
149
|
+
}
|
|
150
|
+
return n;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Estimate domain specificity via CamelCase identifier density.
|
|
154
|
+
*
|
|
155
|
+
* Counts whitespace-delimited tokens containing at least two uppercase letters
|
|
156
|
+
* (a rough proxy for domain-specific identifiers like `ModelSelection` or
|
|
157
|
+
* `XDGBaseDir`). The count is divided by 10 and clamped to `[0.0, 1.0]`.
|
|
158
|
+
*
|
|
159
|
+
* @param s - The raw prompt string.
|
|
160
|
+
* @returns A domain-specificity score in `[0.0, 1.0]`.
|
|
161
|
+
*/
|
|
162
|
+
function estimateDomainSpecificity(s) {
|
|
163
|
+
const camelCaseCount = splitWhitespace(s).filter((w) => uppercaseCount(w) >= 2).length;
|
|
164
|
+
return Math.min(camelCaseCount / 10.0, 1.0);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Count file references in the prompt.
|
|
168
|
+
*
|
|
169
|
+
* A token is a file reference if it contains a `/` or ends in a known
|
|
170
|
+
* source-file extension (`.rs`, `.ts`, `.md`, `.json`). Punctuation on the
|
|
171
|
+
* token is left intact for v1 — callers aware of this limitation can pre-clean
|
|
172
|
+
* their prompts.
|
|
173
|
+
*
|
|
174
|
+
* @param s - The raw prompt string.
|
|
175
|
+
* @returns The number of file-reference tokens.
|
|
176
|
+
*/
|
|
177
|
+
function countFileReferences(s) {
|
|
178
|
+
return splitWhitespace(s).filter((w) => w.includes('/') ||
|
|
179
|
+
w.endsWith('.rs') ||
|
|
180
|
+
w.endsWith('.ts') ||
|
|
181
|
+
w.endsWith('.md') ||
|
|
182
|
+
w.endsWith('.json')).length;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Split a string on Unicode whitespace, dropping empty segments — matching
|
|
186
|
+
* Rust's `str::split_whitespace` (which never yields empty tokens).
|
|
187
|
+
*
|
|
188
|
+
* @param s - The string to split.
|
|
189
|
+
* @returns The non-empty whitespace-delimited tokens of `s`.
|
|
190
|
+
*/
|
|
191
|
+
function splitWhitespace(s) {
|
|
192
|
+
return s.split(/\s+/).filter((w) => w.length > 0);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Extract a {@link PromptFeatures} vector from a raw prompt string.
|
|
196
|
+
*
|
|
197
|
+
* Pure heuristics, no ML runtime — the Layer-1 input stage. Each field is a
|
|
198
|
+
* small, auditable signal that feeds {@link classify}.
|
|
199
|
+
*
|
|
200
|
+
* @param prompt - The raw prompt string.
|
|
201
|
+
* @returns The five-feature vector for `prompt`.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```ts
|
|
205
|
+
* const f = extractFeatures('Refactor auth.ts to use JWT tokens.');
|
|
206
|
+
* f.tokenCount; // > 0
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
export function extractFeatures(prompt) {
|
|
210
|
+
return {
|
|
211
|
+
tokenCount: splitWhitespace(prompt).length,
|
|
212
|
+
syntacticComplexity: estimateSyntacticComplexity(prompt),
|
|
213
|
+
reasoningDepth: countReasoningKeywords(prompt),
|
|
214
|
+
domainSpecificity: estimateDomainSpecificity(prompt),
|
|
215
|
+
touchesFilesCount: countFileReferences(prompt),
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Clamp a value to `[lo, hi]` — equivalent to Rust's `f64::clamp`. Returns `lo`
|
|
220
|
+
* for `NaN`, matching the saturating intent of the original normalizers.
|
|
221
|
+
*/
|
|
222
|
+
function clamp(value, lo, hi) {
|
|
223
|
+
if (Number.isNaN(value))
|
|
224
|
+
return lo;
|
|
225
|
+
return Math.min(Math.max(value, lo), hi);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Normalize each feature to `[0.0, 1.0]` for the weighted sum.
|
|
229
|
+
*
|
|
230
|
+
* These normalization constants are the heuristic v1 defaults tuned against
|
|
231
|
+
* the ULTRAPLAN §11.1 example ranges (not a labeled corpus). Ported verbatim
|
|
232
|
+
* from the Rust `normalize_features`.
|
|
233
|
+
*/
|
|
234
|
+
function normalizeFeatures(f) {
|
|
235
|
+
return {
|
|
236
|
+
tokenCount: Math.min(f.tokenCount / 1000.0, 1.0),
|
|
237
|
+
syntacticComplexity: clamp(f.syntacticComplexity, 0.0, 1.0),
|
|
238
|
+
reasoningDepth: Math.min(f.reasoningDepth / 10.0, 1.0),
|
|
239
|
+
domainSpecificity: clamp(f.domainSpecificity, 0.0, 1.0),
|
|
240
|
+
touchesFilesCount: Math.min(f.touchesFilesCount / 20.0, 1.0),
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Classify a feature vector into a {@link Classification} result.
|
|
245
|
+
*
|
|
246
|
+
* Applies the linear weighted sum from ULTRAPLAN §11.1 and maps the resulting
|
|
247
|
+
* score to a tier via {@link THRESHOLD_HIGH} and {@link THRESHOLD_MID}. The
|
|
248
|
+
* input {@link PromptFeatures} is preserved so downstream consumers can inspect
|
|
249
|
+
* the raw signals that produced the decision.
|
|
250
|
+
*
|
|
251
|
+
* @param features - The five-feature vector to score.
|
|
252
|
+
* @returns The score, tier, and preserved feature vector.
|
|
253
|
+
*/
|
|
254
|
+
export function classify(features) {
|
|
255
|
+
const normalized = normalizeFeatures(features);
|
|
256
|
+
const score = WEIGHT_TOKEN_COUNT * normalized.tokenCount +
|
|
257
|
+
WEIGHT_SYNTACTIC_COMPLEXITY * normalized.syntacticComplexity +
|
|
258
|
+
WEIGHT_REASONING_DEPTH * normalized.reasoningDepth +
|
|
259
|
+
WEIGHT_DOMAIN_SPECIFICITY * normalized.domainSpecificity +
|
|
260
|
+
WEIGHT_TOUCHES_FILES_COUNT * normalized.touchesFilesCount;
|
|
261
|
+
const tier = score >= THRESHOLD_HIGH ? 'high' : score >= THRESHOLD_MID ? 'mid' : 'low';
|
|
262
|
+
return { score, tier, features };
|
|
263
|
+
}
|
|
264
|
+
// ---------------------------------------------------------------------------
|
|
265
|
+
// Public proposer API
|
|
266
|
+
// ---------------------------------------------------------------------------
|
|
267
|
+
/**
|
|
268
|
+
* Classify a raw prompt into a complexity {@link ComplexityTier}.
|
|
269
|
+
*
|
|
270
|
+
* The one-call entry point: `extractFeatures` → `classify` → tier. This is the
|
|
271
|
+
* **proposer** half of the L1 router — it stops at a tier and never touches a
|
|
272
|
+
* model, transport, or credential (Gate-13 compliant).
|
|
273
|
+
*
|
|
274
|
+
* @param prompt - The raw prompt string to classify.
|
|
275
|
+
* @returns The proposed complexity tier (`low` / `mid` / `high`).
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```ts
|
|
279
|
+
* classifyComplexity('list files'); // 'low'
|
|
280
|
+
* classifyComplexity('Why should we compare these and decide the trade-off?'); // 'mid'+
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
export function classifyComplexity(prompt) {
|
|
284
|
+
return classify(extractFeatures(prompt)).tier;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* The next tier up for escalation — ported from the Rust `Tier::escalate`.
|
|
288
|
+
*
|
|
289
|
+
* Returns `null` when already at `high`, signalling the caller that no further
|
|
290
|
+
* escalation is possible.
|
|
291
|
+
*
|
|
292
|
+
* @param tier - The current complexity tier.
|
|
293
|
+
* @returns The next tier up, or `null` at the top of the ladder.
|
|
294
|
+
*/
|
|
295
|
+
export function escalateTier(tier) {
|
|
296
|
+
switch (tier) {
|
|
297
|
+
case 'low':
|
|
298
|
+
return 'mid';
|
|
299
|
+
case 'mid':
|
|
300
|
+
return 'high';
|
|
301
|
+
case 'high':
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Map a complexity {@link ComplexityTier} to the {@link RoleName} that
|
|
307
|
+
* {@link resolveLLMForSystem} should resolve when no explicit tier/role was
|
|
308
|
+
* given.
|
|
309
|
+
*
|
|
310
|
+
* This is the wiring contract (AC2) that lets a tier flow into the E9
|
|
311
|
+
* chokepoint: the classifier proposes a tier, this maps it to a role, and
|
|
312
|
+
* `resolveLLMForSystem({ kind: 'role', id })` performs the actual model +
|
|
313
|
+
* credential resolution. The mapping is a cheap → capable ladder over the
|
|
314
|
+
* canonical {@link RoleName} set — it pins NO model literal of its own.
|
|
315
|
+
*
|
|
316
|
+
* - `low` → `hygiene` — cheapest single-turn cleanup-class role.
|
|
317
|
+
* - `mid` → `consolidation` — the default workhorse role.
|
|
318
|
+
* - `high` → `judgement` — the most-capable reasoning role.
|
|
319
|
+
*
|
|
320
|
+
* @param tier - The proposed complexity tier.
|
|
321
|
+
* @returns The {@link RoleName} to feed into the E9 resolver.
|
|
322
|
+
*/
|
|
323
|
+
export function complexityTierToRole(tier) {
|
|
324
|
+
switch (tier) {
|
|
325
|
+
case 'low':
|
|
326
|
+
return 'hygiene';
|
|
327
|
+
case 'mid':
|
|
328
|
+
return 'consolidation';
|
|
329
|
+
case 'high':
|
|
330
|
+
return 'judgement';
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Propose the {@link RoleName} for a raw prompt by classifying its complexity
|
|
335
|
+
* and mapping the resulting tier to a role.
|
|
336
|
+
*
|
|
337
|
+
* Convenience composition of {@link classifyComplexity} and
|
|
338
|
+
* {@link complexityTierToRole} — the single call a caller uses to derive a role
|
|
339
|
+
* for {@link resolveLLMForSystem} when it has no explicit tier/role.
|
|
340
|
+
*
|
|
341
|
+
* The returned role is intended to be passed as the structured descriptor:
|
|
342
|
+
* `resolveLLMForSystem({ kind: 'role', id: proposeRoleForPrompt(prompt) })`.
|
|
343
|
+
*
|
|
344
|
+
* @param prompt - The raw prompt string.
|
|
345
|
+
* @returns The proposed {@link RoleName} for the E9 chokepoint.
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
* ```ts
|
|
349
|
+
* import { proposeRoleForPrompt } from './complexity-classifier.js';
|
|
350
|
+
* import { resolveLLMForSystem } from './system-resolver.js';
|
|
351
|
+
*
|
|
352
|
+
* const role = proposeRoleForPrompt(userPrompt);
|
|
353
|
+
* const llm = await resolveLLMForSystem({ kind: 'role', id: role }, { projectRoot });
|
|
354
|
+
* ```
|
|
355
|
+
*/
|
|
356
|
+
export function proposeRoleForPrompt(prompt) {
|
|
357
|
+
return complexityTierToRole(classifyComplexity(prompt));
|
|
358
|
+
}
|
|
359
|
+
//# sourceMappingURL=complexity-classifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complexity-classifier.js","sourceRoot":"","sources":["../../src/llm/complexity-classifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AA2DH,8EAA8E;AAC9E,gFAAgF;AAChF,8EAA8E;AAE9E,6DAA6D;AAC7D,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEvC,sEAAsE;AACtE,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAEhD,iEAAiE;AACjE,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAE1C,oEAAoE;AACpE,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAE7C,oEAAoE;AACpE,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAE9C,sEAAsE;AACtE,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC;AAEnC;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC;AAElC,8EAA8E;AAC9E,sEAAsE;AACtE,8EAA8E;AAE9E;;;;;;;;;;GAUG;AACH,SAAS,2BAA2B,CAAC,CAAS;IAC5C,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,QAAQ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,oBAAoB,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -243,7 +243,9 @@ export declare class CredentialPool {
|
|
|
243
243
|
* @param existing - Credential entry to refresh.
|
|
244
244
|
* @param tokenEndpoint - Provider token endpoint URL.
|
|
245
245
|
* @param clientId - OAuth client ID.
|
|
246
|
+
* @param bodyFormat - Token request body encoding (`'json'` for Anthropic).
|
|
246
247
|
* @task T9302
|
|
248
|
+
* @task T11958
|
|
247
249
|
*/
|
|
248
250
|
private _refreshViaPkce;
|
|
249
251
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential-pool.d.ts","sourceRoot":"","sources":["../../src/llm/credential-pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAGH,OAAO,EAEL,KAAK,gBAAgB,EAEtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAWzF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA8BxD;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,aAAa,GAAG,YAAY,CAAC;AAEvE;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,qCAAqC;IACrC,UAAU,EAAE,gBAAgB,CAAC;IAC7B,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAMD;;;;;;;;GAQG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;aAWzB,QAAQ,EAAE,cAAc;aACxB,QAAQ,EAAE,MAAM;aAChB,UAAU,EAAE,MAAM;IAZpC,8BAA8B;IAC9B,QAAQ,CAAC,IAAI,0BAA0B;IAEvC;;;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;;;;;;;;;;;;;GA8BG;AACH,qBAAa,qBAAqB;IAoB9B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAnBjC,kEAAkE;IAClE,OAAO,CAAC,YAAY,CAAK;IAEzB,kEAAkE;IAClE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAmC;IAEhE;;;;;;;;;;;OAWG;gBAEgB,cAAc,GAAE,MAAM,SAAS,gBAAgB,EACtC;IAG5B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,IAAI,CAAC,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,cAAc,CAAC;IA8ItE;;;;;;;;;;;;;;OAcG;IACG,IAAI,CACR,QAAQ,EAAE,cAAc,EACxB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAUnC;;;;;;;;;OASG;IACG,IAAI,IAAI,OAAO,CAAC,SAAS,gBAAgB,EAAE,CAAC;IAIlD;;;;;;;OAOG;IACH,eAAe,IAAI,SAAS,YAAY,EAAE;IAI1C;;;;;;;;;OASG;IACH,cAAc,IAAI,IAAI;CAIvB;AAgBD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,IAAI,qBAAqB,CAKzD;AAED;;;;;;;;GAQG;AACH,wBAAgB,qCAAqC,IAAI,IAAI,CAE5D"}
|
|
@@ -418,7 +418,7 @@ export class CredentialPool {
|
|
|
418
418
|
const profile = await getProviderProfile(this.provider);
|
|
419
419
|
const oauthCfg = profile?.oauth;
|
|
420
420
|
if (oauthCfg?.mode === 'pkce') {
|
|
421
|
-
await this._refreshViaPkce(existing, oauthCfg.tokenEndpoint, oauthCfg.clientId);
|
|
421
|
+
await this._refreshViaPkce(existing, oauthCfg.tokenEndpoint, oauthCfg.clientId, oauthCfg.tokenBodyFormat);
|
|
422
422
|
}
|
|
423
423
|
else if (this.provider === 'kimi-code') {
|
|
424
424
|
const cfg = getKimiCodeDeviceCodeConfig();
|
|
@@ -434,9 +434,11 @@ export class CredentialPool {
|
|
|
434
434
|
* @param existing - Credential entry to refresh.
|
|
435
435
|
* @param tokenEndpoint - Provider token endpoint URL.
|
|
436
436
|
* @param clientId - OAuth client ID.
|
|
437
|
+
* @param bodyFormat - Token request body encoding (`'json'` for Anthropic).
|
|
437
438
|
* @task T9302
|
|
439
|
+
* @task T11958
|
|
438
440
|
*/
|
|
439
|
-
async _refreshViaPkce(existing, tokenEndpoint, clientId) {
|
|
441
|
+
async _refreshViaPkce(existing, tokenEndpoint, clientId, bodyFormat) {
|
|
440
442
|
if (!existing.refreshToken)
|
|
441
443
|
return;
|
|
442
444
|
let tokens;
|
|
@@ -446,6 +448,7 @@ export class CredentialPool {
|
|
|
446
448
|
clientId,
|
|
447
449
|
refreshToken: existing.refreshToken,
|
|
448
450
|
tokenEndpoint,
|
|
451
|
+
bodyFormat,
|
|
449
452
|
});
|
|
450
453
|
}
|
|
451
454
|
catch {
|