@thinkingai/ae-cli 6.0.45 → 6.0.47

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.
Files changed (114) hide show
  1. package/README.md +2 -0
  2. package/README.zh.md +6 -0
  3. package/dist/{auth-77BUFLGC.js → auth-QPEVVBKT.js} +20 -15
  4. package/dist/auth-UMJAA72O.js +15 -0
  5. package/dist/{capability-ENHWPMTG.js → capability-RUSV77CO.js} +53 -15
  6. package/dist/{chunk-UW5UN47B.js → chunk-533JK3YX.js} +2 -0
  7. package/dist/{chunk-VPKZ7I72.js → chunk-6QK7SYYY.js} +5 -4
  8. package/dist/{chunk-TUKQZTMI.js → chunk-7K24F7T2.js} +2 -0
  9. package/dist/{chunk-OO6XR6LK.js → chunk-AMBFK2K3.js} +2 -0
  10. package/dist/{sync-DAVKYVMW.js → chunk-B5HMQAOM.js} +31 -540
  11. package/dist/{chunk-EE45RGOO.js → chunk-BVDST5YT.js} +5 -4
  12. package/dist/{chunk-VTWMIC5L.js → chunk-E2JKXMVO.js} +2 -0
  13. package/dist/{chunk-LYVNONC4.js → chunk-FR2EDAQM.js} +36 -0
  14. package/dist/{chunk-ILIU36SU.js → chunk-GJXRF7Y6.js} +6 -5
  15. package/dist/{chunk-DWO43OIB.js → chunk-JQ3ENZZH.js} +2 -0
  16. package/dist/chunk-JYMGHGCE.js +191 -0
  17. package/dist/{chunk-GT46FPXN.js → chunk-KEWVSO64.js} +18 -8
  18. package/dist/chunk-KZ6ZHF5J.js +294 -0
  19. package/dist/{chunk-QI524WPY.js → chunk-NSIVXKJH.js} +6 -5
  20. package/dist/chunk-O6K2ODUE.js +318 -0
  21. package/dist/chunk-QL6R6TSK.js +25215 -0
  22. package/dist/{chunk-4SGZG4XY.js → chunk-RWXIXOZG.js} +28 -13
  23. package/dist/{chunk-4NN5IWVN.js → chunk-T6OSFQZD.js} +2 -0
  24. package/dist/{chunk-PTE56QPL.js → chunk-TKHSULJT.js} +6 -0
  25. package/dist/{chunk-6EIJSNBD.js → chunk-Y74WTIKJ.js} +2 -0
  26. package/dist/{client-TKG4WBHN.js → client-N7NGZUNI.js} +6 -4
  27. package/dist/{community-report-client-FI4LNVYS.js → community-report-client-6OL6GBQW.js} +3 -3
  28. package/dist/{config-RE6CMGPK.js → config-XNMACCKX.js} +10 -8
  29. package/dist/{data-integration-XQYB4X4F.js → data-integration-4NZGZ45E.js} +2502 -272
  30. package/dist/index.js +130 -1243
  31. package/dist/{local-data-upload-client-BWHSUQQK.js → local-data-upload-client-EFHDLXFG.js} +3 -3
  32. package/dist/{memory-YK33G4T7.js → memory-HBJQ2GC5.js} +8 -7
  33. package/dist/{metadata-AXVHAAZG.js → metadata-PGDJE5RQ.js} +12 -11
  34. package/dist/{model-K3KLWIW6.js → model-BHLJ2QMT.js} +10 -9
  35. package/dist/personal-semantic-preference-E5NZ56DN.js +240 -0
  36. package/dist/sync-MUWPRM5I.js +522 -0
  37. package/dist/{te-agent-4BKBODMF.js → te-agent-WQZTMEK4.js} +12 -10
  38. package/dist/{te-analysis-WX7LRVAV.js → te-analysis-YWCSSLYL.js} +534 -48
  39. package/dist/{te-community-HLC43QKH.js → te-community-BNE6KREL.js} +8 -7
  40. package/dist/{te-dataops-EJP56W3K.js → te-dataops-TXLKM2W6.js} +469 -68
  41. package/dist/{te-engage-UBHPAJCO.js → te-engage-VEW4CJHK.js} +26 -10
  42. package/dist/{te-kb-SQCLHG6X.js → te-kb-BUD6N3NI.js} +312 -25
  43. package/dist/{te-system-YARIK4S5.js → te-system-44LZJDTQ.js} +573 -37
  44. package/dist/{te-team-EFKWYKMK.js → te-team-XMP47YXE.js} +10 -7
  45. package/dist/{update-OGPSZM5A.js → update-UODFOZ4P.js} +9 -7
  46. package/package.json +18 -9
  47. package/skills/ae-agent/SKILL.md +3 -4
  48. package/skills/ae-agent/references/edit-skill.md +3 -0
  49. package/skills/ae-agent/references/get-skill-content.md +1 -1
  50. package/skills/ae-agent/references/rescan-skills.md +15 -13
  51. package/skills/ae-agent/references/upload-skill.md +7 -4
  52. package/skills/ae-analysis/SKILL.md +29 -4
  53. package/skills/ae-analysis/metadata_resolution.md +38 -4
  54. package/skills/ae-analysis/references/analysis_data_retrieval.md +29 -0
  55. package/skills/ae-analysis/references/analysis_gateway_assets.md +1 -1
  56. package/skills/ae-analysis/references/asset_authentication_export.md +22 -0
  57. package/skills/ae-analysis/references/asset_authentication_list.md +18 -14
  58. package/skills/ae-analysis/references/asset_authentication_update.md +29 -14
  59. package/skills/ae-analysis/references/audience_models.md +18 -0
  60. package/skills/ae-analysis/references/command_index.md +19 -11
  61. package/skills/ae-analysis/references/dashboard_get.md +18 -1
  62. package/skills/ae-analysis/references/dashboard_update.md +3 -0
  63. package/skills/ae-analysis/references/personal_semantic_preference_add.md +23 -0
  64. package/skills/ae-analysis/references/personal_semantic_preference_delete.md +17 -0
  65. package/skills/ae-analysis/references/personal_semantic_preference_get.md +17 -0
  66. package/skills/ae-analysis/references/personal_semantic_preference_list.md +19 -0
  67. package/skills/ae-analysis/references/personal_semantic_preference_update.md +19 -0
  68. package/skills/ae-analysis/references/project_timezone_update.md +13 -4
  69. package/skills/ae-analysis/references/property_create.md +2 -0
  70. package/skills/ae-analysis/references/super_metadata_batch_create.md +2 -0
  71. package/skills/ae-analysis/references/user_cluster_models.md +2 -0
  72. package/skills/ae-analysis/references/user_cluster_update.md +8 -4
  73. package/skills/ae-analysis/references/user_tag_create.md +7 -1
  74. package/skills/ae-analysis/references/user_tag_models.md +8 -2
  75. package/skills/ae-data-integration/SKILL.md +24 -4
  76. package/skills/ae-data-integration/references/custom-layer.md +93 -0
  77. package/skills/ae-data-integration/references/error-handling.md +145 -0
  78. package/skills/ae-data-integration/references/handoff.md +77 -18
  79. package/skills/ae-data-integration/references/local-analysis.md +1 -1
  80. package/skills/ae-data-integration/references/reuse.md +9 -5
  81. package/skills/ae-data-integration/references/sink-upload.md +1 -1
  82. package/skills/ae-data-integration/references/source-inspect.md +35 -13
  83. package/skills/ae-data-integration/references/tracking-plan.md +7 -5
  84. package/skills/ae-data-integration/references/transform.md +12 -10
  85. package/skills/ae-data-integration/references/ue-mapping.md +33 -11
  86. package/skills/ae-data-integration/references/ue-routing.md +23 -0
  87. package/skills/ae-dataops/SKILL.md +11 -1
  88. package/skills/ae-dataops/references/dataops-backfill.md +135 -0
  89. package/skills/ae-engage/SKILL.md +3 -0
  90. package/skills/ae-engage/references/build-task-save-guide.md +14 -1
  91. package/skills/ae-engage/references/save-task.md +88 -0
  92. package/skills/ae-kb/SKILL.md +121 -10
  93. package/skills/ae-system/SKILL.md +28 -30
  94. package/skills/ae-system/references/channel-management.md +303 -0
  95. package/dist/auth-2WTQOP77.js +0 -14
  96. package/dist/capability-WA37LSIR.js +0 -312
  97. package/dist/chunk-4KVPKXFX.js +0 -98
  98. package/dist/chunk-C4MGVGJW.js +0 -13
  99. package/dist/chunk-MGU2N3HW.js +0 -556
  100. package/dist/chunk-P3FGXJTU.js +0 -349
  101. package/dist/chunk-QEFCIRNJ.js +0 -71
  102. package/dist/chunk-QGM4M3NI.js +0 -37
  103. package/dist/chunk-UOUS37JQ.js +0 -509
  104. package/dist/chunk-ZZUOD757.js +0 -598
  105. package/dist/memory-CHRU2F7W.js +0 -893
  106. package/dist/metadata-GGEHHPBE.js +0 -339
  107. package/dist/model-NR3JHFSJ.js +0 -139
  108. package/dist/sync-FCKOVWWS.js +0 -10261
  109. package/dist/te-agent-HLW4VTQK.js +0 -3893
  110. package/dist/te-analysis-YKFDBMA6.js +0 -8958
  111. package/dist/te-community-6HPBWJUZ.js +0 -1859
  112. package/dist/te-dataops-HDRUXY4K.js +0 -2208
  113. package/dist/te-engage-WLDTS5J5.js +0 -4898
  114. package/dist/te-system-Z77IKZFN.js +0 -2213
@@ -1,349 +0,0 @@
1
- import {
2
- internalCallSourceHeaders
3
- } from "./chunk-C4MGVGJW.js";
4
- import {
5
- clearCliToken,
6
- getCliToken
7
- } from "./chunk-4SGZG4XY.js";
8
- import {
9
- safeJsonParse
10
- } from "./chunk-ZZUOD757.js";
11
- import {
12
- PermissionError
13
- } from "./chunk-UW5UN47B.js";
14
- import {
15
- logger
16
- } from "./chunk-LYVNONC4.js";
17
-
18
- // src/core/capability-api.ts
19
- import { readFile } from "fs/promises";
20
- import { basename } from "path";
21
- var CapabilityGatewayError = class extends Error {
22
- constructor(message, code, httpStatus, hint, meta) {
23
- super(message);
24
- this.code = code;
25
- this.httpStatus = httpStatus;
26
- this.hint = hint;
27
- this.meta = meta;
28
- this.name = "CapabilityGatewayError";
29
- }
30
- code;
31
- httpStatus;
32
- hint;
33
- meta;
34
- };
35
- function buildCapabilityGatewayUrl(host, domain, pathAfterV1, queryParams = {}) {
36
- const base = host.replace(/\/+$/, "");
37
- const cleanDomain = domain.replace(/^\/+|\/+$/g, "");
38
- const cleanPath = pathAfterV1.replace(/^\/+|\/+$/g, "");
39
- const gatewayPrefix = cleanDomain === "" ? "/api/cli/v1" : `/api/cli/${cleanDomain}/v1`;
40
- const url = new URL(`${base}${gatewayPrefix}/${cleanPath}`);
41
- for (const [key, value] of Object.entries(queryParams)) {
42
- if (value !== void 0 && value !== null) {
43
- url.searchParams.set(key, String(value));
44
- }
45
- }
46
- return url.toString();
47
- }
48
- async function permissionMessage(resp) {
49
- const text = await resp.text().catch(() => "");
50
- try {
51
- const d = safeJsonParse(text);
52
- const msg = d && (d.error?.message || (typeof d.error === "string" ? d.error : void 0) || d.message);
53
- if (msg && typeof msg === "string") return msg;
54
- } catch {
55
- }
56
- return "Permission denied for this resource (HTTP 403)";
57
- }
58
- async function permissionError(resp) {
59
- const codeResponse = resp.clone();
60
- const message = await permissionMessage(resp);
61
- const body = safeJsonParse(await codeResponse.text());
62
- const error = isRecord(body?.error) ? body.error : void 0;
63
- const code = nonEmptyString(error?.code) ?? nonEmptyString(body?.code);
64
- return new PermissionError(message, code);
65
- }
66
- function isInvalidCliTokenMessage(message) {
67
- return /\byour token is invalid\b/i.test(message) || /\bcli[-_\s]?token\b.*\binvalid\b/i.test(message) || /\binvalid\b.*\bcli[-_\s]?token\b/i.test(message);
68
- }
69
- function parseCapabilityResponse(text) {
70
- if (!text) return void 0;
71
- try {
72
- return safeJsonParse(text);
73
- } catch {
74
- return text;
75
- }
76
- }
77
- function parseCapabilityEnvelope(body) {
78
- if (body == null) {
79
- throw new CapabilityGatewayError("Empty capability gateway response");
80
- }
81
- if (typeof body.ok === "boolean") {
82
- if (body.ok) {
83
- return {
84
- ok: true,
85
- data: body.data,
86
- ...isRecord(body.meta) ? { meta: body.meta } : {}
87
- };
88
- }
89
- const err = body.error ?? {};
90
- const code = nonEmptyString(err.code);
91
- const message = nonEmptyString(err.message) ?? code ?? "Capability gateway request failed";
92
- const hint = nonEmptyString(err.hint);
93
- throw new CapabilityGatewayError(
94
- message,
95
- code,
96
- err.http_status ?? err.httpStatus,
97
- hint,
98
- isRecord(body.meta) ? body.meta : void 0
99
- );
100
- }
101
- return { ok: true, data: body };
102
- }
103
- function unwrapCapabilityEnvelope(body) {
104
- return parseCapabilityEnvelope(body).data;
105
- }
106
- function nonEmptyString(value) {
107
- return typeof value === "string" && value.trim() ? value.trim() : void 0;
108
- }
109
- function isRecord(value) {
110
- return value !== null && typeof value === "object" && !Array.isArray(value);
111
- }
112
- function buildCapabilityHttpError(resp, body) {
113
- const fallback = `Capability gateway HTTP error: ${resp.status} ${resp.statusText}`.trim();
114
- if (body && typeof body === "object") {
115
- const err = body.error ?? body.data?.error ?? body;
116
- const code = nonEmptyString(err.code) ?? nonEmptyString(err.errorCode) ?? nonEmptyString(body.code);
117
- const message = nonEmptyString(err.message) ?? nonEmptyString(body.message);
118
- const hint = nonEmptyString(err.hint) ?? nonEmptyString(body.hint);
119
- const details = [code, message, hint ? `Hint: ${hint}` : void 0].filter(Boolean);
120
- if (details.length > 0) {
121
- return new CapabilityGatewayError(
122
- message ?? fallback,
123
- code,
124
- resp.status,
125
- hint,
126
- isRecord(body.meta) ? body.meta : void 0
127
- );
128
- }
129
- }
130
- if (typeof body === "string" && body.trim()) {
131
- return new CapabilityGatewayError(`${fallback}: ${body.slice(0, 500)}`, void 0, resp.status);
132
- }
133
- return new CapabilityGatewayError(fallback, void 0, resp.status);
134
- }
135
- async function throwCapabilityHttpError(resp) {
136
- const body = parseCapabilityResponse(await resp.text());
137
- throw buildCapabilityHttpError(resp, body);
138
- }
139
- async function requestOnce(url, method, token, body, accept = "application/json") {
140
- const headers = {
141
- "cli-token": token,
142
- "Accept": accept,
143
- ...internalCallSourceHeaders()
144
- };
145
- const init = { method, headers };
146
- if (body !== void 0 && method !== "GET") {
147
- headers["Content-Type"] = "application/json";
148
- init.body = JSON.stringify(body);
149
- }
150
- return fetch(url, init);
151
- }
152
- async function requestMultipartOnce(url, token, form) {
153
- return fetch(url, {
154
- method: "POST",
155
- headers: {
156
- "cli-token": token,
157
- "Accept": "application/json",
158
- ...internalCallSourceHeaders()
159
- },
160
- body: form
161
- });
162
- }
163
- async function callGateway(host, domain, pathAfterV1, method, body, queryParams = {}, options = {}) {
164
- return (await callGatewayWithEnvelope(host, domain, pathAfterV1, method, body, queryParams, options)).data;
165
- }
166
- async function callGatewayWithEnvelope(host, domain, pathAfterV1, method, body, queryParams = {}, options = {}) {
167
- const url = buildCapabilityGatewayUrl(options.apiBaseUrl ?? host, domain, pathAfterV1, queryParams);
168
- const token = await getCliToken(host);
169
- let resp = await requestOnce(url, method, token, body);
170
- let permissionMsg;
171
- if (resp.status === 403) {
172
- const error = await permissionError(resp);
173
- permissionMsg = error.message;
174
- if (options.retryOnInvalidTokenForbidden === false || !isInvalidCliTokenMessage(permissionMsg)) {
175
- throw error;
176
- }
177
- }
178
- if (resp.status === 401) {
179
- if (options.retryOnUnauthorized === false) {
180
- await throwCapabilityHttpError(resp);
181
- }
182
- logger.warn(`Capability gateway request failed (HTTP 401) for ${host}, refreshing CLI token`);
183
- clearCliToken(host);
184
- const newToken = await getCliToken(host);
185
- process.stderr.write(`[ae-cli] CLI token refreshed for ${host}
186
- `);
187
- resp = await requestOnce(url, method, newToken, body);
188
- if (resp.status === 403) {
189
- throw new PermissionError(await permissionMessage(resp));
190
- }
191
- if (!resp.ok) {
192
- await throwCapabilityHttpError(resp);
193
- }
194
- } else if (resp.status === 403 && permissionMsg) {
195
- logger.warn(`Capability gateway request failed (${permissionMsg}) for ${host}, refreshing CLI token`);
196
- clearCliToken(host);
197
- const newToken = await getCliToken(host);
198
- process.stderr.write(`[ae-cli] CLI token refreshed for ${host}
199
- `);
200
- resp = await requestOnce(url, method, newToken, body);
201
- if (resp.status === 403) {
202
- throw await permissionError(resp);
203
- }
204
- if (!resp.ok) {
205
- await throwCapabilityHttpError(resp);
206
- }
207
- } else if (!resp.ok) {
208
- await throwCapabilityHttpError(resp);
209
- }
210
- return parseCapabilityEnvelope(parseCapabilityResponse(await resp.text()));
211
- }
212
- async function fetchCapabilityGateway(host, domain, pathAfterV1, method = "GET", body, accept = "application/json") {
213
- const url = buildCapabilityGatewayUrl(host, domain, pathAfterV1);
214
- const token = await getCliToken(host);
215
- let resp = await requestOnce(url, method, token, body, accept);
216
- if (resp.status === 403) {
217
- throw await permissionError(resp);
218
- }
219
- if (resp.status === 401) {
220
- logger.warn(`Capability gateway request failed (HTTP 401) for ${host}, refreshing CLI token`);
221
- clearCliToken(host);
222
- const newToken = await getCliToken(host);
223
- process.stderr.write(`[ae-cli] CLI token refreshed for ${host}
224
- `);
225
- resp = await requestOnce(url, method, newToken, body, accept);
226
- if (resp.status === 403) {
227
- throw await permissionError(resp);
228
- }
229
- if (!resp.ok) {
230
- await throwCapabilityHttpError(resp);
231
- }
232
- } else if (!resp.ok) {
233
- await throwCapabilityHttpError(resp);
234
- }
235
- return resp;
236
- }
237
- async function requestCapabilityGateway(host, domain, pathAfterV1, method = "GET", body) {
238
- const resp = await fetchCapabilityGateway(host, domain, pathAfterV1, method, body);
239
- return unwrapCapabilityEnvelope(parseCapabilityResponse(await resp.text()));
240
- }
241
- async function requestCapabilityGatewayWithEnvelope(host, domain, pathAfterV1, method = "GET", body) {
242
- const resp = await fetchCapabilityGateway(host, domain, pathAfterV1, method, body);
243
- return parseCapabilityEnvelope(parseCapabilityResponse(await resp.text()));
244
- }
245
- async function listCapabilities(host, domain, projectId) {
246
- return callGateway(host, domain, "capabilities", "GET", void 0, { project_id: projectId });
247
- }
248
- async function inspectCapability(host, domain, capabilityId, projectId) {
249
- return callGateway(
250
- host,
251
- domain,
252
- `capabilities/${capabilityId}`,
253
- "GET",
254
- void 0,
255
- { project_id: projectId }
256
- );
257
- }
258
- async function executeCapability(host, domain, capabilityId, input = {}) {
259
- return callGateway(host, domain, `capabilities/${capabilityId}/execute`, "POST", { input });
260
- }
261
- async function executeCapabilityWithEnvelope(host, domain, capabilityId, input = {}) {
262
- return callGatewayWithEnvelope(host, domain, `capabilities/${capabilityId}/execute`, "POST", { input });
263
- }
264
- async function dryRunCapability(host, domain, capabilityId, input = {}) {
265
- return callGateway(host, domain, `capabilities/${capabilityId}/dry-run`, "POST", { input });
266
- }
267
- async function validateCapability(host, domain, capabilityId, input = {}) {
268
- return callGateway(host, domain, `capabilities/${capabilityId}/validate`, "POST", { input });
269
- }
270
- async function uploadInputFile(host, domain, projectId, purpose, filePath) {
271
- const fileBytes = await readFile(filePath);
272
- const filename = basename(filePath);
273
- return uploadInputFileBytes(
274
- host,
275
- domain,
276
- projectId,
277
- purpose,
278
- fileBytes,
279
- filename,
280
- inputFileContentType(filename)
281
- );
282
- }
283
- function inputFileContentType(filename) {
284
- const lower = filename.toLowerCase();
285
- if (lower.endsWith(".csv")) return "text/csv";
286
- if (lower.endsWith(".xlsx")) {
287
- return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
288
- }
289
- if (lower.endsWith(".json")) return "application/json";
290
- if (lower.endsWith(".txt")) return "text/plain";
291
- return "application/octet-stream";
292
- }
293
- async function uploadInputFileBytes(host, domain, projectId, purpose, bytes, filename, contentType = "application/octet-stream") {
294
- const url = buildCapabilityGatewayUrl(host, domain, "input-files");
295
- const fileBuffer = bytes instanceof ArrayBuffer ? bytes : bytes.buffer.slice(
296
- bytes.byteOffset,
297
- bytes.byteOffset + bytes.byteLength
298
- );
299
- const form = new FormData();
300
- form.append("project_id", String(projectId));
301
- form.append("purpose", purpose);
302
- form.append("file", new Blob([fileBuffer], { type: contentType }), filename);
303
- const token = await getCliToken(host);
304
- let resp = await requestMultipartOnce(url, token, form);
305
- if (resp.status === 403) {
306
- throw await permissionError(resp);
307
- }
308
- if (resp.status === 401) {
309
- logger.warn(`Capability gateway request failed (HTTP 401) for ${host}, refreshing CLI token`);
310
- clearCliToken(host);
311
- const newToken = await getCliToken(host);
312
- process.stderr.write(`[ae-cli] CLI token refreshed for ${host}
313
- `);
314
- resp = await requestMultipartOnce(url, newToken, form);
315
- if (resp.status === 403) {
316
- throw await permissionError(resp);
317
- }
318
- if (!resp.ok) {
319
- await throwCapabilityHttpError(resp);
320
- }
321
- } else if (!resp.ok) {
322
- await throwCapabilityHttpError(resp);
323
- }
324
- return unwrapCapabilityEnvelope(parseCapabilityResponse(await resp.text()));
325
- }
326
- async function callCapabilityApi(host, domain, action, method = "POST", params = {}, options = {}) {
327
- const isGet = method === "GET";
328
- if (isGet) {
329
- return callGateway(host, domain, action.replace(/^\/+|\/+$/g, ""), "GET", void 0, {}, options);
330
- }
331
- return callGateway(host, domain, action.replace(/^\/+|\/+$/g, ""), method, params, {}, options);
332
- }
333
-
334
- export {
335
- CapabilityGatewayError,
336
- buildCapabilityGatewayUrl,
337
- fetchCapabilityGateway,
338
- requestCapabilityGateway,
339
- requestCapabilityGatewayWithEnvelope,
340
- listCapabilities,
341
- inspectCapability,
342
- executeCapability,
343
- executeCapabilityWithEnvelope,
344
- dryRunCapability,
345
- validateCapability,
346
- uploadInputFile,
347
- uploadInputFileBytes,
348
- callCapabilityApi
349
- };
@@ -1,71 +0,0 @@
1
- import {
2
- withOutputMetadata
3
- } from "./chunk-GT46FPXN.js";
4
- import {
5
- dryRunCapability,
6
- executeCapabilityWithEnvelope,
7
- validateCapability
8
- } from "./chunk-ILIU36SU.js";
9
- import {
10
- resolveGatewayDomain
11
- } from "./chunk-PTE56QPL.js";
12
-
13
- // src/core/capability-command.ts
14
- import { randomBytes } from "crypto";
15
- function createCapabilityCommand(config) {
16
- return {
17
- service: config.cliService,
18
- resource: config.resource,
19
- command: config.command,
20
- capabilityId: config.capabilityId,
21
- description: config.description,
22
- flags: config.flags,
23
- risk: config.risk,
24
- validate: config.validate,
25
- preflight: (ctx) => {
26
- config.buildInput(ctx);
27
- },
28
- validateInput: async (ctx) => {
29
- const gatewayDomain = resolveGatewayDomain(config.cliService, config.gatewayDomain);
30
- const requestHost = config.requestHost ?? ctx.host();
31
- const input = config.buildInput(ctx);
32
- return validateCapability(requestHost, gatewayDomain, config.capabilityId, input);
33
- },
34
- dryRun: async (ctx) => {
35
- const gatewayDomain = resolveGatewayDomain(config.cliService, config.gatewayDomain);
36
- const requestHost = config.requestHost ?? ctx.host();
37
- const input = config.buildInput(ctx);
38
- return dryRunCapability(requestHost, gatewayDomain, config.capabilityId, input);
39
- },
40
- execute: async (ctx) => {
41
- const gatewayDomain = resolveGatewayDomain(config.cliService, config.gatewayDomain);
42
- const requestHost = config.requestHost ?? ctx.host();
43
- const input = withLifecycleRequestId(config, config.buildInput(ctx));
44
- announceDispatch(config.capabilityId, input);
45
- const result = await executeCapabilityWithEnvelope(requestHost, gatewayDomain, config.capabilityId, input);
46
- const data = config.postProcess ? await config.postProcess(result.data, input, ctx) : result.data;
47
- return withOutputMetadata(data, result.meta);
48
- }
49
- };
50
- }
51
- function withLifecycleRequestId(config, input) {
52
- if (!config.flags.some((flag) => flag.name === "request-id")) {
53
- return input;
54
- }
55
- const supplied = input.request_id;
56
- const requestId = typeof supplied === "string" && supplied.length > 0 ? supplied : `cli_${randomBytes(16).toString("hex")}`;
57
- return { ...input, request_id: requestId };
58
- }
59
- function announceDispatch(capabilityId, input) {
60
- if (typeof input.request_id !== "string") {
61
- return;
62
- }
63
- process.stderr.write(
64
- `[ae-cli] dispatching capability=${capabilityId} request_id=${input.request_id}
65
- `
66
- );
67
- }
68
-
69
- export {
70
- createCapabilityCommand
71
- };
@@ -1,37 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
- }) : x)(function(x) {
10
- if (typeof require !== "undefined") return require.apply(this, arguments);
11
- throw Error('Dynamic require of "' + x + '" is not supported');
12
- });
13
- var __commonJS = (cb, mod) => function __require2() {
14
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
- };
16
- var __copyProps = (to, from, except, desc) => {
17
- if (from && typeof from === "object" || typeof from === "function") {
18
- for (let key of __getOwnPropNames(from))
19
- if (!__hasOwnProp.call(to, key) && key !== except)
20
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
- }
22
- return to;
23
- };
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
- // If the importer is in node compatibility mode or this is not an ESM
26
- // file that has been converted to a CommonJS file using a Babel-
27
- // compatible transform (i.e. "__esModule" has not been set), then set
28
- // "default" to the CommonJS "module.exports" for node compatibility.
29
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
- mod
31
- ));
32
-
33
- export {
34
- __require,
35
- __commonJS,
36
- __toESM
37
- };