@arke-institute/sdk 2.5.0 → 2.6.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.
@@ -1,9 +1,49 @@
1
1
  import { Client } from 'openapi-fetch';
2
- import { paths } from './generated/index.js';
2
+ import { paths, components } from './generated/index.js';
3
+
4
+ /**
5
+ * Retry logic for transient network and server errors
6
+ */
7
+ /**
8
+ * Configuration for retry behavior
9
+ */
10
+ interface RetryConfig {
11
+ /**
12
+ * Maximum number of retry attempts
13
+ * @default 3
14
+ */
15
+ maxRetries?: number;
16
+ /**
17
+ * Initial delay in milliseconds before first retry
18
+ * @default 100
19
+ */
20
+ initialDelay?: number;
21
+ /**
22
+ * Maximum delay in milliseconds (caps exponential backoff)
23
+ * @default 5000
24
+ */
25
+ maxDelay?: number;
26
+ /**
27
+ * Whether to retry on 5xx server errors
28
+ * @default true
29
+ */
30
+ retryOn5xx?: boolean;
31
+ /**
32
+ * Whether to retry on network errors (connection refused, DNS, timeouts)
33
+ * @default true
34
+ */
35
+ retryOnNetworkError?: boolean;
36
+ /**
37
+ * Optional callback invoked before each retry attempt
38
+ * Useful for logging or monitoring
39
+ */
40
+ onRetry?: (attempt: number, error: Error, delayMs: number) => void;
41
+ }
3
42
 
4
43
  /**
5
44
  * SDK configuration types
6
45
  */
46
+
7
47
  interface ArkeClientConfig {
8
48
  /**
9
49
  * Base URL for the Arke API
@@ -34,6 +74,29 @@ interface ArkeClientConfig {
34
74
  * Custom headers to include in all requests
35
75
  */
36
76
  headers?: Record<string, string>;
77
+ /**
78
+ * Retry configuration for transient errors
79
+ *
80
+ * Set to `false` to disable retries entirely.
81
+ * If not specified, uses default retry behavior (3 retries with exponential backoff).
82
+ *
83
+ * CAS conflicts (409) are never retried - they are returned immediately.
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * const arke = new ArkeClient({
88
+ * authToken: 'ak_...',
89
+ * retry: {
90
+ * maxRetries: 5,
91
+ * initialDelay: 200,
92
+ * onRetry: (attempt, error, delay) => {
93
+ * console.log(`Retry ${attempt} after ${delay}ms`);
94
+ * }
95
+ * }
96
+ * });
97
+ * ```
98
+ */
99
+ retry?: RetryConfig | false;
37
100
  }
38
101
  declare const DEFAULT_CONFIG: Required<Pick<ArkeClientConfig, 'baseUrl' | 'network'>>;
39
102
 
@@ -167,6 +230,31 @@ declare class ArkeClient {
167
230
  data: ReadableStream<Uint8Array> | null | undefined;
168
231
  error: unknown;
169
232
  }>;
233
+ /**
234
+ * Upload file content
235
+ *
236
+ * This is a convenience method that handles the binary body serialization
237
+ * that openapi-fetch doesn't handle automatically for non-JSON bodies.
238
+ *
239
+ * @example
240
+ * ```typescript
241
+ * // Upload from a Blob
242
+ * const blob = new Blob(['Hello, world!'], { type: 'text/plain' });
243
+ * const { data, error } = await arke.uploadFileContent('01ABC...', blob, 'text/plain');
244
+ *
245
+ * // Upload from an ArrayBuffer
246
+ * const buffer = new TextEncoder().encode('Hello, world!').buffer;
247
+ * const { data, error } = await arke.uploadFileContent('01ABC...', buffer, 'text/plain');
248
+ *
249
+ * // Upload from a Uint8Array
250
+ * const bytes = new TextEncoder().encode('Hello, world!');
251
+ * const { data, error } = await arke.uploadFileContent('01ABC...', bytes, 'text/plain');
252
+ * ```
253
+ */
254
+ uploadFileContent(fileId: string, content: Blob | ArrayBuffer | Uint8Array, contentType: string): Promise<{
255
+ data: components['schemas']['UploadContentResponse'] | undefined;
256
+ error: unknown;
257
+ }>;
170
258
  }
171
259
  /**
172
260
  * Create a new ArkeClient instance
@@ -1,9 +1,49 @@
1
1
  import { Client } from 'openapi-fetch';
2
- import { paths } from './generated/index.cjs';
2
+ import { paths, components } from './generated/index.cjs';
3
+
4
+ /**
5
+ * Retry logic for transient network and server errors
6
+ */
7
+ /**
8
+ * Configuration for retry behavior
9
+ */
10
+ interface RetryConfig {
11
+ /**
12
+ * Maximum number of retry attempts
13
+ * @default 3
14
+ */
15
+ maxRetries?: number;
16
+ /**
17
+ * Initial delay in milliseconds before first retry
18
+ * @default 100
19
+ */
20
+ initialDelay?: number;
21
+ /**
22
+ * Maximum delay in milliseconds (caps exponential backoff)
23
+ * @default 5000
24
+ */
25
+ maxDelay?: number;
26
+ /**
27
+ * Whether to retry on 5xx server errors
28
+ * @default true
29
+ */
30
+ retryOn5xx?: boolean;
31
+ /**
32
+ * Whether to retry on network errors (connection refused, DNS, timeouts)
33
+ * @default true
34
+ */
35
+ retryOnNetworkError?: boolean;
36
+ /**
37
+ * Optional callback invoked before each retry attempt
38
+ * Useful for logging or monitoring
39
+ */
40
+ onRetry?: (attempt: number, error: Error, delayMs: number) => void;
41
+ }
3
42
 
4
43
  /**
5
44
  * SDK configuration types
6
45
  */
46
+
7
47
  interface ArkeClientConfig {
8
48
  /**
9
49
  * Base URL for the Arke API
@@ -34,6 +74,29 @@ interface ArkeClientConfig {
34
74
  * Custom headers to include in all requests
35
75
  */
36
76
  headers?: Record<string, string>;
77
+ /**
78
+ * Retry configuration for transient errors
79
+ *
80
+ * Set to `false` to disable retries entirely.
81
+ * If not specified, uses default retry behavior (3 retries with exponential backoff).
82
+ *
83
+ * CAS conflicts (409) are never retried - they are returned immediately.
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * const arke = new ArkeClient({
88
+ * authToken: 'ak_...',
89
+ * retry: {
90
+ * maxRetries: 5,
91
+ * initialDelay: 200,
92
+ * onRetry: (attempt, error, delay) => {
93
+ * console.log(`Retry ${attempt} after ${delay}ms`);
94
+ * }
95
+ * }
96
+ * });
97
+ * ```
98
+ */
99
+ retry?: RetryConfig | false;
37
100
  }
38
101
  declare const DEFAULT_CONFIG: Required<Pick<ArkeClientConfig, 'baseUrl' | 'network'>>;
39
102
 
@@ -167,6 +230,31 @@ declare class ArkeClient {
167
230
  data: ReadableStream<Uint8Array> | null | undefined;
168
231
  error: unknown;
169
232
  }>;
233
+ /**
234
+ * Upload file content
235
+ *
236
+ * This is a convenience method that handles the binary body serialization
237
+ * that openapi-fetch doesn't handle automatically for non-JSON bodies.
238
+ *
239
+ * @example
240
+ * ```typescript
241
+ * // Upload from a Blob
242
+ * const blob = new Blob(['Hello, world!'], { type: 'text/plain' });
243
+ * const { data, error } = await arke.uploadFileContent('01ABC...', blob, 'text/plain');
244
+ *
245
+ * // Upload from an ArrayBuffer
246
+ * const buffer = new TextEncoder().encode('Hello, world!').buffer;
247
+ * const { data, error } = await arke.uploadFileContent('01ABC...', buffer, 'text/plain');
248
+ *
249
+ * // Upload from a Uint8Array
250
+ * const bytes = new TextEncoder().encode('Hello, world!');
251
+ * const { data, error } = await arke.uploadFileContent('01ABC...', bytes, 'text/plain');
252
+ * ```
253
+ */
254
+ uploadFileContent(fileId: string, content: Blob | ArrayBuffer | Uint8Array, contentType: string): Promise<{
255
+ data: components['schemas']['UploadContentResponse'] | undefined;
256
+ error: unknown;
257
+ }>;
170
258
  }
171
259
  /**
172
260
  * Create a new ArkeClient instance
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * Source: Arke v1 API
8
8
  * Version: 1.0.0
9
- * Generated: 2026-01-25T03:52:16.348Z
9
+ * Generated: 2026-01-26T22:08:41.056Z
10
10
  */
11
11
  type paths = {
12
12
  "/ops-reference": {
@@ -2123,6 +2123,9 @@ type paths = {
2123
2123
  *
2124
2124
  * **Performance:** Preview expansion is recommended for most use cases. Full expansion with many large entities can result in multi-MB payloads.
2125
2125
  *
2126
+ * **Expansion Limit:**
2127
+ * Use `?expand_limit=N` to control maximum relationships expanded (1-500, default 100). When truncated, the response includes `_expansion_metadata` with counts.
2128
+ *
2126
2129
  * ---
2127
2130
  * **Permission:** `entity:view`
2128
2131
  * **Auth:** optional
@@ -2132,6 +2135,8 @@ type paths = {
2132
2135
  query?: {
2133
2136
  /** @description Comma-separated list of fields to expand. Supports: relationships[:preview|full] */
2134
2137
  expand?: string;
2138
+ /** @description Maximum number of relationships to expand (1-500, default 100). When exceeded, relationships beyond the limit are returned without peer data. */
2139
+ expand_limit?: number;
2135
2140
  };
2136
2141
  header?: never;
2137
2142
  path: {
@@ -6610,7 +6615,7 @@ type paths = {
6610
6615
  patch?: never;
6611
6616
  trace?: never;
6612
6617
  };
6613
- "/jobs/{id}": {
6618
+ "/agents/{id}/jobs/{job_id}/status": {
6614
6619
  parameters: {
6615
6620
  query?: never;
6616
6621
  header?: never;
@@ -6618,68 +6623,110 @@ type paths = {
6618
6623
  cookie?: never;
6619
6624
  };
6620
6625
  /**
6621
- * Get job status
6622
- * @description Returns focused job status and summary. Use this endpoint for quick status polling.
6626
+ * Get job status from agent
6627
+ * @description Proxies to the agent's `/status/:job_id` endpoint and returns the response.
6628
+ *
6629
+ * Use this endpoint to poll job status after invoking an agent. The `agent_id` and `job_id`
6630
+ * are both returned in the invoke response.
6623
6631
  *
6624
- * Returns 404 if the entity is not a job collection.
6632
+ * **Query Parameters (passed through to agent):**
6633
+ * - `detail=full` - Include detailed sub-job/dispatch information (orchestrators/workflows)
6634
+ * - `errors=N` - Include last N errors (orchestrators only)
6625
6635
  *
6626
- * **Response includes:**
6627
- * - Current status (running/done/error)
6628
- * - Timestamps (started_at, completed_at)
6629
- * - Agent references (agent, main_agent, target)
6630
- * - Counts (files_count, sub_jobs_count)
6636
+ * **Response:** Returns the agent's status response directly. Schema varies by agent type
6637
+ * (service, workflow, orchestrator) but always includes:
6638
+ * - `job_id` - Job identifier
6639
+ * - `status` - Current status (pending/running/done/error)
6640
+ * - `progress` - Progress counters (total/pending/done/error)
6641
+ * - `started_at` - When the job started
6642
+ * - `completed_at` - When the job completed (if done/error)
6643
+ * - `updated_at` - Last state modification
6644
+ *
6645
+ * Agent-specific fields (phase, stages, sub_jobs, folders, dispatches) are also included
6646
+ * when applicable.
6631
6647
  *
6632
6648
  * ---
6633
- * **Permission:** `collection:view`
6649
+ * **Permission:** `agent:view`
6634
6650
  * **Auth:** optional
6635
6651
  */
6636
6652
  get: {
6637
6653
  parameters: {
6638
- query?: never;
6654
+ query?: {
6655
+ detail?: "full";
6656
+ errors?: number | null;
6657
+ };
6639
6658
  header?: never;
6640
6659
  path: {
6641
- /** @description Entity ID (ULID) */
6642
6660
  id: string;
6661
+ job_id: string;
6643
6662
  };
6644
6663
  cookie?: never;
6645
6664
  };
6646
6665
  requestBody?: never;
6647
6666
  responses: {
6648
- /** @description Job status */
6667
+ /** @description Job status from agent */
6649
6668
  200: {
6650
6669
  headers: {
6651
6670
  [name: string]: unknown;
6652
6671
  };
6653
6672
  content: {
6654
- "application/json": components["schemas"]["JobStatusResponse"];
6673
+ "application/json": {
6674
+ /**
6675
+ * @description Unique job identifier
6676
+ * @example job_01KFXPQ3ABCDEFGHIJKLMN
6677
+ */
6678
+ job_id: string;
6679
+ /**
6680
+ * @description Current job status
6681
+ * @example running
6682
+ * @enum {string}
6683
+ */
6684
+ status: "pending" | "running" | "done" | "error";
6685
+ progress: components["schemas"]["JobProgress"];
6686
+ /**
6687
+ * @description When this job started (ISO timestamp)
6688
+ * @example 2026-01-26T17:48:15.000Z
6689
+ */
6690
+ started_at: string;
6691
+ /**
6692
+ * @description When this job completed (ISO timestamp)
6693
+ * @example 2026-01-26T17:49:30.000Z
6694
+ */
6695
+ completed_at?: string;
6696
+ /**
6697
+ * @description Last state modification (ISO timestamp)
6698
+ * @example 2026-01-26T17:49:27.000Z
6699
+ */
6700
+ updated_at?: string;
6701
+ /** @description Final result data (only when status is done) */
6702
+ result?: {
6703
+ [key: string]: unknown;
6704
+ };
6705
+ error?: components["schemas"]["JobError"];
6706
+ };
6655
6707
  };
6656
6708
  };
6657
- /** @description Forbidden - Insufficient permissions */
6658
- 403: {
6709
+ /** @description Not Found - Resource does not exist */
6710
+ 404: {
6659
6711
  headers: {
6660
6712
  [name: string]: unknown;
6661
6713
  };
6662
6714
  content: {
6663
6715
  /**
6664
6716
  * @example {
6665
- * "error": "Forbidden: You do not have permission to perform this action"
6717
+ * "error": "Entity not found"
6666
6718
  * }
6667
6719
  */
6668
6720
  "application/json": components["schemas"]["ErrorResponse"];
6669
6721
  };
6670
6722
  };
6671
- /** @description Not Found - Resource does not exist */
6672
- 404: {
6723
+ /** @description Agent unreachable or returned an error */
6724
+ 502: {
6673
6725
  headers: {
6674
6726
  [name: string]: unknown;
6675
6727
  };
6676
6728
  content: {
6677
- /**
6678
- * @example {
6679
- * "error": "Entity not found"
6680
- * }
6681
- */
6682
- "application/json": components["schemas"]["ErrorResponse"];
6729
+ "application/json": components["schemas"]["AgentUnreachableError"];
6683
6730
  };
6684
6731
  };
6685
6732
  };
@@ -11416,57 +11463,51 @@ type components = {
11416
11463
  */
11417
11464
  confirm?: boolean;
11418
11465
  };
11419
- EntityRef: {
11466
+ JobProgress: {
11420
11467
  /**
11421
- * @description Entity ID (ULID format)
11422
- * @example 01KDETYWYWM0MJVKM8DK3AEXPY
11468
+ * @description Total items to process
11469
+ * @example 10
11423
11470
  */
11424
- pi: string;
11425
- type?: string;
11426
- label?: string;
11427
- };
11428
- JobStatusResponse: {
11471
+ total: number;
11429
11472
  /**
11430
- * @description Entity ID (ULID format)
11431
- * @example 01KDETYWYWM0MJVKM8DK3AEXPY
11473
+ * @description Items not yet started
11474
+ * @example 3
11432
11475
  */
11433
- id: string;
11476
+ pending: number;
11434
11477
  /**
11435
- * @description Content Identifier (CID) - content-addressed hash
11436
- * @example bafyreibug443cnd4endcwinwttw3c3dzmcl2ikht64xzn5qg56bix3usfy
11478
+ * @description Items dispatched but not complete
11479
+ * @example 2
11437
11480
  */
11438
- cid: string;
11481
+ dispatched?: number;
11439
11482
  /**
11440
- * @description Job collection status
11441
- * @example running
11442
- * @enum {string}
11483
+ * @description Successfully completed items
11484
+ * @example 4
11443
11485
  */
11444
- status: "running" | "done" | "error";
11486
+ done: number;
11445
11487
  /**
11446
- * Format: date-time
11447
- * @description ISO 8601 datetime
11448
- * @example 2025-12-26T12:00:00.000Z
11488
+ * @description Failed items
11489
+ * @example 1
11449
11490
  */
11450
- started_at: string;
11491
+ error: number;
11492
+ };
11493
+ JobError: {
11451
11494
  /**
11452
- * Format: date-time
11453
- * @description ISO 8601 datetime
11454
- * @example 2025-12-26T12:00:00.000Z
11495
+ * @description Error code
11496
+ * @example TIMEOUT
11455
11497
  */
11456
- completed_at: string | null;
11457
- agent: components["schemas"]["EntityRef"];
11458
- target?: components["schemas"]["EntityRef"];
11459
- main_agent?: components["schemas"]["EntityRef"];
11498
+ code: string;
11460
11499
  /**
11461
- * @description Number of files contained in this job collection
11462
- * @example 5
11500
+ * @description Human-readable error message
11501
+ * @example Request timed out after 30 seconds
11463
11502
  */
11464
- files_count: number;
11503
+ message: string;
11504
+ };
11505
+ AgentUnreachableError: {
11465
11506
  /**
11466
- * @description Number of sub-job collections
11467
- * @example 2
11507
+ * @description Error message
11508
+ * @example Failed to reach agent: Connection refused
11468
11509
  */
11469
- sub_jobs_count: number;
11510
+ error: string;
11470
11511
  };
11471
11512
  Event: {
11472
11513
  /**