cascade-ai 0.66.1 → 0.66.2
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/cli.cjs +281 -193
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +281 -193
- package/dist/cli.js.map +1 -1
- package/dist/desktop-core.cjs +280 -192
- package/dist/index.cjs +280 -192
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +280 -192
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1908,7 +1908,7 @@ function reconcilePrice(model, live) {
|
|
|
1908
1908
|
}
|
|
1909
1909
|
|
|
1910
1910
|
// src/constants.ts
|
|
1911
|
-
var CASCADE_VERSION = "0.66.
|
|
1911
|
+
var CASCADE_VERSION = "0.66.2";
|
|
1912
1912
|
var CASCADE_CONFIG_DIR = ".cascade";
|
|
1913
1913
|
var CASCADE_MD_FILE = "CASCADE.md";
|
|
1914
1914
|
var CASCADE_IGNORE_FILE = ".cascadeignore";
|
|
@@ -6636,7 +6636,15 @@ var KNOWN_TOOLS = [
|
|
|
6636
6636
|
"glob",
|
|
6637
6637
|
"grep",
|
|
6638
6638
|
"web_fetch",
|
|
6639
|
-
|
|
6639
|
+
// Every media tool buildMediaTools can register, not just the image one.
|
|
6640
|
+
// Omitting three of the four meant a run whose ONLY tools were media ones
|
|
6641
|
+
// (a video-generation subtask on an account with no file/web tools) counted
|
|
6642
|
+
// as "no tools registered" and dropped all tool guidance — the worker was
|
|
6643
|
+
// then told nothing about using tools at all, and wrote the video as prose.
|
|
6644
|
+
"generate_image",
|
|
6645
|
+
"generate_video",
|
|
6646
|
+
"generate_speech",
|
|
6647
|
+
"transcribe_audio"
|
|
6640
6648
|
];
|
|
6641
6649
|
var PROVIDER_BACKED_TOOLS = /* @__PURE__ */ new Set([
|
|
6642
6650
|
"generate_image",
|
|
@@ -6665,6 +6673,15 @@ function buildWorkerRules(has) {
|
|
|
6665
6673
|
// reference straight to caption text — telling the model to call
|
|
6666
6674
|
// generate_image for THOSE just pays for an image nobody ever sees.
|
|
6667
6675
|
has("generate_image") && '- When a slide deck (PowerPoint) or Word document deliverable calls for a decorative image or illustration, you MUST call the "generate_image" tool and then reference its result using Markdown image syntax: , where "location" is exactly the string the tool reported back. NEVER write a text placeholder or a bracketed description such as [image: a cat] in its place. Do NOT use "generate_image" for a chart, graph, or diagram that must show exact data (numbers, axes, labels) \u2014 an image model cannot guarantee those values are correct, so render that data as a Markdown table instead. For any OTHER deliverable format (PDF, plain text, code, etc.) do NOT call "generate_image" \u2014 those cannot embed the result, so describe the visual in words instead.',
|
|
6676
|
+
// The video counterpart of the image rule above, and the fix for the
|
|
6677
|
+
// reported "it writes scripts forever and never makes the video" run. The
|
|
6678
|
+
// failure mode is identical — the model narrates the deliverable instead of
|
|
6679
|
+
// producing it — but the stakes are not: a video subtask that ends in prose
|
|
6680
|
+
// has burned the whole pre-production plan for nothing. Unlike the image
|
|
6681
|
+
// rule this is NOT scoped to a document format, because the clip itself is
|
|
6682
|
+
// the deliverable rather than an illustration inside one, and the reference
|
|
6683
|
+
// syntax is a plain link: Markdown image syntax does not embed a video.
|
|
6684
|
+
has("generate_video") && '- When the subtask deliverable is a video, you MUST call the "generate_video" tool \u2014 that call IS the deliverable, and the subtask is not done until it has returned. NEVER deliver the video as prose, a script, a storyboard, or a bracketed placeholder such as [video: a cat skating], and NEVER claim a video exists unless the tool reported a location for it. Call it exactly ONCE: it is billed per second of output and renders for minutes, so a second call charges the user again. Then report the location string the tool returned VERBATIM as your result, referencing it as [description](location) if it goes inside a document. If the tool reports a failure or a timeout, report that failure verbatim and stop \u2014 do NOT call it again, and do NOT substitute a written description of a video that was never made.',
|
|
6668
6685
|
has("run_code") && '- Use the "run_code" tool for any file types (Excel, Zip, csv, etc.) or complex processing not covered by other tools. Always cleanup after code execution.',
|
|
6669
6686
|
"- If you are not making meaningful progress, stop and escalate rather than looping or padding the response.",
|
|
6670
6687
|
has("peer_message") && '- Use the "peer_message" tool to communicate with other T3 workers if your tasks have dependencies or shared state. You can send updates or wait for signals.',
|
|
@@ -7207,6 +7224,12 @@ HIERARCHY CONTEXT: ${this.hierarchyContext}` : "") + textToolSuffix,
|
|
|
7207
7224
|
if (isTaggedSystemic || isProviderBacked && classifyProviderError(err).systemic) {
|
|
7208
7225
|
throw new CriticalToolError(errMsg, tc.name);
|
|
7209
7226
|
}
|
|
7227
|
+
if (isProviderBacked) {
|
|
7228
|
+
throw new CriticalToolError(
|
|
7229
|
+
`${tc.name} failed and was not retried \u2014 media generation is billed per attempt, so Cascade stops on the first failure instead of paying for a second. Reason: ${errMsg}`,
|
|
7230
|
+
tc.name
|
|
7231
|
+
);
|
|
7232
|
+
}
|
|
7210
7233
|
return await this.adaptiveFallback(tc, `Tool error: ${errMsg}`);
|
|
7211
7234
|
}
|
|
7212
7235
|
}
|
|
@@ -7216,6 +7239,14 @@ HIERARCHY CONTEXT: ${this.hierarchyContext}` : "") + textToolSuffix,
|
|
|
7216
7239
|
* 1. Find a semantically similar registered tool and retry with same input
|
|
7217
7240
|
* 2. Synthesize a new tool via ToolCreator (if available) and run it
|
|
7218
7241
|
* 3. Return the original error so the agent loop can decide what to do next
|
|
7242
|
+
*
|
|
7243
|
+
* Scoped to CHEAP, task-scoped failures — the class of problem it was built
|
|
7244
|
+
* for is a wrong or missing tool name, where a name-similar sibling plausibly
|
|
7245
|
+
* does the same job for the same (near-zero) cost. PROVIDER_BACKED_TOOLS never
|
|
7246
|
+
* reach it: their siblings are keyword-similar but semantically different
|
|
7247
|
+
* (generate_image is not a stand-in for generate_video), and every attempt —
|
|
7248
|
+
* theirs, or a synthesized replacement's — is separately billed. See the
|
|
7249
|
+
* fast-fail branch in executeTool().
|
|
7219
7250
|
*/
|
|
7220
7251
|
async adaptiveFallback(tc, originalError) {
|
|
7221
7252
|
const altTool = this.findAlternativeTool(tc.name);
|
|
@@ -7968,15 +7999,244 @@ _(incomplete: ${t2Result.issues.join("; ")})_`;
|
|
|
7968
7999
|
return output;
|
|
7969
8000
|
}
|
|
7970
8001
|
|
|
8002
|
+
// src/core/multimodal/registry.ts
|
|
8003
|
+
var CAPABILITIES = [
|
|
8004
|
+
// ── Image ──
|
|
8005
|
+
{
|
|
8006
|
+
modality: "image",
|
|
8007
|
+
provider: "openai",
|
|
8008
|
+
modelId: "dall-e-3",
|
|
8009
|
+
api: "openai-images"
|
|
8010
|
+
},
|
|
8011
|
+
{
|
|
8012
|
+
// Was `imagen-4.0-generate-001` on `:predict`, which now 404s for new keys
|
|
8013
|
+
// ("no longer available to new users") — Imagen's :predict API is deprecated
|
|
8014
|
+
// and shuts down 2026-08-17. Google's own migration path is this model on
|
|
8015
|
+
// the ordinary generateContent endpoint, so the fix was never another Imagen
|
|
8016
|
+
// id: the whole request/response SHAPE changes, which is why `api` moved to
|
|
8017
|
+
// 'gemini-generate-content' rather than just the modelId moving.
|
|
8018
|
+
// https://ai.google.dev/gemini-api/docs/imagen
|
|
8019
|
+
modality: "image",
|
|
8020
|
+
provider: "gemini",
|
|
8021
|
+
modelId: "gemini-2.5-flash-image",
|
|
8022
|
+
api: "gemini-generate-content"
|
|
8023
|
+
},
|
|
8024
|
+
// ── Speech (text → audio) ──
|
|
8025
|
+
{
|
|
8026
|
+
modality: "speech",
|
|
8027
|
+
provider: "openai",
|
|
8028
|
+
modelId: "tts-1",
|
|
8029
|
+
api: "openai-speech"
|
|
8030
|
+
},
|
|
8031
|
+
{
|
|
8032
|
+
// The only quality claim in this table that needs no leaderboard: OpenAI
|
|
8033
|
+
// ships these as the same voice at two fidelities and charges double for
|
|
8034
|
+
// this one. That is the vendor's own ordering, not an inference.
|
|
8035
|
+
modality: "speech",
|
|
8036
|
+
provider: "openai",
|
|
8037
|
+
modelId: "tts-1-hd",
|
|
8038
|
+
api: "openai-speech",
|
|
8039
|
+
quality: 70,
|
|
8040
|
+
qualityBasis: "OpenAI's own hd variant of tts-1, priced 2x"
|
|
8041
|
+
},
|
|
8042
|
+
// ── Transcription (audio → text) ──
|
|
8043
|
+
{
|
|
8044
|
+
modality: "transcription",
|
|
8045
|
+
provider: "openai",
|
|
8046
|
+
modelId: "whisper-1",
|
|
8047
|
+
api: "openai-transcriptions"
|
|
8048
|
+
},
|
|
8049
|
+
// ── Video ──
|
|
8050
|
+
{
|
|
8051
|
+
// Long-running: submit returns an operation name, the video lands minutes
|
|
8052
|
+
// later, and the bytes come from a short-lived signed URL. generate.ts owns
|
|
8053
|
+
// that polling loop; the registry only records the shape via `api`.
|
|
8054
|
+
//
|
|
8055
|
+
// `veo-3.1-generate-001` (no "-preview") is VERTEX AI's id for this model,
|
|
8056
|
+
// not the Gemini Developer API's — this file calls
|
|
8057
|
+
// generativelanguage.googleapis.com (see generate.ts), which 404s on it:
|
|
8058
|
+
// "models/veo-3.1-generate-001 is not found for API version v1beta". On the
|
|
8059
|
+
// Gemini API specifically, Veo 3.1 is still preview-only, so the correct id
|
|
8060
|
+
// there is `veo-3.1-generate-preview`.
|
|
8061
|
+
// https://ai.google.dev/gemini-api/docs/veo
|
|
8062
|
+
modality: "video",
|
|
8063
|
+
provider: "gemini",
|
|
8064
|
+
modelId: "veo-3.1-generate-preview",
|
|
8065
|
+
api: "gemini-predict-lro"
|
|
8066
|
+
}
|
|
8067
|
+
];
|
|
8068
|
+
function capabilityCost(cap) {
|
|
8069
|
+
const match = findPricing(cap.modelId, cap.provider, {
|
|
8070
|
+
fallbackProviders: cap.provider === "gemini" ? ["vertex"] : []
|
|
8071
|
+
});
|
|
8072
|
+
const rate = match?.entry.rates?.[0];
|
|
8073
|
+
if (!rate) return null;
|
|
8074
|
+
const unitLabel = {
|
|
8075
|
+
per_image: "per image",
|
|
8076
|
+
per_second: "per second of video",
|
|
8077
|
+
per_character: "per character",
|
|
8078
|
+
per_audio_minute: "per audio minute"
|
|
8079
|
+
};
|
|
8080
|
+
const unit = unitLabel[rate.unit] ?? rate.unit;
|
|
8081
|
+
const amount = rate.amount;
|
|
8082
|
+
const shown = amount < 1e-3 ? amount.toExponential(2) : amount.toFixed(4);
|
|
8083
|
+
return { label: `$${shown} ${unit}`, amount, unit };
|
|
8084
|
+
}
|
|
8085
|
+
function explainChoice(c, cost, modality, isBest) {
|
|
8086
|
+
const priced = cost ? ` ${cost.label}.` : "";
|
|
8087
|
+
if (c.quality !== void 0) {
|
|
8088
|
+
return isBest ? `${c.modelId} (${c.provider}) \u2014 ranked highest for ${modality}: ${c.qualityBasis}.${priced}` : `${c.modelId} (${c.provider}) \u2014 ranked alternative for ${modality}: ${c.qualityBasis}.${priced}`;
|
|
8089
|
+
}
|
|
8090
|
+
const noRanking = ". No published quality ranking is applied for this modality, so this is a cost choice, not a quality one.";
|
|
8091
|
+
return isBest ? `${c.modelId} (${c.provider}) \u2014 cheapest usable ${modality} model` + (cost ? ` at ${cost.label}` : "") + noRanking : `${c.modelId} (${c.provider}) \u2014 alternative usable ${modality} model` + (cost ? ` at ${cost.label}` : "") + noRanking;
|
|
8092
|
+
}
|
|
8093
|
+
var MultimodalRegistry = class {
|
|
8094
|
+
/** Provider types the user has actually configured a key for. */
|
|
8095
|
+
available;
|
|
8096
|
+
constructor(availableProviders) {
|
|
8097
|
+
this.available = new Set(availableProviders);
|
|
8098
|
+
}
|
|
8099
|
+
/** Every capability whose provider is configured AND which Cascade can call. */
|
|
8100
|
+
usable(modality) {
|
|
8101
|
+
return CAPABILITIES.filter(
|
|
8102
|
+
(c) => !c.unsupported && this.available.has(c.provider) && (!modality || c.modality === modality)
|
|
8103
|
+
);
|
|
8104
|
+
}
|
|
8105
|
+
/** Modalities this account can actually generate right now. */
|
|
8106
|
+
availableModalities() {
|
|
8107
|
+
return [...new Set(this.usable().map((c) => c.modality))];
|
|
8108
|
+
}
|
|
8109
|
+
/**
|
|
8110
|
+
* Every usable capability for a modality, best first.
|
|
8111
|
+
*
|
|
8112
|
+
* Ranked models beat unranked ones, then higher quality, then lower unit
|
|
8113
|
+
* price. An explicit `preferModel` is moved to the head when it is usable —
|
|
8114
|
+
* the user naming a model is a stronger signal than any prior.
|
|
8115
|
+
*
|
|
8116
|
+
* `select()` is just the head of this list. The TAIL is the point: a systemic
|
|
8117
|
+
* provider failure (dead key, 404, exhausted quota) is scoped to one
|
|
8118
|
+
* provider+model, so "this model cannot draw" is not the same fact as "this
|
|
8119
|
+
* account cannot draw". A caller holding the ordered alternatives can try the
|
|
8120
|
+
* next provider instead of aborting the whole run — see generate-media.ts.
|
|
8121
|
+
*/
|
|
8122
|
+
rank(modality, opts = {}) {
|
|
8123
|
+
const scored = this.usable(modality).map((c) => ({ c, cost: capabilityCost(c) })).sort((a, b) => {
|
|
8124
|
+
const qa = a.c.quality ?? -1;
|
|
8125
|
+
const qb = b.c.quality ?? -1;
|
|
8126
|
+
if (qa !== qb) return qb - qa;
|
|
8127
|
+
const pa = a.cost?.amount ?? Number.POSITIVE_INFINITY;
|
|
8128
|
+
const pb = b.cost?.amount ?? Number.POSITIVE_INFINITY;
|
|
8129
|
+
return pa - pb;
|
|
8130
|
+
});
|
|
8131
|
+
const results = scored.map(({ c, cost }, i) => ({
|
|
8132
|
+
capability: c,
|
|
8133
|
+
cost,
|
|
8134
|
+
reason: explainChoice(c, cost, modality, i === 0)
|
|
8135
|
+
}));
|
|
8136
|
+
if (opts.preferModel) {
|
|
8137
|
+
const i = results.findIndex((r) => r.capability.modelId === opts.preferModel);
|
|
8138
|
+
if (i > -1) {
|
|
8139
|
+
const [wanted] = results.splice(i, 1);
|
|
8140
|
+
results.unshift({ ...wanted, reason: `Requested explicitly: ${wanted.capability.modelId}.` });
|
|
8141
|
+
}
|
|
8142
|
+
}
|
|
8143
|
+
return results;
|
|
8144
|
+
}
|
|
8145
|
+
/**
|
|
8146
|
+
* Pick a model for a modality — the best usable one, or null if there is none.
|
|
8147
|
+
*/
|
|
8148
|
+
select(modality, opts = {}) {
|
|
8149
|
+
return this.rank(modality, opts)[0] ?? null;
|
|
8150
|
+
}
|
|
8151
|
+
/**
|
|
8152
|
+
* A plain-language account of what this account can and cannot generate —
|
|
8153
|
+
* including the things it cannot, and why.
|
|
8154
|
+
*
|
|
8155
|
+
* This is the USER-facing inventory (model ids and unit prices), keyed on
|
|
8156
|
+
* which providers are configured. It is deliberately NOT what the planner
|
|
8157
|
+
* reads: see `describeGenerationForPlanner()` below for that, and the note
|
|
8158
|
+
* there for why the two cannot be the same string.
|
|
8159
|
+
*/
|
|
8160
|
+
describe() {
|
|
8161
|
+
const lines = [];
|
|
8162
|
+
const usable = this.usable();
|
|
8163
|
+
if (usable.length) {
|
|
8164
|
+
lines.push("Generation models available on your configured providers:");
|
|
8165
|
+
for (const modality of ["image", "speech", "transcription", "video"]) {
|
|
8166
|
+
const forModality = usable.filter((c) => c.modality === modality);
|
|
8167
|
+
if (!forModality.length) continue;
|
|
8168
|
+
const shown = forModality.map((c) => {
|
|
8169
|
+
const cost = capabilityCost(c);
|
|
8170
|
+
return `${c.modelId}${cost ? ` (${cost.label})` : ""}`;
|
|
8171
|
+
});
|
|
8172
|
+
lines.push(` ${modality}: ${shown.join(", ")}`);
|
|
8173
|
+
}
|
|
8174
|
+
} else {
|
|
8175
|
+
lines.push("No generation models are available \u2014 none of your configured providers offers one.");
|
|
8176
|
+
}
|
|
8177
|
+
const blocked = CAPABILITIES.filter((c) => c.unsupported && this.available.has(c.provider));
|
|
8178
|
+
for (const c of blocked) {
|
|
8179
|
+
lines.push(` ${c.modality}: ${c.modelId} exists on your account but is not callable. ${c.unsupported}`);
|
|
8180
|
+
}
|
|
8181
|
+
lines.push(
|
|
8182
|
+
" music: no supported provider exposes a music-generation API, so Cascade cannot generate music."
|
|
8183
|
+
);
|
|
8184
|
+
return lines.join("\n");
|
|
8185
|
+
}
|
|
8186
|
+
};
|
|
8187
|
+
var PLANNER_FACTS = [
|
|
8188
|
+
{ tool: "generate_image", modality: "image", shape: "one call returns one finished image" },
|
|
8189
|
+
{ tool: "generate_speech", modality: "speech", shape: "one call returns one finished audio file" },
|
|
8190
|
+
{
|
|
8191
|
+
tool: "generate_video",
|
|
8192
|
+
modality: "video",
|
|
8193
|
+
shape: "one call returns one finished clip, after rendering for 1-3 minutes (Cascade stops waiting at 8)"
|
|
8194
|
+
},
|
|
8195
|
+
{
|
|
8196
|
+
tool: "transcribe_audio",
|
|
8197
|
+
modality: "transcription",
|
|
8198
|
+
shape: "one call returns the transcript of one audio file"
|
|
8199
|
+
}
|
|
8200
|
+
];
|
|
8201
|
+
function plannerPriceNote(modality) {
|
|
8202
|
+
const costs = CAPABILITIES.filter((c) => c.modality === modality && !c.unsupported).map((c) => capabilityCost(c)).filter((c) => c !== null);
|
|
8203
|
+
if (!costs.length) return "";
|
|
8204
|
+
const labels = new Set(costs.map((c) => c.label));
|
|
8205
|
+
if (labels.size === 1) return ` Billed ${costs[0].label}.`;
|
|
8206
|
+
const units = new Set(costs.map((c) => c.unit));
|
|
8207
|
+
return units.size === 1 ? ` Billed ${[...units][0]}.` : "";
|
|
8208
|
+
}
|
|
8209
|
+
function describeGenerationForPlanner(has) {
|
|
8210
|
+
const present = PLANNER_FACTS.filter((f) => has(f.tool));
|
|
8211
|
+
if (!present.length) return "";
|
|
8212
|
+
const lines = ["MEDIA GENERATION \u2014 the only generation tools this run can call:"];
|
|
8213
|
+
for (const f of present) {
|
|
8214
|
+
lines.push(`- "${f.tool}" (${f.modality}): ${f.shape}.${plannerPriceNote(f.modality)}`);
|
|
8215
|
+
}
|
|
8216
|
+
lines.push(
|
|
8217
|
+
"Each one is a single ATOMIC tool call, made by ONE T3 worker, that produces the finished file. It is never a multi-step pipeline, and no worker can satisfy it by describing the result in words.",
|
|
8218
|
+
"No other modality has a tool here \u2014 never plan a step that generates music, 3D or anything not listed above."
|
|
8219
|
+
);
|
|
8220
|
+
if (has("generate_video")) {
|
|
8221
|
+
lines.push(
|
|
8222
|
+
'VIDEO PLANS MUST END IN THE TOOL CALL. Creative pre-production \u2014 a script, a shot list, direction notes \u2014 is expected and worth planning, but it is NOT the video. Any plan that involves video MUST contain exactly ONE subtask whose deliverable is the "generate_video" call itself; it MUST be the last subtask on that path (dependsOn the pre-production ones), and nothing after it may be required to produce the clip. Never end a video plan on a script, a storyboard or a review step. Never split one clip across several "generate_video" subtasks, and never plan a render \u2192 critique \u2192 re-render loop: every render is billed again and takes minutes.'
|
|
8223
|
+
);
|
|
8224
|
+
}
|
|
8225
|
+
return lines.join("\n");
|
|
8226
|
+
}
|
|
8227
|
+
|
|
7971
8228
|
// src/core/tiers/t2-manager.ts
|
|
7972
|
-
function buildT2SystemPrompt(
|
|
8229
|
+
function buildT2SystemPrompt(has) {
|
|
8230
|
+
const generation = describeGenerationForPlanner(has);
|
|
7973
8231
|
return [
|
|
7974
8232
|
"You are a T2 Manager agent in the Cascade AI system.",
|
|
7975
8233
|
"Your role is to analyze a section of a task and decompose it into 2-5 discrete subtasks for T3 Workers.",
|
|
7976
8234
|
'If subtasks have dependencies, you can specify "executionMode": "sequential" for the section.',
|
|
7977
|
-
|
|
7978
|
-
"Return ONLY valid JSON matching the T3 subtask array schema \u2014 no other text."
|
|
7979
|
-
|
|
8235
|
+
has("peer_message") && 'Provide "peerT3Ids" to subtasks so they can coordinate using the peer_message tool.',
|
|
8236
|
+
"Return ONLY valid JSON matching the T3 subtask array schema \u2014 no other text.",
|
|
8237
|
+
generation && `
|
|
8238
|
+
${generation}`
|
|
8239
|
+
].filter((l) => l !== false && l !== "").join("\n");
|
|
7980
8240
|
}
|
|
7981
8241
|
var T2Manager = class extends BaseTier {
|
|
7982
8242
|
router;
|
|
@@ -8273,7 +8533,7 @@ Return ONLY the JSON array.`;
|
|
|
8273
8533
|
const messages = [{ role: "user", content: prompt }];
|
|
8274
8534
|
const result = await this.router.generate("T2", {
|
|
8275
8535
|
messages,
|
|
8276
|
-
systemPrompt: this.systemPromptOverride + buildT2SystemPrompt(this.toolRegistry.hasTool(
|
|
8536
|
+
systemPrompt: this.systemPromptOverride + buildT2SystemPrompt((name) => this.toolRegistry.hasTool(name)) + (this.hierarchyContext ? `
|
|
8277
8537
|
|
|
8278
8538
|
HIERARCHY CONTEXT: ${this.hierarchyContext}` : ""),
|
|
8279
8539
|
maxTokens: 2e3,
|
|
@@ -8823,6 +9083,7 @@ function isStrongKeywordOverlap(a = [], b = []) {
|
|
|
8823
9083
|
}
|
|
8824
9084
|
function buildT1SystemPrompt(has) {
|
|
8825
9085
|
const canWriteArtifacts = has("file_write") || has("file_edit") || has("run_code") || has("pdf_create");
|
|
9086
|
+
const generation = describeGenerationForPlanner(has);
|
|
8826
9087
|
const rules = [
|
|
8827
9088
|
"- Simple \u2192 1 T3, Moderate \u2192 2-3 T2s, Complex \u2192 3-5 T2s, Highly Complex \u2192 5+ T2s",
|
|
8828
9089
|
"- Return ONLY valid JSON \u2014 no other text",
|
|
@@ -8857,7 +9118,9 @@ DEPENDENCY GUIDANCE:
|
|
|
8857
9118
|
QUALITY RULES:
|
|
8858
9119
|
- Each section must have a clear, testable "expectedOutput" so T2 knows when it is done.
|
|
8859
9120
|
- Do NOT create trivial sections that only move files or print summaries \u2014 fold those into adjacent sections.
|
|
8860
|
-
- If the plan would naturally produce fewer than 2 independent sections, prefer Moderate routing (single T2)
|
|
9121
|
+
- If the plan would naturally produce fewer than 2 independent sections, prefer Moderate routing (single T2).${generation ? `
|
|
9122
|
+
|
|
9123
|
+
${generation}` : ""}`;
|
|
8861
9124
|
}
|
|
8862
9125
|
var T1Administrator = class extends BaseTier {
|
|
8863
9126
|
router;
|
|
@@ -9552,188 +9815,6 @@ Reply with exactly one word: YES, NO, or UNSURE.
|
|
|
9552
9815
|
}
|
|
9553
9816
|
};
|
|
9554
9817
|
|
|
9555
|
-
// src/core/multimodal/registry.ts
|
|
9556
|
-
var CAPABILITIES = [
|
|
9557
|
-
// ── Image ──
|
|
9558
|
-
{
|
|
9559
|
-
modality: "image",
|
|
9560
|
-
provider: "openai",
|
|
9561
|
-
modelId: "dall-e-3",
|
|
9562
|
-
api: "openai-images"
|
|
9563
|
-
},
|
|
9564
|
-
{
|
|
9565
|
-
// Was `imagen-4.0-generate-001` on `:predict`, which now 404s for new keys
|
|
9566
|
-
// ("no longer available to new users") — Imagen's :predict API is deprecated
|
|
9567
|
-
// and shuts down 2026-08-17. Google's own migration path is this model on
|
|
9568
|
-
// the ordinary generateContent endpoint, so the fix was never another Imagen
|
|
9569
|
-
// id: the whole request/response SHAPE changes, which is why `api` moved to
|
|
9570
|
-
// 'gemini-generate-content' rather than just the modelId moving.
|
|
9571
|
-
// https://ai.google.dev/gemini-api/docs/imagen
|
|
9572
|
-
modality: "image",
|
|
9573
|
-
provider: "gemini",
|
|
9574
|
-
modelId: "gemini-2.5-flash-image",
|
|
9575
|
-
api: "gemini-generate-content"
|
|
9576
|
-
},
|
|
9577
|
-
// ── Speech (text → audio) ──
|
|
9578
|
-
{
|
|
9579
|
-
modality: "speech",
|
|
9580
|
-
provider: "openai",
|
|
9581
|
-
modelId: "tts-1",
|
|
9582
|
-
api: "openai-speech"
|
|
9583
|
-
},
|
|
9584
|
-
{
|
|
9585
|
-
// The only quality claim in this table that needs no leaderboard: OpenAI
|
|
9586
|
-
// ships these as the same voice at two fidelities and charges double for
|
|
9587
|
-
// this one. That is the vendor's own ordering, not an inference.
|
|
9588
|
-
modality: "speech",
|
|
9589
|
-
provider: "openai",
|
|
9590
|
-
modelId: "tts-1-hd",
|
|
9591
|
-
api: "openai-speech",
|
|
9592
|
-
quality: 70,
|
|
9593
|
-
qualityBasis: "OpenAI's own hd variant of tts-1, priced 2x"
|
|
9594
|
-
},
|
|
9595
|
-
// ── Transcription (audio → text) ──
|
|
9596
|
-
{
|
|
9597
|
-
modality: "transcription",
|
|
9598
|
-
provider: "openai",
|
|
9599
|
-
modelId: "whisper-1",
|
|
9600
|
-
api: "openai-transcriptions"
|
|
9601
|
-
},
|
|
9602
|
-
// ── Video ──
|
|
9603
|
-
{
|
|
9604
|
-
// Long-running: submit returns an operation name, the video lands minutes
|
|
9605
|
-
// later, and the bytes come from a short-lived signed URL. generate.ts owns
|
|
9606
|
-
// that polling loop; the registry only records the shape via `api`.
|
|
9607
|
-
//
|
|
9608
|
-
// `veo-3.1-generate-001` (no "-preview") is VERTEX AI's id for this model,
|
|
9609
|
-
// not the Gemini Developer API's — this file calls
|
|
9610
|
-
// generativelanguage.googleapis.com (see generate.ts), which 404s on it:
|
|
9611
|
-
// "models/veo-3.1-generate-001 is not found for API version v1beta". On the
|
|
9612
|
-
// Gemini API specifically, Veo 3.1 is still preview-only, so the correct id
|
|
9613
|
-
// there is `veo-3.1-generate-preview`.
|
|
9614
|
-
// https://ai.google.dev/gemini-api/docs/veo
|
|
9615
|
-
modality: "video",
|
|
9616
|
-
provider: "gemini",
|
|
9617
|
-
modelId: "veo-3.1-generate-preview",
|
|
9618
|
-
api: "gemini-predict-lro"
|
|
9619
|
-
}
|
|
9620
|
-
];
|
|
9621
|
-
function capabilityCost(cap) {
|
|
9622
|
-
const match = findPricing(cap.modelId, cap.provider, {
|
|
9623
|
-
fallbackProviders: cap.provider === "gemini" ? ["vertex"] : []
|
|
9624
|
-
});
|
|
9625
|
-
const rate = match?.entry.rates?.[0];
|
|
9626
|
-
if (!rate) return null;
|
|
9627
|
-
const unitLabel = {
|
|
9628
|
-
per_image: "per image",
|
|
9629
|
-
per_second: "per second of video",
|
|
9630
|
-
per_character: "per character",
|
|
9631
|
-
per_audio_minute: "per audio minute"
|
|
9632
|
-
};
|
|
9633
|
-
const unit = unitLabel[rate.unit] ?? rate.unit;
|
|
9634
|
-
const amount = rate.amount;
|
|
9635
|
-
const shown = amount < 1e-3 ? amount.toExponential(2) : amount.toFixed(4);
|
|
9636
|
-
return { label: `$${shown} ${unit}`, amount, unit };
|
|
9637
|
-
}
|
|
9638
|
-
function explainChoice(c, cost, modality, isBest) {
|
|
9639
|
-
const priced = cost ? ` ${cost.label}.` : "";
|
|
9640
|
-
if (c.quality !== void 0) {
|
|
9641
|
-
return isBest ? `${c.modelId} (${c.provider}) \u2014 ranked highest for ${modality}: ${c.qualityBasis}.${priced}` : `${c.modelId} (${c.provider}) \u2014 ranked alternative for ${modality}: ${c.qualityBasis}.${priced}`;
|
|
9642
|
-
}
|
|
9643
|
-
const noRanking = ". No published quality ranking is applied for this modality, so this is a cost choice, not a quality one.";
|
|
9644
|
-
return isBest ? `${c.modelId} (${c.provider}) \u2014 cheapest usable ${modality} model` + (cost ? ` at ${cost.label}` : "") + noRanking : `${c.modelId} (${c.provider}) \u2014 alternative usable ${modality} model` + (cost ? ` at ${cost.label}` : "") + noRanking;
|
|
9645
|
-
}
|
|
9646
|
-
var MultimodalRegistry = class {
|
|
9647
|
-
/** Provider types the user has actually configured a key for. */
|
|
9648
|
-
available;
|
|
9649
|
-
constructor(availableProviders) {
|
|
9650
|
-
this.available = new Set(availableProviders);
|
|
9651
|
-
}
|
|
9652
|
-
/** Every capability whose provider is configured AND which Cascade can call. */
|
|
9653
|
-
usable(modality) {
|
|
9654
|
-
return CAPABILITIES.filter(
|
|
9655
|
-
(c) => !c.unsupported && this.available.has(c.provider) && (!modality || c.modality === modality)
|
|
9656
|
-
);
|
|
9657
|
-
}
|
|
9658
|
-
/** Modalities this account can actually generate right now. */
|
|
9659
|
-
availableModalities() {
|
|
9660
|
-
return [...new Set(this.usable().map((c) => c.modality))];
|
|
9661
|
-
}
|
|
9662
|
-
/**
|
|
9663
|
-
* Every usable capability for a modality, best first.
|
|
9664
|
-
*
|
|
9665
|
-
* Ranked models beat unranked ones, then higher quality, then lower unit
|
|
9666
|
-
* price. An explicit `preferModel` is moved to the head when it is usable —
|
|
9667
|
-
* the user naming a model is a stronger signal than any prior.
|
|
9668
|
-
*
|
|
9669
|
-
* `select()` is just the head of this list. The TAIL is the point: a systemic
|
|
9670
|
-
* provider failure (dead key, 404, exhausted quota) is scoped to one
|
|
9671
|
-
* provider+model, so "this model cannot draw" is not the same fact as "this
|
|
9672
|
-
* account cannot draw". A caller holding the ordered alternatives can try the
|
|
9673
|
-
* next provider instead of aborting the whole run — see generate-media.ts.
|
|
9674
|
-
*/
|
|
9675
|
-
rank(modality, opts = {}) {
|
|
9676
|
-
const scored = this.usable(modality).map((c) => ({ c, cost: capabilityCost(c) })).sort((a, b) => {
|
|
9677
|
-
const qa = a.c.quality ?? -1;
|
|
9678
|
-
const qb = b.c.quality ?? -1;
|
|
9679
|
-
if (qa !== qb) return qb - qa;
|
|
9680
|
-
const pa = a.cost?.amount ?? Number.POSITIVE_INFINITY;
|
|
9681
|
-
const pb = b.cost?.amount ?? Number.POSITIVE_INFINITY;
|
|
9682
|
-
return pa - pb;
|
|
9683
|
-
});
|
|
9684
|
-
const results = scored.map(({ c, cost }, i) => ({
|
|
9685
|
-
capability: c,
|
|
9686
|
-
cost,
|
|
9687
|
-
reason: explainChoice(c, cost, modality, i === 0)
|
|
9688
|
-
}));
|
|
9689
|
-
if (opts.preferModel) {
|
|
9690
|
-
const i = results.findIndex((r) => r.capability.modelId === opts.preferModel);
|
|
9691
|
-
if (i > -1) {
|
|
9692
|
-
const [wanted] = results.splice(i, 1);
|
|
9693
|
-
results.unshift({ ...wanted, reason: `Requested explicitly: ${wanted.capability.modelId}.` });
|
|
9694
|
-
}
|
|
9695
|
-
}
|
|
9696
|
-
return results;
|
|
9697
|
-
}
|
|
9698
|
-
/**
|
|
9699
|
-
* Pick a model for a modality — the best usable one, or null if there is none.
|
|
9700
|
-
*/
|
|
9701
|
-
select(modality, opts = {}) {
|
|
9702
|
-
return this.rank(modality, opts)[0] ?? null;
|
|
9703
|
-
}
|
|
9704
|
-
/**
|
|
9705
|
-
* A plain-language account of what this account can and cannot generate —
|
|
9706
|
-
* including the things it cannot, and why. The planner sees this, so being
|
|
9707
|
-
* candid here is what stops it inventing a `generate_music` call.
|
|
9708
|
-
*/
|
|
9709
|
-
describe() {
|
|
9710
|
-
const lines = [];
|
|
9711
|
-
const usable = this.usable();
|
|
9712
|
-
if (usable.length) {
|
|
9713
|
-
lines.push("Generation models available on your configured providers:");
|
|
9714
|
-
for (const modality of ["image", "speech", "transcription", "video"]) {
|
|
9715
|
-
const forModality = usable.filter((c) => c.modality === modality);
|
|
9716
|
-
if (!forModality.length) continue;
|
|
9717
|
-
const shown = forModality.map((c) => {
|
|
9718
|
-
const cost = capabilityCost(c);
|
|
9719
|
-
return `${c.modelId}${cost ? ` (${cost.label})` : ""}`;
|
|
9720
|
-
});
|
|
9721
|
-
lines.push(` ${modality}: ${shown.join(", ")}`);
|
|
9722
|
-
}
|
|
9723
|
-
} else {
|
|
9724
|
-
lines.push("No generation models are available \u2014 none of your configured providers offers one.");
|
|
9725
|
-
}
|
|
9726
|
-
const blocked = CAPABILITIES.filter((c) => c.unsupported && this.available.has(c.provider));
|
|
9727
|
-
for (const c of blocked) {
|
|
9728
|
-
lines.push(` ${c.modality}: ${c.modelId} exists on your account but is not callable. ${c.unsupported}`);
|
|
9729
|
-
}
|
|
9730
|
-
lines.push(
|
|
9731
|
-
" music: no supported provider exposes a music-generation API, so Cascade cannot generate music."
|
|
9732
|
-
);
|
|
9733
|
-
return lines.join("\n");
|
|
9734
|
-
}
|
|
9735
|
-
};
|
|
9736
|
-
|
|
9737
9818
|
// src/tools/base.ts
|
|
9738
9819
|
var BaseTool = class {
|
|
9739
9820
|
workspaceRoot = process.cwd();
|
|
@@ -9754,10 +9835,17 @@ var BaseTool = class {
|
|
|
9754
9835
|
|
|
9755
9836
|
// src/core/multimodal/generate.ts
|
|
9756
9837
|
var DEFAULT_TIMEOUT_MS = 12e4;
|
|
9838
|
+
var GenerationGaveUpError = class extends Error {
|
|
9839
|
+
constructor(message) {
|
|
9840
|
+
super(message);
|
|
9841
|
+
this.name = "GenerationGaveUpError";
|
|
9842
|
+
}
|
|
9843
|
+
};
|
|
9757
9844
|
async function callProvider(fn, modelId) {
|
|
9758
9845
|
try {
|
|
9759
9846
|
return await fn();
|
|
9760
9847
|
} catch (err) {
|
|
9848
|
+
if (err instanceof GenerationGaveUpError) throw err;
|
|
9761
9849
|
const classified = classifyProviderError(err);
|
|
9762
9850
|
throw new Error(describeProviderError(classified, modelId));
|
|
9763
9851
|
}
|
|
@@ -9955,8 +10043,8 @@ async function generateVideo(cap, cfg, req, signal, onProgress) {
|
|
|
9955
10043
|
onProgress?.("Still rendering\u2026");
|
|
9956
10044
|
}
|
|
9957
10045
|
if (!operation.done) {
|
|
9958
|
-
throw new
|
|
9959
|
-
|
|
10046
|
+
throw new GenerationGaveUpError(
|
|
10047
|
+
`${cap.modelId} timed out after ${Math.round(VIDEO_TIMEOUT_MS / 6e4)} minutes \u2014 no video was produced. Cascade stopped waiting; the render may still finish on the provider side, but nothing was saved. Try again with a shorter clip or a simpler prompt.`
|
|
9960
10048
|
);
|
|
9961
10049
|
}
|
|
9962
10050
|
if (operation.error?.message) throw new Error(operation.error.message);
|