@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
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { tool } from "@alexkroman1/aai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { research } from "../shared.ts";
|
|
4
|
+
|
|
5
|
+
export default tool({
|
|
6
|
+
description: "Start researching a topic. Returns immediately; the work continues after the call.",
|
|
7
|
+
inputSchema: z.object({ topic: z.string().min(3) }),
|
|
8
|
+
execute: async ({ topic }, ctx) => {
|
|
9
|
+
// The definition, not the string "research": that types `topic` against
|
|
10
|
+
// the workflow's own schema. `key` is what `research_status` searches on.
|
|
11
|
+
const runId = await ctx.workflows.start(
|
|
12
|
+
research,
|
|
13
|
+
{ topic, requestedBy: ctx.sessionId },
|
|
14
|
+
{
|
|
15
|
+
key: ctx.sessionId,
|
|
16
|
+
// What makes "I'll let you know" true. The run finishes minutes
|
|
17
|
+
// later, with no turn to land in — so the SDK gives the agent one:
|
|
18
|
+
// when it settles, this session takes an unprompted turn built from
|
|
19
|
+
// the run's own output, and the caller hears the answer without
|
|
20
|
+
// having to think to ask again.
|
|
21
|
+
//
|
|
22
|
+
// The instruction is a sentence for the MODEL, not a line to read:
|
|
23
|
+
// it is the only thing that knows what this caller has already been
|
|
24
|
+
// told. Omit it (`notify: true`) for the SDK's default.
|
|
25
|
+
//
|
|
26
|
+
// `key` is still the durable handle: an announcement only reaches
|
|
27
|
+
// THIS call, and a run outlives it.
|
|
28
|
+
notify: "Tell them the research came back, then read the summary in one sentence.",
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
return { started: true, runId, topic };
|
|
32
|
+
},
|
|
33
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { tool } from "@alexkroman1/aai";
|
|
2
|
+
import { research } from "../shared.ts";
|
|
3
|
+
|
|
4
|
+
export default tool({
|
|
5
|
+
description: "Say what the research is doing right now, for a run that has not finished yet.",
|
|
6
|
+
execute: async (_args, ctx) => {
|
|
7
|
+
const [latest] = await ctx.workflows.find(research, ctx.sessionId, { limit: 1 });
|
|
8
|
+
if (!latest) return { note: "Nothing started yet." };
|
|
9
|
+
// `research_status` reports the run's STATUS; this reports what the run
|
|
10
|
+
// has WRITTEN (`getWritable()` in `workflows/research.ts`). Between "still
|
|
11
|
+
// working on it" and a finished summary there is otherwise nothing to say.
|
|
12
|
+
//
|
|
13
|
+
// `streamTail` FIRST, and not as an optimization: a progress channel is
|
|
14
|
+
// never closed — no step knows it is the last one — so reading a stream
|
|
15
|
+
// with nothing in it waits forever rather than ending. `-1` is "nothing
|
|
16
|
+
// written yet", and it is the only safe way to learn that.
|
|
17
|
+
if ((await ctx.workflows.streamTail(latest.runId)) < 0) {
|
|
18
|
+
return { note: "Started, nothing to report yet." };
|
|
19
|
+
}
|
|
20
|
+
// A negative `startIndex` reads from the END, which is what a voice reply
|
|
21
|
+
// wants — the last line, not a recital of the whole log.
|
|
22
|
+
const stream = await ctx.workflows.stream(latest.runId, { startIndex: -1 });
|
|
23
|
+
for await (const line of stream) return { progress: String(line) };
|
|
24
|
+
return { note: "Started, nothing to report yet." };
|
|
25
|
+
},
|
|
26
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isTerminal,
|
|
3
|
+
tool,
|
|
4
|
+
type WorkflowOutputOf,
|
|
5
|
+
type WorkflowRunSnapshot,
|
|
6
|
+
} from "@alexkroman1/aai";
|
|
7
|
+
import { research } from "../shared.ts";
|
|
8
|
+
|
|
9
|
+
/** How many past runs the status tool will look at. Newest first. */
|
|
10
|
+
const RECENT_RUNS = 3;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* One line a voice agent can read aloud about a run.
|
|
14
|
+
*
|
|
15
|
+
* `WorkflowOutputOf` is what names the output type — the same helper a page uses
|
|
16
|
+
* to type `run.output`, and the reason this signature does not have to reach
|
|
17
|
+
* past the declaration into the body's own return type.
|
|
18
|
+
*/
|
|
19
|
+
function describeRun(run: WorkflowRunSnapshot<WorkflowOutputOf<typeof research>>): string {
|
|
20
|
+
// `isTerminal` narrows to the three finished statuses, which is what makes
|
|
21
|
+
// `run.output` and `run.error` reachable without a cast.
|
|
22
|
+
if (!isTerminal(run)) return "Still working on it.";
|
|
23
|
+
switch (run.status) {
|
|
24
|
+
case "completed":
|
|
25
|
+
return `Done: ${run.output.summary} (${run.output.sources} sources)`;
|
|
26
|
+
case "failed":
|
|
27
|
+
return `That one failed: ${run.error}`;
|
|
28
|
+
default:
|
|
29
|
+
return "That one was cancelled.";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default tool({
|
|
34
|
+
description: "Report on research started earlier in this call.",
|
|
35
|
+
execute: async (_args, ctx) => {
|
|
36
|
+
const runs = await ctx.workflows.find(research, ctx.sessionId, { limit: RECENT_RUNS });
|
|
37
|
+
if (runs.length === 0) return { runs: [] as string[], note: "Nothing started yet." };
|
|
38
|
+
return { runs: runs.map((run) => `${run.workflow}: ${describeRun(run)}`) };
|
|
39
|
+
},
|
|
40
|
+
});
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// Copyright 2026 the AAI authors. MIT license.
|
|
2
|
+
/**
|
|
3
|
+
* The prompts the deep-research pass runs on, and where they come from.
|
|
4
|
+
*
|
|
5
|
+
* **Adapted from LangChain's `open_deep_research`** (MIT,
|
|
6
|
+
* <https://github.com/langchain-ai/open_deep_research>, `src/open_deep_research/
|
|
7
|
+
* prompts.py`) — the shape is theirs and it is the reason this template stopped
|
|
8
|
+
* being three model calls in a row. What that project got right, and what a
|
|
9
|
+
* naive research pipeline gets wrong, is that every stage has an explicit STOP
|
|
10
|
+
* condition and an explicit budget: a researcher told "search until you know
|
|
11
|
+
* enough" either stops at the first plausible page or never stops at all.
|
|
12
|
+
*
|
|
13
|
+
* The five stages it names map onto steps almost exactly, which is the other
|
|
14
|
+
* reason to take the shape rather than invent one — a supervisor delegating to
|
|
15
|
+
* researchers IS a fan-out, and a "compress" stage IS the thing that keeps a
|
|
16
|
+
* step's journaled result small:
|
|
17
|
+
*
|
|
18
|
+
* | open_deep_research | here |
|
|
19
|
+
* | --- | --- |
|
|
20
|
+
* | research brief | {@link BRIEF_SYSTEM} — one call, before anything is searched |
|
|
21
|
+
* | lead researcher / supervisor | {@link PLAN_SYSTEM}, then {@link GAPS_SYSTEM} for the second wave |
|
|
22
|
+
* | researcher | {@link RESEARCH_SYSTEM} — the search loop, bounded |
|
|
23
|
+
* | compress | {@link COMPRESS_SYSTEM} — findings kept verbatim, cited |
|
|
24
|
+
* | final report | {@link REPORT_SYSTEM}, plus {@link BRIEF_SUMMARY_SYSTEM} for the phone |
|
|
25
|
+
*
|
|
26
|
+
* They are ADAPTED rather than copied: theirs are written for a LangGraph agent
|
|
27
|
+
* that calls tools by name and returns a long markdown report to a reader, and
|
|
28
|
+
* ours are written for a `"use step"` function that calls `webSearch` itself,
|
|
29
|
+
* returns JSON a later step consumes, and ends at a voice agent reading two
|
|
30
|
+
* sentences down a phone. What survives verbatim is the part that is the actual
|
|
31
|
+
* finding: the numbered stop rules, "repeat the useful text rather than
|
|
32
|
+
* summarizing it away", and citing as you go rather than at the end.
|
|
33
|
+
*
|
|
34
|
+
* A prompt is DATA, so this module carries no directive and the builder leaves
|
|
35
|
+
* it alone — the same reason `transcription-workflow`'s `wav.ts` can sit beside its
|
|
36
|
+
* bodies.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/** Turn a phone request into something a researcher can be held to. */
|
|
40
|
+
export const BRIEF_SYSTEM = [
|
|
41
|
+
"You turn a spoken research request into a research brief.",
|
|
42
|
+
"The request came over the phone, so it is short and may be ambiguous.",
|
|
43
|
+
"Do NOT ask questions — you cannot; the caller is gone. Instead, state the most",
|
|
44
|
+
"reasonable reading of the request and say what would make the answer good.",
|
|
45
|
+
'Reply as JSON: {"brief": string, "criteria": string[]}.',
|
|
46
|
+
"`brief` is two or three sentences naming what is being researched and for whom.",
|
|
47
|
+
"`criteria` is two to four things a complete answer must contain.",
|
|
48
|
+
].join(" ");
|
|
49
|
+
|
|
50
|
+
/** Decompose the brief into research units — the fan-out's width. */
|
|
51
|
+
export const PLAN_SYSTEM = [
|
|
52
|
+
"You are a research supervisor. Break a research brief into independent angles,",
|
|
53
|
+
"each of which one researcher can investigate on its own.",
|
|
54
|
+
"Bias towards FEWER angles: use one when the brief is a single question, and",
|
|
55
|
+
"only add angles where a genuinely separate line of enquiry exists. Two",
|
|
56
|
+
"researchers covering the same ground is the failure to avoid.",
|
|
57
|
+
"Each angle is one short noun phrase, specific enough to search for.",
|
|
58
|
+
'Reply as JSON: {"angles": string[]}.',
|
|
59
|
+
].join(" ");
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The researcher's loop.
|
|
63
|
+
*
|
|
64
|
+
* The numbered stop rules are the heart of the adaptation and are close to
|
|
65
|
+
* theirs, because they are the finding: without them a researcher either stops
|
|
66
|
+
* at the first plausible page or keeps searching until the budget runs out, and
|
|
67
|
+
* both look identical in the output.
|
|
68
|
+
*/
|
|
69
|
+
export const RESEARCH_SYSTEM = [
|
|
70
|
+
"You are a researcher working on one angle of a research brief.",
|
|
71
|
+
"You decide, one step at a time, what to do next: search the web, read a page",
|
|
72
|
+
"you have already found, or stop because you have enough.",
|
|
73
|
+
"",
|
|
74
|
+
"Rules for how hard to look:",
|
|
75
|
+
"- A simple, factual angle deserves 2 to 3 searches. A comparative or",
|
|
76
|
+
" contested one deserves up to the budget you are given.",
|
|
77
|
+
"- STOP as soon as one of these is true: you can answer the angle thoroughly;",
|
|
78
|
+
" you have three or more relevant sources agreeing; the last two searches",
|
|
79
|
+
" returned much the same thing.",
|
|
80
|
+
"- ALWAYS stop when the budget is spent, even if you are not satisfied. Say",
|
|
81
|
+
" what you did not manage to establish rather than guessing at it.",
|
|
82
|
+
"- Prefer READING a promising result over running another search. A page you",
|
|
83
|
+
" have opened is worth more than a fourth list of titles.",
|
|
84
|
+
"",
|
|
85
|
+
'Reply as JSON, one action per turn: {"action": "search", "query": string} or',
|
|
86
|
+
'{"action": "read", "url": string} or {"action": "stop", "why": string}.',
|
|
87
|
+
].join("\n");
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Compression, and the one instruction it turns on.
|
|
91
|
+
*
|
|
92
|
+
* "Repeat the relevant text rather than summarizing it" is theirs and is
|
|
93
|
+
* counter-intuitive enough to be worth keeping verbatim in spirit: a summary of
|
|
94
|
+
* a summary is what makes a long research pass produce a confident, sourceless
|
|
95
|
+
* paragraph at the end.
|
|
96
|
+
*/
|
|
97
|
+
export const COMPRESS_SYSTEM = [
|
|
98
|
+
"You are compressing one researcher's raw findings for a later stage.",
|
|
99
|
+
"Keep ALL of the information that bears on the angle, rewritten cleanly —",
|
|
100
|
+
"repeat the relevant text rather than summarizing it away. A later stage will",
|
|
101
|
+
"do the summarizing, and it can only work with what you keep.",
|
|
102
|
+
"Cite as you go: mark each claim with the number of the source it came from.",
|
|
103
|
+
'Reply as JSON: {"findings": string, "sources": {"title": string, "url": string}[]}.',
|
|
104
|
+
"The numbers you cite are 1-based indexes into `sources`.",
|
|
105
|
+
].join(" ");
|
|
106
|
+
|
|
107
|
+
/** The supervisor's second look: what is still unanswered. */
|
|
108
|
+
export const GAPS_SYSTEM = [
|
|
109
|
+
"You are a research supervisor reviewing what came back from the first wave.",
|
|
110
|
+
"Name only the angles that are still genuinely unanswered against the brief's",
|
|
111
|
+
"criteria — a gap is something a reader would notice, not something that could",
|
|
112
|
+
"merely be said at greater length.",
|
|
113
|
+
"Answer with an EMPTY list when the brief is covered; a second wave costs the",
|
|
114
|
+
"caller minutes and it should buy something.",
|
|
115
|
+
'Reply as JSON: {"angles": string[]}.',
|
|
116
|
+
].join(" ");
|
|
117
|
+
|
|
118
|
+
/** The written report — what a page renders and what is filed. */
|
|
119
|
+
export const REPORT_SYSTEM = [
|
|
120
|
+
"You write the final research report from the compressed findings you are given.",
|
|
121
|
+
"Markdown, with a `#` title and `##` sections that follow the brief's criteria.",
|
|
122
|
+
"Be as comprehensive as the findings allow, and include everything relevant to",
|
|
123
|
+
"the brief — a section should be as long as it needs to be to answer its part.",
|
|
124
|
+
"Keep the inline citations, renumbered sequentially with no gaps, and end with",
|
|
125
|
+
"a `## Sources` list numbered to match.",
|
|
126
|
+
"Say plainly where the research came up short. Never invent a source, a number",
|
|
127
|
+
"or a date, and never pad with commentary about the research process itself.",
|
|
128
|
+
].join(" ");
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The voice-sized answer.
|
|
132
|
+
*
|
|
133
|
+
* The stage `open_deep_research` has no equivalent of, because its output is
|
|
134
|
+
* read on a screen. This one is read down a phone by an agent that has already
|
|
135
|
+
* said "I'll let you know", so the report is the wrong artefact entirely: two
|
|
136
|
+
* sentences, no markdown, and nothing a listener cannot hold in their head.
|
|
137
|
+
*/
|
|
138
|
+
export const BRIEF_SUMMARY_SYSTEM = [
|
|
139
|
+
"You reduce a research report to what an agent can say out loud on a phone call.",
|
|
140
|
+
"Two sentences at most. No markdown, no lists, no citation markers, no URLs.",
|
|
141
|
+
"Lead with the answer, not with what was done. If the research was inconclusive,",
|
|
142
|
+
"say that first and in those words.",
|
|
143
|
+
].join(" ");
|