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,283 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { IMMUTABLE_CONFIG_PREFIXES, MUTABLE_CONFIG_OVERRIDES, isImmutableConfigPath, matchesOverridePattern, } from "./immutable-keys.js";
|
|
3
|
-
describe("IMMUTABLE_CONFIG_PREFIXES", () => {
|
|
4
|
-
it("contains original prefixes: security, gateway.tls, gateway.tokens", () => {
|
|
5
|
-
expect(IMMUTABLE_CONFIG_PREFIXES).toContain("security");
|
|
6
|
-
expect(IMMUTABLE_CONFIG_PREFIXES).toContain("gateway.tls");
|
|
7
|
-
expect(IMMUTABLE_CONFIG_PREFIXES).toContain("gateway.tokens");
|
|
8
|
-
});
|
|
9
|
-
it("contains SHR-04 prefixes: agents, channels, gateway.host, gateway.port, integrations", () => {
|
|
10
|
-
expect(IMMUTABLE_CONFIG_PREFIXES).toContain("agents");
|
|
11
|
-
expect(IMMUTABLE_CONFIG_PREFIXES).toContain("channels");
|
|
12
|
-
expect(IMMUTABLE_CONFIG_PREFIXES).toContain("gateway.host");
|
|
13
|
-
expect(IMMUTABLE_CONFIG_PREFIXES).toContain("gateway.port");
|
|
14
|
-
expect(IMMUTABLE_CONFIG_PREFIXES).toContain("integrations");
|
|
15
|
-
});
|
|
16
|
-
it("contains CFG-07 prefixes: providers, approvals, browser.noSandbox", () => {
|
|
17
|
-
expect(IMMUTABLE_CONFIG_PREFIXES).toContain("providers");
|
|
18
|
-
expect(IMMUTABLE_CONFIG_PREFIXES).toContain("approvals");
|
|
19
|
-
expect(IMMUTABLE_CONFIG_PREFIXES).toContain("browser.noSandbox");
|
|
20
|
-
});
|
|
21
|
-
it("contains INFRA-05 prefix: daemon.logging", () => {
|
|
22
|
-
expect(IMMUTABLE_CONFIG_PREFIXES).toContain("daemon.logging");
|
|
23
|
-
});
|
|
24
|
-
it("has exactly 12 entries", () => {
|
|
25
|
-
expect(IMMUTABLE_CONFIG_PREFIXES).toHaveLength(12);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
describe("isImmutableConfigPath", () => {
|
|
29
|
-
// Original prefixes (Phase 38)
|
|
30
|
-
it("rejects exact prefix match: security", () => {
|
|
31
|
-
expect(isImmutableConfigPath("security")).toBe(true);
|
|
32
|
-
});
|
|
33
|
-
it("rejects child path: security.audit.enabled", () => {
|
|
34
|
-
expect(isImmutableConfigPath("security", "audit.enabled")).toBe(true);
|
|
35
|
-
});
|
|
36
|
-
it("rejects gateway.tls child: gateway tls.certPath", () => {
|
|
37
|
-
expect(isImmutableConfigPath("gateway", "tls.certPath")).toBe(true);
|
|
38
|
-
});
|
|
39
|
-
it("rejects exact gateway.tokens: gateway tokens", () => {
|
|
40
|
-
expect(isImmutableConfigPath("gateway", "tokens")).toBe(true);
|
|
41
|
-
});
|
|
42
|
-
it("rejects gateway.tokens child: gateway tokens.0.name", () => {
|
|
43
|
-
expect(isImmutableConfigPath("gateway", "tokens.0.name")).toBe(true);
|
|
44
|
-
});
|
|
45
|
-
// SHR-04: agents (top-level section is immutable)
|
|
46
|
-
it("rejects exact agents section", () => {
|
|
47
|
-
expect(isImmutableConfigPath("agents")).toBe(true);
|
|
48
|
-
});
|
|
49
|
-
it("rejects agents child: agents default.model", () => {
|
|
50
|
-
expect(isImmutableConfigPath("agents", "default.model")).toBe(true);
|
|
51
|
-
});
|
|
52
|
-
it("rejects agents deep child: agents default.budgets.maxDailyUsd", () => {
|
|
53
|
-
expect(isImmutableConfigPath("agents", "default.budgets.maxDailyUsd")).toBe(true);
|
|
54
|
-
});
|
|
55
|
-
it("rejects agents model routes: agents default.modelRoutes.default", () => {
|
|
56
|
-
expect(isImmutableConfigPath("agents", "default.modelRoutes.default")).toBe(true);
|
|
57
|
-
});
|
|
58
|
-
// SHR-04: channels
|
|
59
|
-
it("rejects exact channels section", () => {
|
|
60
|
-
expect(isImmutableConfigPath("channels")).toBe(true);
|
|
61
|
-
});
|
|
62
|
-
it("rejects channels child: channels slack.botToken", () => {
|
|
63
|
-
expect(isImmutableConfigPath("channels", "slack.botToken")).toBe(true);
|
|
64
|
-
});
|
|
65
|
-
it("rejects channels deep child: channels discord.guildId", () => {
|
|
66
|
-
expect(isImmutableConfigPath("channels", "discord.guildId")).toBe(true);
|
|
67
|
-
});
|
|
68
|
-
// SHR-04: gateway.host
|
|
69
|
-
it("rejects gateway.host exact match", () => {
|
|
70
|
-
expect(isImmutableConfigPath("gateway", "host")).toBe(true);
|
|
71
|
-
});
|
|
72
|
-
// SHR-04: gateway.port
|
|
73
|
-
it("rejects gateway.port exact match", () => {
|
|
74
|
-
expect(isImmutableConfigPath("gateway", "port")).toBe(true);
|
|
75
|
-
});
|
|
76
|
-
// SHR-04: integrations
|
|
77
|
-
it("rejects exact integrations section", () => {
|
|
78
|
-
expect(isImmutableConfigPath("integrations")).toBe(true);
|
|
79
|
-
});
|
|
80
|
-
it("rejects integrations child: integrations github.token", () => {
|
|
81
|
-
expect(isImmutableConfigPath("integrations", "github.token")).toBe(true);
|
|
82
|
-
});
|
|
83
|
-
it("rejects integrations deep child: integrations openai.apiKey", () => {
|
|
84
|
-
expect(isImmutableConfigPath("integrations", "openai.apiKey")).toBe(true);
|
|
85
|
-
});
|
|
86
|
-
// CFG-07: providers
|
|
87
|
-
it("rejects exact providers section", () => {
|
|
88
|
-
expect(isImmutableConfigPath("providers")).toBe(true);
|
|
89
|
-
});
|
|
90
|
-
it("rejects providers child: providers entries.anthropic.apiKeyName", () => {
|
|
91
|
-
expect(isImmutableConfigPath("providers", "entries.anthropic.apiKeyName")).toBe(true);
|
|
92
|
-
});
|
|
93
|
-
// CFG-07: approvals
|
|
94
|
-
it("rejects exact approvals section", () => {
|
|
95
|
-
expect(isImmutableConfigPath("approvals")).toBe(true);
|
|
96
|
-
});
|
|
97
|
-
it("rejects approvals child: approvals rules", () => {
|
|
98
|
-
expect(isImmutableConfigPath("approvals", "rules")).toBe(true);
|
|
99
|
-
});
|
|
100
|
-
it("rejects approvals deep child: approvals defaultMode", () => {
|
|
101
|
-
expect(isImmutableConfigPath("approvals", "defaultMode")).toBe(true);
|
|
102
|
-
});
|
|
103
|
-
// CFG-07: browser.noSandbox
|
|
104
|
-
it("rejects browser.noSandbox exact match", () => {
|
|
105
|
-
expect(isImmutableConfigPath("browser", "noSandbox")).toBe(true);
|
|
106
|
-
});
|
|
107
|
-
// INFRA-05: daemon.logging
|
|
108
|
-
it("rejects daemon.logging exact match", () => {
|
|
109
|
-
expect(isImmutableConfigPath("daemon", "logging")).toBe(true);
|
|
110
|
-
});
|
|
111
|
-
it("rejects daemon.logging.filePath child", () => {
|
|
112
|
-
expect(isImmutableConfigPath("daemon", "logging.filePath")).toBe(true);
|
|
113
|
-
});
|
|
114
|
-
it("rejects daemon.logging.maxSize child", () => {
|
|
115
|
-
expect(isImmutableConfigPath("daemon", "logging.maxSize")).toBe(true);
|
|
116
|
-
});
|
|
117
|
-
it("rejects daemon.logging.maxFiles child", () => {
|
|
118
|
-
expect(isImmutableConfigPath("daemon", "logging.maxFiles")).toBe(true);
|
|
119
|
-
});
|
|
120
|
-
it("rejects daemon.logging.compress child", () => {
|
|
121
|
-
expect(isImmutableConfigPath("daemon", "logging.compress")).toBe(true);
|
|
122
|
-
});
|
|
123
|
-
it("allows daemon top-level (not immutable)", () => {
|
|
124
|
-
expect(isImmutableConfigPath("daemon")).toBe(false);
|
|
125
|
-
});
|
|
126
|
-
it("allows daemon.watchdogIntervalMs (not logging)", () => {
|
|
127
|
-
expect(isImmutableConfigPath("daemon", "watchdogIntervalMs")).toBe(false);
|
|
128
|
-
});
|
|
129
|
-
it("allows daemon.logLevels (mutable at runtime, not file logging)", () => {
|
|
130
|
-
expect(isImmutableConfigPath("daemon", "logLevels")).toBe(false);
|
|
131
|
-
});
|
|
132
|
-
// CFG-07: Mutable paths (not immutable)
|
|
133
|
-
it("allows browser section (top-level)", () => {
|
|
134
|
-
expect(isImmutableConfigPath("browser")).toBe(false);
|
|
135
|
-
});
|
|
136
|
-
it("allows browser.headless (mutable at runtime)", () => {
|
|
137
|
-
expect(isImmutableConfigPath("browser", "headless")).toBe(false);
|
|
138
|
-
});
|
|
139
|
-
it("allows browser.viewport.width (mutable at runtime)", () => {
|
|
140
|
-
expect(isImmutableConfigPath("browser", "viewport.width")).toBe(false);
|
|
141
|
-
});
|
|
142
|
-
it("allows models section (mutable at runtime)", () => {
|
|
143
|
-
expect(isImmutableConfigPath("models")).toBe(false);
|
|
144
|
-
});
|
|
145
|
-
it("allows models.aliases (mutable at runtime)", () => {
|
|
146
|
-
expect(isImmutableConfigPath("models", "aliases")).toBe(false);
|
|
147
|
-
});
|
|
148
|
-
it("allows messages section (mutable at runtime)", () => {
|
|
149
|
-
expect(isImmutableConfigPath("messages")).toBe(false);
|
|
150
|
-
});
|
|
151
|
-
it("allows messages.splitMaxChars (mutable at runtime)", () => {
|
|
152
|
-
expect(isImmutableConfigPath("messages", "splitMaxChars")).toBe(false);
|
|
153
|
-
});
|
|
154
|
-
// Non-immutable paths
|
|
155
|
-
it("allows scheduler section", () => {
|
|
156
|
-
expect(isImmutableConfigPath("scheduler")).toBe(false);
|
|
157
|
-
});
|
|
158
|
-
it("allows memory section (top-level)", () => {
|
|
159
|
-
expect(isImmutableConfigPath("memory")).toBe(false);
|
|
160
|
-
});
|
|
161
|
-
it("allows memory key: memory maxEntries", () => {
|
|
162
|
-
expect(isImmutableConfigPath("memory", "maxEntries")).toBe(false);
|
|
163
|
-
});
|
|
164
|
-
it("allows gateway non-sensitive key: gateway maxBatchSize", () => {
|
|
165
|
-
expect(isImmutableConfigPath("gateway", "maxBatchSize")).toBe(false);
|
|
166
|
-
});
|
|
167
|
-
it("allows gateway non-sensitive key: gateway rateLimit.maxRequests", () => {
|
|
168
|
-
expect(isImmutableConfigPath("gateway", "rateLimit.maxRequests")).toBe(false);
|
|
169
|
-
});
|
|
170
|
-
// Partial prefix protection
|
|
171
|
-
it("does not match partial prefix: securityExtra", () => {
|
|
172
|
-
expect(isImmutableConfigPath("securityExtra")).toBe(false);
|
|
173
|
-
});
|
|
174
|
-
it("does not match partial prefix with key: securityExtra foo", () => {
|
|
175
|
-
expect(isImmutableConfigPath("securityExtra", "foo")).toBe(false);
|
|
176
|
-
});
|
|
177
|
-
it("does not match partial prefix: channelsExtra", () => {
|
|
178
|
-
expect(isImmutableConfigPath("channelsExtra")).toBe(false);
|
|
179
|
-
});
|
|
180
|
-
it("does not match partial prefix: integrationsExtra", () => {
|
|
181
|
-
expect(isImmutableConfigPath("integrationsExtra")).toBe(false);
|
|
182
|
-
});
|
|
183
|
-
// Mutable overrides: operational agent settings
|
|
184
|
-
it("allows agents.default.skills.watchEnabled (mutable override)", () => {
|
|
185
|
-
expect(isImmutableConfigPath("agents", "default.skills.watchEnabled")).toBe(false);
|
|
186
|
-
});
|
|
187
|
-
it("allows agents.default.skills.watchDebounceMs (mutable override)", () => {
|
|
188
|
-
expect(isImmutableConfigPath("agents", "default.skills.watchDebounceMs")).toBe(false);
|
|
189
|
-
});
|
|
190
|
-
it("allows agents.default.skills.discoveryPaths (mutable override)", () => {
|
|
191
|
-
expect(isImmutableConfigPath("agents", "default.skills.discoveryPaths")).toBe(false);
|
|
192
|
-
});
|
|
193
|
-
it("allows agents.default.maxSteps (mutable override)", () => {
|
|
194
|
-
expect(isImmutableConfigPath("agents", "default.maxSteps")).toBe(false);
|
|
195
|
-
});
|
|
196
|
-
it("allows agents.default.persona (mutable override)", () => {
|
|
197
|
-
expect(isImmutableConfigPath("agents", "default.persona")).toBe(false);
|
|
198
|
-
});
|
|
199
|
-
it("allows agents.default.persona.name (child of mutable override)", () => {
|
|
200
|
-
expect(isImmutableConfigPath("agents", "default.persona.name")).toBe(false);
|
|
201
|
-
});
|
|
202
|
-
it("allows agents.default.persona.tone (child of mutable override)", () => {
|
|
203
|
-
expect(isImmutableConfigPath("agents", "default.persona.tone")).toBe(false);
|
|
204
|
-
});
|
|
205
|
-
// Mutable overrides: promptTimeout runtime tuning
|
|
206
|
-
it("allows agents.*.promptTimeout.promptTimeoutMs (mutable override for timeout tuning)", () => {
|
|
207
|
-
expect(isImmutableConfigPath("agents", "default.promptTimeout.promptTimeoutMs")).toBe(false);
|
|
208
|
-
});
|
|
209
|
-
it("allows agents.*.promptTimeout.retryPromptTimeoutMs (mutable override for retry timeout tuning)", () => {
|
|
210
|
-
expect(isImmutableConfigPath("agents", "default.promptTimeout.retryPromptTimeoutMs")).toBe(false);
|
|
211
|
-
});
|
|
212
|
-
// Mutable overrides: per-channel media processing toggles
|
|
213
|
-
it("allows channels.telegram.mediaProcessing (mutable override)", () => {
|
|
214
|
-
expect(isImmutableConfigPath("channels", "telegram.mediaProcessing")).toBe(false);
|
|
215
|
-
});
|
|
216
|
-
it("allows channels.telegram.mediaProcessing.describeVideos (child of mutable override)", () => {
|
|
217
|
-
expect(isImmutableConfigPath("channels", "telegram.mediaProcessing.describeVideos")).toBe(false);
|
|
218
|
-
});
|
|
219
|
-
it("allows channels.discord.mediaProcessing.transcribeAudio (mutable override)", () => {
|
|
220
|
-
expect(isImmutableConfigPath("channels", "discord.mediaProcessing.transcribeAudio")).toBe(false);
|
|
221
|
-
});
|
|
222
|
-
// Channel credentials remain immutable despite mediaProcessing override
|
|
223
|
-
it("rejects channels.telegram.botToken (NOT overridden, still immutable)", () => {
|
|
224
|
-
expect(isImmutableConfigPath("channels", "telegram.botToken")).toBe(true);
|
|
225
|
-
});
|
|
226
|
-
// Security-sensitive agent settings remain immutable despite overrides
|
|
227
|
-
it("rejects agents.default.model (NOT overridden, still immutable)", () => {
|
|
228
|
-
expect(isImmutableConfigPath("agents", "default.model")).toBe(true);
|
|
229
|
-
});
|
|
230
|
-
it("rejects agents.default.budgets.maxDailyUsd (NOT overridden, still immutable)", () => {
|
|
231
|
-
expect(isImmutableConfigPath("agents", "default.budgets.maxDailyUsd")).toBe(true);
|
|
232
|
-
});
|
|
233
|
-
it("rejects agents.default.toolPolicy (NOT overridden, still immutable)", () => {
|
|
234
|
-
expect(isImmutableConfigPath("agents", "default.toolPolicy")).toBe(true);
|
|
235
|
-
});
|
|
236
|
-
it("rejects agents.default.modelRoutes.default (NOT overridden, still immutable)", () => {
|
|
237
|
-
expect(isImmutableConfigPath("agents", "default.modelRoutes.default")).toBe(true);
|
|
238
|
-
});
|
|
239
|
-
it("rejects agents.default.provider (NOT overridden, still immutable)", () => {
|
|
240
|
-
expect(isImmutableConfigPath("agents", "default.provider")).toBe(true);
|
|
241
|
-
});
|
|
242
|
-
// Mutable override: MCP server management
|
|
243
|
-
it("allows integrations.mcp.servers (mutable override for MCP management)", () => {
|
|
244
|
-
expect(isImmutableConfigPath("integrations", "mcp.servers")).toBe(false);
|
|
245
|
-
});
|
|
246
|
-
// Other integrations remain immutable
|
|
247
|
-
it("rejects integrations.mcp (parent path still immutable)", () => {
|
|
248
|
-
expect(isImmutableConfigPath("integrations", "mcp")).toBe(true);
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
describe("MUTABLE_CONFIG_OVERRIDES", () => {
|
|
252
|
-
it("contains exactly 10 override patterns", () => {
|
|
253
|
-
expect(MUTABLE_CONFIG_OVERRIDES).toHaveLength(10);
|
|
254
|
-
});
|
|
255
|
-
it("agent/channel patterns use * wildcard for second segment", () => {
|
|
256
|
-
const wildcardPatterns = MUTABLE_CONFIG_OVERRIDES.filter((p) => p.startsWith("agents.") || p.startsWith("channels."));
|
|
257
|
-
for (const pattern of wildcardPatterns) {
|
|
258
|
-
const parts = pattern.split(".");
|
|
259
|
-
expect(parts[1]).toBe("*");
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
});
|
|
263
|
-
describe("matchesOverridePattern", () => {
|
|
264
|
-
it("matches exact path to pattern", () => {
|
|
265
|
-
expect(matchesOverridePattern("agents.default.persona", "agents.*.persona")).toBe(true);
|
|
266
|
-
});
|
|
267
|
-
it("matches child path of pattern", () => {
|
|
268
|
-
expect(matchesOverridePattern("agents.default.persona.name", "agents.*.persona")).toBe(true);
|
|
269
|
-
});
|
|
270
|
-
it("rejects path shorter than pattern", () => {
|
|
271
|
-
expect(matchesOverridePattern("agents.default", "agents.*.persona")).toBe(false);
|
|
272
|
-
});
|
|
273
|
-
it("rejects path with wrong literal segment", () => {
|
|
274
|
-
expect(matchesOverridePattern("agents.default.model", "agents.*.persona")).toBe(false);
|
|
275
|
-
});
|
|
276
|
-
it("wildcard matches any single segment", () => {
|
|
277
|
-
expect(matchesOverridePattern("agents.mybot.maxSteps", "agents.*.maxSteps")).toBe(true);
|
|
278
|
-
expect(matchesOverridePattern("agents.production-bot.maxSteps", "agents.*.maxSteps")).toBe(true);
|
|
279
|
-
});
|
|
280
|
-
it("rejects path missing intermediate segment", () => {
|
|
281
|
-
expect(matchesOverridePattern("agents.persona", "agents.*.persona")).toBe(false);
|
|
282
|
-
});
|
|
283
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { ok, err } from "@comis/shared";
|
|
3
|
-
import { resolveIncludes } from "./include-resolver.js";
|
|
4
|
-
/**
|
|
5
|
-
* Helper to create mock deps with a virtual filesystem.
|
|
6
|
-
* Files are keyed by absolute path, values are raw YAML/JSON strings.
|
|
7
|
-
*/
|
|
8
|
-
function createMockDeps(files) {
|
|
9
|
-
return {
|
|
10
|
-
readFile(absPath) {
|
|
11
|
-
if (absPath in files) {
|
|
12
|
-
return ok(files[absPath]);
|
|
13
|
-
}
|
|
14
|
-
return err({
|
|
15
|
-
code: "FILE_NOT_FOUND",
|
|
16
|
-
message: `File not found: ${absPath}`,
|
|
17
|
-
path: absPath,
|
|
18
|
-
});
|
|
19
|
-
},
|
|
20
|
-
parseFn(raw, _filePath) {
|
|
21
|
-
try {
|
|
22
|
-
// Simple JSON parse for tests (YAML is a superset of JSON)
|
|
23
|
-
const parsed = JSON.parse(raw);
|
|
24
|
-
if (parsed === null || parsed === undefined) {
|
|
25
|
-
return ok({});
|
|
26
|
-
}
|
|
27
|
-
if (typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
28
|
-
return err({
|
|
29
|
-
code: "PARSE_ERROR",
|
|
30
|
-
message: `Expected object, got ${typeof parsed}`,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
return ok(parsed);
|
|
34
|
-
}
|
|
35
|
-
catch (e) {
|
|
36
|
-
return err({
|
|
37
|
-
code: "PARSE_ERROR",
|
|
38
|
-
message: `Parse error: ${e.message}`,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
resolvePath(basePath, includePath) {
|
|
43
|
-
// Simple path join for tests — in production this uses safePath()
|
|
44
|
-
// Reject traversal attempts in tests too
|
|
45
|
-
if (includePath.includes("..")) {
|
|
46
|
-
return err({
|
|
47
|
-
code: "INCLUDE_ERROR",
|
|
48
|
-
message: `Path traversal blocked: "${includePath}" escapes base "${basePath}"`,
|
|
49
|
-
path: includePath,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
const resolved = basePath + "/" + includePath;
|
|
53
|
-
return ok(resolved);
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
describe("config/include-resolver", () => {
|
|
58
|
-
describe("resolveIncludes", () => {
|
|
59
|
-
it("resolves simple $include and deep-merges included content", () => {
|
|
60
|
-
const deps = createMockDeps({
|
|
61
|
-
"/config/base.json": JSON.stringify({
|
|
62
|
-
logLevel: "debug",
|
|
63
|
-
agents: { default: { name: "BaseBot" } },
|
|
64
|
-
}),
|
|
65
|
-
});
|
|
66
|
-
const obj = {
|
|
67
|
-
$include: "base.json",
|
|
68
|
-
tenantId: "my-tenant",
|
|
69
|
-
};
|
|
70
|
-
const result = resolveIncludes(obj, "/config", deps);
|
|
71
|
-
expect(result.ok).toBe(true);
|
|
72
|
-
if (result.ok) {
|
|
73
|
-
const val = result.value;
|
|
74
|
-
// Included content is base, sibling keys override
|
|
75
|
-
expect(val.logLevel).toBe("debug");
|
|
76
|
-
expect(val.tenantId).toBe("my-tenant");
|
|
77
|
-
const agents = val.agents;
|
|
78
|
-
expect(agents.default.name).toBe("BaseBot");
|
|
79
|
-
// $include key should be removed
|
|
80
|
-
expect(val.$include).toBeUndefined();
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
it("resolves nested includes (included file includes another file)", () => {
|
|
84
|
-
const deps = createMockDeps({
|
|
85
|
-
"/config/a.json": JSON.stringify({
|
|
86
|
-
$include: "b.json",
|
|
87
|
-
fromA: true,
|
|
88
|
-
}),
|
|
89
|
-
"/config/b.json": JSON.stringify({
|
|
90
|
-
fromB: true,
|
|
91
|
-
shared: "from-b",
|
|
92
|
-
}),
|
|
93
|
-
});
|
|
94
|
-
const obj = {
|
|
95
|
-
$include: "a.json",
|
|
96
|
-
topLevel: "value",
|
|
97
|
-
};
|
|
98
|
-
const result = resolveIncludes(obj, "/config", deps);
|
|
99
|
-
expect(result.ok).toBe(true);
|
|
100
|
-
if (result.ok) {
|
|
101
|
-
const val = result.value;
|
|
102
|
-
expect(val.fromB).toBe(true);
|
|
103
|
-
expect(val.fromA).toBe(true);
|
|
104
|
-
expect(val.topLevel).toBe("value");
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
it("detects circular reference: A includes B includes A", () => {
|
|
108
|
-
const deps = createMockDeps({
|
|
109
|
-
"/config/a.json": JSON.stringify({ $include: "b.json" }),
|
|
110
|
-
"/config/b.json": JSON.stringify({ $include: "a.json" }),
|
|
111
|
-
});
|
|
112
|
-
const obj = { $include: "a.json" };
|
|
113
|
-
const result = resolveIncludes(obj, "/config", deps);
|
|
114
|
-
expect(result.ok).toBe(false);
|
|
115
|
-
if (!result.ok) {
|
|
116
|
-
expect(result.error.code).toBe("CIRCULAR_INCLUDE");
|
|
117
|
-
expect(result.error.message).toContain("Circular");
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
it("returns INCLUDE_ERROR when depth limit (MAX_INCLUDE_DEPTH = 10) is exceeded", () => {
|
|
121
|
-
// Create a chain of 12 files, each including the next
|
|
122
|
-
const files = {};
|
|
123
|
-
for (let i = 0; i < 12; i++) {
|
|
124
|
-
files[`/config/f${i}.json`] = JSON.stringify({
|
|
125
|
-
$include: `f${i + 1}.json`,
|
|
126
|
-
[`key${i}`]: i,
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
files["/config/f12.json"] = JSON.stringify({ leaf: true });
|
|
130
|
-
const deps = createMockDeps(files);
|
|
131
|
-
const obj = { $include: "f0.json" };
|
|
132
|
-
const result = resolveIncludes(obj, "/config", deps);
|
|
133
|
-
expect(result.ok).toBe(false);
|
|
134
|
-
if (!result.ok) {
|
|
135
|
-
expect(result.error.code).toBe("INCLUDE_ERROR");
|
|
136
|
-
expect(result.error.message).toContain("depth");
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
it("rejects include path traversal attempt via resolvePath", () => {
|
|
140
|
-
const deps = createMockDeps({});
|
|
141
|
-
const obj = { $include: "../../../etc/passwd" };
|
|
142
|
-
const result = resolveIncludes(obj, "/config", deps);
|
|
143
|
-
expect(result.ok).toBe(false);
|
|
144
|
-
if (!result.ok) {
|
|
145
|
-
expect(result.error.code).toBe("INCLUDE_ERROR");
|
|
146
|
-
expect(result.error.message).toContain("traversal");
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
it("returns INCLUDE_ERROR for non-existent included file", () => {
|
|
150
|
-
const deps = createMockDeps({});
|
|
151
|
-
const obj = { $include: "missing.json" };
|
|
152
|
-
const result = resolveIncludes(obj, "/config", deps);
|
|
153
|
-
expect(result.ok).toBe(false);
|
|
154
|
-
if (!result.ok) {
|
|
155
|
-
expect(result.error.code).toBe("INCLUDE_ERROR");
|
|
156
|
-
expect(result.error.message).toContain("missing.json");
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
it("deep-merges sibling keys alongside $include (siblings override included content)", () => {
|
|
160
|
-
const deps = createMockDeps({
|
|
161
|
-
"/config/base.json": JSON.stringify({
|
|
162
|
-
agents: { default: { name: "Base", model: "gpt-4" } },
|
|
163
|
-
logLevel: "info",
|
|
164
|
-
}),
|
|
165
|
-
});
|
|
166
|
-
const obj = {
|
|
167
|
-
$include: "base.json",
|
|
168
|
-
agents: { default: { name: "Override" } },
|
|
169
|
-
};
|
|
170
|
-
const result = resolveIncludes(obj, "/config", deps);
|
|
171
|
-
expect(result.ok).toBe(true);
|
|
172
|
-
if (result.ok) {
|
|
173
|
-
const val = result.value;
|
|
174
|
-
const agents = val.agents;
|
|
175
|
-
// Sibling overrides included
|
|
176
|
-
expect(agents.default.name).toBe("Override");
|
|
177
|
-
// Included fields preserved where not overridden
|
|
178
|
-
expect(agents.default.model).toBe("gpt-4");
|
|
179
|
-
expect(val.logLevel).toBe("info");
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
it("resolves $include at nested object levels (not just top-level)", () => {
|
|
183
|
-
const deps = createMockDeps({
|
|
184
|
-
"/config/memory-defaults.json": JSON.stringify({
|
|
185
|
-
walMode: true,
|
|
186
|
-
compaction: { enabled: true, threshold: 500 },
|
|
187
|
-
}),
|
|
188
|
-
});
|
|
189
|
-
const obj = {
|
|
190
|
-
tenantId: "test",
|
|
191
|
-
memory: {
|
|
192
|
-
$include: "memory-defaults.json",
|
|
193
|
-
dbPath: "/custom/path.db",
|
|
194
|
-
},
|
|
195
|
-
};
|
|
196
|
-
const result = resolveIncludes(obj, "/config", deps);
|
|
197
|
-
expect(result.ok).toBe(true);
|
|
198
|
-
if (result.ok) {
|
|
199
|
-
const val = result.value;
|
|
200
|
-
expect(val.tenantId).toBe("test");
|
|
201
|
-
const memory = val.memory;
|
|
202
|
-
expect(memory.walMode).toBe(true);
|
|
203
|
-
expect(memory.dbPath).toBe("/custom/path.db");
|
|
204
|
-
const compaction = memory.compaction;
|
|
205
|
-
expect(compaction.enabled).toBe(true);
|
|
206
|
-
expect(compaction.threshold).toBe(500);
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
it("resolves multiple $include directives across different nested paths", () => {
|
|
210
|
-
const deps = createMockDeps({
|
|
211
|
-
"/config/agent-defaults.json": JSON.stringify({
|
|
212
|
-
name: "DefaultAgent",
|
|
213
|
-
model: "gpt-4",
|
|
214
|
-
}),
|
|
215
|
-
"/config/memory-defaults.json": JSON.stringify({
|
|
216
|
-
walMode: true,
|
|
217
|
-
embeddingModel: "text-embedding-3-small",
|
|
218
|
-
}),
|
|
219
|
-
});
|
|
220
|
-
const obj = {
|
|
221
|
-
tenantId: "multi",
|
|
222
|
-
agents: {
|
|
223
|
-
default: {
|
|
224
|
-
$include: "agent-defaults.json",
|
|
225
|
-
maxSteps: 25,
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
memory: {
|
|
229
|
-
$include: "memory-defaults.json",
|
|
230
|
-
dbPath: "/var/db.sqlite",
|
|
231
|
-
},
|
|
232
|
-
};
|
|
233
|
-
const result = resolveIncludes(obj, "/config", deps);
|
|
234
|
-
expect(result.ok).toBe(true);
|
|
235
|
-
if (result.ok) {
|
|
236
|
-
const val = result.value;
|
|
237
|
-
expect(val.tenantId).toBe("multi");
|
|
238
|
-
const agents = val.agents;
|
|
239
|
-
expect(agents.default.name).toBe("DefaultAgent");
|
|
240
|
-
expect(agents.default.model).toBe("gpt-4");
|
|
241
|
-
expect(agents.default.maxSteps).toBe(25);
|
|
242
|
-
const memory = val.memory;
|
|
243
|
-
expect(memory.walMode).toBe(true);
|
|
244
|
-
expect(memory.embeddingModel).toBe("text-embedding-3-small");
|
|
245
|
-
expect(memory.dbPath).toBe("/var/db.sqlite");
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
it("passes through non-object values unchanged", () => {
|
|
249
|
-
const deps = createMockDeps({});
|
|
250
|
-
// Primitives and arrays should pass through
|
|
251
|
-
const result1 = resolveIncludes("hello", "/config", deps);
|
|
252
|
-
expect(result1.ok).toBe(true);
|
|
253
|
-
if (result1.ok) {
|
|
254
|
-
expect(result1.value).toBe("hello");
|
|
255
|
-
}
|
|
256
|
-
const result2 = resolveIncludes(42, "/config", deps);
|
|
257
|
-
expect(result2.ok).toBe(true);
|
|
258
|
-
if (result2.ok) {
|
|
259
|
-
expect(result2.value).toBe(42);
|
|
260
|
-
}
|
|
261
|
-
const result3 = resolveIncludes([1, 2, 3], "/config", deps);
|
|
262
|
-
expect(result3.ok).toBe(true);
|
|
263
|
-
if (result3.ok) {
|
|
264
|
-
expect(result3.value).toEqual([1, 2, 3]);
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
it("resolves $include in array elements that are objects", () => {
|
|
268
|
-
const deps = createMockDeps({
|
|
269
|
-
"/config/item.json": JSON.stringify({
|
|
270
|
-
name: "from-include",
|
|
271
|
-
value: 42,
|
|
272
|
-
}),
|
|
273
|
-
});
|
|
274
|
-
const obj = {
|
|
275
|
-
items: [
|
|
276
|
-
{ $include: "item.json", extra: "data" },
|
|
277
|
-
{ plain: "object" },
|
|
278
|
-
],
|
|
279
|
-
};
|
|
280
|
-
const result = resolveIncludes(obj, "/config", deps);
|
|
281
|
-
expect(result.ok).toBe(true);
|
|
282
|
-
if (result.ok) {
|
|
283
|
-
const val = result.value;
|
|
284
|
-
const items = val.items;
|
|
285
|
-
expect(items[0].name).toBe("from-include");
|
|
286
|
-
expect(items[0].value).toBe(42);
|
|
287
|
-
expect(items[0].extra).toBe("data");
|
|
288
|
-
expect(items[1].plain).toBe("object");
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|