@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
|
@@ -1,103 +1,76 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Policies Module - Governance
|
|
2
|
+
* Policies Module - Governance & Compliance
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* Defines and evaluates policies that control agent behavior.
|
|
7
|
-
* Enables enterprise governance and compliance.
|
|
4
|
+
* NOT IMPLEMENTED - Backend endpoint not available.
|
|
5
|
+
* All methods return 501 NotImplemented.
|
|
8
6
|
*/
|
|
9
7
|
import type { RawClient, APIResponse } from "../client/raw.js";
|
|
10
|
-
export type
|
|
11
|
-
export type
|
|
8
|
+
export type PolicyScope = "agent" | "workspace" | "tenant" | "global";
|
|
9
|
+
export type PolicyEnforcement = "hard" | "soft" | "audit_only";
|
|
10
|
+
export interface PolicyRule {
|
|
11
|
+
id: string;
|
|
12
|
+
type: "allow" | "deny" | "require_approval" | "log";
|
|
13
|
+
condition: string;
|
|
14
|
+
action?: string;
|
|
15
|
+
message?: string;
|
|
16
|
+
}
|
|
12
17
|
export interface Policy {
|
|
13
18
|
id: string;
|
|
14
19
|
name: string;
|
|
15
20
|
description?: string;
|
|
16
|
-
type: PolicyType;
|
|
17
21
|
scope: PolicyScope;
|
|
18
22
|
scope_id?: string;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
priority: number;
|
|
23
|
+
enforcement: PolicyEnforcement;
|
|
24
|
+
rules: PolicyRule[];
|
|
22
25
|
enabled: boolean;
|
|
26
|
+
priority: number;
|
|
23
27
|
created_at: string;
|
|
24
28
|
updated_at: string;
|
|
25
29
|
}
|
|
26
|
-
export interface
|
|
27
|
-
field: string;
|
|
28
|
-
operator: "eq" | "neq" | "in" | "not_in" | "gt" | "lt" | "contains" | "regex";
|
|
29
|
-
value: unknown;
|
|
30
|
-
}
|
|
31
|
-
export interface PolicyAction {
|
|
32
|
-
type: "block" | "allow" | "require_approval" | "log" | "alert" | "modify";
|
|
33
|
-
config?: Record<string, unknown>;
|
|
34
|
-
}
|
|
35
|
-
export interface PolicyEvaluationInput {
|
|
36
|
-
action: string;
|
|
37
|
-
resource: string;
|
|
38
|
-
context: Record<string, unknown>;
|
|
39
|
-
}
|
|
40
|
-
export interface PolicyEvaluationResult {
|
|
41
|
-
allowed: boolean;
|
|
42
|
-
matched_policies: string[];
|
|
43
|
-
required_approvals: string[];
|
|
44
|
-
warnings: string[];
|
|
45
|
-
audit_entries: PolicyAuditEntry[];
|
|
46
|
-
}
|
|
47
|
-
export interface PolicyAuditEntry {
|
|
30
|
+
export interface PolicyEvaluation {
|
|
48
31
|
policy_id: string;
|
|
49
32
|
policy_name: string;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
33
|
+
passed: boolean;
|
|
34
|
+
violated_rules: PolicyRule[];
|
|
35
|
+
audit_log_id?: string;
|
|
53
36
|
}
|
|
54
|
-
export interface
|
|
55
|
-
|
|
56
|
-
|
|
37
|
+
export interface PolicyEvaluationResult {
|
|
38
|
+
allowed: boolean;
|
|
39
|
+
evaluations: PolicyEvaluation[];
|
|
40
|
+
requires_approval: boolean;
|
|
41
|
+
blocking_policies: string[];
|
|
57
42
|
}
|
|
58
43
|
export declare class PoliciesModule {
|
|
59
44
|
private client;
|
|
60
45
|
private headers;
|
|
61
46
|
constructor(client: RawClient, headers: () => Record<string, string>);
|
|
62
|
-
/**
|
|
63
|
-
* List all policies.
|
|
64
|
-
*/
|
|
47
|
+
/** @returns 501 Not Implemented */
|
|
65
48
|
list(params?: {
|
|
66
49
|
scope?: PolicyScope;
|
|
50
|
+
scope_id?: string;
|
|
67
51
|
enabled?: boolean;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
52
|
+
limit?: number;
|
|
53
|
+
offset?: number;
|
|
54
|
+
}): Promise<APIResponse<{
|
|
55
|
+
items: Policy[];
|
|
56
|
+
total: number;
|
|
57
|
+
}>>;
|
|
58
|
+
/** @returns 501 Not Implemented */
|
|
72
59
|
get(policyId: string): Promise<APIResponse<Policy>>;
|
|
73
|
-
/**
|
|
74
|
-
* Create a new policy.
|
|
75
|
-
*/
|
|
60
|
+
/** @returns 501 Not Implemented */
|
|
76
61
|
create(body: {
|
|
77
62
|
name: string;
|
|
78
63
|
description?: string;
|
|
79
|
-
type: PolicyType;
|
|
80
64
|
scope: PolicyScope;
|
|
81
65
|
scope_id?: string;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
priority?: number;
|
|
66
|
+
enforcement: PolicyEnforcement;
|
|
67
|
+
rules: PolicyRule[];
|
|
85
68
|
}): Promise<APIResponse<Policy>>;
|
|
86
|
-
/**
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
*/
|
|
93
|
-
delete(policyId: string): Promise<APIResponse<void>>;
|
|
94
|
-
/**
|
|
95
|
-
* Evaluate policies against an action (simulation).
|
|
96
|
-
*/
|
|
97
|
-
evaluate(input: PolicyEvaluationInput): Promise<APIResponse<PolicyEvaluationResult>>;
|
|
98
|
-
/**
|
|
99
|
-
* Enforce policies (apply to current context).
|
|
100
|
-
*/
|
|
101
|
-
enforce(runId: string): Promise<APIResponse<PolicyEvaluationResult>>;
|
|
69
|
+
/** @returns 501 Not Implemented */
|
|
70
|
+
evaluate(context: {
|
|
71
|
+
agent_id: string;
|
|
72
|
+
action: string;
|
|
73
|
+
payload?: Record<string, unknown>;
|
|
74
|
+
}): Promise<APIResponse<PolicyEvaluationResult>>;
|
|
102
75
|
}
|
|
103
76
|
//# sourceMappingURL=policies.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policies.d.ts","sourceRoot":"","sources":["../../src/modules/policies.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"policies.d.ts","sourceRoot":"","sources":["../../src/modules/policies.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAM/D,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACtE,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,MAAM,GAAG,YAAY,CAAC;AAE/D,MAAM,WAAW,UAAU;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,kBAAkB,GAAG,KAAK,CAAC;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,MAAM;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,iBAAiB,CAAC;IAC/B,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC7B,SAA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,CAAC,CAAC;IAIhC,mCAAmC;IAC7B,QAAQ,CAAC,OAAO,EAAE;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACrC,GAAG,OAAO,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC;CAGnD"}
|
package/dist/modules/policies.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Policies Module - Governance
|
|
2
|
+
* Policies Module - Governance & Compliance
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* Defines and evaluates policies that control agent behavior.
|
|
7
|
-
* Enables enterprise governance and compliance.
|
|
4
|
+
* NOT IMPLEMENTED - Backend endpoint not available.
|
|
5
|
+
* All methods return 501 NotImplemented.
|
|
8
6
|
*/
|
|
9
7
|
// ============================================================================
|
|
8
|
+
// Helper for 501 responses
|
|
9
|
+
// ============================================================================
|
|
10
|
+
function notImplemented(method) {
|
|
11
|
+
return {
|
|
12
|
+
data: undefined,
|
|
13
|
+
error: {
|
|
14
|
+
code: "NOT_IMPLEMENTED",
|
|
15
|
+
message: `PoliciesModule.${method}() is not implemented. Backend endpoint not available.`,
|
|
16
|
+
},
|
|
17
|
+
response: new Response(null, { status: 501, statusText: "Not Implemented" }),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
// ============================================================================
|
|
10
21
|
// Module
|
|
11
22
|
// ============================================================================
|
|
12
23
|
export class PoliciesModule {
|
|
@@ -16,165 +27,20 @@ export class PoliciesModule {
|
|
|
16
27
|
this.client = client;
|
|
17
28
|
this.headers = headers;
|
|
18
29
|
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* List all policies.
|
|
22
|
-
*/
|
|
30
|
+
/** @returns 501 Not Implemented */
|
|
23
31
|
async list(params) {
|
|
24
|
-
|
|
25
|
-
const mockPolicies = {
|
|
26
|
-
items: [
|
|
27
|
-
{
|
|
28
|
-
id: "policy_1",
|
|
29
|
-
name: "Block External Email",
|
|
30
|
-
description: "Prevent agents from sending external emails without approval",
|
|
31
|
-
type: "require_approval",
|
|
32
|
-
scope: "tenant",
|
|
33
|
-
conditions: [
|
|
34
|
-
{ field: "action", operator: "eq", value: "send_email" },
|
|
35
|
-
{ field: "recipient.domain", operator: "not_in", value: ["company.com"] },
|
|
36
|
-
],
|
|
37
|
-
actions: [
|
|
38
|
-
{ type: "require_approval", config: { approver_role: "admin" } },
|
|
39
|
-
],
|
|
40
|
-
priority: 100,
|
|
41
|
-
enabled: true,
|
|
42
|
-
created_at: new Date(Date.now() - 86400000).toISOString(),
|
|
43
|
-
updated_at: new Date().toISOString(),
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
id: "policy_2",
|
|
47
|
-
name: "Audit All Tool Calls",
|
|
48
|
-
description: "Log all tool calls for compliance",
|
|
49
|
-
type: "audit",
|
|
50
|
-
scope: "tenant",
|
|
51
|
-
conditions: [
|
|
52
|
-
{ field: "action", operator: "eq", value: "tool_call" },
|
|
53
|
-
],
|
|
54
|
-
actions: [
|
|
55
|
-
{ type: "log" },
|
|
56
|
-
],
|
|
57
|
-
priority: 50,
|
|
58
|
-
enabled: true,
|
|
59
|
-
created_at: new Date(Date.now() - 86400000).toISOString(),
|
|
60
|
-
updated_at: new Date().toISOString(),
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
total: 2,
|
|
64
|
-
};
|
|
65
|
-
return { data: mockPolicies, error: undefined, response: new Response() };
|
|
32
|
+
return notImplemented("list");
|
|
66
33
|
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Get a policy by ID.
|
|
70
|
-
*/
|
|
34
|
+
/** @returns 501 Not Implemented */
|
|
71
35
|
async get(policyId) {
|
|
72
|
-
|
|
73
|
-
const mockPolicy = {
|
|
74
|
-
id: policyId,
|
|
75
|
-
name: "Block External Email",
|
|
76
|
-
description: "Prevent agents from sending external emails without approval",
|
|
77
|
-
type: "require_approval",
|
|
78
|
-
scope: "tenant",
|
|
79
|
-
conditions: [
|
|
80
|
-
{ field: "action", operator: "eq", value: "send_email" },
|
|
81
|
-
],
|
|
82
|
-
actions: [
|
|
83
|
-
{ type: "require_approval" },
|
|
84
|
-
],
|
|
85
|
-
priority: 100,
|
|
86
|
-
enabled: true,
|
|
87
|
-
created_at: new Date(Date.now() - 86400000).toISOString(),
|
|
88
|
-
updated_at: new Date().toISOString(),
|
|
89
|
-
};
|
|
90
|
-
return { data: mockPolicy, error: undefined, response: new Response() };
|
|
36
|
+
return notImplemented("get");
|
|
91
37
|
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Create a new policy.
|
|
95
|
-
*/
|
|
38
|
+
/** @returns 501 Not Implemented */
|
|
96
39
|
async create(body) {
|
|
97
|
-
|
|
98
|
-
const mockPolicy = {
|
|
99
|
-
id: `policy_${Date.now()}`,
|
|
100
|
-
name: body.name,
|
|
101
|
-
description: body.description,
|
|
102
|
-
type: body.type,
|
|
103
|
-
scope: body.scope,
|
|
104
|
-
scope_id: body.scope_id,
|
|
105
|
-
conditions: body.conditions,
|
|
106
|
-
actions: body.actions,
|
|
107
|
-
priority: body.priority || 50,
|
|
108
|
-
enabled: true,
|
|
109
|
-
created_at: new Date().toISOString(),
|
|
110
|
-
updated_at: new Date().toISOString(),
|
|
111
|
-
};
|
|
112
|
-
return { data: mockPolicy, error: undefined, response: new Response() };
|
|
113
|
-
}
|
|
114
|
-
// MOCK - Simulated update
|
|
115
|
-
/**
|
|
116
|
-
* Update a policy.
|
|
117
|
-
*/
|
|
118
|
-
async update(policyId, body) {
|
|
119
|
-
// MOCK - Returns simulated data
|
|
120
|
-
const mockPolicy = {
|
|
121
|
-
id: policyId,
|
|
122
|
-
name: body.name || "Updated Policy",
|
|
123
|
-
type: body.type || "allow",
|
|
124
|
-
scope: body.scope || "tenant",
|
|
125
|
-
conditions: body.conditions || [],
|
|
126
|
-
actions: body.actions || [],
|
|
127
|
-
priority: body.priority || 50,
|
|
128
|
-
enabled: body.enabled ?? true,
|
|
129
|
-
created_at: new Date(Date.now() - 86400000).toISOString(),
|
|
130
|
-
updated_at: new Date().toISOString(),
|
|
131
|
-
};
|
|
132
|
-
return { data: mockPolicy, error: undefined, response: new Response() };
|
|
133
|
-
}
|
|
134
|
-
// MOCK - Simulated delete
|
|
135
|
-
/**
|
|
136
|
-
* Delete a policy.
|
|
137
|
-
*/
|
|
138
|
-
async delete(policyId) {
|
|
139
|
-
// MOCK - Returns success
|
|
140
|
-
return { data: undefined, error: undefined, response: new Response() };
|
|
141
|
-
}
|
|
142
|
-
// MOCK - Simulated evaluate
|
|
143
|
-
/**
|
|
144
|
-
* Evaluate policies against an action (simulation).
|
|
145
|
-
*/
|
|
146
|
-
async evaluate(input) {
|
|
147
|
-
// MOCK - Returns simulated evaluation
|
|
148
|
-
const mockResult = {
|
|
149
|
-
allowed: true,
|
|
150
|
-
matched_policies: ["policy_2"],
|
|
151
|
-
required_approvals: [],
|
|
152
|
-
warnings: [],
|
|
153
|
-
audit_entries: [
|
|
154
|
-
{
|
|
155
|
-
policy_id: "policy_2",
|
|
156
|
-
policy_name: "Audit All Tool Calls",
|
|
157
|
-
decision: "allow",
|
|
158
|
-
reason: "Action logged for audit",
|
|
159
|
-
evaluated_at: new Date().toISOString(),
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
};
|
|
163
|
-
return { data: mockResult, error: undefined, response: new Response() };
|
|
40
|
+
return notImplemented("create");
|
|
164
41
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
*/
|
|
169
|
-
async enforce(runId) {
|
|
170
|
-
// MOCK - Returns simulated enforcement
|
|
171
|
-
const mockResult = {
|
|
172
|
-
allowed: true,
|
|
173
|
-
matched_policies: [],
|
|
174
|
-
required_approvals: [],
|
|
175
|
-
warnings: [],
|
|
176
|
-
audit_entries: [],
|
|
177
|
-
};
|
|
178
|
-
return { data: mockResult, error: undefined, response: new Response() };
|
|
42
|
+
/** @returns 501 Not Implemented */
|
|
43
|
+
async evaluate(context) {
|
|
44
|
+
return notImplemented("evaluate");
|
|
179
45
|
}
|
|
180
46
|
}
|
package/dist/modules/runs.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ type CancelRunResponse = components["schemas"]["CancelRunResponse"];
|
|
|
15
15
|
type CheckpointListResponse = components["schemas"]["CheckpointListResponse"];
|
|
16
16
|
export interface Run {
|
|
17
17
|
run_id: string;
|
|
18
|
-
status:
|
|
18
|
+
status: RunStatus;
|
|
19
19
|
thread_id?: string;
|
|
20
20
|
agent_id: string;
|
|
21
21
|
agent_version_id?: string;
|
|
@@ -29,7 +29,13 @@ export interface Run {
|
|
|
29
29
|
completed_at?: string;
|
|
30
30
|
duration_ms?: number;
|
|
31
31
|
reused?: boolean;
|
|
32
|
+
human_prompt?: string;
|
|
33
|
+
checkpoint_id?: string;
|
|
34
|
+
replayed_from_run_id?: string;
|
|
35
|
+
replayed_from_checkpoint_id?: string;
|
|
36
|
+
replay_mode?: "best_effort" | "strict";
|
|
32
37
|
}
|
|
38
|
+
export type RunStatus = "pending" | "queued" | "running" | "completed" | "failed" | "cancelled" | "waiting_for_human" | "resumed";
|
|
33
39
|
export interface RunEvent {
|
|
34
40
|
id: string;
|
|
35
41
|
run_id: string;
|
|
@@ -45,6 +51,22 @@ export interface CreateRunResponse {
|
|
|
45
51
|
}
|
|
46
52
|
export type RunListResponse = PaginatedResponse<Run>;
|
|
47
53
|
export type RunEventsResponse = PaginatedResponse<RunEvent>;
|
|
54
|
+
/** Wave 2.3: Seq-based polling response for execution events */
|
|
55
|
+
export interface RunEventsPollResponse {
|
|
56
|
+
events: RunEventDto[];
|
|
57
|
+
latest_seq: number;
|
|
58
|
+
next_after_seq: number;
|
|
59
|
+
has_more: boolean;
|
|
60
|
+
}
|
|
61
|
+
/** Single event from seq-based polling */
|
|
62
|
+
export interface RunEventDto {
|
|
63
|
+
id: string;
|
|
64
|
+
seq: number;
|
|
65
|
+
type: string;
|
|
66
|
+
timestamp: string;
|
|
67
|
+
attempt_id: string;
|
|
68
|
+
payload: Record<string, unknown> | null;
|
|
69
|
+
}
|
|
48
70
|
export declare class RunsModule {
|
|
49
71
|
private client;
|
|
50
72
|
private baseUrl;
|
|
@@ -111,16 +133,55 @@ export declare class RunsModule {
|
|
|
111
133
|
cancel(runId: string, reason?: string): Promise<APIResponse<CancelRunResponse>>;
|
|
112
134
|
/**
|
|
113
135
|
* Resume a run waiting for human input (HITL).
|
|
136
|
+
* After the run reaches status 'waiting_for_human', use this to provide
|
|
137
|
+
* the human response and continue execution.
|
|
138
|
+
*
|
|
139
|
+
* @param runId - The run ID to resume
|
|
140
|
+
* @param body - The human input to provide
|
|
141
|
+
* @returns Updated run (status will change to 'resumed' then 'queued')
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* // List runs waiting for human input
|
|
146
|
+
* const waiting = await client.runs.list({ status: 'waiting_for_human' })
|
|
147
|
+
*
|
|
148
|
+
* // Get the prompt
|
|
149
|
+
* const run = await client.runs.get(runId)
|
|
150
|
+
* console.log(run.human_prompt) // "Deseja continuar com a compra?"
|
|
151
|
+
*
|
|
152
|
+
* // Respond
|
|
153
|
+
* await client.runs.resume(runId, { input: { answer: "sim" } })
|
|
154
|
+
* ```
|
|
114
155
|
*/
|
|
115
|
-
resume(runId: string,
|
|
156
|
+
resume(runId: string, body: {
|
|
157
|
+
input: unknown;
|
|
158
|
+
}): Promise<APIResponse<Run>>;
|
|
116
159
|
/**
|
|
117
160
|
* Rerun from start (stateless).
|
|
118
161
|
*/
|
|
119
162
|
rerun(runId: string): Promise<APIResponse<CreateRunResponse>>;
|
|
120
163
|
/**
|
|
121
164
|
* Replay from checkpoint (stateful).
|
|
165
|
+
* Creates a NEW run that starts from the specified checkpoint.
|
|
166
|
+
*
|
|
167
|
+
* @param runId - The original run to replay from
|
|
168
|
+
* @param checkpointId - The checkpoint ID to start from
|
|
169
|
+
* @param options - Replay options
|
|
170
|
+
* @returns New run created from checkpoint
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* const checkpoints = await client.runs.getCheckpoints(runId)
|
|
175
|
+
* const newRun = await client.runs.replay(runId, checkpoints[2].id, {
|
|
176
|
+
* mode: 'best_effort',
|
|
177
|
+
* reason: 'Debugging step 3'
|
|
178
|
+
* })
|
|
179
|
+
* ```
|
|
122
180
|
*/
|
|
123
|
-
replay(runId: string, checkpointId?: string,
|
|
181
|
+
replay(runId: string, checkpointId?: string, options?: {
|
|
182
|
+
mode?: "best_effort" | "strict";
|
|
183
|
+
reason?: string;
|
|
184
|
+
}): Promise<APIResponse<CreateRunResponse>>;
|
|
124
185
|
/**
|
|
125
186
|
* Get run events for timeline (paged, no SSE).
|
|
126
187
|
* @example
|
|
@@ -131,6 +192,31 @@ export declare class RunsModule {
|
|
|
131
192
|
getEvents(runId: string, params?: PaginationParams): Promise<APIResponse<RunEventsResponse>>;
|
|
132
193
|
/** Alias: runs.events() -> runs.getEvents() */
|
|
133
194
|
events: (runId: string, params?: PaginationParams) => Promise<APIResponse<RunEventsResponse>>;
|
|
195
|
+
/**
|
|
196
|
+
* Wave 2.3: Seq-based event polling for execution trace.
|
|
197
|
+
* Use this for incremental polling with reconnection support.
|
|
198
|
+
*
|
|
199
|
+
* @param runId - Run ID to poll events for
|
|
200
|
+
* @param params - Polling options
|
|
201
|
+
* @returns Events with seq cursors for pagination
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```ts
|
|
205
|
+
* let afterSeq = 0;
|
|
206
|
+
* while (run.status === 'running') {
|
|
207
|
+
* const { data } = await client.runs.pollEvents(runId, { afterSeq });
|
|
208
|
+
* for (const event of data.events) {
|
|
209
|
+
* console.log(event.type, event.payload);
|
|
210
|
+
* }
|
|
211
|
+
* afterSeq = data.next_after_seq;
|
|
212
|
+
* await sleep(1000);
|
|
213
|
+
* }
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
pollEvents(runId: string, params?: {
|
|
217
|
+
afterSeq?: number;
|
|
218
|
+
limit?: number;
|
|
219
|
+
}): Promise<APIResponse<RunEventsPollResponse>>;
|
|
134
220
|
/**
|
|
135
221
|
* Get checkpoints for a run.
|
|
136
222
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../../src/modules/runs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAa,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGlG,KAAK,eAAe,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,iBAAiB,CAAC,CAAC;AAChE,KAAK,gBAAgB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC;AAClE,KAAK,iBAAiB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,mBAAmB,CAAC,CAAC;AACpE,KAAK,sBAAsB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,wBAAwB,CAAC,CAAC;AAG9E,MAAM,WAAW,GAAG;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../../src/modules/runs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;A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E,OAAO,CAAC,EAAE,UAAU,GAAG,cAAc,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IAQrF;;;;;;;;;;;OAWG;IACI,eAAe,CAClB,IAAI,EAAE;QACF,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE;YAAE,SAAS,CAAC,EAAE,MAAM,CAAA;SAAE,GAAG;YAAE,UAAU,EAAE,IAAI,CAAA;SAAE,CAAC;QACvD,KAAK,CAAC,EAAE,OAAO,CAAC;KACnB,EACD,OAAO,CAAC,EAAE,UAAU,GACrB,cAAc,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IAU3C;;OAEG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,cAAc,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;CAOtF"}
|
package/dist/modules/runs.js
CHANGED
|
@@ -82,11 +82,30 @@ export class RunsModule {
|
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
84
|
* Resume a run waiting for human input (HITL).
|
|
85
|
+
* After the run reaches status 'waiting_for_human', use this to provide
|
|
86
|
+
* the human response and continue execution.
|
|
87
|
+
*
|
|
88
|
+
* @param runId - The run ID to resume
|
|
89
|
+
* @param body - The human input to provide
|
|
90
|
+
* @returns Updated run (status will change to 'resumed' then 'queued')
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* // List runs waiting for human input
|
|
95
|
+
* const waiting = await client.runs.list({ status: 'waiting_for_human' })
|
|
96
|
+
*
|
|
97
|
+
* // Get the prompt
|
|
98
|
+
* const run = await client.runs.get(runId)
|
|
99
|
+
* console.log(run.human_prompt) // "Deseja continuar com a compra?"
|
|
100
|
+
*
|
|
101
|
+
* // Respond
|
|
102
|
+
* await client.runs.resume(runId, { input: { answer: "sim" } })
|
|
103
|
+
* ```
|
|
85
104
|
*/
|
|
86
|
-
async resume(runId,
|
|
105
|
+
async resume(runId, body) {
|
|
87
106
|
return this.client.POST("/v1/api/runs/{runId}/resume", {
|
|
88
107
|
params: { path: { runId } },
|
|
89
|
-
body
|
|
108
|
+
body,
|
|
90
109
|
headers: this.headers(),
|
|
91
110
|
});
|
|
92
111
|
}
|
|
@@ -101,11 +120,30 @@ export class RunsModule {
|
|
|
101
120
|
}
|
|
102
121
|
/**
|
|
103
122
|
* Replay from checkpoint (stateful).
|
|
123
|
+
* Creates a NEW run that starts from the specified checkpoint.
|
|
124
|
+
*
|
|
125
|
+
* @param runId - The original run to replay from
|
|
126
|
+
* @param checkpointId - The checkpoint ID to start from
|
|
127
|
+
* @param options - Replay options
|
|
128
|
+
* @returns New run created from checkpoint
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* const checkpoints = await client.runs.getCheckpoints(runId)
|
|
133
|
+
* const newRun = await client.runs.replay(runId, checkpoints[2].id, {
|
|
134
|
+
* mode: 'best_effort',
|
|
135
|
+
* reason: 'Debugging step 3'
|
|
136
|
+
* })
|
|
137
|
+
* ```
|
|
104
138
|
*/
|
|
105
|
-
async replay(runId, checkpointId,
|
|
139
|
+
async replay(runId, checkpointId, options) {
|
|
106
140
|
return this.client.POST("/v1/api/runs/{runId}/replay", {
|
|
107
141
|
params: { path: { runId } },
|
|
108
|
-
body: {
|
|
142
|
+
body: {
|
|
143
|
+
checkpoint_id: checkpointId,
|
|
144
|
+
mode: options?.mode,
|
|
145
|
+
reason: options?.reason
|
|
146
|
+
},
|
|
109
147
|
headers: this.headers(),
|
|
110
148
|
});
|
|
111
149
|
}
|
|
@@ -125,6 +163,39 @@ export class RunsModule {
|
|
|
125
163
|
}
|
|
126
164
|
/** Alias: runs.events() -> runs.getEvents() */
|
|
127
165
|
events = (runId, params) => this.getEvents(runId, params);
|
|
166
|
+
/**
|
|
167
|
+
* Wave 2.3: Seq-based event polling for execution trace.
|
|
168
|
+
* Use this for incremental polling with reconnection support.
|
|
169
|
+
*
|
|
170
|
+
* @param runId - Run ID to poll events for
|
|
171
|
+
* @param params - Polling options
|
|
172
|
+
* @returns Events with seq cursors for pagination
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```ts
|
|
176
|
+
* let afterSeq = 0;
|
|
177
|
+
* while (run.status === 'running') {
|
|
178
|
+
* const { data } = await client.runs.pollEvents(runId, { afterSeq });
|
|
179
|
+
* for (const event of data.events) {
|
|
180
|
+
* console.log(event.type, event.payload);
|
|
181
|
+
* }
|
|
182
|
+
* afterSeq = data.next_after_seq;
|
|
183
|
+
* await sleep(1000);
|
|
184
|
+
* }
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
async pollEvents(runId, params) {
|
|
188
|
+
return this.client.GET("/v1/api/runs/{runId}/events/stream", {
|
|
189
|
+
params: {
|
|
190
|
+
path: { runId },
|
|
191
|
+
query: {
|
|
192
|
+
afterSeq: params?.afterSeq ?? 0,
|
|
193
|
+
limit: params?.limit ?? 100
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
headers: this.headers(),
|
|
197
|
+
});
|
|
198
|
+
}
|
|
128
199
|
// ======================== Checkpoints ========================
|
|
129
200
|
/**
|
|
130
201
|
* Get checkpoints for a run.
|