aui-agent-builder 0.4.2 → 0.4.4
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 +18 -11
- package/dist/api-client/apollo-client.d.ts +40 -0
- package/dist/api-client/apollo-client.d.ts.map +1 -1
- package/dist/api-client/apollo-client.js.map +1 -1
- package/dist/api-client/mock-db-client.d.ts +144 -0
- package/dist/api-client/mock-db-client.d.ts.map +1 -0
- package/dist/api-client/mock-db-client.js +345 -0
- package/dist/api-client/mock-db-client.js.map +1 -0
- package/dist/commands/agents.d.ts +11 -17
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +148 -144
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/apollo.d.ts +53 -0
- package/dist/commands/apollo.d.ts.map +1 -1
- package/dist/commands/apollo.js +121 -10
- package/dist/commands/apollo.js.map +1 -1
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +1 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/init.js +1 -1
- package/dist/commands/mockdb-guide.d.ts +7 -0
- package/dist/commands/mockdb-guide.d.ts.map +1 -0
- package/dist/commands/mockdb-guide.js +100 -0
- package/dist/commands/mockdb-guide.js.map +1 -0
- package/dist/commands/mockdb.d.ts +76 -0
- package/dist/commands/mockdb.d.ts.map +1 -0
- package/dist/commands/mockdb.js +535 -0
- package/dist/commands/mockdb.js.map +1 -0
- package/dist/config/index.d.ts +33 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +58 -0
- package/dist/config/index.js.map +1 -1
- package/dist/index.js +308 -10
- package/dist/index.js.map +1 -1
- package/dist/services/mock-db.service.d.ts +66 -0
- package/dist/services/mock-db.service.d.ts.map +1 -0
- package/dist/services/mock-db.service.js +177 -0
- package/dist/services/mock-db.service.js.map +1 -0
- package/dist/utils/fetch-with-timeout.d.ts +2 -2
- package/dist/utils/fetch-with-timeout.js +3 -3
- package/dist/utils/fetch-with-timeout.js.map +1 -1
- package/package.json +1 -1
package/dist/commands/agents.js
CHANGED
|
@@ -1131,11 +1131,12 @@ export async function agents(options = {}) {
|
|
|
1131
1131
|
const config = getConfig();
|
|
1132
1132
|
// ─── Resolve & validate kind + bundle_mode up-front ──────────────
|
|
1133
1133
|
//
|
|
1134
|
+
// Agent creation is ALWAYS bundle mode now. Records-mode creation has
|
|
1135
|
+
// been retired (the `--records-mode` flag was removed and every records
|
|
1136
|
+
// creation branch below is commented out — see the notes there). So the
|
|
1137
|
+
// only thing left to resolve here is `kind` (regular vs template).
|
|
1138
|
+
//
|
|
1134
1139
|
// Rules (matches the integration guide §3 — "Working with templates"):
|
|
1135
|
-
// - `--template` + `--records-mode` → REJECTED (templates are
|
|
1136
|
-
// blob-mode-only)
|
|
1137
|
-
// - `--bundle-mode` + `--records-mode` → REJECTED (mutually
|
|
1138
|
-
// exclusive)
|
|
1139
1140
|
// - `--template` + `--network-id` → REJECTED (templates
|
|
1140
1141
|
// are NETWORK_CATEGORY-
|
|
1141
1142
|
// scoped; they don't
|
|
@@ -1147,30 +1148,40 @@ export async function agents(options = {}) {
|
|
|
1147
1148
|
// category for templates"
|
|
1148
1149
|
// fallback)
|
|
1149
1150
|
//
|
|
1150
|
-
//
|
|
1151
|
-
//
|
|
1152
|
-
//
|
|
1153
|
-
//
|
|
1154
|
-
//
|
|
1155
|
-
//
|
|
1156
|
-
//
|
|
1157
|
-
//
|
|
1158
|
-
//
|
|
1159
|
-
//
|
|
1160
|
-
//
|
|
1161
|
-
//
|
|
1162
|
-
//
|
|
1163
|
-
//
|
|
1164
|
-
//
|
|
1165
|
-
//
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
}
|
|
1170
|
-
if (opts.template && opts.recordsMode) {
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1151
|
+
// ─── RECORDS-MODE CREATION RETIRED — moved to bundle-mode creation ──
|
|
1152
|
+
// The two validation gates below used to reject `--records-mode` paired
|
|
1153
|
+
// with `--bundle-mode` / `--template`. The `--records-mode` flag no
|
|
1154
|
+
// longer exists (creation is bundle-only), so these gates are dead and
|
|
1155
|
+
// are kept commented for historical reference only.
|
|
1156
|
+
//
|
|
1157
|
+
// if (opts.bundleMode && opts.recordsMode) {
|
|
1158
|
+
// renderView(
|
|
1159
|
+
// <Box flexDirection="column" paddingX={1}>
|
|
1160
|
+
// <StatusLine
|
|
1161
|
+
// kind="error"
|
|
1162
|
+
// label="--bundle-mode and --records-mode are mutually exclusive."
|
|
1163
|
+
// />
|
|
1164
|
+
// <Text color="gray">
|
|
1165
|
+
// {" Pick one — or pass neither to use the default (records-mode)."}
|
|
1166
|
+
// </Text>
|
|
1167
|
+
// </Box>,
|
|
1168
|
+
// );
|
|
1169
|
+
// return;
|
|
1170
|
+
// }
|
|
1171
|
+
// if (opts.template && opts.recordsMode) {
|
|
1172
|
+
// renderView(
|
|
1173
|
+
// <Box flexDirection="column" paddingX={1}>
|
|
1174
|
+
// <StatusLine
|
|
1175
|
+
// kind="error"
|
|
1176
|
+
// label="--template forces bundle_mode=true; --records-mode is incompatible."
|
|
1177
|
+
// />
|
|
1178
|
+
// <Text color="gray">
|
|
1179
|
+
// {" Templates are blob-mode-only by design (see integration guide §3)."}
|
|
1180
|
+
// </Text>
|
|
1181
|
+
// </Box>,
|
|
1182
|
+
// );
|
|
1183
|
+
// return;
|
|
1184
|
+
// }
|
|
1174
1185
|
if (opts.template && opts.networkId) {
|
|
1175
1186
|
renderView(_jsxs(Box, { flexDirection: "column", paddingX: 1, children: [_jsx(StatusLine, { kind: "error", label: "--template is incompatible with --network-id." }), _jsx(Text, { color: "gray", children: " Templates are scoped to a NETWORK_CATEGORY, not a NETWORK." })] }));
|
|
1176
1187
|
return;
|
|
@@ -1189,30 +1200,21 @@ export async function agents(options = {}) {
|
|
|
1189
1200
|
const kind = opts.template ? "template" : "regular";
|
|
1190
1201
|
// ─── Resolve bundle_mode ──────────────────────────────────────────
|
|
1191
1202
|
//
|
|
1192
|
-
//
|
|
1193
|
-
//
|
|
1194
|
-
//
|
|
1195
|
-
//
|
|
1196
|
-
//
|
|
1197
|
-
//
|
|
1203
|
+
// RECORDS-MODE CREATION RETIRED — moved to bundle-mode creation.
|
|
1204
|
+
// Every agent (regular or template, every environment, interactive or
|
|
1205
|
+
// non-interactive) is now created in bundle mode, provisioned end-to-end
|
|
1206
|
+
// via the Apollo endpoint. There is no `bundleMode` variable anymore —
|
|
1207
|
+
// the create paths below all go through `createBundledAgentViaApollo`.
|
|
1208
|
+
// The old environment/flag-driven resolution is kept commented for
|
|
1209
|
+
// historical reference only:
|
|
1198
1210
|
//
|
|
1199
|
-
//
|
|
1200
|
-
//
|
|
1201
|
-
//
|
|
1202
|
-
//
|
|
1203
|
-
//
|
|
1204
|
-
//
|
|
1205
|
-
//
|
|
1206
|
-
// Override either way with --bundle-mode / --records-mode explicitly.
|
|
1207
|
-
const env = config.environment ?? "staging";
|
|
1208
|
-
const envDefaultsToBundle = !(env === "production" || env === "eu-production");
|
|
1209
|
-
const bundleMode = opts.template
|
|
1210
|
-
? true
|
|
1211
|
-
: opts.bundleMode === true
|
|
1212
|
-
? true
|
|
1213
|
-
: opts.recordsMode === true
|
|
1214
|
-
? false
|
|
1215
|
-
: envDefaultsToBundle;
|
|
1211
|
+
// const bundleMode = opts.template
|
|
1212
|
+
// ? true
|
|
1213
|
+
// : opts.bundleMode === true
|
|
1214
|
+
// ? true
|
|
1215
|
+
// : opts.recordsMode === true
|
|
1216
|
+
// ? false
|
|
1217
|
+
// : true;
|
|
1216
1218
|
const client = new AUIClient({
|
|
1217
1219
|
baseUrl: config.apiUrl,
|
|
1218
1220
|
authToken: config.authToken,
|
|
@@ -1300,63 +1302,64 @@ export async function agents(options = {}) {
|
|
|
1300
1302
|
});
|
|
1301
1303
|
return;
|
|
1302
1304
|
}
|
|
1303
|
-
//
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
}
|
|
1305
|
+
// ─── RECORDS-MODE CREATION RETIRED — moved to bundle-mode creation ──
|
|
1306
|
+
// Direct single-command `aui agents --create --name X --network-id Y`
|
|
1307
|
+
// created the agent inside a caller-supplied existing network — a
|
|
1308
|
+
// records-mode concept. Bundle-mode provisioning creates its OWN network
|
|
1309
|
+
// server-side, so an external `--network-id` is meaningless. This branch
|
|
1310
|
+
// is commented out (kept for historical reference). `--name X` now flows
|
|
1311
|
+
// through the bundle path below / the interactive flow.
|
|
1312
|
+
//
|
|
1313
|
+
// // Direct single-command: aui agents --create --name X --network-id Y
|
|
1314
|
+
// if (agentName && networkId) {
|
|
1315
|
+
// if (!categoryId) {
|
|
1316
|
+
// const networks = (await client.networks.list()).data;
|
|
1317
|
+
// const net = networks.find((n) => (n._id === networkId || n.id === networkId));
|
|
1318
|
+
// categoryId = net
|
|
1319
|
+
// ? (typeof net.category === "string" ? net.category : net.category?._id || "")
|
|
1320
|
+
// : "";
|
|
1321
|
+
// }
|
|
1322
|
+
// const result = await createAgentOnBackend(agentName, networkId, categoryId || "", {
|
|
1323
|
+
// kind,
|
|
1324
|
+
// bundleMode,
|
|
1325
|
+
// });
|
|
1326
|
+
// await runPostCreateFlow(result, bundleMode, opts.dir, agentName, opts.full);
|
|
1327
|
+
// return;
|
|
1328
|
+
// }
|
|
1324
1329
|
// Direct single-command: aui agents --create --name X --category Y (new network)
|
|
1325
1330
|
if (agentName && categoryId && !networkId) {
|
|
1326
1331
|
// Bundle-mode: hand the whole flow (network → agent → version →
|
|
1327
|
-
// publish → activate) to the Apollo provisioning endpoint.
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
organizationId: client.getOrganizationId(),
|
|
1334
|
-
accountId: client.getAccountId(),
|
|
1335
|
-
});
|
|
1336
|
-
await autoImportAndEnter(created, opts.dir, agentName);
|
|
1337
|
-
return;
|
|
1338
|
-
}
|
|
1339
|
-
const netSpinner = render(_jsx(Spinner, { label: "Creating agent..." }));
|
|
1340
|
-
try {
|
|
1341
|
-
const resp = await client.networks.create({ name: agentName, category: categoryId });
|
|
1342
|
-
networkId = resp.data._id || resp.data.id;
|
|
1343
|
-
netSpinner.unmount();
|
|
1344
|
-
logView(_jsx(StatusLine, { kind: "success", label: `Network created: ${agentName} (${networkId})` }));
|
|
1345
|
-
}
|
|
1346
|
-
catch (error) {
|
|
1347
|
-
netSpinner.unmount();
|
|
1348
|
-
renderView(_jsx(ErrorDisplay, { error: error, message: "Failed to create agent." }));
|
|
1349
|
-
return;
|
|
1350
|
-
}
|
|
1351
|
-
const result = await createAgentOnBackend(agentName, networkId, categoryId, {
|
|
1352
|
-
kind,
|
|
1353
|
-
bundleMode,
|
|
1332
|
+
// publish → activate) to the Apollo provisioning endpoint.
|
|
1333
|
+
const created = await createBundledAgentViaApollo({
|
|
1334
|
+
name: agentName,
|
|
1335
|
+
networkCategoryId: categoryId,
|
|
1336
|
+
organizationId: client.getOrganizationId(),
|
|
1337
|
+
accountId: client.getAccountId(),
|
|
1354
1338
|
});
|
|
1355
|
-
|
|
1356
|
-
// seed the v1.0 draft (non-interactive included) and auto-import it
|
|
1357
|
-
// when appropriate. See note on the --network-id branch above.
|
|
1358
|
-
await runPostCreateFlow(result, bundleMode, opts.dir, agentName, opts.full);
|
|
1339
|
+
await autoImportAndEnter(created, opts.dir, agentName);
|
|
1359
1340
|
return;
|
|
1341
|
+
// ─── RECORDS-MODE CREATION RETIRED — moved to bundle-mode creation ──
|
|
1342
|
+
// The legacy per-step records path (network create → createAgentOnBackend
|
|
1343
|
+
// → seed v1.0 draft → auto-import) is commented out below; bundle-mode
|
|
1344
|
+
// provisioning above replaces it.
|
|
1345
|
+
//
|
|
1346
|
+
// const netSpinner = render(<Spinner label="Creating agent..." />);
|
|
1347
|
+
// try {
|
|
1348
|
+
// const resp = await client.networks.create({ name: agentName, category: categoryId });
|
|
1349
|
+
// networkId = resp.data._id || resp.data.id;
|
|
1350
|
+
// netSpinner.unmount();
|
|
1351
|
+
// logView(<StatusLine kind="success" label={`Network created: ${agentName} (${networkId})`} />);
|
|
1352
|
+
// } catch (error: unknown) {
|
|
1353
|
+
// netSpinner.unmount();
|
|
1354
|
+
// renderView(<ErrorDisplay error={error} message="Failed to create agent." />);
|
|
1355
|
+
// return;
|
|
1356
|
+
// }
|
|
1357
|
+
// const result = await createAgentOnBackend(agentName, networkId, categoryId, {
|
|
1358
|
+
// kind,
|
|
1359
|
+
// bundleMode,
|
|
1360
|
+
// });
|
|
1361
|
+
// await runPostCreateFlow(result, bundleMode, opts.dir, agentName, opts.full);
|
|
1362
|
+
// return;
|
|
1360
1363
|
}
|
|
1361
1364
|
// ─── Interactive flow with step indicators ───
|
|
1362
1365
|
logView(_jsxs(Box, { flexDirection: "column", paddingX: 1, children: [_jsxs(Box, { children: [_jsx(Text, { color: "cyan", bold: true, children: "\u25C6 " }), _jsx(Text, { bold: true, children: "Create a New Agent" })] }), !categoryId && (_jsxs(_Fragment, { children: [_jsx(Box, { children: _jsx(Text, { color: "gray", children: " Using default category (General). To use a specific one:" }) }), _jsxs(Box, { children: [_jsx(Text, { color: "gray", children: " aui agents --create --category " }), _jsx(Text, { color: "gray", italic: true, children: "<name or key>" })] })] })), categoryId && (_jsxs(Box, { children: [_jsx(Text, { color: "gray", children: " Category: " }), _jsx(Text, { children: opts.category })] }))] }));
|
|
@@ -1471,48 +1474,49 @@ export async function agents(options = {}) {
|
|
|
1471
1474
|
}
|
|
1472
1475
|
// Bundle-mode: the Apollo provisioning endpoint runs the whole flow
|
|
1473
1476
|
// (network → agent → version-from-template → publish → activate) in a
|
|
1474
|
-
// single call
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
organizationId: client.getOrganizationId(),
|
|
1481
|
-
accountId: client.getAccountId(),
|
|
1482
|
-
});
|
|
1483
|
-
await autoImportAndEnter(created, opts.dir, agentName);
|
|
1484
|
-
return;
|
|
1485
|
-
}
|
|
1486
|
-
// Create network
|
|
1487
|
-
const netSpinner = render(_jsx(Spinner, { label: `Creating "${agentName}"...` }));
|
|
1488
|
-
try {
|
|
1489
|
-
const resp = await client.networks.create({ name: agentName, category: categoryId || "" });
|
|
1490
|
-
networkId = resp.data._id || resp.data.id;
|
|
1491
|
-
netSpinner.unmount();
|
|
1492
|
-
if (process.env.AUI_DEBUG) {
|
|
1493
|
-
console.log(`[debug] Step 1 - network created: ${networkId} (name: ${agentName}, category: ${categoryId})`);
|
|
1494
|
-
}
|
|
1495
|
-
}
|
|
1496
|
-
catch (error) {
|
|
1497
|
-
netSpinner.unmount();
|
|
1498
|
-
let detail = "";
|
|
1499
|
-
if (error && typeof error === "object" && "body" in error) {
|
|
1500
|
-
const body = error.body;
|
|
1501
|
-
const msg = body?.msg || body?.errors?.errors?.[0]?.msg || body?.error?.detail;
|
|
1502
|
-
if (msg)
|
|
1503
|
-
detail = `: ${msg}`;
|
|
1504
|
-
}
|
|
1505
|
-
else if (error instanceof Error) {
|
|
1506
|
-
detail = `: ${error.message}`;
|
|
1507
|
-
}
|
|
1508
|
-
renderView(_jsx(ErrorDisplay, { error: error, message: `Failed to create agent${detail}` }));
|
|
1509
|
-
return;
|
|
1510
|
-
}
|
|
1511
|
-
const result = await createAgentOnBackend(agentName, networkId, categoryId || "", {
|
|
1512
|
-
kind,
|
|
1513
|
-
bundleMode,
|
|
1477
|
+
// single call. This is the only creation path now.
|
|
1478
|
+
const created = await createBundledAgentViaApollo({
|
|
1479
|
+
name: agentName,
|
|
1480
|
+
networkCategoryId: categoryId || "",
|
|
1481
|
+
organizationId: client.getOrganizationId(),
|
|
1482
|
+
accountId: client.getAccountId(),
|
|
1514
1483
|
});
|
|
1515
|
-
await
|
|
1484
|
+
await autoImportAndEnter(created, opts.dir, agentName);
|
|
1485
|
+
return;
|
|
1486
|
+
// ─── RECORDS-MODE CREATION RETIRED — moved to bundle-mode creation ──
|
|
1487
|
+
// The legacy interactive records path (create network → createAgentOnBackend
|
|
1488
|
+
// → seed v1.0 draft / runPostCreateFlow) is commented out below; the
|
|
1489
|
+
// bundle-mode provisioning above replaces it.
|
|
1490
|
+
//
|
|
1491
|
+
// // Create network
|
|
1492
|
+
// const netSpinner = render(<Spinner label={`Creating "${agentName}"...`} />);
|
|
1493
|
+
// try {
|
|
1494
|
+
// const resp = await client.networks.create({ name: agentName!, category: categoryId || "" });
|
|
1495
|
+
// networkId = resp.data._id || resp.data.id;
|
|
1496
|
+
// netSpinner.unmount();
|
|
1497
|
+
// if (process.env.AUI_DEBUG) {
|
|
1498
|
+
// console.log(`[debug] Step 1 - network created: ${networkId} (name: ${agentName}, category: ${categoryId})`);
|
|
1499
|
+
// }
|
|
1500
|
+
// } catch (error: unknown) {
|
|
1501
|
+
// netSpinner.unmount();
|
|
1502
|
+
// let detail = "";
|
|
1503
|
+
// if (error && typeof error === "object" && "body" in error) {
|
|
1504
|
+
// const body = (error as any).body;
|
|
1505
|
+
// const msg = body?.msg || body?.errors?.errors?.[0]?.msg || body?.error?.detail;
|
|
1506
|
+
// if (msg) detail = `: ${msg}`;
|
|
1507
|
+
// } else if (error instanceof Error) {
|
|
1508
|
+
// detail = `: ${error.message}`;
|
|
1509
|
+
// }
|
|
1510
|
+
// renderView(<ErrorDisplay error={error} message={`Failed to create agent${detail}`} />);
|
|
1511
|
+
// return;
|
|
1512
|
+
// }
|
|
1513
|
+
//
|
|
1514
|
+
// const result = await createAgentOnBackend(agentName!, networkId!, categoryId || "", {
|
|
1515
|
+
// kind,
|
|
1516
|
+
// bundleMode,
|
|
1517
|
+
// });
|
|
1518
|
+
//
|
|
1519
|
+
// await runPostCreateFlow(result, bundleMode, opts.dir, agentName, opts.full);
|
|
1516
1520
|
}
|
|
1517
1521
|
}
|
|
1518
1522
|
/**
|