ai-data-workflow-contract 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.ts +289 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -169,3 +169,292 @@ export interface AIDataWorkflowPlanProjection {
|
|
|
169
169
|
export type AIDataWorkflowRunCheckpoint = FlowRunCheckpoint<
|
|
170
170
|
AIDataWorkflowRunProfileState<AIDataWorkflowRunGraph>
|
|
171
171
|
>;
|
|
172
|
+
|
|
173
|
+
export const AI_DATA_CONTROL_SCHEMA_VERSION = 'depa.ai-data-control/v1' as const;
|
|
174
|
+
|
|
175
|
+
export type AIDataControlSchemaVersion = typeof AI_DATA_CONTROL_SCHEMA_VERSION;
|
|
176
|
+
|
|
177
|
+
export interface AIDataControlGoal {
|
|
178
|
+
readonly schemaVersion: AIDataControlSchemaVersion;
|
|
179
|
+
readonly goalId: string;
|
|
180
|
+
readonly objective: string;
|
|
181
|
+
readonly verifierRef: `resource://${string}`;
|
|
182
|
+
readonly requiredOutputSchemaRef: string;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export interface AIDataControlBudgetLimits {
|
|
186
|
+
readonly maxIterations: number;
|
|
187
|
+
readonly maxOperationsPerDecision: number;
|
|
188
|
+
readonly maxNoProgressIterations: number;
|
|
189
|
+
readonly maxTokens?: number;
|
|
190
|
+
readonly deadlineEpochMs?: number;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export interface AIDataControlBudgetUsage {
|
|
194
|
+
readonly iteration: number;
|
|
195
|
+
readonly noProgressIterations: number;
|
|
196
|
+
readonly tokensUsed?: number;
|
|
197
|
+
readonly nowEpochMs?: number;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export interface AIDataControlBudget {
|
|
201
|
+
readonly schemaVersion: AIDataControlSchemaVersion;
|
|
202
|
+
readonly limits: AIDataControlBudgetLimits;
|
|
203
|
+
readonly usage: AIDataControlBudgetUsage;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export interface AIDataControlBudgetProjection {
|
|
207
|
+
readonly iteration: number;
|
|
208
|
+
readonly remainingIterations: number;
|
|
209
|
+
readonly remainingOperations: number;
|
|
210
|
+
readonly noProgressIterations: number;
|
|
211
|
+
readonly remainingNoProgressIterations: number;
|
|
212
|
+
readonly remainingTokens?: number;
|
|
213
|
+
readonly remainingMs?: number;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export interface AIDataControlNodeContract {
|
|
217
|
+
readonly protected: boolean;
|
|
218
|
+
readonly inputSchemaRefs: Readonly<Record<string, string>>;
|
|
219
|
+
readonly outputSchemaRefs: Readonly<Record<string, string>>;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export interface AIDataControlCodeCapabilityImplementation {
|
|
223
|
+
readonly kind: 'code';
|
|
224
|
+
readonly codeRef: `resource://${string}`;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export interface AIDataControlAgentCapabilityImplementation {
|
|
228
|
+
readonly kind: 'agent';
|
|
229
|
+
readonly agentDefinitionRef: `resource://${string}`;
|
|
230
|
+
readonly taskProofRef: `resource://${string}`;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export type AIDataControlCapabilityImplementation =
|
|
234
|
+
| AIDataControlCodeCapabilityImplementation
|
|
235
|
+
| AIDataControlAgentCapabilityImplementation;
|
|
236
|
+
|
|
237
|
+
export interface AIDataControlCapability {
|
|
238
|
+
readonly capabilityId: string;
|
|
239
|
+
readonly tag: 'TransformNode' | 'SinkNode';
|
|
240
|
+
readonly nodeType: AIWorkflowNodeType;
|
|
241
|
+
readonly inputSchemaRefs: Readonly<Record<string, string>>;
|
|
242
|
+
readonly outputSchemaRefs: Readonly<Record<string, string>>;
|
|
243
|
+
readonly fixedConfig: AIDataWorkflowNodeConfig;
|
|
244
|
+
readonly implementation: AIDataControlCapabilityImplementation;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export interface AIDataControlCapabilityCatalog {
|
|
248
|
+
readonly schemaVersion: AIDataControlSchemaVersion;
|
|
249
|
+
readonly catalogId: string;
|
|
250
|
+
readonly digest: string;
|
|
251
|
+
readonly foundationNodes: Readonly<Record<string, AIDataControlNodeContract>>;
|
|
252
|
+
readonly capabilities: Readonly<Record<string, AIDataControlCapability>>;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export type AIDataControlVerifierStatus = 'not-run' | 'passed' | 'failed';
|
|
256
|
+
|
|
257
|
+
export interface AIDataControlDiagnostic {
|
|
258
|
+
readonly code: string;
|
|
259
|
+
readonly message: string;
|
|
260
|
+
readonly nodeId?: string;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export interface AIDataControlVerifierFact {
|
|
264
|
+
readonly schemaVersion: AIDataControlSchemaVersion;
|
|
265
|
+
readonly factId: string;
|
|
266
|
+
readonly goalId: string;
|
|
267
|
+
readonly graphGeneration: number;
|
|
268
|
+
readonly status: AIDataControlVerifierStatus;
|
|
269
|
+
readonly verifierRef: `resource://${string}`;
|
|
270
|
+
readonly requiredOutputSchemaRef: string;
|
|
271
|
+
readonly diagnostics: readonly AIDataControlDiagnostic[];
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export interface AIDataControlObservedNode {
|
|
275
|
+
readonly nodeId: string;
|
|
276
|
+
readonly tag: AIDataWorkflowNodeTag;
|
|
277
|
+
readonly nodeType: AIWorkflowNodeType;
|
|
278
|
+
readonly status: AIDataWorkflowRunNodeStatus;
|
|
279
|
+
readonly protected: boolean;
|
|
280
|
+
readonly capabilityId?: string;
|
|
281
|
+
readonly dependsOn: readonly string[];
|
|
282
|
+
readonly inputSchemaRefs: Readonly<Record<string, string>>;
|
|
283
|
+
readonly outputSchemaRefs: Readonly<Record<string, string>>;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export interface AIDataControlGraphObservation {
|
|
287
|
+
readonly runId: string;
|
|
288
|
+
readonly generation: number;
|
|
289
|
+
readonly digest: string;
|
|
290
|
+
readonly nodes: readonly AIDataControlObservedNode[];
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export type AIDataControlFeedbackCode =
|
|
294
|
+
| 'SCHEMA_VERSION_MISMATCH'
|
|
295
|
+
| 'GOAL_MISMATCH'
|
|
296
|
+
| 'CATALOG_MISMATCH'
|
|
297
|
+
| 'STALE_OBSERVATION'
|
|
298
|
+
| 'BUDGET_EXHAUSTED'
|
|
299
|
+
| 'INVALID_OPERATION_COUNT'
|
|
300
|
+
| 'DUPLICATE_TARGET'
|
|
301
|
+
| 'PROTECTED_NODE'
|
|
302
|
+
| 'UNKNOWN_CAPABILITY'
|
|
303
|
+
| 'UNKNOWN_NODE'
|
|
304
|
+
| 'INPUT_CONTRACT_MISMATCH'
|
|
305
|
+
| 'OUTPUT_CONTRACT_MISMATCH'
|
|
306
|
+
| 'NO_PROGRESS'
|
|
307
|
+
| 'VERIFIER_REQUIRED'
|
|
308
|
+
| 'VERIFIER_MISMATCH'
|
|
309
|
+
| 'INVALID_DECISION';
|
|
310
|
+
|
|
311
|
+
export interface AIDataControlFeedback {
|
|
312
|
+
readonly code: AIDataControlFeedbackCode;
|
|
313
|
+
readonly message: string;
|
|
314
|
+
readonly operationIndex?: number;
|
|
315
|
+
readonly nodeId?: string;
|
|
316
|
+
readonly port?: string;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export interface AIDataControlObservation {
|
|
320
|
+
readonly schemaVersion: AIDataControlSchemaVersion;
|
|
321
|
+
readonly observationId: string;
|
|
322
|
+
readonly observationDigest: string;
|
|
323
|
+
readonly goalId: string;
|
|
324
|
+
readonly catalogDigest: string;
|
|
325
|
+
readonly graph: AIDataControlGraphObservation;
|
|
326
|
+
readonly verifier: AIDataControlVerifierFact;
|
|
327
|
+
readonly budget: AIDataControlBudgetProjection;
|
|
328
|
+
readonly feedback: readonly AIDataControlFeedback[];
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export interface AIDataControlPortInputBinding {
|
|
332
|
+
readonly kind: 'port';
|
|
333
|
+
readonly nodeId: string;
|
|
334
|
+
readonly port: string;
|
|
335
|
+
readonly schemaRef: string;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export interface AIDataControlLiteralInputBinding {
|
|
339
|
+
readonly kind: 'literal';
|
|
340
|
+
readonly schemaRef: string;
|
|
341
|
+
readonly value: EagerDataFlowValue;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export type AIDataControlInputBinding =
|
|
345
|
+
| AIDataControlPortInputBinding
|
|
346
|
+
| AIDataControlLiteralInputBinding;
|
|
347
|
+
|
|
348
|
+
export interface AIDataControlAddCapabilityOperation {
|
|
349
|
+
readonly op: 'add-capability';
|
|
350
|
+
readonly nodeId: string;
|
|
351
|
+
readonly capabilityId: string;
|
|
352
|
+
readonly inputs: Readonly<Record<string, AIDataControlInputBinding>>;
|
|
353
|
+
readonly dependsOn?: readonly string[];
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export interface AIDataControlRewireCapabilityOperation {
|
|
357
|
+
readonly op: 'rewire-capability';
|
|
358
|
+
readonly nodeId: string;
|
|
359
|
+
readonly capabilityId: string;
|
|
360
|
+
readonly inputs: Readonly<Record<string, AIDataControlInputBinding>>;
|
|
361
|
+
readonly dependsOn?: readonly string[];
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export interface AIDataControlRemoveNodeOperation {
|
|
365
|
+
readonly op: 'remove-node';
|
|
366
|
+
readonly nodeId: string;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export type AIDataControlRevisionOperation =
|
|
370
|
+
| AIDataControlAddCapabilityOperation
|
|
371
|
+
| AIDataControlRewireCapabilityOperation
|
|
372
|
+
| AIDataControlRemoveNodeOperation;
|
|
373
|
+
|
|
374
|
+
interface AIDataControlDecisionBase {
|
|
375
|
+
readonly schemaVersion: AIDataControlSchemaVersion;
|
|
376
|
+
readonly decisionId: string;
|
|
377
|
+
readonly goalId: string;
|
|
378
|
+
readonly observationId: string;
|
|
379
|
+
readonly observationDigest: string;
|
|
380
|
+
readonly catalogDigest: string;
|
|
381
|
+
readonly reason: string;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
export interface AIDataControlReviseDecision extends AIDataControlDecisionBase {
|
|
385
|
+
readonly kind: 'revise';
|
|
386
|
+
readonly operations: readonly AIDataControlRevisionOperation[];
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
export interface AIDataControlCompleteDecision extends AIDataControlDecisionBase {
|
|
390
|
+
readonly kind: 'complete';
|
|
391
|
+
readonly verifierFactId: string;
|
|
392
|
+
readonly outputNodeId: string;
|
|
393
|
+
readonly outputPort: string;
|
|
394
|
+
readonly outputSchemaRef: string;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
export type AIDataControlFailureCode =
|
|
398
|
+
| 'CONTROLLER_DECLARED_FAILURE'
|
|
399
|
+
| 'GOAL_UNREACHABLE'
|
|
400
|
+
| 'BUDGET_EXHAUSTED'
|
|
401
|
+
| 'NO_PROGRESS';
|
|
402
|
+
|
|
403
|
+
export interface AIDataControlFailDecision extends AIDataControlDecisionBase {
|
|
404
|
+
readonly kind: 'fail';
|
|
405
|
+
readonly failureCode: AIDataControlFailureCode;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export type AIDataControlDecision =
|
|
409
|
+
| AIDataControlReviseDecision
|
|
410
|
+
| AIDataControlCompleteDecision
|
|
411
|
+
| AIDataControlFailDecision;
|
|
412
|
+
|
|
413
|
+
interface AIDataControlAdmissionBase {
|
|
414
|
+
readonly schemaVersion: AIDataControlSchemaVersion;
|
|
415
|
+
readonly decisionId: string;
|
|
416
|
+
readonly decisionDigest: string;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export interface AIDataControlPatchAdmission extends AIDataControlAdmissionBase {
|
|
420
|
+
readonly kind: 'patch';
|
|
421
|
+
readonly patch: AIDataWorkflowGraphPatch;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
export interface AIDataControlCompletionAdmission extends AIDataControlAdmissionBase {
|
|
425
|
+
readonly kind: 'complete';
|
|
426
|
+
readonly verifierFactId: string;
|
|
427
|
+
readonly outputNodeId: string;
|
|
428
|
+
readonly outputPort: string;
|
|
429
|
+
readonly outputSchemaRef: string;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
export interface AIDataControlFailureAdmission extends AIDataControlAdmissionBase {
|
|
433
|
+
readonly kind: 'fail';
|
|
434
|
+
readonly failureCode: AIDataControlFailureCode;
|
|
435
|
+
readonly reason: string;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
export interface AIDataControlRejectedAdmission extends AIDataControlAdmissionBase {
|
|
439
|
+
readonly kind: 'rejected';
|
|
440
|
+
readonly feedback: readonly AIDataControlFeedback[];
|
|
441
|
+
readonly terminal: boolean;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
export type AIDataControlAdmission =
|
|
445
|
+
| AIDataControlPatchAdmission
|
|
446
|
+
| AIDataControlCompletionAdmission
|
|
447
|
+
| AIDataControlFailureAdmission
|
|
448
|
+
| AIDataControlRejectedAdmission;
|
|
449
|
+
|
|
450
|
+
export interface AIDataControlIterationReceipt {
|
|
451
|
+
readonly schemaVersion: AIDataControlSchemaVersion;
|
|
452
|
+
readonly iteration: number;
|
|
453
|
+
readonly observationId: string;
|
|
454
|
+
readonly observationDigest: string;
|
|
455
|
+
readonly decisionId: string;
|
|
456
|
+
readonly decisionDigest: string;
|
|
457
|
+
readonly admissionKind: AIDataControlAdmission['kind'];
|
|
458
|
+
readonly generationBefore: number;
|
|
459
|
+
readonly generationAfter: number;
|
|
460
|
+
}
|