@alexkroman1/aai-cli 5.14.0 → 6.1.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/{_agent-C8Jk-ZcP.mjs → _agent-vGW5SBnX.mjs} +23 -5
- package/dist/_agent.d.ts +18 -0
- package/dist/{_api-client-BX8Qv51n.mjs → _api-client-LgLksMhN.mjs} +45 -8
- package/dist/_api-client.d.ts +39 -0
- package/dist/{_bundler-BuIyDdvs.mjs → _bundler-BapCUUJN.mjs} +42 -14
- package/dist/_bundler.d.ts +43 -5
- package/dist/_cli-common.d.ts +67 -3
- package/dist/{_config-CzwAWOWr.mjs → _config-D_s09e7g.mjs} +36 -18
- package/dist/_deploy.d.ts +2 -5
- package/dist/_dev-restart.d.ts +6 -1
- package/dist/{_dev-server-Ch7K8e8i.mjs → _dev-server-DQ1t9sbw.mjs} +94 -38
- package/dist/_dev-server.d.ts +30 -2
- package/dist/_e2e-test-utils.d.ts +80 -0
- package/dist/_fault-mode.d.ts +175 -0
- package/dist/{_init-CbkrE2wq.mjs → _init-CpISqoR8.mjs} +3 -3
- package/dist/{_output-CC300DzW.mjs → _output-CKkmWs7i.mjs} +8 -1
- package/dist/_output.d.ts +9 -2
- package/dist/{_server-common-61fL__39.mjs → _server-common-6e0QI4mq.mjs} +1 -1
- package/dist/{_slug-api-D30zPmsn.mjs → _slug-api-D2heILuC.mjs} +2 -2
- package/dist/{_studio-D2ciIhbi.mjs → _studio-zAJycZ8j.mjs} +3 -3
- package/dist/{_templates-B1kt3BGt.mjs → _templates-iDGjGiPf.mjs} +4 -6
- package/dist/{_typecheck-gate-4v9UBZHh.mjs → _typecheck-gate-BXvUNnfs.mjs} +1 -1
- package/dist/{_utils-0DHbcqUb.mjs → _utils-B8QmtFhK.mjs} +21 -7
- package/dist/_utils.d.ts +18 -2
- package/dist/{_vite-env-Dg_QlVv0.mjs → _vite-env-BNveawd1.mjs} +31 -1
- package/dist/_vite-env.d.ts +30 -0
- package/dist/build-BO1Ni6oJ.mjs +62 -0
- package/dist/build.d.ts +19 -0
- package/dist/cli-workflow.d.ts +10 -0
- package/dist/cli.d.ts +1 -2
- package/dist/cli.mjs +406 -224
- package/dist/{client-bundler-C9qXL8A2.mjs → client-bundler-B8Q9F8gJ.mjs} +3 -22
- package/dist/client-bundler.mjs +1 -1
- package/dist/{delete-DCRX3d96.mjs → delete-4I0uNR4a.mjs} +6 -7
- package/dist/delete.d.ts +2 -8
- package/dist/{deploy-DjsEV-40.mjs → deploy-DJ3HRcia.mjs} +13 -14
- package/dist/{dev-CvPH5dbF.mjs → dev-C6SWaAZP.mjs} +3 -3
- package/dist/{eject-LgBRfnbH.mjs → eject-Zrzk5KV3.mjs} +41 -15
- package/dist/eject.d.ts +30 -3
- package/dist/{init-BppxMR8r.mjs → init-BTRGiPQr.mjs} +61 -26
- package/dist/init.d.ts +11 -0
- package/dist/{login-BQQaxJhL.mjs → login-k0Z3VQu9.mjs} +5 -5
- package/dist/project-config.mjs +1 -1
- package/dist/scaffold/CLAUDE.md +498 -91
- package/dist/scaffold/package.json +11 -8
- package/dist/scaffold/pnpm-workspace.yaml +8 -0
- package/dist/scaffold/server.mjs +53 -57
- package/dist/{secret-Ds9dvqAj.mjs → secret-DzSQx1Ds.mjs} +6 -3
- package/dist/{storage-DbrQSHFk.mjs → storage-C-Do0mIA.mjs} +18 -6
- package/dist/{studio-GSFd4s5O.mjs → studio-BGVmCA2G.mjs} +10 -10
- package/dist/templates/code-interpreter/agent.ts +0 -2
- package/dist/templates/dispatch-center/agent.test.ts +17 -19
- package/dist/templates/dispatch-center/agent.ts +2 -29
- package/dist/templates/dispatch-center/client.tsx +33 -16
- package/dist/templates/dispatch-center/shared.ts +53 -19
- package/dist/templates/dispatch-center/tools/incident_add_note.ts +12 -14
- package/dist/templates/dispatch-center/tools/incident_create.ts +41 -44
- package/dist/templates/dispatch-center/tools/incident_escalate.ts +59 -61
- package/dist/templates/dispatch-center/tools/incident_get.ts +3 -4
- package/dist/templates/dispatch-center/tools/incident_triage.ts +43 -45
- package/dist/templates/dispatch-center/tools/incident_update_status.ts +39 -41
- package/dist/templates/dispatch-center/tools/ops_dashboard.ts +2 -5
- package/dist/templates/dispatch-center/tools/ops_protocols.ts +1 -1
- package/dist/templates/dispatch-center/tools/ops_run_scenario.ts +20 -23
- package/dist/templates/dispatch-center/tools/resources_dispatch.ts +52 -54
- package/dist/templates/dispatch-center/tools/resources_get_available.ts +2 -4
- package/dist/templates/dispatch-center/tools/resources_update_status.ts +39 -42
- package/dist/templates/embedded-assets/agent.test.ts +83 -0
- package/dist/templates/embedded-assets/agent.ts +1 -48
- package/dist/templates/embedded-assets/shared.ts +17 -0
- package/dist/templates/embedded-assets/system-prompt.md +13 -0
- package/dist/templates/embedded-assets/tools/list_topics.ts +9 -0
- package/dist/templates/embedded-assets/tools/search_knowledge.ts +26 -0
- package/dist/templates/health-assistant/agent.test.ts +169 -0
- package/dist/templates/health-assistant/agent.ts +1 -166
- package/dist/templates/health-assistant/fda.ts +100 -0
- package/dist/templates/health-assistant/tools/check_drug_interaction.ts +59 -0
- package/dist/templates/health-assistant/tools/medication_lookup.ts +31 -0
- package/dist/templates/infocom-adventure/agent.test.ts +205 -0
- package/dist/templates/infocom-adventure/agent.ts +3 -106
- package/dist/templates/infocom-adventure/client.tsx +28 -12
- package/dist/templates/infocom-adventure/shared.ts +28 -11
- package/dist/templates/infocom-adventure/tools/game_state_drop.ts +13 -0
- package/dist/templates/infocom-adventure/tools/game_state_flag.ts +13 -0
- package/dist/templates/infocom-adventure/tools/game_state_get.ts +16 -0
- package/dist/templates/infocom-adventure/tools/game_state_history.ts +14 -0
- package/dist/templates/infocom-adventure/tools/game_state_move.ts +14 -0
- package/dist/templates/infocom-adventure/tools/game_state_restart.ts +13 -0
- package/dist/templates/infocom-adventure/tools/game_state_score.ts +13 -0
- package/dist/templates/infocom-adventure/tools/game_state_take.ts +13 -0
- package/dist/templates/link-digest/agent.test.ts +223 -0
- package/dist/templates/link-digest/agent.ts +79 -0
- package/dist/templates/link-digest/client.tsx +146 -0
- package/dist/templates/link-digest/workflows/digest.ts +248 -0
- package/dist/templates/math-buddy/agent.ts +0 -2
- package/dist/templates/night-owl/agent.test.ts +80 -0
- package/dist/templates/night-owl/agent.ts +1 -68
- package/dist/templates/night-owl/system-prompt.md +10 -0
- package/dist/templates/night-owl/tools/recommend.ts +64 -0
- package/dist/templates/personal-finance/agent.ts +0 -2
- package/dist/templates/pizza-ordering/agent.test.ts +52 -47
- package/dist/templates/pizza-ordering/agent.ts +9 -158
- package/dist/templates/pizza-ordering/shared.ts +35 -12
- package/dist/templates/pizza-ordering/tools/add_pizza.ts +31 -0
- package/dist/templates/pizza-ordering/tools/place_order.ts +22 -0
- package/dist/templates/pizza-ordering/tools/remove_pizza.ts +22 -0
- package/dist/templates/pizza-ordering/tools/set_customer_name.ts +13 -0
- package/dist/templates/pizza-ordering/tools/update_pizza.ts +28 -0
- package/dist/templates/pizza-ordering/tools/view_order.ts +21 -0
- package/dist/templates/plan-and-execute/agent.test.ts +411 -0
- package/dist/templates/plan-and-execute/agent.ts +23 -0
- package/dist/templates/plan-and-execute/client.tsx +115 -0
- package/dist/templates/plan-and-execute/graph.ts +178 -0
- package/dist/templates/plan-and-execute/prompts.ts +110 -0
- package/dist/templates/plan-and-execute/shared.ts +161 -0
- package/dist/templates/plan-and-execute/system-prompt.md +18 -0
- package/dist/templates/plan-and-execute/tools/plan_status.ts +20 -0
- package/dist/templates/plan-and-execute/tools/revise_plan.ts +63 -0
- package/dist/templates/plan-and-execute/tools/start_plan.ts +51 -0
- package/dist/templates/plan-and-execute/tools/work_next_step.ts +101 -0
- package/dist/templates/recap-workflow/agent.test.ts +762 -0
- package/dist/templates/recap-workflow/agent.ts +95 -0
- package/dist/templates/recap-workflow/shared.ts +43 -0
- package/dist/templates/recap-workflow/tools/cancel_recap.ts +23 -0
- package/dist/templates/recap-workflow/tools/keep_transcript.ts +31 -0
- package/dist/templates/recap-workflow/tools/recap_progress.ts +27 -0
- package/dist/templates/recap-workflow/tools/recap_status.ts +46 -0
- package/dist/templates/recap-workflow/tools/request_recap.ts +43 -0
- package/dist/templates/recap-workflow/workflows/recap.ts +544 -0
- package/dist/templates/recap-workflow/workflows/tokens.ts +26 -0
- package/dist/templates/redline/agent.test.ts +222 -0
- package/dist/templates/redline/agent.ts +89 -0
- package/dist/templates/redline/client.tsx +184 -0
- package/dist/templates/redline/workflows/prompts.ts +68 -0
- package/dist/templates/redline/workflows/redline.ts +258 -0
- package/dist/templates/research-workflow/agent.test.ts +525 -0
- package/dist/templates/research-workflow/agent.ts +94 -0
- package/dist/templates/research-workflow/shared.ts +35 -0
- package/dist/templates/research-workflow/tools/file_it_now.ts +22 -0
- package/dist/templates/research-workflow/tools/request_research.ts +33 -0
- package/dist/templates/research-workflow/tools/research_progress.ts +26 -0
- package/dist/templates/research-workflow/tools/research_status.ts +40 -0
- package/dist/templates/research-workflow/workflows/prompts.ts +143 -0
- package/dist/templates/research-workflow/workflows/research.ts +558 -0
- package/dist/templates/retail/agent.test.ts +236 -172
- package/dist/templates/retail/agent.ts +5 -42
- package/dist/templates/retail/client.tsx +33 -11
- package/dist/templates/retail/registry.test.ts +31 -16
- package/dist/templates/retail/resolve.ts +28 -64
- package/dist/templates/retail/shared.test.ts +4 -3
- package/dist/templates/retail/shared.ts +24 -7
- package/dist/templates/retail/store.test.ts +12 -10
- package/dist/templates/retail/store.ts +69 -30
- package/dist/templates/retail/tools/cancel_pending_order.ts +4 -9
- package/dist/templates/retail/tools/exchange_delivered_order_items.ts +22 -11
- package/dist/templates/retail/tools/find_user_id_by_email.ts +5 -9
- package/dist/templates/retail/tools/find_user_id_by_name_zip.ts +5 -7
- package/dist/templates/retail/tools/get_item_details.ts +5 -7
- package/dist/templates/retail/tools/get_order_details.ts +5 -7
- package/dist/templates/retail/tools/get_product_details.ts +4 -7
- package/dist/templates/retail/tools/get_user_details.ts +4 -7
- package/dist/templates/retail/tools/list_all_product_types.ts +5 -7
- package/dist/templates/retail/tools/modify_pending_order_address.ts +4 -9
- package/dist/templates/retail/tools/modify_pending_order_items.ts +4 -16
- package/dist/templates/retail/tools/modify_pending_order_payment.ts +3 -9
- package/dist/templates/retail/tools/modify_user_address.ts +4 -9
- package/dist/templates/retail/tools/return_delivered_order_items.ts +3 -9
- package/dist/templates/retail/tools/transfer_to_human_agents.ts +1 -1
- package/dist/templates/solo-rpg/agent.test.ts +152 -29
- package/dist/templates/solo-rpg/agent.ts +3 -21
- package/dist/templates/solo-rpg/client.tsx +19 -6
- package/dist/templates/solo-rpg/shared.ts +19 -11
- package/dist/templates/solo-rpg/tools/action_roll.ts +2 -4
- package/dist/templates/solo-rpg/tools/burn_momentum.ts +2 -4
- package/dist/templates/solo-rpg/tools/check_state.ts +6 -6
- package/dist/templates/solo-rpg/tools/load_game.ts +1 -1
- package/dist/templates/solo-rpg/tools/oracle.ts +18 -11
- package/dist/templates/solo-rpg/tools/save_game.ts +10 -7
- package/dist/templates/solo-rpg/tools/setup_character.ts +1 -1
- package/dist/templates/solo-rpg/tools/update_state.ts +3 -4
- package/dist/templates/support-line/agent.test.ts +343 -0
- package/dist/templates/support-line/agent.ts +27 -0
- package/dist/templates/support-line/client.tsx +122 -0
- package/dist/templates/support-line/graph.ts +224 -0
- package/dist/templates/support-line/knowledge.json +65 -0
- package/dist/templates/support-line/prompts.ts +95 -0
- package/dist/templates/support-line/shared.ts +240 -0
- package/dist/templates/support-line/system-prompt.md +17 -0
- package/dist/templates/support-line/tools/answer_question.ts +72 -0
- package/dist/templates/support-line/tools/list_topics.ts +22 -0
- package/dist/templates/support-line/tools/log_ticket.ts +30 -0
- package/dist/templates/transcription-workflow/agent.test.ts +563 -0
- package/dist/templates/transcription-workflow/agent.ts +92 -0
- package/dist/templates/transcription-workflow/client.tsx +234 -0
- package/dist/templates/transcription-workflow/workflows/transcribe.ts +416 -0
- package/dist/templates/transcription-workflow/workflows/wav.ts +314 -0
- package/dist/templates/travel-concierge/agent.test.ts +338 -0
- package/dist/templates/travel-concierge/agent.ts +29 -0
- package/dist/templates/travel-concierge/client.tsx +161 -0
- package/dist/templates/travel-concierge/routing.ts +138 -0
- package/dist/templates/travel-concierge/shared.ts +547 -0
- package/dist/templates/travel-concierge/system-prompt.md +24 -0
- package/dist/templates/travel-concierge/tools/book_car_rental.ts +20 -0
- package/dist/templates/travel-concierge/tools/book_excursion.ts +18 -0
- package/dist/templates/travel-concierge/tools/book_hotel.ts +20 -0
- package/dist/templates/travel-concierge/tools/cancel_action.ts +7 -0
- package/dist/templates/travel-concierge/tools/cancel_ticket.ts +16 -0
- package/dist/templates/travel-concierge/tools/complete_or_escalate.ts +7 -0
- package/dist/templates/travel-concierge/tools/confirm_action.ts +7 -0
- package/dist/templates/travel-concierge/tools/lookup_booking.ts +35 -0
- package/dist/templates/travel-concierge/tools/search_car_rentals.ts +33 -0
- package/dist/templates/travel-concierge/tools/search_excursions.ts +37 -0
- package/dist/templates/travel-concierge/tools/search_flights.ts +43 -0
- package/dist/templates/travel-concierge/tools/search_hotels.ts +36 -0
- package/dist/templates/travel-concierge/tools/to_car_rental_assistant.ts +11 -0
- package/dist/templates/travel-concierge/tools/to_excursion_assistant.ts +11 -0
- package/dist/templates/travel-concierge/tools/to_flight_assistant.ts +11 -0
- package/dist/templates/travel-concierge/tools/to_hotel_assistant.ts +11 -0
- package/dist/templates/travel-concierge/tools/update_ticket.ts +22 -0
- package/dist/templates/web-researcher/agent.ts +0 -2
- package/dist/templates/web-researcher/system-prompt.md +10 -0
- package/dist/{test-2LWBcXvY.mjs → test-B6ZBxSpk.mjs} +2 -2
- package/dist/typecheck.mjs +17 -15
- package/dist/worker-bundler-CIdDhZ0c.mjs +398 -0
- package/dist/worker-bundler.d.ts +14 -0
- package/dist/worker-bundler.mjs +1 -108
- package/dist/workflow-B-O97AqI.mjs +125 -0
- package/dist/workflow-bundler.d.ts +133 -0
- package/dist/workflow.d.ts +67 -0
- package/package.json +13 -9
- package/dist/build-DQJ1ZSm9.mjs +0 -39
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { t as getMonorepoRoot } from "./_agent-
|
|
2
|
+
import { o as errorMessage$1 } from "./_utils-B8QmtFhK.mjs";
|
|
3
|
+
import { t as getMonorepoRoot } from "./_agent-vGW5SBnX.mjs";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
|
+
import { isRecord } from "@alexkroman1/aai/utils";
|
|
6
7
|
import fs from "node:fs/promises";
|
|
7
8
|
const REPO_URL = `https://github.com/alexkroman/agent`;
|
|
8
9
|
/**
|
|
@@ -42,7 +43,7 @@ async function listTemplates(root = resolveTemplatesDir()) {
|
|
|
42
43
|
try {
|
|
43
44
|
available = await fs.readdir(templatesDir, { withFileTypes: true });
|
|
44
45
|
} catch (err) {
|
|
45
|
-
throw new Error(`Templates directory is missing or unreadable at ${templatesDir} (incomplete @alexkroman1/aai-cli install?): ${errorMessage(err)}`, { cause: err });
|
|
46
|
+
throw new Error(`Templates directory is missing or unreadable at ${templatesDir} (incomplete @alexkroman1/aai-cli install?): ${errorMessage$1(err)}`, { cause: err });
|
|
46
47
|
}
|
|
47
48
|
return available.filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
48
49
|
}
|
|
@@ -52,9 +53,6 @@ const MERGED_MANIFEST_FIELDS = [
|
|
|
52
53
|
"devDependencies",
|
|
53
54
|
"scripts"
|
|
54
55
|
];
|
|
55
|
-
function isRecord(value) {
|
|
56
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
57
|
-
}
|
|
58
56
|
/**
|
|
59
57
|
* Fill a manifest's gaps from the scaffold's, `existing` always winning.
|
|
60
58
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import fs from "node:fs/promises";
|
|
5
4
|
import { errorDetail, errorMessage, errorMessage as errorMessage$1, omitUndefined } from "@alexkroman1/aai/utils";
|
|
5
|
+
import fs from "node:fs/promises";
|
|
6
6
|
//#region _utils.ts
|
|
7
7
|
/**
|
|
8
8
|
* The file that marks a directory as an agent project — the single source
|
|
@@ -26,15 +26,29 @@ function validateAgentExport(mod) {
|
|
|
26
26
|
if (!mod?.name || typeof mod.name !== "string") throw new Error("agent.ts must export default agent({ name: ... })");
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
29
|
+
* Read and parse a package.json SYNCHRONOUSLY.
|
|
30
|
+
*
|
|
31
|
+
* Separate from {@link binFromPackageJson} so a caller that needs two fields
|
|
32
|
+
* pays for one read and one parse. `resolveTsc` needed exactly that: it read
|
|
33
|
+
* the TypeScript manifest for the bin and then again for the version, on a
|
|
34
|
+
* path that runs after every settled write burst in the studio.
|
|
35
|
+
*/
|
|
36
|
+
function readPackageJson(pkgJsonPath) {
|
|
37
|
+
return JSON.parse(readFileSync(pkgJsonPath, "utf-8"));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Absolute path of `binName`'s script declared by `manifest`, which was read
|
|
41
|
+
* from `pkgJsonPath` — or undefined when the package declares no such bin.
|
|
31
42
|
* Handles both `"bin": "script.js"` and `"bin": { name: "script.js" }`.
|
|
32
43
|
*/
|
|
33
|
-
function
|
|
34
|
-
const
|
|
35
|
-
const bin = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.[binName];
|
|
44
|
+
function binFromManifest(pkgJsonPath, manifest, binName) {
|
|
45
|
+
const bin = typeof manifest.bin === "string" ? manifest.bin : manifest.bin?.[binName];
|
|
36
46
|
return bin ? path.join(path.dirname(pkgJsonPath), bin) : void 0;
|
|
37
47
|
}
|
|
48
|
+
/** {@link binFromManifest} for a caller that needs nothing else from the file. */
|
|
49
|
+
function binFromPackageJson(pkgJsonPath, binName) {
|
|
50
|
+
return binFromManifest(pkgJsonPath, readPackageJson(pkgJsonPath), binName);
|
|
51
|
+
}
|
|
38
52
|
async function fileExists(p) {
|
|
39
53
|
try {
|
|
40
54
|
await fs.access(p);
|
|
@@ -102,4 +116,4 @@ async function writeJson(filePath, data, opts = {}) {
|
|
|
102
116
|
}
|
|
103
117
|
}
|
|
104
118
|
//#endregion
|
|
105
|
-
export {
|
|
119
|
+
export { errorDetail as a, isEexist as c, resolveCwd as d, validateAgentExport as f, errorCode as i, readJson as l, binFromManifest as n, errorMessage$1 as o, writeJson as p, binFromPackageJson as r, fileExists as s, AGENT_ENTRY as t, readPackageJson as u };
|
package/dist/_utils.d.ts
CHANGED
|
@@ -12,11 +12,27 @@ export declare function errorCode(err: unknown): string | undefined;
|
|
|
12
12
|
export declare function isEexist(err: unknown): boolean;
|
|
13
13
|
/** Validate that a module's default export is a valid agent definition. Throws if invalid. */
|
|
14
14
|
export declare function validateAgentExport(mod: any): void;
|
|
15
|
+
/** The fields of an installed package's manifest that this CLI reads. */
|
|
16
|
+
export type PackageManifest = {
|
|
17
|
+
bin?: string | Record<string, string>;
|
|
18
|
+
version?: string;
|
|
19
|
+
};
|
|
15
20
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
21
|
+
* Read and parse a package.json SYNCHRONOUSLY.
|
|
22
|
+
*
|
|
23
|
+
* Separate from {@link binFromPackageJson} so a caller that needs two fields
|
|
24
|
+
* pays for one read and one parse. `resolveTsc` needed exactly that: it read
|
|
25
|
+
* the TypeScript manifest for the bin and then again for the version, on a
|
|
26
|
+
* path that runs after every settled write burst in the studio.
|
|
27
|
+
*/
|
|
28
|
+
export declare function readPackageJson(pkgJsonPath: string): PackageManifest;
|
|
29
|
+
/**
|
|
30
|
+
* Absolute path of `binName`'s script declared by `manifest`, which was read
|
|
31
|
+
* from `pkgJsonPath` — or undefined when the package declares no such bin.
|
|
18
32
|
* Handles both `"bin": "script.js"` and `"bin": { name: "script.js" }`.
|
|
19
33
|
*/
|
|
34
|
+
export declare function binFromManifest(pkgJsonPath: string, manifest: PackageManifest, binName: string): string | undefined;
|
|
35
|
+
/** {@link binFromManifest} for a caller that needs nothing else from the file. */
|
|
20
36
|
export declare function binFromPackageJson(pkgJsonPath: string, binName: string): string | undefined;
|
|
21
37
|
export declare function fileExists(p: string): Promise<boolean>;
|
|
22
38
|
/**
|
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
//#region _vite-env.ts
|
|
3
3
|
/**
|
|
4
|
+
* Packages resolved from the project root rather than from whichever
|
|
5
|
+
* `node_modules` happens to sit above the importing file.
|
|
6
|
+
*
|
|
7
|
+
* `@alexkroman1/aai-ui` declares React as a **peer** dependency — "my consumer
|
|
8
|
+
* supplies it" — but a bundler resolves the bare `react/jsx-runtime` import
|
|
9
|
+
* inside `aai-ui/dist/**` from that file's own real path, not from the
|
|
10
|
+
* consumer's. Deduping states the peer contract in terms the bundler enforces.
|
|
11
|
+
*
|
|
12
|
+
* Both Vite entry points need it, for failures that look nothing alike:
|
|
13
|
+
*
|
|
14
|
+
* - `buildClient` (`client-bundler.ts`): the studio's build root is nowhere
|
|
15
|
+
* above `packages/aai-ui/dist`, and the production image installs prod deps
|
|
16
|
+
* only, so aai-ui's own devDependency copy of React is pruned there. Publish
|
|
17
|
+
* died with *"Rolldown failed to resolve import react/jsx-runtime"* while
|
|
18
|
+
* every local build passed.
|
|
19
|
+
* - `viteDevConfig` (`_dev-server.ts`): a project whose SDK is LINKED rather
|
|
20
|
+
* than installed — `aai init` run inside this monorepo, which is how a
|
|
21
|
+
* template gets tested by hand — resolves aai-ui's React through the
|
|
22
|
+
* workspace's own store, so the page loads two physically distinct copies of
|
|
23
|
+
* the same version. Two Reacts break hooks: `useSession`/`useWorkflowRun`
|
|
24
|
+
* throw *"Invalid hook call"*, `<ThemeProvider>` unmounts, and the agent
|
|
25
|
+
* renders a BLANK PAGE whose console never names a package.
|
|
26
|
+
*
|
|
27
|
+
* An npm-installed project is unaffected either way, which is precisely why
|
|
28
|
+
* this stayed invisible: the resolution is correct until the SDK is linked or
|
|
29
|
+
* the tree is pruned. Guarded by `client-bundler.test.ts` (asserted against
|
|
30
|
+
* aai-ui's own manifest, so a peer added there without being added here fails).
|
|
31
|
+
*/
|
|
32
|
+
const DEDUPED_PEERS = ["react", "react-dom"];
|
|
33
|
+
/**
|
|
4
34
|
* Run a Vite build without letting it mutate the calling process's env.
|
|
5
35
|
*
|
|
6
36
|
* Vite's `build()` sets `process.env.NODE_ENV = "production"` when NODE_ENV is
|
|
@@ -44,4 +74,4 @@ async function withPreservedNodeEnv(fn, env = process.env) {
|
|
|
44
74
|
}
|
|
45
75
|
}
|
|
46
76
|
//#endregion
|
|
47
|
-
export { withPreservedNodeEnv as t };
|
|
77
|
+
export { withPreservedNodeEnv as n, DEDUPED_PEERS as t };
|
package/dist/_vite-env.d.ts
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Packages resolved from the project root rather than from whichever
|
|
3
|
+
* `node_modules` happens to sit above the importing file.
|
|
4
|
+
*
|
|
5
|
+
* `@alexkroman1/aai-ui` declares React as a **peer** dependency — "my consumer
|
|
6
|
+
* supplies it" — but a bundler resolves the bare `react/jsx-runtime` import
|
|
7
|
+
* inside `aai-ui/dist/**` from that file's own real path, not from the
|
|
8
|
+
* consumer's. Deduping states the peer contract in terms the bundler enforces.
|
|
9
|
+
*
|
|
10
|
+
* Both Vite entry points need it, for failures that look nothing alike:
|
|
11
|
+
*
|
|
12
|
+
* - `buildClient` (`client-bundler.ts`): the studio's build root is nowhere
|
|
13
|
+
* above `packages/aai-ui/dist`, and the production image installs prod deps
|
|
14
|
+
* only, so aai-ui's own devDependency copy of React is pruned there. Publish
|
|
15
|
+
* died with *"Rolldown failed to resolve import react/jsx-runtime"* while
|
|
16
|
+
* every local build passed.
|
|
17
|
+
* - `viteDevConfig` (`_dev-server.ts`): a project whose SDK is LINKED rather
|
|
18
|
+
* than installed — `aai init` run inside this monorepo, which is how a
|
|
19
|
+
* template gets tested by hand — resolves aai-ui's React through the
|
|
20
|
+
* workspace's own store, so the page loads two physically distinct copies of
|
|
21
|
+
* the same version. Two Reacts break hooks: `useSession`/`useWorkflowRun`
|
|
22
|
+
* throw *"Invalid hook call"*, `<ThemeProvider>` unmounts, and the agent
|
|
23
|
+
* renders a BLANK PAGE whose console never names a package.
|
|
24
|
+
*
|
|
25
|
+
* An npm-installed project is unaffected either way, which is precisely why
|
|
26
|
+
* this stayed invisible: the resolution is correct until the SDK is linked or
|
|
27
|
+
* the tree is pruned. Guarded by `client-bundler.test.ts` (asserted against
|
|
28
|
+
* aai-ui's own manifest, so a peer added there without being added here fails).
|
|
29
|
+
*/
|
|
30
|
+
export declare const DEDUPED_PEERS: string[];
|
|
1
31
|
/**
|
|
2
32
|
* `env` is injectable for tests ONLY, so specs can exercise the
|
|
3
33
|
* snapshot/refcount logic on a plain object instead of mutating (and
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { a as ok, t as CliError } from "./_output-CKkmWs7i.mjs";
|
|
3
|
+
import { n as log } from "./_ui-u7T4YooX.mjs";
|
|
4
|
+
import { r as evalWorkerBundle, t as buildAgentBundle } from "./_bundler-BapCUUJN.mjs";
|
|
5
|
+
import { assertTypechecks } from "./_typecheck-gate-BXvUNnfs.mjs";
|
|
6
|
+
import { classifyVitestError, runVitest } from "./test-B6ZBxSpk.mjs";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import fs from "node:fs/promises";
|
|
9
|
+
//#region build.ts
|
|
10
|
+
/**
|
|
11
|
+
* `aai build` — bundle the agent without deploying, behind the same gates
|
|
12
|
+
* deploy runs (tests, then typecheck), so the command previews the deploy
|
|
13
|
+
* artifact and its failures alike.
|
|
14
|
+
*
|
|
15
|
+
* It also LEAVES that artifact on disk, at {@link WORKER_ARTIFACT_REL}, which is
|
|
16
|
+
* what makes self-hosting work: `server.mjs` loads the built worker rather than
|
|
17
|
+
* `agent.ts`, because a tool is discovered by the bundler enumerating `tools/`
|
|
18
|
+
* and no un-bundled loader can see that directory. See the scaffold's own
|
|
19
|
+
* `server.mjs` and "Self-hosting runs the built worker" in
|
|
20
|
+
* `packages/aai-templates/CLAUDE.md`.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Where the built worker lands, relative to the project root — under `.aai/`,
|
|
24
|
+
* beside the built client, so one gitignore rule covers every build output.
|
|
25
|
+
*
|
|
26
|
+
* `server.mjs` hardcodes this path: it is a plain `.mjs` file in a user's
|
|
27
|
+
* project and may not import from the CLI (which a deployed project does not
|
|
28
|
+
* install at all). The pair is covered end-to-end by the `npm start` leg of
|
|
29
|
+
* `e2e.test.ts` — the only tier that runs both halves as a user does.
|
|
30
|
+
*/
|
|
31
|
+
const WORKER_ARTIFACT_REL = path.join(".aai", "worker.mjs");
|
|
32
|
+
/**
|
|
33
|
+
* Map a {@link runVitest} failure to a CliError — distinguishing a real test
|
|
34
|
+
* failure (test_failed) from the runner not spawning (spawn_failed) instead
|
|
35
|
+
* of a generic command_failed.
|
|
36
|
+
*/
|
|
37
|
+
function testGateError(err) {
|
|
38
|
+
const { code, message } = classifyVitestError(err);
|
|
39
|
+
return new CliError(code, message, "Re-run with --skipTests to build without tests", { cause: err });
|
|
40
|
+
}
|
|
41
|
+
async function executeBuild(opts) {
|
|
42
|
+
const { cwd } = opts;
|
|
43
|
+
if (!opts.skipTests) try {
|
|
44
|
+
runVitest(cwd);
|
|
45
|
+
} catch (err) {
|
|
46
|
+
throw testGateError(err);
|
|
47
|
+
}
|
|
48
|
+
if (!opts.skipTypecheck) await assertTypechecks(cwd);
|
|
49
|
+
const bundle = await buildAgentBundle(cwd, { minify: true });
|
|
50
|
+
const agentDef = await evalWorkerBundle(bundle.worker);
|
|
51
|
+
const worker = path.join(cwd, WORKER_ARTIFACT_REL);
|
|
52
|
+
await fs.mkdir(path.dirname(worker), { recursive: true });
|
|
53
|
+
await fs.writeFile(worker, bundle.worker, "utf-8");
|
|
54
|
+
log.success("Build complete");
|
|
55
|
+
return ok({
|
|
56
|
+
name: agentDef.name,
|
|
57
|
+
workerBytes: bundle.worker.length,
|
|
58
|
+
worker
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { executeBuild };
|
package/dist/build.d.ts
CHANGED
|
@@ -2,11 +2,30 @@
|
|
|
2
2
|
* `aai build` — bundle the agent without deploying, behind the same gates
|
|
3
3
|
* deploy runs (tests, then typecheck), so the command previews the deploy
|
|
4
4
|
* artifact and its failures alike.
|
|
5
|
+
*
|
|
6
|
+
* It also LEAVES that artifact on disk, at {@link WORKER_ARTIFACT_REL}, which is
|
|
7
|
+
* what makes self-hosting work: `server.mjs` loads the built worker rather than
|
|
8
|
+
* `agent.ts`, because a tool is discovered by the bundler enumerating `tools/`
|
|
9
|
+
* and no un-bundled loader can see that directory. See the scaffold's own
|
|
10
|
+
* `server.mjs` and "Self-hosting runs the built worker" in
|
|
11
|
+
* `packages/aai-templates/CLAUDE.md`.
|
|
5
12
|
*/
|
|
6
13
|
import { type CommandResult } from "./_output.ts";
|
|
14
|
+
/**
|
|
15
|
+
* Where the built worker lands, relative to the project root — under `.aai/`,
|
|
16
|
+
* beside the built client, so one gitignore rule covers every build output.
|
|
17
|
+
*
|
|
18
|
+
* `server.mjs` hardcodes this path: it is a plain `.mjs` file in a user's
|
|
19
|
+
* project and may not import from the CLI (which a deployed project does not
|
|
20
|
+
* install at all). The pair is covered end-to-end by the `npm start` leg of
|
|
21
|
+
* `e2e.test.ts` — the only tier that runs both halves as a user does.
|
|
22
|
+
*/
|
|
23
|
+
export declare const WORKER_ARTIFACT_REL: string;
|
|
7
24
|
type BuildData = {
|
|
8
25
|
name: string;
|
|
9
26
|
workerBytes: number;
|
|
27
|
+
/** Absolute path of the worker written — what `npm start` boots. */
|
|
28
|
+
worker: string;
|
|
10
29
|
};
|
|
11
30
|
export declare function executeBuild(opts: {
|
|
12
31
|
cwd: string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `aai workflow` subcommand group.
|
|
3
|
+
*
|
|
4
|
+
* Its own module because `cli.ts` is near the 500-line cap and this is the
|
|
5
|
+
* natural seam: four verbs over one surface, none of which shares anything with
|
|
6
|
+
* the deploy/secret/storage commands beyond `sharedArgs`. The executors are in
|
|
7
|
+
* `workflow.ts` and are imported lazily, exactly as every other command here
|
|
8
|
+
* does it — the CLI's startup path must not pay for a group nobody invoked.
|
|
9
|
+
*/
|
|
10
|
+
export declare const workflow: import("citty").CommandDef<import("citty").ArgsDef>;
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const mainCommand: CommandDef<ArgsDef>;
|
|
1
|
+
export declare const mainCommand: import("citty").CommandDef<import("citty").ArgsDef>;
|