@aiwg/cli 2026.10.5 → 2026.10.7
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/agentic/code/addons/composition-engine/lib/runtime.mjs +1401 -0
- package/agentic/code/addons/composition-engine/lib/validator.mjs +513 -0
- package/agentic/code/addons/composition-engine/schemas/flow-graph.schema.json +372 -0
- package/agentic/code/providers/model-capabilities.v1.json +74 -50
- package/bin/aiwg.mjs +7 -3
- package/dist/src/a2a/agent-card.js +11 -0
- package/dist/src/api/index.d.ts +1 -0
- package/dist/src/api/index.js +1 -0
- package/dist/src/artifacts/browser-export.js +1 -0
- package/dist/src/artifacts/citation-parser.js +8 -1
- package/dist/src/artifacts/cli.js +57 -6
- package/dist/src/artifacts/fortemi-core-query-adapter.js +2 -0
- package/dist/src/artifacts/fortemi-core-sync.js +26 -8
- package/dist/src/artifacts/fortemi-shard-contract/2.2.0/contract.json +103 -0
- package/dist/src/artifacts/fortemi-shard-contract/2.2.0/full-v1-embedding-config.schema.json +212 -0
- package/dist/src/artifacts/fortemi-shard-contract/2.2.0/full-v1-embedding-set.schema.json +240 -0
- package/dist/src/artifacts/fortemi-shard-contract/2.2.0/full-v1-manifest.schema.json +451 -0
- package/dist/src/artifacts/fortemi-shard-export.js +284 -0
- package/dist/src/artifacts/graph-query.js +18 -8
- package/dist/src/artifacts/index-adapters.js +339 -0
- package/dist/src/artifacts/index-builder.js +143 -14
- package/dist/src/artifacts/index-files.js +15 -4
- package/dist/src/artifacts/index-preparation.js +2 -0
- package/dist/src/artifacts/index-reader.js +44 -0
- package/dist/src/artifacts/index-refresh.js +114 -55
- package/dist/src/artifacts/index-status.js +20 -5
- package/dist/src/artifacts/memory-maintenance.js +503 -0
- package/dist/src/artifacts/prebuilt-relations.js +3 -1
- package/dist/src/artifacts/query-engine.js +263 -108
- package/dist/src/artifacts/relations-builder.js +2 -2
- package/dist/src/artifacts/source-graph.js +2 -2
- package/dist/src/artifacts/types.js +9 -1
- package/dist/src/auth/client.js +5 -1
- package/dist/src/auth/credential-store.js +5 -1
- package/dist/src/auth/sensitive-input.js +151 -0
- package/dist/src/channel/manager.mjs +3 -0
- package/dist/src/cli/handlers/agentcard.js +47 -25
- package/dist/src/cli/handlers/auth.js +22 -2
- package/dist/src/cli/handlers/decision.js +22 -3
- package/dist/src/cli/handlers/effect.js +4 -84
- package/dist/src/cli/handlers/guided-setup.js +470 -0
- package/dist/src/cli/handlers/help.js +2 -2
- package/dist/src/cli/handlers/housekeeper.js +1110 -0
- package/dist/src/cli/handlers/index.js +4 -2
- package/dist/src/cli/handlers/init.js +41 -6
- package/dist/src/cli/handlers/install.js +6 -0
- package/dist/src/cli/handlers/local-executor.js +5 -3
- package/dist/src/cli/handlers/marketplace.js +15 -4
- package/dist/src/cli/handlers/mc.js +509 -53
- package/dist/src/cli/handlers/models.js +32 -2
- package/dist/src/cli/handlers/ralph-launcher.js +76 -4
- package/dist/src/cli/handlers/rules.js +1 -1
- package/dist/src/cli/handlers/script-runner.js +73 -2
- package/dist/src/cli/handlers/serve.js +5 -3
- package/dist/src/cli/handlers/sessions.js +1 -0
- package/dist/src/cli/handlers/setup.js +432 -1
- package/dist/src/cli/handlers/skill-lint.js +1 -1
- package/dist/src/cli/handlers/subcommands.js +118 -8
- package/dist/src/cli/handlers/use.js +335 -107
- package/dist/src/cli/handlers/workspace.js +3 -1
- package/dist/src/cli/prompt-utils.js +81 -0
- package/dist/src/cli/router.js +16 -1
- package/dist/src/config/aiwg-config.js +42 -0
- package/dist/src/config/cli.js +7 -3
- package/dist/src/config/decision-config.js +14 -1
- package/dist/src/config/gitignore.js +4 -0
- package/dist/src/config/native-sandbox-warnings.js +25 -0
- package/dist/src/config/workspace.js +2 -1
- package/dist/src/contributors/validation.js +6 -5
- package/dist/src/decision/adapters/jev.js +20 -31
- package/dist/src/decision/admission.js +7 -3
- package/dist/src/decision/ask.js +6 -1
- package/dist/src/decision/benchmark.js +482 -0
- package/dist/src/decision/ledger.js +22 -3
- package/dist/src/decision/pricing.js +147 -0
- package/dist/src/decision/qualification/gate-evidence.js +23 -18
- package/dist/src/decision/qualification/load-staged.js +576 -0
- package/dist/src/decision/qualification/load.js +109 -33
- package/dist/src/decision/qualification/runner.js +12 -5
- package/dist/src/decision/review/service.js +6 -4
- package/dist/src/decision/review/validate.js +23 -2
- package/dist/src/decision/savings.js +8 -3
- package/dist/src/discovery/index.js +492 -0
- package/dist/src/discovery/interview.js +238 -0
- package/dist/src/discovery/plan-apply.js +567 -0
- package/dist/src/discovery/plan-store.js +171 -0
- package/dist/src/discovery/plan-types.js +2 -0
- package/dist/src/discovery/plan-validation.js +139 -0
- package/dist/src/discovery/types.js +2 -0
- package/dist/src/effects/host.js +91 -0
- package/dist/src/extensions/commands/definitions.js +49 -9
- package/dist/src/extensions/manifest.js +71 -44
- package/dist/src/extensions/project-local-discovery.js +1 -1
- package/dist/src/extensions/project-local-gitignore.js +2 -0
- package/dist/src/extensions/project-quickref.js +18 -17
- package/dist/src/extensions/validation.js +32 -29
- package/dist/src/housekeeper/daemon-config.js +148 -0
- package/dist/src/housekeeper/ipc.js +84 -0
- package/dist/src/housekeeper/lifecycle.js +148 -0
- package/dist/src/housekeeper/platform.js +35 -0
- package/dist/src/housekeeper/status.js +70 -0
- package/dist/src/housekeeper/units.js +114 -0
- package/dist/src/issues/cli.js +16 -5
- package/dist/src/issues/live.js +44 -12
- package/dist/src/jobs/flow.js +22 -21
- package/dist/src/lint/rule-activation.js +20 -5
- package/dist/src/lint/runner.js +1 -1
- package/dist/src/marketplace/exchange.js +18 -6
- package/dist/src/marketplace/provenance.js +3 -2
- package/dist/src/mcp/adapters/codex-runtime.js +46 -76
- package/dist/src/mcp/cli.mjs +22 -96
- package/dist/src/mcp/config-file.mjs +6 -2
- package/dist/src/mcp/config-layers.mjs +23 -7
- package/dist/src/mcp/grok-build-config.mjs +2 -1
- package/dist/src/mcp/muse-native-config.mjs +2 -1
- package/dist/src/mcp/profiles.js +18 -31
- package/dist/src/mcp/profiles.mjs +18 -32
- package/dist/src/mcp/registry.js +7 -27
- package/dist/src/mcp/registry.mjs +7 -28
- package/dist/src/mcp/server.mjs +34 -1
- package/dist/src/mcp/tools/agentic-sandbox.mjs +8 -7
- package/dist/src/mcp/tools/command-run.mjs +3 -2
- package/dist/src/mcp/tools/decision.mjs +49 -48
- package/dist/src/mcp/tools/discovery.mjs +46 -21
- package/dist/src/mcp/tools/orchestration.mjs +22 -22
- package/dist/src/mcp/tools/subsystems.mjs +9 -8
- package/dist/src/mcp/tools/worker-invoke.mjs +30 -6
- package/dist/src/mcp/tools/writer-profiles.mjs +1 -1
- package/dist/src/memory/audit.js +719 -0
- package/dist/src/memory/canonical-context.js +392 -13
- package/dist/src/memory/canonical-maintenance.js +95 -0
- package/dist/src/memory/cli-result.js +22 -0
- package/dist/src/memory/cli.js +176 -0
- package/dist/src/memory/context-pack.js +57 -6
- package/dist/src/memory/cost.js +512 -0
- package/dist/src/memory/firewall-classification.d.mts +7 -0
- package/dist/src/memory/firewall-classification.mjs +32 -0
- package/dist/src/memory/index.js +8 -0
- package/dist/src/memory/line-maintenance.js +68 -0
- package/dist/src/memory/maintenance-cli.js +286 -0
- package/dist/src/memory/maintenance-contract.js +136 -0
- package/dist/src/memory/maintenance-index.js +18 -0
- package/dist/src/memory/maintenance-owner.js +2 -0
- package/dist/src/memory/maintenance-record.js +138 -0
- package/dist/src/memory/maintenance.js +254 -0
- package/dist/src/memory/project-registry.js +2 -1
- package/dist/src/memory/provider-memory-adapter.js +154 -0
- package/dist/src/memory/recommend-cli.js +83 -0
- package/dist/src/memory/recommend.js +269 -0
- package/dist/src/memory/scheduled.js +81 -0
- package/dist/src/memory/taxonomy.js +44 -0
- package/dist/src/mission-protocol/codecs.js +19 -9
- package/dist/src/mission-protocol/worker-status.js +91 -1
- package/dist/src/models/config-loader.js +11 -1
- package/dist/src/models/model-capabilities.v1.json +74 -50
- package/dist/src/models/provider-policy.js +125 -62
- package/dist/src/models/resolver.js +45 -8
- package/dist/src/models/worker-installation.d.mts +8 -1
- package/dist/src/models/worker-installation.mjs +231 -38
- package/dist/src/models/wrapper-route.js +1 -1
- package/dist/src/output-modes/registry.js +8 -7
- package/dist/src/packages/adapters/git.js +99 -23
- package/dist/src/packages/adapters/gitea.js +8 -27
- package/dist/src/packages/adapters/github.js +7 -25
- package/dist/src/packages/registry.js +4 -4
- package/dist/src/plugin/metadata-validator.js +1 -1
- package/dist/src/process/cli-command.d.mts +5 -0
- package/dist/src/process/cli-command.mjs +42 -0
- package/dist/src/providers/deploy-version.d.mts +1 -0
- package/dist/src/providers/deploy-version.mjs +17 -0
- package/dist/src/providers/provider-definitions.js +19 -16
- package/dist/src/providers/skill-ownership.d.mts +11 -2
- package/dist/src/providers/skill-ownership.mjs +35 -17
- package/dist/src/rules/activation.d.mts +11 -2
- package/dist/src/rules/activation.mjs +82 -6
- package/dist/src/rules/inventory.js +1 -1
- package/dist/src/rules/rule-frontmatter.schema.json +2 -0
- package/dist/src/schema/zod-validation.d.mts +6 -0
- package/dist/src/schema/zod-validation.mjs +50 -0
- package/dist/src/serve/executor-registry.js +297 -20
- package/dist/src/serve/executor-token.d.mts +1 -0
- package/dist/src/serve/executor-token.mjs +8 -0
- package/dist/src/serve/shared-host-scheduler.js +1102 -31
- package/dist/src/serve/worker-invocation.js +124 -15
- package/dist/src/sessions/adapters/claude.js +19 -18
- package/dist/src/sessions/adapters/codex.js +10 -9
- package/dist/src/sessions/adapters/copilot.js +14 -13
- package/dist/src/sessions/adapters/cursor.js +19 -18
- package/dist/src/sessions/adapters/deepseek-harness.js +9 -8
- package/dist/src/sessions/adapters/factory.js +11 -10
- package/dist/src/sessions/adapters/generic.js +32 -23
- package/dist/src/sessions/adapters/grokbot.js +35 -35
- package/dist/src/sessions/adapters/hermes.js +20 -19
- package/dist/src/sessions/adapters/muse.js +50 -49
- package/dist/src/sessions/adapters/omp.js +5 -4
- package/dist/src/sessions/adapters/openclaw.js +30 -29
- package/dist/src/sessions/adapters/opencode.js +26 -26
- package/dist/src/sessions/adapters/openhuman.js +24 -23
- package/dist/src/sessions/adapters/pi.js +5 -4
- package/dist/src/sessions/adapters/windsurf.js +8 -8
- package/dist/src/sessions/analytics.js +10 -9
- package/dist/src/sessions/candidates.js +7 -6
- package/dist/src/sessions/contracts.js +63 -53
- package/dist/src/sessions/output-registration.js +11 -10
- package/dist/src/sessions/workspace-discovery.js +3 -4
- package/dist/src/smiths/context-pipeline/aiwg-md.js +18 -1
- package/dist/src/smiths/context-pipeline/claude-hook.js +46 -10
- package/dist/src/smiths/context-pipeline/context-file-safety.js +330 -9
- package/dist/src/smiths/context-pipeline/finalization.js +3 -2
- package/dist/src/smiths/context-pipeline/generator.js +7 -19
- package/dist/src/smiths/context-pipeline/legacy-inject.js +3 -10
- package/dist/src/smiths/context-pipeline/managed-hook.js +5 -5
- package/dist/src/smiths/context-pipeline/parallelism-section.js +72 -5
- package/dist/src/smiths/context-pipeline/workspace-context.js +110 -22
- package/dist/src/tracker/project-inputs.js +2 -0
- package/dist/src/update/checker.d.mts +4 -0
- package/dist/src/update/checker.mjs +14 -0
- package/dist/src/update/notifier.mjs +2 -4
- package/dist/src/writing/exemplar-selection.js +6 -6
- package/dist/src/writing/voice-evaluation.js +24 -23
- package/dist/src/writing/writer-migration.js +14 -13
- package/dist/src/writing/writer-profile.js +19 -18
- package/dist/src/writing/writing-brief.js +18 -17
- package/dist/src/writing/writing-receipt.js +47 -46
- package/package.json +5 -2
- package/schemas/decision/DecisionReview.schema.json +78 -1
- package/schemas/mission-v1.schema.json +3 -0
- package/tools/agents/deploy-agents.mjs +67 -39
- package/tools/agents/providers/antigravity.mjs +6 -1
- package/tools/agents/providers/base.mjs +24 -14
- package/tools/agents/providers/claude.mjs +6 -3
- package/tools/agents/providers/codex.mjs +54 -57
- package/tools/agents/providers/context-write.mjs +28 -0
- package/tools/agents/providers/copilot.mjs +13 -4
- package/tools/agents/providers/cursor.mjs +1 -1
- package/tools/agents/providers/deepseek-harness.mjs +1 -1
- package/tools/agents/providers/factory.mjs +7 -1
- package/tools/agents/providers/grok-build.mjs +18 -2
- package/tools/agents/providers/grokbot.mjs +1 -1
- package/tools/agents/providers/hermes.mjs +12 -15
- package/tools/agents/providers/muse-hooks.mjs +21 -14
- package/tools/agents/providers/muse.mjs +7 -2
- package/tools/agents/providers/omp.mjs +31 -5
- package/tools/agents/providers/opencode.mjs +14 -5
- package/tools/agents/providers/openhuman.mjs +1 -1
- package/tools/agents/providers/pi.mjs +1 -1
- package/tools/agents/providers/provider-prepare-coordinator.mjs +29 -9
- package/tools/agents/providers/rule-delivery.mjs +289 -80
- package/tools/agents/providers/warp.mjs +4 -1
- package/tools/agents/providers/windsurf.mjs +13 -3
- package/tools/cli/workspace-status.mjs +5 -0
- package/tools/commands/deploy-prompts-codex.mjs +11 -8
- package/tools/ralph-external/lib/codex-adapter.mjs +6 -2
- package/tools/ralph-external/lib/consecutive-failure-circuit-breaker.mjs +26 -0
- package/tools/ralph-external/lib/launcher-recovery-evidence.mjs +7 -1
- package/tools/ralph-external/lib/muse-adapter.mjs +12 -2
- package/tools/ralph-external/lib/recovery-probe.mjs +14 -4
- package/tools/ralph-external/lib/worker-health.mjs +1 -1
- package/tools/ralph-external/lib/worker-isolation.mjs +65 -9
- package/tools/ralph-external/process-monitor.mjs +49 -8
- package/tools/ralph-external/session-launcher.mjs +405 -35
- package/tools/skills/deploy-skills-codex.mjs +11 -7
- package/vscode-extension/schemas/aiwg.config.v1.json +11 -1
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { number } from '../../schema/zod-validation.mjs';
|
|
2
3
|
import { schemaRejectionDetail, schemaIssueDetail, SessionContractError, assertSupportedSchemaMajor, } from '../contracts.js';
|
|
3
4
|
import { readBoundedJson, streamBoundedJsonLines, } from '../readers.js';
|
|
4
5
|
export const OPENCODE_ADAPTER_VERSION = '1.0.0';
|
|
5
6
|
export const OPENCODE_EXPORT_SCHEMA_VERSION = '1.0.0';
|
|
6
|
-
const SessionInfoSchema = z.
|
|
7
|
+
const SessionInfoSchema = z.looseObject({
|
|
7
8
|
id: z.string().min(1),
|
|
8
9
|
projectID: z.string().optional(),
|
|
9
10
|
directory: z.string().optional(),
|
|
10
11
|
parentID: z.string().optional(),
|
|
11
12
|
title: z.string().optional(),
|
|
12
13
|
version: z.string().optional(),
|
|
13
|
-
time: z.
|
|
14
|
-
created:
|
|
15
|
-
updated:
|
|
16
|
-
compacting:
|
|
17
|
-
archived:
|
|
18
|
-
}).
|
|
19
|
-
share: z.
|
|
20
|
-
})
|
|
21
|
-
const MessageInfoSchema = z.
|
|
14
|
+
time: z.looseObject({
|
|
15
|
+
created: number().optional(),
|
|
16
|
+
updated: number().optional(),
|
|
17
|
+
compacting: number().nullable().optional(),
|
|
18
|
+
archived: number().nullable().optional(),
|
|
19
|
+
}).optional(),
|
|
20
|
+
share: z.looseObject({ url: z.string().optional() }).optional(),
|
|
21
|
+
});
|
|
22
|
+
const MessageInfoSchema = z.looseObject({
|
|
22
23
|
id: z.string().min(1),
|
|
23
24
|
sessionID: z.string().min(1),
|
|
24
25
|
role: z.string().min(1),
|
|
@@ -26,13 +27,12 @@ const MessageInfoSchema = z.object({
|
|
|
26
27
|
modelID: z.string().optional(),
|
|
27
28
|
providerID: z.string().optional(),
|
|
28
29
|
model: z.object({ providerID: z.string(), modelID: z.string() }).optional(),
|
|
29
|
-
cost:
|
|
30
|
-
tokens: z.record(z.unknown()).optional(),
|
|
31
|
-
time: z.
|
|
32
|
-
.passthrough().optional(),
|
|
30
|
+
cost: number().optional(),
|
|
31
|
+
tokens: z.record(z.string(), z.unknown()).optional(),
|
|
32
|
+
time: z.looseObject({ created: number().optional(), completed: number().optional() }).optional(),
|
|
33
33
|
error: z.unknown().optional(),
|
|
34
|
-
})
|
|
35
|
-
const PartSchema = z.
|
|
34
|
+
});
|
|
35
|
+
const PartSchema = z.looseObject({
|
|
36
36
|
id: z.string().min(1),
|
|
37
37
|
sessionID: z.string().min(1),
|
|
38
38
|
messageID: z.string().min(1),
|
|
@@ -45,27 +45,27 @@ const PartSchema = z.object({
|
|
|
45
45
|
filename: z.string().optional(),
|
|
46
46
|
url: z.string().optional(),
|
|
47
47
|
time: z.unknown().optional(),
|
|
48
|
-
})
|
|
49
|
-
const MessageSchema = z.
|
|
48
|
+
});
|
|
49
|
+
const MessageSchema = z.looseObject({
|
|
50
50
|
info: MessageInfoSchema,
|
|
51
51
|
parts: z.array(PartSchema),
|
|
52
|
-
})
|
|
53
|
-
const ExportSchema = z.
|
|
52
|
+
});
|
|
53
|
+
const ExportSchema = z.looseObject({
|
|
54
54
|
schemaVersion: z.string().optional(),
|
|
55
55
|
info: SessionInfoSchema,
|
|
56
56
|
messages: z.array(MessageSchema),
|
|
57
57
|
sanitized: z.boolean().optional(),
|
|
58
|
-
sanitization: z.record(z.unknown()).optional(),
|
|
58
|
+
sanitization: z.record(z.string(), z.unknown()).optional(),
|
|
59
59
|
shared: z.boolean().optional(),
|
|
60
|
-
providerDeletedAt:
|
|
61
|
-
})
|
|
62
|
-
const EventSchema = z.
|
|
60
|
+
providerDeletedAt: number().nullable().optional(),
|
|
61
|
+
});
|
|
62
|
+
const EventSchema = z.looseObject({
|
|
63
63
|
schemaVersion: z.string().optional(),
|
|
64
64
|
type: z.string().min(1),
|
|
65
|
-
properties: z.record(z.unknown()),
|
|
65
|
+
properties: z.record(z.string(), z.unknown()),
|
|
66
66
|
sanitized: z.boolean().optional(),
|
|
67
67
|
shared: z.boolean().optional(),
|
|
68
|
-
})
|
|
68
|
+
});
|
|
69
69
|
export class OpenCodeSessionAdapter {
|
|
70
70
|
limits;
|
|
71
71
|
transports;
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { number } from '../../schema/zod-validation.mjs';
|
|
2
3
|
import { schemaRejectionDetail, schemaIssueDetail, SessionContractError, assertSupportedSchemaMajor, } from '../contracts.js';
|
|
3
4
|
import { streamBoundedJsonLines, } from '../readers.js';
|
|
4
5
|
export const OPENHUMAN_ADAPTER_VERSION = '1.0.0';
|
|
5
6
|
export const OPENHUMAN_SOURCE_SCHEMA_VERSION = '1.0.0';
|
|
6
|
-
const MetadataSchema = z.
|
|
7
|
+
const MetadataSchema = z.looseObject({
|
|
7
8
|
provider: z.string().optional(),
|
|
8
9
|
model: z.string().optional(),
|
|
9
10
|
profile: z.string().optional(),
|
|
10
11
|
nestedAgentId: z.string().optional(),
|
|
11
12
|
parentAgentId: z.string().optional(),
|
|
12
|
-
})
|
|
13
|
-
const AttachmentSchema = z.
|
|
13
|
+
});
|
|
14
|
+
const AttachmentSchema = z.looseObject({
|
|
14
15
|
id: z.string().min(1),
|
|
15
16
|
name: z.string().optional(),
|
|
16
17
|
mime: z.string().optional(),
|
|
17
18
|
uri: z.string().optional(),
|
|
18
19
|
state: z.enum(['present', 'expired']),
|
|
19
|
-
expiredAt: z.union([z.string(),
|
|
20
|
-
})
|
|
21
|
-
const RawSchema = z.
|
|
22
|
-
schemaVersion: z.union([z.string(),
|
|
20
|
+
expiredAt: z.union([z.string(), number()]).optional(),
|
|
21
|
+
});
|
|
22
|
+
const RawSchema = z.looseObject({
|
|
23
|
+
schemaVersion: z.union([z.string(), number()]),
|
|
23
24
|
recordType: z.literal('session_raw'),
|
|
24
25
|
session_id: z.string().min(1),
|
|
25
26
|
event_id: z.string().min(1),
|
|
@@ -29,36 +30,36 @@ const RawSchema = z.object({
|
|
|
29
30
|
type: z.string().min(1),
|
|
30
31
|
role: z.string().optional(),
|
|
31
32
|
content: z.unknown().optional(),
|
|
32
|
-
timestamp: z.union([z.string(),
|
|
33
|
+
timestamp: z.union([z.string(), number()]).optional(),
|
|
33
34
|
metadata: MetadataSchema.optional(),
|
|
34
|
-
input_tokens:
|
|
35
|
-
cached_input_tokens:
|
|
36
|
-
output_tokens:
|
|
37
|
-
charged_amount_usd:
|
|
35
|
+
input_tokens: number().optional(),
|
|
36
|
+
cached_input_tokens: number().optional(),
|
|
37
|
+
output_tokens: number().optional(),
|
|
38
|
+
charged_amount_usd: number().optional(),
|
|
38
39
|
compacted: z.boolean().optional(),
|
|
39
40
|
interrupted: z.boolean().optional(),
|
|
40
|
-
tool: z.record(z.unknown()).optional(),
|
|
41
|
+
tool: z.record(z.string(), z.unknown()).optional(),
|
|
41
42
|
attachment: AttachmentSchema.optional(),
|
|
42
43
|
active: z.boolean().optional(),
|
|
43
|
-
raw_transcript_deleted_at: z.union([z.string(),
|
|
44
|
-
})
|
|
45
|
-
const ThreadStateSchema = z.
|
|
46
|
-
schemaVersion: z.union([z.string(),
|
|
44
|
+
raw_transcript_deleted_at: z.union([z.string(), number()]).nullable().optional(),
|
|
45
|
+
});
|
|
46
|
+
const ThreadStateSchema = z.looseObject({
|
|
47
|
+
schemaVersion: z.union([z.string(), number()]),
|
|
47
48
|
recordType: z.literal('thread_state'),
|
|
48
49
|
thread_id: z.string().min(1),
|
|
49
50
|
title: z.string().optional(),
|
|
50
51
|
state: z.string().optional(),
|
|
51
|
-
deleted_at: z.union([z.string(),
|
|
52
|
-
})
|
|
53
|
-
const TurnStateSchema = z.
|
|
54
|
-
schemaVersion: z.union([z.string(),
|
|
52
|
+
deleted_at: z.union([z.string(), number()]).nullable().optional(),
|
|
53
|
+
});
|
|
54
|
+
const TurnStateSchema = z.looseObject({
|
|
55
|
+
schemaVersion: z.union([z.string(), number()]),
|
|
55
56
|
recordType: z.literal('turn_state'),
|
|
56
57
|
thread_id: z.string().min(1),
|
|
57
58
|
request_id: z.string().min(1),
|
|
58
59
|
state: z.string().min(1),
|
|
59
60
|
interrupted: z.boolean().optional(),
|
|
60
|
-
completed_at: z.union([z.string(),
|
|
61
|
-
})
|
|
61
|
+
completed_at: z.union([z.string(), number()]).nullable().optional(),
|
|
62
|
+
});
|
|
62
63
|
const RecordSchema = z.discriminatedUnion('recordType', [
|
|
63
64
|
RawSchema, ThreadStateSchema, TurnStateSchema,
|
|
64
65
|
]);
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { opendir } from 'node:fs/promises';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
+
import { integer, dateTime } from '../../schema/zod-validation.mjs';
|
|
4
5
|
import { schemaRejectionDetail, schemaIssueDetail, SessionContractError, } from '../contracts.js';
|
|
5
6
|
import { streamBoundedJsonLines } from '../readers.js';
|
|
6
7
|
export const PI_ADAPTER_VERSION = '1.0.0';
|
|
7
8
|
export const PI_SOURCE_SCHEMA_VERSION = '3.0.0';
|
|
8
|
-
const Header = z.
|
|
9
|
-
timestamp:
|
|
10
|
-
const Entry = z.
|
|
11
|
-
parentId: z.string().nullable(), timestamp:
|
|
9
|
+
const Header = z.looseObject({ type: z.literal('session'), version: integer(), id: z.string().min(1),
|
|
10
|
+
timestamp: dateTime({ offset: true }), cwd: z.string(), parentSession: z.string().optional() });
|
|
11
|
+
const Entry = z.looseObject({ type: z.string().min(1), id: z.string().min(1),
|
|
12
|
+
parentId: z.string().nullable(), timestamp: dateTime({ offset: true }) });
|
|
12
13
|
export class PiSessionAdapter {
|
|
13
14
|
limits;
|
|
14
15
|
maxFiles;
|
|
@@ -8,7 +8,7 @@ export const DEVIN_DESKTOP_TRANSCRIPT_SCHEMA_VERSION = '1.0.0';
|
|
|
8
8
|
export const WINDSURF_ADAPTER_VERSION = DEVIN_DESKTOP_ADAPTER_VERSION;
|
|
9
9
|
/** @deprecated Compatibility export. */
|
|
10
10
|
export const WINDSURF_TRANSCRIPT_SCHEMA_VERSION = DEVIN_DESKTOP_TRANSCRIPT_SCHEMA_VERSION;
|
|
11
|
-
const StepSchema = z.
|
|
11
|
+
const StepSchema = z.looseObject({
|
|
12
12
|
schema_version: z.string().optional(),
|
|
13
13
|
type: z.string().min(1),
|
|
14
14
|
status: z.string().min(1),
|
|
@@ -17,13 +17,13 @@ const StepSchema = z.object({
|
|
|
17
17
|
event_id: z.string().min(1).optional(),
|
|
18
18
|
timestamp: z.string().optional(),
|
|
19
19
|
model_name: z.string().optional(),
|
|
20
|
-
model: z.union([z.string(), z.record(z.unknown())]).optional(),
|
|
21
|
-
sensitive_content_warning: z.union([z.boolean(), z.string(), z.record(z.unknown())]).optional(),
|
|
22
|
-
user_input: z.record(z.unknown()).optional(),
|
|
23
|
-
planner_response: z.record(z.unknown()).optional(),
|
|
24
|
-
code_action: z.record(z.unknown()).optional(),
|
|
25
|
-
tool_info: z.record(z.unknown()).optional(),
|
|
26
|
-
})
|
|
20
|
+
model: z.union([z.string(), z.record(z.string(), z.unknown())]).optional(),
|
|
21
|
+
sensitive_content_warning: z.union([z.boolean(), z.string(), z.record(z.string(), z.unknown())]).optional(),
|
|
22
|
+
user_input: z.record(z.string(), z.unknown()).optional(),
|
|
23
|
+
planner_response: z.record(z.string(), z.unknown()).optional(),
|
|
24
|
+
code_action: z.record(z.string(), z.unknown()).optional(),
|
|
25
|
+
tool_info: z.record(z.string(), z.unknown()).optional(),
|
|
26
|
+
});
|
|
27
27
|
export class DevinDesktopSessionAdapter {
|
|
28
28
|
limits;
|
|
29
29
|
provider = 'devin-desktop';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { integer, dateTime } from '../schema/zod-validation.mjs';
|
|
2
3
|
import { sha256 } from './contracts.js';
|
|
3
4
|
export const SESSION_ANALYTICS_VERSION = '1.0.0';
|
|
4
5
|
export const SessionAnalyticsCategorySchema = z.enum([
|
|
@@ -21,7 +22,7 @@ export const SessionAnalyticsStatusSchema = z.enum([
|
|
|
21
22
|
'provider-unknown',
|
|
22
23
|
'observed',
|
|
23
24
|
]);
|
|
24
|
-
export const SessionAnalyticsFactSchema = z.
|
|
25
|
+
export const SessionAnalyticsFactSchema = z.strictObject({
|
|
25
26
|
analyticsVersion: z.literal(SESSION_ANALYTICS_VERSION),
|
|
26
27
|
factId: z.string().min(1),
|
|
27
28
|
category: SessionAnalyticsCategorySchema,
|
|
@@ -32,33 +33,33 @@ export const SessionAnalyticsFactSchema = z.object({
|
|
|
32
33
|
eventId: z.string().min(1),
|
|
33
34
|
sourceId: z.string().min(1),
|
|
34
35
|
importRunId: z.string().min(1),
|
|
35
|
-
occurredAt:
|
|
36
|
-
sequence:
|
|
36
|
+
occurredAt: dateTime({ offset: true }).nullable(),
|
|
37
|
+
sequence: integer().nonnegative(),
|
|
37
38
|
actor: z.string().min(1).nullable(),
|
|
38
39
|
participant: z.string().min(1).nullable(),
|
|
39
40
|
toolName: z.string().min(1).nullable(),
|
|
40
41
|
toolCallId: z.string().min(1).nullable(),
|
|
41
42
|
retryGroupId: z.string().min(1).nullable(),
|
|
42
|
-
retryOrdinal:
|
|
43
|
+
retryOrdinal: integer().positive().nullable(),
|
|
43
44
|
errorClass: z.string().min(1).nullable(),
|
|
44
45
|
capability: z.string().min(1).nullable(),
|
|
45
46
|
decision: z.string().min(1).nullable(),
|
|
46
47
|
promptType: z.string().min(1).nullable(),
|
|
47
|
-
latencyMs:
|
|
48
|
+
latencyMs: integer().nonnegative().nullable(),
|
|
48
49
|
transition: z.string().min(1).nullable(),
|
|
49
50
|
indicator: z.string().min(1).nullable(),
|
|
50
51
|
sensitivity: z.enum(['none', 'sensitive']),
|
|
51
52
|
extractionState: z.string().min(1).nullable(),
|
|
52
|
-
sourceCitation: z.
|
|
53
|
+
sourceCitation: z.strictObject({
|
|
53
54
|
provider: z.string().min(1),
|
|
54
55
|
sessionId: z.string().min(1),
|
|
55
56
|
eventId: z.string().min(1),
|
|
56
57
|
importRunId: z.string().min(1),
|
|
57
58
|
sourceId: z.string().min(1),
|
|
58
59
|
locatorClass: z.string().min(1),
|
|
59
|
-
sequence:
|
|
60
|
-
})
|
|
61
|
-
})
|
|
60
|
+
sequence: integer().nonnegative(),
|
|
61
|
+
}),
|
|
62
|
+
});
|
|
62
63
|
/**
|
|
63
64
|
* Derive content-free analytics facts from normalized session events.
|
|
64
65
|
*
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { integer } from '../schema/zod-validation.mjs';
|
|
2
3
|
import { IntelligenceCandidateSchema, IntelligenceCandidateTypeSchema, SESSION_CONTRACT_VERSION, SessionContractError, sha256, } from './contracts.js';
|
|
3
|
-
export const ExtractedCandidateDraftSchema = z.
|
|
4
|
+
export const ExtractedCandidateDraftSchema = z.strictObject({
|
|
4
5
|
type: IntelligenceCandidateTypeSchema,
|
|
5
6
|
assertion: z.string().min(1),
|
|
6
7
|
subject: z.string().min(1).nullable(),
|
|
7
8
|
predicate: z.string().min(1).nullable(),
|
|
8
9
|
object: z.string().min(1).nullable(),
|
|
9
|
-
evidence: z.array(z.
|
|
10
|
+
evidence: z.array(z.strictObject({
|
|
10
11
|
eventId: z.string().min(1),
|
|
11
|
-
start:
|
|
12
|
-
end:
|
|
13
|
-
})
|
|
12
|
+
start: integer().nonnegative(),
|
|
13
|
+
end: integer().positive(),
|
|
14
|
+
})).min(1),
|
|
14
15
|
confidence: z.number().min(0).max(1),
|
|
15
16
|
conflictsWith: z.array(z.string().min(1)).default([]),
|
|
16
17
|
supersedes: z.array(z.string().min(1)).default([]),
|
|
17
|
-
}).
|
|
18
|
+
}).superRefine((candidate, context) => {
|
|
18
19
|
if (candidate.type === 'relationship'
|
|
19
20
|
&& (!candidate.subject || !candidate.predicate || !candidate.object)) {
|
|
20
21
|
context.addIssue({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
+
import { integer, dateTime, number } from '../schema/zod-validation.mjs';
|
|
3
4
|
import { redactSessionText, redactSessionValue } from './policy.js';
|
|
4
5
|
export const SESSION_CONTRACT_VERSION = '1.0.0';
|
|
5
6
|
export const SESSION_PROVIDER_IDS = [
|
|
@@ -46,7 +47,7 @@ export const SessionCoveragePreflightSchema = z.object({
|
|
|
46
47
|
adapterVersion: z.string().nullable(),
|
|
47
48
|
supportedOperations: z.array(z.string()),
|
|
48
49
|
acquisitionModes: z.array(z.string()),
|
|
49
|
-
sourceCount:
|
|
50
|
+
sourceCount: integer().nonnegative(),
|
|
50
51
|
boundaries: z.array(z.string()),
|
|
51
52
|
remediation: z.string().nullable(),
|
|
52
53
|
})),
|
|
@@ -80,7 +81,7 @@ export const SessionErrorCodeSchema = z.enum([
|
|
|
80
81
|
]);
|
|
81
82
|
const VersionSchema = z.string().regex(/^\d+\.\d+\.\d+(?:[-+].+)?$/);
|
|
82
83
|
const DigestSchema = z.string().regex(/^sha256:[a-f0-9]{64}$/);
|
|
83
|
-
const NativeExtensionsSchema = z.record(z.unknown()).superRefine((value, context) => {
|
|
84
|
+
const NativeExtensionsSchema = z.record(z.string(), z.unknown()).superRefine((value, context) => {
|
|
84
85
|
for (const key of Object.keys(value)) {
|
|
85
86
|
if (!key.startsWith('native.')) {
|
|
86
87
|
context.addIssue({ code: z.ZodIssueCode.custom, message: `native extension must use native.<provider>: ${key}` });
|
|
@@ -99,8 +100,8 @@ export const SessionSourceSchema = z.object({
|
|
|
99
100
|
disposition: CapabilityDispositionSchema,
|
|
100
101
|
operationalState: OperationalStateSchema,
|
|
101
102
|
consistency: ConsistencyStateSchema,
|
|
102
|
-
authorizedAt:
|
|
103
|
-
extensions: NativeExtensionsSchema.
|
|
103
|
+
authorizedAt: dateTime({ offset: true }),
|
|
104
|
+
extensions: NativeExtensionsSchema.prefault({}),
|
|
104
105
|
});
|
|
105
106
|
export const SessionEventSchema = z.object({
|
|
106
107
|
contractVersion: z.literal(SESSION_CONTRACT_VERSION),
|
|
@@ -109,7 +110,7 @@ export const SessionEventSchema = z.object({
|
|
|
109
110
|
sourceId: z.string().min(1),
|
|
110
111
|
importRunId: z.string().min(1),
|
|
111
112
|
nativeId: z.string().min(1).nullable(),
|
|
112
|
-
sequence:
|
|
113
|
+
sequence: integer().nonnegative(),
|
|
113
114
|
kind: z.string().min(1),
|
|
114
115
|
role: z.string().min(1).nullable(),
|
|
115
116
|
participant: z.string().min(1).nullable().default(null),
|
|
@@ -118,7 +119,7 @@ export const SessionEventSchema = z.object({
|
|
|
118
119
|
model: z.string().min(1).nullable().default(null),
|
|
119
120
|
entities: z.array(z.string().min(1)).default([]),
|
|
120
121
|
extractionState: z.string().min(1).nullable().default(null),
|
|
121
|
-
occurredAt:
|
|
122
|
+
occurredAt: dateTime({ offset: true }).nullable(),
|
|
122
123
|
activityBoundary: z.enum(['pause', 'resume', 'continuation', 'end']).nullable().default(null),
|
|
123
124
|
activityBoundaryBasis: z.string().min(1).nullable().default(null),
|
|
124
125
|
activityBoundaryConfidence: z.enum(['low', 'medium', 'high']).nullable().default(null),
|
|
@@ -132,8 +133,8 @@ export const SessionEventSchema = z.object({
|
|
|
132
133
|
digest: DigestSchema,
|
|
133
134
|
rawReference: z.object({
|
|
134
135
|
locatorClass: z.string().min(1),
|
|
135
|
-
offset:
|
|
136
|
-
sequence:
|
|
136
|
+
offset: integer().nonnegative().optional(),
|
|
137
|
+
sequence: integer().nonnegative().optional(),
|
|
137
138
|
}),
|
|
138
139
|
adapterVersion: VersionSchema,
|
|
139
140
|
consistency: ConsistencyStateSchema,
|
|
@@ -142,7 +143,7 @@ export const SessionEventSchema = z.object({
|
|
|
142
143
|
classes: z.array(z.string().min(1)),
|
|
143
144
|
}),
|
|
144
145
|
opaque: z.boolean().default(false),
|
|
145
|
-
extensions: NativeExtensionsSchema.
|
|
146
|
+
extensions: NativeExtensionsSchema.prefault({}),
|
|
146
147
|
});
|
|
147
148
|
export const SessionSchema = z.object({
|
|
148
149
|
contractVersion: z.literal(SESSION_CONTRACT_VERSION),
|
|
@@ -151,8 +152,8 @@ export const SessionSchema = z.object({
|
|
|
151
152
|
provider: CompatibleSessionProviderIdSchema,
|
|
152
153
|
nativeSessionId: z.string().min(1),
|
|
153
154
|
workspaceId: z.string().min(1),
|
|
154
|
-
startedAt:
|
|
155
|
-
updatedAt:
|
|
155
|
+
startedAt: dateTime({ offset: true }).nullable(),
|
|
156
|
+
updatedAt: dateTime({ offset: true }).nullable(),
|
|
156
157
|
consistency: ConsistencyStateSchema,
|
|
157
158
|
lifecycle: z.enum([
|
|
158
159
|
'active', 'inactive', 'paused', 'complete', 'interrupted', 'archived',
|
|
@@ -161,10 +162,10 @@ export const SessionSchema = z.object({
|
|
|
161
162
|
intent: z.object({
|
|
162
163
|
status: z.enum(['selected', 'absent', 'unknown']),
|
|
163
164
|
eventId: z.string().min(1).nullable(),
|
|
164
|
-
sequence:
|
|
165
|
+
sequence: integer().nonnegative().nullable(),
|
|
165
166
|
title: z.string().nullable(),
|
|
166
167
|
summary: z.string().nullable(),
|
|
167
|
-
}).
|
|
168
|
+
}).prefault({
|
|
168
169
|
status: 'unknown',
|
|
169
170
|
eventId: null,
|
|
170
171
|
sequence: null,
|
|
@@ -172,12 +173,12 @@ export const SessionSchema = z.object({
|
|
|
172
173
|
summary: null,
|
|
173
174
|
}),
|
|
174
175
|
sourceDigest: DigestSchema,
|
|
175
|
-
extensions: NativeExtensionsSchema.
|
|
176
|
+
extensions: NativeExtensionsSchema.prefault({}),
|
|
176
177
|
});
|
|
177
178
|
export const ImportCheckpointSchema = z.object({
|
|
178
179
|
cursor: z.string(),
|
|
179
|
-
recordsRead:
|
|
180
|
-
bytesRead:
|
|
180
|
+
recordsRead: integer().nonnegative(),
|
|
181
|
+
bytesRead: integer().nonnegative(),
|
|
181
182
|
checkpointVersion: z.literal('2').optional(),
|
|
182
183
|
positionKind: z.enum(['record-index', 'byte-offset', 'provider-native']).optional(),
|
|
183
184
|
sourceGeneration: z.string().min(1).optional(),
|
|
@@ -191,8 +192,8 @@ export const ImportCheckpointSchema = z.object({
|
|
|
191
192
|
'unchanged-replay',
|
|
192
193
|
'unverified',
|
|
193
194
|
]).optional(),
|
|
194
|
-
sourceSize:
|
|
195
|
-
sourceMtimeMs: z.
|
|
195
|
+
sourceSize: integer().nonnegative().optional(),
|
|
196
|
+
sourceMtimeMs: number().check(z.gte(0)).meta({ type: 'number', minimum: 0 }).optional(),
|
|
196
197
|
sourceFileIdentity: z.string().min(1).optional(),
|
|
197
198
|
prefixDigest: DigestSchema.optional(),
|
|
198
199
|
});
|
|
@@ -206,8 +207,8 @@ export const ImportRunSchema = z.object({
|
|
|
206
207
|
consistency: ConsistencyStateSchema,
|
|
207
208
|
status: z.enum(['running', 'committed', 'rolled-back', 'failed']),
|
|
208
209
|
checkpoint: ImportCheckpointSchema,
|
|
209
|
-
startedAt:
|
|
210
|
-
completedAt:
|
|
210
|
+
startedAt: dateTime({ offset: true }),
|
|
211
|
+
completedAt: dateTime({ offset: true }).nullable(),
|
|
211
212
|
errorCode: SessionErrorCodeSchema.nullable(),
|
|
212
213
|
});
|
|
213
214
|
export const ProvenanceEdgeSchema = z.object({
|
|
@@ -220,7 +221,7 @@ export const ProvenanceEdgeSchema = z.object({
|
|
|
220
221
|
fromId: z.string().min(1),
|
|
221
222
|
toId: z.string().min(1),
|
|
222
223
|
importRunId: z.string().min(1),
|
|
223
|
-
createdAt:
|
|
224
|
+
createdAt: dateTime({ offset: true }),
|
|
224
225
|
});
|
|
225
226
|
export const IntelligenceCandidateTypeSchema = z.enum([
|
|
226
227
|
'decision', 'requirement', 'constraint', 'preference', 'task', 'discovery',
|
|
@@ -231,29 +232,29 @@ export const CandidateSecurityWarningSchema = z.enum([
|
|
|
231
232
|
'instruction-like', 'structure-breaking', 'control-character', 'bidi-control',
|
|
232
233
|
'unicode-confusable', 'active-content', 'secret-bearing',
|
|
233
234
|
]);
|
|
234
|
-
export const CandidateSecuritySchema = z.
|
|
235
|
+
export const CandidateSecuritySchema = z.strictObject({
|
|
235
236
|
disposition: z.enum(['clear', 'suspicious']),
|
|
236
237
|
warnings: z.array(CandidateSecurityWarningSchema),
|
|
237
238
|
requiresAcknowledgement: z.boolean(),
|
|
238
239
|
acknowledged: z.boolean(),
|
|
239
240
|
policyVersion: VersionSchema,
|
|
240
|
-
})
|
|
241
|
-
export const IntelligenceCandidateSchema = z.
|
|
241
|
+
});
|
|
242
|
+
export const IntelligenceCandidateSchema = z.strictObject({
|
|
242
243
|
contractVersion: z.literal(SESSION_CONTRACT_VERSION),
|
|
243
244
|
candidateId: z.string().min(1),
|
|
244
|
-
version:
|
|
245
|
+
version: integer().positive(),
|
|
245
246
|
type: IntelligenceCandidateTypeSchema,
|
|
246
247
|
assertion: z.string().min(1),
|
|
247
248
|
subject: z.string().min(1).nullable(),
|
|
248
249
|
predicate: z.string().min(1).nullable(),
|
|
249
250
|
object: z.string().min(1).nullable(),
|
|
250
|
-
evidence: z.array(z.
|
|
251
|
+
evidence: z.array(z.strictObject({
|
|
251
252
|
eventId: z.string().min(1),
|
|
252
|
-
start:
|
|
253
|
-
end:
|
|
253
|
+
start: integer().nonnegative(),
|
|
254
|
+
end: integer().positive(),
|
|
254
255
|
quoteDigest: DigestSchema,
|
|
255
256
|
quote: z.string().min(1).optional(),
|
|
256
|
-
})
|
|
257
|
+
})).min(1),
|
|
257
258
|
confidence: z.number().min(0).max(1),
|
|
258
259
|
temporalScope: z.string().min(1),
|
|
259
260
|
projectScope: z.string().min(1),
|
|
@@ -262,7 +263,7 @@ export const IntelligenceCandidateSchema = z.object({
|
|
|
262
263
|
extractionPolicyVersion: VersionSchema,
|
|
263
264
|
model: z.string().min(1).nullable(),
|
|
264
265
|
sensitivity: z.enum(['none', 'sensitive']),
|
|
265
|
-
security: CandidateSecuritySchema.
|
|
266
|
+
security: CandidateSecuritySchema.prefault({
|
|
266
267
|
disposition: 'clear',
|
|
267
268
|
warnings: [],
|
|
268
269
|
requiresAcknowledgement: false,
|
|
@@ -274,8 +275,8 @@ export const IntelligenceCandidateSchema = z.object({
|
|
|
274
275
|
]),
|
|
275
276
|
conflictsWith: z.array(z.string().min(1)).default([]),
|
|
276
277
|
supersedes: z.array(z.string().min(1)).default([]),
|
|
277
|
-
createdAt:
|
|
278
|
-
}).
|
|
278
|
+
createdAt: dateTime({ offset: true }),
|
|
279
|
+
}).superRefine((candidate, context) => {
|
|
279
280
|
if (candidate.type === 'relationship'
|
|
280
281
|
&& (!candidate.subject || !candidate.predicate || !candidate.object)) {
|
|
281
282
|
context.addIssue({
|
|
@@ -284,11 +285,11 @@ export const IntelligenceCandidateSchema = z.object({
|
|
|
284
285
|
});
|
|
285
286
|
}
|
|
286
287
|
});
|
|
287
|
-
export const CandidateReviewReceiptSchema = z.
|
|
288
|
+
export const CandidateReviewReceiptSchema = z.strictObject({
|
|
288
289
|
contractVersion: z.literal(SESSION_CONTRACT_VERSION),
|
|
289
290
|
receiptId: z.string().min(1),
|
|
290
291
|
candidateId: z.string().min(1),
|
|
291
|
-
candidateVersion:
|
|
292
|
+
candidateVersion: integer().positive(),
|
|
292
293
|
fromState: z.enum([
|
|
293
294
|
'pending', 'accepted', 'rejected', 'deferred', 'promoted', 'superseded',
|
|
294
295
|
]),
|
|
@@ -299,18 +300,18 @@ export const CandidateReviewReceiptSchema = z.object({
|
|
|
299
300
|
reason: z.string().min(1),
|
|
300
301
|
securityWarnings: z.array(CandidateSecurityWarningSchema).default([]),
|
|
301
302
|
securityAcknowledged: z.boolean().default(false),
|
|
302
|
-
occurredAt:
|
|
303
|
-
})
|
|
304
|
-
export const PromotionReceiptSchema = z.
|
|
303
|
+
occurredAt: dateTime({ offset: true }),
|
|
304
|
+
});
|
|
305
|
+
export const PromotionReceiptSchema = z.strictObject({
|
|
305
306
|
contractVersion: z.literal(SESSION_CONTRACT_VERSION),
|
|
306
307
|
receiptId: z.string().min(1),
|
|
307
308
|
operationId: z.string().min(1),
|
|
308
309
|
candidateId: z.string().min(1),
|
|
309
|
-
candidateVersion:
|
|
310
|
+
candidateVersion: integer().positive(),
|
|
310
311
|
consumer: z.string().min(1),
|
|
311
312
|
destinationRef: z.string().min(1),
|
|
312
313
|
reviewer: z.string().min(1),
|
|
313
|
-
approvedAt:
|
|
314
|
+
approvedAt: dateTime({ offset: true }),
|
|
314
315
|
evidenceEventIds: z.array(z.string().min(1)).min(1),
|
|
315
316
|
conflictsWith: z.array(z.string().min(1)),
|
|
316
317
|
supersedes: z.array(z.string().min(1)),
|
|
@@ -318,27 +319,27 @@ export const PromotionReceiptSchema = z.object({
|
|
|
318
319
|
afterHash: DigestSchema,
|
|
319
320
|
dryRun: z.boolean(),
|
|
320
321
|
duplicate: z.boolean(),
|
|
321
|
-
})
|
|
322
|
-
export const DeletionReceiptSchema = z.
|
|
322
|
+
});
|
|
323
|
+
export const DeletionReceiptSchema = z.strictObject({
|
|
323
324
|
contractVersion: z.literal(SESSION_CONTRACT_VERSION),
|
|
324
325
|
receiptId: z.string().min(1),
|
|
325
326
|
operationId: z.string().min(1),
|
|
326
327
|
scopeClass: z.string().min(1),
|
|
327
|
-
counts: z.record(z.
|
|
328
|
+
counts: z.record(z.string(), integer().nonnegative()),
|
|
328
329
|
survivingDependentIds: z.array(z.string().min(1)),
|
|
329
330
|
actorClass: z.string().min(1),
|
|
330
331
|
reasonCode: z.string().min(1),
|
|
331
|
-
orphanCounts: z.record(z.
|
|
332
|
+
orphanCounts: z.record(z.string(), integer().nonnegative()),
|
|
332
333
|
outcome: z.enum(['preview', 'committed', 'failed']),
|
|
333
|
-
occurredAt:
|
|
334
|
-
})
|
|
335
|
-
export const PromotionDependencyDecisionSchema = z.
|
|
334
|
+
occurredAt: dateTime({ offset: true }),
|
|
335
|
+
});
|
|
336
|
+
export const PromotionDependencyDecisionSchema = z.strictObject({
|
|
336
337
|
dependentId: z.string().min(1),
|
|
337
338
|
action: z.enum([
|
|
338
339
|
'revoke', 'supersede', 'retain', 'origin_unavailable', 'delete', 'abort',
|
|
339
340
|
]),
|
|
340
341
|
basis: z.string().min(1),
|
|
341
|
-
})
|
|
342
|
+
});
|
|
342
343
|
export function assertSessionProviderId(value) {
|
|
343
344
|
const canonical = SESSION_PROVIDER_ALIASES[value] ?? value;
|
|
344
345
|
const parsed = SessionProviderIdSchema.safeParse(canonical);
|
|
@@ -373,7 +374,7 @@ function stableId(prefix, ...parts) {
|
|
|
373
374
|
return `${prefix}_${createHash('sha256').update(parts.join('\0')).digest('hex')}`;
|
|
374
375
|
}
|
|
375
376
|
export const SessionRejectionDetailSchema = z.union([
|
|
376
|
-
z.object({ limit: z.string(), configured:
|
|
377
|
+
z.object({ limit: z.string(), configured: number(), observed: number(),
|
|
377
378
|
setting: z.string().optional(), origin: z.enum(['flag', 'env', 'config', 'default']).optional() }),
|
|
378
379
|
z.object({ issues: z.array(z.object({ path: z.string(), code: z.string() })) }),
|
|
379
380
|
]);
|
|
@@ -390,16 +391,25 @@ export function assertSessionResourceLimit(limit, configured, observed) {
|
|
|
390
391
|
/** Extract schema locations and validator codes without messages or input values. */
|
|
391
392
|
export function schemaRejectionDetail(error) {
|
|
392
393
|
const issues = [];
|
|
393
|
-
const visit = (entries) => {
|
|
394
|
+
const visit = (entries, prefix = []) => {
|
|
394
395
|
for (const issue of entries) {
|
|
395
396
|
if (issues.length >= 20)
|
|
396
397
|
return;
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
398
|
+
const path = [...prefix, ...issue.path];
|
|
399
|
+
if (issue.code === 'invalid_union' && issue.errors.length === 0) {
|
|
400
|
+
issues.push({ path: path.join('.') || '<root>', code: 'invalid_union_discriminator' });
|
|
401
|
+
}
|
|
402
|
+
else if (issue.code === 'invalid_union') {
|
|
403
|
+
// Native union branches carry paths relative to their parent union.
|
|
404
|
+
for (const branch of issue.errors)
|
|
405
|
+
visit(branch, path);
|
|
400
406
|
}
|
|
401
407
|
else {
|
|
402
|
-
|
|
408
|
+
// Keep the published diagnostic codes stable across validator versions.
|
|
409
|
+
const code = issue.code === 'invalid_value'
|
|
410
|
+
? (issue.values.length === 1 ? 'invalid_literal' : 'invalid_enum_value')
|
|
411
|
+
: issue.code === 'invalid_format' ? 'invalid_string' : issue.code;
|
|
412
|
+
issues.push({ path: path.join('.') || '<root>', code });
|
|
403
413
|
}
|
|
404
414
|
}
|
|
405
415
|
};
|