cascade-ai 0.66.0 → 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.d.cts
CHANGED
|
@@ -2948,6 +2948,14 @@ declare class T3Worker extends BaseTier {
|
|
|
2948
2948
|
* 1. Find a semantically similar registered tool and retry with same input
|
|
2949
2949
|
* 2. Synthesize a new tool via ToolCreator (if available) and run it
|
|
2950
2950
|
* 3. Return the original error so the agent loop can decide what to do next
|
|
2951
|
+
*
|
|
2952
|
+
* Scoped to CHEAP, task-scoped failures — the class of problem it was built
|
|
2953
|
+
* for is a wrong or missing tool name, where a name-similar sibling plausibly
|
|
2954
|
+
* does the same job for the same (near-zero) cost. PROVIDER_BACKED_TOOLS never
|
|
2955
|
+
* reach it: their siblings are keyword-similar but semantically different
|
|
2956
|
+
* (generate_image is not a stand-in for generate_video), and every attempt —
|
|
2957
|
+
* theirs, or a synthesized replacement's — is separately billed. See the
|
|
2958
|
+
* fast-fail branch in executeTool().
|
|
2951
2959
|
*/
|
|
2952
2960
|
private adaptiveFallback;
|
|
2953
2961
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -2948,6 +2948,14 @@ declare class T3Worker extends BaseTier {
|
|
|
2948
2948
|
* 1. Find a semantically similar registered tool and retry with same input
|
|
2949
2949
|
* 2. Synthesize a new tool via ToolCreator (if available) and run it
|
|
2950
2950
|
* 3. Return the original error so the agent loop can decide what to do next
|
|
2951
|
+
*
|
|
2952
|
+
* Scoped to CHEAP, task-scoped failures — the class of problem it was built
|
|
2953
|
+
* for is a wrong or missing tool name, where a name-similar sibling plausibly
|
|
2954
|
+
* does the same job for the same (near-zero) cost. PROVIDER_BACKED_TOOLS never
|
|
2955
|
+
* reach it: their siblings are keyword-similar but semantically different
|
|
2956
|
+
* (generate_image is not a stand-in for generate_video), and every attempt —
|
|
2957
|
+
* theirs, or a synthesized replacement's — is separately billed. See the
|
|
2958
|
+
* fast-fail branch in executeTool().
|
|
2951
2959
|
*/
|
|
2952
2960
|
private adaptiveFallback;
|
|
2953
2961
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1862,7 +1862,7 @@ function reconcilePrice(model, live) {
|
|
|
1862
1862
|
}
|
|
1863
1863
|
|
|
1864
1864
|
// src/constants.ts
|
|
1865
|
-
var CASCADE_VERSION = "0.66.
|
|
1865
|
+
var CASCADE_VERSION = "0.66.2";
|
|
1866
1866
|
var CASCADE_CONFIG_DIR = ".cascade";
|
|
1867
1867
|
var CASCADE_MD_FILE = "CASCADE.md";
|
|
1868
1868
|
var CASCADE_IGNORE_FILE = ".cascadeignore";
|
|
@@ -6590,7 +6590,15 @@ var KNOWN_TOOLS = [
|
|
|
6590
6590
|
"glob",
|
|
6591
6591
|
"grep",
|
|
6592
6592
|
"web_fetch",
|
|
6593
|
-
|
|
6593
|
+
// Every media tool buildMediaTools can register, not just the image one.
|
|
6594
|
+
// Omitting three of the four meant a run whose ONLY tools were media ones
|
|
6595
|
+
// (a video-generation subtask on an account with no file/web tools) counted
|
|
6596
|
+
// as "no tools registered" and dropped all tool guidance — the worker was
|
|
6597
|
+
// then told nothing about using tools at all, and wrote the video as prose.
|
|
6598
|
+
"generate_image",
|
|
6599
|
+
"generate_video",
|
|
6600
|
+
"generate_speech",
|
|
6601
|
+
"transcribe_audio"
|
|
6594
6602
|
];
|
|
6595
6603
|
var PROVIDER_BACKED_TOOLS = /* @__PURE__ */ new Set([
|
|
6596
6604
|
"generate_image",
|
|
@@ -6619,6 +6627,15 @@ function buildWorkerRules(has) {
|
|
|
6619
6627
|
// reference straight to caption text — telling the model to call
|
|
6620
6628
|
// generate_image for THOSE just pays for an image nobody ever sees.
|
|
6621
6629
|
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.',
|
|
6630
|
+
// The video counterpart of the image rule above, and the fix for the
|
|
6631
|
+
// reported "it writes scripts forever and never makes the video" run. The
|
|
6632
|
+
// failure mode is identical — the model narrates the deliverable instead of
|
|
6633
|
+
// producing it — but the stakes are not: a video subtask that ends in prose
|
|
6634
|
+
// has burned the whole pre-production plan for nothing. Unlike the image
|
|
6635
|
+
// rule this is NOT scoped to a document format, because the clip itself is
|
|
6636
|
+
// the deliverable rather than an illustration inside one, and the reference
|
|
6637
|
+
// syntax is a plain link: Markdown image syntax does not embed a video.
|
|
6638
|
+
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.',
|
|
6622
6639
|
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.',
|
|
6623
6640
|
"- If you are not making meaningful progress, stop and escalate rather than looping or padding the response.",
|
|
6624
6641
|
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.',
|
|
@@ -7161,6 +7178,12 @@ HIERARCHY CONTEXT: ${this.hierarchyContext}` : "") + textToolSuffix,
|
|
|
7161
7178
|
if (isTaggedSystemic || isProviderBacked && classifyProviderError(err).systemic) {
|
|
7162
7179
|
throw new CriticalToolError(errMsg, tc.name);
|
|
7163
7180
|
}
|
|
7181
|
+
if (isProviderBacked) {
|
|
7182
|
+
throw new CriticalToolError(
|
|
7183
|
+
`${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}`,
|
|
7184
|
+
tc.name
|
|
7185
|
+
);
|
|
7186
|
+
}
|
|
7164
7187
|
return await this.adaptiveFallback(tc, `Tool error: ${errMsg}`);
|
|
7165
7188
|
}
|
|
7166
7189
|
}
|
|
@@ -7170,6 +7193,14 @@ HIERARCHY CONTEXT: ${this.hierarchyContext}` : "") + textToolSuffix,
|
|
|
7170
7193
|
* 1. Find a semantically similar registered tool and retry with same input
|
|
7171
7194
|
* 2. Synthesize a new tool via ToolCreator (if available) and run it
|
|
7172
7195
|
* 3. Return the original error so the agent loop can decide what to do next
|
|
7196
|
+
*
|
|
7197
|
+
* Scoped to CHEAP, task-scoped failures — the class of problem it was built
|
|
7198
|
+
* for is a wrong or missing tool name, where a name-similar sibling plausibly
|
|
7199
|
+
* does the same job for the same (near-zero) cost. PROVIDER_BACKED_TOOLS never
|
|
7200
|
+
* reach it: their siblings are keyword-similar but semantically different
|
|
7201
|
+
* (generate_image is not a stand-in for generate_video), and every attempt —
|
|
7202
|
+
* theirs, or a synthesized replacement's — is separately billed. See the
|
|
7203
|
+
* fast-fail branch in executeTool().
|
|
7173
7204
|
*/
|
|
7174
7205
|
async adaptiveFallback(tc, originalError) {
|
|
7175
7206
|
const altTool = this.findAlternativeTool(tc.name);
|
|
@@ -7922,15 +7953,244 @@ _(incomplete: ${t2Result.issues.join("; ")})_`;
|
|
|
7922
7953
|
return output;
|
|
7923
7954
|
}
|
|
7924
7955
|
|
|
7956
|
+
// src/core/multimodal/registry.ts
|
|
7957
|
+
var CAPABILITIES = [
|
|
7958
|
+
// ── Image ──
|
|
7959
|
+
{
|
|
7960
|
+
modality: "image",
|
|
7961
|
+
provider: "openai",
|
|
7962
|
+
modelId: "dall-e-3",
|
|
7963
|
+
api: "openai-images"
|
|
7964
|
+
},
|
|
7965
|
+
{
|
|
7966
|
+
// Was `imagen-4.0-generate-001` on `:predict`, which now 404s for new keys
|
|
7967
|
+
// ("no longer available to new users") — Imagen's :predict API is deprecated
|
|
7968
|
+
// and shuts down 2026-08-17. Google's own migration path is this model on
|
|
7969
|
+
// the ordinary generateContent endpoint, so the fix was never another Imagen
|
|
7970
|
+
// id: the whole request/response SHAPE changes, which is why `api` moved to
|
|
7971
|
+
// 'gemini-generate-content' rather than just the modelId moving.
|
|
7972
|
+
// https://ai.google.dev/gemini-api/docs/imagen
|
|
7973
|
+
modality: "image",
|
|
7974
|
+
provider: "gemini",
|
|
7975
|
+
modelId: "gemini-2.5-flash-image",
|
|
7976
|
+
api: "gemini-generate-content"
|
|
7977
|
+
},
|
|
7978
|
+
// ── Speech (text → audio) ──
|
|
7979
|
+
{
|
|
7980
|
+
modality: "speech",
|
|
7981
|
+
provider: "openai",
|
|
7982
|
+
modelId: "tts-1",
|
|
7983
|
+
api: "openai-speech"
|
|
7984
|
+
},
|
|
7985
|
+
{
|
|
7986
|
+
// The only quality claim in this table that needs no leaderboard: OpenAI
|
|
7987
|
+
// ships these as the same voice at two fidelities and charges double for
|
|
7988
|
+
// this one. That is the vendor's own ordering, not an inference.
|
|
7989
|
+
modality: "speech",
|
|
7990
|
+
provider: "openai",
|
|
7991
|
+
modelId: "tts-1-hd",
|
|
7992
|
+
api: "openai-speech",
|
|
7993
|
+
quality: 70,
|
|
7994
|
+
qualityBasis: "OpenAI's own hd variant of tts-1, priced 2x"
|
|
7995
|
+
},
|
|
7996
|
+
// ── Transcription (audio → text) ──
|
|
7997
|
+
{
|
|
7998
|
+
modality: "transcription",
|
|
7999
|
+
provider: "openai",
|
|
8000
|
+
modelId: "whisper-1",
|
|
8001
|
+
api: "openai-transcriptions"
|
|
8002
|
+
},
|
|
8003
|
+
// ── Video ──
|
|
8004
|
+
{
|
|
8005
|
+
// Long-running: submit returns an operation name, the video lands minutes
|
|
8006
|
+
// later, and the bytes come from a short-lived signed URL. generate.ts owns
|
|
8007
|
+
// that polling loop; the registry only records the shape via `api`.
|
|
8008
|
+
//
|
|
8009
|
+
// `veo-3.1-generate-001` (no "-preview") is VERTEX AI's id for this model,
|
|
8010
|
+
// not the Gemini Developer API's — this file calls
|
|
8011
|
+
// generativelanguage.googleapis.com (see generate.ts), which 404s on it:
|
|
8012
|
+
// "models/veo-3.1-generate-001 is not found for API version v1beta". On the
|
|
8013
|
+
// Gemini API specifically, Veo 3.1 is still preview-only, so the correct id
|
|
8014
|
+
// there is `veo-3.1-generate-preview`.
|
|
8015
|
+
// https://ai.google.dev/gemini-api/docs/veo
|
|
8016
|
+
modality: "video",
|
|
8017
|
+
provider: "gemini",
|
|
8018
|
+
modelId: "veo-3.1-generate-preview",
|
|
8019
|
+
api: "gemini-predict-lro"
|
|
8020
|
+
}
|
|
8021
|
+
];
|
|
8022
|
+
function capabilityCost(cap) {
|
|
8023
|
+
const match = findPricing(cap.modelId, cap.provider, {
|
|
8024
|
+
fallbackProviders: cap.provider === "gemini" ? ["vertex"] : []
|
|
8025
|
+
});
|
|
8026
|
+
const rate = match?.entry.rates?.[0];
|
|
8027
|
+
if (!rate) return null;
|
|
8028
|
+
const unitLabel = {
|
|
8029
|
+
per_image: "per image",
|
|
8030
|
+
per_second: "per second of video",
|
|
8031
|
+
per_character: "per character",
|
|
8032
|
+
per_audio_minute: "per audio minute"
|
|
8033
|
+
};
|
|
8034
|
+
const unit = unitLabel[rate.unit] ?? rate.unit;
|
|
8035
|
+
const amount = rate.amount;
|
|
8036
|
+
const shown = amount < 1e-3 ? amount.toExponential(2) : amount.toFixed(4);
|
|
8037
|
+
return { label: `$${shown} ${unit}`, amount, unit };
|
|
8038
|
+
}
|
|
8039
|
+
function explainChoice(c, cost, modality, isBest) {
|
|
8040
|
+
const priced = cost ? ` ${cost.label}.` : "";
|
|
8041
|
+
if (c.quality !== void 0) {
|
|
8042
|
+
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}`;
|
|
8043
|
+
}
|
|
8044
|
+
const noRanking = ". No published quality ranking is applied for this modality, so this is a cost choice, not a quality one.";
|
|
8045
|
+
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;
|
|
8046
|
+
}
|
|
8047
|
+
var MultimodalRegistry = class {
|
|
8048
|
+
/** Provider types the user has actually configured a key for. */
|
|
8049
|
+
available;
|
|
8050
|
+
constructor(availableProviders) {
|
|
8051
|
+
this.available = new Set(availableProviders);
|
|
8052
|
+
}
|
|
8053
|
+
/** Every capability whose provider is configured AND which Cascade can call. */
|
|
8054
|
+
usable(modality) {
|
|
8055
|
+
return CAPABILITIES.filter(
|
|
8056
|
+
(c) => !c.unsupported && this.available.has(c.provider) && (!modality || c.modality === modality)
|
|
8057
|
+
);
|
|
8058
|
+
}
|
|
8059
|
+
/** Modalities this account can actually generate right now. */
|
|
8060
|
+
availableModalities() {
|
|
8061
|
+
return [...new Set(this.usable().map((c) => c.modality))];
|
|
8062
|
+
}
|
|
8063
|
+
/**
|
|
8064
|
+
* Every usable capability for a modality, best first.
|
|
8065
|
+
*
|
|
8066
|
+
* Ranked models beat unranked ones, then higher quality, then lower unit
|
|
8067
|
+
* price. An explicit `preferModel` is moved to the head when it is usable —
|
|
8068
|
+
* the user naming a model is a stronger signal than any prior.
|
|
8069
|
+
*
|
|
8070
|
+
* `select()` is just the head of this list. The TAIL is the point: a systemic
|
|
8071
|
+
* provider failure (dead key, 404, exhausted quota) is scoped to one
|
|
8072
|
+
* provider+model, so "this model cannot draw" is not the same fact as "this
|
|
8073
|
+
* account cannot draw". A caller holding the ordered alternatives can try the
|
|
8074
|
+
* next provider instead of aborting the whole run — see generate-media.ts.
|
|
8075
|
+
*/
|
|
8076
|
+
rank(modality, opts = {}) {
|
|
8077
|
+
const scored = this.usable(modality).map((c) => ({ c, cost: capabilityCost(c) })).sort((a, b) => {
|
|
8078
|
+
const qa = a.c.quality ?? -1;
|
|
8079
|
+
const qb = b.c.quality ?? -1;
|
|
8080
|
+
if (qa !== qb) return qb - qa;
|
|
8081
|
+
const pa = a.cost?.amount ?? Number.POSITIVE_INFINITY;
|
|
8082
|
+
const pb = b.cost?.amount ?? Number.POSITIVE_INFINITY;
|
|
8083
|
+
return pa - pb;
|
|
8084
|
+
});
|
|
8085
|
+
const results = scored.map(({ c, cost }, i) => ({
|
|
8086
|
+
capability: c,
|
|
8087
|
+
cost,
|
|
8088
|
+
reason: explainChoice(c, cost, modality, i === 0)
|
|
8089
|
+
}));
|
|
8090
|
+
if (opts.preferModel) {
|
|
8091
|
+
const i = results.findIndex((r) => r.capability.modelId === opts.preferModel);
|
|
8092
|
+
if (i > -1) {
|
|
8093
|
+
const [wanted] = results.splice(i, 1);
|
|
8094
|
+
results.unshift({ ...wanted, reason: `Requested explicitly: ${wanted.capability.modelId}.` });
|
|
8095
|
+
}
|
|
8096
|
+
}
|
|
8097
|
+
return results;
|
|
8098
|
+
}
|
|
8099
|
+
/**
|
|
8100
|
+
* Pick a model for a modality — the best usable one, or null if there is none.
|
|
8101
|
+
*/
|
|
8102
|
+
select(modality, opts = {}) {
|
|
8103
|
+
return this.rank(modality, opts)[0] ?? null;
|
|
8104
|
+
}
|
|
8105
|
+
/**
|
|
8106
|
+
* A plain-language account of what this account can and cannot generate —
|
|
8107
|
+
* including the things it cannot, and why.
|
|
8108
|
+
*
|
|
8109
|
+
* This is the USER-facing inventory (model ids and unit prices), keyed on
|
|
8110
|
+
* which providers are configured. It is deliberately NOT what the planner
|
|
8111
|
+
* reads: see `describeGenerationForPlanner()` below for that, and the note
|
|
8112
|
+
* there for why the two cannot be the same string.
|
|
8113
|
+
*/
|
|
8114
|
+
describe() {
|
|
8115
|
+
const lines = [];
|
|
8116
|
+
const usable = this.usable();
|
|
8117
|
+
if (usable.length) {
|
|
8118
|
+
lines.push("Generation models available on your configured providers:");
|
|
8119
|
+
for (const modality of ["image", "speech", "transcription", "video"]) {
|
|
8120
|
+
const forModality = usable.filter((c) => c.modality === modality);
|
|
8121
|
+
if (!forModality.length) continue;
|
|
8122
|
+
const shown = forModality.map((c) => {
|
|
8123
|
+
const cost = capabilityCost(c);
|
|
8124
|
+
return `${c.modelId}${cost ? ` (${cost.label})` : ""}`;
|
|
8125
|
+
});
|
|
8126
|
+
lines.push(` ${modality}: ${shown.join(", ")}`);
|
|
8127
|
+
}
|
|
8128
|
+
} else {
|
|
8129
|
+
lines.push("No generation models are available \u2014 none of your configured providers offers one.");
|
|
8130
|
+
}
|
|
8131
|
+
const blocked = CAPABILITIES.filter((c) => c.unsupported && this.available.has(c.provider));
|
|
8132
|
+
for (const c of blocked) {
|
|
8133
|
+
lines.push(` ${c.modality}: ${c.modelId} exists on your account but is not callable. ${c.unsupported}`);
|
|
8134
|
+
}
|
|
8135
|
+
lines.push(
|
|
8136
|
+
" music: no supported provider exposes a music-generation API, so Cascade cannot generate music."
|
|
8137
|
+
);
|
|
8138
|
+
return lines.join("\n");
|
|
8139
|
+
}
|
|
8140
|
+
};
|
|
8141
|
+
var PLANNER_FACTS = [
|
|
8142
|
+
{ tool: "generate_image", modality: "image", shape: "one call returns one finished image" },
|
|
8143
|
+
{ tool: "generate_speech", modality: "speech", shape: "one call returns one finished audio file" },
|
|
8144
|
+
{
|
|
8145
|
+
tool: "generate_video",
|
|
8146
|
+
modality: "video",
|
|
8147
|
+
shape: "one call returns one finished clip, after rendering for 1-3 minutes (Cascade stops waiting at 8)"
|
|
8148
|
+
},
|
|
8149
|
+
{
|
|
8150
|
+
tool: "transcribe_audio",
|
|
8151
|
+
modality: "transcription",
|
|
8152
|
+
shape: "one call returns the transcript of one audio file"
|
|
8153
|
+
}
|
|
8154
|
+
];
|
|
8155
|
+
function plannerPriceNote(modality) {
|
|
8156
|
+
const costs = CAPABILITIES.filter((c) => c.modality === modality && !c.unsupported).map((c) => capabilityCost(c)).filter((c) => c !== null);
|
|
8157
|
+
if (!costs.length) return "";
|
|
8158
|
+
const labels = new Set(costs.map((c) => c.label));
|
|
8159
|
+
if (labels.size === 1) return ` Billed ${costs[0].label}.`;
|
|
8160
|
+
const units = new Set(costs.map((c) => c.unit));
|
|
8161
|
+
return units.size === 1 ? ` Billed ${[...units][0]}.` : "";
|
|
8162
|
+
}
|
|
8163
|
+
function describeGenerationForPlanner(has) {
|
|
8164
|
+
const present = PLANNER_FACTS.filter((f) => has(f.tool));
|
|
8165
|
+
if (!present.length) return "";
|
|
8166
|
+
const lines = ["MEDIA GENERATION \u2014 the only generation tools this run can call:"];
|
|
8167
|
+
for (const f of present) {
|
|
8168
|
+
lines.push(`- "${f.tool}" (${f.modality}): ${f.shape}.${plannerPriceNote(f.modality)}`);
|
|
8169
|
+
}
|
|
8170
|
+
lines.push(
|
|
8171
|
+
"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.",
|
|
8172
|
+
"No other modality has a tool here \u2014 never plan a step that generates music, 3D or anything not listed above."
|
|
8173
|
+
);
|
|
8174
|
+
if (has("generate_video")) {
|
|
8175
|
+
lines.push(
|
|
8176
|
+
'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.'
|
|
8177
|
+
);
|
|
8178
|
+
}
|
|
8179
|
+
return lines.join("\n");
|
|
8180
|
+
}
|
|
8181
|
+
|
|
7925
8182
|
// src/core/tiers/t2-manager.ts
|
|
7926
|
-
function buildT2SystemPrompt(
|
|
8183
|
+
function buildT2SystemPrompt(has) {
|
|
8184
|
+
const generation = describeGenerationForPlanner(has);
|
|
7927
8185
|
return [
|
|
7928
8186
|
"You are a T2 Manager agent in the Cascade AI system.",
|
|
7929
8187
|
"Your role is to analyze a section of a task and decompose it into 2-5 discrete subtasks for T3 Workers.",
|
|
7930
8188
|
'If subtasks have dependencies, you can specify "executionMode": "sequential" for the section.',
|
|
7931
|
-
|
|
7932
|
-
"Return ONLY valid JSON matching the T3 subtask array schema \u2014 no other text."
|
|
7933
|
-
|
|
8189
|
+
has("peer_message") && 'Provide "peerT3Ids" to subtasks so they can coordinate using the peer_message tool.',
|
|
8190
|
+
"Return ONLY valid JSON matching the T3 subtask array schema \u2014 no other text.",
|
|
8191
|
+
generation && `
|
|
8192
|
+
${generation}`
|
|
8193
|
+
].filter((l) => l !== false && l !== "").join("\n");
|
|
7934
8194
|
}
|
|
7935
8195
|
var T2Manager = class extends BaseTier {
|
|
7936
8196
|
router;
|
|
@@ -8227,7 +8487,7 @@ Return ONLY the JSON array.`;
|
|
|
8227
8487
|
const messages = [{ role: "user", content: prompt }];
|
|
8228
8488
|
const result = await this.router.generate("T2", {
|
|
8229
8489
|
messages,
|
|
8230
|
-
systemPrompt: this.systemPromptOverride + buildT2SystemPrompt(this.toolRegistry.hasTool(
|
|
8490
|
+
systemPrompt: this.systemPromptOverride + buildT2SystemPrompt((name) => this.toolRegistry.hasTool(name)) + (this.hierarchyContext ? `
|
|
8231
8491
|
|
|
8232
8492
|
HIERARCHY CONTEXT: ${this.hierarchyContext}` : ""),
|
|
8233
8493
|
maxTokens: 2e3,
|
|
@@ -8777,6 +9037,7 @@ function isStrongKeywordOverlap(a = [], b = []) {
|
|
|
8777
9037
|
}
|
|
8778
9038
|
function buildT1SystemPrompt(has) {
|
|
8779
9039
|
const canWriteArtifacts = has("file_write") || has("file_edit") || has("run_code") || has("pdf_create");
|
|
9040
|
+
const generation = describeGenerationForPlanner(has);
|
|
8780
9041
|
const rules = [
|
|
8781
9042
|
"- Simple \u2192 1 T3, Moderate \u2192 2-3 T2s, Complex \u2192 3-5 T2s, Highly Complex \u2192 5+ T2s",
|
|
8782
9043
|
"- Return ONLY valid JSON \u2014 no other text",
|
|
@@ -8811,7 +9072,9 @@ DEPENDENCY GUIDANCE:
|
|
|
8811
9072
|
QUALITY RULES:
|
|
8812
9073
|
- Each section must have a clear, testable "expectedOutput" so T2 knows when it is done.
|
|
8813
9074
|
- Do NOT create trivial sections that only move files or print summaries \u2014 fold those into adjacent sections.
|
|
8814
|
-
- If the plan would naturally produce fewer than 2 independent sections, prefer Moderate routing (single T2)
|
|
9075
|
+
- If the plan would naturally produce fewer than 2 independent sections, prefer Moderate routing (single T2).${generation ? `
|
|
9076
|
+
|
|
9077
|
+
${generation}` : ""}`;
|
|
8815
9078
|
}
|
|
8816
9079
|
var T1Administrator = class extends BaseTier {
|
|
8817
9080
|
router;
|
|
@@ -9506,188 +9769,6 @@ Reply with exactly one word: YES, NO, or UNSURE.
|
|
|
9506
9769
|
}
|
|
9507
9770
|
};
|
|
9508
9771
|
|
|
9509
|
-
// src/core/multimodal/registry.ts
|
|
9510
|
-
var CAPABILITIES = [
|
|
9511
|
-
// ── Image ──
|
|
9512
|
-
{
|
|
9513
|
-
modality: "image",
|
|
9514
|
-
provider: "openai",
|
|
9515
|
-
modelId: "dall-e-3",
|
|
9516
|
-
api: "openai-images"
|
|
9517
|
-
},
|
|
9518
|
-
{
|
|
9519
|
-
// Was `imagen-4.0-generate-001` on `:predict`, which now 404s for new keys
|
|
9520
|
-
// ("no longer available to new users") — Imagen's :predict API is deprecated
|
|
9521
|
-
// and shuts down 2026-08-17. Google's own migration path is this model on
|
|
9522
|
-
// the ordinary generateContent endpoint, so the fix was never another Imagen
|
|
9523
|
-
// id: the whole request/response SHAPE changes, which is why `api` moved to
|
|
9524
|
-
// 'gemini-generate-content' rather than just the modelId moving.
|
|
9525
|
-
// https://ai.google.dev/gemini-api/docs/imagen
|
|
9526
|
-
modality: "image",
|
|
9527
|
-
provider: "gemini",
|
|
9528
|
-
modelId: "gemini-2.5-flash-image",
|
|
9529
|
-
api: "gemini-generate-content"
|
|
9530
|
-
},
|
|
9531
|
-
// ── Speech (text → audio) ──
|
|
9532
|
-
{
|
|
9533
|
-
modality: "speech",
|
|
9534
|
-
provider: "openai",
|
|
9535
|
-
modelId: "tts-1",
|
|
9536
|
-
api: "openai-speech"
|
|
9537
|
-
},
|
|
9538
|
-
{
|
|
9539
|
-
// The only quality claim in this table that needs no leaderboard: OpenAI
|
|
9540
|
-
// ships these as the same voice at two fidelities and charges double for
|
|
9541
|
-
// this one. That is the vendor's own ordering, not an inference.
|
|
9542
|
-
modality: "speech",
|
|
9543
|
-
provider: "openai",
|
|
9544
|
-
modelId: "tts-1-hd",
|
|
9545
|
-
api: "openai-speech",
|
|
9546
|
-
quality: 70,
|
|
9547
|
-
qualityBasis: "OpenAI's own hd variant of tts-1, priced 2x"
|
|
9548
|
-
},
|
|
9549
|
-
// ── Transcription (audio → text) ──
|
|
9550
|
-
{
|
|
9551
|
-
modality: "transcription",
|
|
9552
|
-
provider: "openai",
|
|
9553
|
-
modelId: "whisper-1",
|
|
9554
|
-
api: "openai-transcriptions"
|
|
9555
|
-
},
|
|
9556
|
-
// ── Video ──
|
|
9557
|
-
{
|
|
9558
|
-
// Long-running: submit returns an operation name, the video lands minutes
|
|
9559
|
-
// later, and the bytes come from a short-lived signed URL. generate.ts owns
|
|
9560
|
-
// that polling loop; the registry only records the shape via `api`.
|
|
9561
|
-
//
|
|
9562
|
-
// `veo-3.1-generate-001` (no "-preview") is VERTEX AI's id for this model,
|
|
9563
|
-
// not the Gemini Developer API's — this file calls
|
|
9564
|
-
// generativelanguage.googleapis.com (see generate.ts), which 404s on it:
|
|
9565
|
-
// "models/veo-3.1-generate-001 is not found for API version v1beta". On the
|
|
9566
|
-
// Gemini API specifically, Veo 3.1 is still preview-only, so the correct id
|
|
9567
|
-
// there is `veo-3.1-generate-preview`.
|
|
9568
|
-
// https://ai.google.dev/gemini-api/docs/veo
|
|
9569
|
-
modality: "video",
|
|
9570
|
-
provider: "gemini",
|
|
9571
|
-
modelId: "veo-3.1-generate-preview",
|
|
9572
|
-
api: "gemini-predict-lro"
|
|
9573
|
-
}
|
|
9574
|
-
];
|
|
9575
|
-
function capabilityCost(cap) {
|
|
9576
|
-
const match = findPricing(cap.modelId, cap.provider, {
|
|
9577
|
-
fallbackProviders: cap.provider === "gemini" ? ["vertex"] : []
|
|
9578
|
-
});
|
|
9579
|
-
const rate = match?.entry.rates?.[0];
|
|
9580
|
-
if (!rate) return null;
|
|
9581
|
-
const unitLabel = {
|
|
9582
|
-
per_image: "per image",
|
|
9583
|
-
per_second: "per second of video",
|
|
9584
|
-
per_character: "per character",
|
|
9585
|
-
per_audio_minute: "per audio minute"
|
|
9586
|
-
};
|
|
9587
|
-
const unit = unitLabel[rate.unit] ?? rate.unit;
|
|
9588
|
-
const amount = rate.amount;
|
|
9589
|
-
const shown = amount < 1e-3 ? amount.toExponential(2) : amount.toFixed(4);
|
|
9590
|
-
return { label: `$${shown} ${unit}`, amount, unit };
|
|
9591
|
-
}
|
|
9592
|
-
function explainChoice(c, cost, modality, isBest) {
|
|
9593
|
-
const priced = cost ? ` ${cost.label}.` : "";
|
|
9594
|
-
if (c.quality !== void 0) {
|
|
9595
|
-
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}`;
|
|
9596
|
-
}
|
|
9597
|
-
const noRanking = ". No published quality ranking is applied for this modality, so this is a cost choice, not a quality one.";
|
|
9598
|
-
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;
|
|
9599
|
-
}
|
|
9600
|
-
var MultimodalRegistry = class {
|
|
9601
|
-
/** Provider types the user has actually configured a key for. */
|
|
9602
|
-
available;
|
|
9603
|
-
constructor(availableProviders) {
|
|
9604
|
-
this.available = new Set(availableProviders);
|
|
9605
|
-
}
|
|
9606
|
-
/** Every capability whose provider is configured AND which Cascade can call. */
|
|
9607
|
-
usable(modality) {
|
|
9608
|
-
return CAPABILITIES.filter(
|
|
9609
|
-
(c) => !c.unsupported && this.available.has(c.provider) && (!modality || c.modality === modality)
|
|
9610
|
-
);
|
|
9611
|
-
}
|
|
9612
|
-
/** Modalities this account can actually generate right now. */
|
|
9613
|
-
availableModalities() {
|
|
9614
|
-
return [...new Set(this.usable().map((c) => c.modality))];
|
|
9615
|
-
}
|
|
9616
|
-
/**
|
|
9617
|
-
* Every usable capability for a modality, best first.
|
|
9618
|
-
*
|
|
9619
|
-
* Ranked models beat unranked ones, then higher quality, then lower unit
|
|
9620
|
-
* price. An explicit `preferModel` is moved to the head when it is usable —
|
|
9621
|
-
* the user naming a model is a stronger signal than any prior.
|
|
9622
|
-
*
|
|
9623
|
-
* `select()` is just the head of this list. The TAIL is the point: a systemic
|
|
9624
|
-
* provider failure (dead key, 404, exhausted quota) is scoped to one
|
|
9625
|
-
* provider+model, so "this model cannot draw" is not the same fact as "this
|
|
9626
|
-
* account cannot draw". A caller holding the ordered alternatives can try the
|
|
9627
|
-
* next provider instead of aborting the whole run — see generate-media.ts.
|
|
9628
|
-
*/
|
|
9629
|
-
rank(modality, opts = {}) {
|
|
9630
|
-
const scored = this.usable(modality).map((c) => ({ c, cost: capabilityCost(c) })).sort((a, b) => {
|
|
9631
|
-
const qa = a.c.quality ?? -1;
|
|
9632
|
-
const qb = b.c.quality ?? -1;
|
|
9633
|
-
if (qa !== qb) return qb - qa;
|
|
9634
|
-
const pa = a.cost?.amount ?? Number.POSITIVE_INFINITY;
|
|
9635
|
-
const pb = b.cost?.amount ?? Number.POSITIVE_INFINITY;
|
|
9636
|
-
return pa - pb;
|
|
9637
|
-
});
|
|
9638
|
-
const results = scored.map(({ c, cost }, i) => ({
|
|
9639
|
-
capability: c,
|
|
9640
|
-
cost,
|
|
9641
|
-
reason: explainChoice(c, cost, modality, i === 0)
|
|
9642
|
-
}));
|
|
9643
|
-
if (opts.preferModel) {
|
|
9644
|
-
const i = results.findIndex((r) => r.capability.modelId === opts.preferModel);
|
|
9645
|
-
if (i > -1) {
|
|
9646
|
-
const [wanted] = results.splice(i, 1);
|
|
9647
|
-
results.unshift({ ...wanted, reason: `Requested explicitly: ${wanted.capability.modelId}.` });
|
|
9648
|
-
}
|
|
9649
|
-
}
|
|
9650
|
-
return results;
|
|
9651
|
-
}
|
|
9652
|
-
/**
|
|
9653
|
-
* Pick a model for a modality — the best usable one, or null if there is none.
|
|
9654
|
-
*/
|
|
9655
|
-
select(modality, opts = {}) {
|
|
9656
|
-
return this.rank(modality, opts)[0] ?? null;
|
|
9657
|
-
}
|
|
9658
|
-
/**
|
|
9659
|
-
* A plain-language account of what this account can and cannot generate —
|
|
9660
|
-
* including the things it cannot, and why. The planner sees this, so being
|
|
9661
|
-
* candid here is what stops it inventing a `generate_music` call.
|
|
9662
|
-
*/
|
|
9663
|
-
describe() {
|
|
9664
|
-
const lines = [];
|
|
9665
|
-
const usable = this.usable();
|
|
9666
|
-
if (usable.length) {
|
|
9667
|
-
lines.push("Generation models available on your configured providers:");
|
|
9668
|
-
for (const modality of ["image", "speech", "transcription", "video"]) {
|
|
9669
|
-
const forModality = usable.filter((c) => c.modality === modality);
|
|
9670
|
-
if (!forModality.length) continue;
|
|
9671
|
-
const shown = forModality.map((c) => {
|
|
9672
|
-
const cost = capabilityCost(c);
|
|
9673
|
-
return `${c.modelId}${cost ? ` (${cost.label})` : ""}`;
|
|
9674
|
-
});
|
|
9675
|
-
lines.push(` ${modality}: ${shown.join(", ")}`);
|
|
9676
|
-
}
|
|
9677
|
-
} else {
|
|
9678
|
-
lines.push("No generation models are available \u2014 none of your configured providers offers one.");
|
|
9679
|
-
}
|
|
9680
|
-
const blocked = CAPABILITIES.filter((c) => c.unsupported && this.available.has(c.provider));
|
|
9681
|
-
for (const c of blocked) {
|
|
9682
|
-
lines.push(` ${c.modality}: ${c.modelId} exists on your account but is not callable. ${c.unsupported}`);
|
|
9683
|
-
}
|
|
9684
|
-
lines.push(
|
|
9685
|
-
" music: no supported provider exposes a music-generation API, so Cascade cannot generate music."
|
|
9686
|
-
);
|
|
9687
|
-
return lines.join("\n");
|
|
9688
|
-
}
|
|
9689
|
-
};
|
|
9690
|
-
|
|
9691
9772
|
// src/tools/base.ts
|
|
9692
9773
|
var BaseTool = class {
|
|
9693
9774
|
workspaceRoot = process.cwd();
|
|
@@ -9708,10 +9789,17 @@ var BaseTool = class {
|
|
|
9708
9789
|
|
|
9709
9790
|
// src/core/multimodal/generate.ts
|
|
9710
9791
|
var DEFAULT_TIMEOUT_MS = 12e4;
|
|
9792
|
+
var GenerationGaveUpError = class extends Error {
|
|
9793
|
+
constructor(message) {
|
|
9794
|
+
super(message);
|
|
9795
|
+
this.name = "GenerationGaveUpError";
|
|
9796
|
+
}
|
|
9797
|
+
};
|
|
9711
9798
|
async function callProvider(fn, modelId) {
|
|
9712
9799
|
try {
|
|
9713
9800
|
return await fn();
|
|
9714
9801
|
} catch (err) {
|
|
9802
|
+
if (err instanceof GenerationGaveUpError) throw err;
|
|
9715
9803
|
const classified = classifyProviderError(err);
|
|
9716
9804
|
throw new Error(describeProviderError(classified, modelId));
|
|
9717
9805
|
}
|
|
@@ -9909,8 +9997,8 @@ async function generateVideo(cap, cfg, req, signal, onProgress) {
|
|
|
9909
9997
|
onProgress?.("Still rendering\u2026");
|
|
9910
9998
|
}
|
|
9911
9999
|
if (!operation.done) {
|
|
9912
|
-
throw new
|
|
9913
|
-
|
|
10000
|
+
throw new GenerationGaveUpError(
|
|
10001
|
+
`${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.`
|
|
9914
10002
|
);
|
|
9915
10003
|
}
|
|
9916
10004
|
if (operation.error?.message) throw new Error(operation.error.message);
|