@bitkyc08/opencodex 2.11.1 → 2.12.0
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 +1 -1
- package/bin/ocx.mjs +4 -0
- package/gui/dist/assets/index-BNVYzdn0.css +1 -0
- package/gui/dist/assets/index-Cw1_mxO8.js +70 -0
- package/gui/dist/index.html +2 -2
- package/package.json +1 -1
- package/src/adapters/command-code.ts +94 -5
- package/src/adapters/cursor/live-transport.ts +14 -1
- package/src/adapters/google-tool-schema.ts +80 -15
- package/src/adapters/google.ts +24 -7
- package/src/adapters/openai-chat.ts +233 -305
- package/src/adapters/openai-responses.ts +62 -0
- package/src/adapters/tool-catalog-nudge.ts +2 -11
- package/src/claude/outbound.ts +42 -14
- package/src/cli/claude.ts +61 -9
- package/src/cli/codex-shim-autorestore.ts +2 -0
- package/src/cli/codex-shim-readiness.ts +8 -1
- package/src/cli/config-command.ts +4 -1
- package/src/cli/doctor.ts +10 -0
- package/src/cli/help.ts +15 -0
- package/src/cli/index.ts +27 -11
- package/src/cli/lab.ts +367 -0
- package/src/cli/provider.ts +9 -1
- package/src/clients/config-export.ts +100 -3
- package/src/codex/app-server-processes.ts +11 -8
- package/src/codex/auth-api.ts +92 -28
- package/src/codex/auth-collision.ts +5 -3
- package/src/codex/catalog/metadata.ts +7 -3
- package/src/codex/catalog/provider-fetch.ts +191 -47
- package/src/codex/catalog.ts +2 -2
- package/src/codex/history-job.ts +83 -18
- package/src/codex/history-migration-guardian.ts +9 -16
- package/src/codex/history-provider.ts +178 -1
- package/src/codex/history-transition.ts +5 -5
- package/src/codex/history-worker.ts +22 -2
- package/src/codex/native-profile-store.ts +1 -1
- package/src/codex/plan.ts +15 -0
- package/src/codex/quota.ts +6 -6
- package/src/codex/routing.ts +3 -3
- package/src/codex/subagent-model-fallback.ts +246 -22
- package/src/codex/user-identity.ts +63 -12
- package/src/config.ts +265 -32
- package/src/images/loop.ts +3 -1
- package/src/images/plan.ts +23 -13
- package/src/integrations/omp-yaml-source.ts +225 -0
- package/src/integrations/ownership.ts +5 -5
- package/src/integrations/state.ts +45 -6
- package/src/integrations/writer.ts +38 -3
- package/src/lab/artifacts/sanitize.ts +586 -0
- package/src/lab/artifacts/secure-fs.ts +475 -0
- package/src/lab/artifacts/store.ts +310 -0
- package/src/lab/conformance/assertion.ts +325 -0
- package/src/lab/conformance/digest.ts +22 -0
- package/src/lab/conformance/executor.ts +741 -0
- package/src/lab/conformance/fixture-provider.ts +27 -0
- package/src/lab/conformance/fixtures/live-v1-cases.json +175 -0
- package/src/lab/conformance/fixtures/protocol-v1-cases.json +461 -0
- package/src/lab/conformance/harness-budget.ts +47 -0
- package/src/lab/conformance/index.ts +5 -0
- package/src/lab/conformance/jcs.ts +24 -0
- package/src/lab/conformance/json-pointer.ts +39 -0
- package/src/lab/conformance/manifest.ts +180 -0
- package/src/lab/conformance/mcp-stub.ts +179 -0
- package/src/lab/conformance/negative-controls.ts +160 -0
- package/src/lab/conformance/observation.ts +355 -0
- package/src/lab/conformance/runner.ts +57 -0
- package/src/lab/conformance/sse-normalize.ts +59 -0
- package/src/lab/conformance/suite-manifest.ts +78 -0
- package/src/lab/conformance/types.ts +191 -0
- package/src/lab/constants.ts +126 -0
- package/src/lab/digest.ts +64 -0
- package/src/lab/events/errors.ts +9 -0
- package/src/lab/events/limits.ts +117 -0
- package/src/lab/events/types.ts +228 -0
- package/src/lab/events/validate.ts +780 -0
- package/src/lab/index.ts +36 -0
- package/src/lab/ledger/artifact-refs.ts +127 -0
- package/src/lab/ledger/invalidation.ts +136 -0
- package/src/lab/ledger/purge.ts +241 -0
- package/src/lab/ledger/store.ts +263 -0
- package/src/lab/live/credential-lease.ts +53 -0
- package/src/lab/live/destination.ts +155 -0
- package/src/lab/live/executor.ts +311 -0
- package/src/lab/live/inert-tools.ts +56 -0
- package/src/lab/live/manifest.ts +85 -0
- package/src/lab/live/mcp-loopback.ts +57 -0
- package/src/lab/live/runner.ts +19 -0
- package/src/lab/live/sandbox.ts +61 -0
- package/src/lab/live/suite-manifest.ts +41 -0
- package/src/lab/live/transport.ts +116 -0
- package/src/lab/live/types.ts +197 -0
- package/src/lab/observe/from-conformance.ts +344 -0
- package/src/lab/observe/from-live.ts +103 -0
- package/src/lab/paths.ts +65 -0
- package/src/lab/projection/rebuild.ts +477 -0
- package/src/lab/projection/schema.ts +122 -0
- package/src/lab/projection/verdicts.ts +438 -0
- package/src/lab/projection/verification.ts +332 -0
- package/src/lab/query/catalog.ts +72 -0
- package/src/lab/query/connection.ts +107 -0
- package/src/lab/query/constants.ts +4 -0
- package/src/lab/query/cursor.ts +132 -0
- package/src/lab/query/dto-map.ts +277 -0
- package/src/lab/query/errors.ts +22 -0
- package/src/lab/query/index.ts +34 -0
- package/src/lab/query/queries.ts +444 -0
- package/src/lab/query/types.ts +266 -0
- package/src/lab/subject/behavior-fingerprint.ts +77 -0
- package/src/lab/subject/installation-salt.ts +81 -0
- package/src/lab/subject/route-subject.ts +73 -0
- package/src/lib/bounded-body.ts +104 -0
- package/src/lib/lab-live-execution-authority.ts +13 -0
- package/src/lib/lab-live-host.ts +30 -0
- package/src/lib/lab-live-pinned-sender.ts +45 -0
- package/src/lib/pinned-http.ts +36 -7
- package/src/oauth/index.ts +20 -1
- package/src/oauth/local-token-detect.ts +11 -2
- package/src/oauth/login-cli.ts +38 -4
- package/src/providers/alibaba-region-migration.ts +1 -1
- package/src/providers/codex-capacity.ts +7 -4
- package/src/providers/command-code-efforts.ts +5 -2
- package/src/providers/derive.ts +105 -0
- package/src/providers/label.ts +1 -1
- package/src/providers/openai-tiers.ts +59 -3
- package/src/providers/opencode-zen-rate-limit.ts +102 -0
- package/src/providers/quota.ts +67 -21
- package/src/providers/registry.ts +118 -5
- package/src/router.ts +15 -1
- package/src/routing/analytics.ts +8 -7
- package/src/routing/evaluator.ts +51 -5
- package/src/routing/profile.ts +10 -1
- package/src/routing/trace.ts +42 -6
- package/src/server/auth-cors.ts +15 -0
- package/src/server/background-lifecycle.ts +169 -0
- package/src/server/chat-completions.ts +18 -3
- package/src/server/claude-messages.ts +1 -0
- package/src/server/images.ts +78 -11
- package/src/server/index.ts +72 -18
- package/src/server/lifecycle.ts +6 -0
- package/src/server/live.ts +5 -1
- package/src/server/management/agent-settings-routes.ts +41 -24
- package/src/server/management/body.ts +6 -0
- package/src/server/management/config-routes.ts +51 -8
- package/src/server/management/lab-routes.ts +388 -0
- package/src/server/management/logs-usage-routes.ts +19 -1
- package/src/server/management/model-rows.ts +25 -11
- package/src/server/management/native-integration-routes.ts +3 -3
- package/src/server/management/provider-routes.ts +5 -0
- package/src/server/management/shared.ts +8 -1
- package/src/server/management/usage-summary-cache.ts +2 -0
- package/src/server/management/vision-sidecar-options.ts +125 -0
- package/src/server/management-api.ts +2 -0
- package/src/server/request-decompress.ts +106 -5
- package/src/server/responses/collaboration.ts +4 -1
- package/src/server/responses/core.ts +117 -31
- package/src/server/responses-json-events.ts +50 -12
- package/src/server/search.ts +23 -7
- package/src/server/ws-bridge.ts +3 -1
- package/src/service.ts +40 -20
- package/src/types.ts +74 -0
- package/src/update/job.ts +10 -2
- package/src/usage/cost.ts +0 -0
- package/src/usage/expected-prices.ts +9 -0
- package/src/usage/log.ts +9 -9
- package/src/usage/user-cost-overlay-reconciler.ts +313 -0
- package/src/usage/user-cost-overlays.ts +314 -0
- package/src/vision/describe.ts +2 -2
- package/src/vision/eligibility.ts +229 -0
- package/src/vision/index.ts +20 -2
- package/src/web-search/executor.ts +2 -2
- package/src/web-search/index.ts +4 -2
- package/src/web-search/loop.ts +3 -1
- package/src/web-search/parse.ts +72 -3
- package/gui/dist/assets/index-BA1dgo4q.css +0 -1
- package/gui/dist/assets/index-DDZpgzKk.js +0 -70
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { sanitizeDiagnostic } from "../artifacts/sanitize";
|
|
2
|
+
import type {
|
|
3
|
+
ClaimSnapshotEvent,
|
|
4
|
+
InvalidationEvent,
|
|
5
|
+
LabEvent,
|
|
6
|
+
ObservationEvent,
|
|
7
|
+
PurgeTombstoneEvent,
|
|
8
|
+
RouteDependencyV1,
|
|
9
|
+
RouteSubjectV1,
|
|
10
|
+
TaskSubjectV1,
|
|
11
|
+
} from "../events/types";
|
|
12
|
+
import { validateLabEvent } from "../events/validate";
|
|
13
|
+
import type {
|
|
14
|
+
ArtifactMetadataDto,
|
|
15
|
+
ClaimSnapshotEventDto,
|
|
16
|
+
EventListItemDto,
|
|
17
|
+
InvalidationEventDto,
|
|
18
|
+
LabEventDto,
|
|
19
|
+
ObservationDto,
|
|
20
|
+
ObservationEventDto,
|
|
21
|
+
ProtocolSubjectDto,
|
|
22
|
+
PurgeTombstoneEventDto,
|
|
23
|
+
RouteDependencyDto,
|
|
24
|
+
RouteSubjectDto,
|
|
25
|
+
SubjectDto,
|
|
26
|
+
SubjectListItemDto,
|
|
27
|
+
TaskSubjectDto,
|
|
28
|
+
VerdictDto,
|
|
29
|
+
} from "./types";
|
|
30
|
+
|
|
31
|
+
const SECRETISH = /sk-[a-z0-9]{10,}|Bearer\s+[A-Za-z0-9._\-]+|ghp_[A-Za-z0-9]{20,}|xox[baprs]-[A-Za-z0-9-]{10,}/gi;
|
|
32
|
+
const URL_USERINFO = /https?:\/\/[^/\s:@]+:[^/\s@]+@/gi;
|
|
33
|
+
const WINDOWS_PATH = /[A-Za-z]:\\(?:[^\\:*?"<>|\r\n]+\\)*[^\\:*?"<>|\r\n]*/g;
|
|
34
|
+
const POSIX_HOME = /(?:^|[^A-Za-z0-9_])(?:\/home\/|\/Users\/|~\/)[^\s"'<>|]+/g;
|
|
35
|
+
|
|
36
|
+
export function sanitizePublicText(value: string | null | undefined, max = 256): string | null {
|
|
37
|
+
if (value === null || value === undefined) return null;
|
|
38
|
+
let out = sanitizeDiagnostic(value);
|
|
39
|
+
out = out.replace(SECRETISH, "[redacted]");
|
|
40
|
+
out = out.replace(URL_USERINFO, "[redacted-url]@");
|
|
41
|
+
out = out.replace(WINDOWS_PATH, "[redacted-path]");
|
|
42
|
+
out = out.replace(POSIX_HOME, "[redacted-path]");
|
|
43
|
+
if (out.length > max) out = out.slice(0, max);
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function parseJsonArray(raw: string): string[] {
|
|
48
|
+
try {
|
|
49
|
+
const parsed = JSON.parse(raw);
|
|
50
|
+
return Array.isArray(parsed) ? parsed.filter((v): v is string => typeof v === "string") : [];
|
|
51
|
+
} catch {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function mapVerdictRow(row: Record<string, unknown>): VerdictDto {
|
|
57
|
+
return {
|
|
58
|
+
projectionKey: String(row.projection_key),
|
|
59
|
+
subjectId: String(row.subject_id),
|
|
60
|
+
evidenceLayer: row.evidence_layer as VerdictDto["evidenceLayer"],
|
|
61
|
+
suiteId: String(row.suite_id),
|
|
62
|
+
suiteVersion: String(row.suite_version),
|
|
63
|
+
suiteManifestDigest: String(row.suite_manifest_digest),
|
|
64
|
+
projectionSpecVersion: String(row.projection_spec_version),
|
|
65
|
+
verdict: row.verdict as VerdictDto["verdict"],
|
|
66
|
+
asOf: Number(row.as_of),
|
|
67
|
+
scenarioManifestDigests: parseJsonArray(String(row.scenario_manifest_digests_json)),
|
|
68
|
+
claimSourceDigest: row.claim_source_digest ? String(row.claim_source_digest) : null,
|
|
69
|
+
contributingEventIds: parseJsonArray(String(row.contributing_event_ids_json)),
|
|
70
|
+
contradictingEventIds: parseJsonArray(String(row.contradicting_event_ids_json)),
|
|
71
|
+
notes: parseJsonArray(String(row.notes_json)).map((n) => sanitizePublicText(n, 512) ?? ""),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function mapRouteDependency(dep: RouteDependencyV1): RouteDependencyDto {
|
|
76
|
+
return {
|
|
77
|
+
role: dep.role,
|
|
78
|
+
providerId: dep.providerId,
|
|
79
|
+
providerInstanceFingerprint: dep.providerInstanceFingerprint,
|
|
80
|
+
clientModelId: dep.clientModelId,
|
|
81
|
+
upstreamModelId: dep.upstreamModelId,
|
|
82
|
+
effectiveAdapter: dep.effectiveAdapter,
|
|
83
|
+
upstreamProtocol: dep.upstreamProtocol,
|
|
84
|
+
endpointFingerprint: dep.endpointFingerprint,
|
|
85
|
+
behaviorFingerprint: dep.behaviorFingerprint,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function mapRouteSubject(subject: RouteSubjectV1): RouteSubjectDto {
|
|
90
|
+
return {
|
|
91
|
+
subjectKind: "route",
|
|
92
|
+
subjectSchemaVersion: 1,
|
|
93
|
+
providerId: subject.providerId,
|
|
94
|
+
providerInstanceFingerprint: subject.providerInstanceFingerprint,
|
|
95
|
+
clientModelId: subject.clientModelId,
|
|
96
|
+
upstreamModelId: subject.upstreamModelId,
|
|
97
|
+
effectiveAdapter: subject.effectiveAdapter,
|
|
98
|
+
inboundProtocol: subject.inboundProtocol,
|
|
99
|
+
upstreamProtocol: subject.upstreamProtocol,
|
|
100
|
+
surface: subject.surface,
|
|
101
|
+
opencodexCompatibilityVersion: subject.opencodexCompatibilityVersion,
|
|
102
|
+
behaviorFingerprint: subject.behaviorFingerprint,
|
|
103
|
+
endpointFingerprint: subject.endpointFingerprint,
|
|
104
|
+
dependencies: subject.dependencies.map(mapRouteDependency),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function mapSubjectJson(subjectJson: string): SubjectDto | null {
|
|
109
|
+
try {
|
|
110
|
+
const parsed = JSON.parse(subjectJson) as Record<string, unknown>;
|
|
111
|
+
const kind = parsed.subjectKind;
|
|
112
|
+
if (kind === "protocol") {
|
|
113
|
+
return {
|
|
114
|
+
subjectKind: "protocol",
|
|
115
|
+
subjectSchemaVersion: 1,
|
|
116
|
+
opencodexCompatibilityVersion: String(parsed.opencodexCompatibilityVersion),
|
|
117
|
+
effectiveAdapter: String(parsed.effectiveAdapter),
|
|
118
|
+
inboundProtocol: String(parsed.inboundProtocol),
|
|
119
|
+
upstreamProtocol: String(parsed.upstreamProtocol),
|
|
120
|
+
surface: String(parsed.surface),
|
|
121
|
+
behaviorFingerprint: String(parsed.behaviorFingerprint),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
if (kind === "route") {
|
|
125
|
+
return mapRouteSubject(parsed as unknown as RouteSubjectV1);
|
|
126
|
+
}
|
|
127
|
+
if (kind === "task") {
|
|
128
|
+
const task = parsed as unknown as TaskSubjectV1;
|
|
129
|
+
return {
|
|
130
|
+
subjectKind: "task",
|
|
131
|
+
subjectSchemaVersion: 1,
|
|
132
|
+
routeSubject: mapRouteSubject(task.routeSubject),
|
|
133
|
+
taskClassId: task.taskClassId,
|
|
134
|
+
taskClassVersion: task.taskClassVersion,
|
|
135
|
+
taskFixtureDigest: task.taskFixtureDigest,
|
|
136
|
+
verifierManifestDigest: task.verifierManifestDigest,
|
|
137
|
+
fabricCompatibilityVersion: task.fabricCompatibilityVersion,
|
|
138
|
+
sandboxProfileDigest: task.sandboxProfileDigest,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
return null;
|
|
142
|
+
} catch {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function mapSubjectListRow(row: Record<string, unknown>): SubjectListItemDto {
|
|
148
|
+
return {
|
|
149
|
+
subjectId: String(row.subject_id),
|
|
150
|
+
subjectKind: String(row.subject_kind),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function mapObservationRow(
|
|
155
|
+
row: Record<string, unknown>,
|
|
156
|
+
excluded: boolean,
|
|
157
|
+
exclusionReason: string | null,
|
|
158
|
+
): ObservationDto {
|
|
159
|
+
return {
|
|
160
|
+
eventId: String(row.event_id),
|
|
161
|
+
subjectId: String(row.subject_id),
|
|
162
|
+
evidenceLayer: row.evidence_layer as ObservationDto["evidenceLayer"],
|
|
163
|
+
suiteId: String(row.suite_id),
|
|
164
|
+
suiteVersion: String(row.suite_version),
|
|
165
|
+
suiteManifestDigest: String(row.suite_manifest_digest),
|
|
166
|
+
scenarioId: String(row.scenario_id),
|
|
167
|
+
scenarioVersion: String(row.scenario_version),
|
|
168
|
+
scenarioManifestDigest: String(row.scenario_manifest_digest),
|
|
169
|
+
outcome: row.outcome as ObservationDto["outcome"],
|
|
170
|
+
completedAt: Number(row.completed_at),
|
|
171
|
+
executionMode: row.execution_mode as ObservationDto["executionMode"],
|
|
172
|
+
excluded,
|
|
173
|
+
exclusionReason: sanitizePublicText(exclusionReason),
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export function mapEventListRow(row: Record<string, unknown>): EventListItemDto {
|
|
178
|
+
return {
|
|
179
|
+
eventId: String(row.event_id),
|
|
180
|
+
eventKind: row.event_kind as EventListItemDto["eventKind"],
|
|
181
|
+
recordedAt: Number(row.recorded_at),
|
|
182
|
+
excluded: Number(row.excluded) === 1,
|
|
183
|
+
exclusionReason: sanitizePublicText(row.exclusion_reason ? String(row.exclusion_reason) : null),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function mapArtifactRow(row: Record<string, unknown>): ArtifactMetadataDto {
|
|
188
|
+
return {
|
|
189
|
+
digest: String(row.digest),
|
|
190
|
+
artifactClass: row.artifact_class ? row.artifact_class as ArtifactMetadataDto["artifactClass"] : null,
|
|
191
|
+
mediaType: row.media_type ? String(row.media_type) : null,
|
|
192
|
+
byteCount: row.byte_count === null || row.byte_count === undefined ? null : Number(row.byte_count),
|
|
193
|
+
status: row.status as ArtifactMetadataDto["status"],
|
|
194
|
+
lastError: sanitizePublicText(row.last_error ? String(row.last_error) : null),
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function exclusionFromRow(row: Record<string, unknown>): { excluded: boolean; exclusionReason: string | null } {
|
|
199
|
+
return {
|
|
200
|
+
excluded: Number(row.excluded) === 1,
|
|
201
|
+
exclusionReason: sanitizePublicText(row.exclusion_reason ? String(row.exclusion_reason) : null),
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export function mapValidatedEventToDto(event: LabEvent, excluded: boolean, exclusionReason: string | null): LabEventDto {
|
|
206
|
+
const base = {
|
|
207
|
+
eventId: event.eventId,
|
|
208
|
+
recordedAt: event.recordedAt,
|
|
209
|
+
producer: event.producer,
|
|
210
|
+
producerVersion: event.producerVersion,
|
|
211
|
+
excluded,
|
|
212
|
+
exclusionReason: sanitizePublicText(exclusionReason),
|
|
213
|
+
};
|
|
214
|
+
if (event.eventKind === "observation") {
|
|
215
|
+
const obs = event as ObservationEvent;
|
|
216
|
+
return {
|
|
217
|
+
eventKind: "observation",
|
|
218
|
+
...base,
|
|
219
|
+
evidenceLayer: obs.evidenceLayer,
|
|
220
|
+
scenarioId: obs.scenarioId,
|
|
221
|
+
scenarioVersion: obs.scenarioVersion,
|
|
222
|
+
scenarioManifestDigest: obs.scenarioManifestDigest,
|
|
223
|
+
suiteId: obs.suiteId,
|
|
224
|
+
suiteVersion: obs.suiteVersion,
|
|
225
|
+
suiteManifestDigest: obs.suiteManifestDigest,
|
|
226
|
+
subjectId: obs.subjectId,
|
|
227
|
+
startedAt: obs.startedAt,
|
|
228
|
+
completedAt: obs.completedAt,
|
|
229
|
+
executionMode: obs.executionMode,
|
|
230
|
+
attempt: obs.attempt,
|
|
231
|
+
outcome: obs.outcome,
|
|
232
|
+
} satisfies ObservationEventDto;
|
|
233
|
+
}
|
|
234
|
+
if (event.eventKind === "claim_snapshot") {
|
|
235
|
+
const claim = event as ClaimSnapshotEvent;
|
|
236
|
+
return {
|
|
237
|
+
eventKind: "claim_snapshot",
|
|
238
|
+
...base,
|
|
239
|
+
subjectId: claim.subjectId,
|
|
240
|
+
capability: claim.capability,
|
|
241
|
+
polarity: claim.polarity,
|
|
242
|
+
sourceManifestDigest: claim.sourceManifestDigest,
|
|
243
|
+
effectiveAt: claim.effectiveAt,
|
|
244
|
+
} satisfies ClaimSnapshotEventDto;
|
|
245
|
+
}
|
|
246
|
+
if (event.eventKind === "invalidation") {
|
|
247
|
+
const inv = event as InvalidationEvent;
|
|
248
|
+
return {
|
|
249
|
+
eventKind: "invalidation",
|
|
250
|
+
...base,
|
|
251
|
+
reason: inv.reason,
|
|
252
|
+
targetEventIds: [...inv.targetEventIds],
|
|
253
|
+
} satisfies InvalidationEventDto;
|
|
254
|
+
}
|
|
255
|
+
const purge = event as PurgeTombstoneEvent;
|
|
256
|
+
return {
|
|
257
|
+
eventKind: "purge_tombstone",
|
|
258
|
+
...base,
|
|
259
|
+
targetEventIds: [...purge.targetEventIds],
|
|
260
|
+
targetArtifactDigests: [...purge.targetArtifactDigests],
|
|
261
|
+
purgeActions: [...purge.purgeActions],
|
|
262
|
+
} satisfies PurgeTombstoneEventDto;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export function parseEventPayloadToDto(
|
|
266
|
+
payloadJson: string,
|
|
267
|
+
excluded: boolean,
|
|
268
|
+
exclusionReason: string | null,
|
|
269
|
+
): LabEventDto | null {
|
|
270
|
+
try {
|
|
271
|
+
const parsed = JSON.parse(payloadJson);
|
|
272
|
+
const event = validateLabEvent(parsed);
|
|
273
|
+
return mapValidatedEventToDto(event, excluded, exclusionReason);
|
|
274
|
+
} catch {
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** CL-04 read-surface errors — safe codes only, no SQLite/path leakage. */
|
|
2
|
+
|
|
3
|
+
export class LabProjectionUnavailableError extends Error {
|
|
4
|
+
readonly code = "lab_projection_unavailable" as const;
|
|
5
|
+
constructor() {
|
|
6
|
+
super("lab projection is not available");
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class LabProjectionIncompatibleError extends Error {
|
|
11
|
+
readonly code = "lab_projection_incompatible" as const;
|
|
12
|
+
constructor() {
|
|
13
|
+
super("lab projection schema or spec version is incompatible");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class InvalidCursorError extends Error {
|
|
18
|
+
readonly code = "invalid_cursor" as const;
|
|
19
|
+
constructor() {
|
|
20
|
+
super("invalid cursor");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export {
|
|
2
|
+
LAB_QUERY_DEFAULT_PAGE_SIZE,
|
|
3
|
+
LAB_QUERY_MAX_PAGE_SIZE,
|
|
4
|
+
} from "./constants";
|
|
5
|
+
export {
|
|
6
|
+
LabProjectionUnavailableError,
|
|
7
|
+
LabProjectionIncompatibleError,
|
|
8
|
+
InvalidCursorError,
|
|
9
|
+
} from "./errors";
|
|
10
|
+
export {
|
|
11
|
+
openLabReadConnection,
|
|
12
|
+
closeLabReadConnection,
|
|
13
|
+
resolveLabSqlitePath,
|
|
14
|
+
type LabReadConnection,
|
|
15
|
+
} from "./connection";
|
|
16
|
+
export {
|
|
17
|
+
encodeLabCursor,
|
|
18
|
+
decodeLabCursor,
|
|
19
|
+
filterKeyFor,
|
|
20
|
+
} from "./cursor";
|
|
21
|
+
export { queryLabCatalog } from "./catalog";
|
|
22
|
+
export {
|
|
23
|
+
queryLabStatus,
|
|
24
|
+
queryLabVerdicts,
|
|
25
|
+
queryLabSubjects,
|
|
26
|
+
queryLabSubjectById,
|
|
27
|
+
queryLabObservations,
|
|
28
|
+
queryLabEvents,
|
|
29
|
+
queryLabEventById,
|
|
30
|
+
queryLabArtifacts,
|
|
31
|
+
queryLabArtifactByDigest,
|
|
32
|
+
queryLabCatalogEntries,
|
|
33
|
+
} from "./queries";
|
|
34
|
+
export { sanitizePublicText } from "./dto-map";
|