@agent-os-sdk/client 0.9.24 → 0.9.26

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.
Files changed (185) hide show
  1. package/package.json +15 -8
  2. package/src/generated/openapi.ts +90 -0
  3. package/src/generated/swagger.json +181 -0
  4. package/src/modules/runs.ts +64 -0
  5. package/src/modules/templates.ts +35 -0
  6. package/dist/client/AgentOsClient.d.ts +0 -141
  7. package/dist/client/AgentOsClient.d.ts.map +0 -1
  8. package/dist/client/AgentOsClient.js +0 -250
  9. package/dist/client/HttpRequestBuilder.d.ts +0 -50
  10. package/dist/client/HttpRequestBuilder.d.ts.map +0 -1
  11. package/dist/client/HttpRequestBuilder.js +0 -83
  12. package/dist/client/OperationContext.d.ts +0 -19
  13. package/dist/client/OperationContext.d.ts.map +0 -1
  14. package/dist/client/OperationContext.js +0 -13
  15. package/dist/client/OperationContextProvider.d.ts +0 -54
  16. package/dist/client/OperationContextProvider.d.ts.map +0 -1
  17. package/dist/client/OperationContextProvider.js +0 -71
  18. package/dist/client/auth.d.ts +0 -100
  19. package/dist/client/auth.d.ts.map +0 -1
  20. package/dist/client/auth.js +0 -38
  21. package/dist/client/config.d.ts +0 -49
  22. package/dist/client/config.d.ts.map +0 -1
  23. package/dist/client/config.js +0 -62
  24. package/dist/client/helpers.d.ts +0 -63
  25. package/dist/client/helpers.d.ts.map +0 -1
  26. package/dist/client/helpers.js +0 -55
  27. package/dist/client/pagination.d.ts +0 -105
  28. package/dist/client/pagination.d.ts.map +0 -1
  29. package/dist/client/pagination.js +0 -117
  30. package/dist/client/raw.d.ts +0 -277
  31. package/dist/client/raw.d.ts.map +0 -1
  32. package/dist/client/raw.js +0 -337
  33. package/dist/client/retry.d.ts +0 -37
  34. package/dist/client/retry.d.ts.map +0 -1
  35. package/dist/client/retry.js +0 -108
  36. package/dist/client/sanitize.d.ts +0 -19
  37. package/dist/client/sanitize.d.ts.map +0 -1
  38. package/dist/client/sanitize.js +0 -28
  39. package/dist/client/timeout.d.ts +0 -26
  40. package/dist/client/timeout.d.ts.map +0 -1
  41. package/dist/client/timeout.js +0 -51
  42. package/dist/errors/factory.d.ts +0 -22
  43. package/dist/errors/factory.d.ts.map +0 -1
  44. package/dist/errors/factory.js +0 -101
  45. package/dist/errors/index.d.ts +0 -210
  46. package/dist/errors/index.d.ts.map +0 -1
  47. package/dist/errors/index.js +0 -283
  48. package/dist/generated/client.d.ts +0 -20
  49. package/dist/generated/client.d.ts.map +0 -1
  50. package/dist/generated/client.js +0 -15
  51. package/dist/generated/index.d.ts +0 -2
  52. package/dist/generated/index.d.ts.map +0 -1
  53. package/dist/generated/index.js +0 -1
  54. package/dist/generated/openapi.d.ts +0 -12294
  55. package/dist/generated/openapi.d.ts.map +0 -1
  56. package/dist/generated/openapi.js +0 -5
  57. package/dist/index.d.ts +0 -69
  58. package/dist/index.d.ts.map +0 -1
  59. package/dist/index.js +0 -81
  60. package/dist/modules/a2a.d.ts +0 -48
  61. package/dist/modules/a2a.d.ts.map +0 -1
  62. package/dist/modules/a2a.js +0 -37
  63. package/dist/modules/agents.d.ts +0 -346
  64. package/dist/modules/agents.d.ts.map +0 -1
  65. package/dist/modules/agents.js +0 -296
  66. package/dist/modules/apiTokens.d.ts +0 -62
  67. package/dist/modules/apiTokens.d.ts.map +0 -1
  68. package/dist/modules/apiTokens.js +0 -56
  69. package/dist/modules/approvals.d.ts +0 -75
  70. package/dist/modules/approvals.d.ts.map +0 -1
  71. package/dist/modules/approvals.js +0 -91
  72. package/dist/modules/audit.d.ts +0 -78
  73. package/dist/modules/audit.d.ts.map +0 -1
  74. package/dist/modules/audit.js +0 -94
  75. package/dist/modules/auth.d.ts +0 -28
  76. package/dist/modules/auth.d.ts.map +0 -1
  77. package/dist/modules/auth.js +0 -22
  78. package/dist/modules/builder.d.ts +0 -242
  79. package/dist/modules/builder.d.ts.map +0 -1
  80. package/dist/modules/builder.js +0 -248
  81. package/dist/modules/catalog.d.ts +0 -142
  82. package/dist/modules/catalog.d.ts.map +0 -1
  83. package/dist/modules/catalog.js +0 -136
  84. package/dist/modules/chatwoot.d.ts +0 -59
  85. package/dist/modules/chatwoot.d.ts.map +0 -1
  86. package/dist/modules/chatwoot.js +0 -200
  87. package/dist/modules/checkpoints.d.ts +0 -62
  88. package/dist/modules/checkpoints.d.ts.map +0 -1
  89. package/dist/modules/checkpoints.js +0 -48
  90. package/dist/modules/contracts.d.ts +0 -48
  91. package/dist/modules/contracts.d.ts.map +0 -1
  92. package/dist/modules/contracts.js +0 -25
  93. package/dist/modules/credentials.d.ts +0 -105
  94. package/dist/modules/credentials.d.ts.map +0 -1
  95. package/dist/modules/credentials.js +0 -135
  96. package/dist/modules/crons.d.ts +0 -73
  97. package/dist/modules/crons.d.ts.map +0 -1
  98. package/dist/modules/crons.js +0 -67
  99. package/dist/modules/datasets.d.ts +0 -80
  100. package/dist/modules/datasets.d.ts.map +0 -1
  101. package/dist/modules/datasets.js +0 -91
  102. package/dist/modules/evaluation.d.ts +0 -183
  103. package/dist/modules/evaluation.d.ts.map +0 -1
  104. package/dist/modules/evaluation.js +0 -108
  105. package/dist/modules/files.d.ts +0 -89
  106. package/dist/modules/files.d.ts.map +0 -1
  107. package/dist/modules/files.js +0 -133
  108. package/dist/modules/graphs.d.ts +0 -120
  109. package/dist/modules/graphs.d.ts.map +0 -1
  110. package/dist/modules/graphs.js +0 -69
  111. package/dist/modules/improvements.d.ts +0 -52
  112. package/dist/modules/improvements.d.ts.map +0 -1
  113. package/dist/modules/improvements.js +0 -27
  114. package/dist/modules/info.d.ts +0 -76
  115. package/dist/modules/info.d.ts.map +0 -1
  116. package/dist/modules/info.js +0 -93
  117. package/dist/modules/knowledge.d.ts +0 -91
  118. package/dist/modules/knowledge.d.ts.map +0 -1
  119. package/dist/modules/knowledge.js +0 -80
  120. package/dist/modules/me.d.ts +0 -58
  121. package/dist/modules/me.d.ts.map +0 -1
  122. package/dist/modules/me.js +0 -28
  123. package/dist/modules/members.d.ts +0 -124
  124. package/dist/modules/members.d.ts.map +0 -1
  125. package/dist/modules/members.js +0 -142
  126. package/dist/modules/memberships.d.ts +0 -25
  127. package/dist/modules/memberships.d.ts.map +0 -1
  128. package/dist/modules/memberships.js +0 -20
  129. package/dist/modules/metaAgent.d.ts +0 -95
  130. package/dist/modules/metaAgent.d.ts.map +0 -1
  131. package/dist/modules/metaAgent.js +0 -32
  132. package/dist/modules/metrics.d.ts +0 -20
  133. package/dist/modules/metrics.d.ts.map +0 -1
  134. package/dist/modules/metrics.js +0 -27
  135. package/dist/modules/observability.d.ts +0 -19
  136. package/dist/modules/observability.d.ts.map +0 -1
  137. package/dist/modules/observability.js +0 -14
  138. package/dist/modules/playground.d.ts +0 -42
  139. package/dist/modules/playground.d.ts.map +0 -1
  140. package/dist/modules/playground.js +0 -48
  141. package/dist/modules/presets.d.ts +0 -32
  142. package/dist/modules/presets.d.ts.map +0 -1
  143. package/dist/modules/presets.js +0 -199
  144. package/dist/modules/prompts.d.ts +0 -87
  145. package/dist/modules/prompts.d.ts.map +0 -1
  146. package/dist/modules/prompts.js +0 -87
  147. package/dist/modules/roles.d.ts +0 -64
  148. package/dist/modules/roles.d.ts.map +0 -1
  149. package/dist/modules/roles.js +0 -79
  150. package/dist/modules/runs.d.ts +0 -400
  151. package/dist/modules/runs.d.ts.map +0 -1
  152. package/dist/modules/runs.js +0 -526
  153. package/dist/modules/store.d.ts +0 -37
  154. package/dist/modules/store.d.ts.map +0 -1
  155. package/dist/modules/store.js +0 -48
  156. package/dist/modules/templates.d.ts +0 -28
  157. package/dist/modules/templates.d.ts.map +0 -1
  158. package/dist/modules/templates.js +0 -19
  159. package/dist/modules/tenants.d.ts +0 -49
  160. package/dist/modules/tenants.d.ts.map +0 -1
  161. package/dist/modules/tenants.js +0 -56
  162. package/dist/modules/threads.d.ts +0 -205
  163. package/dist/modules/threads.d.ts.map +0 -1
  164. package/dist/modules/threads.js +0 -225
  165. package/dist/modules/tools.d.ts +0 -62
  166. package/dist/modules/tools.d.ts.map +0 -1
  167. package/dist/modules/tools.js +0 -45
  168. package/dist/modules/traces.d.ts +0 -89
  169. package/dist/modules/traces.d.ts.map +0 -1
  170. package/dist/modules/traces.js +0 -65
  171. package/dist/modules/triggers.d.ts +0 -228
  172. package/dist/modules/triggers.d.ts.map +0 -1
  173. package/dist/modules/triggers.js +0 -176
  174. package/dist/modules/usage.d.ts +0 -85
  175. package/dist/modules/usage.d.ts.map +0 -1
  176. package/dist/modules/usage.js +0 -43
  177. package/dist/modules/vectorStores.d.ts +0 -100
  178. package/dist/modules/vectorStores.d.ts.map +0 -1
  179. package/dist/modules/vectorStores.js +0 -159
  180. package/dist/modules/workspaces.d.ts +0 -138
  181. package/dist/modules/workspaces.d.ts.map +0 -1
  182. package/dist/modules/workspaces.js +0 -121
  183. package/dist/sse/client.d.ts +0 -140
  184. package/dist/sse/client.d.ts.map +0 -1
  185. package/dist/sse/client.js +0 -103
@@ -1,71 +0,0 @@
1
- /**
2
- * OperationContextProvider — Flow lifecycle management
3
- *
4
- * Provider defines the lifecycle of a flow context.
5
- * Implementations can use AsyncLocalStorage or manual context passing.
6
- *
7
- * @see sdk-upgrade.md Section 1.2
8
- */
9
- /**
10
- * Default provider that always returns undefined.
11
- * Used when no flow context is established.
12
- */
13
- export class DefaultContextProvider {
14
- get() {
15
- return undefined;
16
- }
17
- }
18
- /**
19
- * AsyncLocalStorage-based provider for Node.js environments.
20
- * Automatically propagates context through async call chains.
21
- *
22
- * Note: This class requires Node.js async_hooks module.
23
- * Import and use only in Node.js environments.
24
- */
25
- export class AsyncLocalStorageContextProvider {
26
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
- storage;
28
- constructor() {
29
- // Dynamic import to avoid browser errors
30
- try {
31
- // eslint-disable-next-line @typescript-eslint/no-require-imports
32
- const asyncHooks = require("async_hooks");
33
- this.storage = new asyncHooks.AsyncLocalStorage();
34
- }
35
- catch {
36
- throw new Error("AsyncLocalStorage requires Node.js environment");
37
- }
38
- }
39
- get() {
40
- return this.storage?.getStore();
41
- }
42
- /**
43
- * Run a function within a context.
44
- * The context is automatically available to all async operations within.
45
- */
46
- run(context, fn) {
47
- return this.storage.run(context, fn);
48
- }
49
- /**
50
- * Run an async function within a context.
51
- */
52
- runAsync(context, fn) {
53
- return this.storage.run(context, fn);
54
- }
55
- }
56
- /**
57
- * Manual provider for environments without AsyncLocalStorage.
58
- * Context must be explicitly set and cleared.
59
- */
60
- export class ManualContextProvider {
61
- context;
62
- get() {
63
- return this.context;
64
- }
65
- set(context) {
66
- this.context = context;
67
- }
68
- clear() {
69
- this.context = undefined;
70
- }
71
- }
@@ -1,100 +0,0 @@
1
- /**
2
- * Auth Provider Types for Agent OS SDK
3
- *
4
- * Two modes only:
5
- * - JWT (browser): Uses Supabase JWT + X-Workspace-Id header
6
- * - API Token (server): Uses aosk_* token with embedded claims
7
- */
8
- import type { NetworkConfig } from "./config.js";
9
- import type { SDKHooks } from "./raw.js";
10
- import type { OperationContextProvider } from "./OperationContextProvider.js";
11
- /**
12
- * API Token authentication for server-to-server integrations.
13
- * Token format: aosk_live_* or aosk_test_*
14
- *
15
- * SECURITY: API tokens contain embedded workspace/tenant claims.
16
- * The SDK sends ONLY Authorization header (no X-Workspace-Id, no X-Tenant-Id).
17
- *
18
- * @example
19
- * ```ts
20
- * const client = new AgentOsClient({
21
- * baseUrl: "https://api.example.com",
22
- * auth: { type: "api_token", apiKey: "aosk_live_xxx" }
23
- * })
24
- * ```
25
- */
26
- export type ApiTokenAuth = {
27
- type: "api_token";
28
- /** API key (aosk_*) or function that returns one */
29
- apiKey: string | (() => string | Promise<string>);
30
- };
31
- /**
32
- * JWT authentication for browser/frontend clients.
33
- * Uses Supabase JWT with X-Workspace-Id header.
34
- *
35
- * SECURITY:
36
- * - X-Workspace-Id is REQUIRED (throws if missing)
37
- * - X-Tenant-Id is NEVER sent (backend derives from workspace membership)
38
- *
39
- * @example
40
- * ```ts
41
- * const client = new AgentOsClient({
42
- * baseUrl: "https://api.example.com",
43
- * auth: {
44
- * type: "jwt",
45
- * getToken: async () => (await supabase.auth.getSession()).data.session?.access_token,
46
- * getWorkspaceId: () => localStorage.getItem("agentos.workspaceId")!,
47
- * }
48
- * })
49
- * ```
50
- */
51
- export type JwtAuth = {
52
- type: "jwt";
53
- /** Function to get the JWT access token */
54
- getToken: () => string | Promise<string>;
55
- /** Function to get the current workspace ID (REQUIRED) */
56
- getWorkspaceId: () => string | Promise<string>;
57
- };
58
- /**
59
- * Auth provider union type - only two modes supported
60
- */
61
- export type AuthProvider = ApiTokenAuth | JwtAuth;
62
- /**
63
- * Options for AgentOsClient - auth is REQUIRED
64
- */
65
- export type AgentOsClientOptions = {
66
- /** Base URL of the Agent OS Control Plane */
67
- baseUrl: string;
68
- /** Authentication provider (REQUIRED) */
69
- auth: AuthProvider;
70
- /**
71
- * Allow API token in browser environment.
72
- * Default: false (throws error to prevent accidental exposure)
73
- * Only set to true if you understand the security implications.
74
- */
75
- allowApiTokenInBrowser?: boolean;
76
- /** Network policy (timeouts/retries). */
77
- network?: Partial<NetworkConfig>;
78
- /** Optional request lifecycle hooks for observability */
79
- hooks?: SDKHooks;
80
- /** Optional flow context provider (ALS/manual) for sticky correlation per operation. */
81
- /** Recommended for long-lived server clients to avoid process-wide sticky fallback correlation. */
82
- contextProvider?: OperationContextProvider;
83
- /** Custom headers to add to all requests */
84
- headers?: Record<string, string>;
85
- };
86
- export declare function isApiTokenAuth(auth: AuthProvider): auth is ApiTokenAuth;
87
- export declare function isJwtAuth(auth: AuthProvider): auth is JwtAuth;
88
- /**
89
- * Detect browser environment
90
- */
91
- export declare function isBrowser(): boolean;
92
- /**
93
- * Check if token looks like an API token (aosk_*)
94
- */
95
- export declare function isApiToken(token: string): boolean;
96
- /**
97
- * Check if token looks like a JWT (three base64 segments)
98
- */
99
- export declare function isJwtToken(token: string): boolean;
100
- //# sourceMappingURL=auth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["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BAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,IAAI,YAAY,CAEvE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,IAAI,OAAO,CAE7D;AAMD;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGjD"}
@@ -1,38 +0,0 @@
1
- /**
2
- * Auth Provider Types for Agent OS SDK
3
- *
4
- * Two modes only:
5
- * - JWT (browser): Uses Supabase JWT + X-Workspace-Id header
6
- * - API Token (server): Uses aosk_* token with embedded claims
7
- */
8
- // ============================================================================
9
- // Type Guards
10
- // ============================================================================
11
- export function isApiTokenAuth(auth) {
12
- return auth.type === "api_token";
13
- }
14
- export function isJwtAuth(auth) {
15
- return auth.type === "jwt";
16
- }
17
- // ============================================================================
18
- // Helpers
19
- // ============================================================================
20
- /**
21
- * Detect browser environment
22
- */
23
- export function isBrowser() {
24
- return typeof window !== "undefined" && typeof document !== "undefined";
25
- }
26
- /**
27
- * Check if token looks like an API token (aosk_*)
28
- */
29
- export function isApiToken(token) {
30
- return token.startsWith("aosk_");
31
- }
32
- /**
33
- * Check if token looks like a JWT (three base64 segments)
34
- */
35
- export function isJwtToken(token) {
36
- const parts = token.split(".");
37
- return parts.length === 3 && parts.every(p => p.length > 0);
38
- }
@@ -1,49 +0,0 @@
1
- /**
2
- * Agent OS SDK - Network Configuration
3
- *
4
- * Centralized configuration for timeouts, retries, and network policies.
5
- */
6
- /**
7
- * Retry configuration for network requests.
8
- */
9
- export interface RetryConfig {
10
- /** Maximum retry attempts (default: 3) */
11
- maxRetries: number;
12
- /** Base delay between retries in ms (default: 1000) */
13
- baseDelayMs: number;
14
- /** Maximum delay between retries in ms (default: 30000) */
15
- maxDelayMs: number;
16
- /** Jitter factor to prevent thundering herd (0-1, default: 0.2) */
17
- jitterFactor: number;
18
- /** HTTP status codes that trigger retry (default: [408, 429, 500, 502, 503, 504]) */
19
- retryableStatuses: number[];
20
- }
21
- /**
22
- * Full network configuration for the SDK client.
23
- */
24
- export interface NetworkConfig {
25
- /** Timeout per request attempt in milliseconds (default: 30000) */
26
- timeoutMs: number;
27
- /** Retry configuration */
28
- retry: RetryConfig;
29
- }
30
- /**
31
- * Default network configuration.
32
- * Balanced for most use cases - 30s timeout, 3 retries with exponential backoff.
33
- */
34
- export declare const DEFAULT_NETWORK_CONFIG: NetworkConfig;
35
- /**
36
- * Aggressive configuration for interactive UIs.
37
- * Shorter timeouts, fewer retries.
38
- */
39
- export declare const INTERACTIVE_NETWORK_CONFIG: NetworkConfig;
40
- /**
41
- * Patient configuration for background jobs.
42
- * Longer timeouts, more retries.
43
- */
44
- export declare const BACKGROUND_NETWORK_CONFIG: NetworkConfig;
45
- /**
46
- * Merges user config with defaults.
47
- */
48
- export declare function mergeNetworkConfig(userConfig?: Partial<NetworkConfig>): NetworkConfig;
49
- //# sourceMappingURL=config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/client/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,0CAA0C;IAC1C,UAAU,EAAE,MAAM,CAAC;IAEnB,uDAAuD;IACvD,WAAW,EAAE,MAAM,CAAC;IAEpB,2DAA2D;IAC3D,UAAU,EAAE,MAAM,CAAC;IAEnB,mEAAmE;IACnE,YAAY,EAAE,MAAM,CAAC;IAErB,qFAAqF;IACrF,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC;IAElB,0BAA0B;IAC1B,KAAK,EAAE,WAAW,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,aASpC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,0BAA0B,EAAE,aASxC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,aASvC,CAAC;AAEF;;GAEG;AACH,wBAAgB,kBAAkB,CAC9B,UAAU,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GACpC,aAAa,CAYf"}
@@ -1,62 +0,0 @@
1
- /**
2
- * Agent OS SDK - Network Configuration
3
- *
4
- * Centralized configuration for timeouts, retries, and network policies.
5
- */
6
- /**
7
- * Default network configuration.
8
- * Balanced for most use cases - 30s timeout, 3 retries with exponential backoff.
9
- */
10
- export const DEFAULT_NETWORK_CONFIG = {
11
- timeoutMs: 30_000,
12
- retry: {
13
- maxRetries: 3,
14
- baseDelayMs: 1_000,
15
- maxDelayMs: 30_000,
16
- jitterFactor: 0.2,
17
- retryableStatuses: [408, 429, 500, 502, 503, 504],
18
- },
19
- };
20
- /**
21
- * Aggressive configuration for interactive UIs.
22
- * Shorter timeouts, fewer retries.
23
- */
24
- export const INTERACTIVE_NETWORK_CONFIG = {
25
- timeoutMs: 10_000,
26
- retry: {
27
- maxRetries: 1,
28
- baseDelayMs: 500,
29
- maxDelayMs: 5_000,
30
- jitterFactor: 0.1,
31
- retryableStatuses: [429, 503, 504],
32
- },
33
- };
34
- /**
35
- * Patient configuration for background jobs.
36
- * Longer timeouts, more retries.
37
- */
38
- export const BACKGROUND_NETWORK_CONFIG = {
39
- timeoutMs: 120_000,
40
- retry: {
41
- maxRetries: 5,
42
- baseDelayMs: 2_000,
43
- maxDelayMs: 60_000,
44
- jitterFactor: 0.3,
45
- retryableStatuses: [408, 429, 500, 502, 503, 504],
46
- },
47
- };
48
- /**
49
- * Merges user config with defaults.
50
- */
51
- export function mergeNetworkConfig(userConfig) {
52
- if (!userConfig) {
53
- return DEFAULT_NETWORK_CONFIG;
54
- }
55
- return {
56
- timeoutMs: userConfig.timeoutMs ?? DEFAULT_NETWORK_CONFIG.timeoutMs,
57
- retry: {
58
- ...DEFAULT_NETWORK_CONFIG.retry,
59
- ...userConfig.retry,
60
- },
61
- };
62
- }
@@ -1,63 +0,0 @@
1
- /**
2
- * SDK Helper Types and Functions
3
- *
4
- * Provides utilities for working with API responses.
5
- */
6
- import type { APIResponse } from "./raw.js";
7
- /**
8
- * Standard pagination parameters used across all list endpoints.
9
- * Extends Record to be compatible with query parameter types.
10
- */
11
- export interface PaginationParams extends Record<string, unknown> {
12
- /** Maximum number of items to return (default: 20) */
13
- limit?: number;
14
- /** Number of items to skip (default: 0) */
15
- offset?: number;
16
- }
17
- /**
18
- * Paginated list response wrapper.
19
- */
20
- export interface PaginatedResponse<T> {
21
- items: T[];
22
- total: number;
23
- }
24
- /**
25
- * SDK-specific error class with structured error data.
26
- */
27
- export declare class SDKError extends Error {
28
- readonly code: string;
29
- readonly status: number;
30
- readonly details?: unknown;
31
- constructor(response: APIResponse<unknown>);
32
- }
33
- /**
34
- * Unwraps an APIResponse, returning the data directly or throwing on error.
35
- * Use this when you want the cleaner "throws on error" pattern.
36
- *
37
- * @example
38
- * ```ts
39
- * // Instead of:
40
- * const { data, error } = await client.agents.list();
41
- * if (error) throw new Error(error.message);
42
- *
43
- * // Use:
44
- * const agents = await unwrap(client.agents.list());
45
- * ```
46
- */
47
- export declare function unwrap<T>(promise: Promise<APIResponse<T>>): Promise<T>;
48
- /**
49
- * Type helper for unwrapped responses.
50
- */
51
- export type Unwrapped<T> = T extends APIResponse<infer U> ? U : never;
52
- export type Result<T, E = SDKError> = {
53
- success: true;
54
- data: T;
55
- } | {
56
- success: false;
57
- error: E;
58
- };
59
- /**
60
- * Converts an APIResponse to a Result type for pattern matching.
61
- */
62
- export declare function toResult<T>(promise: Promise<APIResponse<T>>): Promise<Result<T>>;
63
- //# sourceMappingURL=helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/client/helpers.ts"],"names":[],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OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAMtF"}
@@ -1,55 +0,0 @@
1
- /**
2
- * SDK Helper Types and Functions
3
- *
4
- * Provides utilities for working with API responses.
5
- */
6
- // ============================================================================
7
- // Error Handling
8
- // ============================================================================
9
- /**
10
- * SDK-specific error class with structured error data.
11
- */
12
- export class SDKError extends Error {
13
- code;
14
- status;
15
- details;
16
- constructor(response) {
17
- const message = response.error?.message || `HTTP ${response.response.status}`;
18
- super(message);
19
- this.name = "SDKError";
20
- this.code = response.error?.code || `HTTP_${response.response.status}`;
21
- this.status = response.response.status;
22
- this.details = response.error?.details;
23
- }
24
- }
25
- /**
26
- * Unwraps an APIResponse, returning the data directly or throwing on error.
27
- * Use this when you want the cleaner "throws on error" pattern.
28
- *
29
- * @example
30
- * ```ts
31
- * // Instead of:
32
- * const { data, error } = await client.agents.list();
33
- * if (error) throw new Error(error.message);
34
- *
35
- * // Use:
36
- * const agents = await unwrap(client.agents.list());
37
- * ```
38
- */
39
- export async function unwrap(promise) {
40
- const result = await promise;
41
- if (result.error || !result.data) {
42
- throw new SDKError(result);
43
- }
44
- return result.data;
45
- }
46
- /**
47
- * Converts an APIResponse to a Result type for pattern matching.
48
- */
49
- export async function toResult(promise) {
50
- const result = await promise;
51
- if (result.error || !result.data) {
52
- return { success: false, error: new SDKError(result) };
53
- }
54
- return { success: true, data: result.data };
55
- }
@@ -1,105 +0,0 @@
1
- /**
2
- * Agent OS SDK - Pagination Utilities
3
- *
4
- * Auto-paginating iterators that support both offset and cursor pagination.
5
- * Designed to work with any list endpoint.
6
- */
7
- import type { APIResponse } from "./raw.js";
8
- /**
9
- * Offset-based paginated response.
10
- * Most common format for list endpoints.
11
- */
12
- export interface OffsetPaginatedResponse<T> {
13
- items: T[];
14
- total: number;
15
- }
16
- /**
17
- * Cursor-based paginated response.
18
- * Better for large datasets and real-time consistency.
19
- */
20
- export interface CursorPaginatedResponse<T> {
21
- items: T[];
22
- next_cursor?: string;
23
- has_more: boolean;
24
- }
25
- /**
26
- * Union type for both pagination styles.
27
- */
28
- export type PaginatedResponse<T> = OffsetPaginatedResponse<T> | CursorPaginatedResponse<T>;
29
- /**
30
- * Offset pagination parameters.
31
- */
32
- export interface OffsetParams {
33
- limit?: number;
34
- offset?: number;
35
- }
36
- /**
37
- * Cursor pagination parameters.
38
- */
39
- export interface CursorParams {
40
- limit?: number;
41
- after?: string;
42
- }
43
- /**
44
- * Combined pagination parameters.
45
- */
46
- export type PaginationParams = OffsetParams | CursorParams;
47
- /**
48
- * Options for pagination behavior.
49
- */
50
- export interface PaginateOptions {
51
- /** Number of items per page (default: 100) */
52
- pageSize?: number;
53
- /** Maximum total items to fetch (default: unlimited) */
54
- maxItems?: number;
55
- /** AbortSignal for cancellation */
56
- signal?: AbortSignal;
57
- }
58
- /**
59
- * Creates an async iterator that automatically paginates through results.
60
- * Supports both offset and cursor pagination transparently.
61
- *
62
- * @example
63
- * // Basic usage
64
- * for await (const run of paginate(
65
- * (p) => client.runs.list(p),
66
- * { status: "completed" }
67
- * )) {
68
- * console.log(run.id);
69
- * }
70
- *
71
- * @example
72
- * // With options
73
- * for await (const agent of paginate(
74
- * (p) => client.agents.list(p),
75
- * { workspace_id: "ws_123" },
76
- * { pageSize: 50, maxItems: 200 }
77
- * )) {
78
- * console.log(agent.name);
79
- * }
80
- */
81
- export declare function paginate<T, P extends PaginationParams>(fetchPage: (params: P) => Promise<APIResponse<PaginatedResponse<T>>>, baseParams: Omit<P, "limit" | "offset" | "after">, options?: PaginateOptions): AsyncGenerator<T, void, unknown>;
82
- /**
83
- * Collects all items from a paginated endpoint into an array.
84
- * Useful when you need all items at once.
85
- *
86
- * @example
87
- * const allRuns = await collectAll(
88
- * (p) => client.runs.list(p),
89
- * { status: "completed" },
90
- * { maxItems: 1000 }
91
- * );
92
- */
93
- export declare function collectAll<T, P extends PaginationParams>(fetchPage: (params: P) => Promise<APIResponse<PaginatedResponse<T>>>, baseParams: Omit<P, "limit" | "offset" | "after">, options?: PaginateOptions): Promise<T[]>;
94
- /**
95
- * Gets the first item from a paginated endpoint.
96
- * More efficient than collecting all items when you only need one.
97
- *
98
- * @example
99
- * const latestRun = await getFirst(
100
- * (p) => client.runs.list({ ...p, order: "desc" }),
101
- * { agent_id: "agent_123" }
102
- * );
103
- */
104
- export declare function getFirst<T, P extends PaginationParams>(fetchPage: (params: P) => Promise<APIResponse<PaginatedResponse<T>>>, baseParams: Omit<P, "limit" | "offset" | "after">): Promise<T | undefined>;
105
- //# sourceMappingURL=pagination.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../src/client/pagination.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAM5C;;;GAGG;AACH,MAAM,WAAW,uBAAuB,CAAC,CAAC;IACtC,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB,CAAC,CAAC;IACtC,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IACzB,uBAAuB,CAAC,CAAC,CAAC,GAC1B,uBAAuB,CAAC,CAAC,CAAC,CAAC;AAMjC;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,YAAY,CAAC;AAiB3D;;GAEG;AACH,MAAM,WAAW,eAAe;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**
2
- * Agent OS SDK - Pagination Utilities
3
- *
4
- * Auto-paginating iterators that support both offset and cursor pagination.
5
- * Designed to work with any list endpoint.
6
- */
7
- // ============================================================================
8
- // Type Guards
9
- // ============================================================================
10
- /**
11
- * Checks if response uses cursor pagination.
12
- */
13
- function isCursorResponse(response) {
14
- return "has_more" in response;
15
- }
16
- /**
17
- * Creates an async iterator that automatically paginates through results.
18
- * Supports both offset and cursor pagination transparently.
19
- *
20
- * @example
21
- * // Basic usage
22
- * for await (const run of paginate(
23
- * (p) => client.runs.list(p),
24
- * { status: "completed" }
25
- * )) {
26
- * console.log(run.id);
27
- * }
28
- *
29
- * @example
30
- * // With options
31
- * for await (const agent of paginate(
32
- * (p) => client.agents.list(p),
33
- * { workspace_id: "ws_123" },
34
- * { pageSize: 50, maxItems: 200 }
35
- * )) {
36
- * console.log(agent.name);
37
- * }
38
- */
39
- export async function* paginate(fetchPage, baseParams, options) {
40
- const pageSize = options?.pageSize ?? 100;
41
- const maxItems = options?.maxItems ?? Infinity;
42
- const signal = options?.signal;
43
- let offset = 0;
44
- let cursor;
45
- let hasMore = true;
46
- let yielded = 0;
47
- while (hasMore && yielded < maxItems) {
48
- // Check for cancellation
49
- if (signal?.aborted) {
50
- return;
51
- }
52
- // Build params based on pagination style
53
- const params = {
54
- ...baseParams,
55
- limit: Math.min(pageSize, maxItems - yielded),
56
- ...(cursor !== undefined ? { after: cursor } : { offset }),
57
- };
58
- const response = await fetchPage(params);
59
- if (response.error) {
60
- throw response.error;
61
- }
62
- const data = response.data;
63
- for (const item of data.items) {
64
- if (yielded >= maxItems) {
65
- return;
66
- }
67
- yield item;
68
- yielded++;
69
- }
70
- // Update pagination state based on response type
71
- if (isCursorResponse(data)) {
72
- cursor = data.next_cursor;
73
- hasMore = data.has_more && data.items.length > 0;
74
- }
75
- else {
76
- offset += data.items.length;
77
- hasMore = offset < data.total && data.items.length > 0;
78
- }
79
- }
80
- }
81
- // ============================================================================
82
- // Collect Utility
83
- // ============================================================================
84
- /**
85
- * Collects all items from a paginated endpoint into an array.
86
- * Useful when you need all items at once.
87
- *
88
- * @example
89
- * const allRuns = await collectAll(
90
- * (p) => client.runs.list(p),
91
- * { status: "completed" },
92
- * { maxItems: 1000 }
93
- * );
94
- */
95
- export async function collectAll(fetchPage, baseParams, options) {
96
- const items = [];
97
- for await (const item of paginate(fetchPage, baseParams, options)) {
98
- items.push(item);
99
- }
100
- return items;
101
- }
102
- /**
103
- * Gets the first item from a paginated endpoint.
104
- * More efficient than collecting all items when you only need one.
105
- *
106
- * @example
107
- * const latestRun = await getFirst(
108
- * (p) => client.runs.list({ ...p, order: "desc" }),
109
- * { agent_id: "agent_123" }
110
- * );
111
- */
112
- export async function getFirst(fetchPage, baseParams) {
113
- for await (const item of paginate(fetchPage, baseParams, { pageSize: 1, maxItems: 1 })) {
114
- return item;
115
- }
116
- return undefined;
117
- }