comisai 1.0.10 → 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/README.md +3 -3
- 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/dist/wizard/steps/06-channels.js +88 -11
- package/node_modules/@comis/cli/dist/wizard/steps/10-write-config.js +4 -0
- package/node_modules/@comis/cli/dist/wizard/types.d.ts +1 -0
- 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,291 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { parseSessionKey, formatSessionKey, parseFormattedSessionKey } from "./session-key.js";
|
|
3
|
-
function validKey(overrides = {}) {
|
|
4
|
-
return {
|
|
5
|
-
userId: "user-42",
|
|
6
|
-
channelId: "general",
|
|
7
|
-
...overrides,
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
describe("SessionKey", () => {
|
|
11
|
-
describe("valid data", () => {
|
|
12
|
-
it("parses a minimal valid key", () => {
|
|
13
|
-
const result = parseSessionKey(validKey());
|
|
14
|
-
expect(result.ok).toBe(true);
|
|
15
|
-
if (result.ok) {
|
|
16
|
-
expect(result.value.userId).toBe("user-42");
|
|
17
|
-
expect(result.value.channelId).toBe("general");
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
it("applies default tenantId", () => {
|
|
21
|
-
const result = parseSessionKey(validKey());
|
|
22
|
-
expect(result.ok).toBe(true);
|
|
23
|
-
if (result.ok) {
|
|
24
|
-
expect(result.value.tenantId).toBe("default");
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
it("accepts explicit tenantId", () => {
|
|
28
|
-
const result = parseSessionKey(validKey({ tenantId: "acme" }));
|
|
29
|
-
expect(result.ok).toBe(true);
|
|
30
|
-
if (result.ok) {
|
|
31
|
-
expect(result.value.tenantId).toBe("acme");
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
it("accepts optional peerId", () => {
|
|
35
|
-
const result = parseSessionKey(validKey({ peerId: "peer-99" }));
|
|
36
|
-
expect(result.ok).toBe(true);
|
|
37
|
-
if (result.ok) {
|
|
38
|
-
expect(result.value.peerId).toBe("peer-99");
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
it("accepts optional guildId", () => {
|
|
42
|
-
const result = parseSessionKey(validKey({ guildId: "guild-7" }));
|
|
43
|
-
expect(result.ok).toBe(true);
|
|
44
|
-
if (result.ok) {
|
|
45
|
-
expect(result.value.guildId).toBe("guild-7");
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
it("allows omitting optional fields (peerId, guildId)", () => {
|
|
49
|
-
const result = parseSessionKey(validKey());
|
|
50
|
-
expect(result.ok).toBe(true);
|
|
51
|
-
if (result.ok) {
|
|
52
|
-
expect(result.value.peerId).toBeUndefined();
|
|
53
|
-
expect(result.value.guildId).toBeUndefined();
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
it("accepts optional agentId", () => {
|
|
57
|
-
const result = parseSessionKey(validKey({ agentId: "dash" }));
|
|
58
|
-
expect(result.ok).toBe(true);
|
|
59
|
-
if (result.ok) {
|
|
60
|
-
expect(result.value.agentId).toBe("dash");
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
it("accepts optional threadId", () => {
|
|
64
|
-
const result = parseSessionKey(validKey({ threadId: "t-123" }));
|
|
65
|
-
expect(result.ok).toBe(true);
|
|
66
|
-
if (result.ok) {
|
|
67
|
-
expect(result.value.threadId).toBe("t-123");
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
describe("invalid data", () => {
|
|
72
|
-
it("rejects missing required fields", () => {
|
|
73
|
-
const result = parseSessionKey({});
|
|
74
|
-
expect(result.ok).toBe(false);
|
|
75
|
-
if (!result.ok) {
|
|
76
|
-
const paths = result.error.issues.map((i) => i.path[0]);
|
|
77
|
-
expect(paths).toContain("userId");
|
|
78
|
-
expect(paths).toContain("channelId");
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
it("rejects empty userId", () => {
|
|
82
|
-
const result = parseSessionKey(validKey({ userId: "" }));
|
|
83
|
-
expect(result.ok).toBe(false);
|
|
84
|
-
});
|
|
85
|
-
it("rejects empty channelId", () => {
|
|
86
|
-
const result = parseSessionKey(validKey({ channelId: "" }));
|
|
87
|
-
expect(result.ok).toBe(false);
|
|
88
|
-
});
|
|
89
|
-
it("rejects empty tenantId", () => {
|
|
90
|
-
const result = parseSessionKey(validKey({ tenantId: "" }));
|
|
91
|
-
expect(result.ok).toBe(false);
|
|
92
|
-
});
|
|
93
|
-
it("strips extra/unknown fields", () => {
|
|
94
|
-
const result = parseSessionKey(validKey({ extra: "data" }));
|
|
95
|
-
expect(result.ok).toBe(false);
|
|
96
|
-
});
|
|
97
|
-
it("rejects non-object input", () => {
|
|
98
|
-
const result = parseSessionKey("not-an-object");
|
|
99
|
-
expect(result.ok).toBe(false);
|
|
100
|
-
});
|
|
101
|
-
it("rejects null input", () => {
|
|
102
|
-
const result = parseSessionKey(null);
|
|
103
|
-
expect(result.ok).toBe(false);
|
|
104
|
-
});
|
|
105
|
-
it("returns descriptive ZodError issues", () => {
|
|
106
|
-
const result = parseSessionKey({ userId: 123 });
|
|
107
|
-
expect(result.ok).toBe(false);
|
|
108
|
-
if (!result.ok) {
|
|
109
|
-
expect(result.error.issues.length).toBeGreaterThan(0);
|
|
110
|
-
for (const issue of result.error.issues) {
|
|
111
|
-
expect(issue.message).toBeTruthy();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
describe("formatSessionKey", () => {
|
|
117
|
-
it("formats basic key", () => {
|
|
118
|
-
const key = {
|
|
119
|
-
tenantId: "default",
|
|
120
|
-
userId: "user-42",
|
|
121
|
-
channelId: "general",
|
|
122
|
-
};
|
|
123
|
-
expect(formatSessionKey(key)).toBe("default:user-42:general");
|
|
124
|
-
});
|
|
125
|
-
it("includes peerId when present", () => {
|
|
126
|
-
const key = {
|
|
127
|
-
tenantId: "default",
|
|
128
|
-
userId: "user-42",
|
|
129
|
-
channelId: "general",
|
|
130
|
-
peerId: "peer-99",
|
|
131
|
-
};
|
|
132
|
-
expect(formatSessionKey(key)).toBe("default:user-42:general:peer:peer-99");
|
|
133
|
-
});
|
|
134
|
-
it("includes guildId when present", () => {
|
|
135
|
-
const key = {
|
|
136
|
-
tenantId: "default",
|
|
137
|
-
userId: "user-42",
|
|
138
|
-
channelId: "general",
|
|
139
|
-
guildId: "guild-7",
|
|
140
|
-
};
|
|
141
|
-
expect(formatSessionKey(key)).toBe("default:user-42:general:guild:guild-7");
|
|
142
|
-
});
|
|
143
|
-
it("includes both peerId and guildId when present", () => {
|
|
144
|
-
const key = {
|
|
145
|
-
tenantId: "acme",
|
|
146
|
-
userId: "user-1",
|
|
147
|
-
channelId: "ch-1",
|
|
148
|
-
peerId: "p-1",
|
|
149
|
-
guildId: "g-1",
|
|
150
|
-
};
|
|
151
|
-
expect(formatSessionKey(key)).toBe("acme:user-1:ch-1:peer:p-1:guild:g-1");
|
|
152
|
-
});
|
|
153
|
-
it("uses custom tenantId", () => {
|
|
154
|
-
const key = {
|
|
155
|
-
tenantId: "acme-corp",
|
|
156
|
-
userId: "admin",
|
|
157
|
-
channelId: "ops",
|
|
158
|
-
};
|
|
159
|
-
expect(formatSessionKey(key)).toBe("acme-corp:admin:ops");
|
|
160
|
-
});
|
|
161
|
-
it("prepends agent prefix when agentId is set", () => {
|
|
162
|
-
const key = {
|
|
163
|
-
tenantId: "default",
|
|
164
|
-
userId: "user-42",
|
|
165
|
-
channelId: "general",
|
|
166
|
-
agentId: "myAgent",
|
|
167
|
-
};
|
|
168
|
-
expect(formatSessionKey(key)).toBe("agent:myAgent:default:user-42:general");
|
|
169
|
-
});
|
|
170
|
-
it("appends thread suffix when threadId is set", () => {
|
|
171
|
-
const key = {
|
|
172
|
-
tenantId: "default",
|
|
173
|
-
userId: "user-42",
|
|
174
|
-
channelId: "general",
|
|
175
|
-
threadId: "t123",
|
|
176
|
-
};
|
|
177
|
-
expect(formatSessionKey(key)).toBe("default:user-42:general:thread:t123");
|
|
178
|
-
});
|
|
179
|
-
it("includes both agentId and threadId", () => {
|
|
180
|
-
const key = {
|
|
181
|
-
tenantId: "default",
|
|
182
|
-
userId: "u1",
|
|
183
|
-
channelId: "c1",
|
|
184
|
-
peerId: "p1",
|
|
185
|
-
agentId: "dash",
|
|
186
|
-
threadId: "th-7",
|
|
187
|
-
};
|
|
188
|
-
expect(formatSessionKey(key)).toBe("agent:dash:default:u1:c1:peer:p1:thread:th-7");
|
|
189
|
-
});
|
|
190
|
-
it("produces identical output without agentId/threadId", () => {
|
|
191
|
-
const key = {
|
|
192
|
-
tenantId: "default",
|
|
193
|
-
userId: "user-42",
|
|
194
|
-
channelId: "general",
|
|
195
|
-
peerId: "peer-99",
|
|
196
|
-
guildId: "guild-7",
|
|
197
|
-
};
|
|
198
|
-
// Must match the original format exactly
|
|
199
|
-
expect(formatSessionKey(key)).toBe("default:user-42:general:peer:peer-99:guild:guild-7");
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
|
-
describe("parseFormattedSessionKey", () => {
|
|
203
|
-
it("parses basic 3-part key", () => {
|
|
204
|
-
const key = parseFormattedSessionKey("default:user-1:chan-1");
|
|
205
|
-
expect(key).toEqual({ tenantId: "default", userId: "user-1", channelId: "chan-1" });
|
|
206
|
-
});
|
|
207
|
-
it("parses key with peer segment", () => {
|
|
208
|
-
const key = parseFormattedSessionKey("default:user-1:chan-1:peer:peer-1");
|
|
209
|
-
expect(key).toEqual({ tenantId: "default", userId: "user-1", channelId: "chan-1", peerId: "peer-1" });
|
|
210
|
-
});
|
|
211
|
-
it("parses key with guild segment", () => {
|
|
212
|
-
const key = parseFormattedSessionKey("default:user-1:chan-1:guild:guild-1");
|
|
213
|
-
expect(key).toEqual({ tenantId: "default", userId: "user-1", channelId: "chan-1", guildId: "guild-1" });
|
|
214
|
-
});
|
|
215
|
-
it("parses key with both peer and guild", () => {
|
|
216
|
-
const key = parseFormattedSessionKey("default:user-1:chan-1:peer:peer-1:guild:guild-1");
|
|
217
|
-
expect(key).toEqual({
|
|
218
|
-
tenantId: "default", userId: "user-1", channelId: "chan-1",
|
|
219
|
-
peerId: "peer-1", guildId: "guild-1",
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
it("roundtrips with formatSessionKey", () => {
|
|
223
|
-
const original = { tenantId: "t", userId: "u", channelId: "c", peerId: "p", guildId: "g" };
|
|
224
|
-
const formatted = formatSessionKey(original);
|
|
225
|
-
const parsed = parseFormattedSessionKey(formatted);
|
|
226
|
-
expect(parsed).toEqual(original);
|
|
227
|
-
});
|
|
228
|
-
it("returns undefined for invalid format (fewer than 3 parts)", () => {
|
|
229
|
-
expect(parseFormattedSessionKey("only:two")).toBeUndefined();
|
|
230
|
-
expect(parseFormattedSessionKey("one")).toBeUndefined();
|
|
231
|
-
expect(parseFormattedSessionKey("")).toBeUndefined();
|
|
232
|
-
});
|
|
233
|
-
it("parses agent-prefixed key", () => {
|
|
234
|
-
const key = parseFormattedSessionKey("agent:dash:default:user-1:chan-1");
|
|
235
|
-
expect(key).toEqual({
|
|
236
|
-
tenantId: "default",
|
|
237
|
-
userId: "user-1",
|
|
238
|
-
channelId: "chan-1",
|
|
239
|
-
agentId: "dash",
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
it("parses thread-suffixed key", () => {
|
|
243
|
-
const key = parseFormattedSessionKey("default:user-1:chan-1:thread:t-42");
|
|
244
|
-
expect(key).toEqual({
|
|
245
|
-
tenantId: "default",
|
|
246
|
-
userId: "user-1",
|
|
247
|
-
channelId: "chan-1",
|
|
248
|
-
threadId: "t-42",
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
it("parses key with agent prefix, peer, guild, and thread", () => {
|
|
252
|
-
const key = parseFormattedSessionKey("agent:coder:acme:u1:c1:peer:p1:guild:g1:thread:th7");
|
|
253
|
-
expect(key).toEqual({
|
|
254
|
-
tenantId: "acme",
|
|
255
|
-
userId: "u1",
|
|
256
|
-
channelId: "c1",
|
|
257
|
-
peerId: "p1",
|
|
258
|
-
guildId: "g1",
|
|
259
|
-
agentId: "coder",
|
|
260
|
-
threadId: "th7",
|
|
261
|
-
});
|
|
262
|
-
});
|
|
263
|
-
it("roundtrips with new fields (agentId + threadId)", () => {
|
|
264
|
-
const original = {
|
|
265
|
-
tenantId: "t",
|
|
266
|
-
userId: "u",
|
|
267
|
-
channelId: "c",
|
|
268
|
-
peerId: "p",
|
|
269
|
-
guildId: "g",
|
|
270
|
-
agentId: "bot",
|
|
271
|
-
threadId: "th",
|
|
272
|
-
};
|
|
273
|
-
const formatted = formatSessionKey(original);
|
|
274
|
-
const parsed = parseFormattedSessionKey(formatted);
|
|
275
|
-
expect(parsed).toEqual(original);
|
|
276
|
-
});
|
|
277
|
-
it("still handles old format without agent/thread (regression)", () => {
|
|
278
|
-
// Old format keys must parse identically to original behavior
|
|
279
|
-
const key = parseFormattedSessionKey("default:user-1:chan-1:peer:p1:guild:g1");
|
|
280
|
-
expect(key).toEqual({
|
|
281
|
-
tenantId: "default",
|
|
282
|
-
userId: "user-1",
|
|
283
|
-
channelId: "chan-1",
|
|
284
|
-
peerId: "p1",
|
|
285
|
-
guildId: "g1",
|
|
286
|
-
});
|
|
287
|
-
expect(key.agentId).toBeUndefined();
|
|
288
|
-
expect(key.threadId).toBeUndefined();
|
|
289
|
-
});
|
|
290
|
-
});
|
|
291
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { SubagentContextConfigSchema } from "./subagent-context-config.js";
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
// SubagentContextConfigSchema
|
|
5
|
-
// ---------------------------------------------------------------------------
|
|
6
|
-
describe("SubagentContextConfigSchema", () => {
|
|
7
|
-
it("produces valid defaults from empty object", () => {
|
|
8
|
-
const result = SubagentContextConfigSchema.parse({});
|
|
9
|
-
expect(result).toEqual({
|
|
10
|
-
maxSpawnDepth: 3,
|
|
11
|
-
maxChildrenPerAgent: 5,
|
|
12
|
-
maxResultTokens: 4_000,
|
|
13
|
-
resultRetentionMs: 86_400_000,
|
|
14
|
-
condensationStrategy: "auto",
|
|
15
|
-
includeParentHistory: "none",
|
|
16
|
-
objectiveReinforcement: true,
|
|
17
|
-
artifactPassthrough: true,
|
|
18
|
-
autoCompactThreshold: 0.95,
|
|
19
|
-
errorPreservation: true,
|
|
20
|
-
narrativeCasting: true,
|
|
21
|
-
resultTagPrefix: "Subagent Result",
|
|
22
|
-
parentSummaryMaxTokens: 1_000,
|
|
23
|
-
maxQueuedPerAgent: 10,
|
|
24
|
-
queueTimeoutMs: 120_000,
|
|
25
|
-
maxRunTimeoutMs: 600_000,
|
|
26
|
-
perStepTimeoutMs: 60_000,
|
|
27
|
-
});
|
|
28
|
-
// condensationModel is optional with no default -- should NOT be present
|
|
29
|
-
expect("condensationModel" in result).toBe(false);
|
|
30
|
-
});
|
|
31
|
-
it("accepts full override", () => {
|
|
32
|
-
const result = SubagentContextConfigSchema.parse({
|
|
33
|
-
maxSpawnDepth: 5,
|
|
34
|
-
maxChildrenPerAgent: 10,
|
|
35
|
-
maxResultTokens: 8_000,
|
|
36
|
-
resultRetentionMs: 172_800_000,
|
|
37
|
-
condensationStrategy: "always",
|
|
38
|
-
includeParentHistory: "summary",
|
|
39
|
-
objectiveReinforcement: false,
|
|
40
|
-
artifactPassthrough: false,
|
|
41
|
-
autoCompactThreshold: 0.8,
|
|
42
|
-
errorPreservation: false,
|
|
43
|
-
narrativeCasting: false,
|
|
44
|
-
resultTagPrefix: "Custom Tag",
|
|
45
|
-
parentSummaryMaxTokens: 2_000,
|
|
46
|
-
condensationModel: "groq:llama-3.3-70b-versatile",
|
|
47
|
-
maxQueuedPerAgent: 20,
|
|
48
|
-
queueTimeoutMs: 60_000,
|
|
49
|
-
maxRunTimeoutMs: 300_000,
|
|
50
|
-
perStepTimeoutMs: 30_000,
|
|
51
|
-
});
|
|
52
|
-
expect(result.maxSpawnDepth).toBe(5);
|
|
53
|
-
expect(result.maxChildrenPerAgent).toBe(10);
|
|
54
|
-
expect(result.maxResultTokens).toBe(8_000);
|
|
55
|
-
expect(result.resultRetentionMs).toBe(172_800_000);
|
|
56
|
-
expect(result.condensationStrategy).toBe("always");
|
|
57
|
-
expect(result.includeParentHistory).toBe("summary");
|
|
58
|
-
expect(result.objectiveReinforcement).toBe(false);
|
|
59
|
-
expect(result.artifactPassthrough).toBe(false);
|
|
60
|
-
expect(result.autoCompactThreshold).toBe(0.8);
|
|
61
|
-
expect(result.errorPreservation).toBe(false);
|
|
62
|
-
expect(result.narrativeCasting).toBe(false);
|
|
63
|
-
expect(result.resultTagPrefix).toBe("Custom Tag");
|
|
64
|
-
expect(result.parentSummaryMaxTokens).toBe(2_000);
|
|
65
|
-
expect(result.condensationModel).toBe("groq:llama-3.3-70b-versatile");
|
|
66
|
-
expect(result.maxQueuedPerAgent).toBe(20);
|
|
67
|
-
expect(result.queueTimeoutMs).toBe(60_000);
|
|
68
|
-
expect(result.maxRunTimeoutMs).toBe(300_000);
|
|
69
|
-
expect(result.perStepTimeoutMs).toBe(30_000);
|
|
70
|
-
});
|
|
71
|
-
it("accepts condensationModel override", () => {
|
|
72
|
-
const result = SubagentContextConfigSchema.parse({
|
|
73
|
-
condensationModel: "anthropic:claude-haiku-4-20250514",
|
|
74
|
-
});
|
|
75
|
-
expect(result.condensationModel).toBe("anthropic:claude-haiku-4-20250514");
|
|
76
|
-
});
|
|
77
|
-
it("rejects unknown keys (strictObject enforcement)", () => {
|
|
78
|
-
const result = SubagentContextConfigSchema.safeParse({ unknownField: true });
|
|
79
|
-
expect(result.success).toBe(false);
|
|
80
|
-
});
|
|
81
|
-
it("rejects maxSpawnDepth below 1", () => {
|
|
82
|
-
const result = SubagentContextConfigSchema.safeParse({ maxSpawnDepth: 0 });
|
|
83
|
-
expect(result.success).toBe(false);
|
|
84
|
-
});
|
|
85
|
-
it("rejects maxSpawnDepth above 10", () => {
|
|
86
|
-
const result = SubagentContextConfigSchema.safeParse({ maxSpawnDepth: 11 });
|
|
87
|
-
expect(result.success).toBe(false);
|
|
88
|
-
});
|
|
89
|
-
it("rejects autoCompactThreshold below 0.5", () => {
|
|
90
|
-
const result = SubagentContextConfigSchema.safeParse({ autoCompactThreshold: 0.4 });
|
|
91
|
-
expect(result.success).toBe(false);
|
|
92
|
-
});
|
|
93
|
-
it("rejects invalid condensationStrategy", () => {
|
|
94
|
-
const result = SubagentContextConfigSchema.safeParse({ condensationStrategy: "manual" });
|
|
95
|
-
expect(result.success).toBe(false);
|
|
96
|
-
});
|
|
97
|
-
it("maxQueuedPerAgent defaults to 10", () => {
|
|
98
|
-
const result = SubagentContextConfigSchema.parse({});
|
|
99
|
-
expect(result.maxQueuedPerAgent).toBe(10);
|
|
100
|
-
});
|
|
101
|
-
it("queueTimeoutMs defaults to 120000", () => {
|
|
102
|
-
const result = SubagentContextConfigSchema.parse({});
|
|
103
|
-
expect(result.queueTimeoutMs).toBe(120_000);
|
|
104
|
-
});
|
|
105
|
-
it("maxQueuedPerAgent: 0 is valid (disables queuing)", () => {
|
|
106
|
-
const result = SubagentContextConfigSchema.safeParse({ maxQueuedPerAgent: 0 });
|
|
107
|
-
expect(result.success).toBe(true);
|
|
108
|
-
if (result.success)
|
|
109
|
-
expect(result.data.maxQueuedPerAgent).toBe(0);
|
|
110
|
-
});
|
|
111
|
-
it("rejects maxQueuedPerAgent above 50", () => {
|
|
112
|
-
const result = SubagentContextConfigSchema.safeParse({ maxQueuedPerAgent: 51 });
|
|
113
|
-
expect(result.success).toBe(false);
|
|
114
|
-
});
|
|
115
|
-
it("rejects queueTimeoutMs below 1000", () => {
|
|
116
|
-
const result = SubagentContextConfigSchema.safeParse({ queueTimeoutMs: 999 });
|
|
117
|
-
expect(result.success).toBe(false);
|
|
118
|
-
});
|
|
119
|
-
it("rejects queueTimeoutMs above 600000", () => {
|
|
120
|
-
const result = SubagentContextConfigSchema.safeParse({ queueTimeoutMs: 600_001 });
|
|
121
|
-
expect(result.success).toBe(false);
|
|
122
|
-
});
|
|
123
|
-
it("maxRunTimeoutMs defaults to 600000", () => {
|
|
124
|
-
const result = SubagentContextConfigSchema.parse({});
|
|
125
|
-
expect(result.maxRunTimeoutMs).toBe(600_000);
|
|
126
|
-
});
|
|
127
|
-
it("perStepTimeoutMs defaults to 60000", () => {
|
|
128
|
-
const result = SubagentContextConfigSchema.parse({});
|
|
129
|
-
expect(result.perStepTimeoutMs).toBe(60_000);
|
|
130
|
-
});
|
|
131
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { SubagentResultSchema, SubagentEndReasonSchema, parseSubagentResult, } from "./subagent-context-types.js";
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
// Helpers
|
|
5
|
-
// ---------------------------------------------------------------------------
|
|
6
|
-
function validResult(overrides = {}) {
|
|
7
|
-
return {
|
|
8
|
-
taskComplete: true,
|
|
9
|
-
summary: "Successfully analyzed the codebase structure.",
|
|
10
|
-
conclusions: ["The architecture follows hexagonal patterns"],
|
|
11
|
-
...overrides,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
// ---------------------------------------------------------------------------
|
|
15
|
-
// SubagentResultSchema
|
|
16
|
-
// ---------------------------------------------------------------------------
|
|
17
|
-
describe("SubagentResultSchema", () => {
|
|
18
|
-
describe("valid data", () => {
|
|
19
|
-
it("accepts valid minimal result", () => {
|
|
20
|
-
const result = SubagentResultSchema.safeParse(validResult());
|
|
21
|
-
expect(result.success).toBe(true);
|
|
22
|
-
if (result.success) {
|
|
23
|
-
expect(result.data.taskComplete).toBe(true);
|
|
24
|
-
expect(result.data.summary).toBe("Successfully analyzed the codebase structure.");
|
|
25
|
-
expect(result.data.conclusions).toEqual(["The architecture follows hexagonal patterns"]);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
it("accepts valid full result", () => {
|
|
29
|
-
const result = SubagentResultSchema.safeParse(validResult({
|
|
30
|
-
filePaths: ["/src/index.ts", "/src/types.ts"],
|
|
31
|
-
actionableItems: ["Review the port interfaces"],
|
|
32
|
-
errors: ["Minor: unused import in file.ts"],
|
|
33
|
-
keyData: { linesOfCode: 1500, coverage: 0.85 },
|
|
34
|
-
confidence: 0.92,
|
|
35
|
-
}));
|
|
36
|
-
expect(result.success).toBe(true);
|
|
37
|
-
if (result.success) {
|
|
38
|
-
expect(result.data.filePaths).toEqual(["/src/index.ts", "/src/types.ts"]);
|
|
39
|
-
expect(result.data.actionableItems).toEqual(["Review the port interfaces"]);
|
|
40
|
-
expect(result.data.errors).toEqual(["Minor: unused import in file.ts"]);
|
|
41
|
-
expect(result.data.keyData).toEqual({ linesOfCode: 1500, coverage: 0.85 });
|
|
42
|
-
expect(result.data.confidence).toBe(0.92);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
describe("invalid data", () => {
|
|
47
|
-
it("rejects missing required field taskComplete", () => {
|
|
48
|
-
const { taskComplete: _, ...rest } = validResult();
|
|
49
|
-
const result = SubagentResultSchema.safeParse(rest);
|
|
50
|
-
expect(result.success).toBe(false);
|
|
51
|
-
});
|
|
52
|
-
it("rejects missing required field summary", () => {
|
|
53
|
-
const { summary: _, ...rest } = validResult();
|
|
54
|
-
const result = SubagentResultSchema.safeParse(rest);
|
|
55
|
-
expect(result.success).toBe(false);
|
|
56
|
-
});
|
|
57
|
-
it("rejects missing required field conclusions", () => {
|
|
58
|
-
const { conclusions: _, ...rest } = validResult();
|
|
59
|
-
const result = SubagentResultSchema.safeParse(rest);
|
|
60
|
-
expect(result.success).toBe(false);
|
|
61
|
-
});
|
|
62
|
-
it("rejects empty summary", () => {
|
|
63
|
-
const result = SubagentResultSchema.safeParse(validResult({ summary: "" }));
|
|
64
|
-
expect(result.success).toBe(false);
|
|
65
|
-
});
|
|
66
|
-
it("rejects empty conclusions array", () => {
|
|
67
|
-
const result = SubagentResultSchema.safeParse(validResult({ conclusions: [] }));
|
|
68
|
-
expect(result.success).toBe(false);
|
|
69
|
-
});
|
|
70
|
-
it("rejects confidence outside 0-1 range", () => {
|
|
71
|
-
const tooHigh = SubagentResultSchema.safeParse(validResult({ confidence: 1.5 }));
|
|
72
|
-
expect(tooHigh.success).toBe(false);
|
|
73
|
-
const tooLow = SubagentResultSchema.safeParse(validResult({ confidence: -0.1 }));
|
|
74
|
-
expect(tooLow.success).toBe(false);
|
|
75
|
-
});
|
|
76
|
-
it("rejects unknown keys", () => {
|
|
77
|
-
const result = SubagentResultSchema.safeParse(validResult({ unknownField: "surprise" }));
|
|
78
|
-
expect(result.success).toBe(false);
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
describe("parseSubagentResult", () => {
|
|
82
|
-
it("returns ok() on valid input", () => {
|
|
83
|
-
const result = parseSubagentResult(validResult());
|
|
84
|
-
expect(result.ok).toBe(true);
|
|
85
|
-
if (result.ok) {
|
|
86
|
-
expect(result.value.taskComplete).toBe(true);
|
|
87
|
-
expect(result.value.summary).toBe("Successfully analyzed the codebase structure.");
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
it("returns err() on invalid input", () => {
|
|
91
|
-
const result = parseSubagentResult({ taskComplete: "not a boolean" });
|
|
92
|
-
expect(result.ok).toBe(false);
|
|
93
|
-
if (!result.ok) {
|
|
94
|
-
expect(result.error.issues.length).toBeGreaterThan(0);
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
// ---------------------------------------------------------------------------
|
|
100
|
-
// SubagentEndReasonSchema
|
|
101
|
-
// ---------------------------------------------------------------------------
|
|
102
|
-
describe("SubagentEndReasonSchema", () => {
|
|
103
|
-
it("accepts valid reasons", () => {
|
|
104
|
-
const reasons = ["completed", "failed", "killed", "swept"];
|
|
105
|
-
for (const reason of reasons) {
|
|
106
|
-
const result = SubagentEndReasonSchema.safeParse(reason);
|
|
107
|
-
expect(result.success).toBe(true);
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
it("rejects invalid reason", () => {
|
|
111
|
-
const result = SubagentEndReasonSchema.safeParse("cancelled");
|
|
112
|
-
expect(result.success).toBe(false);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
// ---------------------------------------------------------------------------
|
|
116
|
-
// Type Assertion Tests (compile-time only)
|
|
117
|
-
// ---------------------------------------------------------------------------
|
|
118
|
-
describe("Type assertions", () => {
|
|
119
|
-
it("SpawnPacket literal satisfies the interface", () => {
|
|
120
|
-
const packet = {
|
|
121
|
-
task: "analyze codebase",
|
|
122
|
-
artifactRefs: ["/src/index.ts"],
|
|
123
|
-
domainKnowledge: ["hexagonal architecture"],
|
|
124
|
-
toolGroups: ["coding"],
|
|
125
|
-
objective: "Understand the project structure",
|
|
126
|
-
workspaceDir: "/workspace",
|
|
127
|
-
depth: 1,
|
|
128
|
-
maxDepth: 3,
|
|
129
|
-
};
|
|
130
|
-
// Compile-time check: if this file compiles, the type assertion holds
|
|
131
|
-
expect(packet).toBeTruthy();
|
|
132
|
-
});
|
|
133
|
-
it("SpawnPacket accepts optional parentSummary", () => {
|
|
134
|
-
const packet = {
|
|
135
|
-
task: "analyze codebase",
|
|
136
|
-
artifactRefs: [],
|
|
137
|
-
domainKnowledge: [],
|
|
138
|
-
toolGroups: [],
|
|
139
|
-
objective: "Understand the project structure",
|
|
140
|
-
parentSummary: "Parent was working on auth module",
|
|
141
|
-
workspaceDir: "/workspace",
|
|
142
|
-
depth: 0,
|
|
143
|
-
maxDepth: 3,
|
|
144
|
-
};
|
|
145
|
-
expect(packet).toBeTruthy();
|
|
146
|
-
expect(packet.parentSummary).toBe("Parent was working on auth module");
|
|
147
|
-
});
|
|
148
|
-
it("SpawnPacket accepts optional agentWorkspaces", () => {
|
|
149
|
-
const packet = {
|
|
150
|
-
task: "update agent configs",
|
|
151
|
-
artifactRefs: [],
|
|
152
|
-
domainKnowledge: [],
|
|
153
|
-
toolGroups: [],
|
|
154
|
-
objective: "Modify workspace files for all agents",
|
|
155
|
-
workspaceDir: "/workspace",
|
|
156
|
-
depth: 1,
|
|
157
|
-
maxDepth: 3,
|
|
158
|
-
agentWorkspaces: {
|
|
159
|
-
"default": "/home/user/.comis/workspace",
|
|
160
|
-
"technical-analyst": "/home/user/.comis/workspace-technical-analyst",
|
|
161
|
-
},
|
|
162
|
-
};
|
|
163
|
-
expect(packet).toBeTruthy();
|
|
164
|
-
expect(packet.agentWorkspaces).toBeDefined();
|
|
165
|
-
expect(Object.keys(packet.agentWorkspaces)).toHaveLength(2);
|
|
166
|
-
});
|
|
167
|
-
it("CondensedResult literal satisfies the interface", () => {
|
|
168
|
-
const condensed = {
|
|
169
|
-
level: 2,
|
|
170
|
-
result: {
|
|
171
|
-
taskComplete: true,
|
|
172
|
-
summary: "Completed analysis",
|
|
173
|
-
conclusions: ["All good"],
|
|
174
|
-
},
|
|
175
|
-
originalTokens: 5000,
|
|
176
|
-
condensedTokens: 2000,
|
|
177
|
-
compressionRatio: 0.4,
|
|
178
|
-
diskPath: "/tmp/result-001.json",
|
|
179
|
-
};
|
|
180
|
-
expect(condensed).toBeTruthy();
|
|
181
|
-
});
|
|
182
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|