@humain/humain-code-contracts 0.3.2
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/CHANGELOG.md +51 -0
- package/README.md +92 -0
- package/dist/index.d.ts +224 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +218 -0
- package/dist/index.js.map +1 -0
- package/dist/orchestration.d.ts +327 -0
- package/dist/orchestration.d.ts.map +1 -0
- package/dist/orchestration.js +307 -0
- package/dist/orchestration.js.map +1 -0
- package/dist/rpc.d.ts +63 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +147 -0
- package/dist/rpc.js.map +1 -0
- package/dist/subagent-progress.d.ts +106 -0
- package/dist/subagent-progress.d.ts.map +1 -0
- package/dist/subagent-progress.js +440 -0
- package/dist/subagent-progress.js.map +1 -0
- package/dist/testing.d.ts +390 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +431 -0
- package/dist/testing.js.map +1 -0
- package/dist/trace-api.d.ts +293 -0
- package/dist/trace-api.d.ts.map +1 -0
- package/dist/trace-api.js +202 -0
- package/dist/trace-api.js.map +1 -0
- package/dist/trace-artifact.d.ts +94 -0
- package/dist/trace-artifact.d.ts.map +1 -0
- package/dist/trace-artifact.js +168 -0
- package/dist/trace-artifact.js.map +1 -0
- package/dist/trace-canonical.d.ts +23 -0
- package/dist/trace-canonical.d.ts.map +1 -0
- package/dist/trace-canonical.js +240 -0
- package/dist/trace-canonical.js.map +1 -0
- package/dist/trace-export.d.ts +94 -0
- package/dist/trace-export.d.ts.map +1 -0
- package/dist/trace-export.js +374 -0
- package/dist/trace-export.js.map +1 -0
- package/dist/trace-http.d.ts +1294 -0
- package/dist/trace-http.d.ts.map +1 -0
- package/dist/trace-http.js +1481 -0
- package/dist/trace-http.js.map +1 -0
- package/dist/trace-payload.d.ts +425 -0
- package/dist/trace-payload.d.ts.map +1 -0
- package/dist/trace-payload.js +1519 -0
- package/dist/trace-payload.js.map +1 -0
- package/dist/trace.d.ts +257 -0
- package/dist/trace.d.ts.map +1 -0
- package/dist/trace.js +1014 -0
- package/dist/trace.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,1294 @@
|
|
|
1
|
+
import { type Static, type TSchema, Type } from "typebox";
|
|
2
|
+
import { type DhAckV1, type DhCoverage, type DhEventKind, type DhEventV1, type DhExternalId, type DhOutcome, type DhRejectionCode } from "./trace.ts";
|
|
3
|
+
import { type DhExportHashOptions } from "./trace-export.ts";
|
|
4
|
+
/** Schema ids introduced by this freeze. Existing dh.event/1, dh.artifact/1 and dh.ack/1 are unchanged. */
|
|
5
|
+
export declare const DH_HTTP_SCHEMA_IDS: Readonly<{
|
|
6
|
+
readonly admissionBinding: "dh.admission-binding/1";
|
|
7
|
+
readonly workloadBinding: "dh.workload-binding/1";
|
|
8
|
+
readonly originDelegation: "dh.origin-delegation/1";
|
|
9
|
+
readonly artifactReceipt: "dh.artifact-receipt/1";
|
|
10
|
+
readonly controlReceipt: "dh.control-receipt/1";
|
|
11
|
+
readonly controlRequest: "dh.control-request/2";
|
|
12
|
+
readonly controlStatus: "dh.control-status/2";
|
|
13
|
+
readonly controlTarget: "dh.control-target/1";
|
|
14
|
+
readonly controlDelivery: "dh.control-delivery/1";
|
|
15
|
+
readonly controlHandshake: "dh.control-handshake/1";
|
|
16
|
+
readonly controllerCredential: "dh.controller-credential/1";
|
|
17
|
+
readonly cursorBinding: "dh.cursor-binding/2";
|
|
18
|
+
readonly snapshotCutoff: "dh.snapshot-cutoff/1";
|
|
19
|
+
readonly generationPage: "dh.generation-page/2";
|
|
20
|
+
readonly agentPage: "dh.agent-page/2";
|
|
21
|
+
readonly eventPage: "dh.event-page/2";
|
|
22
|
+
readonly exportManifestHeader: "dh.export-manifest-header/2";
|
|
23
|
+
readonly exportManifestPage: "dh.export-manifest-page/2";
|
|
24
|
+
readonly producerEnrollment: "dh.producer-enrollment/2";
|
|
25
|
+
readonly producerEnrollmentRequest: "dh.producer-enrollment-request/2";
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Batch version decision record. dh.batch/1-proposal stays the ONLY schema managed ingress accepts.
|
|
29
|
+
* C0 resolves the synthetic-local lane to the proposal literal only. Production promotion remains
|
|
30
|
+
* a separate coordinated decision; it is never accepted alongside the proposal.
|
|
31
|
+
*/
|
|
32
|
+
export declare const DH_BATCH_VERSION_DECISION: Readonly<{
|
|
33
|
+
readonly accepted: "dh.batch/1-proposal";
|
|
34
|
+
readonly promotionCandidate: "dh.batch/1";
|
|
35
|
+
readonly status: "resolved-synthetic-local";
|
|
36
|
+
readonly dualVersionIngress: false;
|
|
37
|
+
}>;
|
|
38
|
+
/** Validation ceiling only; the real access-token TTL is an open policy input. Matches the current client ceiling. */
|
|
39
|
+
export declare const DH_TOKEN_MAX_EXPIRES_IN_SECONDS = 600;
|
|
40
|
+
export declare const DH_EXPORT_MANIFEST_MAX_SHARDS = 1024;
|
|
41
|
+
/** Equal to DH_MAX_ACK_IDS (asserted in tests): one shard page is one bounded ACK-sized ID list. */
|
|
42
|
+
export declare const DH_EXPORT_MANIFEST_SHARD_MAX_IDS = 1000;
|
|
43
|
+
export declare const DH_GRANT_MAX_PROJECTS = 16;
|
|
44
|
+
/** Provisional bound for continuation text; policy may lower it. */
|
|
45
|
+
export declare const DH_CONTROL_MESSAGE_MAX_CHARS = 16384;
|
|
46
|
+
export declare const DH_GRANT_PERMISSIONS: readonly ["review-metadata", "review-content", "export"];
|
|
47
|
+
export type DhGrantPermission = (typeof DH_GRANT_PERMISSIONS)[number];
|
|
48
|
+
/** Strict parser: plain-JSON gate, schema check, clone, re-check, calendar-valid instants, DTO semantics, freeze. */
|
|
49
|
+
declare function dtoParser<T extends TSchema>(label: string, schema: () => T, semantic?: (value: Static<T>) => void): (value: unknown) => Static<T>;
|
|
50
|
+
/**
|
|
51
|
+
* The strict DTO parser (plain-JSON wire gate, schema check, clone, re-check, instants, semantics, freeze)
|
|
52
|
+
* for sibling modules such as trace-payload.ts, so the gate is never re-implemented.
|
|
53
|
+
*/
|
|
54
|
+
export { dtoParser as dhStrictDtoParser };
|
|
55
|
+
export declare const DH_ROUTE_AUDIENCES: readonly ["browser-review", "producer", "workload", "control", "records-policy"];
|
|
56
|
+
export type DhRouteAudience = (typeof DH_ROUTE_AUDIENCES)[number];
|
|
57
|
+
export type DhRouteMethod = "GET" | "POST" | "PUT" | "DELETE";
|
|
58
|
+
export interface DhRoute {
|
|
59
|
+
readonly method: DhRouteMethod;
|
|
60
|
+
/** `{name}` placeholders are the only variable parts; see DH_PATH_PARAM_PATTERNS. */
|
|
61
|
+
readonly path: string;
|
|
62
|
+
readonly audience: DhRouteAudience;
|
|
63
|
+
readonly requestContentType: string | null;
|
|
64
|
+
readonly requestHeaders?: readonly string[];
|
|
65
|
+
readonly responseContentType: string | null;
|
|
66
|
+
readonly responseSchemaId?: string;
|
|
67
|
+
readonly successStatus: readonly number[];
|
|
68
|
+
}
|
|
69
|
+
declare const ROUTE_DEFINITIONS: {
|
|
70
|
+
readonly authorizeConsent: DhRoute;
|
|
71
|
+
readonly authorizeSubmit: DhRoute;
|
|
72
|
+
readonly clientToken: DhRoute;
|
|
73
|
+
readonly clientRevoke: DhRoute;
|
|
74
|
+
readonly producerEnroll: DhRoute;
|
|
75
|
+
readonly producerToken: DhRoute;
|
|
76
|
+
readonly producerRevoke: DhRoute;
|
|
77
|
+
readonly ingestRecords: DhRoute;
|
|
78
|
+
readonly ingestArtifactContent: DhRoute;
|
|
79
|
+
readonly reviewGenerations: DhRoute;
|
|
80
|
+
readonly reviewAgents: DhRoute;
|
|
81
|
+
readonly reviewEvents: DhRoute;
|
|
82
|
+
readonly reviewArtifact: DhRoute;
|
|
83
|
+
readonly reviewArtifactContent: DhRoute;
|
|
84
|
+
readonly usage: DhRoute;
|
|
85
|
+
readonly search: DhRoute;
|
|
86
|
+
readonly exportCreate: DhRoute;
|
|
87
|
+
readonly exportStatus: DhRoute;
|
|
88
|
+
readonly exportManifest: DhRoute;
|
|
89
|
+
readonly exportDownload: DhRoute;
|
|
90
|
+
readonly exportContent: DhRoute;
|
|
91
|
+
readonly controlTarget: DhRoute;
|
|
92
|
+
readonly controlCancel: DhRoute;
|
|
93
|
+
readonly controlRetry: DhRoute;
|
|
94
|
+
readonly controlContinue: DhRoute;
|
|
95
|
+
readonly controlRequest: DhRoute;
|
|
96
|
+
readonly generationDelete: DhRoute;
|
|
97
|
+
readonly legalHoldCreate: DhRoute;
|
|
98
|
+
readonly legalHoldRelease: DhRoute;
|
|
99
|
+
};
|
|
100
|
+
export type DhRouteId = keyof typeof ROUTE_DEFINITIONS;
|
|
101
|
+
export declare const DH_ROUTES: Readonly<typeof ROUTE_DEFINITIONS>;
|
|
102
|
+
/** ID segment validators. Only unreserved characters: no separators, dots-only segments, encodings or wildcards. */
|
|
103
|
+
export declare const DH_PATH_PARAM_PATTERNS: Readonly<Record<string, RegExp>>;
|
|
104
|
+
/** Builds a path from the frozen template. Params must be exactly the template's placeholders, each validated then percent-encoded. */
|
|
105
|
+
export declare function buildDhRoutePath(id: DhRouteId, params: Readonly<Record<string, string>>): string;
|
|
106
|
+
/**
|
|
107
|
+
* Grant permissions a browser-review route needs. Export reads (status, manifest, download, content)
|
|
108
|
+
* are authorized from the SERVER-STORED job, passed as `job` (its `contentIncluded`, e.g. from
|
|
109
|
+
* DhExportJobStatus): export + review-metadata always, plus review-content when the stored job
|
|
110
|
+
* includes content. A caller-supplied `includeContent` is ignored for them and a missing or malformed
|
|
111
|
+
* `job` throws. The server must evaluate this on every read, so a grant that lost review-content after
|
|
112
|
+
* creation can no longer read a content job. Only `exportCreate` (which creates the job) and the
|
|
113
|
+
* event/search views use `includeContent`. Control/producer/records-policy routes use no read-grant permission.
|
|
114
|
+
* `options` (and the `job` inside it) pass the plain-JSON wire gate before any member is read, so an accessor or
|
|
115
|
+
* non-plain object is rejected without executing user code.
|
|
116
|
+
*/
|
|
117
|
+
export declare function requiredDhPermissions(id: DhRouteId, options: {
|
|
118
|
+
includeContent?: boolean;
|
|
119
|
+
job?: Readonly<Pick<DhExportJobStatus, "contentIncluded">>;
|
|
120
|
+
}): DhGrantPermission[];
|
|
121
|
+
/** Credential classes are not interchangeable: a credential is valid only on routes of its own audience class. */
|
|
122
|
+
export declare function assertDhCredentialForRoute(id: DhRouteId, credentialClass: string): void;
|
|
123
|
+
export declare const parseDhAdmissionBinding: (value: unknown) => {
|
|
124
|
+
readonly schema: "dh.admission-binding/1";
|
|
125
|
+
readonly bindingId: string;
|
|
126
|
+
readonly generationRootBindingId: string;
|
|
127
|
+
readonly mappingRevision: string;
|
|
128
|
+
readonly tenantId: string;
|
|
129
|
+
readonly environmentId: string;
|
|
130
|
+
readonly projectId: string;
|
|
131
|
+
readonly nativeProjectId: string;
|
|
132
|
+
readonly nativeRunId: string;
|
|
133
|
+
readonly nativeSegmentId: string;
|
|
134
|
+
readonly generationId: string;
|
|
135
|
+
readonly rootAgentId: string;
|
|
136
|
+
readonly initiatingActorId: string;
|
|
137
|
+
readonly bindingEpoch: string;
|
|
138
|
+
readonly policyRevision: string;
|
|
139
|
+
readonly admittedAt: string;
|
|
140
|
+
readonly environment: "local";
|
|
141
|
+
readonly syntheticOnly: true;
|
|
142
|
+
};
|
|
143
|
+
export type DhAdmissionBinding = ReturnType<typeof parseDhAdmissionBinding>;
|
|
144
|
+
export interface DhRecordOwner {
|
|
145
|
+
readonly bindingId: string;
|
|
146
|
+
readonly originProducerInstanceId: string;
|
|
147
|
+
}
|
|
148
|
+
export interface DhRecordBindingContext {
|
|
149
|
+
readonly rootBinding?: DhAdmissionBinding;
|
|
150
|
+
readonly registryMapping?: Readonly<Pick<DhAdmissionBinding, "tenantId" | "environmentId" | "projectId" | "nativeProjectId" | "mappingRevision">> | null;
|
|
151
|
+
readonly routeScope?: Readonly<{
|
|
152
|
+
environmentId: string;
|
|
153
|
+
projectId: string;
|
|
154
|
+
}>;
|
|
155
|
+
readonly previousBinding?: DhAdmissionBinding;
|
|
156
|
+
readonly owner?: DhRecordOwner;
|
|
157
|
+
readonly existingOwner?: DhRecordOwner;
|
|
158
|
+
readonly tombstoned?: boolean;
|
|
159
|
+
/** Login changes never rewrite the initiating actor. This field grants no authority. */
|
|
160
|
+
readonly currentActorId?: string;
|
|
161
|
+
}
|
|
162
|
+
/** Pure equality over supplied durable facts, not a registry lookup or authentication. */
|
|
163
|
+
export declare function assertDhRecordBinding(recordInput: unknown, bindingInput: unknown, context?: DhRecordBindingContext): void;
|
|
164
|
+
declare function grantScopeSchema(): Type.TObject<{
|
|
165
|
+
readonly environmentId: Type.TString;
|
|
166
|
+
readonly projectIds: Type.TArray<Type.TString>;
|
|
167
|
+
readonly permissions: Type.TArray<Type.TEnum<["review-metadata", "review-content", "export"]>>;
|
|
168
|
+
}>;
|
|
169
|
+
export type DhGrantScope = Static<ReturnType<typeof grantScopeSchema>>;
|
|
170
|
+
declare function tokenResponseSchema(): Type.TObject<{
|
|
171
|
+
readonly access_token: Type.TString;
|
|
172
|
+
readonly token_type: Type.TLiteral<"Bearer">;
|
|
173
|
+
readonly expires_in: Type.TInteger;
|
|
174
|
+
readonly refresh_token: Type.TString;
|
|
175
|
+
readonly grant_scope: Type.TObject<{
|
|
176
|
+
readonly environmentId: Type.TString;
|
|
177
|
+
readonly projectIds: Type.TArray<Type.TString>;
|
|
178
|
+
readonly permissions: Type.TArray<Type.TEnum<["review-metadata", "review-content", "export"]>>;
|
|
179
|
+
}>;
|
|
180
|
+
}>;
|
|
181
|
+
export type DhTokenResponse = Static<ReturnType<typeof tokenResponseSchema>>;
|
|
182
|
+
export declare const parseDhTokenResponse: (value: unknown) => {
|
|
183
|
+
readonly access_token: string;
|
|
184
|
+
readonly token_type: "Bearer";
|
|
185
|
+
readonly expires_in: number;
|
|
186
|
+
readonly refresh_token: string;
|
|
187
|
+
readonly grant_scope: {
|
|
188
|
+
readonly environmentId: string;
|
|
189
|
+
readonly projectIds: string[];
|
|
190
|
+
readonly permissions: ("export" | "review-content" | "review-metadata")[];
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
/** OAuth errors have no reflecting error_description or non-OAuth fields. */
|
|
194
|
+
export declare const parseDhTokenError: (value: unknown) => {
|
|
195
|
+
readonly error: "invalid_client" | "invalid_grant" | "invalid_request" | "invalid_scope" | "server_error" | "temporarily_unavailable" | "unauthorized_client" | "unsupported_grant_type";
|
|
196
|
+
};
|
|
197
|
+
export type DhTokenError = ReturnType<typeof parseDhTokenError>;
|
|
198
|
+
declare function tokenRequestSchema(): Type.TUnion<[Type.TObject<{
|
|
199
|
+
readonly grant_type: Type.TLiteral<"authorization_code">;
|
|
200
|
+
readonly client_id: Type.TString;
|
|
201
|
+
readonly code: Type.TString;
|
|
202
|
+
readonly code_verifier: Type.TString;
|
|
203
|
+
readonly redirect_uri: Type.TString;
|
|
204
|
+
}>, Type.TObject<{
|
|
205
|
+
readonly grant_type: Type.TLiteral<"refresh_token">;
|
|
206
|
+
readonly client_id: Type.TString;
|
|
207
|
+
readonly refresh_token: Type.TString;
|
|
208
|
+
}>]>;
|
|
209
|
+
export type DhTokenRequest = Static<ReturnType<typeof tokenRequestSchema>>;
|
|
210
|
+
export declare const parseDhTokenRequest: (input: string | URLSearchParams) => DhTokenRequest;
|
|
211
|
+
declare function revokeRequestSchema(): Type.TObject<{
|
|
212
|
+
readonly client_id: Type.TString;
|
|
213
|
+
readonly token: Type.TString;
|
|
214
|
+
readonly token_type_hint: Type.TLiteral<"refresh_token">;
|
|
215
|
+
}>;
|
|
216
|
+
export type DhRevokeRequest = Static<ReturnType<typeof revokeRequestSchema>>;
|
|
217
|
+
export declare const parseDhRevokeRequest: (input: string | URLSearchParams) => DhRevokeRequest;
|
|
218
|
+
declare function authorizeQuerySchema(): Type.TObject<{
|
|
219
|
+
readonly response_type: Type.TLiteral<"code">;
|
|
220
|
+
readonly client_id: Type.TString;
|
|
221
|
+
readonly redirect_uri: Type.TString;
|
|
222
|
+
readonly state: Type.TString;
|
|
223
|
+
readonly code_challenge: Type.TString;
|
|
224
|
+
readonly code_challenge_method: Type.TLiteral<"S256">;
|
|
225
|
+
readonly environment_id: Type.TString;
|
|
226
|
+
readonly project_id: Type.TArray<Type.TString>;
|
|
227
|
+
readonly permission: Type.TArray<Type.TEnum<["review-metadata", "review-content", "export"]>>;
|
|
228
|
+
}>;
|
|
229
|
+
export type DhAuthorizeQuery = Static<ReturnType<typeof authorizeQuerySchema>>;
|
|
230
|
+
export declare const parseDhAuthorizeQuery: (input: string | URLSearchParams) => DhAuthorizeQuery;
|
|
231
|
+
declare function producerEnrollmentRequestSchema(): Type.TObject<{
|
|
232
|
+
readonly schema: Type.TLiteral<"dh.producer-enrollment-request/2">;
|
|
233
|
+
readonly bindingId: Type.TString;
|
|
234
|
+
readonly producerInstanceId: Type.TString;
|
|
235
|
+
readonly generationId: Type.TString;
|
|
236
|
+
readonly originStreamId: Type.TString;
|
|
237
|
+
readonly producer: Type.TObject<{
|
|
238
|
+
readonly issuer: Type.TEnum<["code", "cli", "flow"]>;
|
|
239
|
+
readonly version: Type.TString;
|
|
240
|
+
readonly mode: Type.TString;
|
|
241
|
+
}>;
|
|
242
|
+
}>;
|
|
243
|
+
export type DhProducerEnrollmentRequest = Static<ReturnType<typeof producerEnrollmentRequestSchema>>;
|
|
244
|
+
/** Workload proof travels in the authentication header, never the body; a reviewer grant is never producer proof. */
|
|
245
|
+
export declare const parseDhProducerEnrollmentRequest: (value: unknown) => {
|
|
246
|
+
readonly schema: "dh.producer-enrollment-request/2";
|
|
247
|
+
readonly bindingId: string;
|
|
248
|
+
readonly producerInstanceId: string;
|
|
249
|
+
readonly generationId: string;
|
|
250
|
+
readonly originStreamId: string;
|
|
251
|
+
readonly producer: {
|
|
252
|
+
readonly issuer: "cli" | "code" | "flow";
|
|
253
|
+
readonly version: string;
|
|
254
|
+
readonly mode: string;
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
declare function producerEnrollmentSchema(): Type.TObject<{
|
|
258
|
+
readonly schema: Type.TLiteral<"dh.producer-enrollment/2">;
|
|
259
|
+
readonly enrollmentId: Type.TString;
|
|
260
|
+
readonly tenantScope: Type.TObject<{
|
|
261
|
+
readonly environmentId: Type.TString;
|
|
262
|
+
readonly projectId: Type.TString;
|
|
263
|
+
}>;
|
|
264
|
+
readonly generationId: Type.TString;
|
|
265
|
+
readonly originStreamId: Type.TString;
|
|
266
|
+
readonly issuer: Type.TEnum<["code", "cli", "flow"]>;
|
|
267
|
+
readonly credentialVersion: Type.TInteger;
|
|
268
|
+
readonly bindingId: Type.TString;
|
|
269
|
+
readonly producerInstanceId: Type.TString;
|
|
270
|
+
readonly allowedOriginIssuers: Type.TArray<Type.TEnum<["code", "cli", "flow"]>>;
|
|
271
|
+
}>;
|
|
272
|
+
export type DhProducerEnrollment = Static<ReturnType<typeof producerEnrollmentSchema>>;
|
|
273
|
+
export declare const parseDhProducerEnrollment: (value: unknown) => {
|
|
274
|
+
readonly schema: "dh.producer-enrollment/2";
|
|
275
|
+
readonly enrollmentId: string;
|
|
276
|
+
readonly tenantScope: {
|
|
277
|
+
readonly environmentId: string;
|
|
278
|
+
readonly projectId: string;
|
|
279
|
+
};
|
|
280
|
+
readonly generationId: string;
|
|
281
|
+
readonly originStreamId: string;
|
|
282
|
+
readonly issuer: "cli" | "code" | "flow";
|
|
283
|
+
readonly credentialVersion: number;
|
|
284
|
+
readonly bindingId: string;
|
|
285
|
+
readonly producerInstanceId: string;
|
|
286
|
+
readonly allowedOriginIssuers: ("cli" | "code" | "flow")[];
|
|
287
|
+
};
|
|
288
|
+
export declare const parseDhProducerTokenRequest: (value: unknown) => {
|
|
289
|
+
readonly enrollmentId: string;
|
|
290
|
+
};
|
|
291
|
+
export declare const parseDhProducerRevokeRequest: (value: unknown) => {
|
|
292
|
+
readonly enrollmentId: string;
|
|
293
|
+
};
|
|
294
|
+
declare function producerAudienceSchema(): Type.TObject<{
|
|
295
|
+
readonly environmentId: Type.TString;
|
|
296
|
+
readonly projectId: Type.TString;
|
|
297
|
+
readonly generationId: Type.TString;
|
|
298
|
+
readonly originStreamId: Type.TString;
|
|
299
|
+
readonly issuer: Type.TEnum<["code", "cli", "flow"]>;
|
|
300
|
+
readonly enrollmentId: Type.TString;
|
|
301
|
+
readonly credentialVersion: Type.TInteger;
|
|
302
|
+
readonly bindingId: Type.TString;
|
|
303
|
+
readonly producerInstanceId: Type.TString;
|
|
304
|
+
readonly allowedOriginIssuers: Type.TArray<Type.TEnum<["code", "cli", "flow"]>>;
|
|
305
|
+
}>;
|
|
306
|
+
export type DhProducerAudience = Static<ReturnType<typeof producerAudienceSchema>>;
|
|
307
|
+
/** No refresh_token and no grant_scope: a producer credential cannot be refreshed into, or mistaken for, a read grant. */
|
|
308
|
+
export declare const parseDhProducerTokenResponse: (value: unknown) => {
|
|
309
|
+
readonly access_token: string;
|
|
310
|
+
readonly token_type: "Bearer";
|
|
311
|
+
readonly expires_in: number;
|
|
312
|
+
readonly audience: {
|
|
313
|
+
readonly environmentId: string;
|
|
314
|
+
readonly projectId: string;
|
|
315
|
+
readonly generationId: string;
|
|
316
|
+
readonly originStreamId: string;
|
|
317
|
+
readonly issuer: "cli" | "code" | "flow";
|
|
318
|
+
readonly enrollmentId: string;
|
|
319
|
+
readonly credentialVersion: number;
|
|
320
|
+
readonly bindingId: string;
|
|
321
|
+
readonly producerInstanceId: string;
|
|
322
|
+
readonly allowedOriginIssuers: ("cli" | "code" | "flow")[];
|
|
323
|
+
};
|
|
324
|
+
};
|
|
325
|
+
export type DhProducerTokenResponse = ReturnType<typeof parseDhProducerTokenResponse>;
|
|
326
|
+
export interface DhProducerAudienceExpectation {
|
|
327
|
+
environmentId: string;
|
|
328
|
+
projectId: string;
|
|
329
|
+
generationId: string;
|
|
330
|
+
originStreamId: string;
|
|
331
|
+
issuer: DhProducerAudience["issuer"];
|
|
332
|
+
enrollmentId: string;
|
|
333
|
+
credentialVersion: number;
|
|
334
|
+
bindingId: string;
|
|
335
|
+
producerInstanceId: string;
|
|
336
|
+
allowedOriginIssuers: readonly DhProducerAudience["issuer"][];
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* A producer credential is bound to one environment/project/generation/origin stream AND to its issuer,
|
|
340
|
+
* enrollment and credential version, so a credential from a superseded or other enrollment never passes.
|
|
341
|
+
*/
|
|
342
|
+
export declare function assertDhProducerAudience(audience: DhProducerAudience, expected: DhProducerAudienceExpectation): void;
|
|
343
|
+
export declare const parseDhWorkloadBinding: (value: unknown) => {
|
|
344
|
+
readonly schema: "dh.workload-binding/1";
|
|
345
|
+
readonly workloadId: string;
|
|
346
|
+
readonly bindingId: string;
|
|
347
|
+
readonly producerInstanceId: string;
|
|
348
|
+
readonly launchNonce: string;
|
|
349
|
+
readonly issuer: "cli" | "code" | "flow";
|
|
350
|
+
readonly buildSha256: string;
|
|
351
|
+
readonly mode: string;
|
|
352
|
+
readonly credentialVersion: number;
|
|
353
|
+
readonly expiresAt: string;
|
|
354
|
+
};
|
|
355
|
+
export type DhWorkloadBinding = ReturnType<typeof parseDhWorkloadBinding>;
|
|
356
|
+
export declare const parseDhOriginDelegation: (value: unknown) => {
|
|
357
|
+
readonly schema: "dh.origin-delegation/1";
|
|
358
|
+
readonly delegationId: string;
|
|
359
|
+
readonly bindingId: string;
|
|
360
|
+
readonly originProducerInstanceId: string;
|
|
361
|
+
readonly originStreamId: string;
|
|
362
|
+
readonly originIssuer: "cli" | "code" | "flow";
|
|
363
|
+
readonly relayProducerInstanceId: string;
|
|
364
|
+
readonly enrollmentId: string;
|
|
365
|
+
readonly credentialVersion: number;
|
|
366
|
+
readonly expiresAt: string;
|
|
367
|
+
};
|
|
368
|
+
export type DhOriginDelegation = ReturnType<typeof parseDhOriginDelegation>;
|
|
369
|
+
/** Compare to a live server-issued receipt. A syntactically valid receipt grants nothing by itself. */
|
|
370
|
+
export declare function assertDhOriginDelegation(delegationInput: unknown, expected: unknown): void;
|
|
371
|
+
/** Exactly 32 bytes in canonical unpadded base64url; caller handles private custody and live verification. */
|
|
372
|
+
export declare function parseDhWorkloadAuthorizationHeader(value: unknown): string;
|
|
373
|
+
export declare function parseDhOriginDelegationHeader(value: unknown): string;
|
|
374
|
+
declare function eventMetadataViewSchema(): Type.TObject<{
|
|
375
|
+
readonly eventId: Type.TString;
|
|
376
|
+
readonly generationId: Type.TString;
|
|
377
|
+
readonly agentId: Type.TString;
|
|
378
|
+
readonly parentAgentId: Type.TOptional<Type.TString>;
|
|
379
|
+
readonly attemptId: Type.TOptional<Type.TString>;
|
|
380
|
+
readonly retryOfAttemptId: Type.TOptional<Type.TString>;
|
|
381
|
+
readonly attemptNumber: Type.TOptional<Type.TInteger>;
|
|
382
|
+
readonly streamId: Type.TString;
|
|
383
|
+
readonly sequence: Type.TInteger;
|
|
384
|
+
readonly kind: Type.TEnum<["generation.started", "generation.finished", "agent.spawned", "attempt.started", "attempt.finished", "attempt.retry_scheduled", "model.request", "model.response", "tool.call", "tool.result", "file.change", "orchestration.decision", "cancellation.requested", "cancellation.outcome", "usage.reported", "capture.health", "control.correlation", "event.amendment"]>;
|
|
385
|
+
readonly occurredAt: Type.TString;
|
|
386
|
+
readonly recordedAt: Type.TString;
|
|
387
|
+
readonly outcome: Type.TOptional<Type.TEnum<["succeeded", "failed", "cancelled", "unknown"]>>;
|
|
388
|
+
/** The failure code only. Raw failure messages are content. */
|
|
389
|
+
readonly failureCode: Type.TOptional<Type.TString>;
|
|
390
|
+
readonly coverage: Type.TArray<Type.TObject<{
|
|
391
|
+
readonly path: Type.TString;
|
|
392
|
+
readonly state: Type.TEnum<["captured", "redacted", "truncated", "unavailable", "not-applicable", "inferred"]>;
|
|
393
|
+
readonly reason: Type.TOptional<Type.TEnum<["secret_redacted", "policy_redacted", "size_limit", "producer_lost", "worker_exited_before_flush", "legacy_producer", "not_captured_by_version", "provider_hidden", "not_applicable", "derived_from_summary"]>>;
|
|
394
|
+
}>>;
|
|
395
|
+
readonly artifactIds: Type.TArray<Type.TString>;
|
|
396
|
+
}>;
|
|
397
|
+
export type DhEventMetadataView = Static<ReturnType<typeof eventMetadataViewSchema>>;
|
|
398
|
+
export declare const parseDhEventMetadataView: (value: unknown) => {
|
|
399
|
+
readonly eventId: string;
|
|
400
|
+
readonly generationId: string;
|
|
401
|
+
readonly agentId: string;
|
|
402
|
+
readonly parentAgentId?: string | undefined;
|
|
403
|
+
readonly attemptId?: string | undefined;
|
|
404
|
+
readonly retryOfAttemptId?: string | undefined;
|
|
405
|
+
readonly attemptNumber?: number | undefined;
|
|
406
|
+
readonly streamId: string;
|
|
407
|
+
readonly sequence: number;
|
|
408
|
+
readonly kind: "agent.spawned" | "attempt.finished" | "attempt.retry_scheduled" | "attempt.started" | "cancellation.outcome" | "cancellation.requested" | "capture.health" | "control.correlation" | "event.amendment" | "file.change" | "generation.finished" | "generation.started" | "model.request" | "model.response" | "orchestration.decision" | "tool.call" | "tool.result" | "usage.reported";
|
|
409
|
+
readonly occurredAt: string;
|
|
410
|
+
readonly recordedAt: string;
|
|
411
|
+
readonly outcome?: "cancelled" | "failed" | "succeeded" | "unknown" | undefined;
|
|
412
|
+
readonly failureCode?: string | undefined;
|
|
413
|
+
readonly coverage: {
|
|
414
|
+
readonly path: string;
|
|
415
|
+
readonly state: "captured" | "inferred" | "not-applicable" | "redacted" | "truncated" | "unavailable";
|
|
416
|
+
readonly reason?: "derived_from_summary" | "legacy_producer" | "not_applicable" | "not_captured_by_version" | "policy_redacted" | "producer_lost" | "provider_hidden" | "secret_redacted" | "size_limit" | "worker_exited_before_flush" | undefined;
|
|
417
|
+
}[];
|
|
418
|
+
readonly artifactIds: string[];
|
|
419
|
+
};
|
|
420
|
+
declare const parseEventMetadataPage: (value: unknown) => {
|
|
421
|
+
readonly schema: "dh.event-page/2";
|
|
422
|
+
readonly cursorBinding: {
|
|
423
|
+
readonly schema: "dh.cursor-binding/2";
|
|
424
|
+
readonly environmentId: string;
|
|
425
|
+
readonly projectId: string;
|
|
426
|
+
readonly resource: "agents" | "events" | "generations" | "manifest";
|
|
427
|
+
readonly generationId?: string | undefined;
|
|
428
|
+
readonly bindingId?: string | undefined;
|
|
429
|
+
readonly filterSha256: string;
|
|
430
|
+
readonly view: "content" | "metadata";
|
|
431
|
+
readonly cutoff: {
|
|
432
|
+
readonly schema: "dh.snapshot-cutoff/1";
|
|
433
|
+
readonly snapshotId: string;
|
|
434
|
+
readonly receiptOrdinal: number;
|
|
435
|
+
readonly captureCutoff: string;
|
|
436
|
+
};
|
|
437
|
+
readonly mappingRevision: string;
|
|
438
|
+
readonly authorizationRevision: string;
|
|
439
|
+
readonly principalId: string;
|
|
440
|
+
readonly grantId: string;
|
|
441
|
+
readonly sessionId: string;
|
|
442
|
+
readonly pageSize: number;
|
|
443
|
+
};
|
|
444
|
+
readonly nextCursor: string | null;
|
|
445
|
+
readonly captureCutoff: string;
|
|
446
|
+
readonly contentIncluded: false;
|
|
447
|
+
readonly items: {
|
|
448
|
+
readonly eventId: string;
|
|
449
|
+
readonly generationId: string;
|
|
450
|
+
readonly agentId: string;
|
|
451
|
+
readonly parentAgentId?: string | undefined;
|
|
452
|
+
readonly attemptId?: string | undefined;
|
|
453
|
+
readonly retryOfAttemptId?: string | undefined;
|
|
454
|
+
readonly attemptNumber?: number | undefined;
|
|
455
|
+
readonly streamId: string;
|
|
456
|
+
readonly sequence: number;
|
|
457
|
+
readonly kind: "agent.spawned" | "attempt.finished" | "attempt.retry_scheduled" | "attempt.started" | "cancellation.outcome" | "cancellation.requested" | "capture.health" | "control.correlation" | "event.amendment" | "file.change" | "generation.finished" | "generation.started" | "model.request" | "model.response" | "orchestration.decision" | "tool.call" | "tool.result" | "usage.reported";
|
|
458
|
+
readonly occurredAt: string;
|
|
459
|
+
readonly recordedAt: string;
|
|
460
|
+
readonly outcome?: "cancelled" | "failed" | "succeeded" | "unknown" | undefined;
|
|
461
|
+
readonly failureCode?: string | undefined;
|
|
462
|
+
readonly coverage: {
|
|
463
|
+
readonly path: string;
|
|
464
|
+
readonly state: "captured" | "inferred" | "not-applicable" | "redacted" | "truncated" | "unavailable";
|
|
465
|
+
readonly reason?: "derived_from_summary" | "legacy_producer" | "not_applicable" | "not_captured_by_version" | "policy_redacted" | "producer_lost" | "provider_hidden" | "secret_redacted" | "size_limit" | "worker_exited_before_flush" | undefined;
|
|
466
|
+
}[];
|
|
467
|
+
readonly artifactIds: string[];
|
|
468
|
+
}[];
|
|
469
|
+
};
|
|
470
|
+
export type DhEventMetadataPage = ReturnType<typeof parseEventMetadataPage>;
|
|
471
|
+
export interface DhEventContentPage {
|
|
472
|
+
readonly schema: "dh.event-page/2";
|
|
473
|
+
readonly cursorBinding: DhCursorBinding;
|
|
474
|
+
readonly nextCursor: string | null;
|
|
475
|
+
readonly captureCutoff: string;
|
|
476
|
+
readonly contentIncluded: true;
|
|
477
|
+
readonly items: readonly DhEventV1[];
|
|
478
|
+
}
|
|
479
|
+
export type DhEventPage = DhEventMetadataPage | DhEventContentPage;
|
|
480
|
+
/** The metadata view never carries payload, raw failure messages, coverage detail or redaction paths; content pages are full dh.event/1. */
|
|
481
|
+
export declare function parseDhEventPage(value: unknown): DhEventPage;
|
|
482
|
+
export declare const DH_ARTIFACT_AVAILABILITY: readonly ["available", "pending", "unavailable"];
|
|
483
|
+
declare function artifactMetadataViewSchema(): Type.TObject<{
|
|
484
|
+
readonly artifactId: Type.TString;
|
|
485
|
+
readonly generationId: Type.TString;
|
|
486
|
+
readonly agentId: Type.TString;
|
|
487
|
+
readonly attemptId: Type.TOptional<Type.TString>;
|
|
488
|
+
readonly eventId: Type.TString;
|
|
489
|
+
readonly kind: Type.TEnum<["file-diff", "file-snapshot", "tool-output", "model-context", "log", "bundle"]>;
|
|
490
|
+
readonly mediaType: Type.TEnum<["text/plain", "text/x-diff", "application/json", "application/octet-stream"]>;
|
|
491
|
+
readonly sizeBytes: Type.TInteger;
|
|
492
|
+
readonly sha256: Type.TString;
|
|
493
|
+
/** available = bytes stored; pending = metadata acknowledged, bytes not yet; unavailable = never readable (lost, withheld or purged). */
|
|
494
|
+
readonly availability: Type.TEnum<["available", "pending", "unavailable"]>;
|
|
495
|
+
readonly coverage: Type.TObject<{
|
|
496
|
+
readonly state: Type.TEnum<["captured", "redacted", "truncated", "unavailable", "not-applicable", "inferred"]>;
|
|
497
|
+
readonly reason: Type.TOptional<Type.TEnum<["secret_redacted", "policy_redacted", "size_limit", "producer_lost", "worker_exited_before_flush", "legacy_producer", "not_captured_by_version", "provider_hidden", "not_applicable", "derived_from_summary"]>>;
|
|
498
|
+
}>;
|
|
499
|
+
}>;
|
|
500
|
+
export type DhArtifactMetadataView = Static<ReturnType<typeof artifactMetadataViewSchema>>;
|
|
501
|
+
/** Excludes logicalPath (sensitive file names), redaction paths and coverage.detail. Bytes are a separate route and grant. */
|
|
502
|
+
export declare const parseDhArtifactMetadataView: (value: unknown) => {
|
|
503
|
+
readonly artifactId: string;
|
|
504
|
+
readonly generationId: string;
|
|
505
|
+
readonly agentId: string;
|
|
506
|
+
readonly attemptId?: string | undefined;
|
|
507
|
+
readonly eventId: string;
|
|
508
|
+
readonly kind: "bundle" | "file-diff" | "file-snapshot" | "log" | "model-context" | "tool-output";
|
|
509
|
+
readonly mediaType: "application/json" | "application/octet-stream" | "text/plain" | "text/x-diff";
|
|
510
|
+
readonly sizeBytes: number;
|
|
511
|
+
readonly sha256: string;
|
|
512
|
+
readonly availability: "available" | "pending" | "unavailable";
|
|
513
|
+
readonly coverage: {
|
|
514
|
+
readonly state: "captured" | "inferred" | "not-applicable" | "redacted" | "truncated" | "unavailable";
|
|
515
|
+
readonly reason?: "derived_from_summary" | "legacy_producer" | "not_applicable" | "not_captured_by_version" | "policy_redacted" | "producer_lost" | "provider_hidden" | "secret_redacted" | "size_limit" | "worker_exited_before_flush" | undefined;
|
|
516
|
+
};
|
|
517
|
+
};
|
|
518
|
+
export declare const DH_CURSOR_RESOURCES: readonly ["generations", "agents", "events", "manifest"];
|
|
519
|
+
export declare const parseDhSnapshotCutoff: (value: unknown) => {
|
|
520
|
+
readonly schema: "dh.snapshot-cutoff/1";
|
|
521
|
+
readonly snapshotId: string;
|
|
522
|
+
readonly receiptOrdinal: number;
|
|
523
|
+
readonly captureCutoff: string;
|
|
524
|
+
};
|
|
525
|
+
export type DhSnapshotCutoff = ReturnType<typeof parseDhSnapshotCutoff>;
|
|
526
|
+
/** Internal lazy schema seam shared by existing read-page parsers. */
|
|
527
|
+
export declare function dhCursorBindingSchema(): Type.TObject<{
|
|
528
|
+
readonly schema: Type.TLiteral<"dh.cursor-binding/2">;
|
|
529
|
+
readonly environmentId: Type.TString;
|
|
530
|
+
readonly projectId: Type.TString;
|
|
531
|
+
readonly resource: Type.TEnum<["generations", "agents", "events", "manifest"]>;
|
|
532
|
+
readonly generationId: Type.TOptional<Type.TString>;
|
|
533
|
+
readonly bindingId: Type.TOptional<Type.TString>;
|
|
534
|
+
readonly filterSha256: Type.TString;
|
|
535
|
+
readonly view: Type.TUnion<[Type.TLiteral<"metadata">, Type.TLiteral<"content">]>;
|
|
536
|
+
readonly cutoff: Type.TObject<{
|
|
537
|
+
readonly schema: Type.TLiteral<"dh.snapshot-cutoff/1">;
|
|
538
|
+
readonly snapshotId: Type.TString;
|
|
539
|
+
readonly receiptOrdinal: Type.TInteger;
|
|
540
|
+
readonly captureCutoff: Type.TString;
|
|
541
|
+
}>;
|
|
542
|
+
readonly mappingRevision: Type.TString;
|
|
543
|
+
readonly authorizationRevision: Type.TString;
|
|
544
|
+
readonly principalId: Type.TString;
|
|
545
|
+
readonly grantId: Type.TString;
|
|
546
|
+
readonly sessionId: Type.TString;
|
|
547
|
+
readonly pageSize: Type.TInteger;
|
|
548
|
+
}>;
|
|
549
|
+
export type DhCursorBinding = Static<ReturnType<typeof dhCursorBindingSchema>>;
|
|
550
|
+
/** What an opaque cursor is authenticated against (server-side); clients compare it across continuation pages. */
|
|
551
|
+
export declare const parseDhCursorBinding: (value: unknown) => {
|
|
552
|
+
readonly schema: "dh.cursor-binding/2";
|
|
553
|
+
readonly environmentId: string;
|
|
554
|
+
readonly projectId: string;
|
|
555
|
+
readonly resource: "agents" | "events" | "generations" | "manifest";
|
|
556
|
+
readonly generationId?: string | undefined;
|
|
557
|
+
readonly bindingId?: string | undefined;
|
|
558
|
+
readonly filterSha256: string;
|
|
559
|
+
readonly view: "content" | "metadata";
|
|
560
|
+
readonly cutoff: {
|
|
561
|
+
readonly schema: "dh.snapshot-cutoff/1";
|
|
562
|
+
readonly snapshotId: string;
|
|
563
|
+
readonly receiptOrdinal: number;
|
|
564
|
+
readonly captureCutoff: string;
|
|
565
|
+
};
|
|
566
|
+
readonly mappingRevision: string;
|
|
567
|
+
readonly authorizationRevision: string;
|
|
568
|
+
readonly principalId: string;
|
|
569
|
+
readonly grantId: string;
|
|
570
|
+
readonly sessionId: string;
|
|
571
|
+
readonly pageSize: number;
|
|
572
|
+
};
|
|
573
|
+
export declare function assertDhReadPageBinding(page: {
|
|
574
|
+
cursorBinding: unknown;
|
|
575
|
+
captureCutoff: string;
|
|
576
|
+
items: readonly unknown[];
|
|
577
|
+
}, resource: "generations" | "agents" | "events", view?: "metadata" | "content"): void;
|
|
578
|
+
/** Pure supplied-context checks; opaque storage and authentication remain server responsibilities. */
|
|
579
|
+
export declare function assertDhCursorContext(context: {
|
|
580
|
+
registered: boolean;
|
|
581
|
+
now: string;
|
|
582
|
+
expiresAt: string;
|
|
583
|
+
}): void;
|
|
584
|
+
export declare function assertDhCursorProgress(previous: string | undefined, next: string | null, seen?: ReadonlySet<string>): void;
|
|
585
|
+
/** Every field, including the cutoff and view, must be identical across pages of one snapshot. */
|
|
586
|
+
export declare function assertDhCursorBinding(expected: unknown, actual: unknown): void;
|
|
587
|
+
export declare const parseDhExportCreateRequest: (value: unknown) => {
|
|
588
|
+
readonly includeContent: boolean;
|
|
589
|
+
readonly acknowledgeNonRevocable: true;
|
|
590
|
+
};
|
|
591
|
+
export type DhExportCreateRequest = ReturnType<typeof parseDhExportCreateRequest>;
|
|
592
|
+
/** GET exports/{jobId}. `DhExportJob` (jobId+state) stays the POST 202 handle. */
|
|
593
|
+
export declare const parseDhExportJobStatus: (value: unknown) => {
|
|
594
|
+
readonly jobId: string;
|
|
595
|
+
readonly generationId: string;
|
|
596
|
+
readonly state: "failed" | "queued" | "ready" | "running";
|
|
597
|
+
readonly contentIncluded: boolean;
|
|
598
|
+
readonly captureCutoff?: string | undefined;
|
|
599
|
+
};
|
|
600
|
+
export type DhExportJobStatus = ReturnType<typeof parseDhExportJobStatus>;
|
|
601
|
+
declare const parseManifestHeader: (value: unknown) => {
|
|
602
|
+
readonly jobId: string;
|
|
603
|
+
readonly generationId: string;
|
|
604
|
+
readonly tenantScope: {
|
|
605
|
+
readonly environmentId: string;
|
|
606
|
+
readonly projectId: string;
|
|
607
|
+
};
|
|
608
|
+
readonly bindingId: string;
|
|
609
|
+
readonly cutoff: {
|
|
610
|
+
readonly schema: "dh.snapshot-cutoff/1";
|
|
611
|
+
readonly snapshotId: string;
|
|
612
|
+
readonly receiptOrdinal: number;
|
|
613
|
+
readonly captureCutoff: string;
|
|
614
|
+
};
|
|
615
|
+
readonly captureCutoff: string;
|
|
616
|
+
readonly contentIncluded: boolean;
|
|
617
|
+
readonly policyRevision: string;
|
|
618
|
+
readonly schema: "dh.export-manifest-header/2";
|
|
619
|
+
readonly canonicalProfile: "dh.canonical-jcs/1";
|
|
620
|
+
readonly state: "sealed";
|
|
621
|
+
readonly eventCount: number;
|
|
622
|
+
readonly artifactCount: number;
|
|
623
|
+
readonly streamCount: number;
|
|
624
|
+
readonly omittedArtifactCount: number;
|
|
625
|
+
readonly shardCount: number;
|
|
626
|
+
readonly shards: {
|
|
627
|
+
readonly index: number;
|
|
628
|
+
readonly recordCount: number;
|
|
629
|
+
readonly sha256: string;
|
|
630
|
+
}[];
|
|
631
|
+
readonly manifestSha256: string;
|
|
632
|
+
readonly coverage: {
|
|
633
|
+
readonly state: "captured" | "inferred" | "not-applicable" | "redacted" | "truncated" | "unavailable";
|
|
634
|
+
readonly reason?: "derived_from_summary" | "legacy_producer" | "not_applicable" | "not_captured_by_version" | "policy_redacted" | "producer_lost" | "provider_hidden" | "secret_redacted" | "size_limit" | "worker_exited_before_flush" | undefined;
|
|
635
|
+
};
|
|
636
|
+
};
|
|
637
|
+
export declare function parseDhExportManifestHeader(value: unknown): ReturnType<typeof parseManifestHeader>;
|
|
638
|
+
export type DhExportManifestHeader = ReturnType<typeof parseDhExportManifestHeader>;
|
|
639
|
+
declare function manifestEntrySchema(): Type.TUnion<[Type.TObject<{
|
|
640
|
+
readonly bindingId: Type.TString;
|
|
641
|
+
readonly originProducerInstanceId: Type.TString;
|
|
642
|
+
readonly originStreamId: Type.TString;
|
|
643
|
+
readonly representation: Type.TEnum<["metadata", "content"]>;
|
|
644
|
+
readonly recordSha256: Type.TString;
|
|
645
|
+
readonly kind: Type.TLiteral<"event">;
|
|
646
|
+
readonly id: Type.TString;
|
|
647
|
+
}>, Type.TObject<{
|
|
648
|
+
readonly bindingId: Type.TString;
|
|
649
|
+
readonly originProducerInstanceId: Type.TString;
|
|
650
|
+
readonly originStreamId: Type.TString;
|
|
651
|
+
readonly representation: Type.TEnum<["metadata", "content"]>;
|
|
652
|
+
readonly recordSha256: Type.TString;
|
|
653
|
+
readonly kind: Type.TLiteral<"artifact">;
|
|
654
|
+
readonly id: Type.TString;
|
|
655
|
+
readonly sha256: Type.TString;
|
|
656
|
+
readonly sizeBytes: Type.TInteger;
|
|
657
|
+
readonly bytes: Type.TEnum<["included", "omitted", "unavailable"]>;
|
|
658
|
+
readonly reason: Type.TOptional<Type.TEnum<["policy_redacted", "producer_lost", "size_limit", "not_captured_by_version"]>>;
|
|
659
|
+
}>, Type.TObject<{
|
|
660
|
+
readonly bindingId: Type.TString;
|
|
661
|
+
readonly originProducerInstanceId: Type.TString;
|
|
662
|
+
readonly kind: Type.TLiteral<"stream">;
|
|
663
|
+
readonly id: Type.TString;
|
|
664
|
+
readonly prefixThroughSequence: Type.TInteger;
|
|
665
|
+
readonly state: Type.TEnum<["open", "closed", "lost", "disputed"]>;
|
|
666
|
+
}>]>;
|
|
667
|
+
export type DhManifestEntry = Static<ReturnType<typeof manifestEntrySchema>>;
|
|
668
|
+
declare const parseManifestPage: (value: unknown) => {
|
|
669
|
+
readonly jobId: string;
|
|
670
|
+
readonly generationId: string;
|
|
671
|
+
readonly tenantScope: {
|
|
672
|
+
readonly environmentId: string;
|
|
673
|
+
readonly projectId: string;
|
|
674
|
+
};
|
|
675
|
+
readonly bindingId: string;
|
|
676
|
+
readonly cutoff: {
|
|
677
|
+
readonly schema: "dh.snapshot-cutoff/1";
|
|
678
|
+
readonly snapshotId: string;
|
|
679
|
+
readonly receiptOrdinal: number;
|
|
680
|
+
readonly captureCutoff: string;
|
|
681
|
+
};
|
|
682
|
+
readonly captureCutoff: string;
|
|
683
|
+
readonly contentIncluded: boolean;
|
|
684
|
+
readonly policyRevision: string;
|
|
685
|
+
readonly schema: "dh.export-manifest-page/2";
|
|
686
|
+
readonly shardIndex: number;
|
|
687
|
+
readonly sha256: string;
|
|
688
|
+
readonly entries: ({
|
|
689
|
+
readonly bindingId: string;
|
|
690
|
+
readonly originProducerInstanceId: string;
|
|
691
|
+
readonly originStreamId: string;
|
|
692
|
+
readonly representation: "content" | "metadata";
|
|
693
|
+
readonly recordSha256: string;
|
|
694
|
+
readonly kind: "event";
|
|
695
|
+
readonly id: string;
|
|
696
|
+
} | {
|
|
697
|
+
readonly bindingId: string;
|
|
698
|
+
readonly originProducerInstanceId: string;
|
|
699
|
+
readonly originStreamId: string;
|
|
700
|
+
readonly representation: "content" | "metadata";
|
|
701
|
+
readonly recordSha256: string;
|
|
702
|
+
readonly kind: "artifact";
|
|
703
|
+
readonly id: string;
|
|
704
|
+
readonly sha256: string;
|
|
705
|
+
readonly sizeBytes: number;
|
|
706
|
+
readonly bytes: "included" | "omitted" | "unavailable";
|
|
707
|
+
readonly reason?: "not_captured_by_version" | "policy_redacted" | "producer_lost" | "size_limit" | undefined;
|
|
708
|
+
} | {
|
|
709
|
+
readonly bindingId: string;
|
|
710
|
+
readonly originProducerInstanceId: string;
|
|
711
|
+
readonly kind: "stream";
|
|
712
|
+
readonly id: string;
|
|
713
|
+
readonly prefixThroughSequence: number;
|
|
714
|
+
readonly state: "closed" | "disputed" | "lost" | "open";
|
|
715
|
+
})[];
|
|
716
|
+
readonly nextCursor: string | null;
|
|
717
|
+
};
|
|
718
|
+
export declare function parseDhExportManifestPage(value: unknown): ReturnType<typeof parseManifestPage>;
|
|
719
|
+
export type DhExportManifestPage = ReturnType<typeof parseDhExportManifestPage>;
|
|
720
|
+
/** Navigation is outside the immutable sealed header. */
|
|
721
|
+
export declare const parseDhExportManifestResponse: (value: unknown) => {
|
|
722
|
+
readonly header: {
|
|
723
|
+
readonly jobId: string;
|
|
724
|
+
readonly generationId: string;
|
|
725
|
+
readonly tenantScope: {
|
|
726
|
+
readonly environmentId: string;
|
|
727
|
+
readonly projectId: string;
|
|
728
|
+
};
|
|
729
|
+
readonly bindingId: string;
|
|
730
|
+
readonly cutoff: {
|
|
731
|
+
readonly schema: "dh.snapshot-cutoff/1";
|
|
732
|
+
readonly snapshotId: string;
|
|
733
|
+
readonly receiptOrdinal: number;
|
|
734
|
+
readonly captureCutoff: string;
|
|
735
|
+
};
|
|
736
|
+
readonly captureCutoff: string;
|
|
737
|
+
readonly contentIncluded: boolean;
|
|
738
|
+
readonly policyRevision: string;
|
|
739
|
+
readonly schema: "dh.export-manifest-header/2";
|
|
740
|
+
readonly canonicalProfile: "dh.canonical-jcs/1";
|
|
741
|
+
readonly state: "sealed";
|
|
742
|
+
readonly eventCount: number;
|
|
743
|
+
readonly artifactCount: number;
|
|
744
|
+
readonly streamCount: number;
|
|
745
|
+
readonly omittedArtifactCount: number;
|
|
746
|
+
readonly shardCount: number;
|
|
747
|
+
readonly shards: {
|
|
748
|
+
readonly index: number;
|
|
749
|
+
readonly recordCount: number;
|
|
750
|
+
readonly sha256: string;
|
|
751
|
+
}[];
|
|
752
|
+
readonly manifestSha256: string;
|
|
753
|
+
readonly coverage: {
|
|
754
|
+
readonly state: "captured" | "inferred" | "not-applicable" | "redacted" | "truncated" | "unavailable";
|
|
755
|
+
readonly reason?: "derived_from_summary" | "legacy_producer" | "not_applicable" | "not_captured_by_version" | "policy_redacted" | "producer_lost" | "provider_hidden" | "secret_redacted" | "size_limit" | "worker_exited_before_flush" | undefined;
|
|
756
|
+
};
|
|
757
|
+
};
|
|
758
|
+
readonly firstShardCursor: string | null;
|
|
759
|
+
readonly cursorBinding: {
|
|
760
|
+
readonly schema: "dh.cursor-binding/2";
|
|
761
|
+
readonly environmentId: string;
|
|
762
|
+
readonly projectId: string;
|
|
763
|
+
readonly resource: "agents" | "events" | "generations" | "manifest";
|
|
764
|
+
readonly generationId?: string | undefined;
|
|
765
|
+
readonly bindingId?: string | undefined;
|
|
766
|
+
readonly filterSha256: string;
|
|
767
|
+
readonly view: "content" | "metadata";
|
|
768
|
+
readonly cutoff: {
|
|
769
|
+
readonly schema: "dh.snapshot-cutoff/1";
|
|
770
|
+
readonly snapshotId: string;
|
|
771
|
+
readonly receiptOrdinal: number;
|
|
772
|
+
readonly captureCutoff: string;
|
|
773
|
+
};
|
|
774
|
+
readonly mappingRevision: string;
|
|
775
|
+
readonly authorizationRevision: string;
|
|
776
|
+
readonly principalId: string;
|
|
777
|
+
readonly grantId: string;
|
|
778
|
+
readonly sessionId: string;
|
|
779
|
+
readonly pageSize: number;
|
|
780
|
+
};
|
|
781
|
+
};
|
|
782
|
+
export type DhExportManifestResponse = ReturnType<typeof parseDhExportManifestResponse>;
|
|
783
|
+
/** JCS shard body; hash its domain-separated bytes, never navigation cursors. */
|
|
784
|
+
export declare function dhManifestShardCanonicalText(page: DhExportManifestPage): string;
|
|
785
|
+
/** Convenience over the same bounded incremental algorithm. */
|
|
786
|
+
export declare function validateDhExportManifest(headerInput: unknown, pageInputs: readonly unknown[], options: DhExportHashOptions): {
|
|
787
|
+
header: DhExportManifestHeader;
|
|
788
|
+
pages: readonly DhExportManifestPage[];
|
|
789
|
+
};
|
|
790
|
+
export declare const DH_CONTROL_ACTIONS: readonly ["cancel", "retry", "continue"];
|
|
791
|
+
export type DhControlAction = (typeof DH_CONTROL_ACTIONS)[number];
|
|
792
|
+
/** Acceptance, delivery and application are not termination: terminationConfirmed is a separate observation. */
|
|
793
|
+
export declare const DH_CONTROL_STATES: readonly ["requested", "accepted", "delivered", "applied", "rejected", "unsupported", "unknown"];
|
|
794
|
+
export type DhControlState = (typeof DH_CONTROL_STATES)[number];
|
|
795
|
+
export declare const DH_CONTROL_REJECT_REASONS: readonly ["not_authorized", "scope_mismatch", "stale_epoch", "target_settled", "not_eligible", "policy_denied", "budget_exhausted", "workspace_unavailable"];
|
|
796
|
+
export type DhControlRejectReason = (typeof DH_CONTROL_REJECT_REASONS)[number];
|
|
797
|
+
declare function controlRequestSchema(): Type.TUnion<[Type.TObject<{
|
|
798
|
+
readonly schema: Type.TLiteral<"dh.control-request/2">;
|
|
799
|
+
readonly requestId: Type.TString;
|
|
800
|
+
readonly idempotencyKey: Type.TString;
|
|
801
|
+
readonly generationId: Type.TString;
|
|
802
|
+
readonly agentId: Type.TString;
|
|
803
|
+
readonly attemptId: Type.TString;
|
|
804
|
+
readonly bindingId: Type.TString;
|
|
805
|
+
readonly bindingEpoch: Type.TString;
|
|
806
|
+
readonly sessionEpoch: Type.TString;
|
|
807
|
+
readonly capabilityRevision: Type.TString;
|
|
808
|
+
readonly action: Type.TLiteral<"cancel">;
|
|
809
|
+
readonly payload: Type.TObject<{
|
|
810
|
+
readonly scope: Type.TUnion<[Type.TLiteral<"selected">, Type.TLiteral<"whole-run">]>;
|
|
811
|
+
}>;
|
|
812
|
+
}>, Type.TObject<{
|
|
813
|
+
readonly schema: Type.TLiteral<"dh.control-request/2">;
|
|
814
|
+
readonly requestId: Type.TString;
|
|
815
|
+
readonly idempotencyKey: Type.TString;
|
|
816
|
+
readonly generationId: Type.TString;
|
|
817
|
+
readonly agentId: Type.TString;
|
|
818
|
+
readonly attemptId: Type.TString;
|
|
819
|
+
readonly bindingId: Type.TString;
|
|
820
|
+
readonly bindingEpoch: Type.TString;
|
|
821
|
+
readonly sessionEpoch: Type.TString;
|
|
822
|
+
readonly capabilityRevision: Type.TString;
|
|
823
|
+
readonly action: Type.TLiteral<"retry">;
|
|
824
|
+
readonly payload: Type.TObject<{
|
|
825
|
+
readonly sourceAttemptId: Type.TString;
|
|
826
|
+
/** new-attempt: same agent, new att_ (Flow/CLI worker). new-agent: new agent + cross-agent relation (Code native retry). */
|
|
827
|
+
readonly relation: Type.TUnion<[Type.TLiteral<"new-attempt">, Type.TLiteral<"new-agent">]>;
|
|
828
|
+
/** Literal on purpose: a retry cannot drop model/context/workspace policy or reset cumulative spend. */
|
|
829
|
+
readonly policy: Type.TObject<{
|
|
830
|
+
readonly model: Type.TLiteral<"retain">;
|
|
831
|
+
readonly context: Type.TLiteral<"retain">;
|
|
832
|
+
readonly workspace: Type.TLiteral<"retain">;
|
|
833
|
+
readonly spend: Type.TLiteral<"cumulative">;
|
|
834
|
+
}>;
|
|
835
|
+
}>;
|
|
836
|
+
}>, Type.TObject<{
|
|
837
|
+
readonly schema: Type.TLiteral<"dh.control-request/2">;
|
|
838
|
+
readonly requestId: Type.TString;
|
|
839
|
+
readonly idempotencyKey: Type.TString;
|
|
840
|
+
readonly generationId: Type.TString;
|
|
841
|
+
readonly agentId: Type.TString;
|
|
842
|
+
readonly attemptId: Type.TString;
|
|
843
|
+
readonly bindingId: Type.TString;
|
|
844
|
+
readonly bindingEpoch: Type.TString;
|
|
845
|
+
readonly sessionEpoch: Type.TString;
|
|
846
|
+
readonly capabilityRevision: Type.TString;
|
|
847
|
+
readonly action: Type.TLiteral<"continue">;
|
|
848
|
+
readonly payload: Type.TObject<{
|
|
849
|
+
readonly message: Type.TString;
|
|
850
|
+
}>;
|
|
851
|
+
}>]>;
|
|
852
|
+
export type DhControlRequest = Static<ReturnType<typeof controlRequestSchema>>;
|
|
853
|
+
export type DhCancelRequest = Extract<DhControlRequest, {
|
|
854
|
+
action: "cancel";
|
|
855
|
+
}>;
|
|
856
|
+
export type DhRetryRequest = Extract<DhControlRequest, {
|
|
857
|
+
action: "retry";
|
|
858
|
+
}>;
|
|
859
|
+
export type DhContinueRequest = Extract<DhControlRequest, {
|
|
860
|
+
action: "continue";
|
|
861
|
+
}>;
|
|
862
|
+
export declare const parseDhControlRequest: (value: unknown) => {
|
|
863
|
+
readonly schema: "dh.control-request/2";
|
|
864
|
+
readonly requestId: string;
|
|
865
|
+
readonly idempotencyKey: string;
|
|
866
|
+
readonly generationId: string;
|
|
867
|
+
readonly agentId: string;
|
|
868
|
+
readonly attemptId: string;
|
|
869
|
+
readonly bindingId: string;
|
|
870
|
+
readonly bindingEpoch: string;
|
|
871
|
+
readonly sessionEpoch: string;
|
|
872
|
+
readonly capabilityRevision: string;
|
|
873
|
+
readonly action: "cancel";
|
|
874
|
+
readonly payload: {
|
|
875
|
+
readonly scope: "selected" | "whole-run";
|
|
876
|
+
};
|
|
877
|
+
} | {
|
|
878
|
+
readonly schema: "dh.control-request/2";
|
|
879
|
+
readonly requestId: string;
|
|
880
|
+
readonly idempotencyKey: string;
|
|
881
|
+
readonly generationId: string;
|
|
882
|
+
readonly agentId: string;
|
|
883
|
+
readonly attemptId: string;
|
|
884
|
+
readonly bindingId: string;
|
|
885
|
+
readonly bindingEpoch: string;
|
|
886
|
+
readonly sessionEpoch: string;
|
|
887
|
+
readonly capabilityRevision: string;
|
|
888
|
+
readonly action: "retry";
|
|
889
|
+
readonly payload: {
|
|
890
|
+
readonly sourceAttemptId: string;
|
|
891
|
+
readonly relation: "new-agent" | "new-attempt";
|
|
892
|
+
readonly policy: {
|
|
893
|
+
readonly model: "retain";
|
|
894
|
+
readonly context: "retain";
|
|
895
|
+
readonly workspace: "retain";
|
|
896
|
+
readonly spend: "cumulative";
|
|
897
|
+
};
|
|
898
|
+
};
|
|
899
|
+
} | {
|
|
900
|
+
readonly schema: "dh.control-request/2";
|
|
901
|
+
readonly requestId: string;
|
|
902
|
+
readonly idempotencyKey: string;
|
|
903
|
+
readonly generationId: string;
|
|
904
|
+
readonly agentId: string;
|
|
905
|
+
readonly attemptId: string;
|
|
906
|
+
readonly bindingId: string;
|
|
907
|
+
readonly bindingEpoch: string;
|
|
908
|
+
readonly sessionEpoch: string;
|
|
909
|
+
readonly capabilityRevision: string;
|
|
910
|
+
readonly action: "continue";
|
|
911
|
+
readonly payload: {
|
|
912
|
+
readonly message: string;
|
|
913
|
+
};
|
|
914
|
+
};
|
|
915
|
+
export declare const parseDhCancelRequest: (value: unknown) => DhCancelRequest;
|
|
916
|
+
export declare const parseDhRetryRequest: (value: unknown) => DhRetryRequest;
|
|
917
|
+
export declare const parseDhContinueRequest: (value: unknown) => DhContinueRequest;
|
|
918
|
+
export interface DhControlFence {
|
|
919
|
+
generationId: string;
|
|
920
|
+
agentId: string;
|
|
921
|
+
attemptId: string;
|
|
922
|
+
bindingId: string;
|
|
923
|
+
bindingEpoch: string;
|
|
924
|
+
sessionEpoch: string;
|
|
925
|
+
capabilityRevision: string;
|
|
926
|
+
}
|
|
927
|
+
/** A different generation/agent is a scope error; a replaced attempt or binding epoch is stale. Never apply a stale fence. */
|
|
928
|
+
export declare function checkDhControlFence(request: DhControlFence, live: DhControlFence): "ok" | "scope_mismatch" | "stale_epoch" | "policy_denied";
|
|
929
|
+
/** The POST body must match the action-specific route and the path's generation/agent. */
|
|
930
|
+
export declare function assertDhControlRequestForRoute(id: DhRouteId, params: Readonly<Record<string, string>>, request: unknown): DhControlRequest;
|
|
931
|
+
export interface DhControlReplayEntry {
|
|
932
|
+
/** Authenticated by the server, never taken from the request body. */
|
|
933
|
+
actor: string;
|
|
934
|
+
authorityId: string;
|
|
935
|
+
tenantId: string;
|
|
936
|
+
scope: {
|
|
937
|
+
environmentId: string;
|
|
938
|
+
projectId: string;
|
|
939
|
+
};
|
|
940
|
+
request: unknown;
|
|
941
|
+
}
|
|
942
|
+
/**
|
|
943
|
+
* Idempotency: entries with the same actor, environment/project, generation, agent, action and key are
|
|
944
|
+
* one request. Then a byte-equal canonical body (request id, attempt, epoch, payload) is a replay (`same`);
|
|
945
|
+
* anything else under that key is a `conflict` (HTTP 409, no second effect). Other keys/actors/scopes/targets are `distinct`.
|
|
946
|
+
*/
|
|
947
|
+
export declare function compareDhControlReplay(stored: DhControlReplayEntry, incoming: DhControlReplayEntry): "same" | "conflict" | "distinct";
|
|
948
|
+
/** POST response: a correlated handle, not an effect. */
|
|
949
|
+
export declare const parseDhControlReceipt: (value: unknown) => {
|
|
950
|
+
readonly schema: "dh.control-receipt/1";
|
|
951
|
+
readonly requestId: string;
|
|
952
|
+
readonly action: "cancel" | "continue" | "retry";
|
|
953
|
+
readonly state: "accepted" | "applied" | "delivered" | "rejected" | "requested" | "unknown" | "unsupported";
|
|
954
|
+
readonly reason?: "budget_exhausted" | "not_authorized" | "not_eligible" | "policy_denied" | "scope_mismatch" | "stale_epoch" | "target_settled" | "workspace_unavailable" | undefined;
|
|
955
|
+
};
|
|
956
|
+
export type DhControlReceipt = ReturnType<typeof parseDhControlReceipt>;
|
|
957
|
+
export declare const parseDhControlRequestStatus: (value: unknown) => {
|
|
958
|
+
readonly schema: "dh.control-status/2";
|
|
959
|
+
readonly requestId: string;
|
|
960
|
+
readonly action: "cancel" | "continue" | "retry";
|
|
961
|
+
readonly generationId: string;
|
|
962
|
+
readonly agentId: string;
|
|
963
|
+
readonly attemptId: string;
|
|
964
|
+
readonly bindingId: string;
|
|
965
|
+
readonly bindingEpoch: string;
|
|
966
|
+
readonly sessionEpoch: string;
|
|
967
|
+
readonly capabilityRevision: string;
|
|
968
|
+
readonly requestSha256: string;
|
|
969
|
+
readonly state: "accepted" | "applied" | "delivered" | "rejected" | "requested" | "unknown" | "unsupported";
|
|
970
|
+
readonly reason?: "budget_exhausted" | "not_authorized" | "not_eligible" | "policy_denied" | "scope_mismatch" | "stale_epoch" | "target_settled" | "workspace_unavailable" | undefined;
|
|
971
|
+
readonly terminationConfirmed?: boolean | undefined;
|
|
972
|
+
readonly observed?: {
|
|
973
|
+
readonly startedAgentId?: string | undefined;
|
|
974
|
+
readonly startedAttemptId?: string | undefined;
|
|
975
|
+
readonly consumedByEventId?: string | undefined;
|
|
976
|
+
} | undefined;
|
|
977
|
+
readonly updatedAt: string;
|
|
978
|
+
};
|
|
979
|
+
export type DhControlRequestStatus = ReturnType<typeof parseDhControlRequestStatus>;
|
|
980
|
+
export declare const parseDhControlTarget: (value: unknown) => {
|
|
981
|
+
readonly generationId: string;
|
|
982
|
+
readonly agentId: string;
|
|
983
|
+
readonly attemptId: string;
|
|
984
|
+
readonly bindingId: string;
|
|
985
|
+
readonly bindingEpoch: string;
|
|
986
|
+
readonly sessionEpoch: string;
|
|
987
|
+
readonly capabilityRevision: string;
|
|
988
|
+
readonly schema: "dh.control-target/1";
|
|
989
|
+
readonly updatedAt: string;
|
|
990
|
+
};
|
|
991
|
+
export type DhControlTarget = ReturnType<typeof parseDhControlTarget>;
|
|
992
|
+
export declare const parseDhControlHandshake: (value: unknown) => {
|
|
993
|
+
readonly schema: "dh.control-handshake/1";
|
|
994
|
+
readonly bindingId: string;
|
|
995
|
+
readonly sessionEpoch: string;
|
|
996
|
+
readonly token: string;
|
|
997
|
+
};
|
|
998
|
+
export type DhControlHandshake = ReturnType<typeof parseDhControlHandshake>;
|
|
999
|
+
export declare const parseDhControlDelivery: (value: unknown) => {
|
|
1000
|
+
readonly schema: "dh.control-delivery/1";
|
|
1001
|
+
readonly request: {
|
|
1002
|
+
readonly schema: "dh.control-request/2";
|
|
1003
|
+
readonly requestId: string;
|
|
1004
|
+
readonly idempotencyKey: string;
|
|
1005
|
+
readonly generationId: string;
|
|
1006
|
+
readonly agentId: string;
|
|
1007
|
+
readonly attemptId: string;
|
|
1008
|
+
readonly bindingId: string;
|
|
1009
|
+
readonly bindingEpoch: string;
|
|
1010
|
+
readonly sessionEpoch: string;
|
|
1011
|
+
readonly capabilityRevision: string;
|
|
1012
|
+
readonly action: "cancel";
|
|
1013
|
+
readonly payload: {
|
|
1014
|
+
readonly scope: "selected" | "whole-run";
|
|
1015
|
+
};
|
|
1016
|
+
} | {
|
|
1017
|
+
readonly schema: "dh.control-request/2";
|
|
1018
|
+
readonly requestId: string;
|
|
1019
|
+
readonly idempotencyKey: string;
|
|
1020
|
+
readonly generationId: string;
|
|
1021
|
+
readonly agentId: string;
|
|
1022
|
+
readonly attemptId: string;
|
|
1023
|
+
readonly bindingId: string;
|
|
1024
|
+
readonly bindingEpoch: string;
|
|
1025
|
+
readonly sessionEpoch: string;
|
|
1026
|
+
readonly capabilityRevision: string;
|
|
1027
|
+
readonly action: "retry";
|
|
1028
|
+
readonly payload: {
|
|
1029
|
+
readonly sourceAttemptId: string;
|
|
1030
|
+
readonly relation: "new-agent" | "new-attempt";
|
|
1031
|
+
readonly policy: {
|
|
1032
|
+
readonly model: "retain";
|
|
1033
|
+
readonly context: "retain";
|
|
1034
|
+
readonly workspace: "retain";
|
|
1035
|
+
readonly spend: "cumulative";
|
|
1036
|
+
};
|
|
1037
|
+
};
|
|
1038
|
+
} | {
|
|
1039
|
+
readonly schema: "dh.control-request/2";
|
|
1040
|
+
readonly requestId: string;
|
|
1041
|
+
readonly idempotencyKey: string;
|
|
1042
|
+
readonly generationId: string;
|
|
1043
|
+
readonly agentId: string;
|
|
1044
|
+
readonly attemptId: string;
|
|
1045
|
+
readonly bindingId: string;
|
|
1046
|
+
readonly bindingEpoch: string;
|
|
1047
|
+
readonly sessionEpoch: string;
|
|
1048
|
+
readonly capabilityRevision: string;
|
|
1049
|
+
readonly action: "continue";
|
|
1050
|
+
readonly payload: {
|
|
1051
|
+
readonly message: string;
|
|
1052
|
+
};
|
|
1053
|
+
};
|
|
1054
|
+
readonly tenantScope: {
|
|
1055
|
+
readonly environmentId: string;
|
|
1056
|
+
readonly projectId: string;
|
|
1057
|
+
};
|
|
1058
|
+
readonly actorId: string;
|
|
1059
|
+
readonly authorityId: string;
|
|
1060
|
+
readonly authorizationRevision: string;
|
|
1061
|
+
readonly authorizedAt: string;
|
|
1062
|
+
readonly expiresAt: string;
|
|
1063
|
+
readonly requestSha256: string;
|
|
1064
|
+
};
|
|
1065
|
+
export type DhControlDelivery = ReturnType<typeof parseDhControlDelivery>;
|
|
1066
|
+
export interface DhControlDeliveryContext {
|
|
1067
|
+
live: DhControlFence;
|
|
1068
|
+
scope: {
|
|
1069
|
+
environmentId: string;
|
|
1070
|
+
projectId: string;
|
|
1071
|
+
};
|
|
1072
|
+
actorId: string;
|
|
1073
|
+
authorityId: string;
|
|
1074
|
+
authorizationRevision: string;
|
|
1075
|
+
authorized: boolean;
|
|
1076
|
+
now: string;
|
|
1077
|
+
}
|
|
1078
|
+
export declare function assertDhControlDelivery(input: unknown, context: DhControlDeliveryContext, options: DhExportHashOptions): void;
|
|
1079
|
+
/** Non-secret registry descriptor only. The bearer is held privately and never serialized here. */
|
|
1080
|
+
export declare const parseDhControllerCredential: (value: unknown) => {
|
|
1081
|
+
readonly schema: "dh.controller-credential/1";
|
|
1082
|
+
readonly authorityId: string;
|
|
1083
|
+
readonly actorId: string;
|
|
1084
|
+
readonly bindingId: string;
|
|
1085
|
+
readonly targets: {
|
|
1086
|
+
readonly generationId: string;
|
|
1087
|
+
readonly agentId: string;
|
|
1088
|
+
readonly attemptId: string;
|
|
1089
|
+
}[];
|
|
1090
|
+
readonly actions: {
|
|
1091
|
+
readonly cancelSelected: boolean;
|
|
1092
|
+
readonly cancelWholeRun: boolean;
|
|
1093
|
+
readonly continueLive: boolean;
|
|
1094
|
+
readonly retryFresh: boolean;
|
|
1095
|
+
};
|
|
1096
|
+
readonly statusRead: boolean;
|
|
1097
|
+
readonly discoverTarget: boolean;
|
|
1098
|
+
readonly sessionVersion: number;
|
|
1099
|
+
readonly credentialVersion: number;
|
|
1100
|
+
readonly issuedAt: string;
|
|
1101
|
+
readonly expiresAt: string;
|
|
1102
|
+
};
|
|
1103
|
+
export type DhControllerCredential = ReturnType<typeof parseDhControllerCredential>;
|
|
1104
|
+
export declare function assertDhControllerAction(input: unknown, targetInput: unknown, action: keyof DhControllerCredential["actions"], context: {
|
|
1105
|
+
now: string;
|
|
1106
|
+
liveVersion: number;
|
|
1107
|
+
sessionVersion: number;
|
|
1108
|
+
membershipActive: boolean;
|
|
1109
|
+
}): void;
|
|
1110
|
+
export declare function assertDhControlStatusEvidence(input: unknown, events: readonly DhEventV1[]): void;
|
|
1111
|
+
/** Socket/fd3 message framing only; no I/O or transport authority is implemented. */
|
|
1112
|
+
export declare function parseDhControlFrame(bytes: Uint8Array): DhControlDelivery | DhControlHandshake;
|
|
1113
|
+
export declare function dhControlFrameBytes(input: unknown): Uint8Array;
|
|
1114
|
+
/** POST-local reply context only: never an assertion of the collector's durable prefix. */
|
|
1115
|
+
export declare function parseDhPreviousAckedSequenceHeader(value: unknown): number;
|
|
1116
|
+
/** Validate at the transport boundary before invoking the unchanged prefix checker. Full batches are allowed. */
|
|
1117
|
+
export declare function assertDhAckSentBatch(sent: DhAckSentBatch): void;
|
|
1118
|
+
/** Structural view of a sent batch: a DhIngestBatch satisfies it. */
|
|
1119
|
+
export interface DhAckSentBatch {
|
|
1120
|
+
readonly streamId: string;
|
|
1121
|
+
readonly events: readonly {
|
|
1122
|
+
readonly eventId: string;
|
|
1123
|
+
readonly sequence: number;
|
|
1124
|
+
}[];
|
|
1125
|
+
readonly artifacts: readonly {
|
|
1126
|
+
readonly artifactId: string;
|
|
1127
|
+
}[];
|
|
1128
|
+
}
|
|
1129
|
+
export interface DhAckRejection {
|
|
1130
|
+
id: string;
|
|
1131
|
+
code: DhRejectionCode;
|
|
1132
|
+
retryable: boolean;
|
|
1133
|
+
}
|
|
1134
|
+
/** `none` is the explicit empty prefix. With no accepted ids, ackedThroughSequence only repeats the previous watermark (0 when nothing was acknowledged): it never means sequence 0 was accepted. */
|
|
1135
|
+
export type DhAckEventPrefix = {
|
|
1136
|
+
readonly kind: "none";
|
|
1137
|
+
} | {
|
|
1138
|
+
readonly kind: "prefix";
|
|
1139
|
+
readonly throughSequence: number;
|
|
1140
|
+
readonly eventIds: readonly string[];
|
|
1141
|
+
};
|
|
1142
|
+
export interface DhBatchAckResult {
|
|
1143
|
+
readonly ack: DhAckV1;
|
|
1144
|
+
readonly eventPrefix: DhAckEventPrefix;
|
|
1145
|
+
readonly eventRejections: readonly DhAckRejection[];
|
|
1146
|
+
/** Batch ACK artifact entries are metadata receipts. Bytes are acknowledged only by a dh.artifact-receipt/1 from the PUT. */
|
|
1147
|
+
readonly artifactMetadata: {
|
|
1148
|
+
readonly accepted: readonly string[];
|
|
1149
|
+
readonly rejected: readonly DhAckRejection[];
|
|
1150
|
+
};
|
|
1151
|
+
readonly bytesAcknowledged: false;
|
|
1152
|
+
}
|
|
1153
|
+
/** Value of `previousAckedSequence` when no event has been acknowledged yet (the uploader cursor's initial `-1`). */
|
|
1154
|
+
export declare const DH_ACK_NO_PREVIOUS_SEQUENCE = -1;
|
|
1155
|
+
/**
|
|
1156
|
+
* Validates a dh.ack/1 against the batch that was actually sent. The ACK must name the same stream and
|
|
1157
|
+
* only sent ids; accepted and rejected are disjoint; accepted events are exactly the first k sent events
|
|
1158
|
+
* by sequence (k may be 0).
|
|
1159
|
+
*
|
|
1160
|
+
* `previousAckedSequence` is REQUIRED: the stream's current acknowledged watermark, or
|
|
1161
|
+
* DH_ACK_NO_PREVIOUS_SEQUENCE (-1) when nothing is acknowledged yet. The accepted prefix must be gap-free
|
|
1162
|
+
* and start at previous + 1, so `[0,10,20]` cannot be acknowledged as one prefix. For k > 0,
|
|
1163
|
+
* ackedThroughSequence is the prefix's last sequence. For k = 0 it must repeat the previous watermark
|
|
1164
|
+
* (0 when previous is -1, because dh.ack/1 cannot carry a negative value and the empty accepted list
|
|
1165
|
+
* disambiguates), so an empty ACK can neither advance nor regress the stream.
|
|
1166
|
+
*/
|
|
1167
|
+
export declare function validateDhBatchAck(sent: DhAckSentBatch, ackInput: unknown, options: {
|
|
1168
|
+
previousAckedSequence: number;
|
|
1169
|
+
}): DhBatchAckResult;
|
|
1170
|
+
/**
|
|
1171
|
+
* Response to PUT artifacts/{artifactId}/content. Names only the requested artifact and carries no
|
|
1172
|
+
* sequence, event id or watermark, so it cannot advance an event cursor or acknowledge metadata.
|
|
1173
|
+
*/
|
|
1174
|
+
export declare const parseDhArtifactReceipt: (value: unknown) => {
|
|
1175
|
+
readonly schema: "dh.artifact-receipt/1";
|
|
1176
|
+
readonly artifactId: string;
|
|
1177
|
+
readonly sha256: string;
|
|
1178
|
+
readonly sizeBytes?: number | undefined;
|
|
1179
|
+
readonly state: "rejected" | "stored";
|
|
1180
|
+
readonly rejection?: {
|
|
1181
|
+
readonly code: "duplicate_conflict" | "rate_limited" | "schema_invalid" | "scope_denied" | "tombstoned" | "too_large";
|
|
1182
|
+
readonly retryable: boolean;
|
|
1183
|
+
} | undefined;
|
|
1184
|
+
readonly receivedAt: string;
|
|
1185
|
+
};
|
|
1186
|
+
export type DhArtifactReceiptV1 = ReturnType<typeof parseDhArtifactReceipt>;
|
|
1187
|
+
export interface DhArtifactPutRequest {
|
|
1188
|
+
artifactId: string;
|
|
1189
|
+
sha256: string;
|
|
1190
|
+
sizeBytes?: number;
|
|
1191
|
+
}
|
|
1192
|
+
export declare function validateDhArtifactReceipt(requested: DhArtifactPutRequest, receiptInput: unknown): DhArtifactReceiptV1;
|
|
1193
|
+
/** Same id, same canonical bytes is an idempotent redelivery; the same id with different bytes is a conflict and never overwrites. */
|
|
1194
|
+
export declare function classifyDhDuplicate(existing: unknown, incoming: unknown): "identical" | "conflict";
|
|
1195
|
+
export declare const DH_CONTROL_SUPPORT: readonly ["required", "unsupported"];
|
|
1196
|
+
export type DhControlSupport = (typeof DH_CONTROL_SUPPORT)[number];
|
|
1197
|
+
export interface DhRuntimeCapabilities {
|
|
1198
|
+
readonly controls: Readonly<{
|
|
1199
|
+
backgroundStatus: DhControlSupport;
|
|
1200
|
+
cancelSelected: DhControlSupport;
|
|
1201
|
+
cancelWholeRun: DhControlSupport;
|
|
1202
|
+
continueLive: DhControlSupport;
|
|
1203
|
+
retryFresh: DhControlSupport;
|
|
1204
|
+
}>;
|
|
1205
|
+
readonly modes: readonly string[];
|
|
1206
|
+
readonly unsupportedModes: readonly string[];
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* "required" means the implementation and a positive qualification check are mandatory for full
|
|
1210
|
+
* completion; an `unsupported` reply never satisfies it. "unsupportedModes" cannot claim full capture.
|
|
1211
|
+
*/
|
|
1212
|
+
export declare const DH_SUPPORTED_RUNTIMES: {
|
|
1213
|
+
"cli-node": DhRuntimeCapabilities;
|
|
1214
|
+
"cli-bun": DhRuntimeCapabilities;
|
|
1215
|
+
flow: {
|
|
1216
|
+
controls: {
|
|
1217
|
+
readonly backgroundStatus: "required";
|
|
1218
|
+
readonly cancelSelected: "required";
|
|
1219
|
+
readonly cancelWholeRun: "required";
|
|
1220
|
+
readonly continueLive: "required";
|
|
1221
|
+
readonly retryFresh: "required";
|
|
1222
|
+
};
|
|
1223
|
+
modes: string[];
|
|
1224
|
+
unsupportedModes: never[];
|
|
1225
|
+
};
|
|
1226
|
+
};
|
|
1227
|
+
export type DhRuntimeId = keyof typeof DH_SUPPORTED_RUNTIMES;
|
|
1228
|
+
/**
|
|
1229
|
+
* Public shape of the safe host capability `getFlowTraceProducer(ctx: ExtensionContext):
|
|
1230
|
+
* FlowTraceProducer | undefined`, implemented and exported by the CLI (`@humain/humain-code`, C14).
|
|
1231
|
+
* This package ships no implementation, recorder, config, token or transport. The host validates and
|
|
1232
|
+
* narrows every input, binds `issuer=flow`/`via=flow` provenance and re-checks the live binding on each call.
|
|
1233
|
+
*/
|
|
1234
|
+
export interface FlowTraceIdentity {
|
|
1235
|
+
readonly generationId: string;
|
|
1236
|
+
readonly agentId: string;
|
|
1237
|
+
readonly attemptId: string;
|
|
1238
|
+
readonly environmentId: string;
|
|
1239
|
+
readonly projectId: string;
|
|
1240
|
+
/** Actual segment admission identity and epoch, never fabricated by the host. */
|
|
1241
|
+
readonly bindingId: string;
|
|
1242
|
+
readonly bindingEpoch: string;
|
|
1243
|
+
/** Independent host session epoch; replacement disables stale capabilities. */
|
|
1244
|
+
readonly sessionEpoch: string;
|
|
1245
|
+
}
|
|
1246
|
+
export interface FlowTraceEventInput {
|
|
1247
|
+
kind: DhEventKind;
|
|
1248
|
+
agentId?: string;
|
|
1249
|
+
parentAgentId?: string;
|
|
1250
|
+
attemptId?: string;
|
|
1251
|
+
attemptNumber?: number;
|
|
1252
|
+
retryOfAttemptId?: string;
|
|
1253
|
+
outcome?: DhOutcome;
|
|
1254
|
+
failure?: {
|
|
1255
|
+
code: string;
|
|
1256
|
+
message?: string;
|
|
1257
|
+
};
|
|
1258
|
+
payload: Record<string, unknown>;
|
|
1259
|
+
fields?: Record<string, DhCoverage>;
|
|
1260
|
+
removedFieldPaths?: readonly string[];
|
|
1261
|
+
artifacts?: readonly string[];
|
|
1262
|
+
eventId?: string;
|
|
1263
|
+
}
|
|
1264
|
+
export interface TraceChildEnv {
|
|
1265
|
+
/** Variables to set on the child process environment. */
|
|
1266
|
+
set: Record<string, string>;
|
|
1267
|
+
/** Variables to delete from the child process environment. */
|
|
1268
|
+
unset: string[];
|
|
1269
|
+
}
|
|
1270
|
+
export interface FlowTraceProducer {
|
|
1271
|
+
readonly identity: Readonly<FlowTraceIdentity>;
|
|
1272
|
+
recordEvent(input: FlowTraceEventInput): string | undefined;
|
|
1273
|
+
eventIdForToolCall(toolCallId: string): string | undefined;
|
|
1274
|
+
beginChildAgent(input: {
|
|
1275
|
+
logicalTaskId: string;
|
|
1276
|
+
nativeLaunchId: string;
|
|
1277
|
+
parentEventId: string;
|
|
1278
|
+
externalIds: readonly DhExternalId[];
|
|
1279
|
+
}): string;
|
|
1280
|
+
beginChildAttempt(agentId: string, input: {
|
|
1281
|
+
attemptNumber: number;
|
|
1282
|
+
retryOfAttemptId?: string;
|
|
1283
|
+
externalIds: readonly DhExternalId[];
|
|
1284
|
+
}): {
|
|
1285
|
+
attemptId: string;
|
|
1286
|
+
env: TraceChildEnv;
|
|
1287
|
+
};
|
|
1288
|
+
finishChildAttempt(agentId: string, attemptId: string, outcome: DhOutcome, failure?: {
|
|
1289
|
+
code: string;
|
|
1290
|
+
message?: string;
|
|
1291
|
+
}): string | undefined;
|
|
1292
|
+
recordRetryScheduled(agentId: string, failedAttemptId: string, nextAttemptNumber: number, delayMs: number): string | undefined;
|
|
1293
|
+
}
|
|
1294
|
+
//# sourceMappingURL=trace-http.d.ts.map
|