@aiwg/cli 2026.10.4 → 2026.10.6
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 +3 -1
- package/dist/src/artifacts/browser-export.js +1 -0
- package/dist/src/artifacts/citation-parser.js +8 -1
- package/dist/src/artifacts/cli.js +72 -9
- 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/graph-query.js +18 -8
- package/dist/src/artifacts/index-adapters.js +339 -0
- package/dist/src/artifacts/index-builder.js +146 -16
- package/dist/src/artifacts/index-files.js +15 -4
- package/dist/src/artifacts/index-preparation.js +91 -26
- package/dist/src/artifacts/index-reader.js +44 -0
- package/dist/src/artifacts/index-refresh.js +130 -56
- package/dist/src/artifacts/index-status.js +20 -5
- package/dist/src/artifacts/index-worker.mjs +9 -7
- 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/cli/handlers/decision.js +19 -1
- 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/local-executor.js +5 -3
- 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 +40 -6
- package/dist/src/cli/handlers/setup.js +428 -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 +279 -93
- package/dist/src/cli/handlers/workspace.js +3 -1
- package/dist/src/cli/prompt-utils.js +8 -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/native-sandbox-warnings.js +25 -0
- package/dist/src/contributors/validation.js +6 -5
- package/dist/src/decision/admission.js +7 -3
- package/dist/src/decision/benchmark.js +469 -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 +18 -15
- package/dist/src/decision/qualification/load-staged.js +539 -0
- package/dist/src/decision/qualification/load.js +109 -33
- package/dist/src/decision/qualification/runner.js +5 -2
- 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 +233 -0
- package/dist/src/discovery/plan-apply.js +571 -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/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-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/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/mcp/cli.mjs +5 -6
- package/dist/src/mcp/config-file.mjs +6 -2
- package/dist/src/mcp/config-layers.mjs +23 -7
- 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 +17 -4
- 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/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/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 +7 -0
- package/dist/src/models/worker-installation.mjs +169 -37
- package/dist/src/models/wrapper-route.js +1 -1
- package/dist/src/output-modes/registry.js +8 -7
- package/dist/src/plugin/metadata-validator.js +1 -1
- 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 +114 -15
- package/dist/src/sessions/adapters/claude.js +19 -18
- package/dist/src/sessions/adapters/codex.js +33 -19
- 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/batch-contracts.js +1 -1
- package/dist/src/sessions/batch-import.js +202 -2
- package/dist/src/sessions/candidates.js +7 -6
- package/dist/src/sessions/contracts.js +73 -54
- package/dist/src/sessions/coverage-preflight.js +26 -1
- package/dist/src/sessions/output-registration.js +11 -10
- package/dist/src/sessions/policy.js +18 -7
- package/dist/src/sessions/refresh.js +2 -3
- package/dist/src/sessions/repository.js +4 -2
- package/dist/src/sessions/workspace-discovery.js +92 -26
- package/dist/src/smiths/context-pipeline/aiwg-md.js +18 -1
- package/dist/src/smiths/context-pipeline/claude-hook.js +42 -6
- package/dist/src/smiths/context-pipeline/parallelism-section.js +72 -5
- package/dist/src/smiths/context-pipeline/workspace-context.js +106 -10
- package/dist/src/update/checker.d.mts +4 -0
- package/dist/src/update/checker.mjs +14 -0
- 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 +19 -13
- package/tools/agents/providers/claude.mjs +1 -1
- package/tools/agents/providers/codex.mjs +50 -56
- package/tools/agents/providers/copilot.mjs +8 -2
- 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 +7 -13
- package/tools/agents/providers/muse-hooks.mjs +21 -14
- package/tools/agents/providers/muse.mjs +7 -2
- package/tools/agents/providers/omp.mjs +28 -4
- 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 +263 -71
- package/tools/agents/providers/windsurf.mjs +7 -0
- 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/muse-adapter.mjs +12 -2
- 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 +7 -4
- package/tools/ralph-external/session-launcher.mjs +280 -32
- 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
|
*
|
|
@@ -24,7 +24,7 @@ export function coverageFromBatchRun(run, now = new Date(), staleAfterMs = 24 *
|
|
|
24
24
|
const unresolvedProviders = preflight?.unresolvedProviders
|
|
25
25
|
?? [...new Set([...unavailable, ...exportRequired, ...notChecked])].sort();
|
|
26
26
|
const acquisitionIncomplete = rejected > 0 || pending > 0 || skipped > 0
|
|
27
|
-
|| (preflight
|
|
27
|
+
|| (preflight && ['explicit', 'workspace-config'].includes(preflight.expectedProviderBasis) && unresolvedProviders.length > 0);
|
|
28
28
|
const incomplete = acquisitionIncomplete || !preflight || preflight.status !== 'complete'
|
|
29
29
|
|| unavailable.length > 0 || accepted + duplicated + previouslyCommitted + excluded === 0
|
|
30
30
|
|| exportRequired.length > 0 || notChecked.length > 0;
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import { stat } from 'node:fs/promises';
|
|
1
|
+
import { mkdtemp, rm, stat } from 'node:fs/promises';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
2
4
|
import { createSessionAdapterRegistry } from './adapter-registry.js';
|
|
3
5
|
import { coveragePreflight, sessionRuntimeIdentity } from './coverage-preflight.js';
|
|
4
|
-
import { SESSION_CONTRACT_VERSION, SessionContractError, schemaIssueDetail, SessionSourceSchema, sha256, } from './contracts.js';
|
|
6
|
+
import { SESSION_CONTRACT_VERSION, SessionContractError, schemaIssueDetail, SessionSourceSchema, sha256, stableSessionId, stableEventId, } from './contracts.js';
|
|
5
7
|
import { BATCH_IMPORT_VERSION, coverageFromBatchRun, } from './batch-contracts.js';
|
|
6
8
|
import { IncrementalSessionImporter, SessionImportFailure } from './importer.js';
|
|
7
9
|
import { matchImportExclusion, resolveImportExclusions } from './import-exclusions.js';
|
|
8
10
|
import { resolveImportLimits } from './import-limits.js';
|
|
9
11
|
import { fingerprintSourceFile } from './readers.js';
|
|
12
|
+
import { SessionRepository } from './repository.js';
|
|
13
|
+
import { redactSessionValue, sanitizeSessionEvent } from './policy.js';
|
|
14
|
+
import { deriveSessionIntent } from './origin.js';
|
|
15
|
+
import { recoverCodexRolloutIdentity } from './adapters/codex.js';
|
|
10
16
|
export async function importDiscoveryManifest(options) {
|
|
17
|
+
if (options.carryForward)
|
|
18
|
+
return rebuildFromCatalog(options);
|
|
11
19
|
const exclusions = resolveImportExclusions(undefined, options.exclude);
|
|
12
20
|
const limits = { ...resolveImportLimits(undefined, {
|
|
13
21
|
maxRecordBytes: options.limits?.maxRecordBytes, maxSourceBytes: options.limits?.maxTotalBytes,
|
|
@@ -25,6 +33,8 @@ export async function importDiscoveryManifest(options) {
|
|
|
25
33
|
}
|
|
26
34
|
run.schemaVersion = BATCH_IMPORT_VERSION;
|
|
27
35
|
run.preflight = coveragePreflight({
|
|
36
|
+
configuredProviders: options.manifest.preflight?.configuredProviders,
|
|
37
|
+
scopeWarnings: options.manifest.preflight?.scopeWarnings,
|
|
28
38
|
expectedProviders: options.manifest.preflight?.expectedProviders,
|
|
29
39
|
expectedProviderBasis: options.manifest.preflight?.expectedProviderBasis ?? 'legacy',
|
|
30
40
|
runtime: options.runtime ?? sessionRuntimeIdentity(),
|
|
@@ -160,6 +170,8 @@ export function previewDiscoveryImport(manifest, existing, now = new Date(), exc
|
|
|
160
170
|
return disposition;
|
|
161
171
|
}),
|
|
162
172
|
preflight: coveragePreflight({
|
|
173
|
+
configuredProviders: manifest.preflight?.configuredProviders,
|
|
174
|
+
scopeWarnings: manifest.preflight?.scopeWarnings,
|
|
163
175
|
expectedProviders: manifest.preflight?.expectedProviders,
|
|
164
176
|
expectedProviderBasis: manifest.preflight?.expectedProviderBasis ?? 'legacy',
|
|
165
177
|
reports: manifest.providers,
|
|
@@ -202,6 +214,7 @@ function receiptFor(run, now) {
|
|
|
202
214
|
run,
|
|
203
215
|
coverage,
|
|
204
216
|
interruptedRuns: [],
|
|
217
|
+
...(run.carryForward ? { carryForward: run.carryForward } : {}),
|
|
205
218
|
totals: {
|
|
206
219
|
discovered: coverage.sources.discovered,
|
|
207
220
|
accepted: coverage.sources.accepted,
|
|
@@ -304,4 +317,191 @@ function isAccepted(status) {
|
|
|
304
317
|
|| status === 'duplicate'
|
|
305
318
|
|| status === 'previously-committed';
|
|
306
319
|
}
|
|
320
|
+
/** Reuse source import and normalized repository gates, without copying FTS/analytics. */
|
|
321
|
+
async function rebuildFromCatalog(options) {
|
|
322
|
+
const previous = options.carryForward;
|
|
323
|
+
if (previous === options.repository) {
|
|
324
|
+
throw new SessionContractError('INVALID_ARGUMENT', 'carry-forward requires a separate destination catalog');
|
|
325
|
+
}
|
|
326
|
+
const workspaceId = options.manifest.workspaceId;
|
|
327
|
+
const exclusions = resolveImportExclusions(undefined, options.exclude);
|
|
328
|
+
const byProvider = {};
|
|
329
|
+
const counts = (provider) => byProvider[provider] ??= {
|
|
330
|
+
reimported: 0, carried: 0, droppedAsDuplicate: 0, excluded: 0,
|
|
331
|
+
};
|
|
332
|
+
const oldSessions = catalogSessions(previous, workspaceId);
|
|
333
|
+
const available = [];
|
|
334
|
+
const present = new Set();
|
|
335
|
+
const excludedSources = new Set();
|
|
336
|
+
for (const source of options.manifest.sources) {
|
|
337
|
+
if (matchImportExclusion(source, exclusions) ?? source.exclusion) {
|
|
338
|
+
excludedSources.add(source.sourceId);
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
let details;
|
|
342
|
+
try {
|
|
343
|
+
details = await stat(source.locator);
|
|
344
|
+
}
|
|
345
|
+
catch (error) {
|
|
346
|
+
if (['ENOENT', 'ENOTDIR'].includes(error.code ?? ''))
|
|
347
|
+
continue;
|
|
348
|
+
throw error;
|
|
349
|
+
}
|
|
350
|
+
// Refresh the snapshot, but retain the explicitly saved authorization and source identity.
|
|
351
|
+
const fingerprint = await fingerprintSourceFile({ selectedPath: source.locator,
|
|
352
|
+
allowedRoots: [source.authorizedRoot] });
|
|
353
|
+
available.push({ ...source, sizeBytes: details.size, modifiedAt: details.mtime.toISOString(),
|
|
354
|
+
digest: fingerprint.digest });
|
|
355
|
+
present.add(source.sourceId);
|
|
356
|
+
}
|
|
357
|
+
const manifest = { ...options.manifest, sources: available,
|
|
358
|
+
manifestId: sha256(JSON.stringify(['carry-forward-v1', options.manifest.manifestId, available])) };
|
|
359
|
+
const stagingDirectory = await mkdtemp(join(tmpdir(), 'aiwg-session-rebuild-'));
|
|
360
|
+
let staged;
|
|
361
|
+
try {
|
|
362
|
+
staged = new SessionRepository(join(stagingDirectory, 'staging.sqlite'));
|
|
363
|
+
const receipt = await importDiscoveryManifest({ ...options, manifest, repository: staged,
|
|
364
|
+
carryForward: undefined, fault: undefined });
|
|
365
|
+
const identities = new Set();
|
|
366
|
+
const destinationCodex = new Map(catalogSessions(options.repository, workspaceId)
|
|
367
|
+
.filter(session => session.provider === 'codex').map(session => [session.nativeSessionId, session.sourceId]));
|
|
368
|
+
const transfer = (repository, sessions, category) => {
|
|
369
|
+
// A legacy Codex rollout may have split replayed parent events into phantom rows.
|
|
370
|
+
// Recover the first session_meta ID for the whole source before grouping events.
|
|
371
|
+
const sourceGroups = new Map();
|
|
372
|
+
for (const session of sessions) {
|
|
373
|
+
const group = sourceGroups.get(session.sourceId) ?? [];
|
|
374
|
+
group.push(session);
|
|
375
|
+
sourceGroups.set(session.sourceId, group);
|
|
376
|
+
}
|
|
377
|
+
for (const [sourceId, group] of sourceGroups) {
|
|
378
|
+
if (options.signal?.aborted)
|
|
379
|
+
throw new SessionContractError('IMPORT_INTERRUPTED', 'catalog rebuild interrupted');
|
|
380
|
+
const source = repository.getSource(sourceId, workspaceId);
|
|
381
|
+
if (!source)
|
|
382
|
+
throw new SessionContractError('IMPORT_CONFLICT', 'catalog session has no authorized source');
|
|
383
|
+
const allEvents = group.flatMap(session => repository.listEvents(session.sessionId, workspaceId))
|
|
384
|
+
.sort((a, b) => a.sequence - b.sequence || a.eventId.localeCompare(b.eventId));
|
|
385
|
+
const rollout = source.provider === 'codex' ? recoverCodexRolloutIdentity(allEvents) : undefined;
|
|
386
|
+
const childId = rollout?.nativeSessionId;
|
|
387
|
+
// Prefer the child's aggregate when the legacy source also has phantom parent aggregates.
|
|
388
|
+
group.sort((a, b) => Number(b.nativeSessionId === childId) - Number(a.nativeSessionId === childId));
|
|
389
|
+
const canonical = new Map();
|
|
390
|
+
for (const session of group) {
|
|
391
|
+
const nativeId = childId ?? session.nativeSessionId;
|
|
392
|
+
const locator = options.manifest.sources.find(item => item.sourceId === sourceId)?.locator
|
|
393
|
+
?? source.redactedLocator;
|
|
394
|
+
if (excludedSources.has(sourceId) || matchImportExclusion({ provider: session.provider,
|
|
395
|
+
locator, locatorClass: source.locatorClass, nativeSessionId: nativeId }, exclusions)) {
|
|
396
|
+
counts(session.provider).excluded++;
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
const key = session.provider === 'codex' ? `${session.provider}\0${nativeId}` : session.sessionId;
|
|
400
|
+
if (identities.has(key)) {
|
|
401
|
+
counts(session.provider).droppedAsDuplicate++;
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
404
|
+
const existing = canonical.get(key);
|
|
405
|
+
if (existing) {
|
|
406
|
+
counts(session.provider).droppedAsDuplicate++;
|
|
407
|
+
existing.events.push(...repository.listEvents(session.sessionId, workspaceId));
|
|
408
|
+
}
|
|
409
|
+
else
|
|
410
|
+
canonical.set(key, { session: { ...session, nativeSessionId: nativeId },
|
|
411
|
+
events: repository.listEvents(session.sessionId, workspaceId) });
|
|
412
|
+
}
|
|
413
|
+
for (const [key, entry] of canonical) {
|
|
414
|
+
if (source.provider === 'codex' && destinationCodex.has(entry.session.nativeSessionId)
|
|
415
|
+
&& destinationCodex.get(entry.session.nativeSessionId) !== sourceId) {
|
|
416
|
+
throw new SessionContractError('IMPORT_CONFLICT', 'destination has a different source for this Codex identity; select a fresh catalog');
|
|
417
|
+
}
|
|
418
|
+
const session = redactSessionValue({ ...entry.session,
|
|
419
|
+
sessionId: stableSessionId(source.provider, sourceId, entry.session.nativeSessionId),
|
|
420
|
+
}).value;
|
|
421
|
+
// Hash only sanitized content; receipts and IDs must never retain old plaintext.
|
|
422
|
+
const sanitized = entry.events.map(sanitizeSessionEvent);
|
|
423
|
+
const runId = sha256(JSON.stringify(['catalog-carry-v1', session.sessionId, sanitized]));
|
|
424
|
+
const events = sanitized.map(event => {
|
|
425
|
+
const digest = event.digest;
|
|
426
|
+
return { ...event, sessionId: session.sessionId, importRunId: runId, digest,
|
|
427
|
+
eventId: stableEventId(source.provider, sourceId, {
|
|
428
|
+
nativeSessionId: session.nativeSessionId, nativeEventId: event.nativeId ?? event.eventId,
|
|
429
|
+
sequence: event.sequence, kind: event.kind, text: event.searchableText,
|
|
430
|
+
rawReference: event.rawReference,
|
|
431
|
+
}, digest) };
|
|
432
|
+
});
|
|
433
|
+
if (rollout && Object.keys(rollout.lineage).length > 0) {
|
|
434
|
+
session.extensions['native.codex'] = { lineage: rollout.lineage };
|
|
435
|
+
}
|
|
436
|
+
session.intent = deriveSessionIntent(events);
|
|
437
|
+
const checkpoint = repository.getCheckpoint(sourceId, source.adapterVersion)
|
|
438
|
+
?? { cursor: '', recordsRead: events.length, bytesRead: Buffer.byteLength(JSON.stringify(events)) };
|
|
439
|
+
options.repository.applyImport({ source, sessions: [session], events,
|
|
440
|
+
run: { contractVersion: SESSION_CONTRACT_VERSION, importRunId: runId, sourceId,
|
|
441
|
+
parserVersion: source.adapterVersion, policyVersion: '1.0.0',
|
|
442
|
+
sourceSchemaVersion: source.sourceSchemaVersion, consistency: source.consistency,
|
|
443
|
+
status: 'running', checkpoint, startedAt: (options.now?.() ?? new Date()).toISOString(),
|
|
444
|
+
completedAt: null, errorCode: null } }, checkpoint);
|
|
445
|
+
for (const old of group.filter(item => (childId ?? item.nativeSessionId) === entry.session.nativeSessionId)) {
|
|
446
|
+
for (const tag of repository.listTags(old.sessionId, workspaceId)) {
|
|
447
|
+
options.repository.tagSession(session.sessionId, tag, workspaceId);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
identities.add(key);
|
|
451
|
+
counts(source.provider)[category]++;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
const reimported = catalogSessions(staged, workspaceId);
|
|
456
|
+
transfer(staged, reimported, 'reimported');
|
|
457
|
+
for (const sourceId of present) {
|
|
458
|
+
const old = oldSessions.filter(session => session.sourceId === sourceId && session.provider === 'codex');
|
|
459
|
+
const imported = reimported.filter(session => session.sourceId === sourceId);
|
|
460
|
+
// Account for phantom rows eliminated by current source parsing, separately from copied duplicates.
|
|
461
|
+
if (imported.length > 0 && old.length > imported.length) {
|
|
462
|
+
counts('codex').droppedAsDuplicate += old.length - imported.length;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
transfer(previous, oldSessions.filter(session => !present.has(session.sourceId)), 'carried');
|
|
466
|
+
options.repository.reindex(workspaceId);
|
|
467
|
+
const finalSessions = catalogSessions(options.repository, workspaceId);
|
|
468
|
+
const sourceIds = new Set([...receipt.run.sources.map(item => item.sourceId),
|
|
469
|
+
...oldSessions.map(session => session.sourceId)]);
|
|
470
|
+
for (const sourceId of sourceIds) {
|
|
471
|
+
const accepted = finalSessions.filter(session => session.sourceId === sourceId);
|
|
472
|
+
let disposition = receipt.run.sources.find(item => item.sourceId === sourceId);
|
|
473
|
+
if (!disposition) {
|
|
474
|
+
const old = oldSessions.find(session => session.sourceId === sourceId);
|
|
475
|
+
const excluded = excludedSources.has(sourceId) || matchImportExclusion({
|
|
476
|
+
provider: old.provider, nativeSessionId: old.nativeSessionId,
|
|
477
|
+
locator: previous.getSource(sourceId, workspaceId)?.redactedLocator ?? '', locatorClass: 'catalog',
|
|
478
|
+
}, exclusions);
|
|
479
|
+
disposition = { sourceId, provider: old.provider,
|
|
480
|
+
status: excluded ? 'excluded' : accepted.length > 0 ? 'committed' : 'duplicate',
|
|
481
|
+
attempts: 1, sessionsAccepted: 0, eventsAccepted: 0,
|
|
482
|
+
errorCode: null, diagnostic: null, updatedAt: receipt.run.updatedAt };
|
|
483
|
+
receipt.run.sources.push(disposition);
|
|
484
|
+
}
|
|
485
|
+
disposition.sessionsAccepted = accepted.length;
|
|
486
|
+
disposition.eventsAccepted = accepted.reduce((sum, session) => sum + options.repository.listEvents(session.sessionId, workspaceId).length, 0);
|
|
487
|
+
}
|
|
488
|
+
receipt.run.carryForward = { byProvider };
|
|
489
|
+
options.repository.saveBatchImportRun(receipt.run);
|
|
490
|
+
return redactSessionValue(receiptFor(receipt.run, options.now?.() ?? new Date())).value;
|
|
491
|
+
}
|
|
492
|
+
finally {
|
|
493
|
+
staged?.close();
|
|
494
|
+
await rm(stagingDirectory, { recursive: true, force: true });
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
function catalogSessions(repository, workspaceId) {
|
|
498
|
+
const sessions = [];
|
|
499
|
+
let cursor;
|
|
500
|
+
do {
|
|
501
|
+
const page = repository.listSessions({ workspaceId, limit: 500, cursor });
|
|
502
|
+
sessions.push(...page.items);
|
|
503
|
+
cursor = page.nextCursor ?? undefined;
|
|
504
|
+
} while (cursor);
|
|
505
|
+
return sessions;
|
|
506
|
+
}
|
|
307
507
|
//# sourceMappingURL=batch-import.js.map
|
|
@@ -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({
|