@agent-os-sdk/client 0.1.2 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/AgentOsClient.d.ts +39 -44
- package/dist/client/AgentOsClient.d.ts.map +1 -1
- package/dist/client/AgentOsClient.js +162 -44
- package/dist/client/auth.d.ts +102 -0
- package/dist/client/auth.d.ts.map +1 -0
- package/dist/client/auth.js +44 -0
- package/dist/generated/openapi.d.ts +914 -202
- package/dist/generated/openapi.d.ts.map +1 -1
- package/dist/index.d.ts +10 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/modules/approvals.d.ts +8 -22
- package/dist/modules/approvals.d.ts.map +1 -1
- package/dist/modules/approvals.js +27 -130
- package/dist/modules/artifacts.d.ts +28 -79
- package/dist/modules/artifacts.d.ts.map +1 -1
- package/dist/modules/artifacts.js +30 -197
- package/dist/modules/budgets.d.ts +47 -70
- package/dist/modules/budgets.d.ts.map +1 -1
- package/dist/modules/budgets.js +28 -139
- package/dist/modules/builder.d.ts +21 -1
- package/dist/modules/builder.d.ts.map +1 -1
- package/dist/modules/builder.js +25 -3
- package/dist/modules/capabilities.d.ts +39 -50
- package/dist/modules/capabilities.d.ts.map +1 -1
- package/dist/modules/capabilities.js +32 -95
- package/dist/modules/deployments.d.ts +49 -92
- package/dist/modules/deployments.d.ts.map +1 -1
- package/dist/modules/deployments.js +37 -209
- package/dist/modules/flows.d.ts +11 -31
- package/dist/modules/flows.d.ts.map +1 -1
- package/dist/modules/flows.js +33 -157
- package/dist/modules/handoff.d.ts +7 -4
- package/dist/modules/handoff.d.ts.map +1 -1
- package/dist/modules/handoff.js +25 -88
- package/dist/modules/incidents.d.ts +40 -101
- package/dist/modules/incidents.d.ts.map +1 -1
- package/dist/modules/incidents.js +31 -208
- package/dist/modules/policies.d.ts +42 -69
- package/dist/modules/policies.d.ts.map +1 -1
- package/dist/modules/policies.js +25 -159
- package/dist/modules/runs.d.ts +89 -3
- package/dist/modules/runs.d.ts.map +1 -1
- package/dist/modules/runs.js +75 -4
- package/package.json +1 -1
- package/src/client/AgentOsClient.ts +185 -67
- package/src/client/auth.ts +148 -0
- package/src/generated/openapi.ts +914 -202
- package/src/generated/swagger.json +770 -630
- package/src/index.ts +22 -10
- package/src/modules/approvals.ts +31 -132
- package/src/modules/artifacts.ts +41 -245
- package/src/modules/budgets.ts +65 -181
- package/src/modules/builder.ts +25 -3
- package/src/modules/capabilities.ts +58 -139
- package/src/modules/deployments.ts +67 -271
- package/src/modules/flows.ts +37 -163
- package/src/modules/handoff.ts +29 -93
- package/src/modules/incidents.ts +56 -282
- package/src/modules/policies.ts +57 -203
- package/src/modules/runs.ts +123 -5
package/src/modules/policies.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Policies Module - Governance
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* Defines and evaluates policies that control agent behavior.
|
|
7
|
-
* Enables enterprise governance and compliance.
|
|
2
|
+
* Policies Module - Governance & Compliance
|
|
3
|
+
*
|
|
4
|
+
* NOT IMPLEMENTED - Backend endpoint not available.
|
|
5
|
+
* All methods return 501 NotImplemented.
|
|
8
6
|
*/
|
|
9
7
|
|
|
10
8
|
import type { RawClient, APIResponse } from "../client/raw.js";
|
|
@@ -13,60 +11,59 @@ import type { RawClient, APIResponse } from "../client/raw.js";
|
|
|
13
11
|
// Types
|
|
14
12
|
// ============================================================================
|
|
15
13
|
|
|
16
|
-
export type
|
|
17
|
-
export type
|
|
14
|
+
export type PolicyScope = "agent" | "workspace" | "tenant" | "global";
|
|
15
|
+
export type PolicyEnforcement = "hard" | "soft" | "audit_only";
|
|
16
|
+
|
|
17
|
+
export interface PolicyRule {
|
|
18
|
+
id: string;
|
|
19
|
+
type: "allow" | "deny" | "require_approval" | "log";
|
|
20
|
+
condition: string;
|
|
21
|
+
action?: string;
|
|
22
|
+
message?: string;
|
|
23
|
+
}
|
|
18
24
|
|
|
19
25
|
export interface Policy {
|
|
20
26
|
id: string;
|
|
21
27
|
name: string;
|
|
22
28
|
description?: string;
|
|
23
|
-
type: PolicyType;
|
|
24
29
|
scope: PolicyScope;
|
|
25
30
|
scope_id?: string;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
priority: number;
|
|
31
|
+
enforcement: PolicyEnforcement;
|
|
32
|
+
rules: PolicyRule[];
|
|
29
33
|
enabled: boolean;
|
|
34
|
+
priority: number;
|
|
30
35
|
created_at: string;
|
|
31
36
|
updated_at: string;
|
|
32
37
|
}
|
|
33
38
|
|
|
34
|
-
export interface
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
export interface PolicyAction {
|
|
41
|
-
type: "block" | "allow" | "require_approval" | "log" | "alert" | "modify";
|
|
42
|
-
config?: Record<string, unknown>;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface PolicyEvaluationInput {
|
|
46
|
-
action: string;
|
|
47
|
-
resource: string;
|
|
48
|
-
context: Record<string, unknown>;
|
|
39
|
+
export interface PolicyEvaluation {
|
|
40
|
+
policy_id: string;
|
|
41
|
+
policy_name: string;
|
|
42
|
+
passed: boolean;
|
|
43
|
+
violated_rules: PolicyRule[];
|
|
44
|
+
audit_log_id?: string;
|
|
49
45
|
}
|
|
50
46
|
|
|
51
47
|
export interface PolicyEvaluationResult {
|
|
52
48
|
allowed: boolean;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
audit_entries: PolicyAuditEntry[];
|
|
49
|
+
evaluations: PolicyEvaluation[];
|
|
50
|
+
requires_approval: boolean;
|
|
51
|
+
blocking_policies: string[];
|
|
57
52
|
}
|
|
58
53
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
decision: "allow" | "deny" | "pending_approval";
|
|
63
|
-
reason: string;
|
|
64
|
-
evaluated_at: string;
|
|
65
|
-
}
|
|
54
|
+
// ============================================================================
|
|
55
|
+
// Helper for 501 responses
|
|
56
|
+
// ============================================================================
|
|
66
57
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
58
|
+
function notImplemented<T>(method: string): APIResponse<T> {
|
|
59
|
+
return {
|
|
60
|
+
data: undefined,
|
|
61
|
+
error: {
|
|
62
|
+
code: "NOT_IMPLEMENTED",
|
|
63
|
+
message: `PoliciesModule.${method}() is not implemented. Backend endpoint not available.`,
|
|
64
|
+
},
|
|
65
|
+
response: new Response(null, { status: 501, statusText: "Not Implemented" }),
|
|
66
|
+
};
|
|
70
67
|
}
|
|
71
68
|
|
|
72
69
|
// ============================================================================
|
|
@@ -76,183 +73,40 @@ export interface PolicyListResponse {
|
|
|
76
73
|
export class PoliciesModule {
|
|
77
74
|
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
78
75
|
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* List all policies.
|
|
82
|
-
*/
|
|
76
|
+
/** @returns 501 Not Implemented */
|
|
83
77
|
async list(params?: {
|
|
84
78
|
scope?: PolicyScope;
|
|
79
|
+
scope_id?: string;
|
|
85
80
|
enabled?: boolean;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
{
|
|
91
|
-
id: "policy_1",
|
|
92
|
-
name: "Block External Email",
|
|
93
|
-
description: "Prevent agents from sending external emails without approval",
|
|
94
|
-
type: "require_approval",
|
|
95
|
-
scope: "tenant",
|
|
96
|
-
conditions: [
|
|
97
|
-
{ field: "action", operator: "eq", value: "send_email" },
|
|
98
|
-
{ field: "recipient.domain", operator: "not_in", value: ["company.com"] },
|
|
99
|
-
],
|
|
100
|
-
actions: [
|
|
101
|
-
{ type: "require_approval", config: { approver_role: "admin" } },
|
|
102
|
-
],
|
|
103
|
-
priority: 100,
|
|
104
|
-
enabled: true,
|
|
105
|
-
created_at: new Date(Date.now() - 86400000).toISOString(),
|
|
106
|
-
updated_at: new Date().toISOString(),
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
id: "policy_2",
|
|
110
|
-
name: "Audit All Tool Calls",
|
|
111
|
-
description: "Log all tool calls for compliance",
|
|
112
|
-
type: "audit",
|
|
113
|
-
scope: "tenant",
|
|
114
|
-
conditions: [
|
|
115
|
-
{ field: "action", operator: "eq", value: "tool_call" },
|
|
116
|
-
],
|
|
117
|
-
actions: [
|
|
118
|
-
{ type: "log" },
|
|
119
|
-
],
|
|
120
|
-
priority: 50,
|
|
121
|
-
enabled: true,
|
|
122
|
-
created_at: new Date(Date.now() - 86400000).toISOString(),
|
|
123
|
-
updated_at: new Date().toISOString(),
|
|
124
|
-
},
|
|
125
|
-
],
|
|
126
|
-
total: 2,
|
|
127
|
-
};
|
|
128
|
-
return { data: mockPolicies, error: undefined, response: new Response() };
|
|
81
|
+
limit?: number;
|
|
82
|
+
offset?: number;
|
|
83
|
+
}): Promise<APIResponse<{ items: Policy[]; total: number }>> {
|
|
84
|
+
return notImplemented<{ items: Policy[]; total: number }>("list");
|
|
129
85
|
}
|
|
130
86
|
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Get a policy by ID.
|
|
134
|
-
*/
|
|
87
|
+
/** @returns 501 Not Implemented */
|
|
135
88
|
async get(policyId: string): Promise<APIResponse<Policy>> {
|
|
136
|
-
|
|
137
|
-
const mockPolicy: Policy = {
|
|
138
|
-
id: policyId,
|
|
139
|
-
name: "Block External Email",
|
|
140
|
-
description: "Prevent agents from sending external emails without approval",
|
|
141
|
-
type: "require_approval",
|
|
142
|
-
scope: "tenant",
|
|
143
|
-
conditions: [
|
|
144
|
-
{ field: "action", operator: "eq", value: "send_email" },
|
|
145
|
-
],
|
|
146
|
-
actions: [
|
|
147
|
-
{ type: "require_approval" },
|
|
148
|
-
],
|
|
149
|
-
priority: 100,
|
|
150
|
-
enabled: true,
|
|
151
|
-
created_at: new Date(Date.now() - 86400000).toISOString(),
|
|
152
|
-
updated_at: new Date().toISOString(),
|
|
153
|
-
};
|
|
154
|
-
return { data: mockPolicy, error: undefined, response: new Response() };
|
|
89
|
+
return notImplemented<Policy>("get");
|
|
155
90
|
}
|
|
156
91
|
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Create a new policy.
|
|
160
|
-
*/
|
|
92
|
+
/** @returns 501 Not Implemented */
|
|
161
93
|
async create(body: {
|
|
162
94
|
name: string;
|
|
163
95
|
description?: string;
|
|
164
|
-
type: PolicyType;
|
|
165
96
|
scope: PolicyScope;
|
|
166
97
|
scope_id?: string;
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
priority?: number;
|
|
98
|
+
enforcement: PolicyEnforcement;
|
|
99
|
+
rules: PolicyRule[];
|
|
170
100
|
}): Promise<APIResponse<Policy>> {
|
|
171
|
-
|
|
172
|
-
const mockPolicy: Policy = {
|
|
173
|
-
id: `policy_${Date.now()}`,
|
|
174
|
-
name: body.name,
|
|
175
|
-
description: body.description,
|
|
176
|
-
type: body.type,
|
|
177
|
-
scope: body.scope,
|
|
178
|
-
scope_id: body.scope_id,
|
|
179
|
-
conditions: body.conditions,
|
|
180
|
-
actions: body.actions,
|
|
181
|
-
priority: body.priority || 50,
|
|
182
|
-
enabled: true,
|
|
183
|
-
created_at: new Date().toISOString(),
|
|
184
|
-
updated_at: new Date().toISOString(),
|
|
185
|
-
};
|
|
186
|
-
return { data: mockPolicy, error: undefined, response: new Response() };
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// MOCK - Simulated update
|
|
190
|
-
/**
|
|
191
|
-
* Update a policy.
|
|
192
|
-
*/
|
|
193
|
-
async update(policyId: string, body: Partial<Policy>): Promise<APIResponse<Policy>> {
|
|
194
|
-
// MOCK - Returns simulated data
|
|
195
|
-
const mockPolicy: Policy = {
|
|
196
|
-
id: policyId,
|
|
197
|
-
name: body.name || "Updated Policy",
|
|
198
|
-
type: body.type || "allow",
|
|
199
|
-
scope: body.scope || "tenant",
|
|
200
|
-
conditions: body.conditions || [],
|
|
201
|
-
actions: body.actions || [],
|
|
202
|
-
priority: body.priority || 50,
|
|
203
|
-
enabled: body.enabled ?? true,
|
|
204
|
-
created_at: new Date(Date.now() - 86400000).toISOString(),
|
|
205
|
-
updated_at: new Date().toISOString(),
|
|
206
|
-
};
|
|
207
|
-
return { data: mockPolicy, error: undefined, response: new Response() };
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// MOCK - Simulated delete
|
|
211
|
-
/**
|
|
212
|
-
* Delete a policy.
|
|
213
|
-
*/
|
|
214
|
-
async delete(policyId: string): Promise<APIResponse<void>> {
|
|
215
|
-
// MOCK - Returns success
|
|
216
|
-
return { data: undefined, error: undefined, response: new Response() };
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// MOCK - Simulated evaluate
|
|
220
|
-
/**
|
|
221
|
-
* Evaluate policies against an action (simulation).
|
|
222
|
-
*/
|
|
223
|
-
async evaluate(input: PolicyEvaluationInput): Promise<APIResponse<PolicyEvaluationResult>> {
|
|
224
|
-
// MOCK - Returns simulated evaluation
|
|
225
|
-
const mockResult: PolicyEvaluationResult = {
|
|
226
|
-
allowed: true,
|
|
227
|
-
matched_policies: ["policy_2"],
|
|
228
|
-
required_approvals: [],
|
|
229
|
-
warnings: [],
|
|
230
|
-
audit_entries: [
|
|
231
|
-
{
|
|
232
|
-
policy_id: "policy_2",
|
|
233
|
-
policy_name: "Audit All Tool Calls",
|
|
234
|
-
decision: "allow",
|
|
235
|
-
reason: "Action logged for audit",
|
|
236
|
-
evaluated_at: new Date().toISOString(),
|
|
237
|
-
},
|
|
238
|
-
],
|
|
239
|
-
};
|
|
240
|
-
return { data: mockResult, error: undefined, response: new Response() };
|
|
101
|
+
return notImplemented<Policy>("create");
|
|
241
102
|
}
|
|
242
103
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
allowed: true,
|
|
251
|
-
matched_policies: [],
|
|
252
|
-
required_approvals: [],
|
|
253
|
-
warnings: [],
|
|
254
|
-
audit_entries: [],
|
|
255
|
-
};
|
|
256
|
-
return { data: mockResult, error: undefined, response: new Response() };
|
|
104
|
+
/** @returns 501 Not Implemented */
|
|
105
|
+
async evaluate(context: {
|
|
106
|
+
agent_id: string;
|
|
107
|
+
action: string;
|
|
108
|
+
payload?: Record<string, unknown>;
|
|
109
|
+
}): Promise<APIResponse<PolicyEvaluationResult>> {
|
|
110
|
+
return notImplemented<PolicyEvaluationResult>("evaluate");
|
|
257
111
|
}
|
|
258
112
|
}
|
package/src/modules/runs.ts
CHANGED
|
@@ -20,7 +20,7 @@ type CheckpointListResponse = components["schemas"]["CheckpointListResponse"];
|
|
|
20
20
|
// Response types
|
|
21
21
|
export interface Run {
|
|
22
22
|
run_id: string;
|
|
23
|
-
status:
|
|
23
|
+
status: RunStatus;
|
|
24
24
|
thread_id?: string;
|
|
25
25
|
agent_id: string;
|
|
26
26
|
agent_version_id?: string;
|
|
@@ -34,8 +34,26 @@ export interface Run {
|
|
|
34
34
|
completed_at?: string;
|
|
35
35
|
duration_ms?: number;
|
|
36
36
|
reused?: boolean;
|
|
37
|
+
// HITL (Human-in-the-Loop) fields
|
|
38
|
+
human_prompt?: string;
|
|
39
|
+
checkpoint_id?: string;
|
|
40
|
+
// Replay fields
|
|
41
|
+
replayed_from_run_id?: string;
|
|
42
|
+
replayed_from_checkpoint_id?: string;
|
|
43
|
+
replay_mode?: "best_effort" | "strict";
|
|
37
44
|
}
|
|
38
45
|
|
|
46
|
+
// Run status values
|
|
47
|
+
export type RunStatus =
|
|
48
|
+
| "pending"
|
|
49
|
+
| "queued"
|
|
50
|
+
| "running"
|
|
51
|
+
| "completed"
|
|
52
|
+
| "failed"
|
|
53
|
+
| "cancelled"
|
|
54
|
+
| "waiting_for_human"
|
|
55
|
+
| "resumed";
|
|
56
|
+
|
|
39
57
|
export interface RunEvent {
|
|
40
58
|
id: string;
|
|
41
59
|
run_id: string;
|
|
@@ -54,6 +72,24 @@ export interface CreateRunResponse {
|
|
|
54
72
|
export type RunListResponse = PaginatedResponse<Run>;
|
|
55
73
|
export type RunEventsResponse = PaginatedResponse<RunEvent>;
|
|
56
74
|
|
|
75
|
+
/** Wave 2.3: Seq-based polling response for execution events */
|
|
76
|
+
export interface RunEventsPollResponse {
|
|
77
|
+
events: RunEventDto[];
|
|
78
|
+
latest_seq: number;
|
|
79
|
+
next_after_seq: number;
|
|
80
|
+
has_more: boolean;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Single event from seq-based polling */
|
|
84
|
+
export interface RunEventDto {
|
|
85
|
+
id: string;
|
|
86
|
+
seq: number;
|
|
87
|
+
type: string;
|
|
88
|
+
timestamp: string;
|
|
89
|
+
attempt_id: string;
|
|
90
|
+
payload: Record<string, unknown> | null;
|
|
91
|
+
}
|
|
92
|
+
|
|
57
93
|
export class RunsModule {
|
|
58
94
|
constructor(
|
|
59
95
|
private client: RawClient,
|
|
@@ -152,11 +188,30 @@ export class RunsModule {
|
|
|
152
188
|
|
|
153
189
|
/**
|
|
154
190
|
* Resume a run waiting for human input (HITL).
|
|
191
|
+
* After the run reaches status 'waiting_for_human', use this to provide
|
|
192
|
+
* the human response and continue execution.
|
|
193
|
+
*
|
|
194
|
+
* @param runId - The run ID to resume
|
|
195
|
+
* @param body - The human input to provide
|
|
196
|
+
* @returns Updated run (status will change to 'resumed' then 'queued')
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* // List runs waiting for human input
|
|
201
|
+
* const waiting = await client.runs.list({ status: 'waiting_for_human' })
|
|
202
|
+
*
|
|
203
|
+
* // Get the prompt
|
|
204
|
+
* const run = await client.runs.get(runId)
|
|
205
|
+
* console.log(run.human_prompt) // "Deseja continuar com a compra?"
|
|
206
|
+
*
|
|
207
|
+
* // Respond
|
|
208
|
+
* await client.runs.resume(runId, { input: { answer: "sim" } })
|
|
209
|
+
* ```
|
|
155
210
|
*/
|
|
156
|
-
async resume(runId: string, input: unknown): Promise<APIResponse<Run>> {
|
|
211
|
+
async resume(runId: string, body: { input: unknown }): Promise<APIResponse<Run>> {
|
|
157
212
|
return this.client.POST<Run>("/v1/api/runs/{runId}/resume", {
|
|
158
213
|
params: { path: { runId } },
|
|
159
|
-
body
|
|
214
|
+
body,
|
|
160
215
|
headers: this.headers(),
|
|
161
216
|
});
|
|
162
217
|
}
|
|
@@ -173,11 +228,37 @@ export class RunsModule {
|
|
|
173
228
|
|
|
174
229
|
/**
|
|
175
230
|
* Replay from checkpoint (stateful).
|
|
231
|
+
* Creates a NEW run that starts from the specified checkpoint.
|
|
232
|
+
*
|
|
233
|
+
* @param runId - The original run to replay from
|
|
234
|
+
* @param checkpointId - The checkpoint ID to start from
|
|
235
|
+
* @param options - Replay options
|
|
236
|
+
* @returns New run created from checkpoint
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```ts
|
|
240
|
+
* const checkpoints = await client.runs.getCheckpoints(runId)
|
|
241
|
+
* const newRun = await client.runs.replay(runId, checkpoints[2].id, {
|
|
242
|
+
* mode: 'best_effort',
|
|
243
|
+
* reason: 'Debugging step 3'
|
|
244
|
+
* })
|
|
245
|
+
* ```
|
|
176
246
|
*/
|
|
177
|
-
async replay(
|
|
247
|
+
async replay(
|
|
248
|
+
runId: string,
|
|
249
|
+
checkpointId?: string,
|
|
250
|
+
options?: {
|
|
251
|
+
mode?: "best_effort" | "strict";
|
|
252
|
+
reason?: string;
|
|
253
|
+
}
|
|
254
|
+
): Promise<APIResponse<CreateRunResponse>> {
|
|
178
255
|
return this.client.POST<CreateRunResponse>("/v1/api/runs/{runId}/replay", {
|
|
179
256
|
params: { path: { runId } },
|
|
180
|
-
body: {
|
|
257
|
+
body: {
|
|
258
|
+
checkpoint_id: checkpointId,
|
|
259
|
+
mode: options?.mode,
|
|
260
|
+
reason: options?.reason
|
|
261
|
+
},
|
|
181
262
|
headers: this.headers(),
|
|
182
263
|
});
|
|
183
264
|
}
|
|
@@ -201,6 +282,43 @@ export class RunsModule {
|
|
|
201
282
|
/** Alias: runs.events() -> runs.getEvents() */
|
|
202
283
|
events = (runId: string, params?: PaginationParams) => this.getEvents(runId, params);
|
|
203
284
|
|
|
285
|
+
/**
|
|
286
|
+
* Wave 2.3: Seq-based event polling for execution trace.
|
|
287
|
+
* Use this for incremental polling with reconnection support.
|
|
288
|
+
*
|
|
289
|
+
* @param runId - Run ID to poll events for
|
|
290
|
+
* @param params - Polling options
|
|
291
|
+
* @returns Events with seq cursors for pagination
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* ```ts
|
|
295
|
+
* let afterSeq = 0;
|
|
296
|
+
* while (run.status === 'running') {
|
|
297
|
+
* const { data } = await client.runs.pollEvents(runId, { afterSeq });
|
|
298
|
+
* for (const event of data.events) {
|
|
299
|
+
* console.log(event.type, event.payload);
|
|
300
|
+
* }
|
|
301
|
+
* afterSeq = data.next_after_seq;
|
|
302
|
+
* await sleep(1000);
|
|
303
|
+
* }
|
|
304
|
+
* ```
|
|
305
|
+
*/
|
|
306
|
+
async pollEvents(runId: string, params?: {
|
|
307
|
+
afterSeq?: number;
|
|
308
|
+
limit?: number;
|
|
309
|
+
}): Promise<APIResponse<RunEventsPollResponse>> {
|
|
310
|
+
return this.client.GET<RunEventsPollResponse>("/v1/api/runs/{runId}/events/stream", {
|
|
311
|
+
params: {
|
|
312
|
+
path: { runId },
|
|
313
|
+
query: {
|
|
314
|
+
afterSeq: params?.afterSeq ?? 0,
|
|
315
|
+
limit: params?.limit ?? 100
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
headers: this.headers(),
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
|
|
204
322
|
// ======================== Checkpoints ========================
|
|
205
323
|
|
|
206
324
|
/**
|