@alexkroman1/aai-cli 5.13.2 → 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 +32 -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 +21 -30
- package/dist/templates/dispatch-center/agent.ts +4 -31
- package/dist/templates/dispatch-center/client.tsx +41 -28
- package/dist/templates/dispatch-center/shared.ts +73 -66
- package/dist/templates/dispatch-center/tools/incident_add_note.ts +13 -15
- package/dist/templates/dispatch-center/tools/incident_create.ts +42 -45
- package/dist/templates/dispatch-center/tools/incident_escalate.ts +60 -62
- package/dist/templates/dispatch-center/tools/incident_get.ts +10 -6
- package/dist/templates/dispatch-center/tools/incident_triage.ts +44 -46
- package/dist/templates/dispatch-center/tools/incident_update_status.ts +40 -42
- package/dist/templates/dispatch-center/tools/ops_dashboard.ts +3 -6
- package/dist/templates/dispatch-center/tools/ops_protocols.ts +1 -1
- package/dist/templates/dispatch-center/tools/ops_run_scenario.ts +21 -24
- package/dist/templates/dispatch-center/tools/resources_dispatch.ts +53 -55
- package/dist/templates/dispatch-center/tools/resources_get_available.ts +3 -5
- package/dist/templates/dispatch-center/tools/resources_update_status.ts +40 -43
- 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 +32 -28
- package/dist/templates/infocom-adventure/shared.ts +36 -16
- 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 +59 -58
- package/dist/templates/pizza-ordering/agent.ts +10 -159
- package/dist/templates/pizza-ordering/client.tsx +4 -4
- package/dist/templates/pizza-ordering/shared.ts +44 -27
- 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 +319 -256
- package/dist/templates/retail/agent.ts +6 -46
- package/dist/templates/retail/authenticate.ts +2 -2
- package/dist/templates/retail/client.tsx +45 -24
- package/dist/templates/retail/registry.test.ts +40 -25
- package/dist/templates/retail/resolve.test.ts +17 -16
- package/dist/templates/retail/resolve.ts +32 -67
- package/dist/templates/retail/shared.test.ts +21 -19
- package/dist/templates/retail/shared.ts +61 -23
- package/dist/templates/retail/store.test.ts +47 -52
- package/dist/templates/retail/store.ts +92 -79
- package/dist/templates/retail/swap.test.ts +20 -17
- package/dist/templates/retail/swap.ts +7 -14
- package/dist/templates/retail/tools/cancel_pending_order.ts +7 -11
- package/dist/templates/retail/tools/exchange_delivered_order_items.ts +26 -14
- 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 +7 -8
- package/dist/templates/retail/tools/get_order_details.ts +7 -8
- package/dist/templates/retail/tools/get_product_details.ts +6 -8
- package/dist/templates/retail/tools/get_user_details.ts +6 -8
- package/dist/templates/retail/tools/list_all_product_types.ts +5 -7
- package/dist/templates/retail/tools/modify_pending_order_address.ts +6 -10
- package/dist/templates/retail/tools/modify_pending_order_items.ts +8 -20
- package/dist/templates/retail/tools/modify_pending_order_payment.ts +7 -13
- package/dist/templates/retail/tools/modify_user_address.ts +6 -10
- package/dist/templates/retail/tools/return_delivered_order_items.ts +7 -13
- package/dist/templates/retail/tools/transfer_to_human_agents.ts +1 -1
- package/dist/templates/solo-rpg/agent.test.ts +169 -54
- package/dist/templates/solo-rpg/agent.ts +4 -22
- package/dist/templates/solo-rpg/client.tsx +19 -6
- package/dist/templates/solo-rpg/shared.ts +20 -20
- package/dist/templates/solo-rpg/tools/action_roll.ts +3 -5
- package/dist/templates/solo-rpg/tools/burn_momentum.ts +3 -5
- package/dist/templates/solo-rpg/tools/check_state.ts +7 -7
- package/dist/templates/solo-rpg/tools/load_game.ts +3 -3
- package/dist/templates/solo-rpg/tools/oracle.ts +19 -12
- package/dist/templates/solo-rpg/tools/save_game.ts +11 -8
- package/dist/templates/solo-rpg/tools/setup_character.ts +3 -3
- package/dist/templates/solo-rpg/tools/update_state.ts +13 -13
- 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,7 +1,8 @@
|
|
|
1
|
+
import { isToolFailure } from "@alexkroman1/aai";
|
|
1
2
|
import { z } from "zod";
|
|
2
|
-
import { findItem,
|
|
3
|
+
import { findItem, retailTool } from "../store.ts";
|
|
3
4
|
|
|
4
|
-
export
|
|
5
|
+
export default retailTool({
|
|
5
6
|
name: "get_item_details",
|
|
6
7
|
description:
|
|
7
8
|
"Get one specific item's options, price and availability. Takes an ITEM id, which is not the " +
|
|
@@ -10,11 +11,9 @@ export const getItemDetails = retailTool({
|
|
|
10
11
|
item_id: z.string().max(60).describe("The item id, e.g. '1008292230'"),
|
|
11
12
|
}),
|
|
12
13
|
requiresAuth: false,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const found = findItem(getState(ctx), args.item_id);
|
|
17
|
-
if (isError(found)) return found;
|
|
14
|
+
execute: (args, state) => {
|
|
15
|
+
const found = findItem(state, args.item_id);
|
|
16
|
+
if (isToolFailure(found)) return found;
|
|
18
17
|
return {
|
|
19
18
|
item_id: found.variant.item_id,
|
|
20
19
|
product_id: found.product.product_id,
|
|
@@ -25,5 +24,5 @@ export const getItemDetails = retailTool({
|
|
|
25
24
|
};
|
|
26
25
|
},
|
|
27
26
|
summary: (_args, result) =>
|
|
28
|
-
|
|
27
|
+
isToolFailure(result) ? "item read failed" : `read item ${result.item_id}`,
|
|
29
28
|
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { isToolFailure } from "@alexkroman1/aai";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import { resolveOrder } from "../resolve.ts";
|
|
3
|
-
import {
|
|
4
|
+
import { retailTool, setFocus } from "../store.ts";
|
|
4
5
|
|
|
5
|
-
export
|
|
6
|
+
export default retailTool({
|
|
6
7
|
name: "get_order_details",
|
|
7
8
|
description:
|
|
8
9
|
"Get the status and full details of one of the authenticated customer's orders. Accepts the " +
|
|
@@ -14,12 +15,9 @@ export const getOrderDetails = retailTool({
|
|
|
14
15
|
.max(120)
|
|
15
16
|
.describe("Order id such as '#W0000000', or a spoken reference to one of their orders"),
|
|
16
17
|
}),
|
|
17
|
-
|
|
18
|
-
// is load-bearing for the generic `result` type in `summary`.
|
|
19
|
-
execute: (args, ctx) => {
|
|
20
|
-
const state = getState(ctx);
|
|
18
|
+
execute: (args, state) => {
|
|
21
19
|
const order = resolveOrder(state, args.order_id);
|
|
22
|
-
if (
|
|
20
|
+
if (isToolFailure(order)) return order;
|
|
23
21
|
setFocus(state, { orderId: order.order_id });
|
|
24
22
|
return {
|
|
25
23
|
order_id: order.order_id,
|
|
@@ -37,5 +35,6 @@ export const getOrderDetails = retailTool({
|
|
|
37
35
|
...(order.cancel_reason ? { cancel_reason: order.cancel_reason } : {}),
|
|
38
36
|
};
|
|
39
37
|
},
|
|
40
|
-
summary: (_args, result) =>
|
|
38
|
+
summary: (_args, result) =>
|
|
39
|
+
isToolFailure(result) ? "order read failed" : `read ${result.order_id}`,
|
|
41
40
|
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { isToolFailure } from "@alexkroman1/aai";
|
|
1
2
|
import { z } from "zod";
|
|
2
|
-
import { findProduct,
|
|
3
|
+
import { findProduct, retailTool, setFocus } from "../store.ts";
|
|
3
4
|
|
|
4
|
-
export
|
|
5
|
+
export default retailTool({
|
|
5
6
|
name: "get_product_details",
|
|
6
7
|
description:
|
|
7
8
|
"Get a product's variants — each with its item id, options, price and availability. Takes a " +
|
|
@@ -10,12 +11,9 @@ export const getProductDetails = retailTool({
|
|
|
10
11
|
product_id: z.string().max(60).describe("The product id, e.g. '6086499569'"),
|
|
11
12
|
}),
|
|
12
13
|
requiresAuth: false,
|
|
13
|
-
|
|
14
|
-
// is load-bearing for the generic `result` type in `summary`.
|
|
15
|
-
execute: (args, ctx) => {
|
|
16
|
-
const state = getState(ctx);
|
|
14
|
+
execute: (args, state) => {
|
|
17
15
|
const product = findProduct(state, args.product_id);
|
|
18
|
-
if (
|
|
16
|
+
if (isToolFailure(product)) return product;
|
|
19
17
|
setFocus(state, { productId: product.product_id });
|
|
20
18
|
return {
|
|
21
19
|
name: product.name,
|
|
@@ -29,5 +27,5 @@ export const getProductDetails = retailTool({
|
|
|
29
27
|
};
|
|
30
28
|
},
|
|
31
29
|
summary: (_args, result) =>
|
|
32
|
-
|
|
30
|
+
isToolFailure(result) ? "product read failed" : `read product ${result.name}`,
|
|
33
31
|
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { isToolFailure } from "@alexkroman1/aai";
|
|
1
2
|
import { z } from "zod";
|
|
2
|
-
import { authenticatedUser,
|
|
3
|
+
import { authenticatedUser, retailTool } from "../store.ts";
|
|
3
4
|
|
|
4
|
-
export
|
|
5
|
+
export default retailTool({
|
|
5
6
|
name: "get_user_details",
|
|
6
7
|
description:
|
|
7
8
|
"Get the authenticated customer's profile: name, email, default address, payment methods " +
|
|
@@ -9,12 +10,9 @@ export const getUserDetails = retailTool({
|
|
|
9
10
|
inputSchema: z.object({
|
|
10
11
|
user_id: z.string().max(100).describe("The user id, e.g. 'sara_doe_496'"),
|
|
11
12
|
}),
|
|
12
|
-
|
|
13
|
-
// is load-bearing for the generic `result` type in `summary`.
|
|
14
|
-
execute: (args, ctx) => {
|
|
15
|
-
const state = getState(ctx);
|
|
13
|
+
execute: (args, state) => {
|
|
16
14
|
const user = authenticatedUser(state);
|
|
17
|
-
if (
|
|
15
|
+
if (isToolFailure(user)) return user;
|
|
18
16
|
if (user.user_id !== args.user_id) {
|
|
19
17
|
return {
|
|
20
18
|
error: `${args.user_id} is not the customer on this call. You can help only one customer per conversation.`,
|
|
@@ -40,5 +38,5 @@ export const getUserDetails = retailTool({
|
|
|
40
38
|
};
|
|
41
39
|
},
|
|
42
40
|
summary: (_args, result) =>
|
|
43
|
-
|
|
41
|
+
isToolFailure(result) ? "profile read failed" : `read profile ${result.user_id}`,
|
|
44
42
|
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { isToolFailure } from "@alexkroman1/aai";
|
|
1
2
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
+
import { retailTool } from "../store.ts";
|
|
3
4
|
|
|
4
|
-
export
|
|
5
|
+
export default retailTool({
|
|
5
6
|
name: "list_all_product_types",
|
|
6
7
|
description:
|
|
7
8
|
"List every product type the store carries, as a name-to-product-id map. Each product type " +
|
|
@@ -10,15 +11,12 @@ export const listAllProductTypes = retailTool({
|
|
|
10
11
|
// that is where the per-call UI-update invariant lives.
|
|
11
12
|
inputSchema: z.object({}),
|
|
12
13
|
requiresAuth: false,
|
|
13
|
-
|
|
14
|
-
// is load-bearing for the generic `result` type in `summary`.
|
|
15
|
-
execute: (_args, ctx) => {
|
|
16
|
-
const state = getState(ctx);
|
|
14
|
+
execute: (_args, state) => {
|
|
17
15
|
const entries = Object.values(state.store.products)
|
|
18
16
|
.map((product) => [product.name, product.product_id] as const)
|
|
19
17
|
.sort(([a], [b]) => a.localeCompare(b));
|
|
20
18
|
return { count: entries.length, products: Object.fromEntries(entries) };
|
|
21
19
|
},
|
|
22
20
|
summary: (_args, result) =>
|
|
23
|
-
|
|
21
|
+
isToolFailure(result) ? "catalog read failed" : `listed ${result.count} product types`,
|
|
24
22
|
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { isToolFailure } from "@alexkroman1/aai";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import { AddressFields, formatAddress, toAddress } from "../address.ts";
|
|
3
4
|
import { resolveOrder } from "../resolve.ts";
|
|
4
|
-
import {
|
|
5
|
+
import { retailTool, setFocus } from "../store.ts";
|
|
5
6
|
|
|
6
|
-
export
|
|
7
|
+
export default retailTool({
|
|
7
8
|
name: "modify_pending_order_address",
|
|
8
9
|
description:
|
|
9
10
|
"Change the shipping address of a pending order. Read the new address back to the caller and " +
|
|
@@ -15,14 +16,9 @@ export const modifyPendingOrderAddress = retailTool({
|
|
|
15
16
|
.describe("Order id such as '#W0000000', or a spoken reference to one of their orders"),
|
|
16
17
|
...AddressFields,
|
|
17
18
|
}),
|
|
18
|
-
|
|
19
|
-
// `execute`'s return type, and processes object literal properties in
|
|
20
|
-
// source order — with `summary` first, `result` in its signature can't be
|
|
21
|
-
// inferred and silently falls back to `unknown`.
|
|
22
|
-
execute: (args, ctx) => {
|
|
23
|
-
const state = getState(ctx);
|
|
19
|
+
execute: (args, state) => {
|
|
24
20
|
const order = resolveOrder(state, args.order_id);
|
|
25
|
-
if (
|
|
21
|
+
if (isToolFailure(order)) return order;
|
|
26
22
|
setFocus(state, { orderId: order.order_id });
|
|
27
23
|
|
|
28
24
|
// Any pending variant is fine here — unlike cancel and modify-items, which
|
|
@@ -42,5 +38,5 @@ export const modifyPendingOrderAddress = retailTool({
|
|
|
42
38
|
};
|
|
43
39
|
},
|
|
44
40
|
summary: (_args, result) =>
|
|
45
|
-
|
|
41
|
+
isToolFailure(result) ? "address change failed" : `re-addressed ${result.order_id}`,
|
|
46
42
|
});
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
+
import { isToolFailure } from "@alexkroman1/aai";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import { resolveOrder } from "../resolve.ts";
|
|
3
|
-
import {
|
|
4
|
-
authenticatedUser,
|
|
5
|
-
getState,
|
|
6
|
-
isError,
|
|
7
|
-
isGiftCard,
|
|
8
|
-
money,
|
|
9
|
-
retailTool,
|
|
10
|
-
setFocus,
|
|
11
|
-
} from "../store.ts";
|
|
4
|
+
import { authenticatedUser, isGiftCard, money, retailTool, setFocus } from "../store.ts";
|
|
12
5
|
import { applySwap, assertCanCoverDiff, planItemSwap } from "../swap.ts";
|
|
13
6
|
|
|
14
|
-
export
|
|
7
|
+
export default retailTool({
|
|
15
8
|
name: "modify_pending_order_items",
|
|
16
9
|
description:
|
|
17
10
|
"Change items in a pending order to different options of the SAME products. This can be done " +
|
|
@@ -37,17 +30,12 @@ export const modifyPendingOrderItems = retailTool({
|
|
|
37
30
|
.max(80)
|
|
38
31
|
.describe("Method to charge or refund the price difference, e.g. 'gift_card_0000000'"),
|
|
39
32
|
}),
|
|
40
|
-
|
|
41
|
-
// `execute`'s return type, and processes object literal properties in
|
|
42
|
-
// source order — with `summary` first, `result` in its signature can't be
|
|
43
|
-
// inferred and silently falls back to `unknown`.
|
|
44
|
-
execute: (args, ctx) => {
|
|
45
|
-
const state = getState(ctx);
|
|
33
|
+
execute: (args, state) => {
|
|
46
34
|
const user = authenticatedUser(state);
|
|
47
|
-
if (
|
|
35
|
+
if (isToolFailure(user)) return user;
|
|
48
36
|
|
|
49
37
|
const order = resolveOrder(state, args.order_id);
|
|
50
|
-
if (
|
|
38
|
+
if (isToolFailure(order)) return order;
|
|
51
39
|
setFocus(state, { orderId: order.order_id });
|
|
52
40
|
|
|
53
41
|
// Exactly 'pending'. A 'pending (item modified)' order has already used its
|
|
@@ -61,7 +49,7 @@ export const modifyPendingOrderItems = retailTool({
|
|
|
61
49
|
const plan = planItemSwap(state, order, args.item_ids, args.new_item_ids, {
|
|
62
50
|
requireDifferent: true,
|
|
63
51
|
});
|
|
64
|
-
if (
|
|
52
|
+
if (isToolFailure(plan)) return plan;
|
|
65
53
|
|
|
66
54
|
const blocked = assertCanCoverDiff(user, args.payment_method_id, plan.diff);
|
|
67
55
|
if (blocked) return blocked;
|
|
@@ -96,7 +84,7 @@ export const modifyPendingOrderItems = retailTool({
|
|
|
96
84
|
};
|
|
97
85
|
},
|
|
98
86
|
summary: (_args, result) =>
|
|
99
|
-
|
|
87
|
+
isToolFailure(result)
|
|
100
88
|
? "item change failed"
|
|
101
89
|
: `modified ${result.order_id} (${result.price_difference >= 0 ? "+" : ""}${result.price_difference})`,
|
|
102
90
|
});
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
+
import { isToolFailure } from "@alexkroman1/aai";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import { resolveOrder } from "../resolve.ts";
|
|
3
4
|
import {
|
|
4
5
|
authenticatedUser,
|
|
5
6
|
findPaymentMethod,
|
|
6
|
-
getState,
|
|
7
|
-
isError,
|
|
8
7
|
isGiftCard,
|
|
9
8
|
money,
|
|
10
9
|
retailTool,
|
|
11
10
|
setFocus,
|
|
12
11
|
} from "../store.ts";
|
|
13
12
|
|
|
14
|
-
export
|
|
13
|
+
export default retailTool({
|
|
15
14
|
name: "modify_pending_order_payment",
|
|
16
15
|
description:
|
|
17
16
|
"Change which payment method a pending order is charged to. The new method must be different " +
|
|
@@ -27,17 +26,12 @@ export const modifyPendingOrderPayment = retailTool({
|
|
|
27
26
|
.max(80)
|
|
28
27
|
.describe("The new payment method id, e.g. 'gift_card_0000000'"),
|
|
29
28
|
}),
|
|
30
|
-
|
|
31
|
-
// `execute`'s return type, and processes object literal properties in
|
|
32
|
-
// source order — with `summary` first, `result` in its signature can't be
|
|
33
|
-
// inferred and silently falls back to `unknown`.
|
|
34
|
-
execute: (args, ctx) => {
|
|
35
|
-
const state = getState(ctx);
|
|
29
|
+
execute: (args, state) => {
|
|
36
30
|
const user = authenticatedUser(state);
|
|
37
|
-
if (
|
|
31
|
+
if (isToolFailure(user)) return user;
|
|
38
32
|
|
|
39
33
|
const order = resolveOrder(state, args.order_id);
|
|
40
|
-
if (
|
|
34
|
+
if (isToolFailure(order)) return order;
|
|
41
35
|
setFocus(state, { orderId: order.order_id });
|
|
42
36
|
|
|
43
37
|
if (!order.status.startsWith("pending")) {
|
|
@@ -47,7 +41,7 @@ export const modifyPendingOrderPayment = retailTool({
|
|
|
47
41
|
}
|
|
48
42
|
|
|
49
43
|
const newMethod = findPaymentMethod(user, args.payment_method_id);
|
|
50
|
-
if (
|
|
44
|
+
if (isToolFailure(newMethod)) return newMethod;
|
|
51
45
|
|
|
52
46
|
const original = order.payment_history[0];
|
|
53
47
|
if (order.payment_history.length !== 1 || original?.transaction_type !== "payment") {
|
|
@@ -99,5 +93,5 @@ export const modifyPendingOrderPayment = retailTool({
|
|
|
99
93
|
};
|
|
100
94
|
},
|
|
101
95
|
summary: (_args, result) =>
|
|
102
|
-
|
|
96
|
+
isToolFailure(result) ? "payment change failed" : `re-paid ${result.order_id}`,
|
|
103
97
|
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { isToolFailure } from "@alexkroman1/aai";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import { AddressFields, formatAddress, toAddress } from "../address.ts";
|
|
3
|
-
import { authenticatedUser,
|
|
4
|
+
import { authenticatedUser, retailTool } from "../store.ts";
|
|
4
5
|
|
|
5
|
-
export
|
|
6
|
+
export default retailTool({
|
|
6
7
|
name: "modify_user_address",
|
|
7
8
|
description:
|
|
8
9
|
"Change the customer's default address, used for future orders. Read the new address back and " +
|
|
@@ -12,14 +13,9 @@ export const modifyUserAddress = retailTool({
|
|
|
12
13
|
user_id: z.string().max(100).describe("The user id, e.g. 'sara_doe_496'"),
|
|
13
14
|
...AddressFields,
|
|
14
15
|
}),
|
|
15
|
-
|
|
16
|
-
// `execute`'s return type, and processes object literal properties in
|
|
17
|
-
// source order — with `summary` first, `result` in its signature can't be
|
|
18
|
-
// inferred and silently falls back to `unknown`.
|
|
19
|
-
execute: (args, ctx) => {
|
|
20
|
-
const state = getState(ctx);
|
|
16
|
+
execute: (args, state) => {
|
|
21
17
|
const user = authenticatedUser(state);
|
|
22
|
-
if (
|
|
18
|
+
if (isToolFailure(user)) return user;
|
|
23
19
|
if (user.user_id !== args.user_id) {
|
|
24
20
|
return {
|
|
25
21
|
error: `${args.user_id} is not the customer on this call. You can help only one customer per conversation.`,
|
|
@@ -34,5 +30,5 @@ export const modifyUserAddress = retailTool({
|
|
|
34
30
|
};
|
|
35
31
|
},
|
|
36
32
|
summary: (_args, result) =>
|
|
37
|
-
|
|
33
|
+
isToolFailure(result) ? "profile address change failed" : `re-addressed ${result.user_id}`,
|
|
38
34
|
});
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
+
import { isToolFailure } from "@alexkroman1/aai";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import { resolveOrder } from "../resolve.ts";
|
|
3
4
|
import {
|
|
4
5
|
authenticatedUser,
|
|
5
6
|
findPaymentMethod,
|
|
6
|
-
getState,
|
|
7
|
-
isError,
|
|
8
7
|
isGiftCard,
|
|
9
8
|
retailTool,
|
|
10
9
|
setFocus,
|
|
11
10
|
} from "../store.ts";
|
|
12
11
|
|
|
13
|
-
export
|
|
12
|
+
export default retailTool({
|
|
14
13
|
name: "return_delivered_order_items",
|
|
15
14
|
description:
|
|
16
15
|
"Request a return of items from a delivered order. Only a 'delivered' order can be returned, " +
|
|
@@ -32,17 +31,12 @@ export const returnDeliveredOrderItems = retailTool({
|
|
|
32
31
|
.max(80)
|
|
33
32
|
.describe("Where the refund goes — the original method, or one of their gift cards"),
|
|
34
33
|
}),
|
|
35
|
-
|
|
36
|
-
// `execute`'s return type, and processes object literal properties in
|
|
37
|
-
// source order — with `summary` first, `result` in its signature can't be
|
|
38
|
-
// inferred and silently falls back to `unknown`.
|
|
39
|
-
execute: (args, ctx) => {
|
|
40
|
-
const state = getState(ctx);
|
|
34
|
+
execute: (args, state) => {
|
|
41
35
|
const user = authenticatedUser(state);
|
|
42
|
-
if (
|
|
36
|
+
if (isToolFailure(user)) return user;
|
|
43
37
|
|
|
44
38
|
const order = resolveOrder(state, args.order_id);
|
|
45
|
-
if (
|
|
39
|
+
if (isToolFailure(order)) return order;
|
|
46
40
|
setFocus(state, { orderId: order.order_id });
|
|
47
41
|
|
|
48
42
|
if (order.status !== "delivered") {
|
|
@@ -52,7 +46,7 @@ export const returnDeliveredOrderItems = retailTool({
|
|
|
52
46
|
}
|
|
53
47
|
|
|
54
48
|
const method = findPaymentMethod(user, args.payment_method_id);
|
|
55
|
-
if (
|
|
49
|
+
if (isToolFailure(method)) return method;
|
|
56
50
|
|
|
57
51
|
const originalMethodId = order.payment_history[0]?.payment_method_id;
|
|
58
52
|
if (!isGiftCard(method) && args.payment_method_id !== originalMethodId) {
|
|
@@ -97,5 +91,5 @@ export const returnDeliveredOrderItems = retailTool({
|
|
|
97
91
|
};
|
|
98
92
|
},
|
|
99
93
|
summary: (_args, result) =>
|
|
100
|
-
|
|
94
|
+
isToolFailure(result) ? "return failed" : `return requested on ${result.order_id}`,
|
|
101
95
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { retailTool } from "../store.ts";
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export default retailTool({
|
|
5
5
|
name: "transfer_to_human_agents",
|
|
6
6
|
description:
|
|
7
7
|
"Hand the caller to a human agent. Use this ONLY when the caller explicitly asks for a human, " +
|