@agent-os-sdk/client 0.1.1 → 0.2.1
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 +57 -38
- package/dist/client/AgentOsClient.d.ts.map +1 -1
- package/dist/client/AgentOsClient.js +192 -37
- 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 +1009 -204
- package/dist/generated/openapi.d.ts.map +1 -1
- package/dist/index.d.ts +12 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/modules/approvals.d.ts +64 -0
- package/dist/modules/approvals.d.ts.map +1 -0
- package/dist/modules/approvals.js +54 -0
- package/dist/modules/artifacts.d.ts +49 -0
- package/dist/modules/artifacts.d.ts.map +1 -0
- package/dist/modules/artifacts.js +50 -0
- package/dist/modules/budgets.d.ts +81 -0
- package/dist/modules/budgets.d.ts.map +1 -0
- package/dist/modules/budgets.js +50 -0
- package/dist/modules/builder.d.ts +23 -3
- package/dist/modules/builder.d.ts.map +1 -1
- package/dist/modules/builder.js +28 -6
- package/dist/modules/capabilities.d.ts +57 -0
- package/dist/modules/capabilities.d.ts.map +1 -0
- package/dist/modules/capabilities.js +50 -0
- package/dist/modules/deployments.d.ts +67 -0
- package/dist/modules/deployments.d.ts.map +1 -0
- package/dist/modules/deployments.js +58 -0
- package/dist/modules/flows.d.ts +84 -0
- package/dist/modules/flows.d.ts.map +1 -0
- package/dist/modules/flows.js +66 -0
- package/dist/modules/handoff.d.ts +91 -0
- package/dist/modules/handoff.d.ts.map +1 -0
- package/dist/modules/handoff.js +65 -0
- package/dist/modules/incidents.d.ts +72 -0
- package/dist/modules/incidents.d.ts.map +1 -0
- package/dist/modules/incidents.js +54 -0
- package/dist/modules/members.d.ts +5 -0
- package/dist/modules/members.d.ts.map +1 -1
- package/dist/modules/members.js +10 -0
- package/dist/modules/policies.d.ts +76 -0
- package/dist/modules/policies.d.ts.map +1 -0
- package/dist/modules/policies.js +46 -0
- 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/dist/modules/tenants.d.ts +4 -0
- package/dist/modules/tenants.d.ts.map +1 -1
- package/dist/modules/tenants.js +8 -0
- package/package.json +49 -48
- package/src/client/AgentOsClient.ts +217 -61
- package/src/client/auth.ts +148 -0
- package/src/generated/openapi.ts +1009 -204
- package/src/generated/swagger.json +947 -700
- package/src/index.ts +25 -2
- package/src/modules/approvals.ts +109 -0
- package/src/modules/artifacts.ts +83 -0
- package/src/modules/budgets.ts +120 -0
- package/src/modules/builder.ts +26 -4
- package/src/modules/capabilities.ts +95 -0
- package/src/modules/deployments.ts +111 -0
- package/src/modules/flows.ts +133 -0
- package/src/modules/handoff.ts +140 -0
- package/src/modules/incidents.ts +113 -0
- package/src/modules/members.ts +11 -0
- package/src/modules/policies.ts +112 -0
- package/src/modules/runs.ts +123 -5
- package/src/modules/tenants.ts +9 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flows Module - Workflow Orchestration
|
|
3
|
+
*
|
|
4
|
+
* NOT IMPLEMENTED - Backend endpoint not available.
|
|
5
|
+
* All methods return 501 NotImplemented.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { RawClient, APIResponse } from "../client/raw.js";
|
|
9
|
+
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Types
|
|
12
|
+
// ============================================================================
|
|
13
|
+
|
|
14
|
+
export type FlowStatus = "draft" | "active" | "paused" | "completed" | "failed" | "cancelled";
|
|
15
|
+
|
|
16
|
+
export interface FlowStep {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
agent_id: string;
|
|
20
|
+
type: "agent" | "condition" | "parallel" | "wait" | "human_approval";
|
|
21
|
+
config?: Record<string, unknown>;
|
|
22
|
+
next_steps?: string[];
|
|
23
|
+
on_error?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface Flow {
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
steps: FlowStep[];
|
|
31
|
+
status: FlowStatus;
|
|
32
|
+
version: number;
|
|
33
|
+
created_at: string;
|
|
34
|
+
updated_at: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface FlowRun {
|
|
38
|
+
id: string;
|
|
39
|
+
flow_id: string;
|
|
40
|
+
status: FlowStatus;
|
|
41
|
+
current_step_id?: string;
|
|
42
|
+
completed_steps: string[];
|
|
43
|
+
failed_steps: string[];
|
|
44
|
+
context: Record<string, unknown>;
|
|
45
|
+
started_at: string;
|
|
46
|
+
completed_at?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface FlowVisualization {
|
|
50
|
+
mermaid: string;
|
|
51
|
+
svg?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface FlowSimulationResult {
|
|
55
|
+
success: boolean;
|
|
56
|
+
steps_executed: string[];
|
|
57
|
+
estimated_duration_seconds: number;
|
|
58
|
+
estimated_cost: number;
|
|
59
|
+
potential_issues: string[];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface FlowListResponse {
|
|
63
|
+
items: Flow[];
|
|
64
|
+
total: number;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ============================================================================
|
|
68
|
+
// Helper for 501 responses
|
|
69
|
+
// ============================================================================
|
|
70
|
+
|
|
71
|
+
function notImplemented<T>(method: string): APIResponse<T> {
|
|
72
|
+
return {
|
|
73
|
+
data: undefined,
|
|
74
|
+
error: {
|
|
75
|
+
code: "NOT_IMPLEMENTED",
|
|
76
|
+
message: `FlowsModule.${method}() is not implemented. Backend endpoint not available.`,
|
|
77
|
+
},
|
|
78
|
+
response: new Response(null, { status: 501, statusText: "Not Implemented" }),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// ============================================================================
|
|
83
|
+
// Module
|
|
84
|
+
// ============================================================================
|
|
85
|
+
|
|
86
|
+
export class FlowsModule {
|
|
87
|
+
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
88
|
+
|
|
89
|
+
/** @returns 501 Not Implemented */
|
|
90
|
+
async list(params?: { limit?: number; offset?: number }): Promise<APIResponse<FlowListResponse>> {
|
|
91
|
+
return notImplemented<FlowListResponse>("list");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** @returns 501 Not Implemented */
|
|
95
|
+
async get(flowId: string): Promise<APIResponse<Flow>> {
|
|
96
|
+
return notImplemented<Flow>("get");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** @returns 501 Not Implemented */
|
|
100
|
+
async create(body: { name: string; description?: string; steps: FlowStep[] }): Promise<APIResponse<Flow>> {
|
|
101
|
+
return notImplemented<Flow>("create");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** @returns 501 Not Implemented */
|
|
105
|
+
async run(flowId: string, input?: Record<string, unknown>): Promise<APIResponse<FlowRun>> {
|
|
106
|
+
return notImplemented<FlowRun>("run");
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** @returns 501 Not Implemented */
|
|
110
|
+
async pause(flowRunId: string): Promise<APIResponse<FlowRun>> {
|
|
111
|
+
return notImplemented<FlowRun>("pause");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** @returns 501 Not Implemented */
|
|
115
|
+
async resume(flowRunId: string): Promise<APIResponse<FlowRun>> {
|
|
116
|
+
return notImplemented<FlowRun>("resume");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** @returns 501 Not Implemented */
|
|
120
|
+
async cancel(flowRunId: string): Promise<APIResponse<FlowRun>> {
|
|
121
|
+
return notImplemented<FlowRun>("cancel");
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** @returns 501 Not Implemented */
|
|
125
|
+
async visualize(flowId: string): Promise<APIResponse<FlowVisualization>> {
|
|
126
|
+
return notImplemented<FlowVisualization>("visualize");
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** @returns 501 Not Implemented */
|
|
130
|
+
async simulate(flowId: string, input?: Record<string, unknown>): Promise<APIResponse<FlowSimulationResult>> {
|
|
131
|
+
return notImplemented<FlowSimulationResult>("simulate");
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handoff Module - Multi-Agent Delegation
|
|
3
|
+
*
|
|
4
|
+
* NOT IMPLEMENTED - Backend endpoint not available.
|
|
5
|
+
* All methods return 501 NotImplemented.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { RawClient, APIResponse } from "../client/raw.js";
|
|
9
|
+
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Types
|
|
12
|
+
// ============================================================================
|
|
13
|
+
|
|
14
|
+
export type HandoffMode = "same_thread" | "subthread" | "new_thread";
|
|
15
|
+
|
|
16
|
+
export interface HandoffOptions {
|
|
17
|
+
mode: HandoffMode;
|
|
18
|
+
payload?: Record<string, unknown>;
|
|
19
|
+
constraints?: HandoffConstraints;
|
|
20
|
+
inherit_budget?: boolean;
|
|
21
|
+
inherit_policies?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface HandoffConstraints {
|
|
25
|
+
max_tool_calls?: number;
|
|
26
|
+
max_tokens?: number;
|
|
27
|
+
tool_allowlist?: string[];
|
|
28
|
+
tool_denylist?: string[];
|
|
29
|
+
timeout_seconds?: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface HandoffResult {
|
|
33
|
+
run_id: string;
|
|
34
|
+
parent_run_id: string;
|
|
35
|
+
to_agent_id: string;
|
|
36
|
+
mode: HandoffMode;
|
|
37
|
+
thread_id: string;
|
|
38
|
+
status: "pending" | "running" | "completed" | "failed";
|
|
39
|
+
created_at: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ForkOptions {
|
|
43
|
+
mode?: HandoffMode;
|
|
44
|
+
checkpoint_id?: string;
|
|
45
|
+
copy_messages?: boolean;
|
|
46
|
+
copy_state?: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface ForkResult {
|
|
50
|
+
original_thread_id: string;
|
|
51
|
+
forked_thread_id: string;
|
|
52
|
+
checkpoint_id?: string;
|
|
53
|
+
created_at: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface RunChainNode {
|
|
57
|
+
run_id: string;
|
|
58
|
+
agent_id: string;
|
|
59
|
+
agent_name: string;
|
|
60
|
+
status: string;
|
|
61
|
+
parent_run_id?: string;
|
|
62
|
+
children: RunChainNode[];
|
|
63
|
+
depth: number;
|
|
64
|
+
started_at: string;
|
|
65
|
+
completed_at?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface RunChain {
|
|
69
|
+
root_run_id: string;
|
|
70
|
+
total_runs: number;
|
|
71
|
+
max_depth: number;
|
|
72
|
+
nodes: RunChainNode[];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// ============================================================================
|
|
76
|
+
// Helper for 501 responses
|
|
77
|
+
// ============================================================================
|
|
78
|
+
|
|
79
|
+
function notImplemented<T>(method: string): APIResponse<T> {
|
|
80
|
+
return {
|
|
81
|
+
data: undefined,
|
|
82
|
+
error: {
|
|
83
|
+
code: "NOT_IMPLEMENTED",
|
|
84
|
+
message: `HandoffModule.${method}() is not implemented. Backend endpoint not available.`,
|
|
85
|
+
},
|
|
86
|
+
response: new Response(null, { status: 501, statusText: "Not Implemented" }),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// ============================================================================
|
|
91
|
+
// Module
|
|
92
|
+
// ============================================================================
|
|
93
|
+
|
|
94
|
+
export class HandoffModule {
|
|
95
|
+
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Hand off current run to another agent.
|
|
99
|
+
* @returns 501 Not Implemented - Backend not available
|
|
100
|
+
*/
|
|
101
|
+
async handoff(
|
|
102
|
+
runId: string,
|
|
103
|
+
toAgentId: string,
|
|
104
|
+
options?: HandoffOptions
|
|
105
|
+
): Promise<APIResponse<HandoffResult>> {
|
|
106
|
+
return notImplemented<HandoffResult>("handoff");
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Fork a thread into a new conversation branch.
|
|
111
|
+
* @returns 501 Not Implemented - Backend not available
|
|
112
|
+
*/
|
|
113
|
+
async fork(threadId: string, options?: ForkOptions): Promise<APIResponse<ForkResult>> {
|
|
114
|
+
return notImplemented<ForkResult>("fork");
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Get the full run chain (delegation tree).
|
|
119
|
+
* @returns 501 Not Implemented - Backend not available
|
|
120
|
+
*/
|
|
121
|
+
async getChain(runId: string): Promise<APIResponse<RunChain>> {
|
|
122
|
+
return notImplemented<RunChain>("getChain");
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Get parent runs in the chain.
|
|
127
|
+
* @returns 501 Not Implemented - Backend not available
|
|
128
|
+
*/
|
|
129
|
+
async getParents(runId: string): Promise<APIResponse<RunChainNode[]>> {
|
|
130
|
+
return notImplemented<RunChainNode[]>("getParents");
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Get child runs in the chain.
|
|
135
|
+
* @returns 501 Not Implemented - Backend not available
|
|
136
|
+
*/
|
|
137
|
+
async getChildren(runId: string): Promise<APIResponse<RunChainNode[]>> {
|
|
138
|
+
return notImplemented<RunChainNode[]>("getChildren");
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Incidents Module - Error & Alert Management
|
|
3
|
+
*
|
|
4
|
+
* NOT IMPLEMENTED - Backend endpoint not available.
|
|
5
|
+
* All methods return 501 NotImplemented.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { RawClient, APIResponse } from "../client/raw.js";
|
|
9
|
+
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Types
|
|
12
|
+
// ============================================================================
|
|
13
|
+
|
|
14
|
+
export type IncidentSeverity = "low" | "medium" | "high" | "critical";
|
|
15
|
+
export type IncidentStatus = "open" | "investigating" | "identified" | "monitoring" | "resolved" | "closed";
|
|
16
|
+
|
|
17
|
+
export interface Incident {
|
|
18
|
+
id: string;
|
|
19
|
+
title: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
severity: IncidentSeverity;
|
|
22
|
+
status: IncidentStatus;
|
|
23
|
+
agent_id?: string;
|
|
24
|
+
run_id?: string;
|
|
25
|
+
error_type?: string;
|
|
26
|
+
error_message?: string;
|
|
27
|
+
stack_trace?: string;
|
|
28
|
+
affected_users?: number;
|
|
29
|
+
created_at: string;
|
|
30
|
+
updated_at: string;
|
|
31
|
+
resolved_at?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface IncidentUpdate {
|
|
35
|
+
id: string;
|
|
36
|
+
incident_id: string;
|
|
37
|
+
message: string;
|
|
38
|
+
status_change?: IncidentStatus;
|
|
39
|
+
created_by: string;
|
|
40
|
+
created_at: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface IncidentMetrics {
|
|
44
|
+
total_open: number;
|
|
45
|
+
by_severity: Record<IncidentSeverity, number>;
|
|
46
|
+
mttr_seconds: number;
|
|
47
|
+
trend_last_7_days: number[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ============================================================================
|
|
51
|
+
// Helper for 501 responses
|
|
52
|
+
// ============================================================================
|
|
53
|
+
|
|
54
|
+
function notImplemented<T>(method: string): APIResponse<T> {
|
|
55
|
+
return {
|
|
56
|
+
data: undefined,
|
|
57
|
+
error: {
|
|
58
|
+
code: "NOT_IMPLEMENTED",
|
|
59
|
+
message: `IncidentsModule.${method}() is not implemented. Backend endpoint not available.`,
|
|
60
|
+
},
|
|
61
|
+
response: new Response(null, { status: 501, statusText: "Not Implemented" }),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// ============================================================================
|
|
66
|
+
// Module
|
|
67
|
+
// ============================================================================
|
|
68
|
+
|
|
69
|
+
export class IncidentsModule {
|
|
70
|
+
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
71
|
+
|
|
72
|
+
/** @returns 501 Not Implemented */
|
|
73
|
+
async list(params?: {
|
|
74
|
+
status?: IncidentStatus;
|
|
75
|
+
severity?: IncidentSeverity;
|
|
76
|
+
agent_id?: string;
|
|
77
|
+
limit?: number;
|
|
78
|
+
offset?: number;
|
|
79
|
+
}): Promise<APIResponse<{ items: Incident[]; total: number }>> {
|
|
80
|
+
return notImplemented<{ items: Incident[]; total: number }>("list");
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** @returns 501 Not Implemented */
|
|
84
|
+
async get(incidentId: string): Promise<APIResponse<Incident>> {
|
|
85
|
+
return notImplemented<Incident>("get");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** @returns 501 Not Implemented */
|
|
89
|
+
async create(body: {
|
|
90
|
+
title: string;
|
|
91
|
+
description?: string;
|
|
92
|
+
severity: IncidentSeverity;
|
|
93
|
+
agent_id?: string;
|
|
94
|
+
run_id?: string;
|
|
95
|
+
}): Promise<APIResponse<Incident>> {
|
|
96
|
+
return notImplemented<Incident>("create");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** @returns 501 Not Implemented */
|
|
100
|
+
async update(incidentId: string, status: IncidentStatus, message?: string): Promise<APIResponse<IncidentUpdate>> {
|
|
101
|
+
return notImplemented<IncidentUpdate>("update");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** @returns 501 Not Implemented */
|
|
105
|
+
async resolve(incidentId: string, message?: string): Promise<APIResponse<Incident>> {
|
|
106
|
+
return notImplemented<Incident>("resolve");
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** @returns 501 Not Implemented */
|
|
110
|
+
async getMetrics(): Promise<APIResponse<IncidentMetrics>> {
|
|
111
|
+
return notImplemented<IncidentMetrics>("getMetrics");
|
|
112
|
+
}
|
|
113
|
+
}
|
package/src/modules/members.ts
CHANGED
|
@@ -114,4 +114,15 @@ export class MembersModule {
|
|
|
114
114
|
headers: this.headers(),
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Ensure membership exists (auto-create on first access).
|
|
120
|
+
* This is used by the frontend for onboarding.
|
|
121
|
+
*/
|
|
122
|
+
async ensure(tenantId?: string): Promise<APIResponse<Member>> {
|
|
123
|
+
return this.client.POST<Member>("/v1/api/memberships/ensure", {
|
|
124
|
+
body: { tenant_id: tenantId ?? null },
|
|
125
|
+
headers: this.headers(),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
117
128
|
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Policies Module - Governance & Compliance
|
|
3
|
+
*
|
|
4
|
+
* NOT IMPLEMENTED - Backend endpoint not available.
|
|
5
|
+
* All methods return 501 NotImplemented.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { RawClient, APIResponse } from "../client/raw.js";
|
|
9
|
+
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Types
|
|
12
|
+
// ============================================================================
|
|
13
|
+
|
|
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
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface Policy {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
scope: PolicyScope;
|
|
30
|
+
scope_id?: string;
|
|
31
|
+
enforcement: PolicyEnforcement;
|
|
32
|
+
rules: PolicyRule[];
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
priority: number;
|
|
35
|
+
created_at: string;
|
|
36
|
+
updated_at: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface PolicyEvaluation {
|
|
40
|
+
policy_id: string;
|
|
41
|
+
policy_name: string;
|
|
42
|
+
passed: boolean;
|
|
43
|
+
violated_rules: PolicyRule[];
|
|
44
|
+
audit_log_id?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface PolicyEvaluationResult {
|
|
48
|
+
allowed: boolean;
|
|
49
|
+
evaluations: PolicyEvaluation[];
|
|
50
|
+
requires_approval: boolean;
|
|
51
|
+
blocking_policies: string[];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// ============================================================================
|
|
55
|
+
// Helper for 501 responses
|
|
56
|
+
// ============================================================================
|
|
57
|
+
|
|
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
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ============================================================================
|
|
70
|
+
// Module
|
|
71
|
+
// ============================================================================
|
|
72
|
+
|
|
73
|
+
export class PoliciesModule {
|
|
74
|
+
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
75
|
+
|
|
76
|
+
/** @returns 501 Not Implemented */
|
|
77
|
+
async list(params?: {
|
|
78
|
+
scope?: PolicyScope;
|
|
79
|
+
scope_id?: string;
|
|
80
|
+
enabled?: boolean;
|
|
81
|
+
limit?: number;
|
|
82
|
+
offset?: number;
|
|
83
|
+
}): Promise<APIResponse<{ items: Policy[]; total: number }>> {
|
|
84
|
+
return notImplemented<{ items: Policy[]; total: number }>("list");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** @returns 501 Not Implemented */
|
|
88
|
+
async get(policyId: string): Promise<APIResponse<Policy>> {
|
|
89
|
+
return notImplemented<Policy>("get");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** @returns 501 Not Implemented */
|
|
93
|
+
async create(body: {
|
|
94
|
+
name: string;
|
|
95
|
+
description?: string;
|
|
96
|
+
scope: PolicyScope;
|
|
97
|
+
scope_id?: string;
|
|
98
|
+
enforcement: PolicyEnforcement;
|
|
99
|
+
rules: PolicyRule[];
|
|
100
|
+
}): Promise<APIResponse<Policy>> {
|
|
101
|
+
return notImplemented<Policy>("create");
|
|
102
|
+
}
|
|
103
|
+
|
|
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");
|
|
111
|
+
}
|
|
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
|
/**
|