@agentfield/sdk 0.1.80 → 0.1.81-rc.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/README.md CHANGED
@@ -113,12 +113,13 @@ const approvalClient = new ApprovalClient({
113
113
 
114
114
  agent.reasoner<{ task: string }, { status: string }>('deploy', async (ctx) => {
115
115
  const plan = await ctx.ai(`Create deployment plan for: ${ctx.input.task}`);
116
+ const approvalRequestId = `req-${ctx.executionId}`;
116
117
 
117
- // Request approval transitions execution to "waiting"
118
+ // Create the human-facing approval request in your approval service first,
119
+ // then pass its ID/URL to AgentField so the execution transitions to "waiting".
118
120
  await approvalClient.requestApproval(ctx.executionId, {
119
- projectId: 'my-project',
120
- title: `Deploy: ${ctx.input.task}`,
121
- description: String(plan),
121
+ approvalRequestId,
122
+ approvalRequestUrl: `https://approvals.example.com/review/${approvalRequestId}`,
122
123
  expiresInHours: 24,
123
124
  });
124
125
 
package/dist/index.d.ts CHANGED
@@ -1769,14 +1769,12 @@ declare function isActive(status: string | null | undefined): boolean;
1769
1769
  */
1770
1770
  /** Payload sent when requesting approval. */
1771
1771
  interface RequestApprovalPayload {
1772
- title?: string;
1773
- description?: string;
1774
- templateType?: string;
1775
- payload?: Record<string, any>;
1776
- projectId: string;
1772
+ approvalRequestId: string;
1773
+ approvalRequestUrl?: string;
1774
+ callbackUrl?: string;
1777
1775
  expiresInHours?: number;
1778
1776
  }
1779
- /** Response from the control plane after creating an approval request. */
1777
+ /** Response from the control plane after tracking an approval request. */
1780
1778
  interface ApprovalRequestResponse {
1781
1779
  approvalRequestId: string;
1782
1780
  approvalRequestUrl: string;
package/dist/index.js CHANGED
@@ -6002,13 +6002,15 @@ var ApprovalClient = class {
6002
6002
  */
6003
6003
  async requestApproval(executionId, payload) {
6004
6004
  const body = {
6005
- title: payload.title ?? "Approval Request",
6006
- description: payload.description ?? "",
6007
- template_type: payload.templateType ?? "plan-review-v1",
6008
- payload: payload.payload ?? {},
6009
- project_id: payload.projectId,
6005
+ approval_request_id: payload.approvalRequestId,
6010
6006
  expires_in_hours: payload.expiresInHours ?? 72
6011
6007
  };
6008
+ if (payload.approvalRequestUrl) {
6009
+ body.approval_request_url = payload.approvalRequestUrl;
6010
+ }
6011
+ if (payload.callbackUrl) {
6012
+ body.callback_url = payload.callbackUrl;
6013
+ }
6012
6014
  const res = await this.http.post(
6013
6015
  `/api/v1/agents/${encodeURIComponent(this.nodeId)}/executions/${encodeURIComponent(executionId)}/request-approval`,
6014
6016
  body,