@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,425 @@
|
|
|
1
|
+
import { type Static, Type } from "typebox";
|
|
2
|
+
import { type DhArtifactV1, type DhEventKind, type DhEventV1, type DhTerminalOwnership } from "./trace.ts";
|
|
3
|
+
export declare const DH_PAYLOAD_SCHEMA_IDS: Readonly<{
|
|
4
|
+
readonly agentRelation: "dh.payload.agent-relation/1";
|
|
5
|
+
readonly agentSpawn: "dh.payload.agent-spawn/1";
|
|
6
|
+
readonly amendment: "dh.payload.amendment/1";
|
|
7
|
+
readonly attemptLifecycle: "dh.payload.attempt-lifecycle/1";
|
|
8
|
+
readonly captureHealth: "dh.payload.capture-health/1";
|
|
9
|
+
readonly continuationDecision: "dh.payload.continuation-decision/1";
|
|
10
|
+
readonly controlCorrelation: "dh.payload.control-correlation/1";
|
|
11
|
+
readonly fileEvidence: "dh.payload.file-evidence/1";
|
|
12
|
+
readonly flowDecision: "dh.payload.flow-decision/1";
|
|
13
|
+
readonly localCancellation: "dh.payload.local-cancellation/1";
|
|
14
|
+
readonly modelResponse: "dh.payload.model-response/1";
|
|
15
|
+
readonly modelSubmission: "dh.payload.model-submission/1";
|
|
16
|
+
readonly toolCall: "dh.payload.tool-call/1";
|
|
17
|
+
readonly toolResult: "dh.payload.tool-result/1";
|
|
18
|
+
readonly usage: "dh.payload.usage/1";
|
|
19
|
+
}>;
|
|
20
|
+
export type DhPayloadSchemaId = (typeof DH_PAYLOAD_SCHEMA_IDS)[keyof typeof DH_PAYLOAD_SCHEMA_IDS];
|
|
21
|
+
/** Kinds that existed before typed payloads. They may keep a freeform payload without `schema`. */
|
|
22
|
+
export declare const DH_LEGACY_FREEFORM_PAYLOAD_KINDS: readonly DhEventKind[];
|
|
23
|
+
/** Kinds introduced with typed payloads; `payload.schema` is mandatory. */
|
|
24
|
+
export declare const DH_PAYLOAD_REQUIRED_KINDS: readonly DhEventKind[];
|
|
25
|
+
/**
|
|
26
|
+
* Continuation decisions recorded on `orchestration.decision` (dh.payload.continuation-decision/1).
|
|
27
|
+
* `consumed` is the only consumption event type: a control `continue` is `applied` only when the addressed
|
|
28
|
+
* target recorded `continuation.consumed` for that request (admitted, pending and rejected are not consumption).
|
|
29
|
+
*/
|
|
30
|
+
export declare const DH_CONTINUATION_DECISIONS: readonly ["continuation.pending", "continuation.admitted", "continuation.rejected", "continuation.consumed"];
|
|
31
|
+
export type DhContinuationDecision = (typeof DH_CONTINUATION_DECISIONS)[number];
|
|
32
|
+
/** Delivery channel of a continuation. `queue-steering` is never a live continuation of a running child. */
|
|
33
|
+
export declare const DH_CONTINUATION_CHANNELS: readonly ["live-child", "native-descendant", "run-root", "queue-steering", "internal"];
|
|
34
|
+
export type DhContinuationChannel = (typeof DH_CONTINUATION_CHANNELS)[number];
|
|
35
|
+
/** Named observations from the existing local process-cancellation seam; never arbitrary diagnostic text. */
|
|
36
|
+
export declare const DH_LOCAL_CANCELLATION_DIAGNOSTICS: readonly ["cancelled_before_spawn", "logical_cancellation_observed", "process_closed_after_signal"];
|
|
37
|
+
export type DhLocalCancellationDiagnostic = (typeof DH_LOCAL_CANCELLATION_DIAGNOSTICS)[number];
|
|
38
|
+
/** Payload schema ids accepted on a kind (empty for kinds that only carry legacy freeform payloads). */
|
|
39
|
+
export declare function dhPayloadSchemaIdsForKind(kind: DhEventKind): readonly DhPayloadSchemaId[];
|
|
40
|
+
declare function modelSubmissionSchema(): Type.TObject<{
|
|
41
|
+
readonly schema: Type.TLiteral<"dh.payload.model-submission/1">;
|
|
42
|
+
readonly requestId: Type.TString;
|
|
43
|
+
readonly submissionId: Type.TString;
|
|
44
|
+
readonly attemptId: Type.TString;
|
|
45
|
+
readonly transportRetryIndex: Type.TInteger;
|
|
46
|
+
readonly provider: Type.TString;
|
|
47
|
+
readonly api: Type.TString;
|
|
48
|
+
readonly model: Type.TString;
|
|
49
|
+
readonly operation: Type.TEnum<["chat", "image", "classifier", "auxiliary"]>;
|
|
50
|
+
readonly purpose: Type.TOptional<Type.TEnum<["chat", "compaction", "branch-summary", "cache-warming"]>>;
|
|
51
|
+
readonly transport: Type.TEnum<["http", "websocket"]>;
|
|
52
|
+
readonly representation: Type.TEnum<["json-body", "json-frame"]>;
|
|
53
|
+
readonly adapterVersion: Type.TOptional<Type.TString>;
|
|
54
|
+
readonly requestArtifact: Type.TOptional<Type.TObject<{
|
|
55
|
+
readonly artifactId: Type.TString;
|
|
56
|
+
readonly sha256: Type.TString;
|
|
57
|
+
readonly sizeBytes: Type.TOptional<Type.TInteger>;
|
|
58
|
+
}>>;
|
|
59
|
+
}>;
|
|
60
|
+
export type DhModelSubmissionPayload = Static<ReturnType<typeof modelSubmissionSchema>>;
|
|
61
|
+
declare function modelResponseSchema(): Type.TObject<{
|
|
62
|
+
readonly schema: Type.TLiteral<"dh.payload.model-response/1">;
|
|
63
|
+
readonly submissionId: Type.TString;
|
|
64
|
+
readonly attemptId: Type.TString;
|
|
65
|
+
readonly stopReason: Type.TEnum<["pending", "stop", "length", "toolUse", "error", "aborted", "deferred"]>;
|
|
66
|
+
readonly provider: Type.TOptional<Type.TString>;
|
|
67
|
+
readonly api: Type.TOptional<Type.TString>;
|
|
68
|
+
readonly model: Type.TOptional<Type.TString>;
|
|
69
|
+
readonly responseModel: Type.TOptional<Type.TString>;
|
|
70
|
+
readonly toolCallCount: Type.TOptional<Type.TInteger>;
|
|
71
|
+
readonly text: Type.TOptional<Type.TString>;
|
|
72
|
+
readonly reasoning: Type.TOptional<Type.TString>;
|
|
73
|
+
readonly errorMessage: Type.TOptional<Type.TString>;
|
|
74
|
+
readonly responseArtifact: Type.TOptional<Type.TObject<{
|
|
75
|
+
readonly artifactId: Type.TString;
|
|
76
|
+
readonly sha256: Type.TString;
|
|
77
|
+
readonly sizeBytes: Type.TOptional<Type.TInteger>;
|
|
78
|
+
}>>;
|
|
79
|
+
readonly usage: Type.TOptional<Type.TObject<{
|
|
80
|
+
readonly origin: Type.TUnion<[Type.TObject<{
|
|
81
|
+
readonly owner: Type.TLiteral<"submission">;
|
|
82
|
+
readonly submissionId: Type.TString;
|
|
83
|
+
}>, Type.TObject<{
|
|
84
|
+
readonly owner: Type.TLiteral<"attempt">;
|
|
85
|
+
readonly attemptId: Type.TString;
|
|
86
|
+
}>, Type.TObject<{
|
|
87
|
+
readonly owner: Type.TLiteral<"flow-aggregate">;
|
|
88
|
+
readonly inclusive: Type.TLiteral<true>;
|
|
89
|
+
}>]>;
|
|
90
|
+
readonly measurement: Type.TUnion<[Type.TObject<{
|
|
91
|
+
readonly state: Type.TLiteral<"unknown">;
|
|
92
|
+
}>, Type.TObject<{
|
|
93
|
+
readonly state: Type.TLiteral<"reported">;
|
|
94
|
+
readonly input: Type.TOptional<Type.TInteger>;
|
|
95
|
+
readonly output: Type.TOptional<Type.TInteger>;
|
|
96
|
+
readonly cacheRead: Type.TOptional<Type.TInteger>;
|
|
97
|
+
readonly cacheWrite: Type.TOptional<Type.TInteger>;
|
|
98
|
+
readonly reasoning: Type.TOptional<Type.TInteger>;
|
|
99
|
+
readonly totalTokens: Type.TOptional<Type.TInteger>;
|
|
100
|
+
readonly durationMs: Type.TOptional<Type.TInteger>;
|
|
101
|
+
readonly cost: Type.TUnion<[Type.TObject<{
|
|
102
|
+
readonly state: Type.TLiteral<"unknown">;
|
|
103
|
+
}>, Type.TObject<{
|
|
104
|
+
readonly state: Type.TLiteral<"known">;
|
|
105
|
+
readonly amount: Type.TNumber;
|
|
106
|
+
readonly currency: Type.TString;
|
|
107
|
+
readonly priceProvenance: Type.TString;
|
|
108
|
+
}>]>;
|
|
109
|
+
}>]>;
|
|
110
|
+
}>>;
|
|
111
|
+
}>;
|
|
112
|
+
export type DhModelResponsePayload = Static<ReturnType<typeof modelResponseSchema>>;
|
|
113
|
+
/**
|
|
114
|
+
* The typed call carries no free `arguments` object: the shared DTO parser scans every nested key for
|
|
115
|
+
* instant-named fields (`startedAt`, `occurredAt`, ...), so arbitrary tool arguments would be rejected on a
|
|
116
|
+
* name collision. Arguments travel as a bounded redacted JSON-text preview and/or a complete artifact; a
|
|
117
|
+
* truncated preview is marked in the envelope `fields` at `payload.argumentsPreview`.
|
|
118
|
+
*/
|
|
119
|
+
declare function toolCallSchema(): Type.TObject<{
|
|
120
|
+
readonly schema: Type.TLiteral<"dh.payload.tool-call/1">;
|
|
121
|
+
readonly callId: Type.TString;
|
|
122
|
+
readonly toolName: Type.TString;
|
|
123
|
+
readonly argumentsPreview: Type.TOptional<Type.TString>;
|
|
124
|
+
readonly argumentsArtifact: Type.TOptional<Type.TObject<{
|
|
125
|
+
readonly artifactId: Type.TString;
|
|
126
|
+
readonly sha256: Type.TString;
|
|
127
|
+
readonly sizeBytes: Type.TOptional<Type.TInteger>;
|
|
128
|
+
}>>;
|
|
129
|
+
/** Provenance of a nested call: the enclosing call's id and (when recorded) its tool.call event. */
|
|
130
|
+
readonly parentCallId: Type.TOptional<Type.TString>;
|
|
131
|
+
readonly parentEventId: Type.TOptional<Type.TString>;
|
|
132
|
+
}>;
|
|
133
|
+
export type DhToolCallPayload = Static<ReturnType<typeof toolCallSchema>>;
|
|
134
|
+
declare function toolResultSchema(): Type.TObject<{
|
|
135
|
+
readonly schema: Type.TLiteral<"dh.payload.tool-result/1">;
|
|
136
|
+
readonly callId: Type.TString;
|
|
137
|
+
readonly toolName: Type.TString;
|
|
138
|
+
readonly stage: Type.TEnum<["original", "final"]>;
|
|
139
|
+
readonly source: Type.TEnum<["executed", "blocked", "synthetic"]>;
|
|
140
|
+
readonly isError: Type.TBoolean;
|
|
141
|
+
readonly modified: Type.TOptional<Type.TBoolean>;
|
|
142
|
+
readonly originalResultEventId: Type.TOptional<Type.TString>;
|
|
143
|
+
readonly parentCallId: Type.TOptional<Type.TString>;
|
|
144
|
+
readonly output: Type.TOptional<Type.TString>;
|
|
145
|
+
readonly outputArtifact: Type.TOptional<Type.TObject<{
|
|
146
|
+
readonly artifactId: Type.TString;
|
|
147
|
+
readonly sha256: Type.TString;
|
|
148
|
+
readonly sizeBytes: Type.TOptional<Type.TInteger>;
|
|
149
|
+
}>>;
|
|
150
|
+
readonly nonTextBlockCount: Type.TInteger;
|
|
151
|
+
readonly nonTextArtifacts: Type.TOptional<Type.TArray<Type.TObject<{
|
|
152
|
+
readonly artifactId: Type.TString;
|
|
153
|
+
readonly sha256: Type.TString;
|
|
154
|
+
readonly sizeBytes: Type.TOptional<Type.TInteger>;
|
|
155
|
+
}>>>;
|
|
156
|
+
readonly childAgentId: Type.TOptional<Type.TString>;
|
|
157
|
+
readonly childAgentIds: Type.TOptional<Type.TArray<Type.TString>>;
|
|
158
|
+
}>;
|
|
159
|
+
export type DhToolResultPayload = Static<ReturnType<typeof toolResultSchema>>;
|
|
160
|
+
declare function fileEvidenceSchema(): Type.TObject<{
|
|
161
|
+
readonly schema: Type.TLiteral<"dh.payload.file-evidence/1">;
|
|
162
|
+
readonly callId: Type.TString;
|
|
163
|
+
readonly toolName: Type.TString;
|
|
164
|
+
readonly operation: Type.TEnum<["write", "edit", "delete"]>;
|
|
165
|
+
readonly outcome: Type.TEnum<["succeeded", "failed", "cancelled"]>;
|
|
166
|
+
readonly intent: Type.TObject<{
|
|
167
|
+
readonly contentSha256: Type.TOptional<Type.TString>;
|
|
168
|
+
readonly contentBytes: Type.TOptional<Type.TInteger>;
|
|
169
|
+
readonly patchSha256: Type.TOptional<Type.TString>;
|
|
170
|
+
}>;
|
|
171
|
+
readonly observed: Type.TObject<{
|
|
172
|
+
readonly before: Type.TUnion<[Type.TObject<{
|
|
173
|
+
readonly state: Type.TLiteral<"observed">;
|
|
174
|
+
readonly sha256: Type.TString;
|
|
175
|
+
readonly sizeBytes: Type.TInteger;
|
|
176
|
+
}>, Type.TObject<{
|
|
177
|
+
readonly state: Type.TLiteral<"unavailable">;
|
|
178
|
+
readonly reason: Type.TEnum<["missing", "denied", "oversized", "binary", "unsupported", "read-failed"]>;
|
|
179
|
+
}>]>;
|
|
180
|
+
readonly after: Type.TUnion<[Type.TObject<{
|
|
181
|
+
readonly state: Type.TLiteral<"observed">;
|
|
182
|
+
readonly sha256: Type.TString;
|
|
183
|
+
readonly sizeBytes: Type.TInteger;
|
|
184
|
+
}>, Type.TObject<{
|
|
185
|
+
readonly state: Type.TLiteral<"unavailable">;
|
|
186
|
+
readonly reason: Type.TEnum<["missing", "denied", "oversized", "binary", "unsupported", "read-failed"]>;
|
|
187
|
+
}>]>;
|
|
188
|
+
readonly effectObserved: Type.TBoolean;
|
|
189
|
+
}>;
|
|
190
|
+
readonly pathRef: Type.TObject<{
|
|
191
|
+
readonly artifactId: Type.TString;
|
|
192
|
+
readonly sha256: Type.TString;
|
|
193
|
+
readonly sizeBytes: Type.TOptional<Type.TInteger>;
|
|
194
|
+
}>;
|
|
195
|
+
readonly evidence: Type.TOptional<Type.TArray<Type.TObject<{
|
|
196
|
+
readonly artifactId: Type.TString;
|
|
197
|
+
readonly sha256: Type.TString;
|
|
198
|
+
readonly sizeBytes: Type.TOptional<Type.TInteger>;
|
|
199
|
+
readonly role: Type.TEnum<["diff", "snapshot"]>;
|
|
200
|
+
}>>>;
|
|
201
|
+
readonly worktree: Type.TOptional<Type.TObject<{
|
|
202
|
+
readonly mode: Type.TEnum<["shared", "isolated", "degraded-to-shared"]>;
|
|
203
|
+
readonly baseRevision: Type.TOptional<Type.TString>;
|
|
204
|
+
readonly endRevision: Type.TOptional<Type.TString>;
|
|
205
|
+
readonly baseObserved: Type.TBoolean;
|
|
206
|
+
}>>;
|
|
207
|
+
}>;
|
|
208
|
+
export type DhFileEvidencePayload = Static<ReturnType<typeof fileEvidenceSchema>>;
|
|
209
|
+
declare function agentSpawnSchema(): Type.TObject<{
|
|
210
|
+
readonly schema: Type.TLiteral<"dh.payload.agent-spawn/1">;
|
|
211
|
+
readonly via: Type.TEnum<["subagent", "flow"]>;
|
|
212
|
+
readonly spawnedByEventId: Type.TOptional<Type.TString>;
|
|
213
|
+
readonly launchedByToolCallEventId: Type.TOptional<Type.TString>;
|
|
214
|
+
readonly command: Type.TOptional<Type.TObject<{
|
|
215
|
+
readonly name: Type.TString;
|
|
216
|
+
readonly decisionEventId: Type.TOptional<Type.TString>;
|
|
217
|
+
}>>;
|
|
218
|
+
readonly logicalTaskId: Type.TOptional<Type.TString>;
|
|
219
|
+
readonly nativeLaunchId: Type.TOptional<Type.TString>;
|
|
220
|
+
}>;
|
|
221
|
+
export type DhAgentSpawnPayload = Static<ReturnType<typeof agentSpawnSchema>>;
|
|
222
|
+
/** Cross-agent relation (native Code retry): a NEW agent linked to its source, never a same-agent retryOfAttemptId. */
|
|
223
|
+
declare function agentRelationSchema(): Type.TObject<{
|
|
224
|
+
readonly schema: Type.TLiteral<"dh.payload.agent-relation/1">;
|
|
225
|
+
readonly via: Type.TLiteral<"native-code">;
|
|
226
|
+
readonly relation: Type.TLiteral<"native-retry">;
|
|
227
|
+
readonly sourceAgentId: Type.TString;
|
|
228
|
+
readonly sourceAttemptId: Type.TString;
|
|
229
|
+
readonly reasonCode: Type.TOptional<Type.TString>;
|
|
230
|
+
}>;
|
|
231
|
+
export type DhAgentRelationPayload = Static<ReturnType<typeof agentRelationSchema>>;
|
|
232
|
+
declare function attemptLifecycleSchema(): Type.TObject<{
|
|
233
|
+
readonly schema: Type.TLiteral<"dh.payload.attempt-lifecycle/1">;
|
|
234
|
+
readonly phase: Type.TEnum<["started", "finished", "retry-scheduled"]>;
|
|
235
|
+
readonly agentId: Type.TString;
|
|
236
|
+
readonly attemptId: Type.TString;
|
|
237
|
+
readonly attemptNumber: Type.TOptional<Type.TInteger>;
|
|
238
|
+
readonly retryOfAttemptId: Type.TOptional<Type.TString>;
|
|
239
|
+
readonly retryReason: Type.TOptional<Type.TString>;
|
|
240
|
+
readonly nextAttemptNumber: Type.TOptional<Type.TInteger>;
|
|
241
|
+
readonly delayMs: Type.TOptional<Type.TInteger>;
|
|
242
|
+
readonly spawnOutcome: Type.TOptional<Type.TEnum<["spawned", "failed-to-spawn", "unknown"]>>;
|
|
243
|
+
readonly terminationConfirmed: Type.TOptional<Type.TBoolean>;
|
|
244
|
+
}>;
|
|
245
|
+
export type DhAttemptLifecyclePayload = Static<ReturnType<typeof attemptLifecycleSchema>>;
|
|
246
|
+
declare function flowDecisionSchema(): Type.TObject<{
|
|
247
|
+
readonly schema: Type.TLiteral<"dh.payload.flow-decision/1">;
|
|
248
|
+
readonly decision: Type.TEnum<["schedule", "delegate", "dependency-not-launched", "dependency-released", "retry"]>;
|
|
249
|
+
readonly issuer: Type.TLiteral<"flow">;
|
|
250
|
+
readonly via: Type.TLiteral<"flow">;
|
|
251
|
+
readonly mode: Type.TEnum<["single", "parallel", "chain", "hierarchy"]>;
|
|
252
|
+
/** A command launch has no tool call: the two variants share no event-id field. */
|
|
253
|
+
readonly provenance: Type.TUnion<[Type.TObject<{
|
|
254
|
+
readonly source: Type.TLiteral<"tool-call">;
|
|
255
|
+
readonly toolCallEventId: Type.TString;
|
|
256
|
+
}>, Type.TObject<{
|
|
257
|
+
readonly source: Type.TLiteral<"command">;
|
|
258
|
+
readonly command: Type.TString;
|
|
259
|
+
readonly commandEventId: Type.TOptional<Type.TString>;
|
|
260
|
+
}>, Type.TObject<{
|
|
261
|
+
readonly source: Type.TLiteral<"internal">;
|
|
262
|
+
}>]>;
|
|
263
|
+
readonly logicalTaskId: Type.TOptional<Type.TString>;
|
|
264
|
+
readonly dependencies: Type.TOptional<Type.TArray<Type.TString>>;
|
|
265
|
+
readonly causeEventId: Type.TOptional<Type.TString>;
|
|
266
|
+
readonly childAgentId: Type.TOptional<Type.TString>;
|
|
267
|
+
readonly failedAttemptId: Type.TOptional<Type.TString>;
|
|
268
|
+
readonly nextAttemptNumber: Type.TOptional<Type.TInteger>;
|
|
269
|
+
readonly delayMs: Type.TOptional<Type.TInteger>;
|
|
270
|
+
readonly wave: Type.TOptional<Type.TInteger>;
|
|
271
|
+
readonly order: Type.TOptional<Type.TInteger>;
|
|
272
|
+
readonly policyVersion: Type.TOptional<Type.TString>;
|
|
273
|
+
readonly reasonCode: Type.TOptional<Type.TString>;
|
|
274
|
+
}>;
|
|
275
|
+
export type DhFlowDecisionPayload = Static<ReturnType<typeof flowDecisionSchema>>;
|
|
276
|
+
/**
|
|
277
|
+
* A continuation decision about one addressed target (agent + attempt). `pending` and `consumed` are recorded
|
|
278
|
+
* by the target itself; `admitted` and `rejected` may be recorded by the admitting authority. `requestId`
|
|
279
|
+
* links a decision to a control `continue` request; a continuation that no request caused names none. Message
|
|
280
|
+
* text never appears here: it is content, and would also be free text inside a typed payload.
|
|
281
|
+
*/
|
|
282
|
+
declare function continuationDecisionSchema(): Type.TObject<{
|
|
283
|
+
readonly schema: Type.TLiteral<"dh.payload.continuation-decision/1">;
|
|
284
|
+
readonly decision: Type.TEnum<["continuation.pending", "continuation.admitted", "continuation.rejected", "continuation.consumed"]>;
|
|
285
|
+
readonly target: Type.TObject<{
|
|
286
|
+
readonly agentId: Type.TString;
|
|
287
|
+
readonly attemptId: Type.TString;
|
|
288
|
+
}>;
|
|
289
|
+
readonly requestId: Type.TOptional<Type.TString>;
|
|
290
|
+
readonly channel: Type.TEnum<["live-child", "native-descendant", "run-root", "queue-steering", "internal"]>;
|
|
291
|
+
readonly reason: Type.TOptional<Type.TEnum<["not_authorized", "scope_mismatch", "stale_epoch", "target_settled", "not_eligible", "policy_denied", "budget_exhausted", "workspace_unavailable"]>>;
|
|
292
|
+
}>;
|
|
293
|
+
export type DhContinuationDecisionPayload = Static<ReturnType<typeof continuationDecisionSchema>>;
|
|
294
|
+
declare function usageSchema(): Type.TObject<{
|
|
295
|
+
readonly schema: Type.TLiteral<"dh.payload.usage/1">;
|
|
296
|
+
readonly usageId: Type.TString;
|
|
297
|
+
readonly origin: Type.TUnion<[Type.TObject<{
|
|
298
|
+
readonly owner: Type.TLiteral<"submission">;
|
|
299
|
+
readonly submissionId: Type.TString;
|
|
300
|
+
}>, Type.TObject<{
|
|
301
|
+
readonly owner: Type.TLiteral<"attempt">;
|
|
302
|
+
readonly attemptId: Type.TString;
|
|
303
|
+
}>, Type.TObject<{
|
|
304
|
+
readonly owner: Type.TLiteral<"flow-aggregate">;
|
|
305
|
+
readonly inclusive: Type.TLiteral<true>;
|
|
306
|
+
}>]>;
|
|
307
|
+
readonly measurement: Type.TUnion<[Type.TObject<{
|
|
308
|
+
readonly state: Type.TLiteral<"unknown">;
|
|
309
|
+
}>, Type.TObject<{
|
|
310
|
+
readonly state: Type.TLiteral<"reported">;
|
|
311
|
+
readonly input: Type.TOptional<Type.TInteger>;
|
|
312
|
+
readonly output: Type.TOptional<Type.TInteger>;
|
|
313
|
+
readonly cacheRead: Type.TOptional<Type.TInteger>;
|
|
314
|
+
readonly cacheWrite: Type.TOptional<Type.TInteger>;
|
|
315
|
+
readonly reasoning: Type.TOptional<Type.TInteger>;
|
|
316
|
+
readonly totalTokens: Type.TOptional<Type.TInteger>;
|
|
317
|
+
readonly durationMs: Type.TOptional<Type.TInteger>;
|
|
318
|
+
readonly cost: Type.TUnion<[Type.TObject<{
|
|
319
|
+
readonly state: Type.TLiteral<"unknown">;
|
|
320
|
+
}>, Type.TObject<{
|
|
321
|
+
readonly state: Type.TLiteral<"known">;
|
|
322
|
+
readonly amount: Type.TNumber;
|
|
323
|
+
readonly currency: Type.TString;
|
|
324
|
+
readonly priceProvenance: Type.TString;
|
|
325
|
+
}>]>;
|
|
326
|
+
}>]>;
|
|
327
|
+
}>;
|
|
328
|
+
export type DhUsagePayload = Static<ReturnType<typeof usageSchema>>;
|
|
329
|
+
declare function captureHealthSchema(): Type.TObject<{
|
|
330
|
+
readonly schema: Type.TLiteral<"dh.payload.capture-health/1">;
|
|
331
|
+
readonly status: Type.TEnum<["healthy", "degraded", "failed", "recovered"]>;
|
|
332
|
+
readonly condition: Type.TEnum<["none", "dropped", "write_failed", "redaction_failed", "unsupported_adapter", "flush_timeout", "lost_observer", "recovery"]>;
|
|
333
|
+
readonly droppedEvents: Type.TOptional<Type.TInteger>;
|
|
334
|
+
readonly droppedArtifacts: Type.TOptional<Type.TInteger>;
|
|
335
|
+
readonly adapter: Type.TOptional<Type.TObject<{
|
|
336
|
+
readonly name: Type.TString;
|
|
337
|
+
readonly version: Type.TString;
|
|
338
|
+
}>>;
|
|
339
|
+
readonly affectedKinds: Type.TOptional<Type.TArray<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"]>>>;
|
|
340
|
+
readonly coverageGaps: Type.TOptional<Type.TArray<Type.TObject<{
|
|
341
|
+
readonly path: Type.TString;
|
|
342
|
+
readonly state: Type.TEnum<["captured", "redacted", "truncated", "unavailable", "not-applicable", "inferred"]>;
|
|
343
|
+
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"]>>;
|
|
344
|
+
}>>>;
|
|
345
|
+
readonly sequenceRange: Type.TOptional<Type.TObject<{
|
|
346
|
+
readonly from: Type.TInteger;
|
|
347
|
+
readonly to: Type.TInteger;
|
|
348
|
+
}>>;
|
|
349
|
+
}>;
|
|
350
|
+
export type DhCaptureHealthPayload = Static<ReturnType<typeof captureHealthSchema>>;
|
|
351
|
+
declare function controlCorrelationSchema(): Type.TObject<{
|
|
352
|
+
readonly schema: Type.TLiteral<"dh.payload.control-correlation/1">;
|
|
353
|
+
readonly requestId: Type.TString;
|
|
354
|
+
readonly action: Type.TEnum<["cancel", "retry", "continue"]>;
|
|
355
|
+
readonly phase: Type.TEnum<["requested", "observed"]>;
|
|
356
|
+
readonly state: Type.TEnum<["requested", "accepted", "delivered", "applied", "rejected", "unsupported", "unknown"]>;
|
|
357
|
+
readonly reason: Type.TOptional<Type.TEnum<["not_authorized", "scope_mismatch", "stale_epoch", "target_settled", "not_eligible", "policy_denied", "budget_exhausted", "workspace_unavailable"]>>;
|
|
358
|
+
readonly terminationConfirmed: Type.TOptional<Type.TBoolean>;
|
|
359
|
+
readonly observed: Type.TOptional<Type.TObject<{
|
|
360
|
+
readonly startedAgentId: Type.TOptional<Type.TString>;
|
|
361
|
+
readonly startedAttemptId: Type.TOptional<Type.TString>;
|
|
362
|
+
readonly consumingEventId: Type.TOptional<Type.TString>;
|
|
363
|
+
}>>;
|
|
364
|
+
}>;
|
|
365
|
+
export type DhControlCorrelationPayload = Static<ReturnType<typeof controlCorrelationSchema>>;
|
|
366
|
+
/** Local cancellation is not a Code control request: there is deliberately no requestId. */
|
|
367
|
+
declare function localCancellationSchema(): Type.TObject<{
|
|
368
|
+
readonly schema: Type.TLiteral<"dh.payload.local-cancellation/1">;
|
|
369
|
+
readonly requester: Type.TLiteral<"local">;
|
|
370
|
+
readonly scope: Type.TEnum<["selected", "whole-run"]>;
|
|
371
|
+
readonly phase: Type.TEnum<["requested", "observed"]>;
|
|
372
|
+
readonly state: Type.TEnum<["requested", "applied", "rejected", "unsupported", "unknown"]>;
|
|
373
|
+
readonly reason: Type.TOptional<Type.TEnum<["not_authorized", "scope_mismatch", "stale_epoch", "target_settled", "not_eligible", "policy_denied", "budget_exhausted", "workspace_unavailable"]>>;
|
|
374
|
+
readonly diagnosticCode: Type.TOptional<Type.TEnum<["cancelled_before_spawn", "logical_cancellation_observed", "process_closed_after_signal"]>>;
|
|
375
|
+
readonly terminationConfirmed: Type.TOptional<Type.TBoolean>;
|
|
376
|
+
readonly exitCode: Type.TOptional<Type.TInteger>;
|
|
377
|
+
}>;
|
|
378
|
+
export type DhLocalCancellationPayload = Static<ReturnType<typeof localCancellationSchema>>;
|
|
379
|
+
declare function amendmentSchema(): Type.TObject<{
|
|
380
|
+
readonly schema: Type.TLiteral<"dh.payload.amendment/1">;
|
|
381
|
+
readonly amendsEventId: Type.TString;
|
|
382
|
+
readonly amendsKind: 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"]>;
|
|
383
|
+
readonly relation: Type.TEnum<["supersedes", "resolves-unknown"]>;
|
|
384
|
+
readonly reasonCode: Type.TString;
|
|
385
|
+
readonly coverage: Type.TOptional<Type.TArray<Type.TObject<{
|
|
386
|
+
readonly path: Type.TString;
|
|
387
|
+
readonly state: Type.TEnum<["captured", "redacted", "truncated", "unavailable", "not-applicable", "inferred"]>;
|
|
388
|
+
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"]>>;
|
|
389
|
+
}>>>;
|
|
390
|
+
readonly replacement: Type.TOptional<Type.TObject<{
|
|
391
|
+
readonly outcome: Type.TEnum<["succeeded", "failed", "cancelled", "unknown"]>;
|
|
392
|
+
readonly failureCode: Type.TOptional<Type.TString>;
|
|
393
|
+
}>>;
|
|
394
|
+
}>;
|
|
395
|
+
export type DhAmendmentPayload = Static<ReturnType<typeof amendmentSchema>>;
|
|
396
|
+
/**
|
|
397
|
+
* Enforces the payload contract on one event. Legacy kinds without `payload.schema` pass; everything
|
|
398
|
+
* else must name a registered (kind, schema id) pair and satisfy that schema and its envelope rules.
|
|
399
|
+
* Called by `parseDhEvent` on the trusted clone.
|
|
400
|
+
*/
|
|
401
|
+
export declare function assertDhEventPayload(event: DhEventV1): void;
|
|
402
|
+
/**
|
|
403
|
+
* Cross-event rules over already-parsed events. Legacy freeform events are ignored. Returns one message per
|
|
404
|
+
* violation (never throws); `validateDhTraceBundle` appends these to its own errors. Nothing here rewrites or
|
|
405
|
+
* reinterprets an original event: amendments are separate events that point at their target.
|
|
406
|
+
*
|
|
407
|
+
* One pass builds the indexes (events by id, attempts by agent, attempt starts, relations, confirmed
|
|
408
|
+
* terminations); every rule after it is a Map/Set lookup, so the cost is linear in the number of events
|
|
409
|
+
* (no per-event scan of `events`, no per-event array copy).
|
|
410
|
+
*/
|
|
411
|
+
export declare function validateDhPayloadGraph(events: readonly DhEventV1[], artifacts?: readonly DhArtifactV1[], ownership?: DhTerminalOwnership): string[];
|
|
412
|
+
interface DhControlEvidenceTarget {
|
|
413
|
+
readonly generationId: string;
|
|
414
|
+
readonly agentId: string;
|
|
415
|
+
readonly attemptId?: string;
|
|
416
|
+
readonly requestId?: string;
|
|
417
|
+
}
|
|
418
|
+
interface DhControlObserved {
|
|
419
|
+
readonly startedAgentId?: string;
|
|
420
|
+
readonly startedAttemptId?: string;
|
|
421
|
+
readonly consumingEventId?: string;
|
|
422
|
+
}
|
|
423
|
+
export declare function assertDhAppliedControlEvidence(target: DhControlEvidenceTarget, action: "retry" | "continue", observed: DhControlObserved, events: readonly DhEventV1[]): void;
|
|
424
|
+
export {};
|
|
425
|
+
//# sourceMappingURL=trace-payload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace-payload.d.ts","sourceRoot":"","sources":["../src/trace-payload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgB,IAAI,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAON,KAAK,YAAY,EAGjB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,mBAAmB,EAExB,MAAM,YAAY,CAAC;AAuBpB,eAAO,MAAM,qBAAqB;4BAClB,6BAA6B;yBAChC,0BAA0B;wBAC3B,wBAAwB;+BACjB,gCAAgC;4BACnC,6BAA6B;mCACtB,oCAAoC;iCACtC,kCAAkC;2BACxC,4BAA4B;2BAC5B,4BAA4B;gCACvB,iCAAiC;4BACrC,6BAA6B;8BAC3B,+BAA+B;uBACtC,wBAAwB;yBACtB,0BAA0B;oBAC/B,oBAAoB;EACjB,CAAC;AACZ,MAAM,MAAM,iBAAiB,GAAG,C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