@alexkroman1/aai-cli 16.1.0 → 18.0.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/README.md +2 -1
- package/dist/{_build-target-ClEEuUuW.mjs → _build-target-C08aM-Es.mjs} +504 -43
- package/dist/_build-target.d.ts +98 -19
- package/dist/_console-audio.d.ts +17 -0
- package/dist/_console-session.d.ts +70 -0
- package/dist/_deno-target.d.ts +15 -14
- package/dist/_dev-env.d.ts +19 -13
- package/dist/{_dev-server-D1wKiA0_.mjs → _dev-server-Dtp4aAlo.mjs} +26 -18
- package/dist/_dev-server.d.ts +5 -3
- package/dist/_init.d.ts +39 -0
- package/dist/_modal-target.d.ts +11 -6
- package/dist/_preflight-CnW9QiE7.mjs +116 -0
- package/dist/_preflight.d.ts +110 -5
- package/dist/_target-bundle.d.ts +112 -0
- package/dist/_target-entry.d.ts +81 -0
- package/dist/_templates-DXadVNsL.mjs +135 -0
- package/dist/_templates.d.ts +11 -34
- package/dist/{_vitest-runner-BiAMIir1.mjs → _vitest-runner-CZNGj0ZC.mjs} +21 -16
- package/dist/_vitest-runner.d.ts +35 -23
- package/dist/{build-O6BT51x_.mjs → build-DrQTSc2R.mjs} +128 -293
- package/dist/build.d.ts +34 -4
- package/dist/cli.mjs +40 -16
- package/dist/console-BsyE3DyB.mjs +422 -0
- package/dist/console.d.ts +37 -0
- package/dist/{deploy-lldQyJVj.mjs → deploy-B68-x7xM.mjs} +12 -4
- package/dist/deploy.d.ts +9 -0
- package/dist/{dev-Du8pCWFq.mjs → dev-BGWU2zPP.mjs} +1 -1
- package/dist/dev.d.ts +1 -1
- package/dist/{eval-Ducmkt1n.mjs → eval-DB07kTxO.mjs} +1 -1
- package/dist/init-CbOhyNYe.mjs +559 -0
- package/dist/init.d.ts +43 -3
- package/dist/scaffold/CLAUDE.md +161 -166
- package/dist/scaffold/package.json +6 -6
- package/dist/scaffold/vite.config.ts +29 -1
- package/dist/start.d.ts +3 -3
- package/dist/{studio-It7SRfUN.mjs → studio-BRJsw7lr.mjs} +19 -9
- package/dist/templates/applicant-screening-agent/agent.eval.test.ts +20 -6
- package/dist/templates/applicant-screening-agent/agent.test.ts +17 -13
- package/dist/templates/applicant-screening-agent/agent.ts +28 -0
- package/dist/templates/applicant-screening-agent/crews.ts +4 -4
- package/dist/templates/applicant-screening-agent/shared.ts +11 -11
- package/dist/templates/call-audit-workflow/agent.ts +2 -0
- package/dist/templates/code-interpreter-agent/agent.eval.test.ts +3 -2
- package/dist/templates/code-interpreter-agent/agent.test.ts +2 -2
- package/dist/templates/code-interpreter-agent/agent.ts +1 -0
- package/dist/templates/coding-agent/agent.eval.test.ts +136 -0
- package/dist/templates/coding-agent/agent.test.ts +109 -0
- package/dist/templates/coding-agent/agent.ts +45 -0
- package/dist/templates/coding-agent/chat.ts +63 -0
- package/dist/templates/coding-agent/shared.ts +46 -0
- package/dist/templates/coding-agent/system-prompt.md +32 -0
- package/dist/templates/coding-agent/tools/bash.ts +6 -0
- package/dist/templates/coding-agent/tools/delete_file.ts +6 -0
- package/dist/templates/coding-agent/tools/edit_file.ts +6 -0
- package/dist/templates/coding-agent/tools/glob.ts +6 -0
- package/dist/templates/coding-agent/tools/grep.ts +6 -0
- package/dist/templates/coding-agent/tools/list_files.ts +6 -0
- package/dist/templates/coding-agent/tools/read_file.ts +6 -0
- package/dist/templates/coding-agent/tools/todo_write.ts +6 -0
- package/dist/templates/coding-agent/tools/write_file.ts +6 -0
- package/dist/templates/custom-pipeline-agent/agent.ts +3 -2
- package/dist/templates/custom-pipeline-agent/modes.test.ts +4 -4
- package/dist/templates/custom-pipeline-agent/stages.test.ts +75 -83
- package/dist/templates/document-redline-workflow/agent.ts +2 -0
- package/dist/templates/emergency-dispatch-agent/agent.eval.test.ts +1 -1
- package/dist/templates/emergency-dispatch-agent/agent.test.ts +103 -0
- package/dist/templates/emergency-dispatch-agent/agent.ts +15 -0
- package/dist/templates/emergency-dispatch-agent/guardrails.ts +105 -0
- package/dist/templates/emergency-dispatch-agent/system-prompt.md +1 -0
- package/dist/templates/entertainment-picks-agent/agent.eval.test.ts +9 -2
- package/dist/templates/entertainment-picks-agent/agent.ts +1 -0
- package/dist/templates/entertainment-picks-agent/system-prompt.md +6 -0
- package/dist/templates/entertainment-picks-agent/tools/revisit.ts +7 -0
- package/dist/templates/executive-inbox-agent/agent.eval.test.ts +84 -23
- package/dist/templates/executive-inbox-agent/agent.test.ts +35 -25
- package/dist/templates/executive-inbox-agent/agent.ts +1 -0
- package/dist/templates/executive-inbox-agent/calendar.test.ts +13 -7
- package/dist/templates/executive-inbox-agent/meeting.ts +3 -3
- package/dist/templates/executive-inbox-agent/prompts.ts +3 -1
- package/dist/templates/executive-inbox-agent/system-prompt.md +3 -3
- package/dist/templates/executive-inbox-agent/tools/meeting_assistant.ts +3 -3
- package/dist/templates/executive-inbox-agent/tools/open_email.ts +8 -16
- package/dist/templates/front-desk-agent/agent.eval.test.ts +174 -0
- package/dist/templates/front-desk-agent/agent.test.ts +150 -0
- package/dist/templates/front-desk-agent/agent.ts +22 -0
- package/dist/templates/front-desk-agent/shared.ts +234 -0
- package/dist/templates/front-desk-agent/system-prompt.md +13 -0
- package/dist/templates/front-desk-agent/tools/verify_account.ts +41 -0
- package/dist/templates/hotel-reception-agent/agent.eval.test.ts +85 -21
- package/dist/templates/hotel-reception-agent/agent.test.ts +3 -3
- package/dist/templates/hotel-reception-agent/agent.ts +6 -3
- package/dist/templates/hotel-reception-agent/client.tsx +14 -2
- package/dist/templates/hotel-reception-agent/concierge.ts +2 -1
- package/dist/templates/hotel-reception-agent/desk-seams.test.ts +3 -3
- package/dist/templates/hotel-reception-agent/disputes.ts +9 -11
- package/dist/templates/hotel-reception-agent/events.ts +2 -1
- package/dist/templates/hotel-reception-agent/session.ts +56 -0
- package/dist/templates/hotel-reception-agent/shared.ts +20 -21
- package/dist/templates/hotel-reception-agent/system-prompt.md +1 -1
- package/dist/templates/hotel-reception-agent/tools/abandon_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/add_to_waitlist.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/book_airport_car.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/cancel_restaurant_reservation.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/cancel_room_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/check_restaurant_availability.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/check_room_availability.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/choose_room.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/confirm_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/dispatch_emergency.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/dispute_charge.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/flag_late_arrival.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_guest_history.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_invoice.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_restaurant_reservation.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/modify_restaurant_reservation.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/record_card.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/record_followup.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/record_group_inquiry.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/record_guest_details.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/reinstate_booking.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/request_flight_reconfirmation.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/resend_confirmation.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/reserve_table.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/resolve_room_conflict.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/schedule_wakeup_call.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/set_do_not_disturb.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/set_extras.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/set_stay.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/start_booking_modification.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/start_room_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/take_guest_message.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/transfer_call.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/update_card.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/verify_booking.ts +2 -1
- package/dist/templates/link-digest-workflow/agent.eval.test.ts +16 -1
- package/dist/templates/link-digest-workflow/agent.ts +5 -0
- package/dist/templates/medication-safety-agent/agent.test.ts +57 -4
- package/dist/templates/medication-safety-agent/agent.ts +48 -1
- package/dist/templates/meeting-recap-agent/agent.test.ts +2 -2
- package/dist/templates/meeting-recap-agent/agent.ts +4 -0
- package/dist/templates/pizza-ordering-agent/agent.eval.test.ts +68 -2
- package/dist/templates/pizza-ordering-agent/agent.ts +3 -0
- package/dist/templates/podcast-digest-workflow/agent.ts +4 -0
- package/dist/templates/push-to-talk-agent/agent.eval.test.ts +74 -0
- package/dist/templates/push-to-talk-agent/agent.test.ts +61 -0
- package/dist/templates/push-to-talk-agent/agent.ts +22 -0
- package/dist/templates/push-to-talk-agent/client.tsx +124 -0
- package/dist/templates/push-to-talk-agent/shared.ts +34 -0
- package/dist/templates/push-to-talk-agent/system-prompt.md +11 -0
- package/dist/templates/push-to-talk-agent/tools/list_notes.ts +15 -0
- package/dist/templates/push-to-talk-agent/tools/save_note.ts +26 -0
- package/dist/templates/quickstart-agent/agent.eval.test.ts +91 -3
- package/dist/templates/quickstart-agent/agent.test.ts +22 -0
- package/dist/templates/quickstart-agent/agent.ts +18 -2
- package/dist/templates/quickstart-agent/system-prompt.md +8 -0
- package/dist/templates/quickstart-agent/tools/get_weather.ts +59 -0
- package/dist/templates/research-handoff-agent/agent.eval.test.ts +1 -1
- package/dist/templates/research-handoff-agent/agent.test.ts +34 -26
- package/dist/templates/research-handoff-agent/agent.ts +4 -0
- package/dist/templates/research-planner-agent/agent.eval.test.ts +24 -2
- package/dist/templates/research-planner-agent/agent.test.ts +26 -16
- package/dist/templates/research-planner-agent/agent.ts +3 -0
- package/dist/templates/research-planner-agent/system-prompt.md +1 -1
- package/dist/templates/retail-orders-agent/agent.eval.test.ts +1 -1
- package/dist/templates/retail-orders-agent/agent.ts +32 -3
- package/dist/templates/retail-orders-agent/keyterms.ts +154 -0
- package/dist/templates/retail-orders-agent/resolve.ts +18 -3
- package/dist/templates/roadside-assistance-agent/agent.eval.test.ts +124 -5
- package/dist/templates/roadside-assistance-agent/agent.test.ts +39 -7
- package/dist/templates/roadside-assistance-agent/agent.ts +4 -0
- package/dist/templates/roadside-assistance-agent/shared.ts +12 -0
- package/dist/templates/roadside-assistance-agent/tools/acknowledge_disclosure.ts +14 -0
- package/dist/templates/roadside-assistance-agent/tools/lookup_coverage.ts +11 -0
- package/dist/templates/roadside-assistance-agent/tools/service_disclosure.ts +17 -11
- package/dist/templates/roadside-assistance-agent/yard.test.ts +4 -0
- package/dist/templates/spoken-summary-workflow/agent.ts +4 -0
- package/dist/templates/tabletop-rpg-agent/agent.eval.test.ts +6 -0
- package/dist/templates/tabletop-rpg-agent/agent.test.ts +125 -1
- package/dist/templates/tabletop-rpg-agent/agent.ts +30 -1
- package/dist/templates/tabletop-rpg-agent/shared.ts +81 -0
- package/dist/templates/tabletop-rpg-agent/system-prompt.md +1 -1
- package/dist/templates/tabletop-rpg-agent/tools/check_state.ts +16 -7
- package/dist/templates/technical-support-agent/agent.test.ts +29 -23
- package/dist/templates/technical-support-agent/agent.ts +5 -1
- package/dist/templates/technical-support-agent/knowledge.ts +165 -0
- package/dist/templates/technical-support-agent/nodes.ts +3 -2
- package/dist/templates/technical-support-agent/procedure.ts +7 -6
- package/dist/templates/technical-support-agent/shared.ts +10 -146
- package/dist/templates/technical-support-agent/tools/list_topics.ts +2 -1
- package/dist/templates/text-adventure-agent/agent.eval.test.ts +39 -6
- package/dist/templates/text-adventure-agent/agent.test.ts +79 -1
- package/dist/templates/text-adventure-agent/agent.ts +30 -1
- package/dist/templates/text-adventure-agent/shared.ts +37 -0
- package/dist/templates/text-adventure-agent/system-prompt.md +9 -2
- package/dist/templates/topic-briefing-agent/agent.eval.test.ts +18 -4
- package/dist/templates/topic-briefing-agent/agent.test.ts +61 -36
- package/dist/templates/topic-briefing-agent/agent.ts +4 -1
- package/dist/templates/topic-briefing-agent/shared.ts +19 -18
- package/dist/templates/topic-briefing-agent/system-prompt.md +13 -8
- package/dist/templates/topic-briefing-agent/tools/send_briefing.ts +43 -5
- package/dist/templates/transcription-workflow/agent.ts +3 -0
- package/dist/templates/travel-concierge-agent/agent.eval.test.ts +9 -7
- package/dist/templates/travel-concierge-agent/agent.test.ts +1 -2
- package/dist/templates/travel-concierge-agent/agent.ts +4 -0
- package/dist/templates/web-research-agent/agent.eval.test.ts +31 -5
- package/dist/templates/web-research-agent/agent.test.ts +16 -0
- package/dist/templates/web-research-agent/agent.ts +30 -0
- package/dist/templates/web-research-agent/system-prompt.md +8 -2
- package/dist/templates/word-game-agent/agent.eval.test.ts +79 -18
- package/dist/templates/word-game-agent/agent.test.ts +3 -1
- package/dist/templates/word-game-agent/agent.ts +20 -0
- package/dist/test-CjKPQ9_B.mjs +102 -0
- package/dist/test.d.ts +37 -12
- package/package.json +5 -5
- package/dist/_init-Bp1CjRrU.mjs +0 -199
- package/dist/_preflight-CcAR577V.mjs +0 -46
- package/dist/_templates-CuP74F8D.mjs +0 -291
- package/dist/init-CY4NAXAA.mjs +0 -183
- package/dist/test-PHHv0Vj6.mjs +0 -83
package/dist/_preflight.d.ts
CHANGED
|
@@ -21,7 +21,16 @@
|
|
|
21
21
|
* so could reject — moving the config to where it is authored costs that
|
|
22
22
|
* accuracy, and a false rejection is worse than a false warning: it blocks a
|
|
23
23
|
* deploy that would have worked.
|
|
24
|
+
*
|
|
25
|
+
* **The telephony half is here for the same reason and warns for a different
|
|
26
|
+
* failure.** A declared carrier's signing secret being absent does not stop the
|
|
27
|
+
* agent — it serves that carrier's webhook with verification OFF — so it is a
|
|
28
|
+
* silent outcome rather than a loud one, which is exactly why nothing else was
|
|
29
|
+
* going to report it. `telephonyWebhooks` sits beside it because both readers
|
|
30
|
+
* need the same declaration and this module is already where the normalized
|
|
31
|
+
* config is unpacked.
|
|
24
32
|
*/
|
|
33
|
+
import type { TelephonyCarrier } from "@alexkroman1/aai";
|
|
25
34
|
import { requiredProviderEnvVars } from "@alexkroman1/aai-runtime";
|
|
26
35
|
/**
|
|
27
36
|
* The config shape read out of a bundle's `__aaiConfig` export: the provider
|
|
@@ -42,16 +51,112 @@ import { requiredProviderEnvVars } from "@alexkroman1/aai-runtime";
|
|
|
42
51
|
*/
|
|
43
52
|
export type PreflightConfig = Parameters<typeof requiredProviderEnvVars>[0] & {
|
|
44
53
|
requiredEnv?: readonly string[] | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* `AgentDef.telephony`, for {@link missingTelephonySecrets} and
|
|
56
|
+
* {@link telephonyWebhooks}. Serializable like `page` is, so it survives the
|
|
57
|
+
* trip through `__aaiConfig` — see `packages/aai/src/sdk/telephony-config.ts`.
|
|
58
|
+
*
|
|
59
|
+
* `readonly string[]` rather than `TelephonyAccess`'s carrier union, and
|
|
60
|
+
* deliberately: this value was JSON on the way here, written by whichever
|
|
61
|
+
* SDK built the bundle, so a name this build has never heard of is a case
|
|
62
|
+
* that HAPPENS rather than one a cast has to manufacture.
|
|
63
|
+
* {@link declaredCarriers} filters against `TELEPHONY_CARRIERS` for exactly
|
|
64
|
+
* that reason, and typing the field narrower than the data made its own
|
|
65
|
+
* test unwritable without erasing the type.
|
|
66
|
+
*/
|
|
67
|
+
telephony?: boolean | readonly string[] | undefined;
|
|
45
68
|
};
|
|
69
|
+
/**
|
|
70
|
+
* Every env var name the agent needs to start: provider credentials derived
|
|
71
|
+
* from the stt/llm/tts/s2s descriptors (the same registry-backed derivation the
|
|
72
|
+
* runtime resolves keys with), plus the agent's own declared `requiredEnv` — an
|
|
73
|
+
* `agent()` field for custom keys tools read from `ctx.env`, which no static
|
|
74
|
+
* derivation can see.
|
|
75
|
+
*
|
|
76
|
+
* **Named on its own because the CLI has TWO deploy paths and only one of them
|
|
77
|
+
* used to ask.** `missingDeployEnv` (`build.ts`, the `--target` hosts) derived
|
|
78
|
+
* its list from `.env.example` alone, so an agent declaring
|
|
79
|
+
* `requiredEnv: ["ORDERS_API_KEY"]` and no example entry got neither a warning
|
|
80
|
+
* nor an `env add` step for it — while the managed path below saw both sources.
|
|
81
|
+
* One derivation, two callers; each applies its own "what counts as supplied".
|
|
82
|
+
*/
|
|
83
|
+
export declare function requiredEnvNames(config: PreflightConfig): string[];
|
|
46
84
|
/**
|
|
47
85
|
* Env var names the agent needs that the env being uploaded doesn't supply.
|
|
48
86
|
* Empty values count as missing — an empty credential authenticates nothing.
|
|
49
|
-
*
|
|
50
|
-
* Two sources: provider credentials derived from the stt/llm/tts/s2s
|
|
51
|
-
* descriptors (the same registry-backed derivation the runtime resolves keys
|
|
52
|
-
* with), and the agent's own declared `requiredEnv` — an `agent()` field for
|
|
53
|
-
* custom keys tools read from `ctx.env`, which no static derivation can see.
|
|
54
87
|
*/
|
|
55
88
|
export declare function missingCredentials(config: PreflightConfig, env: Record<string, string>): string[];
|
|
56
89
|
/** One line naming the missing keys and what to do about them. */
|
|
57
90
|
export declare function missingCredentialMessage(missing: string[]): string;
|
|
91
|
+
/**
|
|
92
|
+
* The webhook-signing secret each carrier's requests are verified with —
|
|
93
|
+
* `phone-signature.ts`'s `TWILIO_AUTH_TOKEN_SECRET` / `TELNYX_PUBLIC_KEY_SECRET`
|
|
94
|
+
* from the reading end.
|
|
95
|
+
*
|
|
96
|
+
* Copied rather than imported: those constants live in `aai-server`, which the
|
|
97
|
+
* CLI may never import (see "Dependency flow" in `AGENTS.md`). `satisfies` is
|
|
98
|
+
* what keeps the copy total — a carrier added to `TELEPHONY_CARRIERS` with no
|
|
99
|
+
* secret named here fails this package's build rather than deploying a phone
|
|
100
|
+
* number nothing warns about.
|
|
101
|
+
*/
|
|
102
|
+
export declare const CARRIER_SIGNING_SECRETS: {
|
|
103
|
+
readonly twilio: "TWILIO_AUTH_TOKEN";
|
|
104
|
+
readonly telnyx: "TELNYX_PUBLIC_KEY";
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* The carriers a declaration admits, in `TELEPHONY_CARRIERS` order.
|
|
108
|
+
*
|
|
109
|
+
* The same resolution the runtime's `enabledCarriers` performs — `false`, `[]`
|
|
110
|
+
* and an absent field all mean the route is not served, `true` means every
|
|
111
|
+
* carrier this build ships a codec for, and a name this build does not know is
|
|
112
|
+
* DROPPED. It is re-derived here only because that function is `@internal` to
|
|
113
|
+
* `aai-runtime` and reaches no published subpath; keep the two in step.
|
|
114
|
+
*/
|
|
115
|
+
export declare function declaredCarriers(config: PreflightConfig): TelephonyCarrier[];
|
|
116
|
+
/**
|
|
117
|
+
* Declared carriers whose signing secret the env being uploaded doesn't
|
|
118
|
+
* supply — the phone half of {@link missingCredentials}, and a separate
|
|
119
|
+
* function because the failure is a separate one.
|
|
120
|
+
*
|
|
121
|
+
* A missing provider key stops the agent starting; a missing signing secret
|
|
122
|
+
* lets it start and serve a phone number with **verification off**. Signature
|
|
123
|
+
* checking is enabled BY PRESENCE (`phone-signature.ts`), so the absence is
|
|
124
|
+
* silent at every layer: the deploy succeeds, the call connects, and nothing
|
|
125
|
+
* anywhere says the webhook is unauthenticated. That is the one thing about a
|
|
126
|
+
* declared carrier the CLI knows and the platform cannot — the platform stores
|
|
127
|
+
* no agent config — so it is said here or nowhere.
|
|
128
|
+
*
|
|
129
|
+
* Empty values count as missing for the reason they do above, and for one more:
|
|
130
|
+
* `verifyPhoneWebhook` reads the stored value, and a blank secret is a check
|
|
131
|
+
* that cannot pass rather than one that is off.
|
|
132
|
+
*/
|
|
133
|
+
export declare function missingTelephonySecrets(config: PreflightConfig, env: Record<string, string>): {
|
|
134
|
+
carrier: TelephonyCarrier;
|
|
135
|
+
secret: string;
|
|
136
|
+
}[];
|
|
137
|
+
/** One line per carrier whose signing secret is absent. */
|
|
138
|
+
export declare function missingTelephonySecretWarnings(missing: readonly {
|
|
139
|
+
carrier: TelephonyCarrier;
|
|
140
|
+
secret: string;
|
|
141
|
+
}[]): string[];
|
|
142
|
+
/**
|
|
143
|
+
* The webhook URL to paste into each declared carrier's phone-number
|
|
144
|
+
* configuration, `?carrier=` already filled in.
|
|
145
|
+
*
|
|
146
|
+
* Printed because both halves are things a user is otherwise asked to
|
|
147
|
+
* reconstruct by hand, and getting either wrong produces a failure that names
|
|
148
|
+
* neither: the platform's phone route defaults `carrier` to `"twilio"` against
|
|
149
|
+
* a hardcoded set and never consults the agent's declaration, so a Telnyx
|
|
150
|
+
* number reached without the query parameter is verified against Twilio's
|
|
151
|
+
* scheme and answers `403 Invalid webhook signature`. The parameter cannot be
|
|
152
|
+
* inferred server-side — `BundleStore` deliberately holds no agent config — and
|
|
153
|
+
* it does not have to be, because the declaration is in hand right here.
|
|
154
|
+
*
|
|
155
|
+
* The path and the parameter name come from `aai-runtime`'s own constants
|
|
156
|
+
* rather than from string literals, so a route rename cannot leave this
|
|
157
|
+
* printing a URL that 404s.
|
|
158
|
+
*/
|
|
159
|
+
export declare function telephonyWebhooks(config: PreflightConfig, agentUrl: string): {
|
|
160
|
+
carrier: TelephonyCarrier;
|
|
161
|
+
url: string;
|
|
162
|
+
}[];
|
package/dist/_target-bundle.d.ts
CHANGED
|
@@ -16,11 +16,123 @@
|
|
|
16
16
|
* A bundle removes the question. The host resolves nothing, installs nothing,
|
|
17
17
|
* and what runs is what the project's own lockfile pinned.
|
|
18
18
|
*
|
|
19
|
+
* ...as long as the bundle really has nothing left to resolve, which is what
|
|
20
|
+
* {@link JSDOC_FREE_COMMENTS} is about — a bundle can carry a dependency it
|
|
21
|
+
* never imports.
|
|
22
|
+
*
|
|
19
23
|
* The entry is written INTO the project rather than a temp directory, because
|
|
20
24
|
* that is what makes `@alexkroman1/aai-cli/start` resolve against the user's
|
|
21
25
|
* install. Removed in a `finally`: a build that throws must not leave a file
|
|
22
26
|
* that looks authored.
|
|
23
27
|
*/
|
|
28
|
+
/**
|
|
29
|
+
* Drop JSDoc from the bundle, and KEEP the other two comment classes.
|
|
30
|
+
*
|
|
31
|
+
* ## A commented `import()` is a real dependency
|
|
32
|
+
*
|
|
33
|
+
* A JSDoc `@type {import(<specifier>).Webidl}` is a comment to every runtime
|
|
34
|
+
* that executes this file and an EDGE in the module graph to every tool that
|
|
35
|
+
* walks it. Deno resolves the specifier out of a JSDoc type position, so a
|
|
36
|
+
* bundle full of third-party JSDoc arrives at Deno Deploy carrying dependencies
|
|
37
|
+
* that were never bundled because nothing imports them.
|
|
38
|
+
*
|
|
39
|
+
* **Every specifier below is written with a `<placeholder>` rather than
|
|
40
|
+
* quoted**, and that is this bug rather than pedantry: spelling them the real
|
|
41
|
+
* way made `pnpm check:knip` fail on THIS file, reporting `selderee` as an
|
|
42
|
+
* unlisted dependency and undici's relative path as an unresolved import — a
|
|
43
|
+
* comment describing the defect reproducing it, in a second graph-walking tool.
|
|
44
|
+
* Keep the placeholders.
|
|
45
|
+
*
|
|
46
|
+
* **Deno Deploy TOLERATES them today, and that is not a reason to ship them.**
|
|
47
|
+
* Measured, because the first version of this comment guessed otherwise and was
|
|
48
|
+
* wrong: a `quickstart-agent` emit carrying all the JSDoc below deployed and
|
|
49
|
+
* served a full voice session, so nothing here is load-bearing for that host.
|
|
50
|
+
* What the phantom edges cost is the property `app.py` states in its own header
|
|
51
|
+
* — "a bundle with no imports left to resolve" — which was false: `deno info`
|
|
52
|
+
* on the emitted entry reported NINE unresolvable specifiers, and after this
|
|
53
|
+
* setting reports zero. Any tool that walks the graph rather than executing it
|
|
54
|
+
* sees them (`deno info`, `deno check`, `@vercel/nft`), and a host that starts
|
|
55
|
+
* enforcing what Deploy currently ignores would present as a build failure with
|
|
56
|
+
* no line of ours in it.
|
|
57
|
+
*
|
|
58
|
+
* Nine phantom specifiers in that bundle, from THREE sources, which is why
|
|
59
|
+
* this is a bundler setting rather than nine fixes:
|
|
60
|
+
* - undici's JSDoc — `../api/api-request`, `../dispatcher/client`,
|
|
61
|
+
* `../core/request`, `types/dispatcher`, `types/client`, `types/webidl`
|
|
62
|
+
* - html-to-text's — a `@param` naming the `selderee` package, which IS in the
|
|
63
|
+
* bundle, so the bare specifier resolves nowhere from inside it
|
|
64
|
+
* - **our own SDK's** — an `{@link import(<step-generate-json>)}` in the
|
|
65
|
+
* workflow docs' prose, the half no dependency bump would ever fix
|
|
66
|
+
*
|
|
67
|
+
* ## Why not `comments: false`
|
|
68
|
+
*
|
|
69
|
+
* `annotation` carries `@__PURE__` and `@__NO_SIDE_EFFECTS__`: those are
|
|
70
|
+
* instructions to the tree-shaker, and dropping them changes what the bundle
|
|
71
|
+
* DOES, not just how it reads. `legal` carries `@license` and `@preserve` from
|
|
72
|
+
* every third-party package in here — stripping those wholesale is a licensing
|
|
73
|
+
* decision and not one a deploy target gets to make quietly. `jsdoc` is the
|
|
74
|
+
* only class that can name a module, so it is the only one that goes.
|
|
75
|
+
*
|
|
76
|
+
* Applied to EVERY target rather than to Deno alone, on this module's own
|
|
77
|
+
* thesis: what a host does with the graph "differs in ways that are all bad",
|
|
78
|
+
* and a phantom edge is a hazard to any host that walks one — `@vercel/nft`
|
|
79
|
+
* traces imports too. One bundler, one behaviour.
|
|
80
|
+
*
|
|
81
|
+
* @see https://docs.deno.com/runtime/reference/cli/info — `deno info` resolves
|
|
82
|
+
* the graph instead of executing it, which is why it is the gate and why
|
|
83
|
+
* booting the emitted directory is not.
|
|
84
|
+
*/
|
|
85
|
+
export declare const JSDOC_FREE_COMMENTS: {
|
|
86
|
+
readonly legal: true;
|
|
87
|
+
readonly annotation: true;
|
|
88
|
+
readonly jsdoc: false;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* The `node:` builtins an emitted deployment may import.
|
|
92
|
+
*
|
|
93
|
+
* ## Why an ALLOWLIST rather than a note in a guide
|
|
94
|
+
*
|
|
95
|
+
* `ssr.noExternal` bundles everything except these, so whatever survives the
|
|
96
|
+
* pass is a hard dependency on the runtime the host chose — and the emitted
|
|
97
|
+
* directory is a container payload whose runtime is the operator's choice, not
|
|
98
|
+
* ours (`_target-entry.ts` carries that argument). Every name here is
|
|
99
|
+
* implemented by `node`, `deno` and `bun` alike, so the deployment behaves the
|
|
100
|
+
* same under all three.
|
|
101
|
+
*
|
|
102
|
+
* What it is written for is the class the boot arms in
|
|
103
|
+
* `_target-runtimes.scenario.test.ts` cannot see. A dependency bump that drags
|
|
104
|
+
* `node:vm`, `node:cluster` or `node:v8` into the graph reaches a runtime that
|
|
105
|
+
* half-implements it not at boot but at the first CALL — which is a live
|
|
106
|
+
* session, days after the deploy, with nothing in CI to have caught it. This
|
|
107
|
+
* suite reads the bundle instead, so it fails on the build that introduced it.
|
|
108
|
+
* (`node:vm` is a real risk rather than a hypothetical: `aai-runtime`'s
|
|
109
|
+
* `eval/vm-run-code.ts` uses it, and it stays out of the deployment only
|
|
110
|
+
* because nothing in the boot graph reaches that subpath.)
|
|
111
|
+
*
|
|
112
|
+
* ADDING a name is a claim about three runtimes, so check all three rather
|
|
113
|
+
* than the one you are on — `node:worker_threads` is here because Bun and Deno
|
|
114
|
+
* both ship it, `node:cluster` is not because Bun does not.
|
|
115
|
+
*/
|
|
116
|
+
export declare const PORTABLE_NODE_BUILTINS: readonly string[];
|
|
117
|
+
/**
|
|
118
|
+
* Builtins the bundle NAMES but never requires — each behind a runtime feature
|
|
119
|
+
* test, and each therefore free to be absent.
|
|
120
|
+
*
|
|
121
|
+
* A second list rather than more entries in the first, because the two carry
|
|
122
|
+
* different claims and collapsing them would state the wrong one. A name above
|
|
123
|
+
* is portable: all three runtimes implement it, so the code that imports it
|
|
124
|
+
* runs everywhere. A name here is not — `node:sqlite` is Node-only, Deno does
|
|
125
|
+
* not ship it — and what makes it harmless is the GUARD, not the support.
|
|
126
|
+
*
|
|
127
|
+
* `sqlite` is undici's, twice over: `detectRuntimeFeatureByNodeModule` loads it
|
|
128
|
+
* inside a `try` that tolerates `ERR_UNKNOWN_BUILTIN_MODULE`, and
|
|
129
|
+
* `SqliteCacheStore` requires it lazily in a constructor nothing here calls.
|
|
130
|
+
*
|
|
131
|
+
* The spec pins the guard rather than trusting this comment: a name here must
|
|
132
|
+
* never appear as a STATIC import in the bundle, which is what would make it a
|
|
133
|
+
* load-time dependency again.
|
|
134
|
+
*/
|
|
135
|
+
export declare const FEATURE_DETECTED_NODE_BUILTINS: readonly string[];
|
|
24
136
|
/** Bundle `source` as if it were a module in `cwd`, and answer the code. */
|
|
25
137
|
export declare function bundleTargetEntry(cwd: string, source: string, name: string): Promise<string>;
|
|
26
138
|
/** Whether a path exists — the check every emit makes of an optional file. */
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The LONG-LIVED entry — one source, and every runtime that can run it.
|
|
3
|
+
*
|
|
4
|
+
* A leaf beside `_target-drain.ts` (the signal handler both long-lived entries
|
|
5
|
+
* carry), `_target-output.ts` (the directory they share) and
|
|
6
|
+
* `_target-bundle.ts` (the bundle every target's entry goes through): each is a
|
|
7
|
+
* thing more than one host needs and no host owns.
|
|
8
|
+
*
|
|
9
|
+
* ## Why the entry is shared, when it deliberately was not
|
|
10
|
+
*
|
|
11
|
+
* Both long-lived entries do the same four things — build the server, bind a
|
|
12
|
+
* port, bind it on `0.0.0.0`, drain on a signal — and the argument for keeping
|
|
13
|
+
* two copies was the port: `MODAL_ENTRY_SOURCE`'s own doc records it as "the
|
|
14
|
+
* two read the port from different runtimes, and a shared entry would be a
|
|
15
|
+
* template with a hole where that goes".
|
|
16
|
+
*
|
|
17
|
+
* That is true only if a runtime's env is read one runtime's way. It was: the
|
|
18
|
+
* Deno entry read `globalThis.Deno?.env.get("PORT")` and nothing else, and the
|
|
19
|
+
* Modal entry read `process.env.PORT` and nothing else — so each emitted
|
|
20
|
+
* artifact was pinned to its host by ONE expression, and running the Deno
|
|
21
|
+
* directory under `node` or `bun` bound the default port no matter what the
|
|
22
|
+
* host had set. Nobody decided that; it fell out of which global was in reach
|
|
23
|
+
* when each file was written.
|
|
24
|
+
*
|
|
25
|
+
* {@link RUNTIME_PORT_SOURCE} reads BOTH, so the artifact is portable and the
|
|
26
|
+
* hole in the template closes. What is left per host is a comment and a
|
|
27
|
+
* default, which is what {@link longLivedEntrySource} takes.
|
|
28
|
+
*
|
|
29
|
+
* ## Why portability is a property worth spending a module on
|
|
30
|
+
*
|
|
31
|
+
* A self-contained emit is a directory with no `node_modules`, no toolchain and
|
|
32
|
+
* one file to run — which is exactly what a container image carries, and the
|
|
33
|
+
* runtime in that image is the operator's choice, not ours. `deno`, `node` and
|
|
34
|
+
* `bun` all run this file; `_target-runtimes.scenario.test.ts` boots the emit
|
|
35
|
+
* under each of the three and dials a real session on it, because nothing else
|
|
36
|
+
* here can tell you that the same bundle serves on all three rather than only
|
|
37
|
+
* on the one host whose target emitted it.
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* The port expression every long-lived entry uses, reading whichever runtime
|
|
41
|
+
* it finds itself in.
|
|
42
|
+
*
|
|
43
|
+
* `globalThis.Deno?.env` rather than `Deno.env`, and the optional chain is
|
|
44
|
+
* load-bearing twice over: this file is bundled by a Node-side build and read
|
|
45
|
+
* by Node tooling (its own specs included), where a bare `Deno` is a
|
|
46
|
+
* `ReferenceError` — and under Node and Bun the chain is what falls through to
|
|
47
|
+
* `process.env` instead of throwing.
|
|
48
|
+
*
|
|
49
|
+
* `process.env` second rather than first, because Deno's `process` shim reads
|
|
50
|
+
* the same variables and asking Deno for them Deno's way is what keeps the
|
|
51
|
+
* Deno arm honest — a host that grants no env permission fails on the first
|
|
52
|
+
* read either way.
|
|
53
|
+
*
|
|
54
|
+
* `process` itself needs no guard and deliberately gets none: it is a global in
|
|
55
|
+
* all three runtimes, which is what lets {@link TARGET_DRAIN_SOURCE} be the
|
|
56
|
+
* identical text in every entry rather than a template with a hole in it.
|
|
57
|
+
*/
|
|
58
|
+
export declare const RUNTIME_PORT_SOURCE = "globalThis.Deno?.env.get(\"PORT\") ?? process.env.PORT";
|
|
59
|
+
/** What one host varies in the entry it emits. */
|
|
60
|
+
export interface LongLivedEntry {
|
|
61
|
+
/** The `--target` name, for the "do not edit" banner a user's project shows. */
|
|
62
|
+
readonly target: string;
|
|
63
|
+
/** Why this host runs a long-lived process, as comment lines above the code. */
|
|
64
|
+
readonly hostNote: readonly string[];
|
|
65
|
+
/** The port to bind when the host set none. */
|
|
66
|
+
readonly defaultPort: number;
|
|
67
|
+
/** A comment above the drain, where the host supplies the signal's other half. */
|
|
68
|
+
readonly drainNote?: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The entry a long-lived host runs, bundled into that target's entry file.
|
|
72
|
+
*
|
|
73
|
+
* `0.0.0.0`, not `AgentServer.listen`'s loopback default: every host here
|
|
74
|
+
* reaches the process from outside it, so a loopback bind answers nothing while
|
|
75
|
+
* looking healthy.
|
|
76
|
+
*
|
|
77
|
+
* `import.meta.dirname` rather than `process.cwd()`: the artifacts are copied
|
|
78
|
+
* in BESIDE this file (see `_target-output.ts`) and the working directory
|
|
79
|
+
* belongs to the platform.
|
|
80
|
+
*/
|
|
81
|
+
export declare function longLivedEntrySource(entry: LongLivedEntry): string;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { s as errorMessage } from "./_utils-D5JGcjiW.mjs";
|
|
3
|
+
import { t as getMonorepoRoot } from "./_agent-BzUeqOdj.mjs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import fs from "node:fs/promises";
|
|
6
|
+
import { IGNORED_WORKSPACE_DIRS, isLocalOnlyFile, layerScaffoldFiles, readScaffoldFiles, writeFileWithParents } from "@alexkroman1/aai/workspace-files";
|
|
7
|
+
const REPO_URL = `https://github.com/alexkroman/agent`;
|
|
8
|
+
/**
|
|
9
|
+
* Templates as shipped inside the published tarball, copied into `dist/` by
|
|
10
|
+
* `bundle-templates.mjs` at build time — so this resolves to `dist/` for a
|
|
11
|
+
* published CLI and to the (template-less) package root when running source
|
|
12
|
+
* in the monorepo, where the branch above wins.
|
|
13
|
+
*
|
|
14
|
+
* They used to be fetched at `init` time with giget from
|
|
15
|
+
* `github:alexkroman/agent/packages/aai-templates#main`. That required a
|
|
16
|
+
* network for every `init`, and pinned templates to `main` regardless of the
|
|
17
|
+
* CLI version the user had installed, so a template written against a newer
|
|
18
|
+
* SDK could land in a project resolving an older one. Bundling pins the two
|
|
19
|
+
* together by construction. It also puts the templates inside the studio's
|
|
20
|
+
* guest sandbox, which has the CLI in its baked toolchain but no way to fetch
|
|
21
|
+
* anything from GitHub.
|
|
22
|
+
*/
|
|
23
|
+
function bundledTemplatesDir() {
|
|
24
|
+
return import.meta.dirname;
|
|
25
|
+
}
|
|
26
|
+
/** Resolve the templates root — env override, then monorepo, then bundled. */
|
|
27
|
+
function resolveTemplatesDir() {
|
|
28
|
+
const override = process.env.AAI_TEMPLATES_DIR;
|
|
29
|
+
if (override) return override;
|
|
30
|
+
const monorepoRoot = getMonorepoRoot();
|
|
31
|
+
if (monorepoRoot) return path.join(monorepoRoot, "packages", "aai-templates");
|
|
32
|
+
return bundledTemplatesDir();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* List the shipped template names (sorted). Backs `aai templates` and the
|
|
36
|
+
* unknown-template error, so the discoverable list and the validated list
|
|
37
|
+
* can never drift.
|
|
38
|
+
*/
|
|
39
|
+
async function listTemplates(root = resolveTemplatesDir()) {
|
|
40
|
+
const templatesDir = path.join(root, "templates");
|
|
41
|
+
let available;
|
|
42
|
+
try {
|
|
43
|
+
available = await fs.readdir(templatesDir, { withFileTypes: true });
|
|
44
|
+
} catch (err) {
|
|
45
|
+
throw new Error(`Templates directory is missing or unreadable at ${templatesDir} (incomplete @alexkroman1/aai-cli install?): ${errorMessage(err)}`, { cause: err });
|
|
46
|
+
}
|
|
47
|
+
return available.filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Directory holding the base scaffold — the files every project gets
|
|
51
|
+
* underneath its template (package.json, tsconfig, `.gitignore`, …).
|
|
52
|
+
*
|
|
53
|
+
* The scaffold is the single definition of the self-hosted entrypoint, so a
|
|
54
|
+
* caller needing one of its files resolves it here rather than carrying a
|
|
55
|
+
* second copy of that file's contents.
|
|
56
|
+
*/
|
|
57
|
+
function scaffoldDir() {
|
|
58
|
+
return path.join(resolveTemplatesDir(), "scaffold");
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Layer the base scaffold (package.json, tsconfig, `.gitignore`, …) into
|
|
62
|
+
* targetDir WITHOUT overwriting anything already there. Shared by `aai init`
|
|
63
|
+
* (underneath a template) and `aai pull` (underneath the studio workspace
|
|
64
|
+
* files — the workspace stores source, and the scaffold completes it into a
|
|
65
|
+
* runnable project).
|
|
66
|
+
*
|
|
67
|
+
* The rule itself is `layerScaffoldFiles` in the SDK, over file maps, because
|
|
68
|
+
* this is not its only caller: the studio's GitHub sync commits a workspace to
|
|
69
|
+
* a repository and must complete it identically, and neither package may
|
|
70
|
+
* import the other. This function is only the disk half — read what the rule
|
|
71
|
+
* needs to see, write back what it returns. Only the scaffold's own paths are
|
|
72
|
+
* read from the target: whether a project already has a given file is the one
|
|
73
|
+
* thing the rule asks about it, and `package.json`'s content the one thing it
|
|
74
|
+
* merges.
|
|
75
|
+
*/
|
|
76
|
+
async function layerScaffold(targetDir) {
|
|
77
|
+
const scaffold = await readScaffoldFiles(scaffoldDir());
|
|
78
|
+
const existing = {};
|
|
79
|
+
await Promise.all([...Object.keys(scaffold), "CLAUDE.md"].map(async (rel) => {
|
|
80
|
+
try {
|
|
81
|
+
existing[rel] = await fs.readFile(path.join(targetDir, rel), "utf-8");
|
|
82
|
+
} catch {}
|
|
83
|
+
}));
|
|
84
|
+
const writes = layerScaffoldFiles(existing, scaffold);
|
|
85
|
+
await Promise.all(Object.entries(writes).map(([rel, content]) => writeFileWithParents(path.join(targetDir, rel), content)));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* `fs.cp` filter for every copy OUT of a template or the scaffold — the runtime
|
|
89
|
+
* ones here and the build-time one in `bundle-templates.mjs`.
|
|
90
|
+
*
|
|
91
|
+
* A template directory is also a runnable project, so a developer who runs
|
|
92
|
+
* `aai dev`, `aai build` or `aai publish` inside one leaves build output and
|
|
93
|
+
* machine state in it: `.aai/` (which holds `project.json` — a SLUG and a
|
|
94
|
+
* `serverUrl` — plus a built client), `.workflow-data/`, `node_modules/`, a
|
|
95
|
+
* `.env`. None of it is git-tracked, and an unfiltered `fs.cp` copied all of it
|
|
96
|
+
* anyway, to both destinations:
|
|
97
|
+
*
|
|
98
|
+
* - into every scaffolded project, so `aai init foo --template bar` produced a
|
|
99
|
+
* directory already LINKED to `bar`'s last local deploy. `aai init` publishes
|
|
100
|
+
* by default, so the first publish either targeted a slug the user never
|
|
101
|
+
* chose or — for the `http://localhost:8080` a dev checkout leaves behind —
|
|
102
|
+
* failed outright with "Refusing to send your API key to …", the project
|
|
103
|
+
* staying mis-linked for every later `push`/`publish`/`secret`.
|
|
104
|
+
* - into `packages/aai-cli/dist/templates`, i.e. into the PUBLISHED tarball
|
|
105
|
+
* (`files: ["bin.mjs", "dist"]`). Measured on a real build: 26 stray
|
|
106
|
+
* `.aai/project.json` files and 9.4 MB of one developer's `.aai/client`
|
|
107
|
+
* bundles out of a 12 MB `templates/`.
|
|
108
|
+
*
|
|
109
|
+
* The vocabulary is the SDK's, not a fourth list: {@link IGNORED_WORKSPACE_DIRS}
|
|
110
|
+
* is already "never walk this", and {@link isLocalOnlyFile} already means "this
|
|
111
|
+
* exists only on a developer's machine" — including a `.env` that must not ship
|
|
112
|
+
* to npm, and deliberately EXCLUDING `.env.example`, which the scaffold ships as
|
|
113
|
+
* source and a scaffolded project cannot do without.
|
|
114
|
+
*/
|
|
115
|
+
function templateCopyFilter(src) {
|
|
116
|
+
const name = path.basename(src);
|
|
117
|
+
return !(IGNORED_WORKSPACE_DIRS.has(name) || isLocalOnlyFile(name));
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Copy a template into targetDir, merging scaffold files underneath.
|
|
121
|
+
*/
|
|
122
|
+
async function downloadAndMergeTemplate(template, targetDir) {
|
|
123
|
+
const root = resolveTemplatesDir();
|
|
124
|
+
const templatesDir = path.join(root, "templates");
|
|
125
|
+
const names = await listTemplates(root);
|
|
126
|
+
if (!names.includes(template)) throw new Error(`Unknown template "${template}". Available templates: ${names.join(", ")}`);
|
|
127
|
+
await fs.cp(path.join(templatesDir, template), targetDir, {
|
|
128
|
+
recursive: true,
|
|
129
|
+
force: true,
|
|
130
|
+
filter: templateCopyFilter
|
|
131
|
+
});
|
|
132
|
+
await layerScaffold(targetDir);
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
export { REPO_URL, downloadAndMergeTemplate, layerScaffold, listTemplates };
|
package/dist/_templates.d.ts
CHANGED
|
@@ -21,20 +21,6 @@ export declare function bundledTemplatesDir(): string;
|
|
|
21
21
|
* can never drift.
|
|
22
22
|
*/
|
|
23
23
|
export declare function listTemplates(root?: string): Promise<string[]>;
|
|
24
|
-
type Manifest = Record<string, unknown>;
|
|
25
|
-
/**
|
|
26
|
-
* Fill a manifest's gaps from the scaffold's, `existing` always winning.
|
|
27
|
-
*
|
|
28
|
-
* The same rule the file layering uses, one level deeper: a top-level field
|
|
29
|
-
* the manifest already declares is left alone, and for the three map fields
|
|
30
|
-
* it is each ENTRY that is left alone. Per-entry matters both ways — a
|
|
31
|
-
* workspace manifest pins its `dependencies` to exact installed versions and
|
|
32
|
-
* must keep them, while a single agent-added `devDependencies` entry must not
|
|
33
|
-
* shadow the whole toolchain block.
|
|
34
|
-
*
|
|
35
|
-
* Returns null when nothing was missing, so the common case writes no file.
|
|
36
|
-
*/
|
|
37
|
-
export declare function mergeScaffoldManifest(existing: Manifest, scaffold: Manifest): Manifest | null;
|
|
38
24
|
/**
|
|
39
25
|
* Directory holding the base scaffold — the files every project gets
|
|
40
26
|
* underneath its template (package.json, tsconfig, `.gitignore`, …).
|
|
@@ -45,30 +31,22 @@ export declare function mergeScaffoldManifest(existing: Manifest, scaffold: Mani
|
|
|
45
31
|
*/
|
|
46
32
|
export declare function scaffoldDir(): string;
|
|
47
33
|
/**
|
|
48
|
-
* Layer the base scaffold (package.json, tsconfig, …) into
|
|
49
|
-
* WITHOUT overwriting anything already there. Shared by `aai init`
|
|
34
|
+
* Layer the base scaffold (package.json, tsconfig, `.gitignore`, …) into
|
|
35
|
+
* targetDir WITHOUT overwriting anything already there. Shared by `aai init`
|
|
50
36
|
* (underneath a template) and `aai pull` (underneath the studio workspace
|
|
51
37
|
* files — the workspace stores source, and the scaffold completes it into a
|
|
52
|
-
* runnable project
|
|
53
|
-
* before an in-sandbox build).
|
|
38
|
+
* runnable project).
|
|
54
39
|
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
40
|
+
* The rule itself is `layerScaffoldFiles` in the SDK, over file maps, because
|
|
41
|
+
* this is not its only caller: the studio's GitHub sync commits a workspace to
|
|
42
|
+
* a repository and must complete it identically, and neither package may
|
|
43
|
+
* import the other. This function is only the disk half — read what the rule
|
|
44
|
+
* needs to see, write back what it returns. Only the scaffold's own paths are
|
|
45
|
+
* read from the target: whether a project already has a given file is the one
|
|
46
|
+
* thing the rule asks about it, and `package.json`'s content the one thing it
|
|
47
|
+
* merges.
|
|
59
48
|
*/
|
|
60
49
|
export declare function layerScaffold(targetDir: string): Promise<void>;
|
|
61
|
-
/**
|
|
62
|
-
* `templateCopyFilter` plus the scaffold's own `CLAUDE.md`, which is the
|
|
63
|
-
* authoring guide rather than a file a project wants — see
|
|
64
|
-
* {@link PROJECT_GUIDE_POINTER}.
|
|
65
|
-
*
|
|
66
|
-
* Only the scaffold copy filters it. A TEMPLATE's `CLAUDE.md` would be that
|
|
67
|
-
* template's own notes and belongs in the project it seeds, so
|
|
68
|
-
* {@link downloadAndMergeTemplate} keeps using the unfiltered version. Matched
|
|
69
|
-
* on the full path rather than the basename for the same reason.
|
|
70
|
-
*/
|
|
71
|
-
export declare function scaffoldCopyFilter(src: string, scaffold?: string): boolean;
|
|
72
50
|
/**
|
|
73
51
|
* `fs.cp` filter for every copy OUT of a template or the scaffold — the runtime
|
|
74
52
|
* ones here and the build-time one in `bundle-templates.mjs`.
|
|
@@ -102,4 +80,3 @@ export declare function templateCopyFilter(src: string): boolean;
|
|
|
102
80
|
* Copy a template into targetDir, merging scaffold files underneath.
|
|
103
81
|
*/
|
|
104
82
|
export declare function downloadAndMergeTemplate(template: string, targetDir: string): Promise<void>;
|
|
105
|
-
export {};
|
|
@@ -142,12 +142,15 @@ function projectSpecFiles(cwd) {
|
|
|
142
142
|
* of them, so `aai test` there ran 1 file / 67 tests, printed "Tests passed",
|
|
143
143
|
* and left 211 of the project's 278 tests unrun with nothing saying so.
|
|
144
144
|
*
|
|
145
|
-
* The narrow default
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
145
|
+
* The narrow default did NOT stand, and this set is why. It was defensible on
|
|
146
|
+
* its own terms — one documented file, so a spec that is slow or wants
|
|
147
|
+
* credentials is not dragged into every save — but neither verdict over the
|
|
148
|
+
* difference was liveable: a green one is the false pass above, and the
|
|
149
|
+
* failure that replaced it made bare `aai test` red on every project with a
|
|
150
|
+
* second spec file. So `all` is the default for both gates now and `--only`
|
|
151
|
+
* is the inner loop, and what this set feeds is the honest report of a
|
|
152
|
+
* narrowing somebody asked for: {@link warnUnrunSpecs}'s notice, plus
|
|
153
|
+
* `unrun`/`complete` on `aai test`'s own result for a script to read.
|
|
151
154
|
*/
|
|
152
155
|
function unrunSpecFiles(cwd, ran) {
|
|
153
156
|
const covered = new Set(coveredList(ran));
|
|
@@ -176,20 +179,22 @@ function collectSpecs(dir, prefix, out) {
|
|
|
176
179
|
/**
|
|
177
180
|
* The remedy, named the same way wherever the narrowing is reported.
|
|
178
181
|
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
182
|
+
* It is a bare `aai test` now rather than a flag: the whole suite IS the
|
|
183
|
+
* default, so the remedy for a narrowed run is to stop narrowing it. The
|
|
184
|
+
* project's own `npm test` comes second because it is the command a scaffolded
|
|
185
|
+
* project already ships (`scaffold/package.json`) and runs the same set with
|
|
186
|
+
* nothing to remember.
|
|
183
187
|
*/
|
|
184
|
-
const WIDEN_HINT = "Run
|
|
188
|
+
const WIDEN_HINT = "Run every non-eval spec with a bare `aai test` (the default) or this project's `npm test`; behaviour evals have their own command (`aai eval`).";
|
|
185
189
|
/**
|
|
186
190
|
* Warn, once, naming the spec files this run did not cover.
|
|
187
191
|
*
|
|
188
|
-
* This is the notice for a
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
192
|
+
* This is the notice for a run that covered a SUBSET, and `aai test --only` is
|
|
193
|
+
* the caller it now serves: an author asking for the fast inner loop gets
|
|
194
|
+
* vitest's own summary and then the files that loop did not reach. It was
|
|
195
|
+
* written for `aai build`'s pre-build gate, which ran one file out of eight
|
|
196
|
+
* and printed "Build complete" — that gate passes `all` now, so the notice is
|
|
197
|
+
* silent there, which is the correct end state rather than a lost check.
|
|
193
198
|
*/
|
|
194
199
|
function warnUnrunSpecs(cwd, ran) {
|
|
195
200
|
const skipped = unrunSpecFiles(cwd, ran);
|