comisai 1.0.11 → 1.0.12
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/node_modules/@comis/agent/dist/executor/pi-executor.d.ts +1 -4
- package/node_modules/@comis/agent/package.json +1 -1
- package/node_modules/@comis/channels/package.json +1 -1
- package/node_modules/@comis/cli/package.json +1 -1
- package/node_modules/@comis/core/package.json +1 -1
- package/node_modules/@comis/daemon/package.json +1 -1
- package/node_modules/@comis/gateway/package.json +1 -1
- package/node_modules/@comis/infra/package.json +1 -1
- package/node_modules/@comis/memory/package.json +1 -1
- package/node_modules/@comis/scheduler/package.json +1 -1
- package/node_modules/@comis/shared/package.json +1 -1
- package/node_modules/@comis/skills/package.json +1 -1
- package/package.json +18 -18
- package/node_modules/@comis/core/dist/approval/approval-gate.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/approval/approval-gate.test.js +0 -1003
- package/node_modules/@comis/core/dist/bootstrap.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/bootstrap.test.js +0 -150
- package/node_modules/@comis/core/dist/config/backup.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/backup.test.js +0 -160
- package/node_modules/@comis/core/dist/config/env-substitution.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/env-substitution.test.js +0 -259
- package/node_modules/@comis/core/dist/config/field-metadata.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/field-metadata.test.js +0 -72
- package/node_modules/@comis/core/dist/config/git-manager.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/git-manager.test.js +0 -1042
- package/node_modules/@comis/core/dist/config/immutable-keys.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/immutable-keys.test.js +0 -283
- package/node_modules/@comis/core/dist/config/include-resolver.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/include-resolver.test.js +0 -292
- package/node_modules/@comis/core/dist/config/layered.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/layered.test.js +0 -211
- package/node_modules/@comis/core/dist/config/loader.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/loader.test.js +0 -300
- package/node_modules/@comis/core/dist/config/migrate.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/migrate.test.js +0 -244
- package/node_modules/@comis/core/dist/config/partial-validator.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/partial-validator.test.js +0 -98
- package/node_modules/@comis/core/dist/config/schema-agent-model.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-agent-model.test.js +0 -279
- package/node_modules/@comis/core/dist/config/schema-agent-session.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-agent-session.test.js +0 -242
- package/node_modules/@comis/core/dist/config/schema-agent.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-agent.test.js +0 -645
- package/node_modules/@comis/core/dist/config/schema-channel.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-channel.test.js +0 -341
- package/node_modules/@comis/core/dist/config/schema-coalescer.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-coalescer.test.js +0 -51
- package/node_modules/@comis/core/dist/config/schema-context-engine.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-context-engine.test.js +0 -797
- package/node_modules/@comis/core/dist/config/schema-context-guard.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-context-guard.test.js +0 -111
- package/node_modules/@comis/core/dist/config/schema-daemon.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-daemon.test.js +0 -107
- package/node_modules/@comis/core/dist/config/schema-delivery-timing.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-delivery-timing.test.js +0 -51
- package/node_modules/@comis/core/dist/config/schema-documentation.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-documentation.test.js +0 -63
- package/node_modules/@comis/core/dist/config/schema-gateway.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-gateway.test.js +0 -219
- package/node_modules/@comis/core/dist/config/schema-gemini-cache.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-gemini-cache.test.js +0 -41
- package/node_modules/@comis/core/dist/config/schema-integrations.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-integrations.test.js +0 -92
- package/node_modules/@comis/core/dist/config/schema-lifecycle-reactions.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-lifecycle-reactions.test.js +0 -61
- package/node_modules/@comis/core/dist/config/schema-misc.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-misc.test.js +0 -394
- package/node_modules/@comis/core/dist/config/schema-observability.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-observability.test.js +0 -76
- package/node_modules/@comis/core/dist/config/schema-providers.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-providers.test.js +0 -294
- package/node_modules/@comis/core/dist/config/schema-queue.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-queue.test.js +0 -234
- package/node_modules/@comis/core/dist/config/schema-response-prefix.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-response-prefix.test.js +0 -36
- package/node_modules/@comis/core/dist/config/schema-security.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-security.test.js +0 -54
- package/node_modules/@comis/core/dist/config/schema-sender-trust-display.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-sender-trust-display.test.js +0 -60
- package/node_modules/@comis/core/dist/config/schema-serializer.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-serializer.test.js +0 -73
- package/node_modules/@comis/core/dist/config/schema-telegram-file-guard.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/config/schema-telegram-file-guard.test.js +0 -39
- package/node_modules/@comis/core/dist/context/context.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/context/context.test.js +0 -276
- package/node_modules/@comis/core/dist/domain/agent-response.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/domain/agent-response.test.js +0 -159
- package/node_modules/@comis/core/dist/domain/credential-mapping.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/domain/credential-mapping.test.js +0 -135
- package/node_modules/@comis/core/dist/domain/delivery-origin.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/domain/delivery-origin.test.js +0 -68
- package/node_modules/@comis/core/dist/domain/execution-graph.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/domain/execution-graph.test.js +0 -441
- package/node_modules/@comis/core/dist/domain/memory-entry.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/domain/memory-entry.test.js +0 -193
- package/node_modules/@comis/core/dist/domain/normalized-message.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/domain/normalized-message.test.js +0 -255
- package/node_modules/@comis/core/dist/domain/session-key.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/domain/session-key.test.js +0 -291
- package/node_modules/@comis/core/dist/domain/subagent-context-config.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/domain/subagent-context-config.test.js +0 -131
- package/node_modules/@comis/core/dist/domain/subagent-context-types.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/domain/subagent-context-types.test.js +0 -182
- package/node_modules/@comis/core/dist/event-bus/bus.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/event-bus/bus.test.js +0 -152
- package/node_modules/@comis/core/dist/event-bus/events-agent.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/event-bus/events-agent.test.js +0 -409
- package/node_modules/@comis/core/dist/event-bus/events-channel.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/event-bus/events-channel.test.js +0 -240
- package/node_modules/@comis/core/dist/event-bus/events-infra.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/event-bus/events-infra.test.js +0 -416
- package/node_modules/@comis/core/dist/event-bus/events-messaging.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/event-bus/events-messaging.test.js +0 -433
- package/node_modules/@comis/core/dist/event-bus/events.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/event-bus/events.test.js +0 -93
- package/node_modules/@comis/core/dist/hooks/hook-runner-global.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/hooks/hook-runner-global.test.js +0 -29
- package/node_modules/@comis/core/dist/hooks/hook-runner.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/hooks/hook-runner.test.js +0 -490
- package/node_modules/@comis/core/dist/hooks/hook-strategies.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/hooks/hook-strategies.test.js +0 -209
- package/node_modules/@comis/core/dist/hooks/integration.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/hooks/integration.test.js +0 -235
- package/node_modules/@comis/core/dist/hooks/plugin-registry.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/hooks/plugin-registry.test.js +0 -470
- package/node_modules/@comis/core/dist/load-env.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/load-env.test.js +0 -21
- package/node_modules/@comis/core/dist/security/action-classifier.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/security/action-classifier.test.js +0 -298
- package/node_modules/@comis/core/dist/security/audit-aggregator.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/security/audit-aggregator.test.js +0 -128
- package/node_modules/@comis/core/dist/security/audit.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/security/audit.test.js +0 -154
- package/node_modules/@comis/core/dist/security/canary-token.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/security/canary-token.test.js +0 -45
- package/node_modules/@comis/core/dist/security/config-redaction.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/security/config-redaction.test.js +0 -107
- package/node_modules/@comis/core/dist/security/external-content.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/security/external-content.test.js +0 -210
- package/node_modules/@comis/core/dist/security/injection-patterns.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/security/injection-patterns.test.js +0 -213
- package/node_modules/@comis/core/dist/security/injection-rate-limiter.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/security/injection-rate-limiter.test.js +0 -194
- package/node_modules/@comis/core/dist/security/input-guard.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/security/input-guard.test.js +0 -215
- package/node_modules/@comis/core/dist/security/input-security-guard.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/security/input-security-guard.test.js +0 -215
- package/node_modules/@comis/core/dist/security/input-validator.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/security/input-validator.test.js +0 -133
- package/node_modules/@comis/core/dist/security/log-sanitizer.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/security/log-sanitizer.test.js +0 -260
- package/node_modules/@comis/core/dist/security/memory-write-validator.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/security/memory-write-validator.test.js +0 -62
- package/node_modules/@comis/core/dist/security/output-guard.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/security/output-guard.test.js +0 -397
- package/node_modules/@comis/core/dist/security/safe-path.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/security/safe-path.test.js +0 -95
- package/node_modules/@comis/core/dist/security/scoped-secret-manager.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/security/scoped-secret-manager.test.js +0 -231
- package/node_modules/@comis/core/dist/security/secret-access.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/security/secret-access.test.js +0 -41
- package/node_modules/@comis/core/dist/security/secret-crypto.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/security/secret-crypto.test.js +0 -113
- package/node_modules/@comis/core/dist/security/secret-manager.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/security/secret-manager.test.js +0 -394
- package/node_modules/@comis/core/dist/security/secret-ref-resolver.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/security/secret-ref-resolver.test.js +0 -268
- package/node_modules/@comis/core/dist/security/secrets-audit.test.d.ts +0 -10
- package/node_modules/@comis/core/dist/security/secrets-audit.test.js +0 -295
- package/node_modules/@comis/core/dist/security/ssrf-guard.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/security/ssrf-guard.test.js +0 -127
- package/node_modules/@comis/core/dist/security/token-generator.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/security/token-generator.test.js +0 -35
- package/node_modules/@comis/core/dist/tool-metadata.test.d.ts +0 -1
- package/node_modules/@comis/core/dist/tool-metadata.test.js +0 -112
- package/node_modules/@comis/memory/dist/compaction.test.d.ts +0 -1
- package/node_modules/@comis/memory/dist/compaction.test.js +0 -298
- package/node_modules/@comis/memory/dist/context-schema.test.d.ts +0 -1
- package/node_modules/@comis/memory/dist/context-schema.test.js +0 -246
- package/node_modules/@comis/memory/dist/context-store.test.d.ts +0 -1
- package/node_modules/@comis/memory/dist/context-store.test.js +0 -708
- package/node_modules/@comis/memory/dist/credential-mapping-schema.test.d.ts +0 -7
- package/node_modules/@comis/memory/dist/credential-mapping-schema.test.js +0 -73
- package/node_modules/@comis/memory/dist/credential-mapping-store.test.d.ts +0 -8
- package/node_modules/@comis/memory/dist/credential-mapping-store.test.js +0 -340
- package/node_modules/@comis/memory/dist/delivery-mirror-adapter.test.d.ts +0 -1
- package/node_modules/@comis/memory/dist/delivery-mirror-adapter.test.js +0 -165
- package/node_modules/@comis/memory/dist/delivery-queue-adapter.test.d.ts +0 -1
- package/node_modules/@comis/memory/dist/delivery-queue-adapter.test.js +0 -263
- package/node_modules/@comis/memory/dist/embedding-batch-indexer.test.d.ts +0 -1
- package/node_modules/@comis/memory/dist/embedding-batch-indexer.test.js +0 -202
- package/node_modules/@comis/memory/dist/embedding-cache-lru.test.d.ts +0 -1
- package/node_modules/@comis/memory/dist/embedding-cache-lru.test.js +0 -241
- package/node_modules/@comis/memory/dist/embedding-cache-sqlite.test.d.ts +0 -8
- package/node_modules/@comis/memory/dist/embedding-cache-sqlite.test.js +0 -678
- package/node_modules/@comis/memory/dist/embedding-cache.test.d.ts +0 -1
- package/node_modules/@comis/memory/dist/embedding-cache.test.js +0 -213
- package/node_modules/@comis/memory/dist/embedding-fingerprint.test.d.ts +0 -1
- package/node_modules/@comis/memory/dist/embedding-fingerprint.test.js +0 -87
- package/node_modules/@comis/memory/dist/embedding-hash.test.d.ts +0 -1
- package/node_modules/@comis/memory/dist/embedding-hash.test.js +0 -31
- package/node_modules/@comis/memory/dist/embedding-integration.test.d.ts +0 -8
- package/node_modules/@comis/memory/dist/embedding-integration.test.js +0 -232
- package/node_modules/@comis/memory/dist/embedding-provider-factory.test.d.ts +0 -1
- package/node_modules/@comis/memory/dist/embedding-provider-factory.test.js +0 -176
- package/node_modules/@comis/memory/dist/embedding-provider-local.test.d.ts +0 -8
- package/node_modules/@comis/memory/dist/embedding-provider-local.test.js +0 -76
- package/node_modules/@comis/memory/dist/embedding-provider-openai.test.d.ts +0 -8
- package/node_modules/@comis/memory/dist/embedding-provider-openai.test.js +0 -100
- package/node_modules/@comis/memory/dist/embedding-queue.test.d.ts +0 -1
- package/node_modules/@comis/memory/dist/embedding-queue.test.js +0 -236
- package/node_modules/@comis/memory/dist/hybrid-search.test.d.ts +0 -1
- package/node_modules/@comis/memory/dist/hybrid-search.test.js +0 -476
- package/node_modules/@comis/memory/dist/identity-link-store.test.d.ts +0 -1
- package/node_modules/@comis/memory/dist/identity-link-store.test.js +0 -88
- package/node_modules/@comis/memory/dist/memory-api.test.d.ts +0 -1
- package/node_modules/@comis/memory/dist/memory-api.test.js +0 -495
- package/node_modules/@comis/memory/dist/memory-concurrency.test.d.ts +0 -20
- package/node_modules/@comis/memory/dist/memory-concurrency.test.js +0 -222
- package/node_modules/@comis/memory/dist/named-graph-store.test.d.ts +0 -1
- package/node_modules/@comis/memory/dist/named-graph-store.test.js +0 -227
- package/node_modules/@comis/memory/dist/observability-store.test.d.ts +0 -1
- package/node_modules/@comis/memory/dist/observability-store.test.js +0 -704
- package/node_modules/@comis/memory/dist/row-mapper.test.d.ts +0 -1
- package/node_modules/@comis/memory/dist/row-mapper.test.js +0 -409
- package/node_modules/@comis/memory/dist/schema.test.d.ts +0 -1
- package/node_modules/@comis/memory/dist/schema.test.js +0 -240
- package/node_modules/@comis/memory/dist/secret-store-schema.test.d.ts +0 -7
- package/node_modules/@comis/memory/dist/secret-store-schema.test.js +0 -90
- package/node_modules/@comis/memory/dist/session-store.test.d.ts +0 -1
- package/node_modules/@comis/memory/dist/session-store.test.js +0 -262
- package/node_modules/@comis/memory/dist/setup-secrets.test.d.ts +0 -1
- package/node_modules/@comis/memory/dist/setup-secrets.test.js +0 -140
- package/node_modules/@comis/memory/dist/sqlite-memory-adapter.test.d.ts +0 -1
- package/node_modules/@comis/memory/dist/sqlite-memory-adapter.test.js +0 -888
- package/node_modules/@comis/memory/dist/sqlite-secret-store.test.d.ts +0 -8
- package/node_modules/@comis/memory/dist/sqlite-secret-store.test.js +0 -245
- package/node_modules/@comis/shared/dist/abort.test.d.ts +0 -1
- package/node_modules/@comis/shared/dist/abort.test.js +0 -71
- package/node_modules/@comis/shared/dist/result.test.d.ts +0 -1
- package/node_modules/@comis/shared/dist/result.test.js +0 -178
- package/node_modules/@comis/shared/dist/suppress-error.test.d.ts +0 -1
- package/node_modules/@comis/shared/dist/suppress-error.test.js +0 -50
- package/node_modules/@comis/shared/dist/timeout.test.d.ts +0 -1
- package/node_modules/@comis/shared/dist/timeout.test.js +0 -75
- package/node_modules/@comis/shared/dist/ttl-cache.test.d.ts +0 -1
- package/node_modules/@comis/shared/dist/ttl-cache.test.js +0 -81
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { migrateConfig } from "./migrate.js";
|
|
3
|
-
describe("config/migrate", () => {
|
|
4
|
-
// -----------------------------------------------------------------------
|
|
5
|
-
// Passthrough (no legacy keys)
|
|
6
|
-
// -----------------------------------------------------------------------
|
|
7
|
-
it("passes through config with no legacy keys unchanged", () => {
|
|
8
|
-
const input = {
|
|
9
|
-
tenantId: "test",
|
|
10
|
-
streaming: {
|
|
11
|
-
enabled: true,
|
|
12
|
-
defaultDeliveryTiming: { mode: "natural", minMs: 800, maxMs: 2500 },
|
|
13
|
-
defaultCoalescer: { maxChars: 500 },
|
|
14
|
-
perChannel: {
|
|
15
|
-
telegram: {
|
|
16
|
-
enabled: true,
|
|
17
|
-
deliveryTiming: { mode: "adaptive" },
|
|
18
|
-
coalescer: { maxChars: 800 },
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
const result = migrateConfig(input);
|
|
24
|
-
expect(result).toEqual(input);
|
|
25
|
-
});
|
|
26
|
-
it("handles config with no streaming section", () => {
|
|
27
|
-
const input = { tenantId: "bare" };
|
|
28
|
-
const result = migrateConfig(input);
|
|
29
|
-
expect(result).toEqual({ tenantId: "bare" });
|
|
30
|
-
});
|
|
31
|
-
it("handles empty streaming config", () => {
|
|
32
|
-
const input = { streaming: {} };
|
|
33
|
-
const result = migrateConfig(input);
|
|
34
|
-
expect(result).toEqual({ streaming: {} });
|
|
35
|
-
});
|
|
36
|
-
// -----------------------------------------------------------------------
|
|
37
|
-
// Per-channel migration
|
|
38
|
-
// -----------------------------------------------------------------------
|
|
39
|
-
it("migrates per-channel pacingMinMs/pacingMaxMs to deliveryTiming", () => {
|
|
40
|
-
const input = {
|
|
41
|
-
streaming: {
|
|
42
|
-
perChannel: {
|
|
43
|
-
telegram: {
|
|
44
|
-
enabled: true,
|
|
45
|
-
pacingMinMs: 500,
|
|
46
|
-
pacingMaxMs: 1500,
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
const result = migrateConfig(input);
|
|
52
|
-
const telegram = result.streaming.perChannel.telegram;
|
|
53
|
-
expect(telegram.deliveryTiming).toEqual({ minMs: 500, maxMs: 1500 });
|
|
54
|
-
expect(telegram.pacingMinMs).toBeUndefined();
|
|
55
|
-
expect(telegram.pacingMaxMs).toBeUndefined();
|
|
56
|
-
expect(telegram.enabled).toBe(true);
|
|
57
|
-
});
|
|
58
|
-
it("migrates per-channel coalesceMaxChars to coalescer.maxChars", () => {
|
|
59
|
-
const input = {
|
|
60
|
-
streaming: {
|
|
61
|
-
perChannel: {
|
|
62
|
-
discord: {
|
|
63
|
-
enabled: true,
|
|
64
|
-
coalesceMaxChars: 300,
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
const result = migrateConfig(input);
|
|
70
|
-
const discord = result.streaming.perChannel.discord;
|
|
71
|
-
expect(discord.coalescer).toEqual({ maxChars: 300 });
|
|
72
|
-
expect(discord.coalesceMaxChars).toBeUndefined();
|
|
73
|
-
});
|
|
74
|
-
// -----------------------------------------------------------------------
|
|
75
|
-
// Root-level migration
|
|
76
|
-
// -----------------------------------------------------------------------
|
|
77
|
-
it("migrates root defaultPacingMinMs/defaultPacingMaxMs to defaultDeliveryTiming", () => {
|
|
78
|
-
const input = {
|
|
79
|
-
streaming: {
|
|
80
|
-
defaultPacingMinMs: 600,
|
|
81
|
-
defaultPacingMaxMs: 2000,
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
const result = migrateConfig(input);
|
|
85
|
-
const streaming = result.streaming;
|
|
86
|
-
expect(streaming.defaultDeliveryTiming).toEqual({ minMs: 600, maxMs: 2000 });
|
|
87
|
-
expect(streaming.defaultPacingMinMs).toBeUndefined();
|
|
88
|
-
expect(streaming.defaultPacingMaxMs).toBeUndefined();
|
|
89
|
-
});
|
|
90
|
-
// -----------------------------------------------------------------------
|
|
91
|
-
// Partial migration (only some legacy keys present)
|
|
92
|
-
// -----------------------------------------------------------------------
|
|
93
|
-
it("handles partial migration (only some legacy keys present)", () => {
|
|
94
|
-
const input = {
|
|
95
|
-
streaming: {
|
|
96
|
-
perChannel: {
|
|
97
|
-
telegram: {
|
|
98
|
-
enabled: true,
|
|
99
|
-
pacingMinMs: 400,
|
|
100
|
-
// pacingMaxMs is absent
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
const result = migrateConfig(input);
|
|
106
|
-
const telegram = result.streaming.perChannel.telegram;
|
|
107
|
-
expect(telegram.deliveryTiming).toEqual({ minMs: 400 });
|
|
108
|
-
expect(telegram.pacingMinMs).toBeUndefined();
|
|
109
|
-
// pacingMaxMs was never set, so deliveryTiming has no maxMs
|
|
110
|
-
expect(telegram.deliveryTiming.maxMs).toBeUndefined();
|
|
111
|
-
});
|
|
112
|
-
it("handles partial root migration (only defaultPacingMinMs present)", () => {
|
|
113
|
-
const input = {
|
|
114
|
-
streaming: {
|
|
115
|
-
defaultPacingMinMs: 300,
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
const result = migrateConfig(input);
|
|
119
|
-
const streaming = result.streaming;
|
|
120
|
-
expect(streaming.defaultDeliveryTiming).toEqual({ minMs: 300 });
|
|
121
|
-
expect(streaming.defaultPacingMinMs).toBeUndefined();
|
|
122
|
-
expect(streaming.defaultPacingMaxMs).toBeUndefined();
|
|
123
|
-
});
|
|
124
|
-
// -----------------------------------------------------------------------
|
|
125
|
-
// Preservation (does NOT overwrite existing nested objects)
|
|
126
|
-
// -----------------------------------------------------------------------
|
|
127
|
-
it("does NOT overwrite existing deliveryTiming object", () => {
|
|
128
|
-
const input = {
|
|
129
|
-
streaming: {
|
|
130
|
-
perChannel: {
|
|
131
|
-
telegram: {
|
|
132
|
-
enabled: true,
|
|
133
|
-
pacingMinMs: 100,
|
|
134
|
-
pacingMaxMs: 200,
|
|
135
|
-
deliveryTiming: { mode: "adaptive", minMs: 999, maxMs: 1999 },
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
};
|
|
140
|
-
const result = migrateConfig(input);
|
|
141
|
-
const telegram = result.streaming.perChannel.telegram;
|
|
142
|
-
// Existing deliveryTiming preserved, legacy values ignored
|
|
143
|
-
expect(telegram.deliveryTiming).toEqual({ mode: "adaptive", minMs: 999, maxMs: 1999 });
|
|
144
|
-
// Legacy keys are still deleted
|
|
145
|
-
expect(telegram.pacingMinMs).toBeUndefined();
|
|
146
|
-
expect(telegram.pacingMaxMs).toBeUndefined();
|
|
147
|
-
});
|
|
148
|
-
it("does NOT overwrite existing coalescer object", () => {
|
|
149
|
-
const input = {
|
|
150
|
-
streaming: {
|
|
151
|
-
perChannel: {
|
|
152
|
-
discord: {
|
|
153
|
-
enabled: true,
|
|
154
|
-
coalesceMaxChars: 200,
|
|
155
|
-
coalescer: { maxChars: 888, idleMs: 2000 },
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
};
|
|
160
|
-
const result = migrateConfig(input);
|
|
161
|
-
const discord = result.streaming.perChannel.discord;
|
|
162
|
-
// Existing coalescer preserved, legacy value ignored
|
|
163
|
-
expect(discord.coalescer).toEqual({ maxChars: 888, idleMs: 2000 });
|
|
164
|
-
expect(discord.coalesceMaxChars).toBeUndefined();
|
|
165
|
-
});
|
|
166
|
-
it("does NOT overwrite existing root defaultDeliveryTiming object", () => {
|
|
167
|
-
const input = {
|
|
168
|
-
streaming: {
|
|
169
|
-
defaultPacingMinMs: 100,
|
|
170
|
-
defaultPacingMaxMs: 200,
|
|
171
|
-
defaultDeliveryTiming: { mode: "off" },
|
|
172
|
-
},
|
|
173
|
-
};
|
|
174
|
-
const result = migrateConfig(input);
|
|
175
|
-
const streaming = result.streaming;
|
|
176
|
-
expect(streaming.defaultDeliveryTiming).toEqual({ mode: "off" });
|
|
177
|
-
expect(streaming.defaultPacingMinMs).toBeUndefined();
|
|
178
|
-
expect(streaming.defaultPacingMaxMs).toBeUndefined();
|
|
179
|
-
});
|
|
180
|
-
// -----------------------------------------------------------------------
|
|
181
|
-
// Multiple per-channel entries
|
|
182
|
-
// -----------------------------------------------------------------------
|
|
183
|
-
it("migrates multiple per-channel entries independently", () => {
|
|
184
|
-
const input = {
|
|
185
|
-
streaming: {
|
|
186
|
-
perChannel: {
|
|
187
|
-
telegram: {
|
|
188
|
-
enabled: true,
|
|
189
|
-
pacingMinMs: 500,
|
|
190
|
-
pacingMaxMs: 1500,
|
|
191
|
-
coalesceMaxChars: 300,
|
|
192
|
-
},
|
|
193
|
-
discord: {
|
|
194
|
-
enabled: true,
|
|
195
|
-
deliveryTiming: { mode: "adaptive" },
|
|
196
|
-
coalescer: { maxChars: 800 },
|
|
197
|
-
},
|
|
198
|
-
slack: {
|
|
199
|
-
enabled: false,
|
|
200
|
-
pacingMinMs: 100,
|
|
201
|
-
coalesceMaxChars: 400,
|
|
202
|
-
},
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
};
|
|
206
|
-
const result = migrateConfig(input);
|
|
207
|
-
const perChannel = result.streaming.perChannel;
|
|
208
|
-
// telegram: fully migrated
|
|
209
|
-
expect(perChannel.telegram.deliveryTiming).toEqual({ minMs: 500, maxMs: 1500 });
|
|
210
|
-
expect(perChannel.telegram.coalescer).toEqual({ maxChars: 300 });
|
|
211
|
-
expect(perChannel.telegram.pacingMinMs).toBeUndefined();
|
|
212
|
-
expect(perChannel.telegram.pacingMaxMs).toBeUndefined();
|
|
213
|
-
expect(perChannel.telegram.coalesceMaxChars).toBeUndefined();
|
|
214
|
-
// discord: already migrated, untouched
|
|
215
|
-
expect(perChannel.discord.deliveryTiming).toEqual({ mode: "adaptive" });
|
|
216
|
-
expect(perChannel.discord.coalescer).toEqual({ maxChars: 800 });
|
|
217
|
-
// slack: partially migrated (pacingMinMs only, no pacingMaxMs)
|
|
218
|
-
expect(perChannel.slack.deliveryTiming).toEqual({ minMs: 100 });
|
|
219
|
-
expect(perChannel.slack.coalescer).toEqual({ maxChars: 400 });
|
|
220
|
-
expect(perChannel.slack.pacingMinMs).toBeUndefined();
|
|
221
|
-
expect(perChannel.slack.coalesceMaxChars).toBeUndefined();
|
|
222
|
-
expect(perChannel.slack.enabled).toBe(false);
|
|
223
|
-
});
|
|
224
|
-
// -----------------------------------------------------------------------
|
|
225
|
-
// Input immutability
|
|
226
|
-
// -----------------------------------------------------------------------
|
|
227
|
-
it("does not mutate the original input object", () => {
|
|
228
|
-
const input = {
|
|
229
|
-
streaming: {
|
|
230
|
-
defaultPacingMinMs: 600,
|
|
231
|
-
perChannel: {
|
|
232
|
-
telegram: {
|
|
233
|
-
pacingMinMs: 500,
|
|
234
|
-
pacingMaxMs: 1500,
|
|
235
|
-
},
|
|
236
|
-
},
|
|
237
|
-
},
|
|
238
|
-
};
|
|
239
|
-
const inputCopy = JSON.parse(JSON.stringify(input));
|
|
240
|
-
migrateConfig(input);
|
|
241
|
-
// Original unchanged
|
|
242
|
-
expect(input).toEqual(inputCopy);
|
|
243
|
-
});
|
|
244
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { validatePartial } from "./partial-validator.js";
|
|
3
|
-
describe("config/partial-validator", () => {
|
|
4
|
-
describe("validatePartial", () => {
|
|
5
|
-
it("valid config returns all sections with no errors", () => {
|
|
6
|
-
const raw = {
|
|
7
|
-
tenantId: "my-tenant",
|
|
8
|
-
logLevel: "info",
|
|
9
|
-
dataDir: "/data",
|
|
10
|
-
security: {},
|
|
11
|
-
gateway: {},
|
|
12
|
-
};
|
|
13
|
-
const result = validatePartial(raw);
|
|
14
|
-
expect(result.errors).toHaveLength(0);
|
|
15
|
-
expect(result.validSections).toContain("tenantId");
|
|
16
|
-
expect(result.validSections).toContain("logLevel");
|
|
17
|
-
expect(result.validSections).toContain("dataDir");
|
|
18
|
-
expect(result.validSections).toContain("security");
|
|
19
|
-
expect(result.validSections).toContain("gateway");
|
|
20
|
-
expect(result.config.tenantId).toBe("my-tenant");
|
|
21
|
-
expect(result.config.logLevel).toBe("info");
|
|
22
|
-
expect(result.config.dataDir).toBe("/data");
|
|
23
|
-
});
|
|
24
|
-
it("one invalid section returns error for that section, other sections are valid with defaults", () => {
|
|
25
|
-
const raw = {
|
|
26
|
-
tenantId: "my-tenant",
|
|
27
|
-
logLevel: "info",
|
|
28
|
-
// security expects an object, not a string
|
|
29
|
-
security: "invalid-value",
|
|
30
|
-
gateway: {},
|
|
31
|
-
};
|
|
32
|
-
const result = validatePartial(raw);
|
|
33
|
-
// security should be in errors
|
|
34
|
-
const securityError = result.errors.find((e) => e.section === "security");
|
|
35
|
-
expect(securityError).toBeDefined();
|
|
36
|
-
expect(securityError.error.code).toBe("VALIDATION_ERROR");
|
|
37
|
-
// Valid sections should still be present
|
|
38
|
-
expect(result.validSections).toContain("tenantId");
|
|
39
|
-
expect(result.validSections).toContain("logLevel");
|
|
40
|
-
expect(result.validSections).toContain("gateway");
|
|
41
|
-
expect(result.validSections).not.toContain("security");
|
|
42
|
-
expect(result.config.tenantId).toBe("my-tenant");
|
|
43
|
-
});
|
|
44
|
-
it("multiple invalid sections return multiple errors, all valid sections preserved", () => {
|
|
45
|
-
const raw = {
|
|
46
|
-
tenantId: "my-tenant",
|
|
47
|
-
security: "not-an-object",
|
|
48
|
-
gateway: "also-not-an-object",
|
|
49
|
-
memory: {},
|
|
50
|
-
};
|
|
51
|
-
const result = validatePartial(raw);
|
|
52
|
-
expect(result.errors.length).toBeGreaterThanOrEqual(2);
|
|
53
|
-
const errorSections = result.errors.map((e) => e.section);
|
|
54
|
-
expect(errorSections).toContain("security");
|
|
55
|
-
expect(errorSections).toContain("gateway");
|
|
56
|
-
// Valid sections preserved
|
|
57
|
-
expect(result.validSections).toContain("tenantId");
|
|
58
|
-
expect(result.validSections).toContain("memory");
|
|
59
|
-
expect(result.config.tenantId).toBe("my-tenant");
|
|
60
|
-
});
|
|
61
|
-
it("unknown top-level keys are ignored (not treated as errors)", () => {
|
|
62
|
-
const raw = {
|
|
63
|
-
tenantId: "my-tenant",
|
|
64
|
-
unknownKey: "should-be-ignored",
|
|
65
|
-
anotherUnknown: { nested: true },
|
|
66
|
-
};
|
|
67
|
-
const result = validatePartial(raw);
|
|
68
|
-
// Unknown keys should not appear in errors
|
|
69
|
-
const errorSections = result.errors.map((e) => e.section);
|
|
70
|
-
expect(errorSections).not.toContain("unknownKey");
|
|
71
|
-
expect(errorSections).not.toContain("anotherUnknown");
|
|
72
|
-
// Valid sections should still work
|
|
73
|
-
expect(result.validSections).toContain("tenantId");
|
|
74
|
-
});
|
|
75
|
-
it("scalar top-level fields (tenantId, logLevel, dataDir) are validated independently", () => {
|
|
76
|
-
const raw = {
|
|
77
|
-
tenantId: 12345, // Should be a string, not number
|
|
78
|
-
logLevel: "invalid-level", // Not a valid enum value
|
|
79
|
-
dataDir: "/data",
|
|
80
|
-
};
|
|
81
|
-
const result = validatePartial(raw);
|
|
82
|
-
// dataDir should be valid
|
|
83
|
-
expect(result.validSections).toContain("dataDir");
|
|
84
|
-
expect(result.config.dataDir).toBe("/data");
|
|
85
|
-
// tenantId and/or logLevel should have errors
|
|
86
|
-
expect(result.errors.length).toBeGreaterThanOrEqual(1);
|
|
87
|
-
const errorSections = result.errors.map((e) => e.section);
|
|
88
|
-
// At least logLevel should fail (invalid enum)
|
|
89
|
-
expect(errorSections).toContain("logLevel");
|
|
90
|
-
});
|
|
91
|
-
it("return type includes validSections, config, and errors arrays", () => {
|
|
92
|
-
const result = validatePartial({});
|
|
93
|
-
expect(Array.isArray(result.validSections)).toBe(true);
|
|
94
|
-
expect(typeof result.config).toBe("object");
|
|
95
|
-
expect(Array.isArray(result.errors)).toBe(true);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { BudgetConfigSchema, CircuitBreakerConfigSchema, ModelRoutesSchema, FallbackModelSchema, AuthProfileSchema, ModelFailoverConfigSchema, PromptTimeoutConfigSchema, OperationModelsSchema, } from "./schema-agent.js";
|
|
3
|
-
describe("BudgetConfigSchema", () => {
|
|
4
|
-
it("parses valid input with all fields", () => {
|
|
5
|
-
const result = BudgetConfigSchema.safeParse({
|
|
6
|
-
perExecution: 50_000,
|
|
7
|
-
perHour: 200_000,
|
|
8
|
-
perDay: 1_000_000,
|
|
9
|
-
});
|
|
10
|
-
expect(result.success).toBe(true);
|
|
11
|
-
if (result.success) {
|
|
12
|
-
expect(result.data.perExecution).toBe(50_000);
|
|
13
|
-
expect(result.data.perHour).toBe(200_000);
|
|
14
|
-
expect(result.data.perDay).toBe(1_000_000);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
it("applies correct defaults for empty object", () => {
|
|
18
|
-
const result = BudgetConfigSchema.parse({});
|
|
19
|
-
expect(result.perExecution).toBe(2_000_000);
|
|
20
|
-
expect(result.perHour).toBe(10_000_000);
|
|
21
|
-
expect(result.perDay).toBe(100_000_000);
|
|
22
|
-
});
|
|
23
|
-
it("rejects negative values", () => {
|
|
24
|
-
const result = BudgetConfigSchema.safeParse({ perExecution: -1 });
|
|
25
|
-
expect(result.success).toBe(false);
|
|
26
|
-
});
|
|
27
|
-
it("rejects zero values", () => {
|
|
28
|
-
const result = BudgetConfigSchema.safeParse({ perHour: 0 });
|
|
29
|
-
expect(result.success).toBe(false);
|
|
30
|
-
});
|
|
31
|
-
it("rejects non-integer values", () => {
|
|
32
|
-
const result = BudgetConfigSchema.safeParse({ perDay: 1.5 });
|
|
33
|
-
expect(result.success).toBe(false);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
describe("CircuitBreakerConfigSchema", () => {
|
|
37
|
-
it("parses valid input", () => {
|
|
38
|
-
const result = CircuitBreakerConfigSchema.safeParse({
|
|
39
|
-
failureThreshold: 3,
|
|
40
|
-
resetTimeoutMs: 30_000,
|
|
41
|
-
halfOpenTimeoutMs: 15_000,
|
|
42
|
-
});
|
|
43
|
-
expect(result.success).toBe(true);
|
|
44
|
-
if (result.success) {
|
|
45
|
-
expect(result.data.failureThreshold).toBe(3);
|
|
46
|
-
expect(result.data.resetTimeoutMs).toBe(30_000);
|
|
47
|
-
expect(result.data.halfOpenTimeoutMs).toBe(15_000);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
it("applies defaults for empty object", () => {
|
|
51
|
-
const result = CircuitBreakerConfigSchema.parse({});
|
|
52
|
-
expect(result.failureThreshold).toBe(5);
|
|
53
|
-
expect(result.resetTimeoutMs).toBe(60_000);
|
|
54
|
-
expect(result.halfOpenTimeoutMs).toBe(30_000);
|
|
55
|
-
});
|
|
56
|
-
it("rejects negative failureThreshold", () => {
|
|
57
|
-
const result = CircuitBreakerConfigSchema.safeParse({ failureThreshold: -1 });
|
|
58
|
-
expect(result.success).toBe(false);
|
|
59
|
-
});
|
|
60
|
-
it("rejects zero resetTimeoutMs", () => {
|
|
61
|
-
const result = CircuitBreakerConfigSchema.safeParse({ resetTimeoutMs: 0 });
|
|
62
|
-
expect(result.success).toBe(false);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
describe("ModelRoutesSchema", () => {
|
|
66
|
-
it("parses valid route mappings", () => {
|
|
67
|
-
const result = ModelRoutesSchema.safeParse({
|
|
68
|
-
default: "claude-sonnet-4-5-20250929",
|
|
69
|
-
summarization: "claude-haiku-3",
|
|
70
|
-
});
|
|
71
|
-
expect(result.success).toBe(true);
|
|
72
|
-
if (result.success) {
|
|
73
|
-
expect(result.data.default).toBe("claude-sonnet-4-5-20250929");
|
|
74
|
-
expect(result.data.summarization).toBe("claude-haiku-3");
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
it("defaults to empty object", () => {
|
|
78
|
-
const result = ModelRoutesSchema.parse(undefined);
|
|
79
|
-
expect(result).toEqual({});
|
|
80
|
-
});
|
|
81
|
-
it("allows empty object", () => {
|
|
82
|
-
const result = ModelRoutesSchema.safeParse({});
|
|
83
|
-
expect(result.success).toBe(true);
|
|
84
|
-
if (result.success) {
|
|
85
|
-
expect(result.data).toEqual({});
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
it("rejects empty string for default key", () => {
|
|
89
|
-
const result = ModelRoutesSchema.safeParse({ default: "" });
|
|
90
|
-
expect(result.success).toBe(false);
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
describe("FallbackModelSchema", () => {
|
|
94
|
-
it("parses valid fallback configuration", () => {
|
|
95
|
-
const result = FallbackModelSchema.safeParse({
|
|
96
|
-
provider: "openai",
|
|
97
|
-
modelId: "gpt-4o",
|
|
98
|
-
});
|
|
99
|
-
expect(result.success).toBe(true);
|
|
100
|
-
if (result.success) {
|
|
101
|
-
expect(result.data.provider).toBe("openai");
|
|
102
|
-
expect(result.data.modelId).toBe("gpt-4o");
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
it("requires provider field", () => {
|
|
106
|
-
const result = FallbackModelSchema.safeParse({ modelId: "gpt-4o" });
|
|
107
|
-
expect(result.success).toBe(false);
|
|
108
|
-
});
|
|
109
|
-
it("requires modelId field", () => {
|
|
110
|
-
const result = FallbackModelSchema.safeParse({ provider: "openai" });
|
|
111
|
-
expect(result.success).toBe(false);
|
|
112
|
-
});
|
|
113
|
-
it("rejects empty provider string", () => {
|
|
114
|
-
const result = FallbackModelSchema.safeParse({ provider: "", modelId: "gpt-4o" });
|
|
115
|
-
expect(result.success).toBe(false);
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
describe("AuthProfileSchema", () => {
|
|
119
|
-
it("parses valid auth profile entries", () => {
|
|
120
|
-
const result = AuthProfileSchema.safeParse({
|
|
121
|
-
keyName: "ANTHROPIC_API_KEY_2",
|
|
122
|
-
provider: "anthropic",
|
|
123
|
-
});
|
|
124
|
-
expect(result.success).toBe(true);
|
|
125
|
-
if (result.success) {
|
|
126
|
-
expect(result.data.keyName).toBe("ANTHROPIC_API_KEY_2");
|
|
127
|
-
expect(result.data.provider).toBe("anthropic");
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
it("requires keyName field", () => {
|
|
131
|
-
const result = AuthProfileSchema.safeParse({ provider: "anthropic" });
|
|
132
|
-
expect(result.success).toBe(false);
|
|
133
|
-
});
|
|
134
|
-
it("requires provider field", () => {
|
|
135
|
-
const result = AuthProfileSchema.safeParse({ keyName: "ANTHROPIC_API_KEY_2" });
|
|
136
|
-
expect(result.success).toBe(false);
|
|
137
|
-
});
|
|
138
|
-
it("rejects empty keyName string", () => {
|
|
139
|
-
const result = AuthProfileSchema.safeParse({ keyName: "", provider: "anthropic" });
|
|
140
|
-
expect(result.success).toBe(false);
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
describe("ModelFailoverConfigSchema", () => {
|
|
144
|
-
it("parses valid failover config with all fields", () => {
|
|
145
|
-
const result = ModelFailoverConfigSchema.safeParse({
|
|
146
|
-
fallbackModels: [{ provider: "openai", modelId: "gpt-4o" }],
|
|
147
|
-
authProfiles: [{ keyName: "KEY_2", provider: "anthropic" }],
|
|
148
|
-
allowedModels: ["claude-sonnet-4-5-20250929", "gpt-4o"],
|
|
149
|
-
maxAttempts: 3,
|
|
150
|
-
cooldownInitialMs: 30_000,
|
|
151
|
-
cooldownMultiplier: 2,
|
|
152
|
-
cooldownCapMs: 1_800_000,
|
|
153
|
-
});
|
|
154
|
-
expect(result.success).toBe(true);
|
|
155
|
-
if (result.success) {
|
|
156
|
-
expect(result.data.fallbackModels).toHaveLength(1);
|
|
157
|
-
expect(result.data.authProfiles).toHaveLength(1);
|
|
158
|
-
expect(result.data.allowedModels).toHaveLength(2);
|
|
159
|
-
expect(result.data.maxAttempts).toBe(3);
|
|
160
|
-
expect(result.data.cooldownMultiplier).toBe(2);
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
it("applies defaults for empty object", () => {
|
|
164
|
-
const result = ModelFailoverConfigSchema.parse({});
|
|
165
|
-
expect(result.fallbackModels).toEqual([]);
|
|
166
|
-
expect(result.authProfiles).toEqual([]);
|
|
167
|
-
expect(result.allowedModels).toEqual([]);
|
|
168
|
-
expect(result.maxAttempts).toBe(6);
|
|
169
|
-
expect(result.cooldownInitialMs).toBe(60_000);
|
|
170
|
-
expect(result.cooldownMultiplier).toBe(5);
|
|
171
|
-
expect(result.cooldownCapMs).toBe(3_600_000);
|
|
172
|
-
});
|
|
173
|
-
it("rejects negative maxAttempts", () => {
|
|
174
|
-
const result = ModelFailoverConfigSchema.safeParse({ maxAttempts: -1 });
|
|
175
|
-
expect(result.success).toBe(false);
|
|
176
|
-
});
|
|
177
|
-
it("rejects zero cooldownInitialMs", () => {
|
|
178
|
-
const result = ModelFailoverConfigSchema.safeParse({ cooldownInitialMs: 0 });
|
|
179
|
-
expect(result.success).toBe(false);
|
|
180
|
-
});
|
|
181
|
-
it("round-trip: parse then re-parse produces identical result", () => {
|
|
182
|
-
const first = ModelFailoverConfigSchema.parse({
|
|
183
|
-
fallbackModels: [{ provider: "openai", modelId: "gpt-4o" }],
|
|
184
|
-
maxAttempts: 4,
|
|
185
|
-
});
|
|
186
|
-
const second = ModelFailoverConfigSchema.parse(first);
|
|
187
|
-
expect(second).toEqual(first);
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
describe("PromptTimeoutConfigSchema", () => {
|
|
191
|
-
it("applies defaults for empty object", () => {
|
|
192
|
-
const result = PromptTimeoutConfigSchema.parse({});
|
|
193
|
-
expect(result.promptTimeoutMs).toBe(180_000);
|
|
194
|
-
expect(result.retryPromptTimeoutMs).toBe(60_000);
|
|
195
|
-
});
|
|
196
|
-
it("rejects negative values", () => {
|
|
197
|
-
const result = PromptTimeoutConfigSchema.safeParse({ promptTimeoutMs: -1 });
|
|
198
|
-
expect(result.success).toBe(false);
|
|
199
|
-
});
|
|
200
|
-
it("rejects zero values", () => {
|
|
201
|
-
const result = PromptTimeoutConfigSchema.safeParse({ promptTimeoutMs: 0 });
|
|
202
|
-
expect(result.success).toBe(false);
|
|
203
|
-
});
|
|
204
|
-
it("rejects non-integer values", () => {
|
|
205
|
-
const result = PromptTimeoutConfigSchema.safeParse({ promptTimeoutMs: 1.5 });
|
|
206
|
-
expect(result.success).toBe(false);
|
|
207
|
-
});
|
|
208
|
-
it("accepts custom positive integers", () => {
|
|
209
|
-
const result = PromptTimeoutConfigSchema.safeParse({
|
|
210
|
-
promptTimeoutMs: 300_000,
|
|
211
|
-
retryPromptTimeoutMs: 120_000,
|
|
212
|
-
});
|
|
213
|
-
expect(result.success).toBe(true);
|
|
214
|
-
if (result.success) {
|
|
215
|
-
expect(result.data.promptTimeoutMs).toBe(300_000);
|
|
216
|
-
expect(result.data.retryPromptTimeoutMs).toBe(120_000);
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
describe("OperationModelsSchema", () => {
|
|
221
|
-
it("defaults to empty object when not provided", () => {
|
|
222
|
-
const result = OperationModelsSchema.parse(undefined);
|
|
223
|
-
expect(result).toEqual({});
|
|
224
|
-
});
|
|
225
|
-
it("parses empty object (all fields optional)", () => {
|
|
226
|
-
const result = OperationModelsSchema.parse({});
|
|
227
|
-
expect(result).toEqual({});
|
|
228
|
-
});
|
|
229
|
-
it("parses a valid operationModels block with model and timeout fields", () => {
|
|
230
|
-
const result = OperationModelsSchema.parse({
|
|
231
|
-
cron: "anthropic:claude-haiku-4-5",
|
|
232
|
-
cronTimeout: 150_000,
|
|
233
|
-
});
|
|
234
|
-
expect(result.cron).toBe("anthropic:claude-haiku-4-5");
|
|
235
|
-
expect(result.cronTimeout).toBe(150_000);
|
|
236
|
-
});
|
|
237
|
-
it("accepts 'primary' keyword as a model value", () => {
|
|
238
|
-
const result = OperationModelsSchema.parse({ heartbeat: "primary" });
|
|
239
|
-
expect(result.heartbeat).toBe("primary");
|
|
240
|
-
});
|
|
241
|
-
it("rejects unknown keys (z.strictObject behavior)", () => {
|
|
242
|
-
const result = OperationModelsSchema.safeParse({ interactive: "model" });
|
|
243
|
-
expect(result.success).toBe(false);
|
|
244
|
-
});
|
|
245
|
-
it("rejects invalid timeout (negative value)", () => {
|
|
246
|
-
const result = OperationModelsSchema.safeParse({ cronTimeout: -1 });
|
|
247
|
-
expect(result.success).toBe(false);
|
|
248
|
-
});
|
|
249
|
-
it("rejects zero timeout", () => {
|
|
250
|
-
const result = OperationModelsSchema.safeParse({ cronTimeout: 0 });
|
|
251
|
-
expect(result.success).toBe(false);
|
|
252
|
-
});
|
|
253
|
-
it("rejects non-integer timeout", () => {
|
|
254
|
-
const result = OperationModelsSchema.safeParse({ heartbeatTimeout: 1.5 });
|
|
255
|
-
expect(result.success).toBe(false);
|
|
256
|
-
});
|
|
257
|
-
it("rejects empty string model", () => {
|
|
258
|
-
const result = OperationModelsSchema.safeParse({ cron: "" });
|
|
259
|
-
expect(result.success).toBe(false);
|
|
260
|
-
});
|
|
261
|
-
it("parses all 12 fields correctly (6 model strings + 6 timeout numbers)", () => {
|
|
262
|
-
const input = {
|
|
263
|
-
cron: "anthropic:claude-haiku-4-5",
|
|
264
|
-
cronTimeout: 150_000,
|
|
265
|
-
heartbeat: "anthropic:claude-haiku-4-5",
|
|
266
|
-
heartbeatTimeout: 60_000,
|
|
267
|
-
subagent: "primary",
|
|
268
|
-
subagentTimeout: 180_000,
|
|
269
|
-
compaction: "anthropic:claude-haiku-4-5",
|
|
270
|
-
compactionTimeout: 60_000,
|
|
271
|
-
taskExtraction: "anthropic:claude-haiku-4-5",
|
|
272
|
-
taskExtractionTimeout: 30_000,
|
|
273
|
-
condensation: "anthropic:claude-haiku-4-5",
|
|
274
|
-
condensationTimeout: 45_000,
|
|
275
|
-
};
|
|
276
|
-
const result = OperationModelsSchema.parse(input);
|
|
277
|
-
expect(result).toEqual(input);
|
|
278
|
-
});
|
|
279
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|