@arke-institute/sdk 0.1.0 → 0.1.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/dist/{index.d.mts → client-dAk3E64p.d.cts} +1 -7
- package/dist/client-dAk3E64p.d.ts +183 -0
- package/dist/{index.mjs → collections/index.cjs} +34 -5
- package/dist/collections/index.cjs.map +1 -0
- package/dist/collections/index.d.cts +9 -0
- package/dist/collections/index.d.ts +9 -1
- package/dist/collections/index.js +5 -32
- package/dist/collections/index.js.map +1 -1
- package/dist/content/index.cjs +506 -0
- package/dist/content/index.cjs.map +1 -0
- package/dist/content/index.d.cts +403 -0
- package/dist/content/index.d.ts +403 -0
- package/dist/content/index.js +473 -0
- package/dist/content/index.js.map +1 -0
- package/dist/edit/index.cjs +1029 -0
- package/dist/edit/index.cjs.map +1 -0
- package/dist/edit/index.d.cts +78 -0
- package/dist/edit/index.d.ts +78 -0
- package/dist/edit/index.js +983 -0
- package/dist/edit/index.js.map +1 -0
- package/dist/errors-3L7IiHcr.d.cts +480 -0
- package/dist/errors-B82BMmRP.d.cts +343 -0
- package/dist/errors-B82BMmRP.d.ts +343 -0
- package/dist/errors-BTe8GKRQ.d.ts +480 -0
- package/dist/graph/index.cjs +433 -0
- package/dist/graph/index.cjs.map +1 -0
- package/dist/graph/index.d.cts +456 -0
- package/dist/graph/index.d.ts +456 -0
- package/dist/graph/index.js +402 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/index.cjs +3761 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -189
- package/dist/index.js +3502 -30
- package/dist/index.js.map +1 -1
- package/dist/query/index.cjs +289 -0
- package/dist/query/index.cjs.map +1 -0
- package/dist/query/index.d.cts +541 -0
- package/dist/query/index.d.ts +541 -0
- package/dist/query/index.js +261 -0
- package/dist/query/index.js.map +1 -0
- package/dist/upload/index.cjs +1634 -0
- package/dist/upload/index.cjs.map +1 -0
- package/dist/upload/index.d.cts +150 -0
- package/dist/upload/index.d.ts +150 -0
- package/dist/upload/index.js +1597 -0
- package/dist/upload/index.js.map +1 -0
- package/package.json +43 -8
- package/dist/collections/index.d.mts +0 -1
- package/dist/collections/index.mjs +0 -204
- package/dist/collections/index.mjs.map +0 -1
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Arke SDK - Edit Package Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
type EditMode = 'ai-prompt' | 'manual-with-review' | 'manual-only';
|
|
5
|
+
interface EditSessionConfig {
|
|
6
|
+
mode: EditMode;
|
|
7
|
+
aiReviewEnabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface Entity {
|
|
10
|
+
pi: string;
|
|
11
|
+
ver: number;
|
|
12
|
+
ts: string;
|
|
13
|
+
manifest_cid: string;
|
|
14
|
+
components: Record<string, string>;
|
|
15
|
+
children_pi: string[];
|
|
16
|
+
parent_pi?: string;
|
|
17
|
+
note?: string;
|
|
18
|
+
}
|
|
19
|
+
interface EntityUpdate {
|
|
20
|
+
expect_tip: string;
|
|
21
|
+
components?: Record<string, string>;
|
|
22
|
+
components_remove?: string[];
|
|
23
|
+
note: string;
|
|
24
|
+
}
|
|
25
|
+
interface EntityVersion {
|
|
26
|
+
pi: string;
|
|
27
|
+
tip: string;
|
|
28
|
+
ver: number;
|
|
29
|
+
}
|
|
30
|
+
type RegeneratableComponent = 'pinax' | 'description' | 'cheimarros';
|
|
31
|
+
interface EditScope {
|
|
32
|
+
components: RegeneratableComponent[];
|
|
33
|
+
cascade: boolean;
|
|
34
|
+
stopAtPi?: string;
|
|
35
|
+
}
|
|
36
|
+
interface Correction {
|
|
37
|
+
original: string;
|
|
38
|
+
corrected: string;
|
|
39
|
+
sourceFile?: string;
|
|
40
|
+
context?: string;
|
|
41
|
+
}
|
|
42
|
+
type DiffType = 'addition' | 'deletion' | 'change' | 'unchanged';
|
|
43
|
+
interface TextDiff {
|
|
44
|
+
type: DiffType;
|
|
45
|
+
original?: string;
|
|
46
|
+
modified?: string;
|
|
47
|
+
lineNumber?: number;
|
|
48
|
+
context?: string;
|
|
49
|
+
}
|
|
50
|
+
interface ComponentDiff {
|
|
51
|
+
componentName: string;
|
|
52
|
+
diffs: TextDiff[];
|
|
53
|
+
summary: string;
|
|
54
|
+
hasChanges: boolean;
|
|
55
|
+
}
|
|
56
|
+
type PromptTarget = RegeneratableComponent | 'general' | 'reorganization';
|
|
57
|
+
interface EntityContext {
|
|
58
|
+
pi: string;
|
|
59
|
+
ver: number;
|
|
60
|
+
parentPi?: string;
|
|
61
|
+
childrenCount: number;
|
|
62
|
+
currentContent: Record<string, string>;
|
|
63
|
+
}
|
|
64
|
+
interface CascadeContext {
|
|
65
|
+
path: string[];
|
|
66
|
+
depth: number;
|
|
67
|
+
stopAtPi?: string;
|
|
68
|
+
}
|
|
69
|
+
interface CustomPrompts {
|
|
70
|
+
general?: string;
|
|
71
|
+
pinax?: string;
|
|
72
|
+
description?: string;
|
|
73
|
+
cheimarros?: string;
|
|
74
|
+
reorganization?: string;
|
|
75
|
+
}
|
|
76
|
+
interface ReprocessRequest {
|
|
77
|
+
pi: string;
|
|
78
|
+
phases: RegeneratableComponent[];
|
|
79
|
+
cascade: boolean;
|
|
80
|
+
options?: {
|
|
81
|
+
stop_at_pi?: string;
|
|
82
|
+
custom_prompts?: CustomPrompts;
|
|
83
|
+
custom_note?: string;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
interface ReprocessResult {
|
|
87
|
+
batch_id: string;
|
|
88
|
+
entities_queued: number;
|
|
89
|
+
entity_pis: string[];
|
|
90
|
+
status_url: string;
|
|
91
|
+
}
|
|
92
|
+
type ReprocessPhase = 'QUEUED' | 'DISCOVERY' | 'OCR_IN_PROGRESS' | 'REORGANIZATION' | 'PINAX_EXTRACTION' | 'CHEIMARROS_EXTRACTION' | 'DESCRIPTION' | 'DONE' | 'ERROR';
|
|
93
|
+
interface ReprocessProgress {
|
|
94
|
+
directories_total: number;
|
|
95
|
+
directories_pinax_complete: number;
|
|
96
|
+
directories_cheimarros_complete: number;
|
|
97
|
+
directories_description_complete: number;
|
|
98
|
+
}
|
|
99
|
+
interface ReprocessStatus {
|
|
100
|
+
batch_id: string;
|
|
101
|
+
status: ReprocessPhase;
|
|
102
|
+
progress: ReprocessProgress;
|
|
103
|
+
root_pi?: string;
|
|
104
|
+
error?: string;
|
|
105
|
+
started_at?: string;
|
|
106
|
+
completed_at?: string;
|
|
107
|
+
}
|
|
108
|
+
interface SaveResult {
|
|
109
|
+
pi: string;
|
|
110
|
+
newVersion: number;
|
|
111
|
+
newTip: string;
|
|
112
|
+
}
|
|
113
|
+
interface EditResult {
|
|
114
|
+
saved?: SaveResult;
|
|
115
|
+
reprocess?: ReprocessResult;
|
|
116
|
+
}
|
|
117
|
+
type EditPhase = 'idle' | 'saving' | 'reprocessing' | 'complete' | 'error';
|
|
118
|
+
interface EditStatus {
|
|
119
|
+
phase: EditPhase;
|
|
120
|
+
saveComplete: boolean;
|
|
121
|
+
reprocessStatus?: ReprocessStatus;
|
|
122
|
+
error?: string;
|
|
123
|
+
}
|
|
124
|
+
interface PollOptions {
|
|
125
|
+
intervalMs?: number;
|
|
126
|
+
timeoutMs?: number;
|
|
127
|
+
onProgress?: (status: EditStatus) => void;
|
|
128
|
+
}
|
|
129
|
+
interface ChangeSummary {
|
|
130
|
+
mode: EditMode;
|
|
131
|
+
hasManualEdits: boolean;
|
|
132
|
+
editedComponents: string[];
|
|
133
|
+
corrections: Correction[];
|
|
134
|
+
prompts: Record<string, string>;
|
|
135
|
+
scope: EditScope;
|
|
136
|
+
willRegenerate: RegeneratableComponent[];
|
|
137
|
+
willCascade: boolean;
|
|
138
|
+
willSave: boolean;
|
|
139
|
+
willReprocess: boolean;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* EditClient - Low-level API client for Arke edit operations
|
|
144
|
+
*
|
|
145
|
+
* Routes through the gateway:
|
|
146
|
+
* - /api/* -> IPFS Wrapper (entities, content, uploads)
|
|
147
|
+
* - /reprocess/* -> Reprocess API
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
/** Configuration for EditClient */
|
|
151
|
+
interface EditClientConfig {
|
|
152
|
+
/** Gateway URL (e.g., https://gateway.arke.io) */
|
|
153
|
+
gatewayUrl: string;
|
|
154
|
+
/** JWT auth token */
|
|
155
|
+
authToken?: string;
|
|
156
|
+
/** Optional transform for status URLs (e.g., for CORS proxy) */
|
|
157
|
+
statusUrlTransform?: (url: string) => string;
|
|
158
|
+
}
|
|
159
|
+
declare class EditClient {
|
|
160
|
+
private gatewayUrl;
|
|
161
|
+
private authToken?;
|
|
162
|
+
private statusUrlTransform?;
|
|
163
|
+
constructor(config: EditClientConfig);
|
|
164
|
+
/**
|
|
165
|
+
* Update the auth token (useful for token refresh)
|
|
166
|
+
*/
|
|
167
|
+
setAuthToken(token: string): void;
|
|
168
|
+
/**
|
|
169
|
+
* Sleep for a given number of milliseconds
|
|
170
|
+
*/
|
|
171
|
+
private sleep;
|
|
172
|
+
/**
|
|
173
|
+
* Execute a fetch with exponential backoff retry on transient errors
|
|
174
|
+
*/
|
|
175
|
+
private fetchWithRetry;
|
|
176
|
+
private getHeaders;
|
|
177
|
+
/**
|
|
178
|
+
* Handle common error responses
|
|
179
|
+
*/
|
|
180
|
+
private handleErrorResponse;
|
|
181
|
+
/**
|
|
182
|
+
* Fetch an entity by PI
|
|
183
|
+
*/
|
|
184
|
+
getEntity(pi: string): Promise<Entity>;
|
|
185
|
+
/**
|
|
186
|
+
* Fetch content by CID
|
|
187
|
+
*/
|
|
188
|
+
getContent(cid: string): Promise<string>;
|
|
189
|
+
/**
|
|
190
|
+
* Upload content and get CID
|
|
191
|
+
*/
|
|
192
|
+
uploadContent(content: string, filename: string): Promise<string>;
|
|
193
|
+
/**
|
|
194
|
+
* Update an entity with new components
|
|
195
|
+
*/
|
|
196
|
+
updateEntity(pi: string, update: EntityUpdate): Promise<EntityVersion>;
|
|
197
|
+
/**
|
|
198
|
+
* Trigger reprocessing for an entity
|
|
199
|
+
*/
|
|
200
|
+
reprocess(request: ReprocessRequest): Promise<ReprocessResult>;
|
|
201
|
+
/**
|
|
202
|
+
* Get reprocessing status by batch ID
|
|
203
|
+
*
|
|
204
|
+
* Uses exponential backoff retry to handle transient 500 errors
|
|
205
|
+
* that occur when the orchestrator is initializing.
|
|
206
|
+
*
|
|
207
|
+
* @param statusUrl - The status URL returned from reprocess()
|
|
208
|
+
* @param isFirstPoll - If true, uses a longer initial delay (orchestrator warmup)
|
|
209
|
+
*/
|
|
210
|
+
getReprocessStatus(statusUrl: string, isFirstPoll?: boolean): Promise<ReprocessStatus>;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* EditSession - Stateful session managing an edit workflow
|
|
215
|
+
*/
|
|
216
|
+
|
|
217
|
+
declare class EditSession {
|
|
218
|
+
readonly pi: string;
|
|
219
|
+
readonly mode: EditMode;
|
|
220
|
+
readonly aiReviewEnabled: boolean;
|
|
221
|
+
private client;
|
|
222
|
+
private entity;
|
|
223
|
+
private loadedComponents;
|
|
224
|
+
private prompts;
|
|
225
|
+
private editedContent;
|
|
226
|
+
private corrections;
|
|
227
|
+
private scope;
|
|
228
|
+
private submitting;
|
|
229
|
+
private result;
|
|
230
|
+
private statusUrl;
|
|
231
|
+
constructor(client: EditClient, pi: string, config?: EditSessionConfig);
|
|
232
|
+
/**
|
|
233
|
+
* Load the entity and its key components
|
|
234
|
+
*/
|
|
235
|
+
load(): Promise<void>;
|
|
236
|
+
/**
|
|
237
|
+
* Load a specific component on demand
|
|
238
|
+
*/
|
|
239
|
+
loadComponent(name: string): Promise<string | undefined>;
|
|
240
|
+
/**
|
|
241
|
+
* Get the loaded entity
|
|
242
|
+
*/
|
|
243
|
+
getEntity(): Entity;
|
|
244
|
+
/**
|
|
245
|
+
* Get loaded component content
|
|
246
|
+
*/
|
|
247
|
+
getComponents(): Record<string, string>;
|
|
248
|
+
/**
|
|
249
|
+
* Set a prompt for AI regeneration
|
|
250
|
+
*/
|
|
251
|
+
setPrompt(target: PromptTarget, prompt: string): void;
|
|
252
|
+
/**
|
|
253
|
+
* Get all prompts
|
|
254
|
+
*/
|
|
255
|
+
getPrompts(): Record<string, string>;
|
|
256
|
+
/**
|
|
257
|
+
* Clear a prompt
|
|
258
|
+
*/
|
|
259
|
+
clearPrompt(target: PromptTarget): void;
|
|
260
|
+
/**
|
|
261
|
+
* Set edited content for a component
|
|
262
|
+
*/
|
|
263
|
+
setContent(componentName: string, content: string): void;
|
|
264
|
+
/**
|
|
265
|
+
* Get all edited content
|
|
266
|
+
*/
|
|
267
|
+
getEditedContent(): Record<string, string>;
|
|
268
|
+
/**
|
|
269
|
+
* Clear edited content for a component
|
|
270
|
+
*/
|
|
271
|
+
clearContent(componentName: string): void;
|
|
272
|
+
/**
|
|
273
|
+
* Add a correction (for OCR fixes, etc.)
|
|
274
|
+
*/
|
|
275
|
+
addCorrection(original: string, corrected: string, sourceFile?: string): void;
|
|
276
|
+
/**
|
|
277
|
+
* Get all corrections
|
|
278
|
+
*/
|
|
279
|
+
getCorrections(): Correction[];
|
|
280
|
+
/**
|
|
281
|
+
* Clear corrections
|
|
282
|
+
*/
|
|
283
|
+
clearCorrections(): void;
|
|
284
|
+
/**
|
|
285
|
+
* Set the edit scope
|
|
286
|
+
*/
|
|
287
|
+
setScope(scope: Partial<EditScope>): void;
|
|
288
|
+
/**
|
|
289
|
+
* Get the current scope
|
|
290
|
+
*/
|
|
291
|
+
getScope(): EditScope;
|
|
292
|
+
/**
|
|
293
|
+
* Get diffs for manual changes
|
|
294
|
+
*/
|
|
295
|
+
getDiff(): ComponentDiff[];
|
|
296
|
+
/**
|
|
297
|
+
* Preview what prompts will be sent to AI
|
|
298
|
+
*/
|
|
299
|
+
previewPrompt(): Record<RegeneratableComponent, string>;
|
|
300
|
+
/**
|
|
301
|
+
* Get a summary of pending changes
|
|
302
|
+
*/
|
|
303
|
+
getChangeSummary(): ChangeSummary;
|
|
304
|
+
/**
|
|
305
|
+
* Submit changes (saves first if manual edits, then reprocesses)
|
|
306
|
+
*/
|
|
307
|
+
submit(note: string): Promise<EditResult>;
|
|
308
|
+
/**
|
|
309
|
+
* Wait for reprocessing to complete
|
|
310
|
+
*/
|
|
311
|
+
waitForCompletion(options?: PollOptions): Promise<EditStatus>;
|
|
312
|
+
/**
|
|
313
|
+
* Get current status without waiting
|
|
314
|
+
*/
|
|
315
|
+
getStatus(): Promise<EditStatus>;
|
|
316
|
+
private buildCustomPrompts;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Error classes for edit operations
|
|
321
|
+
*/
|
|
322
|
+
declare class EditError extends Error {
|
|
323
|
+
code: string;
|
|
324
|
+
details?: unknown | undefined;
|
|
325
|
+
constructor(message: string, code?: string, details?: unknown | undefined);
|
|
326
|
+
}
|
|
327
|
+
declare class EntityNotFoundError extends EditError {
|
|
328
|
+
constructor(pi: string);
|
|
329
|
+
}
|
|
330
|
+
declare class CASConflictError extends EditError {
|
|
331
|
+
constructor(pi: string, expectedTip: string, actualTip: string);
|
|
332
|
+
}
|
|
333
|
+
declare class ReprocessError extends EditError {
|
|
334
|
+
constructor(message: string, batchId?: string);
|
|
335
|
+
}
|
|
336
|
+
declare class ValidationError extends EditError {
|
|
337
|
+
constructor(message: string, field?: string);
|
|
338
|
+
}
|
|
339
|
+
declare class PermissionError extends EditError {
|
|
340
|
+
constructor(message: string, pi?: string);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export { ReprocessError as A, type ComponentDiff as C, type DiffType as D, EditClient as E, PermissionError as P, type RegeneratableComponent as R, type SaveResult as S, type TextDiff as T, ValidationError as V, type EditClientConfig as a, EditSession as b, EditError as c, type EditMode as d, type EditSessionConfig as e, type EditScope as f, type EditResult as g, type EditStatus as h, type EditPhase as i, type ReprocessResult as j, type ReprocessStatus as k, type Correction as l, type EntityContext as m, type CascadeContext as n, type Entity as o, type EntityUpdate as p, type EntityVersion as q, type PromptTarget as r, type CustomPrompts as s, type ReprocessRequest as t, type ReprocessPhase as u, type ReprocessProgress as v, type PollOptions as w, type ChangeSummary as x, EntityNotFoundError as y, CASConflictError as z };
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Arke SDK - Edit Package Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
type EditMode = 'ai-prompt' | 'manual-with-review' | 'manual-only';
|
|
5
|
+
interface EditSessionConfig {
|
|
6
|
+
mode: EditMode;
|
|
7
|
+
aiReviewEnabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface Entity {
|
|
10
|
+
pi: string;
|
|
11
|
+
ver: number;
|
|
12
|
+
ts: string;
|
|
13
|
+
manifest_cid: string;
|
|
14
|
+
components: Record<string, string>;
|
|
15
|
+
children_pi: string[];
|
|
16
|
+
parent_pi?: string;
|
|
17
|
+
note?: string;
|
|
18
|
+
}
|
|
19
|
+
interface EntityUpdate {
|
|
20
|
+
expect_tip: string;
|
|
21
|
+
components?: Record<string, string>;
|
|
22
|
+
components_remove?: string[];
|
|
23
|
+
note: string;
|
|
24
|
+
}
|
|
25
|
+
interface EntityVersion {
|
|
26
|
+
pi: string;
|
|
27
|
+
tip: string;
|
|
28
|
+
ver: number;
|
|
29
|
+
}
|
|
30
|
+
type RegeneratableComponent = 'pinax' | 'description' | 'cheimarros';
|
|
31
|
+
interface EditScope {
|
|
32
|
+
components: RegeneratableComponent[];
|
|
33
|
+
cascade: boolean;
|
|
34
|
+
stopAtPi?: string;
|
|
35
|
+
}
|
|
36
|
+
interface Correction {
|
|
37
|
+
original: string;
|
|
38
|
+
corrected: string;
|
|
39
|
+
sourceFile?: string;
|
|
40
|
+
context?: string;
|
|
41
|
+
}
|
|
42
|
+
type DiffType = 'addition' | 'deletion' | 'change' | 'unchanged';
|
|
43
|
+
interface TextDiff {
|
|
44
|
+
type: DiffType;
|
|
45
|
+
original?: string;
|
|
46
|
+
modified?: string;
|
|
47
|
+
lineNumber?: number;
|
|
48
|
+
context?: string;
|
|
49
|
+
}
|
|
50
|
+
interface ComponentDiff {
|
|
51
|
+
componentName: string;
|
|
52
|
+
diffs: TextDiff[];
|
|
53
|
+
summary: string;
|
|
54
|
+
hasChanges: boolean;
|
|
55
|
+
}
|
|
56
|
+
type PromptTarget = RegeneratableComponent | 'general' | 'reorganization';
|
|
57
|
+
interface EntityContext {
|
|
58
|
+
pi: string;
|
|
59
|
+
ver: number;
|
|
60
|
+
parentPi?: string;
|
|
61
|
+
childrenCount: number;
|
|
62
|
+
currentContent: Record<string, string>;
|
|
63
|
+
}
|
|
64
|
+
interface CascadeContext {
|
|
65
|
+
path: string[];
|
|
66
|
+
depth: number;
|
|
67
|
+
stopAtPi?: string;
|
|
68
|
+
}
|
|
69
|
+
interface CustomPrompts {
|
|
70
|
+
general?: string;
|
|
71
|
+
pinax?: string;
|
|
72
|
+
description?: string;
|
|
73
|
+
cheimarros?: string;
|
|
74
|
+
reorganization?: string;
|
|
75
|
+
}
|
|
76
|
+
interface ReprocessRequest {
|
|
77
|
+
pi: string;
|
|
78
|
+
phases: RegeneratableComponent[];
|
|
79
|
+
cascade: boolean;
|
|
80
|
+
options?: {
|
|
81
|
+
stop_at_pi?: string;
|
|
82
|
+
custom_prompts?: CustomPrompts;
|
|
83
|
+
custom_note?: string;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
interface ReprocessResult {
|
|
87
|
+
batch_id: string;
|
|
88
|
+
entities_queued: number;
|
|
89
|
+
entity_pis: string[];
|
|
90
|
+
status_url: string;
|
|
91
|
+
}
|
|
92
|
+
type ReprocessPhase = 'QUEUED' | 'DISCOVERY' | 'OCR_IN_PROGRESS' | 'REORGANIZATION' | 'PINAX_EXTRACTION' | 'CHEIMARROS_EXTRACTION' | 'DESCRIPTION' | 'DONE' | 'ERROR';
|
|
93
|
+
interface ReprocessProgress {
|
|
94
|
+
directories_total: number;
|
|
95
|
+
directories_pinax_complete: number;
|
|
96
|
+
directories_cheimarros_complete: number;
|
|
97
|
+
directories_description_complete: number;
|
|
98
|
+
}
|
|
99
|
+
interface ReprocessStatus {
|
|
100
|
+
batch_id: string;
|
|
101
|
+
status: ReprocessPhase;
|
|
102
|
+
progress: ReprocessProgress;
|
|
103
|
+
root_pi?: string;
|
|
104
|
+
error?: string;
|
|
105
|
+
started_at?: string;
|
|
106
|
+
completed_at?: string;
|
|
107
|
+
}
|
|
108
|
+
interface SaveResult {
|
|
109
|
+
pi: string;
|
|
110
|
+
newVersion: number;
|
|
111
|
+
newTip: string;
|
|
112
|
+
}
|
|
113
|
+
interface EditResult {
|
|
114
|
+
saved?: SaveResult;
|
|
115
|
+
reprocess?: ReprocessResult;
|
|
116
|
+
}
|
|
117
|
+
type EditPhase = 'idle' | 'saving' | 'reprocessing' | 'complete' | 'error';
|
|
118
|
+
interface EditStatus {
|
|
119
|
+
phase: EditPhase;
|
|
120
|
+
saveComplete: boolean;
|
|
121
|
+
reprocessStatus?: ReprocessStatus;
|
|
122
|
+
error?: string;
|
|
123
|
+
}
|
|
124
|
+
interface PollOptions {
|
|
125
|
+
intervalMs?: number;
|
|
126
|
+
timeoutMs?: number;
|
|
127
|
+
onProgress?: (status: EditStatus) => void;
|
|
128
|
+
}
|
|
129
|
+
interface ChangeSummary {
|
|
130
|
+
mode: EditMode;
|
|
131
|
+
hasManualEdits: boolean;
|
|
132
|
+
editedComponents: string[];
|
|
133
|
+
corrections: Correction[];
|
|
134
|
+
prompts: Record<string, string>;
|
|
135
|
+
scope: EditScope;
|
|
136
|
+
willRegenerate: RegeneratableComponent[];
|
|
137
|
+
willCascade: boolean;
|
|
138
|
+
willSave: boolean;
|
|
139
|
+
willReprocess: boolean;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* EditClient - Low-level API client for Arke edit operations
|
|
144
|
+
*
|
|
145
|
+
* Routes through the gateway:
|
|
146
|
+
* - /api/* -> IPFS Wrapper (entities, content, uploads)
|
|
147
|
+
* - /reprocess/* -> Reprocess API
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
/** Configuration for EditClient */
|
|
151
|
+
interface EditClientConfig {
|
|
152
|
+
/** Gateway URL (e.g., https://gateway.arke.io) */
|
|
153
|
+
gatewayUrl: string;
|
|
154
|
+
/** JWT auth token */
|
|
155
|
+
authToken?: string;
|
|
156
|
+
/** Optional transform for status URLs (e.g., for CORS proxy) */
|
|
157
|
+
statusUrlTransform?: (url: string) => string;
|
|
158
|
+
}
|
|
159
|
+
declare class EditClient {
|
|
160
|
+
private gatewayUrl;
|
|
161
|
+
private authToken?;
|
|
162
|
+
private statusUrlTransform?;
|
|
163
|
+
constructor(config: EditClientConfig);
|
|
164
|
+
/**
|
|
165
|
+
* Update the auth token (useful for token refresh)
|
|
166
|
+
*/
|
|
167
|
+
setAuthToken(token: string): void;
|
|
168
|
+
/**
|
|
169
|
+
* Sleep for a given number of milliseconds
|
|
170
|
+
*/
|
|
171
|
+
private sleep;
|
|
172
|
+
/**
|
|
173
|
+
* Execute a fetch with exponential backoff retry on transient errors
|
|
174
|
+
*/
|
|
175
|
+
private fetchWithRetry;
|
|
176
|
+
private getHeaders;
|
|
177
|
+
/**
|
|
178
|
+
* Handle common error responses
|
|
179
|
+
*/
|
|
180
|
+
private handleErrorResponse;
|
|
181
|
+
/**
|
|
182
|
+
* Fetch an entity by PI
|
|
183
|
+
*/
|
|
184
|
+
getEntity(pi: string): Promise<Entity>;
|
|
185
|
+
/**
|
|
186
|
+
* Fetch content by CID
|
|
187
|
+
*/
|
|
188
|
+
getContent(cid: string): Promise<string>;
|
|
189
|
+
/**
|
|
190
|
+
* Upload content and get CID
|
|
191
|
+
*/
|
|
192
|
+
uploadContent(content: string, filename: string): Promise<string>;
|
|
193
|
+
/**
|
|
194
|
+
* Update an entity with new components
|
|
195
|
+
*/
|
|
196
|
+
updateEntity(pi: string, update: EntityUpdate): Promise<EntityVersion>;
|
|
197
|
+
/**
|
|
198
|
+
* Trigger reprocessing for an entity
|
|
199
|
+
*/
|
|
200
|
+
reprocess(request: ReprocessRequest): Promise<ReprocessResult>;
|
|
201
|
+
/**
|
|
202
|
+
* Get reprocessing status by batch ID
|
|
203
|
+
*
|
|
204
|
+
* Uses exponential backoff retry to handle transient 500 errors
|
|
205
|
+
* that occur when the orchestrator is initializing.
|
|
206
|
+
*
|
|
207
|
+
* @param statusUrl - The status URL returned from reprocess()
|
|
208
|
+
* @param isFirstPoll - If true, uses a longer initial delay (orchestrator warmup)
|
|
209
|
+
*/
|
|
210
|
+
getReprocessStatus(statusUrl: string, isFirstPoll?: boolean): Promise<ReprocessStatus>;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* EditSession - Stateful session managing an edit workflow
|
|
215
|
+
*/
|
|
216
|
+
|
|
217
|
+
declare class EditSession {
|
|
218
|
+
readonly pi: string;
|
|
219
|
+
readonly mode: EditMode;
|
|
220
|
+
readonly aiReviewEnabled: boolean;
|
|
221
|
+
private client;
|
|
222
|
+
private entity;
|
|
223
|
+
private loadedComponents;
|
|
224
|
+
private prompts;
|
|
225
|
+
private editedContent;
|
|
226
|
+
private corrections;
|
|
227
|
+
private scope;
|
|
228
|
+
private submitting;
|
|
229
|
+
private result;
|
|
230
|
+
private statusUrl;
|
|
231
|
+
constructor(client: EditClient, pi: string, config?: EditSessionConfig);
|
|
232
|
+
/**
|
|
233
|
+
* Load the entity and its key components
|
|
234
|
+
*/
|
|
235
|
+
load(): Promise<void>;
|
|
236
|
+
/**
|
|
237
|
+
* Load a specific component on demand
|
|
238
|
+
*/
|
|
239
|
+
loadComponent(name: string): Promise<string | undefined>;
|
|
240
|
+
/**
|
|
241
|
+
* Get the loaded entity
|
|
242
|
+
*/
|
|
243
|
+
getEntity(): Entity;
|
|
244
|
+
/**
|
|
245
|
+
* Get loaded component content
|
|
246
|
+
*/
|
|
247
|
+
getComponents(): Record<string, string>;
|
|
248
|
+
/**
|
|
249
|
+
* Set a prompt for AI regeneration
|
|
250
|
+
*/
|
|
251
|
+
setPrompt(target: PromptTarget, prompt: string): void;
|
|
252
|
+
/**
|
|
253
|
+
* Get all prompts
|
|
254
|
+
*/
|
|
255
|
+
getPrompts(): Record<string, string>;
|
|
256
|
+
/**
|
|
257
|
+
* Clear a prompt
|
|
258
|
+
*/
|
|
259
|
+
clearPrompt(target: PromptTarget): void;
|
|
260
|
+
/**
|
|
261
|
+
* Set edited content for a component
|
|
262
|
+
*/
|
|
263
|
+
setContent(componentName: string, content: string): void;
|
|
264
|
+
/**
|
|
265
|
+
* Get all edited content
|
|
266
|
+
*/
|
|
267
|
+
getEditedContent(): Record<string, string>;
|
|
268
|
+
/**
|
|
269
|
+
* Clear edited content for a component
|
|
270
|
+
*/
|
|
271
|
+
clearContent(componentName: string): void;
|
|
272
|
+
/**
|
|
273
|
+
* Add a correction (for OCR fixes, etc.)
|
|
274
|
+
*/
|
|
275
|
+
addCorrection(original: string, corrected: string, sourceFile?: string): void;
|
|
276
|
+
/**
|
|
277
|
+
* Get all corrections
|
|
278
|
+
*/
|
|
279
|
+
getCorrections(): Correction[];
|
|
280
|
+
/**
|
|
281
|
+
* Clear corrections
|
|
282
|
+
*/
|
|
283
|
+
clearCorrections(): void;
|
|
284
|
+
/**
|
|
285
|
+
* Set the edit scope
|
|
286
|
+
*/
|
|
287
|
+
setScope(scope: Partial<EditScope>): void;
|
|
288
|
+
/**
|
|
289
|
+
* Get the current scope
|
|
290
|
+
*/
|
|
291
|
+
getScope(): EditScope;
|
|
292
|
+
/**
|
|
293
|
+
* Get diffs for manual changes
|
|
294
|
+
*/
|
|
295
|
+
getDiff(): ComponentDiff[];
|
|
296
|
+
/**
|
|
297
|
+
* Preview what prompts will be sent to AI
|
|
298
|
+
*/
|
|
299
|
+
previewPrompt(): Record<RegeneratableComponent, string>;
|
|
300
|
+
/**
|
|
301
|
+
* Get a summary of pending changes
|
|
302
|
+
*/
|
|
303
|
+
getChangeSummary(): ChangeSummary;
|
|
304
|
+
/**
|
|
305
|
+
* Submit changes (saves first if manual edits, then reprocesses)
|
|
306
|
+
*/
|
|
307
|
+
submit(note: string): Promise<EditResult>;
|
|
308
|
+
/**
|
|
309
|
+
* Wait for reprocessing to complete
|
|
310
|
+
*/
|
|
311
|
+
waitForCompletion(options?: PollOptions): Promise<EditStatus>;
|
|
312
|
+
/**
|
|
313
|
+
* Get current status without waiting
|
|
314
|
+
*/
|
|
315
|
+
getStatus(): Promise<EditStatus>;
|
|
316
|
+
private buildCustomPrompts;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Error classes for edit operations
|
|
321
|
+
*/
|
|
322
|
+
declare class EditError extends Error {
|
|
323
|
+
code: string;
|
|
324
|
+
details?: unknown | undefined;
|
|
325
|
+
constructor(message: string, code?: string, details?: unknown | undefined);
|
|
326
|
+
}
|
|
327
|
+
declare class EntityNotFoundError extends EditError {
|
|
328
|
+
constructor(pi: string);
|
|
329
|
+
}
|
|
330
|
+
declare class CASConflictError extends EditError {
|
|
331
|
+
constructor(pi: string, expectedTip: string, actualTip: string);
|
|
332
|
+
}
|
|
333
|
+
declare class ReprocessError extends EditError {
|
|
334
|
+
constructor(message: string, batchId?: string);
|
|
335
|
+
}
|
|
336
|
+
declare class ValidationError extends EditError {
|
|
337
|
+
constructor(message: string, field?: string);
|
|
338
|
+
}
|
|
339
|
+
declare class PermissionError extends EditError {
|
|
340
|
+
constructor(message: string, pi?: string);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export { ReprocessError as A, type ComponentDiff as C, type DiffType as D, EditClient as E, PermissionError as P, type RegeneratableComponent as R, type SaveResult as S, type TextDiff as T, ValidationError as V, type EditClientConfig as a, EditSession as b, EditError as c, type EditMode as d, type EditSessionConfig as e, type EditScope as f, type EditResult as g, type EditStatus as h, type EditPhase as i, type ReprocessResult as j, type ReprocessStatus as k, type Correction as l, type EntityContext as m, type CascadeContext as n, type Entity as o, type EntityUpdate as p, type EntityVersion as q, type PromptTarget as r, type CustomPrompts as s, type ReprocessRequest as t, type ReprocessPhase as u, type ReprocessProgress as v, type PollOptions as w, type ChangeSummary as x, EntityNotFoundError as y, CASConflictError as z };
|