@agent-os-sdk/client 0.2.2 → 0.3.0
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 +19 -53
- package/dist/client/AgentOsClient.d.ts.map +1 -1
- package/dist/client/AgentOsClient.js +59 -175
- package/dist/client/auth.d.ts +15 -27
- package/dist/client/auth.d.ts.map +1 -1
- package/dist/client/auth.js +2 -8
- package/dist/client/raw.d.ts +1 -0
- package/dist/client/raw.d.ts.map +1 -1
- package/dist/client/raw.js +4 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/modules/approvals.d.ts +50 -39
- package/dist/modules/approvals.d.ts.map +1 -1
- package/dist/modules/approvals.js +71 -34
- package/package.json +50 -49
- package/src/client/AgentOsClient.ts +66 -184
- package/src/client/auth.ts +15 -38
- package/src/client/raw.ts +7 -1
- package/src/index.ts +2 -3
- package/src/modules/approvals.ts +106 -64
package/src/modules/approvals.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Approvals Module - Human-in-the-Loop Native
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* Wave 2.x: Real implementation for HITL workflow.
|
|
5
|
+
* Endpoints: /v1/api/workspaces/{workspaceId}/approvals
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import type { RawClient, APIResponse } from "../client/raw.js";
|
|
@@ -11,58 +11,37 @@ import type { RawClient, APIResponse } from "../client/raw.js";
|
|
|
11
11
|
// Types
|
|
12
12
|
// ============================================================================
|
|
13
13
|
|
|
14
|
-
export type ApprovalStatus = "pending" | "approved" | "
|
|
14
|
+
export type ApprovalStatus = "pending" | "approved" | "denied" | "expired";
|
|
15
15
|
|
|
16
16
|
export interface Approval {
|
|
17
17
|
id: string;
|
|
18
18
|
run_id: string;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
attempt_id: string;
|
|
20
|
+
policy_name: string;
|
|
21
|
+
reason: string;
|
|
22
22
|
status: ApprovalStatus;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
expires_at?: string;
|
|
28
|
-
auto_approve_after?: number;
|
|
23
|
+
created_at: string;
|
|
24
|
+
decided_at?: string;
|
|
25
|
+
decided_by_actor?: string;
|
|
26
|
+
payload?: Record<string, unknown>;
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
export interface
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
payload: Record<string, unknown>;
|
|
35
|
-
expires_in_seconds?: number;
|
|
36
|
-
auto_approve_after_seconds?: number;
|
|
37
|
-
notify_channels?: string[];
|
|
29
|
+
export interface ApprovalDecision {
|
|
30
|
+
decision: "approve" | "deny";
|
|
31
|
+
comment?: string;
|
|
38
32
|
}
|
|
39
33
|
|
|
40
34
|
export interface ApprovalListResponse {
|
|
41
35
|
items: Approval[];
|
|
42
36
|
total: number;
|
|
43
|
-
pending_count: number;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface ApprovalDecision {
|
|
47
|
-
approval_id: string;
|
|
48
|
-
decision: "approve" | "reject";
|
|
49
|
-
reason?: string;
|
|
50
|
-
modified_payload?: Record<string, unknown>;
|
|
51
37
|
}
|
|
52
38
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
data: undefined,
|
|
60
|
-
error: {
|
|
61
|
-
code: "NOT_IMPLEMENTED",
|
|
62
|
-
message: `ApprovalsModule.${method}() is not implemented. Backend endpoint not available.`,
|
|
63
|
-
},
|
|
64
|
-
response: new Response(null, { status: 501, statusText: "Not Implemented" }),
|
|
65
|
-
};
|
|
39
|
+
export interface ApprovalStatusResponse {
|
|
40
|
+
id: string;
|
|
41
|
+
status: ApprovalStatus;
|
|
42
|
+
decided_at?: string;
|
|
43
|
+
decided_by_actor?: string;
|
|
44
|
+
decision_comment?: string;
|
|
66
45
|
}
|
|
67
46
|
|
|
68
47
|
// ============================================================================
|
|
@@ -70,40 +49,103 @@ function notImplemented<T>(method: string): APIResponse<T> {
|
|
|
70
49
|
// ============================================================================
|
|
71
50
|
|
|
72
51
|
export class ApprovalsModule {
|
|
73
|
-
constructor(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
52
|
+
constructor(
|
|
53
|
+
private client: RawClient,
|
|
54
|
+
private headers: () => Record<string, string>
|
|
55
|
+
) { }
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* List approvals for a workspace.
|
|
59
|
+
* @param workspaceId - Workspace ID
|
|
60
|
+
* @param params - Filter options
|
|
61
|
+
*/
|
|
62
|
+
async list(workspaceId: string, params?: {
|
|
77
63
|
status?: ApprovalStatus;
|
|
78
|
-
run_id?: string;
|
|
79
64
|
limit?: number;
|
|
80
|
-
offset?: number;
|
|
81
65
|
}): Promise<APIResponse<ApprovalListResponse>> {
|
|
82
|
-
return
|
|
66
|
+
return this.client.GET<ApprovalListResponse>(
|
|
67
|
+
"/v1/api/workspaces/{workspaceId}/approvals",
|
|
68
|
+
{
|
|
69
|
+
params: {
|
|
70
|
+
path: { workspaceId },
|
|
71
|
+
query: {
|
|
72
|
+
status: params?.status,
|
|
73
|
+
limit: params?.limit ?? 50
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
headers: this.headers(),
|
|
77
|
+
}
|
|
78
|
+
);
|
|
83
79
|
}
|
|
84
80
|
|
|
85
|
-
/**
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Get a specific approval by ID.
|
|
83
|
+
* @param workspaceId - Workspace ID
|
|
84
|
+
* @param approvalId - Approval ID
|
|
85
|
+
*/
|
|
86
|
+
async get(workspaceId: string, approvalId: string): Promise<APIResponse<Approval>> {
|
|
87
|
+
return this.client.GET<Approval>(
|
|
88
|
+
"/v1/api/workspaces/{workspaceId}/approvals/{approvalId}",
|
|
89
|
+
{
|
|
90
|
+
params: {
|
|
91
|
+
path: { workspaceId, approvalId }
|
|
92
|
+
},
|
|
93
|
+
headers: this.headers(),
|
|
94
|
+
}
|
|
95
|
+
);
|
|
88
96
|
}
|
|
89
97
|
|
|
90
|
-
/**
|
|
91
|
-
|
|
92
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Approve an approval request.
|
|
100
|
+
* @param workspaceId - Workspace ID
|
|
101
|
+
* @param approvalId - Approval ID
|
|
102
|
+
* @param comment - Optional reason for approval
|
|
103
|
+
*/
|
|
104
|
+
async approve(workspaceId: string, approvalId: string, comment?: string): Promise<APIResponse<ApprovalStatusResponse>> {
|
|
105
|
+
return this.client.POST<ApprovalStatusResponse>(
|
|
106
|
+
"/v1/api/workspaces/{workspaceId}/approvals/{approvalId}/decision",
|
|
107
|
+
{
|
|
108
|
+
params: {
|
|
109
|
+
path: { workspaceId, approvalId }
|
|
110
|
+
},
|
|
111
|
+
body: {
|
|
112
|
+
decision: "approve",
|
|
113
|
+
comment
|
|
114
|
+
},
|
|
115
|
+
headers: this.headers(),
|
|
116
|
+
}
|
|
117
|
+
);
|
|
93
118
|
}
|
|
94
119
|
|
|
95
|
-
/**
|
|
96
|
-
|
|
97
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Deny an approval request.
|
|
122
|
+
* @param workspaceId - Workspace ID
|
|
123
|
+
* @param approvalId - Approval ID
|
|
124
|
+
* @param comment - Optional reason for denial
|
|
125
|
+
*/
|
|
126
|
+
async deny(workspaceId: string, approvalId: string, comment?: string): Promise<APIResponse<ApprovalStatusResponse>> {
|
|
127
|
+
return this.client.POST<ApprovalStatusResponse>(
|
|
128
|
+
"/v1/api/workspaces/{workspaceId}/approvals/{approvalId}/decision",
|
|
129
|
+
{
|
|
130
|
+
params: {
|
|
131
|
+
path: { workspaceId, approvalId }
|
|
132
|
+
},
|
|
133
|
+
body: {
|
|
134
|
+
decision: "deny",
|
|
135
|
+
comment
|
|
136
|
+
},
|
|
137
|
+
headers: this.headers(),
|
|
138
|
+
}
|
|
139
|
+
);
|
|
98
140
|
}
|
|
99
141
|
|
|
100
|
-
/**
|
|
101
|
-
|
|
102
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Shorthand: List pending approvals for a workspace.
|
|
144
|
+
*/
|
|
145
|
+
async listPending(workspaceId: string, limit = 50): Promise<APIResponse<ApprovalListResponse>> {
|
|
146
|
+
return this.list(workspaceId, { status: "pending", limit });
|
|
103
147
|
}
|
|
104
148
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return notImplemented<Approval>("awaitApproval");
|
|
108
|
-
}
|
|
149
|
+
// Convenience aliases
|
|
150
|
+
reject = this.deny;
|
|
109
151
|
}
|