@eng-ai/sdk 2.2.0 → 2.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/CHANGELOG.md +19 -0
- package/README.md +39 -2
- package/bin/eng-ai.js +219 -0
- package/package.json +5 -1
- package/src/client.js +131 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@eng-ai/sdk` will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## 2.3.0 - 2026-04-05
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- External project autonomy support:
|
|
10
|
+
- `setProjectAutonomyMode(projectId, mode, { idempotencyKey? })`
|
|
11
|
+
- `getProjectContext(projectId)`
|
|
12
|
+
- External automation plan approval flow support:
|
|
13
|
+
- `listActionableAutomationPlans(limit?)`
|
|
14
|
+
- `listProjectAutomationPlans(projectId, { status? })`
|
|
15
|
+
- `approveAutomationPlan(projectId, planId, note?, { idempotencyKey? })`
|
|
16
|
+
- `rejectAutomationPlan(projectId, planId, note?, { idempotencyKey? })`
|
|
17
|
+
- `applyAutomationPlan(projectId, planId, { idempotencyKey? })`
|
|
18
|
+
- Official package CLI (`eng-ai`) with commands:
|
|
19
|
+
- `projects autonomy set`
|
|
20
|
+
- `plans actionable list`
|
|
21
|
+
- `plans approve|reject|apply`
|
|
22
|
+
- `plans watch --interval`
|
|
23
|
+
|
|
5
24
|
## 2.2.0 - 2026-04-05
|
|
6
25
|
|
|
7
26
|
### Added
|
package/README.md
CHANGED
|
@@ -57,8 +57,8 @@ try {
|
|
|
57
57
|
|
|
58
58
|
Agent mode options:
|
|
59
59
|
|
|
60
|
-
- `ENG_AI_AGENT_MODE=autonomous`: omite `agent_id` e deixa o
|
|
61
|
-
- `ENG_AI_AGENT_MODE=specialist`: fixa `agent_id` via `ENG_AI_AGENT_ID` (ex.: `general`, `contract_manager`).
|
|
60
|
+
- `ENG_AI_AGENT_MODE=autonomous`: omite `agent_id` e deixa o Core Orchestrator escolher.
|
|
61
|
+
- `ENG_AI_AGENT_MODE=specialist`: fixa `agent_id` via `ENG_AI_AGENT_ID` (ex.: `general`, `contract_manager` ou alias `project_manager`).
|
|
62
62
|
|
|
63
63
|
Project creation (API key only):
|
|
64
64
|
|
|
@@ -73,6 +73,43 @@ const projects = await client.listProjects({ limit: 10, offset: 0 });
|
|
|
73
73
|
console.log(project.id, projects.length);
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
+
Task autonomy mode by project:
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
await client.setProjectAutonomyMode(project.id, "approval_required");
|
|
80
|
+
const context = await client.getProjectContext(project.id);
|
|
81
|
+
console.log(context.autonomous_tasks_mode);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
External approval flow (pull):
|
|
85
|
+
|
|
86
|
+
```js
|
|
87
|
+
const actionable = await client.listActionableAutomationPlans(30);
|
|
88
|
+
const pending = actionable.find((plan) => plan.status === "pending_approval");
|
|
89
|
+
if (pending) {
|
|
90
|
+
await client.approveAutomationPlan(pending.project_id, pending.id, "Approved by integration bot");
|
|
91
|
+
await client.applyAutomationPlan(pending.project_id, pending.id);
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Supported automation plan actions:
|
|
96
|
+
|
|
97
|
+
- `listActionableAutomationPlans(limit?)`
|
|
98
|
+
- `listProjectAutomationPlans(projectId, { status? })`
|
|
99
|
+
- `approveAutomationPlan(projectId, planId, note?, { idempotencyKey? })`
|
|
100
|
+
- `rejectAutomationPlan(projectId, planId, note?, { idempotencyKey? })`
|
|
101
|
+
- `applyAutomationPlan(projectId, planId, { idempotencyKey? })`
|
|
102
|
+
|
|
103
|
+
CLI (`eng-ai`) included in package:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
ENG_AI_API_KEY=sk_xxx eng-ai projects autonomy set --project-id <id> --mode approval_required
|
|
107
|
+
ENG_AI_API_KEY=sk_xxx eng-ai plans actionable list --limit 30
|
|
108
|
+
ENG_AI_API_KEY=sk_xxx eng-ai plans approve --project-id <id> --plan-id <id> --note "Approved"
|
|
109
|
+
ENG_AI_API_KEY=sk_xxx eng-ai plans apply --project-id <id> --plan-id <id>
|
|
110
|
+
ENG_AI_API_KEY=sk_xxx eng-ai plans watch --interval 15 --limit 30
|
|
111
|
+
```
|
|
112
|
+
|
|
76
113
|
Default base URL: `https://api.eng-ai.com/api/v2`.
|
|
77
114
|
|
|
78
115
|
## Security Notes
|
package/bin/eng-ai.js
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { EngAIClient, EngAIError } from "../src/client.js";
|
|
4
|
+
|
|
5
|
+
function parseArgs(argv) {
|
|
6
|
+
const tokens = [];
|
|
7
|
+
const options = {};
|
|
8
|
+
|
|
9
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
10
|
+
const item = String(argv[i] || "");
|
|
11
|
+
if (!item.startsWith("--")) {
|
|
12
|
+
tokens.push(item);
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const key = item.slice(2);
|
|
17
|
+
const next = argv[i + 1];
|
|
18
|
+
if (next !== undefined && !String(next).startsWith("--")) {
|
|
19
|
+
options[key] = next;
|
|
20
|
+
i += 1;
|
|
21
|
+
} else {
|
|
22
|
+
options[key] = "true";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return { tokens, options };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function envOrDefault(name, fallback = undefined) {
|
|
30
|
+
const value = process.env[name];
|
|
31
|
+
if (value === undefined || value === null || String(value).trim() === "") {
|
|
32
|
+
return fallback;
|
|
33
|
+
}
|
|
34
|
+
return String(value).trim();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function toPositiveInt(value, fallback) {
|
|
38
|
+
const parsed = Number(value);
|
|
39
|
+
if (!Number.isFinite(parsed) || parsed <= 0) return fallback;
|
|
40
|
+
return Math.floor(parsed);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function maskId(value) {
|
|
44
|
+
const text = String(value || "");
|
|
45
|
+
if (text.length <= 8) return text;
|
|
46
|
+
return `${text.slice(0, 4)}...${text.slice(-4)}`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function printHelp() {
|
|
50
|
+
console.log(`
|
|
51
|
+
ENG-AI SDK CLI
|
|
52
|
+
|
|
53
|
+
Usage:
|
|
54
|
+
eng-ai projects autonomy set --project-id <id> --mode <approval_required|approval_delete_only|full_autonomy> [--idempotency-key <key>]
|
|
55
|
+
eng-ai plans actionable list [--limit <n>]
|
|
56
|
+
eng-ai plans approve --project-id <id> --plan-id <id> [--note <text>] [--idempotency-key <key>]
|
|
57
|
+
eng-ai plans reject --project-id <id> --plan-id <id> [--note <text>] [--idempotency-key <key>]
|
|
58
|
+
eng-ai plans apply --project-id <id> --plan-id <id> [--idempotency-key <key>]
|
|
59
|
+
eng-ai plans watch [--interval <seconds>] [--limit <n>]
|
|
60
|
+
|
|
61
|
+
Environment:
|
|
62
|
+
ENG_AI_API_KEY (required)
|
|
63
|
+
ENG_AI_BASE_URL (optional, default: https://api.eng-ai.com/api/v2)
|
|
64
|
+
`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function buildClient() {
|
|
68
|
+
const apiKey = envOrDefault("ENG_AI_API_KEY");
|
|
69
|
+
if (!apiKey) {
|
|
70
|
+
throw new Error("ENG_AI_API_KEY is required");
|
|
71
|
+
}
|
|
72
|
+
const baseUrl = envOrDefault("ENG_AI_BASE_URL", "https://api.eng-ai.com/api/v2");
|
|
73
|
+
return new EngAIClient(apiKey, baseUrl);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function printError(error) {
|
|
77
|
+
if (error instanceof EngAIError) {
|
|
78
|
+
const payload = {
|
|
79
|
+
status: error.status,
|
|
80
|
+
code: error.code,
|
|
81
|
+
detail: error.detail,
|
|
82
|
+
requestId: error.requestId,
|
|
83
|
+
retryAfter: error.retryAfter,
|
|
84
|
+
idempotencyKey: error.idempotencyKey ? maskId(error.idempotencyKey) : null,
|
|
85
|
+
};
|
|
86
|
+
console.error("ENG-AI request failed");
|
|
87
|
+
console.error(JSON.stringify(payload, null, 2));
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
console.error(error?.message || String(error));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async function runProjectsCommand(client, subTokens, options) {
|
|
94
|
+
if (subTokens[0] !== "autonomy" || subTokens[1] !== "set") {
|
|
95
|
+
throw new Error("Unsupported projects command. Use: projects autonomy set");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const projectId = options["project-id"];
|
|
99
|
+
const mode = options.mode;
|
|
100
|
+
const idempotencyKey = options["idempotency-key"];
|
|
101
|
+
if (!projectId || !mode) {
|
|
102
|
+
throw new Error("Missing required options: --project-id and --mode");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const context = await client.setProjectAutonomyMode(projectId, mode, {
|
|
106
|
+
idempotencyKey,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
console.log("Project autonomy mode updated.");
|
|
110
|
+
console.log(
|
|
111
|
+
JSON.stringify(
|
|
112
|
+
{
|
|
113
|
+
project_id: context.project_id,
|
|
114
|
+
autonomous_tasks_mode: context.autonomous_tasks_mode,
|
|
115
|
+
autonomous_tasks_enabled: context.autonomous_tasks_enabled,
|
|
116
|
+
},
|
|
117
|
+
null,
|
|
118
|
+
2
|
|
119
|
+
)
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function printPlansSummary(plans) {
|
|
124
|
+
const rows = Array.isArray(plans) ? plans : [];
|
|
125
|
+
const formatted = rows.map((plan) => ({
|
|
126
|
+
plan_id: plan.id,
|
|
127
|
+
project_id: plan.project_id,
|
|
128
|
+
project_name: plan.project_name || null,
|
|
129
|
+
status: plan.status,
|
|
130
|
+
risk_level: plan.risk_level,
|
|
131
|
+
created_at: plan.created_at,
|
|
132
|
+
}));
|
|
133
|
+
console.log(JSON.stringify(formatted, null, 2));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async function runPlansCommand(client, subTokens, options) {
|
|
137
|
+
const action = subTokens[0];
|
|
138
|
+
|
|
139
|
+
if (action === "actionable" && subTokens[1] === "list") {
|
|
140
|
+
const limit = toPositiveInt(options.limit, 30);
|
|
141
|
+
const plans = await client.listActionableAutomationPlans(limit);
|
|
142
|
+
printPlansSummary(plans);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (action === "watch") {
|
|
147
|
+
const intervalSeconds = toPositiveInt(options.interval, 15);
|
|
148
|
+
const limit = toPositiveInt(options.limit, 30);
|
|
149
|
+
console.log(
|
|
150
|
+
`Watching actionable plans every ${intervalSeconds}s (limit=${limit}). Press Ctrl+C to stop.`
|
|
151
|
+
);
|
|
152
|
+
while (true) {
|
|
153
|
+
const plans = await client.listActionableAutomationPlans(limit);
|
|
154
|
+
const pending = (plans || []).filter((item) => item?.status === "pending_approval");
|
|
155
|
+
const stamp = new Date().toISOString();
|
|
156
|
+
console.log(`\n[${stamp}] actionable=${(plans || []).length} pending=${pending.length}`);
|
|
157
|
+
if (pending.length > 0) {
|
|
158
|
+
printPlansSummary(pending);
|
|
159
|
+
}
|
|
160
|
+
await new Promise((resolve) => setTimeout(resolve, intervalSeconds * 1000));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (!["approve", "reject", "apply"].includes(action)) {
|
|
165
|
+
throw new Error("Unsupported plans command. Use actionable list|watch|approve|reject|apply");
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const projectId = options["project-id"];
|
|
169
|
+
const planId = options["plan-id"];
|
|
170
|
+
const note = options.note;
|
|
171
|
+
const idempotencyKey = options["idempotency-key"];
|
|
172
|
+
if (!projectId || !planId) {
|
|
173
|
+
throw new Error("Missing required options: --project-id and --plan-id");
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
let result;
|
|
177
|
+
if (action === "approve") {
|
|
178
|
+
result = await client.approveAutomationPlan(projectId, planId, note, {
|
|
179
|
+
idempotencyKey,
|
|
180
|
+
});
|
|
181
|
+
} else if (action === "reject") {
|
|
182
|
+
result = await client.rejectAutomationPlan(projectId, planId, note, {
|
|
183
|
+
idempotencyKey,
|
|
184
|
+
});
|
|
185
|
+
} else {
|
|
186
|
+
result = await client.applyAutomationPlan(projectId, planId, {
|
|
187
|
+
idempotencyKey,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
console.log(`Plan ${action} completed.`);
|
|
192
|
+
console.log(JSON.stringify(result, null, 2));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
async function main() {
|
|
196
|
+
const { tokens, options } = parseArgs(process.argv.slice(2));
|
|
197
|
+
const command = tokens[0];
|
|
198
|
+
if (!command || command === "help" || command === "--help") {
|
|
199
|
+
printHelp();
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const client = buildClient();
|
|
204
|
+
if (command === "projects") {
|
|
205
|
+
await runProjectsCommand(client, tokens.slice(1), options);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if (command === "plans") {
|
|
209
|
+
await runPlansCommand(client, tokens.slice(1), options);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
throw new Error(`Unknown command: ${command}`);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
main().catch((error) => {
|
|
217
|
+
printError(error);
|
|
218
|
+
process.exit(1);
|
|
219
|
+
});
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eng-ai/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Official JavaScript SDK for ENG-AI External API v2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/client.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"eng-ai": "./bin/eng-ai.js"
|
|
9
|
+
},
|
|
7
10
|
"exports": {
|
|
8
11
|
".": "./src/client.js"
|
|
9
12
|
},
|
|
10
13
|
"files": [
|
|
14
|
+
"bin",
|
|
11
15
|
"src",
|
|
12
16
|
"README.md",
|
|
13
17
|
"CHANGELOG.md",
|
package/src/client.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
const DEFAULT_BASE_URL = "https://api.eng-ai.com/api/v2";
|
|
2
2
|
const DEFAULT_TIMEOUT_MS = 60000;
|
|
3
3
|
const REDACT_KEY_PATTERN = /api[-_]?key|authorization|token|secret|password|cookie|set-cookie/i;
|
|
4
|
+
const VALID_AUTONOMOUS_TASKS_MODES = new Set([
|
|
5
|
+
"approval_required",
|
|
6
|
+
"approval_delete_only",
|
|
7
|
+
"full_autonomy",
|
|
8
|
+
]);
|
|
4
9
|
|
|
5
10
|
function isPlainObject(value) {
|
|
6
11
|
return !!value && Object.prototype.toString.call(value) === "[object Object]";
|
|
@@ -277,6 +282,18 @@ export class EngAIClient {
|
|
|
277
282
|
}
|
|
278
283
|
}
|
|
279
284
|
|
|
285
|
+
_requireNonEmptyString(value, fieldName) {
|
|
286
|
+
const normalized = String(value || "").trim();
|
|
287
|
+
if (!normalized) {
|
|
288
|
+
throw new EngAIError(`${fieldName} is required`, {
|
|
289
|
+
status: 400,
|
|
290
|
+
code: "validation_error",
|
|
291
|
+
detail: `${fieldName} must be a non-empty string`,
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
return normalized;
|
|
295
|
+
}
|
|
296
|
+
|
|
280
297
|
async invokeAgent(agentIdOrPayload, maybePayload) {
|
|
281
298
|
const implicitAutonomous = arguments.length === 1;
|
|
282
299
|
const agentId = implicitAutonomous ? null : agentIdOrPayload;
|
|
@@ -360,4 +377,118 @@ export class EngAIClient {
|
|
|
360
377
|
method: "GET",
|
|
361
378
|
});
|
|
362
379
|
}
|
|
380
|
+
|
|
381
|
+
async getProjectContext(projectId) {
|
|
382
|
+
const normalizedProjectId = this._requireNonEmptyString(projectId, "projectId");
|
|
383
|
+
return await this._request(`/projects/${encodeURIComponent(normalizedProjectId)}/context`, {
|
|
384
|
+
method: "GET",
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
async setProjectAutonomyMode(projectId, mode, options = {}) {
|
|
389
|
+
const normalizedProjectId = this._requireNonEmptyString(projectId, "projectId");
|
|
390
|
+
const normalizedMode = String(mode || "").trim().toLowerCase();
|
|
391
|
+
if (!VALID_AUTONOMOUS_TASKS_MODES.has(normalizedMode)) {
|
|
392
|
+
throw new EngAIError("invalid mode for setProjectAutonomyMode", {
|
|
393
|
+
status: 400,
|
|
394
|
+
code: "validation_error",
|
|
395
|
+
detail:
|
|
396
|
+
"mode must be one of: approval_required, approval_delete_only, full_autonomy",
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
const headers = {};
|
|
401
|
+
const idempotencyKey = options?.idempotencyKey ?? options?.idempotency_key;
|
|
402
|
+
if (idempotencyKey) {
|
|
403
|
+
headers["Idempotency-Key"] = idempotencyKey;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
return await this._request(
|
|
407
|
+
`/projects/${encodeURIComponent(normalizedProjectId)}/autonomous-tasks-mode`,
|
|
408
|
+
{
|
|
409
|
+
method: "PUT",
|
|
410
|
+
headers,
|
|
411
|
+
body: { mode: normalizedMode },
|
|
412
|
+
}
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
async listActionableAutomationPlans(limit = 30) {
|
|
417
|
+
const query = new URLSearchParams();
|
|
418
|
+
if (limit !== undefined && limit !== null) {
|
|
419
|
+
query.set("limit", String(limit));
|
|
420
|
+
}
|
|
421
|
+
const suffix = query.toString() ? `?${query.toString()}` : "";
|
|
422
|
+
return await this._request(`/projects/automation-plans/actionable${suffix}`, {
|
|
423
|
+
method: "GET",
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
async listProjectAutomationPlans(projectId, options = {}) {
|
|
428
|
+
const normalizedProjectId = this._requireNonEmptyString(projectId, "projectId");
|
|
429
|
+
const query = new URLSearchParams();
|
|
430
|
+
if (options.status) {
|
|
431
|
+
query.set("status", String(options.status));
|
|
432
|
+
}
|
|
433
|
+
const suffix = query.toString() ? `?${query.toString()}` : "";
|
|
434
|
+
return await this._request(
|
|
435
|
+
`/projects/${encodeURIComponent(normalizedProjectId)}/automation-plans${suffix}`,
|
|
436
|
+
{
|
|
437
|
+
method: "GET",
|
|
438
|
+
}
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
async approveAutomationPlan(projectId, planId, note = undefined, options = {}) {
|
|
443
|
+
const normalizedProjectId = this._requireNonEmptyString(projectId, "projectId");
|
|
444
|
+
const normalizedPlanId = this._requireNonEmptyString(planId, "planId");
|
|
445
|
+
const headers = {};
|
|
446
|
+
const idempotencyKey = options?.idempotencyKey ?? options?.idempotency_key;
|
|
447
|
+
if (idempotencyKey) {
|
|
448
|
+
headers["Idempotency-Key"] = idempotencyKey;
|
|
449
|
+
}
|
|
450
|
+
return await this._request(
|
|
451
|
+
`/projects/${encodeURIComponent(normalizedProjectId)}/automation-plans/${encodeURIComponent(normalizedPlanId)}/approve`,
|
|
452
|
+
{
|
|
453
|
+
method: "POST",
|
|
454
|
+
headers,
|
|
455
|
+
body: { note: note ?? undefined },
|
|
456
|
+
}
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
async rejectAutomationPlan(projectId, planId, note = undefined, options = {}) {
|
|
461
|
+
const normalizedProjectId = this._requireNonEmptyString(projectId, "projectId");
|
|
462
|
+
const normalizedPlanId = this._requireNonEmptyString(planId, "planId");
|
|
463
|
+
const headers = {};
|
|
464
|
+
const idempotencyKey = options?.idempotencyKey ?? options?.idempotency_key;
|
|
465
|
+
if (idempotencyKey) {
|
|
466
|
+
headers["Idempotency-Key"] = idempotencyKey;
|
|
467
|
+
}
|
|
468
|
+
return await this._request(
|
|
469
|
+
`/projects/${encodeURIComponent(normalizedProjectId)}/automation-plans/${encodeURIComponent(normalizedPlanId)}/reject`,
|
|
470
|
+
{
|
|
471
|
+
method: "POST",
|
|
472
|
+
headers,
|
|
473
|
+
body: { note: note ?? undefined },
|
|
474
|
+
}
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
async applyAutomationPlan(projectId, planId, options = {}) {
|
|
479
|
+
const normalizedProjectId = this._requireNonEmptyString(projectId, "projectId");
|
|
480
|
+
const normalizedPlanId = this._requireNonEmptyString(planId, "planId");
|
|
481
|
+
const headers = {};
|
|
482
|
+
const idempotencyKey = options?.idempotencyKey ?? options?.idempotency_key;
|
|
483
|
+
if (idempotencyKey) {
|
|
484
|
+
headers["Idempotency-Key"] = idempotencyKey;
|
|
485
|
+
}
|
|
486
|
+
return await this._request(
|
|
487
|
+
`/projects/${encodeURIComponent(normalizedProjectId)}/automation-plans/${encodeURIComponent(normalizedPlanId)}/apply`,
|
|
488
|
+
{
|
|
489
|
+
method: "POST",
|
|
490
|
+
headers,
|
|
491
|
+
}
|
|
492
|
+
);
|
|
493
|
+
}
|
|
363
494
|
}
|