-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.ts
More file actions
377 lines (356 loc) · 11.2 KB
/
Copy pathapi.ts
File metadata and controls
377 lines (356 loc) · 11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
export interface Account {
login: string;
type: string;
id: number;
}
export interface Repository {
id: string;
name: string;
}
export interface IssueOrPR {
id: string;
title: string;
isPR: boolean;
url: string;
}
export interface RepoFile {
path: string;
type: string;
sha: string;
}
export interface AgenticExecutionSummary {
canonicalType: string;
family: 'asset-pack' | 'read-measurement' | 'proof-refresh' | 'upgrade' | 'agentic-execution';
label: string;
lens: 'deposit' | 'read' | 'closure';
proofStatus: string;
closureFocus: string;
}
/** Response from GET /api/executions?action=installations */
export interface InstallationResponse {
accounts: Account[];
}
/** Buyer-repo pull request surface on settle delivery. */
export interface SettleDeliveryPullRequest {
url: string;
number?: number;
title?: string;
type: 'pr';
}
export type AssetPackFileChanges = {
edited: number;
created: number;
deleted: number;
paths?: string[];
charDiff?: {
edited: number;
created: number;
deleted: number;
};
};
export type AssetPackSurface = {
pullRequest?: SettleDeliveryPullRequest | null;
fileChanges?: AssetPackFileChanges | null;
summary?: string | null;
};
export type AssetPackSynthesisArtifactsSurface = AssetPackSurface & {
proofEvidence?: string[] | null;
reviewNotes?: string[] | null;
};
export interface CompletionData {
/** Full markdown summary of work completed */
summary: string;
/** Primary display string or title */
display: string;
/**
* Buyer-repo delivery after settle Simple (PR URL/summary). Sole field name
* for that surface (pre-production: no shippables alias).
*/
settleDelivery?: AssetPackSurface | null;
/** Bitcode-owned implementation-phase AssetPack synthesis artifacts. */
assetPackSynthesisArtifacts?: AssetPackSynthesisArtifactsSurface | null;
/** Semantic reread of the AssetPack synthesis artifacts. */
writtenAssets?: AssetPackSurface | null;
/** Delivery mechanism projected onto connected interfaces. */
deliveryMechanism?: AssetPackSurface | null;
semanticKind?: 'asset-pack-written-asset';
read?: string | null;
writtenAssetType?: string | null;
assetPack?: {
read?: string | null;
writtenAssetType?: string | null;
definitionOfRead?: string | null;
deliveryTarget?: string | null;
} | null;
/** Total time in milliseconds */
duration: number;
/** Type of task executed */
taskType: string;
/** Processing statistics (runtime metrics) */
processingStats?: {
/** Human-readable duration, e.g. "4m 18s" */
time: string;
/** Token usage counts */
tokens?: {
input: number;
output: number;
total: number;
};
/** Measured non-fungible $BTD content amount */
measuredBtd?: number;
btdSemantics?: 'non_fungible_asset_pack_share_read_right' | string;
feeAsset?: 'BTC' | string;
btcFeesPaid?: number | null;
btcFeeUsdEquivalent?: number;
};
/** Snapshot of the repository at time of execution */
repoSnapshot?: {
org: string;
repo: string;
branch: string;
commit: string;
};
}
export interface UrlEntry {
url: string;
title: string;
origin: string;
status?: 'success' | 'error';
}
/** History line item attached to a pipeline execution row. */
export interface PipelineExecutionHistoryItem {
id: string;
title: string;
output?: string | null;
repository?: string | null;
delivery_type: 'pr';
delivery_id?: string | null;
delivery_status?: string | null;
attached_urls?: any;
selected_files?: any;
created_at: string;
run_id: string;
}
// Wrapper object representing a single AssetPack pipeline execution.
export interface PipelineExecution {
id: string;
created_at: string;
guide?: string | null;
type?: string | null;
agentic_execution?: AgenticExecutionSummary | null;
status?: string;
output?: Record<string, any> | null;
metadata?: Record<string, any> | null;
items: PipelineExecutionHistoryItem[];
/**
* Arbitrary JSON context blob attached to the run. Current pipelines attach
* a rich object matching `GlobalContext` (see `lib/context`). Keep this
* loosely typed so callers can narrow as needed.
*/
context?: Record<string, any> | string | null;
/** Optional markdown summary stored by backend */
summary?: string | null;
/** product failure payload from executions.error (source-safe message). */
error?: { message?: string | null } | string | null;
/** Execution metrics (time, tokens, measured $BTD, BTC fee posture, latency) */
processing_stats?: {
time: string;
tokens?: { input: number; output: number; total: number };
measuredBtd?: number;
btdSemantics?: 'non_fungible_asset_pack_share_read_right' | string;
feeAsset?: 'BTC' | string;
btcFeesPaid?: number | null;
btcFeeUsdEquivalent?: number;
averageLatencyMs?: number | null;
modelUsage?: Array<{
provider: string;
model: string;
callCount: number;
totalTokens: number;
inputTokens: number;
outputTokens: number;
totalCostUsd: number;
averageLatencyMs: number | null;
}>;
} | null;
/** Repository snapshot meta */
repo_snapshot?: { org: string; repo: string; branch: string; commit: string } | null;
/** Bitcode-owned implementation-phase AssetPack synthesis artifacts. */
asset_pack_synthesis_artifacts?: AssetPackSynthesisArtifactsSurface | null;
/** Semantic reread of the AssetPack synthesis artifacts. */
written_assets?: AssetPackSurface | null;
/**
* Buyer-repo delivery after settle Simple. History projection of settleDelivery.
*/
settle_delivery?: AssetPackSurface | null;
/** Delivery mechanism projected onto the connected pull-request interface. */
delivery_mechanism?: AssetPackSurface | null;
read?: string | null;
written_asset_type?: string | null;
asset_pack?: {
read?: string | null;
writtenAssetType?: string | null;
definitionOfRead?: string | null;
deliveryTarget?: string | null;
} | null;
/** Canonical AssetPack completion payload. */
asset_pack_completion?: {
summary?: string | null;
/** Buyer-repo delivery after settle Simple (sole field name). */
settleDelivery?: AssetPackSurface;
/** Bitcode-owned implementation-phase AssetPack synthesis artifacts. */
assetPackSynthesisArtifacts?: AssetPackSynthesisArtifactsSurface;
/** Semantic reread of the AssetPack synthesis artifacts. */
writtenAssets?: AssetPackSurface;
/** Delivery mechanism projected onto connected interfaces. */
deliveryMechanism?: AssetPackSurface;
read?: string | null;
writtenAssetType?: string | null;
assetPack?: {
read?: string | null;
writtenAssetType?: string | null;
definitionOfRead?: string | null;
deliveryTarget?: string | null;
};
processingStats?: {
time: string;
tokens?: { input: number; output: number; total: number };
measuredBtd?: number;
btdSemantics?: 'non_fungible_asset_pack_share_read_right' | string;
feeAsset?: 'BTC' | string;
btcFeesPaid?: number | null;
btcFeeUsdEquivalent?: number;
averageLatencyMs?: number | null;
modelUsage?: Array<{
provider: string;
model: string;
callCount: number;
totalTokens: number;
inputTokens: number;
outputTokens: number;
totalCostUsd: number;
averageLatencyMs: number | null;
}>;
};
repoSnapshot?: { org: string; repo: string; branch: string; commit: string };
} | null;
}
// Record type for a single Evidence Document history item.
export interface EvidenceDocumentHistoryItem {
id: string;
title: string;
output?: string | null;
repository?: string | null;
evidenceDocumentType: string;
metrics?: any;
created_at: string;
run_id: string;
}
// Wrapper object representing a single user run that may contain multiple Evidence Documents.
export interface EvidenceDocumentRun {
id: string;
created_at: string;
items: EvidenceDocumentHistoryItem[];
summary?: string | null;
processing_stats?: {
time: string;
tokens?: { input: number; output: number; total: number };
measuredBtd?: number;
btdSemantics?: 'non_fungible_asset_pack_share_read_right' | string;
feeAsset?: 'BTC' | string;
btcFeesPaid?: number | null;
btcFeeUsdEquivalent?: number;
averageLatencyMs?: number | null;
modelUsage?: Array<{
provider: string;
model: string;
callCount: number;
totalTokens: number;
inputTokens: number;
outputTokens: number;
totalCostUsd: number;
averageLatencyMs: number | null;
}>;
} | null;
repo_snapshot?: { org: string; repo: string; branch: string; commit: string } | null;
asset_pack_synthesis_artifacts?: { summary?: string | null } | null;
written_assets?: { summary?: string | null } | null;
settle_delivery?: { summary?: string | null } | null;
read?: string | null;
written_asset_type?: string | null;
asset_pack?: {
read?: string | null;
writtenAssetType?: string | null;
definitionOfRead?: string | null;
deliveryTarget?: string | null;
} | null;
asset_pack_completion?: {
summary?: string | null;
settleDelivery?: { summary?: string | null };
assetPackSynthesisArtifacts?: { summary?: string | null };
writtenAssets?: { summary?: string | null };
read?: string | null;
writtenAssetType?: string | null;
assetPack?: {
read?: string | null;
writtenAssetType?: string | null;
definitionOfRead?: string | null;
deliveryTarget?: string | null;
};
processingStats?: {
time: string;
tokens?: { input: number; output: number; total: number };
measuredBtd?: number;
btdSemantics?: 'non_fungible_asset_pack_share_read_right' | string;
feeAsset?: 'BTC' | string;
btcFeesPaid?: number | null;
btcFeeUsdEquivalent?: number;
averageLatencyMs?: number | null;
modelUsage?: Array<{
provider: string;
model: string;
callCount: number;
totalTokens: number;
inputTokens: number;
outputTokens: number;
totalCostUsd: number;
averageLatencyMs: number | null;
}>;
};
repoSnapshot?: { org: string; repo: string; branch: string; commit: string };
} | null;
}
// Unified postprocessed result type
export type PipelineResultArtifacts = {
filesCreated: string[];
filesModified: string[];
testsAdded: number;
testsPassing?: number;
documentation: string[];
};
export type ValidationReadySnapshot = {
approved: boolean;
assessment?: unknown | null;
confidence?: number | null;
};
export type PostprocessedResult = {
executionId: string;
kind: 'settle_delivery' | 'multi_settle_delivery' | 'evidence_document';
title: string;
repository?: string;
summary?: string;
artifacts?: PipelineResultArtifacts | null;
validationReady?: ValidationReadySnapshot;
entries?: PostprocessedResult[];
series?: PostprocessedResult[];
evidenceDocumentType?: string;
output?: string;
};
// Route Pipeline Execution – Preprocessed (top-level)
export type RoutePreprocessed = {
assetPackWrittenAsset?: {
preprocessing: { multi: boolean; compute: boolean };
selectedPipeline: 'multi' | 'standard';
provisioning: 'requested' | 'skipped' | 'ready' | 'failed';
};
};