@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.
Files changed (61) hide show
  1. package/dist/client/AgentOsClient.d.ts +39 -44
  2. package/dist/client/AgentOsClient.d.ts.map +1 -1
  3. package/dist/client/AgentOsClient.js +162 -44
  4. package/dist/client/auth.d.ts +102 -0
  5. package/dist/client/auth.d.ts.map +1 -0
  6. package/dist/client/auth.js +44 -0
  7. package/dist/generated/openapi.d.ts +914 -202
  8. package/dist/generated/openapi.d.ts.map +1 -1
  9. package/dist/index.d.ts +10 -9
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +3 -1
  12. package/dist/modules/approvals.d.ts +8 -22
  13. package/dist/modules/approvals.d.ts.map +1 -1
  14. package/dist/modules/approvals.js +27 -130
  15. package/dist/modules/artifacts.d.ts +28 -79
  16. package/dist/modules/artifacts.d.ts.map +1 -1
  17. package/dist/modules/artifacts.js +30 -197
  18. package/dist/modules/budgets.d.ts +47 -70
  19. package/dist/modules/budgets.d.ts.map +1 -1
  20. package/dist/modules/budgets.js +28 -139
  21. package/dist/modules/builder.d.ts +21 -1
  22. package/dist/modules/builder.d.ts.map +1 -1
  23. package/dist/modules/builder.js +25 -3
  24. package/dist/modules/capabilities.d.ts +39 -50
  25. package/dist/modules/capabilities.d.ts.map +1 -1
  26. package/dist/modules/capabilities.js +32 -95
  27. package/dist/modules/deployments.d.ts +49 -92
  28. package/dist/modules/deployments.d.ts.map +1 -1
  29. package/dist/modules/deployments.js +37 -209
  30. package/dist/modules/flows.d.ts +11 -31
  31. package/dist/modules/flows.d.ts.map +1 -1
  32. package/dist/modules/flows.js +33 -157
  33. package/dist/modules/handoff.d.ts +7 -4
  34. package/dist/modules/handoff.d.ts.map +1 -1
  35. package/dist/modules/handoff.js +25 -88
  36. package/dist/modules/incidents.d.ts +40 -101
  37. package/dist/modules/incidents.d.ts.map +1 -1
  38. package/dist/modules/incidents.js +31 -208
  39. package/dist/modules/policies.d.ts +42 -69
  40. package/dist/modules/policies.d.ts.map +1 -1
  41. package/dist/modules/policies.js +25 -159
  42. package/dist/modules/runs.d.ts +89 -3
  43. package/dist/modules/runs.d.ts.map +1 -1
  44. package/dist/modules/runs.js +75 -4
  45. package/package.json +1 -1
  46. package/src/client/AgentOsClient.ts +185 -67
  47. package/src/client/auth.ts +148 -0
  48. package/src/generated/openapi.ts +914 -202
  49. package/src/generated/swagger.json +770 -630
  50. package/src/index.ts +22 -10
  51. package/src/modules/approvals.ts +31 -132
  52. package/src/modules/artifacts.ts +41 -245
  53. package/src/modules/budgets.ts +65 -181
  54. package/src/modules/builder.ts +25 -3
  55. package/src/modules/capabilities.ts +58 -139
  56. package/src/modules/deployments.ts +67 -271
  57. package/src/modules/flows.ts +37 -163
  58. package/src/modules/handoff.ts +29 -93
  59. package/src/modules/incidents.ts +56 -282
  60. package/src/modules/policies.ts +57 -203
  61. package/src/modules/runs.ts +123 -5
@@ -1,10 +1,8 @@
1
1
  /**
2
- * Policies Module - Governance Rules
3
- *
4
- * // MOCK - This module contains mock implementations for future features
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 PolicyType = "allow" | "deny" | "require_approval" | "audit";
17
- export type PolicyScope = "tenant" | "workspace" | "agent" | "run";
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
- conditions: PolicyCondition[];
27
- actions: PolicyAction[];
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 PolicyCondition {
35
- field: string;
36
- operator: "eq" | "neq" | "in" | "not_in" | "gt" | "lt" | "contains" | "regex";
37
- value: unknown;
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
- matched_policies: string[];
54
- required_approvals: string[];
55
- warnings: string[];
56
- audit_entries: PolicyAuditEntry[];
49
+ evaluations: PolicyEvaluation[];
50
+ requires_approval: boolean;
51
+ blocking_policies: string[];
57
52
  }
58
53
 
59
- export interface PolicyAuditEntry {
60
- policy_id: string;
61
- policy_name: string;
62
- decision: "allow" | "deny" | "pending_approval";
63
- reason: string;
64
- evaluated_at: string;
65
- }
54
+ // ============================================================================
55
+ // Helper for 501 responses
56
+ // ============================================================================
66
57
 
67
- export interface PolicyListResponse {
68
- items: Policy[];
69
- total: number;
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
- // MOCK - Simulated list
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
- }): Promise<APIResponse<PolicyListResponse>> {
87
- // MOCK - Returns simulated data
88
- const mockPolicies: PolicyListResponse = {
89
- items: [
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
- // MOCK - Simulated get
132
- /**
133
- * Get a policy by ID.
134
- */
87
+ /** @returns 501 Not Implemented */
135
88
  async get(policyId: string): Promise<APIResponse<Policy>> {
136
- // MOCK - Returns simulated data
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
- // MOCK - Simulated create
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
- conditions: PolicyCondition[];
168
- actions: PolicyAction[];
169
- priority?: number;
98
+ enforcement: PolicyEnforcement;
99
+ rules: PolicyRule[];
170
100
  }): Promise<APIResponse<Policy>> {
171
- // MOCK - Returns simulated data
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
- // MOCK - Simulated enforce
244
- /**
245
- * Enforce policies (apply to current context).
246
- */
247
- async enforce(runId: string): Promise<APIResponse<PolicyEvaluationResult>> {
248
- // MOCK - Returns simulated enforcement
249
- const mockResult: PolicyEvaluationResult = {
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
  }
@@ -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: "pending" | "running" | "completed" | "failed" | "cancelled" | "waiting_input";
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: { input },
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(runId: string, checkpointId?: string, mode?: "best_effort" | "deterministic"): Promise<APIResponse<CreateRunResponse>> {
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: { checkpoint_id: checkpointId, mode },
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
  /**