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 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { ContextPruningConfigSchema, SourceGateConfigSchema } from "./schema-agent.js";
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
// ContextPruningConfigSchema
|
|
5
|
-
// ---------------------------------------------------------------------------
|
|
6
|
-
describe("ContextPruningConfigSchema", () => {
|
|
7
|
-
it("produces valid defaults from empty object", () => {
|
|
8
|
-
const result = ContextPruningConfigSchema.safeParse({});
|
|
9
|
-
expect(result.success).toBe(true);
|
|
10
|
-
if (result.success) {
|
|
11
|
-
expect(result.data.enabled).toBe(true);
|
|
12
|
-
expect(result.data.softTrimRatio).toBe(0.3);
|
|
13
|
-
expect(result.data.hardClearRatio).toBe(0.5);
|
|
14
|
-
expect(result.data.keepLastAssistants).toBe(3);
|
|
15
|
-
expect(result.data.minPrunableToolChars).toBe(4000);
|
|
16
|
-
expect(result.data.protectedTools).toHaveLength(4);
|
|
17
|
-
expect(result.data.protectedTools).toEqual([
|
|
18
|
-
"memory_search", "memory_get", "memory_store", "file_read",
|
|
19
|
-
]);
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
it("accepts custom values that override defaults", () => {
|
|
23
|
-
const result = ContextPruningConfigSchema.safeParse({
|
|
24
|
-
enabled: false,
|
|
25
|
-
softTrimRatio: 0.2,
|
|
26
|
-
hardClearRatio: 0.6,
|
|
27
|
-
keepLastAssistants: 5,
|
|
28
|
-
minPrunableToolChars: 8000,
|
|
29
|
-
protectedTools: ["bash"],
|
|
30
|
-
});
|
|
31
|
-
expect(result.success).toBe(true);
|
|
32
|
-
if (result.success) {
|
|
33
|
-
expect(result.data.enabled).toBe(false);
|
|
34
|
-
expect(result.data.softTrimRatio).toBe(0.2);
|
|
35
|
-
expect(result.data.hardClearRatio).toBe(0.6);
|
|
36
|
-
expect(result.data.keepLastAssistants).toBe(5);
|
|
37
|
-
expect(result.data.minPrunableToolChars).toBe(8000);
|
|
38
|
-
expect(result.data.protectedTools).toEqual(["bash"]);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
it("rejects softTrimRatio equal to hardClearRatio", () => {
|
|
42
|
-
const result = ContextPruningConfigSchema.safeParse({
|
|
43
|
-
softTrimRatio: 0.5,
|
|
44
|
-
hardClearRatio: 0.5,
|
|
45
|
-
});
|
|
46
|
-
expect(result.success).toBe(false);
|
|
47
|
-
});
|
|
48
|
-
it("rejects softTrimRatio greater than hardClearRatio", () => {
|
|
49
|
-
const result = ContextPruningConfigSchema.safeParse({
|
|
50
|
-
softTrimRatio: 0.6,
|
|
51
|
-
hardClearRatio: 0.3,
|
|
52
|
-
});
|
|
53
|
-
expect(result.success).toBe(false);
|
|
54
|
-
});
|
|
55
|
-
it("rejects softTrimRatio > 1", () => {
|
|
56
|
-
const result = ContextPruningConfigSchema.safeParse({ softTrimRatio: 1.1 });
|
|
57
|
-
expect(result.success).toBe(false);
|
|
58
|
-
});
|
|
59
|
-
it("rejects softTrimRatio < 0", () => {
|
|
60
|
-
const result = ContextPruningConfigSchema.safeParse({ softTrimRatio: -0.1 });
|
|
61
|
-
expect(result.success).toBe(false);
|
|
62
|
-
});
|
|
63
|
-
it("rejects hardClearRatio > 1", () => {
|
|
64
|
-
const result = ContextPruningConfigSchema.safeParse({ hardClearRatio: 1.1 });
|
|
65
|
-
expect(result.success).toBe(false);
|
|
66
|
-
});
|
|
67
|
-
it("rejects hardClearRatio < 0", () => {
|
|
68
|
-
const result = ContextPruningConfigSchema.safeParse({ hardClearRatio: -0.1 });
|
|
69
|
-
expect(result.success).toBe(false);
|
|
70
|
-
});
|
|
71
|
-
it("rejects non-positive minPrunableToolChars", () => {
|
|
72
|
-
const result = ContextPruningConfigSchema.safeParse({ minPrunableToolChars: 0 });
|
|
73
|
-
expect(result.success).toBe(false);
|
|
74
|
-
const result2 = ContextPruningConfigSchema.safeParse({ minPrunableToolChars: -1 });
|
|
75
|
-
expect(result2.success).toBe(false);
|
|
76
|
-
});
|
|
77
|
-
it("rejects negative keepLastAssistants", () => {
|
|
78
|
-
const result = ContextPruningConfigSchema.safeParse({ keepLastAssistants: -1 });
|
|
79
|
-
expect(result.success).toBe(false);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
// ---------------------------------------------------------------------------
|
|
83
|
-
// SourceGateConfigSchema
|
|
84
|
-
// ---------------------------------------------------------------------------
|
|
85
|
-
describe("SourceGateConfigSchema", () => {
|
|
86
|
-
it("produces valid defaults from empty object", () => {
|
|
87
|
-
const result = SourceGateConfigSchema.safeParse({});
|
|
88
|
-
expect(result.success).toBe(true);
|
|
89
|
-
if (result.success) {
|
|
90
|
-
expect(result.data.maxResponseBytes).toBe(2_000_000);
|
|
91
|
-
expect(result.data.stripHiddenHtml).toBe(true);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
it("accepts custom values that override defaults", () => {
|
|
95
|
-
const result = SourceGateConfigSchema.safeParse({
|
|
96
|
-
maxResponseBytes: 1_000_000,
|
|
97
|
-
stripHiddenHtml: false,
|
|
98
|
-
});
|
|
99
|
-
expect(result.success).toBe(true);
|
|
100
|
-
if (result.success) {
|
|
101
|
-
expect(result.data.maxResponseBytes).toBe(1_000_000);
|
|
102
|
-
expect(result.data.stripHiddenHtml).toBe(false);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
it("rejects non-positive maxResponseBytes", () => {
|
|
106
|
-
const result = SourceGateConfigSchema.safeParse({ maxResponseBytes: 0 });
|
|
107
|
-
expect(result.success).toBe(false);
|
|
108
|
-
const result2 = SourceGateConfigSchema.safeParse({ maxResponseBytes: -1 });
|
|
109
|
-
expect(result2.success).toBe(false);
|
|
110
|
-
});
|
|
111
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { DaemonConfigSchema } from "./schema-daemon.js";
|
|
3
|
-
describe("DaemonConfigSchema", () => {
|
|
4
|
-
describe("logging sub-schema", () => {
|
|
5
|
-
it("provides defaults for all logging fields when daemon is empty", () => {
|
|
6
|
-
const result = DaemonConfigSchema.safeParse({});
|
|
7
|
-
expect(result.success).toBe(true);
|
|
8
|
-
if (result.success) {
|
|
9
|
-
expect(result.data.logging).toEqual({
|
|
10
|
-
filePath: "~/.comis/logs/daemon.log",
|
|
11
|
-
maxSize: "10m",
|
|
12
|
-
maxFiles: 5,
|
|
13
|
-
compress: false,
|
|
14
|
-
tracing: {
|
|
15
|
-
outputDir: "~/.comis/traces",
|
|
16
|
-
maxSize: "5m",
|
|
17
|
-
maxFiles: 3,
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
it("accepts valid logging overrides", () => {
|
|
23
|
-
const result = DaemonConfigSchema.safeParse({
|
|
24
|
-
logging: {
|
|
25
|
-
filePath: "/var/log/comis/daemon.log",
|
|
26
|
-
maxSize: "50m",
|
|
27
|
-
maxFiles: 10,
|
|
28
|
-
compress: true,
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
expect(result.success).toBe(true);
|
|
32
|
-
if (result.success) {
|
|
33
|
-
expect(result.data.logging.filePath).toBe("/var/log/comis/daemon.log");
|
|
34
|
-
expect(result.data.logging.maxSize).toBe("50m");
|
|
35
|
-
expect(result.data.logging.maxFiles).toBe(10);
|
|
36
|
-
expect(result.data.logging.compress).toBe(true);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
it("accepts maxSize with various valid suffixes", () => {
|
|
40
|
-
for (const size of ["100", "10k", "10K", "50m", "50M", "1g", "1G"]) {
|
|
41
|
-
const result = DaemonConfigSchema.safeParse({ logging: { maxSize: size } });
|
|
42
|
-
expect(result.success).toBe(true);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
it("rejects negative maxFiles", () => {
|
|
46
|
-
const result = DaemonConfigSchema.safeParse({ logging: { maxFiles: -1 } });
|
|
47
|
-
expect(result.success).toBe(false);
|
|
48
|
-
});
|
|
49
|
-
it("rejects maxFiles exceeding 100", () => {
|
|
50
|
-
const result = DaemonConfigSchema.safeParse({ logging: { maxFiles: 101 } });
|
|
51
|
-
expect(result.success).toBe(false);
|
|
52
|
-
});
|
|
53
|
-
it("rejects non-integer maxFiles", () => {
|
|
54
|
-
const result = DaemonConfigSchema.safeParse({ logging: { maxFiles: 2.5 } });
|
|
55
|
-
expect(result.success).toBe(false);
|
|
56
|
-
});
|
|
57
|
-
it("rejects non-string filePath", () => {
|
|
58
|
-
const result = DaemonConfigSchema.safeParse({ logging: { filePath: 123 } });
|
|
59
|
-
expect(result.success).toBe(false);
|
|
60
|
-
});
|
|
61
|
-
it("rejects invalid maxSize format", () => {
|
|
62
|
-
for (const bad of ["banana", "10mb", "1.5g", "m10", ""]) {
|
|
63
|
-
const result = DaemonConfigSchema.safeParse({ logging: { maxSize: bad } });
|
|
64
|
-
expect(result.success).toBe(false);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
it("rejects non-boolean compress", () => {
|
|
68
|
-
const result = DaemonConfigSchema.safeParse({ logging: { compress: "yes" } });
|
|
69
|
-
expect(result.success).toBe(false);
|
|
70
|
-
});
|
|
71
|
-
it("rejects unknown keys in logging (strictObject)", () => {
|
|
72
|
-
const result = DaemonConfigSchema.safeParse({ logging: { unknownKey: "value" } });
|
|
73
|
-
expect(result.success).toBe(false);
|
|
74
|
-
});
|
|
75
|
-
it("allows partial logging overrides with defaults for rest", () => {
|
|
76
|
-
const result = DaemonConfigSchema.safeParse({ logging: { maxFiles: 20 } });
|
|
77
|
-
expect(result.success).toBe(true);
|
|
78
|
-
if (result.success) {
|
|
79
|
-
expect(result.data.logging.maxFiles).toBe(20);
|
|
80
|
-
expect(result.data.logging.filePath).toBe("~/.comis/logs/daemon.log");
|
|
81
|
-
expect(result.data.logging.maxSize).toBe("10m");
|
|
82
|
-
expect(result.data.logging.compress).toBe(false);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
it("allows maxFiles of 0 (disable retention)", () => {
|
|
86
|
-
const result = DaemonConfigSchema.safeParse({ logging: { maxFiles: 0 } });
|
|
87
|
-
expect(result.success).toBe(true);
|
|
88
|
-
if (result.success) {
|
|
89
|
-
expect(result.data.logging.maxFiles).toBe(0);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
describe("existing daemon fields preserved", () => {
|
|
94
|
-
it("preserves existing defaults alongside logging", () => {
|
|
95
|
-
const result = DaemonConfigSchema.safeParse({});
|
|
96
|
-
expect(result.success).toBe(true);
|
|
97
|
-
if (result.success) {
|
|
98
|
-
expect(result.data.watchdogIntervalMs).toBe(30_000);
|
|
99
|
-
expect(result.data.shutdownTimeoutMs).toBe(30_000);
|
|
100
|
-
expect(result.data.metricsIntervalMs).toBe(30_000);
|
|
101
|
-
expect(result.data.eventLoopDelayThresholdMs).toBe(500);
|
|
102
|
-
expect(result.data.logLevels).toEqual({});
|
|
103
|
-
expect(result.data.logging).toBeDefined();
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { DeliveryTimingConfigSchema } from "./schema-delivery.js";
|
|
3
|
-
describe("DeliveryTimingConfigSchema", () => {
|
|
4
|
-
it("produces valid defaults from empty object", () => {
|
|
5
|
-
const result = DeliveryTimingConfigSchema.safeParse({});
|
|
6
|
-
expect(result.success).toBe(true);
|
|
7
|
-
if (result.success) {
|
|
8
|
-
expect(result.data.mode).toBe("natural");
|
|
9
|
-
expect(result.data.minMs).toBe(800);
|
|
10
|
-
expect(result.data.maxMs).toBe(2500);
|
|
11
|
-
expect(result.data.jitterMs).toBe(200);
|
|
12
|
-
expect(result.data.firstBlockDelayMs).toBe(0);
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
it("accepts fully specified config", () => {
|
|
16
|
-
const result = DeliveryTimingConfigSchema.safeParse({
|
|
17
|
-
mode: "custom",
|
|
18
|
-
minMs: 500,
|
|
19
|
-
maxMs: 3000,
|
|
20
|
-
jitterMs: 100,
|
|
21
|
-
firstBlockDelayMs: 1000,
|
|
22
|
-
});
|
|
23
|
-
expect(result.success).toBe(true);
|
|
24
|
-
if (result.success) {
|
|
25
|
-
expect(result.data.mode).toBe("custom");
|
|
26
|
-
expect(result.data.minMs).toBe(500);
|
|
27
|
-
expect(result.data.maxMs).toBe(3000);
|
|
28
|
-
expect(result.data.jitterMs).toBe(100);
|
|
29
|
-
expect(result.data.firstBlockDelayMs).toBe(1000);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
it("rejects unknown keys (strictObject)", () => {
|
|
33
|
-
const result = DeliveryTimingConfigSchema.safeParse({
|
|
34
|
-
mode: "natural",
|
|
35
|
-
unknownField: "should-fail",
|
|
36
|
-
});
|
|
37
|
-
expect(result.success).toBe(false);
|
|
38
|
-
});
|
|
39
|
-
it("rejects invalid mode enum value", () => {
|
|
40
|
-
const result = DeliveryTimingConfigSchema.safeParse({
|
|
41
|
-
mode: "turbo",
|
|
42
|
-
});
|
|
43
|
-
expect(result.success).toBe(false);
|
|
44
|
-
});
|
|
45
|
-
it("rejects negative timing values", () => {
|
|
46
|
-
const result = DeliveryTimingConfigSchema.safeParse({
|
|
47
|
-
minMs: -100,
|
|
48
|
-
});
|
|
49
|
-
expect(result.success).toBe(false);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { DocumentationConfigSchema } from "./schema-documentation.js";
|
|
3
|
-
describe("DocumentationConfigSchema", () => {
|
|
4
|
-
it("produces valid defaults from empty object", () => {
|
|
5
|
-
const result = DocumentationConfigSchema.safeParse({});
|
|
6
|
-
expect(result.success).toBe(true);
|
|
7
|
-
if (result.success) {
|
|
8
|
-
expect(result.data.enabled).toBe(false);
|
|
9
|
-
expect(result.data.localDocsPath).toBe("");
|
|
10
|
-
expect(result.data.publicDocsUrl).toBe("");
|
|
11
|
-
expect(result.data.sourceUrl).toBe("");
|
|
12
|
-
expect(result.data.communityUrl).toBe("");
|
|
13
|
-
expect(result.data.skillsMarketplaceUrl).toBe("");
|
|
14
|
-
expect(result.data.mcpRegistryUrl).toBe("");
|
|
15
|
-
expect(result.data.customLinks).toEqual([]);
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
it("accepts fully specified config", () => {
|
|
19
|
-
const result = DocumentationConfigSchema.safeParse({
|
|
20
|
-
enabled: true,
|
|
21
|
-
localDocsPath: "/opt/docs",
|
|
22
|
-
publicDocsUrl: "https://docs.example.com",
|
|
23
|
-
sourceUrl: "https://github.com/org/repo",
|
|
24
|
-
communityUrl: "https://discord.gg/invite",
|
|
25
|
-
skillsMarketplaceUrl: "https://skills.example.com",
|
|
26
|
-
mcpRegistryUrl: "https://mcp.example.com/registry",
|
|
27
|
-
customLinks: [
|
|
28
|
-
{ label: "API Reference", url: "https://api.example.com/docs" },
|
|
29
|
-
{ label: "Changelog", url: "https://example.com/changelog" },
|
|
30
|
-
],
|
|
31
|
-
});
|
|
32
|
-
expect(result.success).toBe(true);
|
|
33
|
-
if (result.success) {
|
|
34
|
-
expect(result.data.enabled).toBe(true);
|
|
35
|
-
expect(result.data.localDocsPath).toBe("/opt/docs");
|
|
36
|
-
expect(result.data.skillsMarketplaceUrl).toBe("https://skills.example.com");
|
|
37
|
-
expect(result.data.mcpRegistryUrl).toBe("https://mcp.example.com/registry");
|
|
38
|
-
expect(result.data.customLinks).toHaveLength(2);
|
|
39
|
-
expect(result.data.customLinks[0]?.label).toBe("API Reference");
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
it("rejects unknown keys (strictObject)", () => {
|
|
43
|
-
const result = DocumentationConfigSchema.safeParse({
|
|
44
|
-
enabled: true,
|
|
45
|
-
unknownField: "should-fail",
|
|
46
|
-
});
|
|
47
|
-
expect(result.success).toBe(false);
|
|
48
|
-
});
|
|
49
|
-
it("rejects unknown keys in customLinks entries (strictObject)", () => {
|
|
50
|
-
const result = DocumentationConfigSchema.safeParse({
|
|
51
|
-
customLinks: [
|
|
52
|
-
{ label: "API", url: "https://api.example.com", icon: "book" },
|
|
53
|
-
],
|
|
54
|
-
});
|
|
55
|
-
expect(result.success).toBe(false);
|
|
56
|
-
});
|
|
57
|
-
it("rejects customLinks entry missing required label", () => {
|
|
58
|
-
const result = DocumentationConfigSchema.safeParse({
|
|
59
|
-
customLinks: [{ url: "https://example.com" }],
|
|
60
|
-
});
|
|
61
|
-
expect(result.success).toBe(false);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { GatewayConfigSchema, GatewayTlsConfigSchema, GatewayTokenSchema, GatewayRateLimitSchema, } from "./schema-gateway.js";
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
// GatewayConfigSchema
|
|
5
|
-
// ---------------------------------------------------------------------------
|
|
6
|
-
describe("GatewayConfigSchema", () => {
|
|
7
|
-
it("produces valid defaults from empty object", () => {
|
|
8
|
-
const result = GatewayConfigSchema.safeParse({});
|
|
9
|
-
expect(result.success).toBe(true);
|
|
10
|
-
if (result.success) {
|
|
11
|
-
expect(result.data.enabled).toBe(true);
|
|
12
|
-
expect(result.data.host).toBe("127.0.0.1");
|
|
13
|
-
expect(result.data.port).toBe(4766);
|
|
14
|
-
expect(result.data.tokens).toEqual([]);
|
|
15
|
-
expect(result.data.maxBatchSize).toBe(50);
|
|
16
|
-
expect(result.data.wsHeartbeatMs).toBe(30_000);
|
|
17
|
-
expect(result.data.corsOrigins).toEqual([]);
|
|
18
|
-
expect(result.data.allowInsecureHttp).toBe(false);
|
|
19
|
-
expect(result.data.trustedProxies).toEqual([]);
|
|
20
|
-
expect(result.data.httpBodyLimitBytes).toBe(1_048_576);
|
|
21
|
-
expect(result.data.wsMaxMessageBytes).toBe(1_048_576);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
it("includes rateLimit defaults", () => {
|
|
25
|
-
const result = GatewayConfigSchema.safeParse({});
|
|
26
|
-
expect(result.success).toBe(true);
|
|
27
|
-
if (result.success) {
|
|
28
|
-
expect(result.data.rateLimit.windowMs).toBe(60_000);
|
|
29
|
-
expect(result.data.rateLimit.maxRequests).toBe(100);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
it("includes wsMessageRateLimit defaults", () => {
|
|
33
|
-
const result = GatewayConfigSchema.safeParse({});
|
|
34
|
-
expect(result.success).toBe(true);
|
|
35
|
-
if (result.success) {
|
|
36
|
-
expect(result.data.wsMessageRateLimit.maxMessages).toBe(60);
|
|
37
|
-
expect(result.data.wsMessageRateLimit.windowMs).toBe(60_000);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
it("tls is optional (undefined when omitted)", () => {
|
|
41
|
-
const result = GatewayConfigSchema.safeParse({});
|
|
42
|
-
expect(result.success).toBe(true);
|
|
43
|
-
if (result.success) {
|
|
44
|
-
expect(result.data.tls).toBeUndefined();
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
it("rejects port below 1", () => {
|
|
48
|
-
const result = GatewayConfigSchema.safeParse({ port: 0 });
|
|
49
|
-
expect(result.success).toBe(false);
|
|
50
|
-
});
|
|
51
|
-
it("rejects port above 65535", () => {
|
|
52
|
-
const result = GatewayConfigSchema.safeParse({ port: 65536 });
|
|
53
|
-
expect(result.success).toBe(false);
|
|
54
|
-
});
|
|
55
|
-
it("accepts valid port at boundaries", () => {
|
|
56
|
-
const r1 = GatewayConfigSchema.safeParse({ port: 1 });
|
|
57
|
-
expect(r1.success).toBe(true);
|
|
58
|
-
const rMax = GatewayConfigSchema.safeParse({ port: 65535 });
|
|
59
|
-
expect(rMax.success).toBe(true);
|
|
60
|
-
});
|
|
61
|
-
it("rejects unknown fields (strictObject enforcement)", () => {
|
|
62
|
-
const result = GatewayConfigSchema.safeParse({ unknownField: "test" });
|
|
63
|
-
expect(result.success).toBe(false);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
// ---------------------------------------------------------------------------
|
|
67
|
-
// GatewayTlsConfigSchema
|
|
68
|
-
// ---------------------------------------------------------------------------
|
|
69
|
-
describe("GatewayTlsConfigSchema", () => {
|
|
70
|
-
it("requires certPath, keyPath, caPath", () => {
|
|
71
|
-
const result = GatewayTlsConfigSchema.safeParse({
|
|
72
|
-
certPath: "/etc/tls/cert.pem",
|
|
73
|
-
keyPath: "/etc/tls/key.pem",
|
|
74
|
-
caPath: "/etc/tls/ca.pem",
|
|
75
|
-
});
|
|
76
|
-
expect(result.success).toBe(true);
|
|
77
|
-
if (result.success) {
|
|
78
|
-
expect(result.data.certPath).toBe("/etc/tls/cert.pem");
|
|
79
|
-
expect(result.data.keyPath).toBe("/etc/tls/key.pem");
|
|
80
|
-
expect(result.data.caPath).toBe("/etc/tls/ca.pem");
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
it("defaults requireClientCert to true", () => {
|
|
84
|
-
const result = GatewayTlsConfigSchema.safeParse({
|
|
85
|
-
certPath: "/cert.pem",
|
|
86
|
-
keyPath: "/key.pem",
|
|
87
|
-
caPath: "/ca.pem",
|
|
88
|
-
});
|
|
89
|
-
expect(result.success).toBe(true);
|
|
90
|
-
if (result.success) {
|
|
91
|
-
expect(result.data.requireClientCert).toBe(true);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
it("rejects empty certPath", () => {
|
|
95
|
-
const result = GatewayTlsConfigSchema.safeParse({
|
|
96
|
-
certPath: "",
|
|
97
|
-
keyPath: "/key.pem",
|
|
98
|
-
caPath: "/ca.pem",
|
|
99
|
-
});
|
|
100
|
-
expect(result.success).toBe(false);
|
|
101
|
-
});
|
|
102
|
-
it("rejects missing required fields", () => {
|
|
103
|
-
const result = GatewayTlsConfigSchema.safeParse({});
|
|
104
|
-
expect(result.success).toBe(false);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
// ---------------------------------------------------------------------------
|
|
108
|
-
// GatewayTokenSchema
|
|
109
|
-
// ---------------------------------------------------------------------------
|
|
110
|
-
describe("GatewayTokenSchema", () => {
|
|
111
|
-
it("accepts token with id and scopes (no secret)", () => {
|
|
112
|
-
const result = GatewayTokenSchema.safeParse({
|
|
113
|
-
id: "token-1",
|
|
114
|
-
scopes: ["rpc", "ws"],
|
|
115
|
-
});
|
|
116
|
-
expect(result.success).toBe(true);
|
|
117
|
-
if (result.success) {
|
|
118
|
-
expect(result.data.id).toBe("token-1");
|
|
119
|
-
expect(result.data.secret).toBeUndefined();
|
|
120
|
-
expect(result.data.scopes).toEqual(["rpc", "ws"]);
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
it("scopes defaults to empty array", () => {
|
|
124
|
-
const result = GatewayTokenSchema.safeParse({ id: "token-2" });
|
|
125
|
-
expect(result.success).toBe(true);
|
|
126
|
-
if (result.success) {
|
|
127
|
-
expect(result.data.scopes).toEqual([]);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
it("accepts secret string with min 32 chars", () => {
|
|
131
|
-
const secret = "a".repeat(32);
|
|
132
|
-
const result = GatewayTokenSchema.safeParse({ id: "token-3", secret });
|
|
133
|
-
expect(result.success).toBe(true);
|
|
134
|
-
if (result.success) {
|
|
135
|
-
expect(result.data.secret).toBe(secret);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
it("rejects short secret string (< 32 chars)", () => {
|
|
139
|
-
const result = GatewayTokenSchema.safeParse({
|
|
140
|
-
id: "token-4",
|
|
141
|
-
secret: "too-short",
|
|
142
|
-
});
|
|
143
|
-
expect(result.success).toBe(false);
|
|
144
|
-
});
|
|
145
|
-
it("accepts SecretRef object for secret field", () => {
|
|
146
|
-
const result = GatewayTokenSchema.safeParse({
|
|
147
|
-
id: "token-5",
|
|
148
|
-
secret: { source: "env", provider: "gateway", id: "GW_TOKEN_SECRET" },
|
|
149
|
-
});
|
|
150
|
-
expect(result.success).toBe(true);
|
|
151
|
-
if (result.success) {
|
|
152
|
-
expect(result.data.secret).toEqual({
|
|
153
|
-
source: "env",
|
|
154
|
-
provider: "gateway",
|
|
155
|
-
id: "GW_TOKEN_SECRET",
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
it("rejects empty id", () => {
|
|
160
|
-
const result = GatewayTokenSchema.safeParse({ id: "" });
|
|
161
|
-
expect(result.success).toBe(false);
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
// ---------------------------------------------------------------------------
|
|
165
|
-
// GatewayRateLimitSchema
|
|
166
|
-
// ---------------------------------------------------------------------------
|
|
167
|
-
describe("GatewayRateLimitSchema", () => {
|
|
168
|
-
it("produces valid defaults", () => {
|
|
169
|
-
const result = GatewayRateLimitSchema.safeParse({});
|
|
170
|
-
expect(result.success).toBe(true);
|
|
171
|
-
if (result.success) {
|
|
172
|
-
expect(result.data.windowMs).toBe(60_000);
|
|
173
|
-
expect(result.data.maxRequests).toBe(100);
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
it("rejects non-positive windowMs", () => {
|
|
177
|
-
const result = GatewayRateLimitSchema.safeParse({ windowMs: 0 });
|
|
178
|
-
expect(result.success).toBe(false);
|
|
179
|
-
});
|
|
180
|
-
it("rejects non-positive maxRequests", () => {
|
|
181
|
-
const result = GatewayRateLimitSchema.safeParse({ maxRequests: 0 });
|
|
182
|
-
expect(result.success).toBe(false);
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
// ---------------------------------------------------------------------------
|
|
186
|
-
// Trusted proxies IP validation
|
|
187
|
-
// ---------------------------------------------------------------------------
|
|
188
|
-
describe("Trusted proxies validation", () => {
|
|
189
|
-
it("accepts valid IPv4 addresses", () => {
|
|
190
|
-
const result = GatewayConfigSchema.safeParse({
|
|
191
|
-
trustedProxies: ["10.0.0.1", "192.168.1.100"],
|
|
192
|
-
});
|
|
193
|
-
expect(result.success).toBe(true);
|
|
194
|
-
if (result.success) {
|
|
195
|
-
expect(result.data.trustedProxies).toEqual(["10.0.0.1", "192.168.1.100"]);
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
it("accepts valid IPv6 addresses", () => {
|
|
199
|
-
const result = GatewayConfigSchema.safeParse({
|
|
200
|
-
trustedProxies: ["::1", "2001:db8::1"],
|
|
201
|
-
});
|
|
202
|
-
expect(result.success).toBe(true);
|
|
203
|
-
if (result.success) {
|
|
204
|
-
expect(result.data.trustedProxies).toHaveLength(2);
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
it("rejects invalid IP strings", () => {
|
|
208
|
-
const result = GatewayConfigSchema.safeParse({
|
|
209
|
-
trustedProxies: ["not-an-ip"],
|
|
210
|
-
});
|
|
211
|
-
expect(result.success).toBe(false);
|
|
212
|
-
});
|
|
213
|
-
it("rejects mixed valid/invalid IPs", () => {
|
|
214
|
-
const result = GatewayConfigSchema.safeParse({
|
|
215
|
-
trustedProxies: ["10.0.0.1", "invalid"],
|
|
216
|
-
});
|
|
217
|
-
expect(result.success).toBe(false);
|
|
218
|
-
});
|
|
219
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { GeminiCacheConfigSchema } from "./schema-gemini-cache.js";
|
|
3
|
-
import { AgentConfigSchema } from "./schema-agent.js";
|
|
4
|
-
// ---------------------------------------------------------------------------
|
|
5
|
-
// GeminiCacheConfigSchema
|
|
6
|
-
// ---------------------------------------------------------------------------
|
|
7
|
-
describe("GeminiCacheConfigSchema", () => {
|
|
8
|
-
it("produces correct defaults from empty object", () => {
|
|
9
|
-
const result = GeminiCacheConfigSchema.parse({});
|
|
10
|
-
expect(result).toEqual({ enabled: false, maxActiveCaches: 20 });
|
|
11
|
-
});
|
|
12
|
-
it("accepts explicit values", () => {
|
|
13
|
-
const result = GeminiCacheConfigSchema.parse({ enabled: true, maxActiveCaches: 10 });
|
|
14
|
-
expect(result).toEqual({ enabled: true, maxActiveCaches: 10 });
|
|
15
|
-
});
|
|
16
|
-
it("rejects maxActiveCaches: 0 (must be positive)", () => {
|
|
17
|
-
const result = GeminiCacheConfigSchema.safeParse({ maxActiveCaches: 0 });
|
|
18
|
-
expect(result.success).toBe(false);
|
|
19
|
-
});
|
|
20
|
-
it("rejects maxActiveCaches: 1.5 (must be integer)", () => {
|
|
21
|
-
const result = GeminiCacheConfigSchema.safeParse({ maxActiveCaches: 1.5 });
|
|
22
|
-
expect(result.success).toBe(false);
|
|
23
|
-
});
|
|
24
|
-
it("rejects unknown keys (strictObject)", () => {
|
|
25
|
-
const result = GeminiCacheConfigSchema.safeParse({ enabled: true, unknownField: "bad" });
|
|
26
|
-
expect(result.success).toBe(false);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
// ---------------------------------------------------------------------------
|
|
30
|
-
// AgentConfigSchema geminiCache integration
|
|
31
|
-
// ---------------------------------------------------------------------------
|
|
32
|
-
describe("AgentConfigSchema geminiCache integration", () => {
|
|
33
|
-
it("includes geminiCache with correct defaults when omitted", () => {
|
|
34
|
-
const config = AgentConfigSchema.parse({});
|
|
35
|
-
expect(config.geminiCache).toEqual({ enabled: false, maxActiveCaches: 20 });
|
|
36
|
-
});
|
|
37
|
-
it("applies maxActiveCaches default when only enabled is set", () => {
|
|
38
|
-
const config = AgentConfigSchema.parse({ geminiCache: { enabled: true } });
|
|
39
|
-
expect(config.geminiCache.maxActiveCaches).toBe(20);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|