@runtypelabs/sdk 1.7.2 → 1.7.3

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 (80) hide show
  1. package/dist/index.cjs +7026 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +5147 -0
  4. package/dist/index.d.ts +5146 -27
  5. package/dist/index.js +6955 -77
  6. package/dist/index.js.map +1 -1
  7. package/package.json +14 -7
  8. package/dist/batch-builder.d.ts +0 -106
  9. package/dist/batch-builder.d.ts.map +0 -1
  10. package/dist/batch-builder.js +0 -124
  11. package/dist/batch-builder.js.map +0 -1
  12. package/dist/batches-namespace.d.ts +0 -132
  13. package/dist/batches-namespace.d.ts.map +0 -1
  14. package/dist/batches-namespace.js +0 -128
  15. package/dist/batches-namespace.js.map +0 -1
  16. package/dist/case-types.d.ts +0 -42
  17. package/dist/case-types.d.ts.map +0 -1
  18. package/dist/case-types.js +0 -16
  19. package/dist/case-types.js.map +0 -1
  20. package/dist/client-token-types.d.ts +0 -143
  21. package/dist/client-token-types.d.ts.map +0 -1
  22. package/dist/client-token-types.js +0 -11
  23. package/dist/client-token-types.js.map +0 -1
  24. package/dist/client.d.ts +0 -135
  25. package/dist/client.d.ts.map +0 -1
  26. package/dist/client.js +0 -522
  27. package/dist/client.js.map +0 -1
  28. package/dist/endpoints.d.ts +0 -1353
  29. package/dist/endpoints.d.ts.map +0 -1
  30. package/dist/endpoints.js +0 -2936
  31. package/dist/endpoints.js.map +0 -1
  32. package/dist/error-handling-types.d.ts +0 -71
  33. package/dist/error-handling-types.d.ts.map +0 -1
  34. package/dist/error-handling-types.js +0 -12
  35. package/dist/error-handling-types.js.map +0 -1
  36. package/dist/eval-builder.d.ts +0 -216
  37. package/dist/eval-builder.d.ts.map +0 -1
  38. package/dist/eval-builder.js +0 -225
  39. package/dist/eval-builder.js.map +0 -1
  40. package/dist/evals-namespace.d.ts +0 -205
  41. package/dist/evals-namespace.d.ts.map +0 -1
  42. package/dist/evals-namespace.js +0 -208
  43. package/dist/evals-namespace.js.map +0 -1
  44. package/dist/flow-builder.d.ts +0 -717
  45. package/dist/flow-builder.d.ts.map +0 -1
  46. package/dist/flow-builder.js +0 -592
  47. package/dist/flow-builder.js.map +0 -1
  48. package/dist/flow-result.d.ts +0 -117
  49. package/dist/flow-result.d.ts.map +0 -1
  50. package/dist/flow-result.js +0 -175
  51. package/dist/flow-result.js.map +0 -1
  52. package/dist/flows-namespace.d.ts +0 -442
  53. package/dist/flows-namespace.d.ts.map +0 -1
  54. package/dist/flows-namespace.js +0 -686
  55. package/dist/flows-namespace.js.map +0 -1
  56. package/dist/generated-tool-gate.d.ts +0 -75
  57. package/dist/generated-tool-gate.d.ts.map +0 -1
  58. package/dist/generated-tool-gate.js +0 -314
  59. package/dist/generated-tool-gate.js.map +0 -1
  60. package/dist/index.d.ts.map +0 -1
  61. package/dist/prompts-namespace.d.ts +0 -237
  62. package/dist/prompts-namespace.d.ts.map +0 -1
  63. package/dist/prompts-namespace.js +0 -222
  64. package/dist/prompts-namespace.js.map +0 -1
  65. package/dist/runtype.d.ts +0 -232
  66. package/dist/runtype.d.ts.map +0 -1
  67. package/dist/runtype.js +0 -367
  68. package/dist/runtype.js.map +0 -1
  69. package/dist/stream-utils.d.ts +0 -58
  70. package/dist/stream-utils.d.ts.map +0 -1
  71. package/dist/stream-utils.js +0 -373
  72. package/dist/stream-utils.js.map +0 -1
  73. package/dist/transform.d.ts +0 -30
  74. package/dist/transform.d.ts.map +0 -1
  75. package/dist/transform.js +0 -196
  76. package/dist/transform.js.map +0 -1
  77. package/dist/types.d.ts +0 -717
  78. package/dist/types.d.ts.map +0 -1
  79. package/dist/types.js +0 -7
  80. package/dist/types.js.map +0 -1
@@ -1,1353 +0,0 @@
1
- /**
2
- * API endpoint handlers with automatic camelCase/snake_case transformation
3
- */
4
- import type { Flow, Prompt, RuntypeRecord, ApiKey, ModelConfig, UserProfile, PaginationResponse, ListParams, RecordListParams, CreateFlowRequest, CreatePromptRequest, CreateRecordRequest, CreateApiKeyRequest, CreateModelConfigRequest, DispatchRequest, BulkEditRequest, BulkEditResponse, Tool, ToolExecution, CreateToolRequest, UpdateToolRequest, ExecuteToolRequest, ExecuteToolResponse, BuiltInTool, ModelUsageResponse, ModelUsageQueryParams, RuntimeTool } from './types';
5
- import type { ClientToken, CreateClientTokenRequest, CreateClientTokenResponse, UpdateClientTokenRequest, ListConversationsResponse } from './client-token-types';
6
- import { type ApplyGeneratedProposalOptions, type ApplyGeneratedProposalResult, type AttachRuntimeToolsOptions, type GeneratedRuntimeToolGateDecision, type GeneratedRuntimeToolGateOptions } from './generated-tool-gate';
7
- export interface ApiClient {
8
- get<T>(path: string, params?: {
9
- [key: string]: any;
10
- }): Promise<T>;
11
- post<T>(path: string, data?: any): Promise<T>;
12
- put<T>(path: string, data?: any): Promise<T>;
13
- patch<T>(path: string, data?: any): Promise<T>;
14
- delete<T>(path: string, data?: any): Promise<T>;
15
- postFormData<T>(path: string, formData: FormData): Promise<T>;
16
- requestStream(path: string, options?: RequestInit): Promise<Response>;
17
- }
18
- /**
19
- * Flows endpoint handlers
20
- */
21
- export declare class FlowsEndpoint {
22
- private client;
23
- constructor(client: ApiClient);
24
- /**
25
- * List all flows for the authenticated user
26
- */
27
- list(params?: ListParams): Promise<PaginationResponse<Flow>>;
28
- /**
29
- * Get a specific flow by ID
30
- */
31
- get(id: string): Promise<Flow>;
32
- /**
33
- * Create a new flow
34
- */
35
- create(data: CreateFlowRequest): Promise<Flow>;
36
- /**
37
- * Update an existing flow
38
- */
39
- update(id: string, data: Partial<CreateFlowRequest>): Promise<Flow>;
40
- /**
41
- * Delete a flow
42
- */
43
- delete(id: string): Promise<void>;
44
- /**
45
- * Run a flow on all records of a specific type
46
- */
47
- runOnRecordType(id: string, recordType: string): Promise<any>;
48
- /**
49
- * Publish flow (promote draft to published)
50
- */
51
- publish(id: string): Promise<{
52
- success: boolean;
53
- publishedVersionId: string;
54
- message: string;
55
- }>;
56
- }
57
- /**
58
- * Prompts endpoint handlers
59
- */
60
- export declare class PromptsEndpoint {
61
- private client;
62
- constructor(client: ApiClient);
63
- /**
64
- * List all prompts for the authenticated user
65
- */
66
- list(params?: ListParams & {
67
- flowId?: string;
68
- }): Promise<PaginationResponse<Prompt>>;
69
- /**
70
- * Get a specific prompt by ID
71
- */
72
- get(id: string): Promise<Prompt>;
73
- /**
74
- * Create a new prompt
75
- */
76
- create(data: CreatePromptRequest): Promise<Prompt>;
77
- /**
78
- * Update an existing prompt
79
- */
80
- update(id: string, data: Partial<CreatePromptRequest>): Promise<Prompt>;
81
- /**
82
- * Delete a prompt
83
- */
84
- delete(id: string): Promise<void>;
85
- /**
86
- * Run a prompt on a specific record
87
- */
88
- runOnRecord(id: string, recordId: string): Promise<any>;
89
- /**
90
- * Get flows using this prompt
91
- */
92
- getFlows(id: string): Promise<{
93
- flows: any[];
94
- }>;
95
- /**
96
- * Update flow attachments for a prompt
97
- */
98
- updateFlows(id: string, flowIds: string[]): Promise<{
99
- success: boolean;
100
- attachedFlows: number;
101
- }>;
102
- }
103
- /**
104
- * Records endpoint handlers
105
- */
106
- export declare class RecordsEndpoint {
107
- private client;
108
- constructor(client: ApiClient);
109
- /**
110
- * List all records for the authenticated user
111
- */
112
- list(params?: RecordListParams): Promise<PaginationResponse<RuntypeRecord>>;
113
- /**
114
- * Get a specific record by ID
115
- */
116
- get(id: string): Promise<RuntypeRecord>;
117
- /**
118
- * Create a new record
119
- */
120
- create(data: CreateRecordRequest): Promise<RuntypeRecord>;
121
- /**
122
- * Update an existing record
123
- */
124
- update(id: string, data: Partial<CreateRecordRequest>): Promise<RuntypeRecord>;
125
- /**
126
- * Delete a record
127
- */
128
- delete(id: string): Promise<void>;
129
- /**
130
- * Bulk delete multiple records
131
- */
132
- bulkDelete(ids: string[]): Promise<{
133
- success: boolean;
134
- deleted: number;
135
- deletedIds: string[];
136
- notFoundIds?: string[];
137
- }>;
138
- /**
139
- * Bulk edit multiple records
140
- */
141
- bulkEdit(data: BulkEditRequest): Promise<BulkEditResponse>;
142
- /**
143
- * Get results for a record
144
- */
145
- getResults(id: string, params?: {
146
- flowId?: string;
147
- fromDate?: string;
148
- toDate?: string;
149
- }): Promise<any[]>;
150
- /**
151
- * Delete a specific result for a record
152
- */
153
- deleteResult(id: string, resultId: string): Promise<void>;
154
- /**
155
- * Upload CSV file to create multiple records
156
- */
157
- uploadCsv(file: File, params?: {
158
- typeColumn?: string;
159
- nameColumn?: string;
160
- }): Promise<any>;
161
- /**
162
- * Get record types (distinct values)
163
- */
164
- getTypes(): Promise<{
165
- data: string[];
166
- total: number;
167
- }>;
168
- /**
169
- * Get example record by type and/or name
170
- */
171
- getExample(params: {
172
- type?: string;
173
- name?: string;
174
- }): Promise<PaginationResponse<RuntypeRecord>>;
175
- }
176
- /**
177
- * API Keys endpoint handlers
178
- */
179
- export declare class ApiKeysEndpoint {
180
- private client;
181
- constructor(client: ApiClient);
182
- /**
183
- * List all API keys for the authenticated user
184
- */
185
- list(): Promise<ApiKey[]>;
186
- /**
187
- * Get a specific API key by ID
188
- */
189
- get(id: string): Promise<ApiKey>;
190
- /**
191
- * Create a new API key
192
- */
193
- create(data: CreateApiKeyRequest): Promise<{
194
- apiKey: ApiKey;
195
- plainKey: string;
196
- warning: string;
197
- }>;
198
- /**
199
- * Update an existing API key
200
- */
201
- update(id: string, data: Partial<CreateApiKeyRequest>): Promise<{
202
- apiKey: ApiKey;
203
- }>;
204
- /**
205
- * Delete an API key
206
- */
207
- delete(id: string): Promise<void>;
208
- /**
209
- * Regenerate an API key
210
- */
211
- regenerate(id: string): Promise<{
212
- apiKey: ApiKey;
213
- plainKey: string;
214
- warning: string;
215
- }>;
216
- /**
217
- * Get API key analytics
218
- */
219
- getAnalytics(id: string): Promise<any>;
220
- /**
221
- * Get usage logs for an API key
222
- */
223
- getUsage(id: string, params?: {
224
- startDate?: string;
225
- endDate?: string;
226
- limit?: number;
227
- }): Promise<any>;
228
- /**
229
- * Get API key analytics (all keys or specific key)
230
- */
231
- getAnalyticsEnhanced(apiKeyId: string | 'all', params?: Record<string, string>): Promise<any>;
232
- /**
233
- * Get API key usage logs (all keys or specific key)
234
- */
235
- getLogs(apiKeyId: string | 'all', params?: Record<string, string>): Promise<any>;
236
- /**
237
- * Get API key permission options
238
- */
239
- getPermissionOptions(): Promise<any>;
240
- /**
241
- * Get API key security logs
242
- */
243
- getSecurityLogs(id: string): Promise<any>;
244
- /**
245
- * Update API key security settings
246
- */
247
- updateSecurity(id: string, data: any): Promise<any>;
248
- /**
249
- * Clear suspicious activity for API key
250
- */
251
- clearSuspiciousActivity(id: string): Promise<any>;
252
- }
253
- /**
254
- * Model Configurations endpoint handlers
255
- */
256
- export declare class ModelConfigsEndpoint {
257
- private client;
258
- constructor(client: ApiClient);
259
- /**
260
- * Get available models catalog
261
- */
262
- getAvailable(): Promise<ModelConfig[]>;
263
- /**
264
- * Get search-capable models (all available, regardless of user configuration)
265
- */
266
- getSearchCapable(): Promise<ModelConfig[]>;
267
- /**
268
- * Get configured search-capable models (only user's configured and enabled models)
269
- */
270
- getSearchConfigured(): Promise<ModelConfig[]>;
271
- /**
272
- * List user's model configurations
273
- */
274
- list(): Promise<ModelConfig[]>;
275
- /**
276
- * Create a new model configuration
277
- */
278
- create(data: CreateModelConfigRequest): Promise<ModelConfig>;
279
- /**
280
- * Update an existing model configuration
281
- */
282
- update(id: string, data: Partial<CreateModelConfigRequest>): Promise<ModelConfig>;
283
- /**
284
- * Delete a model configuration
285
- */
286
- delete(id: string): Promise<void>;
287
- /**
288
- * Enable/disable a model configuration
289
- */
290
- updateStatus(id: string, isEnabled: boolean): Promise<{
291
- success: boolean;
292
- message: string;
293
- }>;
294
- /**
295
- * Set a model configuration as default
296
- */
297
- setDefault(id: string): Promise<{
298
- success: boolean;
299
- message: string;
300
- data: ModelConfig;
301
- }>;
302
- /**
303
- * Get usage statistics
304
- */
305
- getUsage(): Promise<any>;
306
- }
307
- /**
308
- * Dispatch endpoint handler for atomic record/flow creation and execution
309
- */
310
- export declare class DispatchEndpoint {
311
- private client;
312
- constructor(client: ApiClient);
313
- /**
314
- * Dispatch: create and/or execute flows on records atomically
315
- */
316
- execute(data: DispatchRequest): Promise<any>;
317
- /**
318
- * Dispatch with streaming response
319
- */
320
- executeStream(data: DispatchRequest): Promise<Response>;
321
- /**
322
- * Resume paused flow execution
323
- * API expects snake_case field names
324
- *
325
- * @param data.execution_id - The execution ID to resume
326
- * @param data.tool_outputs - Tool outputs to inject into the flow
327
- * @param data.stream_response - Whether to stream the response
328
- * @param data.messages - Optional messages to override the original dispatch messages
329
- */
330
- resume(data: {
331
- executionId: string;
332
- toolOutputs?: Record<string, any>;
333
- streamResponse?: boolean;
334
- messages?: Array<{
335
- role: 'system' | 'user' | 'assistant';
336
- content: string | Array<{
337
- type: string;
338
- text?: string;
339
- image?: string;
340
- }>;
341
- }>;
342
- }): Promise<any>;
343
- /**
344
- * Evaluate a model-proposed runtime tool against a configurable allowlist policy.
345
- * Useful for local `propose_runtime_tool` handlers before redispatch.
346
- */
347
- gateGeneratedRuntimeToolProposal(proposal: unknown, options?: GeneratedRuntimeToolGateOptions): GeneratedRuntimeToolGateDecision;
348
- /**
349
- * Build standardized local-tool output for a generated tool proposal.
350
- * Returns `{ approved, reason, violations, tool? }`.
351
- */
352
- buildGeneratedRuntimeToolGateOutput(proposal: unknown, options?: GeneratedRuntimeToolGateOptions): {
353
- approved: boolean;
354
- reason: string;
355
- violations: string[];
356
- tool?: RuntimeTool;
357
- };
358
- /**
359
- * Attach approved runtime tools to a prompt step in a redispatch request.
360
- * Returns a new request object and does not mutate the original.
361
- */
362
- attachApprovedRuntimeTools(request: DispatchRequest, runtimeTools: RuntimeTool[], options?: AttachRuntimeToolsOptions): DispatchRequest;
363
- /**
364
- * Validate a generated runtime tool proposal and attach it to the redispatch
365
- * request if approved, in one call.
366
- */
367
- applyGeneratedRuntimeToolProposal(request: DispatchRequest, proposal: unknown, options?: ApplyGeneratedProposalOptions): ApplyGeneratedProposalResult;
368
- }
369
- /**
370
- * Chat endpoint handler
371
- */
372
- export declare class ChatEndpoint {
373
- private client;
374
- constructor(client: ApiClient);
375
- /**
376
- * Send a chat message
377
- */
378
- send(message: string): Promise<any>;
379
- /**
380
- * Send a chat message with streaming response
381
- */
382
- sendStream(message: string, options?: any): Promise<Response>;
383
- }
384
- /**
385
- * Users endpoint handlers
386
- */
387
- export declare class UsersEndpoint {
388
- private client;
389
- constructor(client: ApiClient);
390
- /**
391
- * Get current user profile
392
- */
393
- getProfile(): Promise<UserProfile>;
394
- /**
395
- * Update user profile
396
- */
397
- updateProfile(data: Partial<UserProfile>): Promise<UserProfile>;
398
- }
399
- /**
400
- * Analytics endpoint handlers
401
- */
402
- export declare class AnalyticsEndpoint {
403
- private client;
404
- constructor(client: ApiClient);
405
- /**
406
- * Get analytics stats
407
- */
408
- getStats(params?: Record<string, string>): Promise<any>;
409
- /**
410
- * Get analytics executions
411
- */
412
- getExecutions(params?: Record<string, string>): Promise<any>;
413
- /**
414
- * Get all record results (same as executions)
415
- */
416
- getAllRecordResults(params?: Record<string, string>): Promise<any>;
417
- /**
418
- * Get model usage analytics
419
- */
420
- getModelUsage(params?: ModelUsageQueryParams): Promise<ModelUsageResponse>;
421
- }
422
- /**
423
- * Flow Steps endpoint handlers
424
- *
425
- * @deprecated Flow steps are now consolidated into the flows endpoint.
426
- * Use `flows.get(id)` to get a flow with embedded `flowSteps`.
427
- * Use `flows.update(id, { flow_steps: [...] })` to update flow steps.
428
- */
429
- export declare class FlowStepsEndpoint {
430
- private client;
431
- constructor(client: ApiClient);
432
- /**
433
- * Get flow steps for a flow
434
- * @deprecated Use `flows.get(flowId)` instead - flow steps are now embedded in the flow response as `flowSteps`
435
- */
436
- getByFlow(flowId: string): Promise<any[]>;
437
- /**
438
- * Get a specific flow step
439
- * @deprecated Use `flows.get(flowId)` and find the step in `flowSteps` array
440
- */
441
- get(id: string): Promise<any>;
442
- /**
443
- * Create a flow step
444
- * @deprecated Use `flows.update(flowId, { flow_steps: [...] })` to add steps
445
- */
446
- create(data: any): Promise<any>;
447
- /**
448
- * Update a flow step
449
- * @deprecated Use `flows.update(flowId, { flow_steps: [...] })` to update steps
450
- */
451
- update(id: string, data: any): Promise<any>;
452
- /**
453
- * Delete a flow step
454
- * @deprecated Use `flows.update(flowId, { flow_steps: [...] })` with the step removed
455
- */
456
- delete(id: string): Promise<void>;
457
- /**
458
- * Reorder flow steps
459
- * @deprecated Use `flows.update(flowId, { flow_steps: [...] })` with updated order values
460
- */
461
- reorder(flowId: string, stepOrders: Array<{
462
- id: string;
463
- order: number;
464
- }>): Promise<any>;
465
- }
466
- /**
467
- * Context Templates endpoint handlers
468
- */
469
- export declare class ContextTemplatesEndpoint {
470
- private client;
471
- constructor(client: ApiClient);
472
- /**
473
- * List context templates
474
- */
475
- list(params?: Record<string, string>): Promise<any[]>;
476
- /**
477
- * Get a specific context template
478
- */
479
- get(id: string): Promise<any>;
480
- /**
481
- * Create a context template
482
- */
483
- create(data: any): Promise<any>;
484
- /**
485
- * Update a context template
486
- */
487
- update(id: string, data: any): Promise<any>;
488
- /**
489
- * Delete a context template
490
- */
491
- delete(id: string): Promise<void>;
492
- }
493
- /**
494
- * Tools endpoint handlers
495
- */
496
- export declare class ToolsEndpoint {
497
- private client;
498
- constructor(client: ApiClient);
499
- /**
500
- * List all tools for the authenticated user
501
- */
502
- list(params?: ListParams): Promise<PaginationResponse<Tool>>;
503
- /**
504
- * Get a specific tool by ID
505
- */
506
- get(id: string): Promise<Tool>;
507
- /**
508
- * Create a new tool
509
- */
510
- create(data: CreateToolRequest): Promise<Tool>;
511
- /**
512
- * Update an existing tool
513
- */
514
- update(id: string, data: UpdateToolRequest): Promise<Tool>;
515
- /**
516
- * Delete a tool
517
- */
518
- delete(id: string): Promise<void>;
519
- /**
520
- * Execute a tool
521
- */
522
- execute(id: string, data: ExecuteToolRequest): Promise<ExecuteToolResponse>;
523
- /**
524
- * Execute a tool with streaming response
525
- */
526
- executeStream(id: string, data: ExecuteToolRequest): Promise<Response>;
527
- /**
528
- * Test a tool (same as execute but for testing purposes)
529
- */
530
- test(id: string, data: ExecuteToolRequest): Promise<ExecuteToolResponse>;
531
- /**
532
- * Get tool executions for a specific tool
533
- */
534
- getExecutions(toolId: string, params?: ListParams): Promise<PaginationResponse<ToolExecution>>;
535
- /**
536
- * Get AI SDK compatible tool schemas
537
- */
538
- getSchemas(params?: {
539
- toolIds?: string[];
540
- }): Promise<any[]>;
541
- /**
542
- * Get available tools for prompts
543
- */
544
- getAvailable(): Promise<Tool[]>;
545
- /**
546
- * Convert a flow to a tool
547
- */
548
- convertFromFlow(flowId: string, data: {
549
- name: string;
550
- description: string;
551
- parameterMapping?: Record<string, string>;
552
- outputMapping?: string;
553
- }): Promise<Tool>;
554
- /**
555
- * Get all built-in tools
556
- */
557
- getBuiltInTools(): Promise<PaginationResponse<BuiltInTool>>;
558
- /**
559
- * Get built-in tools compatible with a specific model and provider
560
- */
561
- getCompatibleBuiltInTools(model: string, provider: string): Promise<PaginationResponse<BuiltInTool>>;
562
- /**
563
- * Get parameter schema for a specific built-in tool
564
- */
565
- getBuiltInToolSchema(toolId: string): Promise<BuiltInTool>;
566
- }
567
- /**
568
- * Eval endpoint handlers
569
- */
570
- export declare class EvalEndpoint {
571
- private client;
572
- constructor(client: ApiClient);
573
- /**
574
- * Run virtual eval with streaming response
575
- * Executes multiple eval configs simultaneously and streams results via multiplexed SSE
576
- */
577
- runVirtualEval(data: {
578
- record?: {
579
- name?: string;
580
- type?: string;
581
- metadata?: Record<string, any>;
582
- };
583
- messages?: Array<{
584
- role: 'system' | 'user' | 'assistant';
585
- content: string;
586
- }>;
587
- flowId?: string;
588
- flowDefinition?: any;
589
- evalConfigs: Array<{
590
- evalConfigId?: string;
591
- evalName?: string;
592
- stepOverrides?: Record<string, any>;
593
- }>;
594
- evalGroupId?: string;
595
- }): Promise<Response>;
596
- }
597
- /**
598
- * Client Tokens endpoint handlers
599
- *
600
- * Manages client tokens for secure browser-to-API communication.
601
- * Client tokens enable embedding chat widgets in external applications.
602
- */
603
- export declare class ClientTokensEndpoint {
604
- private client;
605
- constructor(client: ApiClient);
606
- /**
607
- * List all client tokens for the authenticated user
608
- */
609
- list(): Promise<ClientToken[]>;
610
- /**
611
- * Get a specific client token by ID
612
- */
613
- get(id: string): Promise<ClientToken>;
614
- /**
615
- * Create a new client token
616
- *
617
- * @returns The created token with the plain token value (shown only once)
618
- */
619
- create(data: CreateClientTokenRequest): Promise<CreateClientTokenResponse>;
620
- /**
621
- * Update an existing client token
622
- */
623
- update(id: string, data: UpdateClientTokenRequest): Promise<ClientToken>;
624
- /**
625
- * Delete a client token
626
- */
627
- delete(id: string): Promise<void>;
628
- /**
629
- * Regenerate a client token's value
630
- *
631
- * @returns The updated token with the new plain token value (shown only once)
632
- */
633
- regenerate(id: string): Promise<CreateClientTokenResponse>;
634
- /**
635
- * Get the plain token value for a client token
636
- *
637
- * Note: Only works if the token was just created or regenerated in the same session
638
- */
639
- getToken(id: string): Promise<{
640
- token: string;
641
- }>;
642
- /**
643
- * List conversations for a client token
644
- */
645
- listConversations(id: string, params?: {
646
- limit?: number;
647
- offset?: number;
648
- }): Promise<ListConversationsResponse>;
649
- }
650
- /**
651
- * Agent event types for streaming
652
- */
653
- export type AgentEventType = 'agent_start' | 'agent_iteration_start' | 'agent_turn_start' | 'agent_turn_delta' | 'agent_turn_complete' | 'agent_tool_start' | 'agent_tool_delta' | 'agent_tool_complete' | 'agent_iteration_complete' | 'agent_reflection' | 'agent_complete' | 'agent_error' | 'agent_ping' | 'agent_await';
654
- /**
655
- * Base agent event with common fields
656
- */
657
- export interface BaseAgentEvent {
658
- type: AgentEventType;
659
- executionId: string;
660
- seq: number;
661
- }
662
- /**
663
- * Agent start event
664
- */
665
- export interface AgentStartEvent extends BaseAgentEvent {
666
- type: 'agent_start';
667
- agentId: string;
668
- agentName: string;
669
- maxTurns: number;
670
- startedAt: string;
671
- config?: {
672
- model?: string;
673
- enableReflection?: boolean;
674
- };
675
- }
676
- /**
677
- * Agent iteration start event
678
- */
679
- export interface AgentIterationStartEvent extends BaseAgentEvent {
680
- type: 'agent_iteration_start';
681
- iteration: number;
682
- maxTurns: number;
683
- totalCost?: number;
684
- startedAt: string;
685
- }
686
- /**
687
- * Agent turn start event
688
- */
689
- export interface AgentTurnStartEvent extends BaseAgentEvent {
690
- type: 'agent_turn_start';
691
- iteration: number;
692
- turnId: string;
693
- turnIndex: number;
694
- role: 'user' | 'assistant' | 'system';
695
- }
696
- /**
697
- * Agent turn delta event (streaming content)
698
- */
699
- export interface AgentTurnDeltaEvent extends BaseAgentEvent {
700
- type: 'agent_turn_delta';
701
- iteration: number;
702
- turnId: string;
703
- delta: string;
704
- contentType: 'text' | 'thinking' | 'tool_input';
705
- }
706
- /**
707
- * Agent turn complete event
708
- */
709
- export interface AgentTurnCompleteEvent extends BaseAgentEvent {
710
- type: 'agent_turn_complete';
711
- iteration: number;
712
- turnId: string;
713
- role: 'user' | 'assistant' | 'system';
714
- completedAt: string;
715
- content?: string;
716
- tokens?: {
717
- input: number;
718
- output: number;
719
- };
720
- cost?: number;
721
- }
722
- /**
723
- * Agent tool start event
724
- */
725
- export interface AgentToolStartEvent extends BaseAgentEvent {
726
- type: 'agent_tool_start';
727
- iteration: number;
728
- toolCallId: string;
729
- toolName: string;
730
- toolType: 'flow' | 'mcp' | 'builtin' | 'custom' | 'external';
731
- parameters?: Record<string, unknown>;
732
- }
733
- /**
734
- * Agent tool delta event
735
- */
736
- export interface AgentToolDeltaEvent extends BaseAgentEvent {
737
- type: 'agent_tool_delta';
738
- iteration: number;
739
- toolCallId: string;
740
- delta: string;
741
- }
742
- /**
743
- * Agent tool complete event
744
- */
745
- export interface AgentToolCompleteEvent extends BaseAgentEvent {
746
- type: 'agent_tool_complete';
747
- iteration: number;
748
- toolCallId: string;
749
- toolName: string;
750
- success: boolean;
751
- result?: unknown;
752
- executionTime?: number;
753
- }
754
- /**
755
- * Agent iteration complete event
756
- */
757
- export interface AgentIterationCompleteEvent extends BaseAgentEvent {
758
- type: 'agent_iteration_complete';
759
- iteration: number;
760
- completedAt: string;
761
- output?: string;
762
- toolCallsMade: number;
763
- cost?: number;
764
- tokens?: {
765
- input: number;
766
- output: number;
767
- };
768
- duration?: number;
769
- stopConditionMet: boolean;
770
- }
771
- /**
772
- * Agent reflection event
773
- */
774
- export interface AgentReflectionEvent extends BaseAgentEvent {
775
- type: 'agent_reflection';
776
- iteration: number;
777
- reflection?: string;
778
- }
779
- /**
780
- * Agent complete event
781
- */
782
- export interface AgentCompleteEvent extends BaseAgentEvent {
783
- type: 'agent_complete';
784
- agentId: string;
785
- success: boolean;
786
- iterations: number;
787
- stopReason: 'complete' | 'end_turn' | 'max_turns' | 'max_cost' | 'timeout' | 'error';
788
- completedAt: string;
789
- totalCost?: number;
790
- totalTokens?: {
791
- input: number;
792
- output: number;
793
- };
794
- finalOutput?: string;
795
- duration?: number;
796
- error?: string;
797
- }
798
- /**
799
- * Agent error event
800
- */
801
- export interface AgentErrorEvent extends BaseAgentEvent {
802
- type: 'agent_error';
803
- iteration?: number;
804
- error: {
805
- code: string;
806
- message: string;
807
- details?: Record<string, unknown>;
808
- };
809
- recoverable: boolean;
810
- }
811
- /**
812
- * Agent ping event (keep-alive)
813
- */
814
- export interface AgentPingEvent extends BaseAgentEvent {
815
- type: 'agent_ping';
816
- timestamp: string;
817
- }
818
- /**
819
- * Agent await event (execution awaiting local tool result from client).
820
- */
821
- export interface AgentPausedEvent extends BaseAgentEvent {
822
- type: 'agent_await';
823
- executionId: string;
824
- toolId: string;
825
- toolName: string;
826
- parameters?: Record<string, unknown>;
827
- awaitedAt: string;
828
- }
829
- /**
830
- * Union of all agent event types
831
- */
832
- export type AgentEvent = AgentStartEvent | AgentIterationStartEvent | AgentTurnStartEvent | AgentTurnDeltaEvent | AgentTurnCompleteEvent | AgentToolStartEvent | AgentToolDeltaEvent | AgentToolCompleteEvent | AgentIterationCompleteEvent | AgentReflectionEvent | AgentCompleteEvent | AgentErrorEvent | AgentPingEvent | AgentPausedEvent;
833
- /**
834
- * Parsed SSE event with event type and data
835
- */
836
- interface ParsedSSEEvent {
837
- eventType: string | null;
838
- data: unknown;
839
- }
840
- /**
841
- * Callbacks for agent stream events
842
- */
843
- export interface AgentStreamCallbacks {
844
- onAgentStart?: (event: AgentStartEvent) => void;
845
- onIterationStart?: (event: AgentIterationStartEvent) => void;
846
- onTurnStart?: (event: AgentTurnStartEvent) => void;
847
- onTurnDelta?: (event: AgentTurnDeltaEvent) => void;
848
- onTurnComplete?: (event: AgentTurnCompleteEvent) => void;
849
- onToolStart?: (event: AgentToolStartEvent) => void;
850
- onToolDelta?: (event: AgentToolDeltaEvent) => void;
851
- onToolComplete?: (event: AgentToolCompleteEvent) => void;
852
- onIterationComplete?: (event: AgentIterationCompleteEvent) => void;
853
- onReflection?: (event: AgentReflectionEvent) => void;
854
- onAgentComplete?: (event: AgentCompleteEvent) => void;
855
- onAgentPaused?: (event: AgentPausedEvent) => void;
856
- onError?: (event: AgentErrorEvent) => void;
857
- onPing?: (event: AgentPingEvent) => void;
858
- onUnknownEvent?: (event: ParsedSSEEvent) => void;
859
- }
860
- /**
861
- * Agent message format
862
- */
863
- export interface AgentMessage {
864
- role: 'system' | 'user' | 'assistant';
865
- content: string | Array<{
866
- type: string;
867
- text?: string;
868
- image?: string;
869
- data?: string;
870
- }>;
871
- }
872
- /**
873
- * Definition for a local tool that executes on the client side.
874
- * Pairs the tool schema (sent to the server) with a handler (executed locally).
875
- */
876
- export interface LocalToolDefinition {
877
- /** Human-readable description of what the tool does */
878
- description: string;
879
- /** JSON Schema describing the tool's parameters */
880
- parametersSchema: Record<string, unknown>;
881
- /** Handler that executes locally when the agent invokes this tool */
882
- execute: (args: Record<string, unknown>) => Promise<unknown>;
883
- }
884
- /**
885
- * Runtime tool definition shape accepted by agent execution endpoints.
886
- */
887
- export interface AgentRuntimeToolDefinition {
888
- name: string;
889
- description: string;
890
- toolType: 'flow' | 'custom' | 'external' | 'local';
891
- parametersSchema: Record<string, unknown>;
892
- config?: Record<string, unknown>;
893
- }
894
- /**
895
- * Agent execute request
896
- */
897
- export interface AgentExecuteRequest {
898
- /** Conversation messages */
899
- messages: AgentMessage[];
900
- /** Variables to pass to the agent */
901
- variables?: Record<string, unknown>;
902
- /** Enable streaming response (default: true) */
903
- streamResponse?: boolean;
904
- /** Enable debug mode to include all fields in events */
905
- debugMode?: boolean;
906
- /** Model ID to use for this session (overrides agent config) */
907
- model?: string;
908
- /** Runtime tools to make available during execution */
909
- tools?: {
910
- runtimeTools?: AgentRuntimeToolDefinition[];
911
- };
912
- }
913
- /**
914
- * Agent execute response (non-streaming)
915
- */
916
- export interface AgentExecuteResponse {
917
- success: boolean;
918
- result: string;
919
- iterations: number;
920
- totalCost: number;
921
- stopReason: 'complete' | 'end_turn' | 'max_turns' | 'max_cost' | 'timeout' | 'error';
922
- reflections?: string[];
923
- error?: string;
924
- }
925
- interface LocalToolExecutionLoopSnapshot {
926
- executionId: string;
927
- pauseCount: number;
928
- discoveryPauseCount: number;
929
- consecutiveDiscoveryPauseCount: number;
930
- toolName: string;
931
- toolNameCount: number;
932
- parameters: Record<string, unknown>;
933
- toolResult: unknown;
934
- accumulatedOutput: string;
935
- actionKey: string;
936
- actionKeyCount: number;
937
- recentActionKeys: string[];
938
- }
939
- interface ExecuteWithLocalToolsOptions {
940
- onLocalToolResult?: (snapshot: LocalToolExecutionLoopSnapshot) => AgentCompleteEvent | null | undefined;
941
- }
942
- /**
943
- * Status of a long-task agent run
944
- */
945
- export type RunTaskStatus = 'running' | 'complete' | 'paused' | 'error' | 'budget_exceeded' | 'max_sessions';
946
- /**
947
- * A continuation point within a long-task run (for marathon resume).
948
- */
949
- export interface RunTaskContinuation {
950
- /** ISO timestamp when this continuation started */
951
- continuedAt: string;
952
- /** Session count at the time of continuation (from-session) */
953
- fromSession: number;
954
- /** User message provided on resume, if any */
955
- userMessage?: string;
956
- /** Model used for this continuation segment */
957
- model?: string;
958
- /** Cost of sessions in this continuation segment */
959
- segmentCost: number;
960
- }
961
- /**
962
- * Summary of a single session within a long-task run
963
- */
964
- export interface RunTaskSessionSummary {
965
- /** 1-based session index */
966
- index: number;
967
- /** Cost of this individual session (USD) */
968
- cost: number;
969
- /** Number of loop iterations in this session */
970
- iterations: number;
971
- /** Why this session stopped */
972
- stopReason: AgentExecuteResponse['stopReason'];
973
- /** Truncated output from this session */
974
- outputPreview: string;
975
- /** Compact summary of tool/discovery activity captured during the session */
976
- toolTraceSummary?: string;
977
- /** Whether repo discovery tools were used during the session */
978
- discoveryPerformed?: boolean;
979
- /** Whether the session attempted a file write even if it did not complete */
980
- attemptedWrite?: boolean;
981
- /** Whether the session wrote any files */
982
- wroteFiles?: boolean;
983
- /** Whether the assistant produced final text output */
984
- hadTextOutput?: boolean;
985
- /** Whether a verification command was run during the session */
986
- verificationAttempted?: boolean;
987
- /** Whether the latest verification command passed during the session */
988
- verificationPassed?: boolean;
989
- /** Best candidate file identified during the session */
990
- bestCandidatePath?: string;
991
- /** Recent action keys used during the session */
992
- actionKeys?: string[];
993
- /** ISO timestamp when this session completed */
994
- completedAt: string;
995
- }
996
- /**
997
- * Accumulated state for a long-task agent run.
998
- * This is both the in-memory state and the record metadata shape.
999
- */
1000
- export interface RunTaskState {
1001
- agentId: string;
1002
- agentName?: string;
1003
- taskName: string;
1004
- status: RunTaskStatus;
1005
- /** Total sessions completed so far */
1006
- sessionCount: number;
1007
- /** Total cost across all sessions (USD) */
1008
- totalCost: number;
1009
- /** Last agent output (full text) */
1010
- lastOutput: string;
1011
- /** Last terminal error captured from agent execution */
1012
- lastError?: string;
1013
- /** Last stop reason */
1014
- lastStopReason: AgentExecuteResponse['stopReason'];
1015
- /** Per-session summaries (kept trimmed to last N) */
1016
- sessions: RunTaskSessionSummary[];
1017
- /** ISO timestamp of first session */
1018
- startedAt: string;
1019
- /** ISO timestamp of last update */
1020
- updatedAt: string;
1021
- /** Original task message (first invocation) */
1022
- originalMessage?: string;
1023
- /** Full conversation message history (source of truth for resume) */
1024
- messages?: AgentMessage[];
1025
- /** History of continuation points */
1026
- continuations?: RunTaskContinuation[];
1027
- /** Per-model cost breakdown */
1028
- costByModel?: Record<string, number>;
1029
- /** Auto-generated repo bootstrap hints derived from the original task */
1030
- bootstrapContext?: string;
1031
- /** Current structured marathon workflow phase */
1032
- workflowPhase?: 'research' | 'planning' | 'execution' | 'complete';
1033
- /** Suggested markdown plan path for the task */
1034
- planPath?: string;
1035
- /** Whether the planning artifact has been written */
1036
- planWritten?: boolean;
1037
- /** Summary of the most recent automatic phase transition */
1038
- phaseTransitionSummary?: string;
1039
- /** Best current file candidate for the task */
1040
- bestCandidatePath?: string;
1041
- /** Reason the best candidate was selected */
1042
- bestCandidateReason?: string;
1043
- /** Recent candidate file paths discovered across sessions */
1044
- candidatePaths?: string[];
1045
- /** Recent file paths read by the agent */
1046
- recentReadPaths?: string[];
1047
- /** Recent action keys used across sessions for loop detection */
1048
- recentActionKeys?: string[];
1049
- /** Whether the current best candidate still needs a post-write verification read */
1050
- bestCandidateNeedsVerification?: boolean;
1051
- /** Whether the current best candidate has been re-read after the latest write */
1052
- bestCandidateVerified?: boolean;
1053
- /** Whether completion requires a successful verification command */
1054
- verificationRequired?: boolean;
1055
- /** Whether the latest verification command succeeded */
1056
- lastVerificationPassed?: boolean;
1057
- }
1058
- export type RunTaskResumeState = Pick<RunTaskState, 'originalMessage' | 'bootstrapContext' | 'workflowPhase' | 'planPath' | 'planWritten' | 'bestCandidatePath' | 'bestCandidateReason' | 'candidatePaths' | 'recentReadPaths' | 'recentActionKeys' | 'bestCandidateNeedsVerification' | 'bestCandidateVerified' | 'verificationRequired' | 'lastVerificationPassed'>;
1059
- /**
1060
- * Callback invoked after each session completes.
1061
- * Return `false` to stop the loop early.
1062
- */
1063
- export type RunTaskOnSession = (state: RunTaskState) => void | false | Promise<void | false>;
1064
- /**
1065
- * Options for `agents.runTask()`
1066
- */
1067
- export interface RunTaskOptions {
1068
- /** The user message / task instruction for the agent */
1069
- message: string;
1070
- /** Maximum number of sessions to run (default: 50) */
1071
- maxSessions?: number;
1072
- /** Maximum total cost in USD across all sessions */
1073
- maxCost?: number;
1074
- /** Whether to use streaming for each session execution (default: true) */
1075
- stream?: boolean;
1076
- /** Enable debug mode on each session */
1077
- debugMode?: boolean;
1078
- /** Called after each session. Return false to stop early. */
1079
- onSession?: RunTaskOnSession;
1080
- /**
1081
- * Sync progress to a Runtype record after each session.
1082
- * Pass `true` to use the agent name, or a string for a custom task name.
1083
- * The record will have type "agent-task" and be upserted by name.
1084
- */
1085
- trackProgress?: boolean | string;
1086
- /** Callbacks for streaming events (only used when stream: true) */
1087
- streamCallbacks?: AgentStreamCallbacks;
1088
- /**
1089
- * Local tools that execute on the client side.
1090
- * When the agent invokes a tool with `toolType: 'local'`, the SDK will
1091
- * pause, call the matching handler, and resume the agent with the result.
1092
- * Requires `stream: true` (default).
1093
- */
1094
- localTools?: Record<string, LocalToolDefinition>;
1095
- /** Model ID to use (overrides agent's configured model) */
1096
- model?: string;
1097
- /** Previous messages from a prior run (for continuation/resume) */
1098
- previousMessages?: AgentMessage[];
1099
- /** New user message for continuation (appended after previous context) */
1100
- continuationMessage?: string;
1101
- /** Use compact summary instead of full message history for continuation */
1102
- compact?: boolean;
1103
- /** Saved workflow state to seed a resumed or restarted marathon run */
1104
- resumeState?: RunTaskResumeState;
1105
- }
1106
- /**
1107
- * Final result returned by `agents.runTask()`
1108
- */
1109
- export interface RunTaskResult {
1110
- status: RunTaskStatus;
1111
- sessionCount: number;
1112
- totalCost: number;
1113
- lastOutput: string;
1114
- sessions: RunTaskSessionSummary[];
1115
- /** The record ID if trackProgress was enabled */
1116
- recordId?: string;
1117
- }
1118
- /**
1119
- * Agent data
1120
- */
1121
- export interface Agent {
1122
- id: string;
1123
- name: string;
1124
- description: string | null;
1125
- agentType: string;
1126
- primaryFlowId: string | null;
1127
- config: Record<string, unknown> | null;
1128
- externalConfig: Record<string, unknown> | null;
1129
- createdAt: string;
1130
- updatedAt: string;
1131
- }
1132
- /**
1133
- * Agents endpoint handlers
1134
- */
1135
- export declare class AgentsEndpoint {
1136
- private client;
1137
- constructor(client: ApiClient);
1138
- /**
1139
- * List all agents for the authenticated user
1140
- */
1141
- list(params?: ListParams): Promise<PaginationResponse<Agent>>;
1142
- /**
1143
- * Get a specific agent by ID
1144
- */
1145
- get(id: string): Promise<Agent>;
1146
- /**
1147
- * Create a new agent
1148
- */
1149
- create(data: Partial<Agent>): Promise<Agent>;
1150
- /**
1151
- * Update an existing agent
1152
- */
1153
- update(id: string, data: Partial<Agent>): Promise<Agent>;
1154
- /**
1155
- * Delete an agent
1156
- */
1157
- delete(id: string): Promise<void>;
1158
- /**
1159
- * Evaluate a model-proposed runtime tool against a configurable allowlist policy.
1160
- * Useful for local `propose_runtime_tool` handlers before follow-up execution.
1161
- */
1162
- gateGeneratedRuntimeToolProposal(proposal: unknown, options?: GeneratedRuntimeToolGateOptions): GeneratedRuntimeToolGateDecision;
1163
- /**
1164
- * Build standardized local-tool output for a generated tool proposal.
1165
- * Returns `{ approved, reason, violations, tool? }`.
1166
- */
1167
- buildGeneratedRuntimeToolGateOutput(proposal: unknown, options?: GeneratedRuntimeToolGateOptions): {
1168
- approved: boolean;
1169
- reason: string;
1170
- violations: string[];
1171
- tool?: RuntimeTool;
1172
- };
1173
- /**
1174
- * Create a local tool definition that validates model-proposed runtime tools.
1175
- * Plug this into `executeWithLocalTools()` under a name like `propose_runtime_tool`.
1176
- */
1177
- createGeneratedRuntimeToolGateLocalTool(options?: GeneratedRuntimeToolGateOptions & {
1178
- description?: string;
1179
- }): LocalToolDefinition;
1180
- /**
1181
- * Attach approved runtime tools to an agent execute request.
1182
- * Returns a new request object and does not mutate the original.
1183
- */
1184
- attachApprovedRuntimeTools(request: AgentExecuteRequest, runtimeTools: RuntimeTool[]): AgentExecuteRequest;
1185
- /**
1186
- * Validate a generated runtime tool proposal and append it to an agent execute
1187
- * request if approved, in one call.
1188
- */
1189
- applyGeneratedRuntimeToolProposal(request: AgentExecuteRequest, proposal: unknown, options?: GeneratedRuntimeToolGateOptions): {
1190
- decision: GeneratedRuntimeToolGateDecision;
1191
- request: AgentExecuteRequest;
1192
- };
1193
- /**
1194
- * Execute an agent (non-streaming)
1195
- */
1196
- execute(id: string, data: AgentExecuteRequest): Promise<AgentExecuteResponse>;
1197
- /**
1198
- * Execute an agent with streaming response
1199
- *
1200
- * Returns a Response object with SSE stream.
1201
- * Use `executeWithCallbacks` for easier handling.
1202
- *
1203
- * @example
1204
- * ```typescript
1205
- * const response = await client.agents.executeStream('agt_123', {
1206
- * messages: [{ role: 'user', content: 'Write me a poem' }],
1207
- * debugMode: true,
1208
- * })
1209
- *
1210
- * // Process the stream manually
1211
- * const reader = response.body?.getReader()
1212
- * // ...
1213
- * ```
1214
- */
1215
- executeStream(id: string, data: AgentExecuteRequest): Promise<Response>;
1216
- /**
1217
- * Execute an agent with streaming and callbacks
1218
- *
1219
- * Processes the SSE stream and calls the appropriate callbacks for each event type.
1220
- * This is the recommended way to handle agent streaming.
1221
- *
1222
- * @example
1223
- * ```typescript
1224
- * let content = ''
1225
- *
1226
- * const result = await client.agents.executeWithCallbacks('agt_123', {
1227
- * messages: [{ role: 'user', content: 'Write me a poem' }],
1228
- * debugMode: true,
1229
- * }, {
1230
- * onTurnDelta: (event) => {
1231
- * content += event.delta
1232
- * process.stdout.write(event.delta)
1233
- * },
1234
- * onIterationComplete: (event) => {
1235
- * console.log(`\nIteration ${event.iteration} complete`)
1236
- * },
1237
- * onAgentComplete: (event) => {
1238
- * console.log(`\nAgent finished: ${event.stopReason}`)
1239
- * },
1240
- * onError: (event) => {
1241
- * console.error(`Error: ${event.error.message}`)
1242
- * },
1243
- * })
1244
- *
1245
- * console.log('Final result:', result)
1246
- * ```
1247
- */
1248
- executeWithCallbacks(id: string, data: AgentExecuteRequest, callbacks: AgentStreamCallbacks): Promise<AgentCompleteEvent | null>;
1249
- /**
1250
- * Execute an agent with local tool support (pause/resume loop)
1251
- *
1252
- * When the agent hits a tool with `toolType: 'local'`, the server emits
1253
- * `agent_await`. This method automatically executes the local tool and
1254
- * resumes execution, repeating until the agent completes.
1255
- *
1256
- * @example
1257
- * ```typescript
1258
- * const result = await client.agents.executeWithLocalTools('agt_123', {
1259
- * messages: [{ role: 'user', content: 'Create a file called hello.txt' }],
1260
- * }, {
1261
- * write_file: async ({ path, content }) => {
1262
- * fs.writeFileSync(path, content)
1263
- * return 'ok'
1264
- * },
1265
- * })
1266
- * ```
1267
- */
1268
- executeWithLocalTools(id: string, data: AgentExecuteRequest, localTools: Record<string, LocalToolDefinition>, callbacks?: AgentStreamCallbacks, options?: ExecuteWithLocalToolsOptions): Promise<AgentCompleteEvent | null>;
1269
- private createEmptyToolTrace;
1270
- private isDiscoveryLocalTool;
1271
- private buildLocalToolActionKey;
1272
- private buildProspectiveStateForSessionTrace;
1273
- private buildForcedLocalToolTurnCompleteEvent;
1274
- private createLocalToolLoopGuard;
1275
- private pushToolTraceEntry;
1276
- private isPreservationSensitiveTask;
1277
- private getLikelySupportingCandidatePaths;
1278
- private hasSufficientResearchEvidence;
1279
- private buildEffectiveSessionOutput;
1280
- private canAcceptTaskCompletion;
1281
- private summarizeUnknownForTrace;
1282
- private summarizeTextBlockForTrace;
1283
- private parseVerificationResult;
1284
- private normalizeCandidatePath;
1285
- private dedupeNormalizedCandidatePaths;
1286
- private isMarathonArtifactPath;
1287
- private isDiscoveryToolName;
1288
- private sanitizeTaskSlug;
1289
- private getDefaultPlanPath;
1290
- private dirnameOfCandidatePath;
1291
- private joinCandidatePath;
1292
- private scoreCandidatePath;
1293
- private addCandidateToTrace;
1294
- private extractCandidatePathsFromText;
1295
- private parseSearchRepoResultForCandidates;
1296
- private extractBestCandidateFromBootstrapContext;
1297
- private sanitizeResumeState;
1298
- private buildPhaseInstructions;
1299
- private updateWorkflowPhase;
1300
- private wrapLocalToolsForTrace;
1301
- private createTraceCallbacks;
1302
- private buildToolTraceSummary;
1303
- private extractBootstrapQueries;
1304
- private generateBootstrapDiscoveryContext;
1305
- private buildStuckTurnRecoveryMessage;
1306
- /**
1307
- * Run a long-task agent across multiple sessions with automatic state management.
1308
- *
1309
- * Each session is a single agent execution. The SDK drives the loop client-side,
1310
- * calling the agent's execute endpoint repeatedly and accumulating context.
1311
- * Progress is optionally synced to a Runtype record for dashboard visibility.
1312
- *
1313
- * @example
1314
- * ```typescript
1315
- * const result = await client.agents.runTask('agt_123', {
1316
- * message: 'Build a REST API with CRUD endpoints',
1317
- * maxSessions: 20,
1318
- * maxCost: 5.00,
1319
- * trackProgress: true,
1320
- * onSession: (state) => {
1321
- * console.log(`Session ${state.sessionCount}: ${state.lastStopReason} ($${state.totalCost.toFixed(4)})`)
1322
- * },
1323
- * })
1324
- *
1325
- * console.log(`Finished: ${result.status} after ${result.sessionCount} sessions`)
1326
- * ```
1327
- */
1328
- runTask(id: string, options: RunTaskOptions): Promise<RunTaskResult>;
1329
- /** Stop phrases that indicate the agent considers its task complete. */
1330
- private static readonly STOP_PHRASES;
1331
- /**
1332
- * Client-side fallback for detecting task completion in agent output.
1333
- * Mirrors the API's detectAutoComplete() for non-loop agents that return 'end_turn'.
1334
- */
1335
- private detectTaskCompletion;
1336
- /**
1337
- * Generate a compact summary of prior work for continuation context.
1338
- * Used when compact mode is enabled to keep token usage low.
1339
- */
1340
- private generateCompactSummary;
1341
- /**
1342
- * Build messages for a session, injecting progress context for continuation sessions.
1343
- * Optionally accepts continuation context for marathon resume scenarios.
1344
- */
1345
- private buildSessionMessages;
1346
- /**
1347
- * Upsert a record to sync long-task progress to the dashboard.
1348
- * Creates the record on first call, updates it on subsequent calls.
1349
- */
1350
- private syncProgressRecord;
1351
- }
1352
- export {};
1353
- //# sourceMappingURL=endpoints.d.ts.map