windmill-cli 1.850.0 → 1.850.1-aireview.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/esm/main.js +891 -107
- package/package.json +1 -1
package/esm/main.js
CHANGED
|
@@ -18286,6 +18286,16 @@ var getAuditLog = (data) => {
|
|
|
18286
18286
|
keep_captures: data.keepCaptures
|
|
18287
18287
|
}
|
|
18288
18288
|
});
|
|
18289
|
+
}, completeAi = (data) => {
|
|
18290
|
+
return request(OpenAPI, {
|
|
18291
|
+
method: "POST",
|
|
18292
|
+
url: "/w/{workspace}/ai/complete",
|
|
18293
|
+
path: {
|
|
18294
|
+
workspace: data.workspace
|
|
18295
|
+
},
|
|
18296
|
+
body: data.requestBody,
|
|
18297
|
+
mediaType: "application/json"
|
|
18298
|
+
});
|
|
18289
18299
|
}, getSharedUi = (data) => {
|
|
18290
18300
|
return request(OpenAPI, {
|
|
18291
18301
|
method: "GET",
|
|
@@ -20074,7 +20084,7 @@ var init_auth = __esm(async () => {
|
|
|
20074
20084
|
});
|
|
20075
20085
|
|
|
20076
20086
|
// src/core/constants.ts
|
|
20077
|
-
var WM_FORK_PREFIX = "wm-fork", VERSION = "1.850.0";
|
|
20087
|
+
var WM_FORK_PREFIX = "wm-fork", VERSION = "1.850.1-aireview.0";
|
|
20078
20088
|
|
|
20079
20089
|
// src/utils/resource_folders.ts
|
|
20080
20090
|
import { existsSync } from "node:fs";
|
|
@@ -27668,17 +27678,14 @@ function s4(e) {
|
|
|
27668
27678
|
function c4(e, t) {
|
|
27669
27679
|
switch (t) {
|
|
27670
27680
|
case "postgresql":
|
|
27671
|
-
|
|
27681
|
+
case "snowflake":
|
|
27682
|
+
case "duckdb":
|
|
27683
|
+
return `"${e.replace(/"/g, '""')}"`;
|
|
27672
27684
|
case "ms_sql_server":
|
|
27673
|
-
return `[${e}]`;
|
|
27685
|
+
return `[${e.replace(/]/g, "]]")}]`;
|
|
27674
27686
|
case "mysql":
|
|
27675
|
-
return `\`${e}\``;
|
|
27676
|
-
case "snowflake":
|
|
27677
|
-
return `"${e}"`;
|
|
27678
27687
|
case "bigquery":
|
|
27679
|
-
return `\`${e}\``;
|
|
27680
|
-
case "duckdb":
|
|
27681
|
-
return `"${e}"`;
|
|
27688
|
+
return `\`${e.replace(/`/g, "``")}\``;
|
|
27682
27689
|
default:
|
|
27683
27690
|
throw Error("Unsupported database type: " + t);
|
|
27684
27691
|
}
|
|
@@ -28455,7 +28462,7 @@ function J3(e) {
|
|
|
28455
28462
|
}).join("; ")} }`;
|
|
28456
28463
|
}
|
|
28457
28464
|
function Y2(e, t) {
|
|
28458
|
-
let n = Object.keys(t).filter((e) => t[e].type == "static");
|
|
28465
|
+
let n = Object.keys(t).filter((e) => t[e].type == "static" || t[e].type == "ctx");
|
|
28459
28466
|
return {
|
|
28460
28467
|
...e,
|
|
28461
28468
|
properties: { ...Object.fromEntries(Object.entries(e.properties ?? {}).filter(([e]) => !n.includes(e))) }
|
|
@@ -28468,13 +28475,20 @@ function Z(e) {
|
|
|
28468
28475
|
return `// THIS FILE IS READ-ONLY
|
|
28469
28476
|
// AND GENERATED AUTOMATICALLY FROM YOUR RUNNABLES
|
|
28470
28477
|
|
|
28478
|
+
/**
|
|
28479
|
+
* \`memoryId\` names the conversation a turn of an agent or a chat-mode flow belongs to: a
|
|
28480
|
+
* signed-in viewer's conversations are theirs alone.
|
|
28481
|
+
*/
|
|
28471
28482
|
export declare const backend: {
|
|
28472
|
-
${Object.entries(e).map(([e, t]) => ` ${e}: (args: ${X2(t)}) => Promise<any>;`).join(`
|
|
28483
|
+
${Object.entries(e).map(([e, t]) => ` ${e}: (args: ${X2(t)}, opts?: { memoryId?: string }) => Promise<any>;`).join(`
|
|
28473
28484
|
`)}
|
|
28474
28485
|
};
|
|
28475
28486
|
|
|
28487
|
+
/**
|
|
28488
|
+
* Start a runnable and resolve its job id. \`memoryId\` is as for \`backend\`.
|
|
28489
|
+
*/
|
|
28476
28490
|
export declare const backendAsync: {
|
|
28477
|
-
${Object.entries(e).map(([e, t]) => ` ${e}: (args: ${X2(t)}) => Promise<string>;`).join(`
|
|
28491
|
+
${Object.entries(e).map(([e, t]) => ` ${e}: (args: ${X2(t)}, opts?: { memoryId?: string }) => Promise<string>;`).join(`
|
|
28478
28492
|
`)}
|
|
28479
28493
|
};
|
|
28480
28494
|
|
|
@@ -28490,10 +28504,10 @@ export type Job = {
|
|
|
28490
28504
|
};
|
|
28491
28505
|
|
|
28492
28506
|
/**
|
|
28493
|
-
*
|
|
28507
|
+
* Wait for a job to complete and return its result. Rejects if the job failed.
|
|
28494
28508
|
* @param id
|
|
28495
28509
|
*/
|
|
28496
|
-
export declare function waitJob(id: string): Promise<
|
|
28510
|
+
export declare function waitJob(id: string): Promise<any>;
|
|
28497
28511
|
|
|
28498
28512
|
/**
|
|
28499
28513
|
* Get a job by id and return immediately with the current state of the job
|
|
@@ -28527,7 +28541,7 @@ function $(e, t) {
|
|
|
28527
28541
|
let n = {};
|
|
28528
28542
|
typeof e.delete_after_secs == "number" && e.delete_after_secs >= 0 && (n.delete_after_secs = e.delete_after_secs);
|
|
28529
28543
|
let r = Object.entries(t).map(([e, t]) => t.sensitive ? e : undefined).filter(Boolean);
|
|
28530
|
-
return r.length > 0 && (n.sensitive_inputs = r), e.inlineScript?.tag && (n.tag = e.inlineScript.tag), n;
|
|
28544
|
+
return r.length > 0 && (n.sensitive_inputs = r), e.inlineScript?.tag && (n.tag = e.inlineScript.tag), e.viewer_data_access === true && k3(e) && (n.viewer_data_access = true), n;
|
|
28531
28545
|
}
|
|
28532
28546
|
async function te2(e, t, n) {
|
|
28533
28547
|
let r = U3(n), i = Object.entries(n).map(([e, t]) => t.allowUserResources ? e : undefined).filter(Boolean);
|
|
@@ -28561,8 +28575,8 @@ export const backend = new Proxy(
|
|
|
28561
28575
|
{},
|
|
28562
28576
|
{
|
|
28563
28577
|
get(_, runnable_id: string) {
|
|
28564
|
-
return (v: any) => {
|
|
28565
|
-
return doRequest('backend', { runnable_id, v })
|
|
28578
|
+
return (v: any, opts?: { memoryId?: string }) => {
|
|
28579
|
+
return doRequest('backend', { runnable_id, v, memoryId: opts?.memoryId })
|
|
28566
28580
|
}
|
|
28567
28581
|
}
|
|
28568
28582
|
}
|
|
@@ -28572,8 +28586,8 @@ export const backendAsync = new Proxy(
|
|
|
28572
28586
|
{},
|
|
28573
28587
|
{
|
|
28574
28588
|
get(_, runnable_id: string) {
|
|
28575
|
-
return (v: any) => {
|
|
28576
|
-
return doRequest('backendAsync', { runnable_id, v })
|
|
28589
|
+
return (v: any, opts?: { memoryId?: string }) => {
|
|
28590
|
+
return doRequest('backendAsync', { runnable_id, v, memoryId: opts?.memoryId })
|
|
28577
28591
|
}
|
|
28578
28592
|
}
|
|
28579
28593
|
}
|
|
@@ -34815,8 +34829,8 @@ export const backend = new Proxy(
|
|
|
34815
34829
|
{},
|
|
34816
34830
|
{
|
|
34817
34831
|
get(_, runnable_id: string) {
|
|
34818
|
-
return (v: any) => {
|
|
34819
|
-
return doRequest('backend', { runnable_id, v })
|
|
34832
|
+
return (v: any, opts?: { memoryId?: string }) => {
|
|
34833
|
+
return doRequest('backend', { runnable_id, v, memoryId: opts?.memoryId })
|
|
34820
34834
|
}
|
|
34821
34835
|
}
|
|
34822
34836
|
})
|
|
@@ -34825,8 +34839,8 @@ export const backendAsync = new Proxy(
|
|
|
34825
34839
|
{},
|
|
34826
34840
|
{
|
|
34827
34841
|
get(_, runnable_id: string) {
|
|
34828
|
-
return (v: any) => {
|
|
34829
|
-
return doRequest('backendAsync', { runnable_id, v })
|
|
34842
|
+
return (v: any, opts?: { memoryId?: string }) => {
|
|
34843
|
+
return doRequest('backendAsync', { runnable_id, v, memoryId: opts?.memoryId })
|
|
34830
34844
|
}
|
|
34831
34845
|
}
|
|
34832
34846
|
})
|
|
@@ -74522,17 +74536,17 @@ data: reload
|
|
|
74522
74536
|
try {
|
|
74523
74537
|
const message = JSON.parse(data.toString());
|
|
74524
74538
|
info(colors.cyan(`[WebSocket] Received: ${JSON.stringify(message)}`));
|
|
74525
|
-
const { type, reqId, runnable_id, v, jobId } = message;
|
|
74539
|
+
const { type, reqId, runnable_id, v, jobId, memoryId } = message;
|
|
74526
74540
|
const respond = (responseType, result, error) => {
|
|
74527
74541
|
ws.send(JSON.stringify({ type: responseType, reqId, result, error }));
|
|
74528
74542
|
};
|
|
74529
|
-
const runAndWaitForResult = async (runnableId, args) => {
|
|
74543
|
+
const runAndWaitForResult = async (runnableId, args, memoryId) => {
|
|
74530
74544
|
const runnables = await loadRunnables();
|
|
74531
74545
|
const runnable = runnables[runnableId];
|
|
74532
74546
|
if (!runnable) {
|
|
74533
74547
|
throw new Error(`Runnable not found: ${runnableId}`);
|
|
74534
74548
|
}
|
|
74535
|
-
const uuid = await executeRunnable(runnable, workspaceId, appPath, runnableId, args, appTempRefs, previewModules(runnables, runnableId));
|
|
74549
|
+
const uuid = await executeRunnable(runnable, workspaceId, appPath, runnableId, args, appTempRefs, previewModules(runnables, runnableId), memoryId);
|
|
74536
74550
|
info(colors.gray(`[backend] Job started: ${uuid}`));
|
|
74537
74551
|
const result = await waitForJob(workspaceId, uuid);
|
|
74538
74552
|
return { uuid, result };
|
|
@@ -74541,7 +74555,7 @@ data: reload
|
|
|
74541
74555
|
case "backend": {
|
|
74542
74556
|
info(colors.blue(`[backend] Running runnable: ${runnable_id}`));
|
|
74543
74557
|
try {
|
|
74544
|
-
const { result } = await runAndWaitForResult(runnable_id, v);
|
|
74558
|
+
const { result } = await runAndWaitForResult(runnable_id, v, memoryId);
|
|
74545
74559
|
respond("backendRes", result, false);
|
|
74546
74560
|
} catch (error2) {
|
|
74547
74561
|
error(colors.red(`[backend] Error: ${error2.message}`));
|
|
@@ -74557,7 +74571,7 @@ data: reload
|
|
|
74557
74571
|
if (!runnable) {
|
|
74558
74572
|
throw new Error(`Runnable not found: ${runnable_id}`);
|
|
74559
74573
|
}
|
|
74560
|
-
const uuid = await executeRunnable(runnable, workspaceId, appPath, runnable_id, v, appTempRefs, previewModules(runnables, runnable_id));
|
|
74574
|
+
const uuid = await executeRunnable(runnable, workspaceId, appPath, runnable_id, v, appTempRefs, previewModules(runnables, runnable_id), memoryId);
|
|
74561
74575
|
info(colors.gray(`[backendAsync] Job started: ${uuid}`));
|
|
74562
74576
|
respond("backendAsyncRes", uuid, false);
|
|
74563
74577
|
waitForJob(workspaceId, uuid).then((result) => {
|
|
@@ -74817,12 +74831,7 @@ function agentRunnableSchema(memory) {
|
|
|
74817
74831
|
const managed = memory?.kind === "compaction" || (memory?.kind === "window" || memory?.kind === "auto") && Boolean(memory.context_length);
|
|
74818
74832
|
const legacy = memory?.kind === "manual";
|
|
74819
74833
|
const history = {};
|
|
74820
|
-
if (managed) {
|
|
74821
|
-
history.memory_id = {
|
|
74822
|
-
type: "string",
|
|
74823
|
-
description: "The conversation the message belongs to: reuse it to continue one, or omit it for a single run"
|
|
74824
|
-
};
|
|
74825
|
-
} else if (!legacy) {
|
|
74834
|
+
if (!managed && !legacy) {
|
|
74826
74835
|
history.previous_messages = {
|
|
74827
74836
|
type: "array",
|
|
74828
74837
|
description: "The history to answer from, as chat messages: this agent keeps no memory",
|
|
@@ -74947,10 +74956,11 @@ function previewModules(runnables, runnableId) {
|
|
|
74947
74956
|
}
|
|
74948
74957
|
return Object.keys(modules).length > 0 ? modules : undefined;
|
|
74949
74958
|
}
|
|
74950
|
-
async function executeRunnable(runnable, workspace, appPath, runnableId, args, tempScriptRefs, modules) {
|
|
74959
|
+
async function executeRunnable(runnable, workspace, appPath, runnableId, args, tempScriptRefs, modules, memoryId) {
|
|
74951
74960
|
const requestBody = {
|
|
74952
74961
|
component: runnableId,
|
|
74953
74962
|
args: args ?? {},
|
|
74963
|
+
...memoryId ? { run_query_params: { memory_id: memoryId } } : {},
|
|
74954
74964
|
force_viewer_static_fields: {},
|
|
74955
74965
|
force_viewer_one_of_fields: {},
|
|
74956
74966
|
force_viewer_allow_user_resources: []
|
|
@@ -80447,6 +80457,7 @@ var init_skills_gen = __esm(() => {
|
|
|
80447
80457
|
{ name: "triggers", description: "MUST use when configuring triggers." },
|
|
80448
80458
|
{ name: "schedules", description: "MUST use when configuring schedules." },
|
|
80449
80459
|
{ name: "resources", description: "MUST use when managing resources." },
|
|
80460
|
+
{ name: "agents", description: "MUST use when creating or changing an AI agent, the reusable `ai_agent` resource the Agents page lists." },
|
|
80450
80461
|
{ name: "write-workflow-as-code", description: "MUST use when writing or modifying Windmill Workflow-as-Code scripts using workflow, task, step, sleep, approvals, taskScript, taskFlow, task_script, or task_flow." },
|
|
80451
80462
|
{ name: "write-pipeline", description: "MUST use when creating or modifying a data pipeline, a set of scripts marked `pipeline` and wired together by `on` / `materialize` annotations." },
|
|
80452
80463
|
{ name: "datatables", description: "MUST use when changing a data table's schema, writing or running its migrations, or working with its roles and permissions." },
|
|
@@ -86324,11 +86335,12 @@ value:
|
|
|
86324
86335
|
## AI Agent Modules
|
|
86325
86336
|
|
|
86326
86337
|
An \`aiagent\` module runs an LLM that can call tools. Each entry of \`value.tools\` is a module-shaped
|
|
86327
|
-
object with an extra \`value.tool_type\`: \`flowmodule\` for a script
|
|
86328
|
-
tool, \`websearch\` for web search, \`question\` for a
|
|
86329
|
-
without holding a worker, until someone answers from
|
|
86330
|
-
\`value.timeout\` in seconds, default 1800). Set
|
|
86331
|
-
tool to have a person approve or reject each of
|
|
86338
|
+
object with an extra \`value.tool_type\`: \`flowmodule\` for a script or inline script tool (or a nested
|
|
86339
|
+
agent or AI decision), \`mcp\` for an MCP server tool, \`websearch\` for web search, \`question\` for a
|
|
86340
|
+
built-in \`ask_question\` tool (the agent stops, without holding a worker, until someone answers from
|
|
86341
|
+
the run page or the chat; optional \`value.timeout\` in seconds, default 1800). Set
|
|
86342
|
+
\`requires_approval: true\` on a \`flowmodule\` or \`mcp\` tool to have a person approve or reject each of
|
|
86343
|
+
its calls before it runs.
|
|
86332
86344
|
|
|
86333
86345
|
\`\`\`json
|
|
86334
86346
|
{
|
|
@@ -86355,7 +86367,7 @@ tool to have a person approve or reject each of its calls before it runs.
|
|
|
86355
86367
|
"type": "rawscript",
|
|
86356
86368
|
"language": "bun",
|
|
86357
86369
|
"content": "export async function main(query: string) { return ['doc1', 'doc2']; }",
|
|
86358
|
-
"input_transforms": { "query": { "type": "
|
|
86370
|
+
"input_transforms": { "query": { "type": "ai" } }
|
|
86359
86371
|
}
|
|
86360
86372
|
}
|
|
86361
86373
|
]
|
|
@@ -86363,6 +86375,11 @@ tool to have a person approve or reject each of its calls before it runs.
|
|
|
86363
86375
|
}
|
|
86364
86376
|
\`\`\`
|
|
86365
86377
|
|
|
86378
|
+
- A flow cannot be a tool: a run offered one fails with \`Unsupported tool\`. Wrap it in a script
|
|
86379
|
+
that runs the flow
|
|
86380
|
+
- Each argument of a tool is either the model's or fixed. \`{ "type": "ai" }\` (or no value) lets the
|
|
86381
|
+
model fill it; a static value, an empty string included, fixes it and hides it from the model. Fix
|
|
86382
|
+
what the model must not choose, such as a resource, a table name or a limit
|
|
86366
86383
|
- \`provider\` is an object, not a bare resource string: \`{ "kind": <provider kind>,
|
|
86367
86384
|
"resource": "$res:<path>", "model": <model id> }\`. Required unless the module links to a saved
|
|
86368
86385
|
agent through \`value.agent\`. Static is right for a flow run from a form; a chat flow wires its
|
|
@@ -87288,7 +87305,7 @@ import * as wmill from './wmill'
|
|
|
87288
87305
|
const chat = useWindmillChat({ wmill, runnable: 'chat' })
|
|
87289
87306
|
\`\`\`
|
|
87290
87307
|
|
|
87291
|
-
\`runnable\` is the runnable's key; each runnable keeps its own conversations. The runnable takes \`user_message
|
|
87308
|
+
\`runnable\` is the runnable's key; each runnable keeps its own conversations. The runnable takes \`user_message\`; the chat passes the conversation id as \`backendAsync.<key>(args, { memoryId })\`: the agent remembers earlier turns of a conversation, and a signed-in viewer's conversations are theirs alone. Called directly as \`backend.<key>({ user_message })\`, it is a single run with no conversation, for a one-off question; \`backend.<key>(args, { memoryId })\` waits for the reply of a conversation turn. The chat needs an agent with managed memory. An agent whose memory is off keeps none: its runnable takes \`previous_messages\` (chat messages) instead, and the app keeps the history itself. The chat keeps its transcript in the app's own storage. \`chat.stop()\` stops following without cancelling the turn, and a message sent while it still runs is refused with \`TurnRunningError\`. Attachments are not supported this way.
|
|
87292
87309
|
|
|
87293
87310
|
## Backend runnables
|
|
87294
87311
|
|
|
@@ -87344,7 +87361,7 @@ Use only \`wmill\` functions the SDK actually exports; for an endpoint none of t
|
|
|
87344
87361
|
|
|
87345
87362
|
### Path runnables (script / flow / hubscript / agent)
|
|
87346
87363
|
|
|
87347
|
-
When \`type\` is \`script\`, \`flow\`, \`hubscript\` or \`agent\`, the runnable just stores a \`path\` to an existing workspace or hub item — no inline code. The referenced item's input/output schema becomes the runnable's surface; an agent's is \`user_message\` and \`user_attachments\`, plus \`
|
|
87364
|
+
When \`type\` is \`script\`, \`flow\`, \`hubscript\` or \`agent\`, the runnable just stores a \`path\` to an existing workspace or hub item — no inline code. The referenced item's input/output schema becomes the runnable's surface; an agent's is \`user_message\` and \`user_attachments\`, plus \`previous_messages\` when its memory is off.
|
|
87348
87365
|
|
|
87349
87366
|
Before writing an inline runnable, look for a workspace script or flow that already does the job, or a Hub script (a prebuilt integration at \`hub/<version>/<app>/<name>\`) for a third-party service, and reference it instead of copying its logic.
|
|
87350
87367
|
|
|
@@ -87633,6 +87650,7 @@ Example: \`f/databases/postgres_prod.resource.json\`
|
|
|
87633
87650
|
An agent, as the Agents page lists it, is a resource of type \`ai_agent\`. Its value holds the
|
|
87634
87651
|
agent's provider, system prompt, tools and memory settings, and a flow step uses a saved agent by
|
|
87635
87652
|
linking its path.
|
|
87653
|
+
Before writing one, use the \`agents\` skill.
|
|
87636
87654
|
|
|
87637
87655
|
## Variable References
|
|
87638
87656
|
|
|
@@ -87900,6 +87918,126 @@ wmill resource-type get postgresql
|
|
|
87900
87918
|
# deploy via \`git push\` or \`wmill sync push\` (see the Deploying section in AGENTS.wmill.md).
|
|
87901
87919
|
wmill sync push
|
|
87902
87920
|
\`\`\`
|
|
87921
|
+
`,
|
|
87922
|
+
agents: `---
|
|
87923
|
+
name: agents
|
|
87924
|
+
description: MUST use when creating or changing an AI agent, the reusable \`ai_agent\` resource the Agents page lists.
|
|
87925
|
+
---
|
|
87926
|
+
|
|
87927
|
+
# Windmill AI Agents
|
|
87928
|
+
|
|
87929
|
+
An agent, as the Agents page lists it, is a saved LLM with its own system prompt, tools and
|
|
87930
|
+
memory, stored as a resource of type \`ai_agent\`. It is built once and used in several places: it is
|
|
87931
|
+
run from its own page (a chat, or a run form), a flow's AI agent step links to it by path, and it
|
|
87932
|
+
can be shared in Slack channels from its page. Build a standalone agent when the user wants an
|
|
87933
|
+
assistant they talk to or reuse. Build a flow when the agent is one step of a larger process.
|
|
87934
|
+
|
|
87935
|
+
## File Format
|
|
87936
|
+
|
|
87937
|
+
An agent is a resource file like any other, \`{path}.resource.yaml\` (or \`.resource.json\`), with
|
|
87938
|
+
\`resource_type: ai_agent\`.
|
|
87939
|
+
|
|
87940
|
+
## Structure
|
|
87941
|
+
|
|
87942
|
+
\`\`\`json
|
|
87943
|
+
{
|
|
87944
|
+
"resource_type": "ai_agent",
|
|
87945
|
+
"description": "Answers support questions from the product docs",
|
|
87946
|
+
"value": {
|
|
87947
|
+
"provider": { "kind": "openai", "resource": "$res:f/ai_providers/openai", "model": "gpt-4o" },
|
|
87948
|
+
"system_prompt": "You are the support assistant for Acme. Answer from the docs; say so when they don't cover a question.",
|
|
87949
|
+
"memory": { "kind": "compaction" },
|
|
87950
|
+
"output_type": "text",
|
|
87951
|
+
"tools": [
|
|
87952
|
+
{
|
|
87953
|
+
"id": "search_docs",
|
|
87954
|
+
"summary": "search_documentation",
|
|
87955
|
+
"description": "Search the product documentation. Use it whenever the user asks how a feature works.",
|
|
87956
|
+
"value": {
|
|
87957
|
+
"tool_type": "flowmodule",
|
|
87958
|
+
"type": "script",
|
|
87959
|
+
"path": "f/support/search_docs",
|
|
87960
|
+
"input_transforms": {
|
|
87961
|
+
"query": { "type": "ai" },
|
|
87962
|
+
"index": { "type": "static", "value": "product_docs" }
|
|
87963
|
+
}
|
|
87964
|
+
}
|
|
87965
|
+
}
|
|
87966
|
+
]
|
|
87967
|
+
}
|
|
87968
|
+
}
|
|
87969
|
+
\`\`\`
|
|
87970
|
+
|
|
87971
|
+
The agent's own settings are plain values, not the \`input_transforms\` an agent step in a flow uses:
|
|
87972
|
+
each is fixed when the agent is saved. Only a tool's arguments keep \`input_transforms\` (see Tools). \`$res:\` and \`$var:\` references inside it are resolved at run time.
|
|
87973
|
+
|
|
87974
|
+
- \`provider\` (required): \`{ "kind", "resource": "$res:<path>", "model" }\`, plus an optional
|
|
87975
|
+
\`reasoning_effort\`. \`resource\` names the workspace's AI provider resource of that kind
|
|
87976
|
+
- \`system_prompt\`: how the agent behaves. Write it for the agent's job: who it serves, what it may
|
|
87977
|
+
do with its tools, and what it should refuse or hand back
|
|
87978
|
+
- \`memory\`: what lets the agent see earlier turns. \`{ "kind": "compaction" }\` keeps the whole
|
|
87979
|
+
conversation, summarizing its older part as it nears the model's context window; it is what a new
|
|
87980
|
+
agent starts with on its page. \`{ "kind": "off" }\` makes every run start from nothing, right for an
|
|
87981
|
+
agent that handles one request per run
|
|
87982
|
+
- \`output_type\`: \`text\` (default) or \`image\`. Image output ignores tools and needs S3 storage on the
|
|
87983
|
+
workspace
|
|
87984
|
+
- \`output_schema\`: a JSON schema the answer must follow, for an agent whose output a program reads
|
|
87985
|
+
- \`max_iterations\`: how many model and tool rounds a run may take, 1 to 1000 (default 10)
|
|
87986
|
+
- \`streaming\` (default on), \`temperature\`, \`max_completion_tokens\`: as their names say
|
|
87987
|
+
- \`run_on_behalf_of\`: runs from the agent's page take the identity the agent was deployed with
|
|
87988
|
+
rather than the caller's, so people can use it without access to what its tools touch.
|
|
87989
|
+
\`slack_anyone\` lets anyone in the Slack channels it is shared in ask it, and is kept only with
|
|
87990
|
+
\`run_on_behalf_of\`. Set either only when the user asks: both widen who acts with the deployer's
|
|
87991
|
+
rights
|
|
87992
|
+
- \`on_behalf_of\` is the identity itself. Deploying sets it, so never write it
|
|
87993
|
+
|
|
87994
|
+
## Tools
|
|
87995
|
+
|
|
87996
|
+
\`tools\` takes the same entries as a flow's AI agent step. \`value.tool_type\` is \`flowmodule\` for a
|
|
87997
|
+
script or inline script the agent calls (or a nested agent or AI decision), \`mcp\` for an MCP server
|
|
87998
|
+
(\`{ "tool_type": "mcp", "resource_path": "$res:<path>", "include_tools": [], "exclude_tools": [] }\`),
|
|
87999
|
+
or \`websearch\` for web search (\`{ "tool_type": "websearch" }\`, summary \`Web Search\`).
|
|
88000
|
+
|
|
88001
|
+
- Write logic made for this agent as an inline \`rawscript\` tool, as a flow writes its steps. Point a
|
|
88002
|
+
\`script\` tool at a deployed script (\`path\`) only when one already does the job: a run calls the
|
|
88003
|
+
deployed version, so a script that exists only as a draft fails the run. An inline tool's
|
|
88004
|
+
\`value\` is a flow's rawscript step:
|
|
88005
|
+
\`{ "tool_type": "flowmodule", "type": "rawscript", "language": "bun", "content": "export async function main(query: string) { ... }", "input_transforms": { "query": { "type": "ai" } } }\`
|
|
88006
|
+
- A flow cannot be a tool: a run offered one fails with \`Unsupported tool\`. Wrap it in a script
|
|
88007
|
+
that runs the flow
|
|
88008
|
+
- A flowmodule tool's \`summary\` is the name the agent calls it by: letters, numbers and underscores
|
|
88009
|
+
only, unique among the agent's tools, and neither a reserved step id (a JavaScript keyword, \`ctx\`,
|
|
88010
|
+
\`state\`, \`bg\`) nor \`__wm_web_search\`. Put the explanation in \`description\`, which tells the agent
|
|
88011
|
+
when to call it
|
|
88012
|
+
- Each argument of a tool is either the model's or fixed. \`{ "type": "ai" }\` (or no value) lets the
|
|
88013
|
+
model fill it; a static value fixes it and hides it from the model. Fix what the model must not
|
|
88014
|
+
choose, such as a resource, a table name or a limit
|
|
88015
|
+
|
|
88016
|
+
## Using It From a Flow
|
|
88017
|
+
|
|
88018
|
+
An AI agent step links to a saved agent with \`value.agent\` instead of carrying its own \`provider\`,
|
|
88019
|
+
system prompt and tools:
|
|
88020
|
+
|
|
88021
|
+
\`\`\`json
|
|
88022
|
+
{
|
|
88023
|
+
"id": "support",
|
|
88024
|
+
"value": {
|
|
88025
|
+
"type": "aiagent",
|
|
88026
|
+
"agent": "f/support/support_agent",
|
|
88027
|
+
"input_transforms": {
|
|
88028
|
+
"user_message": { "type": "javascript", "expr": "flow_input.question" }
|
|
88029
|
+
},
|
|
88030
|
+
"tools": []
|
|
88031
|
+
}
|
|
88032
|
+
}
|
|
88033
|
+
\`\`\`
|
|
88034
|
+
|
|
88035
|
+
The step holds only what belongs to one use of the agent: \`user_message\`, \`user_attachments\`,
|
|
88036
|
+
\`enabled_tools\`, \`memory_id\`, \`previous_messages\`, and the \`model\` and \`reasoning_effort\` overrides.
|
|
88037
|
+
Its \`value.tool_inputs\` (\`{ "<tool id>": { "<argument>": <input transform> } }\`) wires a saved
|
|
88038
|
+
tool's arguments to this flow, e.g. \`flow_input.customer_id\`, over the transforms the agent saved,
|
|
88039
|
+
without changing the agent. Everything else comes from the agent, so a change to the agent reaches
|
|
88040
|
+
every flow linking it.
|
|
87903
88041
|
`,
|
|
87904
88042
|
"write-workflow-as-code": `---
|
|
87905
88043
|
name: write-workflow-as-code
|
|
@@ -88782,7 +88920,7 @@ write a secret you were not given: keep the placeholder.
|
|
|
88782
88920
|
| \`git_sync\` | \`{ repositories: [...] }\`, each with \`git_repo_resource_path\`, \`script_path\` and \`settings\` (include/exclude paths and types). Server-owned fields (webhook secrets, sync state, credentials) are never read nor written. |
|
|
88783
88921
|
| \`datatable\` | \`{ datatables: { <name>: { database: { resource_type, resource_path } } } }\`, both required: \`resource_type: postgresql\` with \`resource_path\` a Postgres resource's path, or \`instance\`, or \`external_instance\` (Enterprise only), with \`resource_path\` the name of a database a superadmin set up. A fork's entry can instead be \`{ reference: { workspace_id, datatable } }\`, pointing at its parent's data table; keep it as is. \`main\` is the one scripts use by default. Role permissions are \`datatable_permissions\`. |
|
|
88784
88922
|
| \`datatable_permissions\` | \`{ <data table>: { default_role, roles: { <role>: [tenants] } } }\`: who may connect to each data table as which role. Tenants are \`u/<user>\`, \`g/<group>\`, \`f/<folder>\` or \`*\`; \`admin\` is always a role, and \`default_role: null\` means no default. A data table the value omits is no longer under roles. Only a data table on a cluster Windmill manages can be. |
|
|
88785
|
-
| \`protection_rules\` | \`{ <rule name>: { rules: [...], bypass_groups: [...], bypass_users: [...] } }\`, rules among \`DisableDirectDeployment\`, \`DisableWorkspaceForking\`, \`RestrictDeployToDeployers\`, \`RestrictAnonymousAppDeployment\`, \`RestrictPublicRunSharing\`, \`RestrictGuestAppDeployment\`, \`RequireIsolatedForks\`. A rule the value omits is deleted. The dev workspace lock is not listed and cannot be set here. |
|
|
88923
|
+
| \`protection_rules\` | \`{ <rule name>: { rules: [...], bypass_groups: [...], bypass_users: [...], fork_role_mapping?: { <role here>: <role in its forks> } } }\`, rules among \`DisableDirectDeployment\`, \`DisableWorkspaceForking\`, \`RestrictDeployToDeployers\`, \`RestrictAnonymousAppDeployment\`, \`RestrictPublicRunSharing\`, \`RestrictGuestAppDeployment\`, \`RequireIsolatedForks\`. A rule the value omits is deleted. The dev workspace lock is not listed and cannot be set here. |
|
|
88786
88924
|
| \`ducklake\` | \`{ ducklakes: { <name>: { catalog, storage, ... } } }\`. |
|
|
88787
88925
|
| \`dbt_warehouses\` | dbt warehouse connections. |
|
|
88788
88926
|
| \`default_app\` | Path of the app shown as the workspace home. |
|
|
@@ -89362,6 +89500,20 @@ resource type related commands
|
|
|
89362
89500
|
- \`resource-type push <file_path:string> <name:string>\` - push a local resource spec. This overrides any remote versions.
|
|
89363
89501
|
- \`resource-type generate-namespace\` - Create a TypeScript definition file with the RT namespace generated from the resource types
|
|
89364
89502
|
|
|
89503
|
+
### review
|
|
89504
|
+
|
|
89505
|
+
Review a pull request on a git sync repository with the workspace's AI, the way deployment requests are reviewed. Reads the changes and the base branch's review instructions from git; the instance, workspace and token come from the flags, never from the checkout's wmill.yaml.
|
|
89506
|
+
|
|
89507
|
+
**Options:**
|
|
89508
|
+
- \`--base <ref:string>\` - The base branch commit. Defaults to the pull_request event's base.
|
|
89509
|
+
- \`--head <ref:string>\` - The pull request's commit. Defaults to the event's head, else HEAD.
|
|
89510
|
+
- \`--model <model:string>\` - provider:model to review with. Defaults to the workspace's default model.
|
|
89511
|
+
- \`--folder <dir:string>\` - The repository directory the workspace is synced into, when it is not the root.
|
|
89512
|
+
- \`--json\` - Print the review as JSON
|
|
89513
|
+
- \`--post <target:string>\` - Post the review on the pull request. Only \`github\` is supported.
|
|
89514
|
+
- \`--pr <number:number>\` - The pull request number. Defaults to the pull_request event's.
|
|
89515
|
+
- \`--fail-on <severity:string>\` - Exit with 1 when a finding is at least this severe: high, medium or low.
|
|
89516
|
+
|
|
89365
89517
|
### schedule
|
|
89366
89518
|
|
|
89367
89519
|
schedule related commands
|
|
@@ -91533,7 +91685,7 @@ var init_freshness = __esm(async () => {
|
|
|
91533
91685
|
// src/commands/refresh/tsconfig.ts
|
|
91534
91686
|
import { execSync as execSync6 } from "node:child_process";
|
|
91535
91687
|
import { createHash as createHash3 } from "node:crypto";
|
|
91536
|
-
import { existsSync as existsSync20, readFileSync as
|
|
91688
|
+
import { existsSync as existsSync20, readFileSync as readFileSync6, writeFileSync as writeFileSync9 } from "node:fs";
|
|
91537
91689
|
import path26 from "node:path";
|
|
91538
91690
|
import process25 from "node:process";
|
|
91539
91691
|
function buildManagedTsconfig() {
|
|
@@ -91671,7 +91823,7 @@ async function ensureUserReferencesManaged(opts) {
|
|
|
91671
91823
|
const existingName = path26.basename(existing);
|
|
91672
91824
|
let text = "";
|
|
91673
91825
|
try {
|
|
91674
|
-
text =
|
|
91826
|
+
text = readFileSync6(existing, "utf-8");
|
|
91675
91827
|
} catch {
|
|
91676
91828
|
return;
|
|
91677
91829
|
}
|
|
@@ -91739,7 +91891,7 @@ async function warnIfTsconfigStale(opts) {
|
|
|
91739
91891
|
return;
|
|
91740
91892
|
let managedText;
|
|
91741
91893
|
try {
|
|
91742
|
-
managedText =
|
|
91894
|
+
managedText = readFileSync6(managedPath, "utf-8");
|
|
91743
91895
|
} catch {
|
|
91744
91896
|
return;
|
|
91745
91897
|
}
|
|
@@ -91756,7 +91908,7 @@ function emitTsconfigWarning(message) {
|
|
|
91756
91908
|
process25.stderr.write(`${colors.yellow(message)}
|
|
91757
91909
|
`);
|
|
91758
91910
|
}
|
|
91759
|
-
var WORKSPACE_IMPORT_DIRS, MANAGED_TSCONFIG = "tsconfig.wmill.json", MANAGED_IMPORT_MAP = "import_map.wmill.json", MANAGED_NOTICE, TSCONFIG_HASH_PREFIX = "// wmill-tsconfig-hash: ", TSCONFIG_HASH_REGEX, LEGACY_GENERATED_TSCONFIGS,
|
|
91911
|
+
var WORKSPACE_IMPORT_DIRS, MANAGED_TSCONFIG = "tsconfig.wmill.json", MANAGED_IMPORT_MAP = "import_map.wmill.json", MANAGED_NOTICE, TSCONFIG_HASH_PREFIX = "// wmill-tsconfig-hash: ", TSCONFIG_HASH_REGEX, LEGACY_GENERATED_TSCONFIGS, command33, tsconfig_default;
|
|
91760
91912
|
var init_tsconfig = __esm(async () => {
|
|
91761
91913
|
init_colors2();
|
|
91762
91914
|
init_mod3();
|
|
@@ -91792,10 +91944,10 @@ var init_tsconfig = __esm(async () => {
|
|
|
91792
91944
|
include: ["**/*.ts", "rt.d.ts"]
|
|
91793
91945
|
}
|
|
91794
91946
|
];
|
|
91795
|
-
|
|
91947
|
+
command33 = new Command().description("Refresh the wmill-managed tsconfig.wmill.json (and Deno import map for Deno projects)").option("--yes", "Non-interactive: wire an existing custom tsconfig.json/deno.json to the managed file without prompting (a previously-generated config is always migrated automatically).").action(async (opts) => {
|
|
91796
91948
|
await refreshTsconfig({ yes: opts.yes === true });
|
|
91797
91949
|
});
|
|
91798
|
-
tsconfig_default =
|
|
91950
|
+
tsconfig_default = command33;
|
|
91799
91951
|
});
|
|
91800
91952
|
|
|
91801
91953
|
// src/main.ts
|
|
@@ -92992,6 +93144,10 @@ await init_conf();
|
|
|
92992
93144
|
function sortedUnique(arr) {
|
|
92993
93145
|
return [...new Set(arr)].sort();
|
|
92994
93146
|
}
|
|
93147
|
+
function sortedMapping(m) {
|
|
93148
|
+
const keys = Object.keys(m ?? {}).sort();
|
|
93149
|
+
return keys.length > 0 ? Object.fromEntries(keys.map((k) => [k, m[k]])) : undefined;
|
|
93150
|
+
}
|
|
92995
93151
|
|
|
92996
93152
|
class ProtectionRulesConverter {
|
|
92997
93153
|
static normalizeEntry(entry) {
|
|
@@ -92999,7 +93155,8 @@ class ProtectionRulesConverter {
|
|
|
92999
93155
|
name: entry.name,
|
|
93000
93156
|
rules: sortedUnique(entry.rules ?? []),
|
|
93001
93157
|
bypass_groups: sortedUnique(entry.bypass_groups ?? []),
|
|
93002
|
-
bypass_users: sortedUnique(entry.bypass_users ?? [])
|
|
93158
|
+
bypass_users: sortedUnique(entry.bypass_users ?? []),
|
|
93159
|
+
...sortedMapping(entry.fork_role_mapping) ? { fork_role_mapping: sortedMapping(entry.fork_role_mapping) } : {}
|
|
93003
93160
|
};
|
|
93004
93161
|
}
|
|
93005
93162
|
static normalizeList(entries) {
|
|
@@ -93010,13 +93167,14 @@ class ProtectionRulesConverter {
|
|
|
93010
93167
|
name: r.name,
|
|
93011
93168
|
rules: [...r.rules ?? []],
|
|
93012
93169
|
bypass_groups: [...r.bypass_groups ?? []],
|
|
93013
|
-
bypass_users: [...r.bypass_users ?? []]
|
|
93170
|
+
bypass_users: [...r.bypass_users ?? []],
|
|
93171
|
+
fork_role_mapping: { ...r.fork_role_mapping ?? {} }
|
|
93014
93172
|
})));
|
|
93015
93173
|
}
|
|
93016
93174
|
static entriesEqual(a, b) {
|
|
93017
93175
|
const na = ProtectionRulesConverter.normalizeEntry(a);
|
|
93018
93176
|
const nb = ProtectionRulesConverter.normalizeEntry(b);
|
|
93019
|
-
return na.name === nb.name && na.rules.length === nb.rules.length && na.rules.every((v, i) => v === nb.rules[i]) && na.bypass_groups.length === nb.bypass_groups.length && na.bypass_groups.every((v, i) => v === nb.bypass_groups[i]) && na.bypass_users.length === nb.bypass_users.length && na.bypass_users.every((v, i) => v === nb.bypass_users[i]);
|
|
93177
|
+
return na.name === nb.name && na.rules.length === nb.rules.length && na.rules.every((v, i) => v === nb.rules[i]) && na.bypass_groups.length === nb.bypass_groups.length && na.bypass_groups.every((v, i) => v === nb.bypass_groups[i]) && na.bypass_users.length === nb.bypass_users.length && na.bypass_users.every((v, i) => v === nb.bypass_users[i]) && JSON.stringify(na.fork_role_mapping ?? {}) === JSON.stringify(nb.fork_role_mapping ?? {});
|
|
93020
93178
|
}
|
|
93021
93179
|
static listsEqual(a, b) {
|
|
93022
93180
|
const na = ProtectionRulesConverter.normalizeList(a);
|
|
@@ -93157,6 +93315,10 @@ function describeEntry(entry) {
|
|
|
93157
93315
|
if (n.bypass_users.length > 0) {
|
|
93158
93316
|
parts.push(`bypass_users=[${n.bypass_users.join(", ")}]`);
|
|
93159
93317
|
}
|
|
93318
|
+
if (n.fork_role_mapping) {
|
|
93319
|
+
const pairs = Object.entries(n.fork_role_mapping).map(([f, t]) => `${f}->${t}`);
|
|
93320
|
+
parts.push(`fork_role_mapping=[${pairs.join(", ")}]`);
|
|
93321
|
+
}
|
|
93160
93322
|
return parts.join(" ");
|
|
93161
93323
|
}
|
|
93162
93324
|
function displayPlan(ws, plan) {
|
|
@@ -93428,7 +93590,8 @@ async function pushProtectionRules(opts, workspaceArg) {
|
|
|
93428
93590
|
name: n.name,
|
|
93429
93591
|
rules: n.rules,
|
|
93430
93592
|
bypass_groups: n.bypass_groups,
|
|
93431
|
-
bypass_users: n.bypass_users
|
|
93593
|
+
bypass_users: n.bypass_users,
|
|
93594
|
+
fork_role_mapping: n.fork_role_mapping ?? {}
|
|
93432
93595
|
}
|
|
93433
93596
|
});
|
|
93434
93597
|
applied.created++;
|
|
@@ -93441,7 +93604,8 @@ async function pushProtectionRules(opts, workspaceArg) {
|
|
|
93441
93604
|
requestBody: {
|
|
93442
93605
|
rules: n.rules,
|
|
93443
93606
|
bypass_groups: n.bypass_groups,
|
|
93444
|
-
bypass_users: n.bypass_users
|
|
93607
|
+
bypass_users: n.bypass_users,
|
|
93608
|
+
fork_role_mapping: n.fork_role_mapping ?? {}
|
|
93445
93609
|
}
|
|
93446
93610
|
});
|
|
93447
93611
|
applied.updated++;
|
|
@@ -93717,6 +93881,626 @@ async function digest(opts, ...paths) {
|
|
|
93717
93881
|
var command27 = new Command().description("Compute the content digest of local scripts and flows, as the `digest` and `root_digest` claims of job OIDC tokens carry it. Run from the root of a sync checkout, pulled after the deployment's dependency jobs completed: they write the lockfiles the digest covers. A flow also lists the digest of each inline step, as `<flow path>/<step id>`.").arguments("<paths...:string>").option("--json", "Output the digests as JSON").action(digest);
|
|
93718
93882
|
var digest_default = command27;
|
|
93719
93883
|
|
|
93884
|
+
// src/commands/review/review.ts
|
|
93885
|
+
init_mod3();
|
|
93886
|
+
init_colors2();
|
|
93887
|
+
init_log();
|
|
93888
|
+
init_services_gen();
|
|
93889
|
+
await __promiseAll([
|
|
93890
|
+
init_auth(),
|
|
93891
|
+
init_context(),
|
|
93892
|
+
init_types(),
|
|
93893
|
+
init_resource_folders(),
|
|
93894
|
+
init_utils(),
|
|
93895
|
+
init_yaml()
|
|
93896
|
+
]);
|
|
93897
|
+
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
93898
|
+
import { readFileSync as readFileSync5 } from "node:fs";
|
|
93899
|
+
import { posix } from "node:path";
|
|
93900
|
+
|
|
93901
|
+
// src/commands/review/aiReviewCore.gen.ts
|
|
93902
|
+
var MAX_FOLDER_INSTRUCTIONS_LENGTH = 32 * 1024;
|
|
93903
|
+
var MAX_FOLDER_INSTRUCTIONS_TOTAL = 48 * 1024;
|
|
93904
|
+
function folderInstructionScope(path) {
|
|
93905
|
+
return path.slice(0, path.lastIndexOf("/") + 1);
|
|
93906
|
+
}
|
|
93907
|
+
function instructionsCovering(instructions, paths) {
|
|
93908
|
+
return instructions.filter((i) => paths.some((p) => `${p}/`.startsWith(i.scope))).sort((a, b) => a.scope.length - b.scope.length || a.path.localeCompare(b.path));
|
|
93909
|
+
}
|
|
93910
|
+
function truncateForPrompt(text, maxBytes) {
|
|
93911
|
+
const encoded = new TextEncoder().encode(text);
|
|
93912
|
+
if (encoded.byteLength <= maxBytes)
|
|
93913
|
+
return text;
|
|
93914
|
+
const cut = new TextDecoder("utf-8").decode(encoded.slice(0, maxBytes)).replace(/�$/, "");
|
|
93915
|
+
return `${cut}… [truncated]`;
|
|
93916
|
+
}
|
|
93917
|
+
function folderInstructionsOpeningTag(path) {
|
|
93918
|
+
return `<folder_instructions path="${path}"`;
|
|
93919
|
+
}
|
|
93920
|
+
function formatFolderInstructions(blocks) {
|
|
93921
|
+
let remaining = MAX_FOLDER_INSTRUCTIONS_TOTAL;
|
|
93922
|
+
const bodies = [...blocks].reverse().map(({ body }) => {
|
|
93923
|
+
const cut = truncateForPrompt(body, Math.min(MAX_FOLDER_INSTRUCTIONS_LENGTH, remaining));
|
|
93924
|
+
remaining = Math.max(0, remaining - new TextEncoder().encode(cut).byteLength);
|
|
93925
|
+
return cut;
|
|
93926
|
+
});
|
|
93927
|
+
bodies.reverse();
|
|
93928
|
+
return blocks.map(({ instruction }, i) => `${folderInstructionsOpeningTag(instruction.path)} scope="${instruction.scope}">
|
|
93929
|
+
${bodies[i]}
|
|
93930
|
+
</folder_instructions>`).join(`
|
|
93931
|
+
|
|
93932
|
+
`);
|
|
93933
|
+
}
|
|
93934
|
+
var REVIEW_INSTRUCTIONS_RESOURCE_TYPE = "ai_review_instruction";
|
|
93935
|
+
var VALUE_WITHHELD_KINDS = new Set(["variable", "resource"]);
|
|
93936
|
+
var PER_SIDE_CHAR_CAP = 20000;
|
|
93937
|
+
var TOTAL_CHAR_BUDGET = 160000;
|
|
93938
|
+
var MAX_OUTPUT_TOKENS = 8000;
|
|
93939
|
+
var INTRO = {
|
|
93940
|
+
deployment_request: "You review a Windmill deployment request: a set of changes made in a fork workspace that will be merged into its parent workspace. Each changed item is given with its parent version (what is deployed now) and its fork version (what will be deployed).",
|
|
93941
|
+
pull_request: "You review a pull request on a git repository that Windmill's git sync keeps in step with a workspace: merging it deploys its changes. Each changed item is given with the files that make it up in the repository, each as a unified diff of the base branch (what is deployed now) against the pull request (what will be deployed). Every diff line starts with its line number: R<n> for line n of the pull request's version of the file, L<n> for line n of the base version, then + for an added line, - for a removed one and a space for unchanged context."
|
|
93942
|
+
};
|
|
93943
|
+
var ANSWER_SHAPE = {
|
|
93944
|
+
deployment_request: '{"summary": "<one or two sentences on what the change does and its overall risk>", "findings": [{"kind": "<item kind as given>", "path": "<item path as given>", "severity": "high" | "medium" | "low", "comment": "<the issue and what to do about it, under 80 words>"}]}',
|
|
93945
|
+
pull_request: '{"summary": "<one or two sentences on what the change does and its overall risk>", "findings": [{"kind": "<item kind as given>", "path": "<item path as given>", "file": "<the file the issue is in, as given>", "line": "<the R or L line number the issue is on, as given, such as R12, or null for the file as a whole>", "severity": "high" | "medium" | "low", "comment": "<the issue and what to do about it, under 80 words>"}]}'
|
|
93946
|
+
};
|
|
93947
|
+
var SOURCE = {
|
|
93948
|
+
deployment_request: "The parent workspace",
|
|
93949
|
+
pull_request: "The repository's base branch"
|
|
93950
|
+
};
|
|
93951
|
+
function reviewSystemPrompt(subject) {
|
|
93952
|
+
return `${INTRO[subject]} An item can be a script, flow, app, schedule, trigger, folder, resource type, datatable migration, variable or resource.
|
|
93953
|
+
|
|
93954
|
+
Report only issues a reviewer should act on before approving the merge:
|
|
93955
|
+
- bugs and logic errors introduced by the change
|
|
93956
|
+
- breaking changes: removed or renamed inputs, changed input types, changed outputs that callers may rely on
|
|
93957
|
+
- risky operational changes: schedules retimed, triggers pointed at a different script or flow, folder owners or permissions, app policies, destructive migrations
|
|
93958
|
+
- hardcoded secrets or credentials
|
|
93959
|
+
- deletions that look unintended
|
|
93960
|
+
|
|
93961
|
+
Do not comment on style, naming, formatting or lockfiles, and do not praise. Do not repeat a finding for every item it touches. An item with no issue gets no finding.
|
|
93962
|
+
|
|
93963
|
+
Answer with JSON only, no prose around it, in this shape:
|
|
93964
|
+
${ANSWER_SHAPE[subject]}`;
|
|
93965
|
+
}
|
|
93966
|
+
function reviewInstructionsSection(subject, blocks) {
|
|
93967
|
+
if (blocks.length === 0)
|
|
93968
|
+
return "";
|
|
93969
|
+
return `
|
|
93970
|
+
|
|
93971
|
+
${SOURCE[subject]} gives the review instructions below, each for the changed items under the folder in its scope. For those items they take precedence over the instructions above, and a nested folder's over its parent folder's. They may ask you to check more, check less or weigh severity differently, except that hardcoded secrets or credentials and deletions that look unintended are always reported. The answer is still the JSON above.
|
|
93972
|
+
|
|
93973
|
+
${formatFolderInstructions(blocks)}`;
|
|
93974
|
+
}
|
|
93975
|
+
function capText(text, cap) {
|
|
93976
|
+
return text.length > cap ? `${text.slice(0, cap)}
|
|
93977
|
+
… (truncated, ${text.length - cap} more characters)` : text;
|
|
93978
|
+
}
|
|
93979
|
+
|
|
93980
|
+
class ReviewBudget {
|
|
93981
|
+
included = [];
|
|
93982
|
+
omitted = [];
|
|
93983
|
+
spent = false;
|
|
93984
|
+
used = 0;
|
|
93985
|
+
add(key, section) {
|
|
93986
|
+
if (!this.spent && this.used + section.length <= TOTAL_CHAR_BUDGET) {
|
|
93987
|
+
this.included.push(section);
|
|
93988
|
+
this.used += section.length;
|
|
93989
|
+
} else {
|
|
93990
|
+
this.spent = true;
|
|
93991
|
+
this.omitted.push(key);
|
|
93992
|
+
}
|
|
93993
|
+
}
|
|
93994
|
+
userPrompt(header) {
|
|
93995
|
+
let user = `${header}
|
|
93996
|
+
|
|
93997
|
+
${this.included.join(`
|
|
93998
|
+
|
|
93999
|
+
`)}`;
|
|
94000
|
+
if (this.omitted.length > 0) {
|
|
94001
|
+
user += `
|
|
94002
|
+
|
|
94003
|
+
Also changed, contents not shown for size:
|
|
94004
|
+
${this.omitted.map((o) => `- ${o}`).join(`
|
|
94005
|
+
`)}`;
|
|
94006
|
+
}
|
|
94007
|
+
return user;
|
|
94008
|
+
}
|
|
94009
|
+
}
|
|
94010
|
+
function parseReviewAnswer(text, anchors) {
|
|
94011
|
+
const start = text.indexOf("{");
|
|
94012
|
+
const end = text.lastIndexOf("}");
|
|
94013
|
+
if (start === -1 || end <= start) {
|
|
94014
|
+
throw new Error("The AI answer was not in the expected format");
|
|
94015
|
+
}
|
|
94016
|
+
const parsed = JSON.parse(text.slice(start, end + 1));
|
|
94017
|
+
const findings = [];
|
|
94018
|
+
for (const [i, raw] of (Array.isArray(parsed.findings) ? parsed.findings : []).entries()) {
|
|
94019
|
+
if (!raw || typeof raw.comment !== "string" || !raw.comment.trim())
|
|
94020
|
+
continue;
|
|
94021
|
+
const anchored = anchors.items.has(`${raw.kind}:${raw.path}`);
|
|
94022
|
+
const finding = {
|
|
94023
|
+
id: String(i),
|
|
94024
|
+
kind: anchored ? raw.kind : "",
|
|
94025
|
+
path: anchored ? raw.path : "",
|
|
94026
|
+
severity: ["high", "medium", "low"].includes(raw.severity) ? raw.severity : "medium",
|
|
94027
|
+
comment: raw.comment.trim()
|
|
94028
|
+
};
|
|
94029
|
+
const fileLines = typeof raw.file === "string" ? anchors.lines?.get(raw.file) : undefined;
|
|
94030
|
+
if (fileLines) {
|
|
94031
|
+
finding.file = raw.file;
|
|
94032
|
+
const line = /^([LR])(\d+)$/.exec(String(raw.line ?? "").trim());
|
|
94033
|
+
const side = line?.[1] === "L" ? "LEFT" : "RIGHT";
|
|
94034
|
+
if (line && fileLines[side].has(Number(line[2]))) {
|
|
94035
|
+
finding.side = side;
|
|
94036
|
+
finding.line = Number(line[2]);
|
|
94037
|
+
}
|
|
94038
|
+
}
|
|
94039
|
+
findings.push(finding);
|
|
94040
|
+
}
|
|
94041
|
+
const rank = { high: 0, medium: 1, low: 2 };
|
|
94042
|
+
findings.sort((a, b) => rank[a.severity] - rank[b.severity]);
|
|
94043
|
+
return { summary: typeof parsed.summary === "string" ? parsed.summary : "", findings };
|
|
94044
|
+
}
|
|
94045
|
+
|
|
94046
|
+
// src/commands/review/review.ts
|
|
94047
|
+
var GITHUB_DIFF_CONTEXT = 3;
|
|
94048
|
+
var MODEL_DIFF_CONTEXT = 20;
|
|
94049
|
+
function git2(args) {
|
|
94050
|
+
return execFileSync3("git", ["-c", "core.quotePath=false", ...args], {
|
|
94051
|
+
encoding: "utf-8",
|
|
94052
|
+
maxBuffer: 512 * 1024 * 1024,
|
|
94053
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
94054
|
+
});
|
|
94055
|
+
}
|
|
94056
|
+
function itemOf(file) {
|
|
94057
|
+
const containers = [
|
|
94058
|
+
[".fileset/", "resource"],
|
|
94059
|
+
["__mod/", "script"],
|
|
94060
|
+
[`${DBT_MODULE_SUFFIX}/`, "script"],
|
|
94061
|
+
...[DOTTED_SUFFIXES, NON_DOTTED_SUFFIXES].flatMap((suffixes) => Object.entries(suffixes).map(([kind, suffix]) => [`${suffix}/`, kind]))
|
|
94062
|
+
];
|
|
94063
|
+
let outermost;
|
|
94064
|
+
for (const [marker, kind] of containers) {
|
|
94065
|
+
const i = file.indexOf(marker);
|
|
94066
|
+
if (i > 0 && (!outermost || i < outermost.path.length)) {
|
|
94067
|
+
outermost = { kind, path: file.slice(0, i) };
|
|
94068
|
+
}
|
|
94069
|
+
}
|
|
94070
|
+
if (outermost)
|
|
94071
|
+
return outermost;
|
|
94072
|
+
if (parseDatatableMigrationPath(file))
|
|
94073
|
+
return { kind: "datatable_migration", path: file };
|
|
94074
|
+
const sidecar = file.indexOf(".resource.file.");
|
|
94075
|
+
if (sidecar > 0)
|
|
94076
|
+
return { kind: "resource", path: file.slice(0, sidecar) };
|
|
94077
|
+
let kind;
|
|
94078
|
+
try {
|
|
94079
|
+
kind = getTypeStrFromPath(file);
|
|
94080
|
+
} catch {
|
|
94081
|
+
return { kind: "file", path: file };
|
|
94082
|
+
}
|
|
94083
|
+
if (kind === "folder")
|
|
94084
|
+
return { kind, path: posix.dirname(file) };
|
|
94085
|
+
const dir = posix.dirname(file);
|
|
94086
|
+
const name = posix.basename(file).split(".")[0];
|
|
94087
|
+
if (!/^[ufg]\//.test(file) || !name)
|
|
94088
|
+
return { kind, path: file };
|
|
94089
|
+
return { kind, path: dir === "." ? name : `${dir}/${name}` };
|
|
94090
|
+
}
|
|
94091
|
+
function isLockfile(file) {
|
|
94092
|
+
return posix.basename(file) === "wmill-lock.yaml" || file.endsWith(".lock");
|
|
94093
|
+
}
|
|
94094
|
+
function numberDiff(diff) {
|
|
94095
|
+
if (/^Binary files .* differ$/m.test(diff))
|
|
94096
|
+
return;
|
|
94097
|
+
const out = [];
|
|
94098
|
+
const left = new Set;
|
|
94099
|
+
const right = new Set;
|
|
94100
|
+
let l = 0;
|
|
94101
|
+
let r = 0;
|
|
94102
|
+
let inHunk = false;
|
|
94103
|
+
for (const line of diff.split(`
|
|
94104
|
+
`)) {
|
|
94105
|
+
const hunk = /^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(line);
|
|
94106
|
+
if (hunk) {
|
|
94107
|
+
l = Number(hunk[1]);
|
|
94108
|
+
r = Number(hunk[2]);
|
|
94109
|
+
inHunk = true;
|
|
94110
|
+
out.push(line);
|
|
94111
|
+
continue;
|
|
94112
|
+
}
|
|
94113
|
+
if (!inHunk || line.startsWith("\\"))
|
|
94114
|
+
continue;
|
|
94115
|
+
const mark = line[0];
|
|
94116
|
+
const content = line.slice(1);
|
|
94117
|
+
if (mark === "+") {
|
|
94118
|
+
right.add(r);
|
|
94119
|
+
out.push(`R${r++} +${content}`);
|
|
94120
|
+
} else if (mark === "-") {
|
|
94121
|
+
left.add(l);
|
|
94122
|
+
out.push(`L${l++} -${content}`);
|
|
94123
|
+
} else if (mark === " ") {
|
|
94124
|
+
right.add(r);
|
|
94125
|
+
out.push(`R${r++} ${content}`);
|
|
94126
|
+
l++;
|
|
94127
|
+
}
|
|
94128
|
+
}
|
|
94129
|
+
return { text: out.join(`
|
|
94130
|
+
`), left, right };
|
|
94131
|
+
}
|
|
94132
|
+
function changedItems(mergeBase, head, root) {
|
|
94133
|
+
const out = git2(["diff", "--name-status", "--no-renames", "-z", mergeBase, head]);
|
|
94134
|
+
const fields = out.split("\x00").filter((f) => f !== "");
|
|
94135
|
+
const items = new Map;
|
|
94136
|
+
for (let i = 0;i + 1 < fields.length; i += 2) {
|
|
94137
|
+
const [code, file] = [fields[i], fields[i + 1]];
|
|
94138
|
+
if (isLockfile(file) || !file.startsWith(root))
|
|
94139
|
+
continue;
|
|
94140
|
+
const { kind, path } = itemOf(file.slice(root.length));
|
|
94141
|
+
const key = `${kind}:${path}`;
|
|
94142
|
+
const item = items.get(key) ?? { kind, path, files: [] };
|
|
94143
|
+
item.files.push({
|
|
94144
|
+
file,
|
|
94145
|
+
status: code === "A" ? "added" : code === "D" ? "deleted" : "modified"
|
|
94146
|
+
});
|
|
94147
|
+
items.set(key, item);
|
|
94148
|
+
}
|
|
94149
|
+
return [...items.values()];
|
|
94150
|
+
}
|
|
94151
|
+
function changeOf(item) {
|
|
94152
|
+
if (item.files.every((f) => f.status === "added"))
|
|
94153
|
+
return "added";
|
|
94154
|
+
if (item.files.every((f) => f.status === "deleted"))
|
|
94155
|
+
return "deleted";
|
|
94156
|
+
return "modified";
|
|
94157
|
+
}
|
|
94158
|
+
function baseInstructions(baseSha, itemPaths, root) {
|
|
94159
|
+
let listing = "";
|
|
94160
|
+
try {
|
|
94161
|
+
listing = git2([
|
|
94162
|
+
"grep",
|
|
94163
|
+
"-l",
|
|
94164
|
+
"-E",
|
|
94165
|
+
`resource_type['"]?:[[:space:]]*['"]?${REVIEW_INSTRUCTIONS_RESOURCE_TYPE}`,
|
|
94166
|
+
baseSha,
|
|
94167
|
+
"--",
|
|
94168
|
+
`${root}*.resource.yaml`,
|
|
94169
|
+
`${root}*.resource.json`
|
|
94170
|
+
]);
|
|
94171
|
+
} catch (e) {
|
|
94172
|
+
if (e.status !== 1)
|
|
94173
|
+
throw e;
|
|
94174
|
+
}
|
|
94175
|
+
const listed = listing.split(`
|
|
94176
|
+
`).filter(Boolean).map((line) => line.slice(baseSha.length + 1)).map((file) => {
|
|
94177
|
+
const path = file.slice(root.length).replace(/\.resource\.(yaml|json)$/, "");
|
|
94178
|
+
return { file, instruction: { path, scope: folderInstructionScope(path) } };
|
|
94179
|
+
});
|
|
94180
|
+
const fileOf = new Map(listed.map((l) => [l.instruction.path, l.file]));
|
|
94181
|
+
const blocks = [];
|
|
94182
|
+
const skipped = [];
|
|
94183
|
+
for (const instruction of instructionsCovering(listed.map((l) => l.instruction), itemPaths)) {
|
|
94184
|
+
const file = fileOf.get(instruction.path);
|
|
94185
|
+
try {
|
|
94186
|
+
const raw = git2(["show", `${baseSha}:${file}`]);
|
|
94187
|
+
const parsed = file.endsWith(".json") ? JSON.parse(raw) : yamlParseContent(file, raw);
|
|
94188
|
+
const content = parsed.value?.content;
|
|
94189
|
+
if (parsed.resource_type !== REVIEW_INSTRUCTIONS_RESOURCE_TYPE)
|
|
94190
|
+
continue;
|
|
94191
|
+
if (typeof content !== "string")
|
|
94192
|
+
throw new Error("no string content");
|
|
94193
|
+
const inline = /^!inline (.+)$/.exec(content);
|
|
94194
|
+
blocks.push({
|
|
94195
|
+
instruction,
|
|
94196
|
+
body: inline ? git2(["show", `${baseSha}:${root}${inline[1].trim()}`]) : content
|
|
94197
|
+
});
|
|
94198
|
+
} catch (e) {
|
|
94199
|
+
warn(`Could not read review instructions ${instruction.path}: ${e}`);
|
|
94200
|
+
skipped.push(instruction.path);
|
|
94201
|
+
}
|
|
94202
|
+
}
|
|
94203
|
+
return { blocks, skipped };
|
|
94204
|
+
}
|
|
94205
|
+
var WITHHELD_KINDS = new Set([...VALUE_WITHHELD_KINDS, "encryption_key"]);
|
|
94206
|
+
var INSTRUCTION_RESOURCE_TYPES = new Set([REVIEW_INSTRUCTIONS_RESOURCE_TYPE, "ai_instruction"]);
|
|
94207
|
+
function isInstructionResource(item, revs, root) {
|
|
94208
|
+
if (item.kind !== "resource")
|
|
94209
|
+
return false;
|
|
94210
|
+
const definition = `${root}${item.path}.resource.`;
|
|
94211
|
+
const ownFile = (file) => {
|
|
94212
|
+
if (!file.startsWith(definition))
|
|
94213
|
+
return false;
|
|
94214
|
+
const rest = file.slice(definition.length);
|
|
94215
|
+
return rest === "yaml" || rest === "json" || /^file\.[^./]+$/.test(rest);
|
|
94216
|
+
};
|
|
94217
|
+
if (!item.files.every((f) => ownFile(f.file)))
|
|
94218
|
+
return false;
|
|
94219
|
+
let defined = false;
|
|
94220
|
+
for (const rev of revs) {
|
|
94221
|
+
for (const file of [`${definition}yaml`, `${definition}json`]) {
|
|
94222
|
+
let raw;
|
|
94223
|
+
try {
|
|
94224
|
+
raw = git2(["show", `${rev}:${file}`]);
|
|
94225
|
+
} catch {
|
|
94226
|
+
continue;
|
|
94227
|
+
}
|
|
94228
|
+
try {
|
|
94229
|
+
const parsed = file.endsWith(".json") ? JSON.parse(raw) : yamlParseContent(file, raw);
|
|
94230
|
+
if (!INSTRUCTION_RESOURCE_TYPES.has(parsed.resource_type))
|
|
94231
|
+
return false;
|
|
94232
|
+
} catch {
|
|
94233
|
+
return false;
|
|
94234
|
+
}
|
|
94235
|
+
defined = true;
|
|
94236
|
+
}
|
|
94237
|
+
}
|
|
94238
|
+
return defined;
|
|
94239
|
+
}
|
|
94240
|
+
function parseModel(model) {
|
|
94241
|
+
if (!model)
|
|
94242
|
+
return;
|
|
94243
|
+
const i = model.indexOf(":");
|
|
94244
|
+
if (i <= 0)
|
|
94245
|
+
throw new Error(`--model takes provider:model, got ${model}`);
|
|
94246
|
+
return { provider: model.slice(0, i), model: model.slice(i + 1) };
|
|
94247
|
+
}
|
|
94248
|
+
function buildReviewPrompt(baseSha, headSha, folder = "") {
|
|
94249
|
+
const trimmed = folder.replace(/^\/+|\/+$/g, "");
|
|
94250
|
+
const root = trimmed ? `${trimmed}/` : "";
|
|
94251
|
+
let mergeBase;
|
|
94252
|
+
try {
|
|
94253
|
+
mergeBase = git2(["merge-base", baseSha, headSha]).trim();
|
|
94254
|
+
} catch {
|
|
94255
|
+
throw new Error(`No common ancestor between ${baseSha} and ${headSha}. Fetch the full history (actions/checkout with fetch-depth: 0).`);
|
|
94256
|
+
}
|
|
94257
|
+
const items = changedItems(mergeBase, headSha, root);
|
|
94258
|
+
const { blocks, skipped } = baseInstructions(baseSha, items.map((i) => i.path), root);
|
|
94259
|
+
const budget = new ReviewBudget;
|
|
94260
|
+
const unreadable = [];
|
|
94261
|
+
const lines = new Map;
|
|
94262
|
+
for (const item of items) {
|
|
94263
|
+
const key = `${item.kind}:${item.path}`;
|
|
94264
|
+
if (budget.spent) {
|
|
94265
|
+
budget.omitted.push(key);
|
|
94266
|
+
continue;
|
|
94267
|
+
}
|
|
94268
|
+
const header = `### ${item.kind} ${item.path} (${changeOf(item)})`;
|
|
94269
|
+
if (WITHHELD_KINDS.has(item.kind) && !isInstructionResource(item, [mergeBase, headSha], root)) {
|
|
94270
|
+
budget.add(key, `${header}
|
|
94271
|
+
Value withheld from review.`);
|
|
94272
|
+
continue;
|
|
94273
|
+
}
|
|
94274
|
+
const files = [];
|
|
94275
|
+
let failed = false;
|
|
94276
|
+
for (const { file, status } of item.files) {
|
|
94277
|
+
const shown = numberDiff(git2(["diff", "--no-color", "--no-ext-diff", `-U${MODEL_DIFF_CONTEXT}`, mergeBase, headSha, "--", `:(literal)${file}`]));
|
|
94278
|
+
const commentable = numberDiff(git2(["diff", "--no-color", "--no-ext-diff", `-U${GITHUB_DIFF_CONTEXT}`, mergeBase, headSha, "--", `:(literal)${file}`]));
|
|
94279
|
+
if (!shown || !commentable) {
|
|
94280
|
+
failed = true;
|
|
94281
|
+
files.push(`#### ${file} (${status})
|
|
94282
|
+
Contents could not be read.`);
|
|
94283
|
+
continue;
|
|
94284
|
+
}
|
|
94285
|
+
lines.set(file, { LEFT: commentable.left, RIGHT: commentable.right });
|
|
94286
|
+
files.push(`#### ${file} (${status})
|
|
94287
|
+
${capText(shown.text, 2 * PER_SIDE_CHAR_CAP)}`);
|
|
94288
|
+
}
|
|
94289
|
+
if (failed)
|
|
94290
|
+
unreadable.push(key);
|
|
94291
|
+
budget.add(key, `${header}
|
|
94292
|
+
${files.join(`
|
|
94293
|
+
`)}`);
|
|
94294
|
+
}
|
|
94295
|
+
return {
|
|
94296
|
+
system: reviewSystemPrompt("pull_request") + reviewInstructionsSection("pull_request", blocks),
|
|
94297
|
+
user: budget.userPrompt(`Base: ${baseSha}
|
|
94298
|
+
Pull request head: ${headSha}`),
|
|
94299
|
+
anchors: { items: new Set(items.map((i) => `${i.kind}:${i.path}`)), lines },
|
|
94300
|
+
omitted: budget.omitted,
|
|
94301
|
+
unreadable,
|
|
94302
|
+
instructions: blocks.map((b) => b.instruction.path),
|
|
94303
|
+
skippedInstructions: skipped
|
|
94304
|
+
};
|
|
94305
|
+
}
|
|
94306
|
+
async function reviewChanges(workspaceId, model, baseSha, headSha, folder) {
|
|
94307
|
+
const { system, user, anchors, ...reported } = buildReviewPrompt(baseSha, headSha, folder);
|
|
94308
|
+
const response = await completeAi({
|
|
94309
|
+
workspace: workspaceId,
|
|
94310
|
+
requestBody: { system, user, model: parseModel(model), max_tokens: MAX_OUTPUT_TOKENS }
|
|
94311
|
+
});
|
|
94312
|
+
return {
|
|
94313
|
+
...parseReviewAnswer(response.text, anchors),
|
|
94314
|
+
...reported,
|
|
94315
|
+
model: `${response.model.provider}:${response.model.model}`
|
|
94316
|
+
};
|
|
94317
|
+
}
|
|
94318
|
+
var SEVERITY_RANK = { high: 0, medium: 1, low: 2 };
|
|
94319
|
+
function findingLine(f) {
|
|
94320
|
+
const where = [f.path && `\`${f.path}\``, f.file && f.file !== f.path && `\`${f.file}\``].filter(Boolean).join(" ");
|
|
94321
|
+
return `- **${f.severity}**${where ? ` ${where}` : ""}: ${f.comment}`;
|
|
94322
|
+
}
|
|
94323
|
+
function reviewBody(result, marker, inBody) {
|
|
94324
|
+
const sections = [marker, "### Windmill AI review", result.summary || "No summary."];
|
|
94325
|
+
if (result.findings.length === 0)
|
|
94326
|
+
sections.push("No issues found.");
|
|
94327
|
+
if (inBody.length > 0)
|
|
94328
|
+
sections.push(inBody.map(findingLine).join(`
|
|
94329
|
+
`));
|
|
94330
|
+
const list = (title, entries) => entries.length > 0 && sections.push(`${title}
|
|
94331
|
+
${entries.map((e) => `- \`${e}\``).join(`
|
|
94332
|
+
`)}`);
|
|
94333
|
+
list("**Not reviewed**, the files could not be read as text:", result.unreadable);
|
|
94334
|
+
list("**Reviewed by name only**, over the size budget:", result.omitted);
|
|
94335
|
+
list("Review instructions applied, from the base branch:", result.instructions);
|
|
94336
|
+
list("**Review instructions skipped**, their body could not be read:", result.skippedInstructions);
|
|
94337
|
+
sections.push(`<sub>${result.model}</sub>`);
|
|
94338
|
+
return sections.join(`
|
|
94339
|
+
|
|
94340
|
+
`);
|
|
94341
|
+
}
|
|
94342
|
+
async function github(ctx, method, path, body) {
|
|
94343
|
+
const res = await fetch(`${ctx.api}/repos/${ctx.repo}${path}`, {
|
|
94344
|
+
method,
|
|
94345
|
+
headers: {
|
|
94346
|
+
Authorization: `Bearer ${ctx.token}`,
|
|
94347
|
+
Accept: "application/vnd.github+json",
|
|
94348
|
+
"X-GitHub-Api-Version": "2022-11-28",
|
|
94349
|
+
...body ? { "Content-Type": "application/json" } : {}
|
|
94350
|
+
},
|
|
94351
|
+
body: body ? JSON.stringify(body) : undefined
|
|
94352
|
+
});
|
|
94353
|
+
if (!res.ok) {
|
|
94354
|
+
const err = new Error(`GitHub ${method} ${path}: ${res.status} ${await res.text()}`);
|
|
94355
|
+
err.status = res.status;
|
|
94356
|
+
throw err;
|
|
94357
|
+
}
|
|
94358
|
+
return res.json();
|
|
94359
|
+
}
|
|
94360
|
+
async function alreadyReviewed(ctx, marker) {
|
|
94361
|
+
for (let page = 1;page <= 20; page++) {
|
|
94362
|
+
const reviews = await github(ctx, "GET", `/pulls/${ctx.pr}/reviews?per_page=100&page=${page}`);
|
|
94363
|
+
if (reviews.some((r) => r.body?.includes(marker)))
|
|
94364
|
+
return true;
|
|
94365
|
+
if (reviews.length < 100)
|
|
94366
|
+
return false;
|
|
94367
|
+
}
|
|
94368
|
+
return false;
|
|
94369
|
+
}
|
|
94370
|
+
function reviewPayload(result, headSha) {
|
|
94371
|
+
const marker = `<!-- windmill-ai-review:${headSha} -->`;
|
|
94372
|
+
const anchored = result.findings.filter((f) => f.file && f.line);
|
|
94373
|
+
return {
|
|
94374
|
+
marker,
|
|
94375
|
+
body: reviewBody(result, marker, result.findings.filter((f) => !(f.file && f.line))),
|
|
94376
|
+
comments: anchored.map((f) => ({
|
|
94377
|
+
path: f.file,
|
|
94378
|
+
line: f.line,
|
|
94379
|
+
side: f.side,
|
|
94380
|
+
body: `**${f.severity}**: ${f.comment}`
|
|
94381
|
+
})),
|
|
94382
|
+
fallback_body: reviewBody(result, marker, result.findings)
|
|
94383
|
+
};
|
|
94384
|
+
}
|
|
94385
|
+
async function postReview(ctx, headSha, result) {
|
|
94386
|
+
const { marker, body, comments, fallback_body } = reviewPayload(result, headSha);
|
|
94387
|
+
if (await alreadyReviewed(ctx, marker)) {
|
|
94388
|
+
info(`This commit already has a Windmill AI review, not posting another.`);
|
|
94389
|
+
return;
|
|
94390
|
+
}
|
|
94391
|
+
try {
|
|
94392
|
+
await github(ctx, "POST", `/pulls/${ctx.pr}/reviews`, {
|
|
94393
|
+
commit_id: headSha,
|
|
94394
|
+
event: "COMMENT",
|
|
94395
|
+
body,
|
|
94396
|
+
comments
|
|
94397
|
+
});
|
|
94398
|
+
} catch (e) {
|
|
94399
|
+
if (e.status !== 422 || comments.length === 0)
|
|
94400
|
+
throw e;
|
|
94401
|
+
warn(`GitHub refused the line comments, posting them in the review body: ${e}`);
|
|
94402
|
+
await github(ctx, "POST", `/pulls/${ctx.pr}/reviews`, {
|
|
94403
|
+
commit_id: headSha,
|
|
94404
|
+
event: "COMMENT",
|
|
94405
|
+
body: fallback_body
|
|
94406
|
+
});
|
|
94407
|
+
}
|
|
94408
|
+
info(colors.green(`Posted the review on pull request #${ctx.pr}.`));
|
|
94409
|
+
}
|
|
94410
|
+
function githubEvent() {
|
|
94411
|
+
const path = process.env.GITHUB_EVENT_PATH;
|
|
94412
|
+
if (!path)
|
|
94413
|
+
return;
|
|
94414
|
+
try {
|
|
94415
|
+
return JSON.parse(readFileSync5(path, "utf-8"));
|
|
94416
|
+
} catch {
|
|
94417
|
+
return;
|
|
94418
|
+
}
|
|
94419
|
+
}
|
|
94420
|
+
function githubContext(opts, event) {
|
|
94421
|
+
const token = process.env.GITHUB_TOKEN;
|
|
94422
|
+
const repo = process.env.GITHUB_REPOSITORY;
|
|
94423
|
+
const pr = opts.pr ?? event?.pull_request?.number;
|
|
94424
|
+
if (!token || !repo || !pr) {
|
|
94425
|
+
throw new Error("--post github needs GITHUB_TOKEN and GITHUB_REPOSITORY in the environment, and the pull request number (--pr, or a pull_request event)");
|
|
94426
|
+
}
|
|
94427
|
+
return { api: process.env.GITHUB_API_URL ?? "https://api.github.com", repo, token, pr };
|
|
94428
|
+
}
|
|
94429
|
+
function printResult(result) {
|
|
94430
|
+
info(colors.bold(result.summary || "No summary."));
|
|
94431
|
+
for (const f of result.findings) {
|
|
94432
|
+
const where = [f.path, f.file && f.line ? `${f.file}:${f.side === "LEFT" ? "L" : "R"}${f.line}` : f.file].filter(Boolean).join(" ");
|
|
94433
|
+
console.log(`${f.severity.toUpperCase()} ${where}
|
|
94434
|
+
${f.comment}`);
|
|
94435
|
+
}
|
|
94436
|
+
if (result.findings.length === 0)
|
|
94437
|
+
info("No issues found.");
|
|
94438
|
+
if (result.unreadable.length)
|
|
94439
|
+
warn(`Not reviewed, unreadable: ${result.unreadable.join(", ")}`);
|
|
94440
|
+
if (result.omitted.length)
|
|
94441
|
+
warn(`Reviewed by name only, over budget: ${result.omitted.join(", ")}`);
|
|
94442
|
+
if (result.instructions.length)
|
|
94443
|
+
info(`Review instructions applied: ${result.instructions.join(", ")}`);
|
|
94444
|
+
if (result.skippedInstructions.length) {
|
|
94445
|
+
warn(`Review instructions skipped: ${result.skippedInstructions.join(", ")}`);
|
|
94446
|
+
}
|
|
94447
|
+
}
|
|
94448
|
+
async function review(opts) {
|
|
94449
|
+
if (opts.json)
|
|
94450
|
+
setSilent(true);
|
|
94451
|
+
if (!opts.baseUrl || !opts.workspace || !opts.token) {
|
|
94452
|
+
throw new Error("wmill review needs --base-url, --workspace and --token");
|
|
94453
|
+
}
|
|
94454
|
+
const event = githubEvent();
|
|
94455
|
+
const base = opts.base ?? event?.pull_request?.base?.sha;
|
|
94456
|
+
const head = opts.head ?? event?.pull_request?.head?.sha ?? "HEAD";
|
|
94457
|
+
if (!base)
|
|
94458
|
+
throw new Error("--base is required outside a GitHub pull_request event");
|
|
94459
|
+
const baseSha = git2(["rev-parse", "--verify", `${base}^{commit}`]).trim();
|
|
94460
|
+
const headSha = git2(["rev-parse", "--verify", `${head}^{commit}`]).trim();
|
|
94461
|
+
const ctx = opts.post === "github" ? githubContext(opts, event) : undefined;
|
|
94462
|
+
await requireLogin(opts);
|
|
94463
|
+
const { workspaceId } = await resolveWorkspace(opts);
|
|
94464
|
+
let result;
|
|
94465
|
+
try {
|
|
94466
|
+
result = await reviewChanges(workspaceId, opts.model, baseSha, headSha, opts.folder);
|
|
94467
|
+
} catch (e) {
|
|
94468
|
+
if (ctx) {
|
|
94469
|
+
await github(ctx, "POST", `/pulls/${ctx.pr}/reviews`, {
|
|
94470
|
+
commit_id: headSha,
|
|
94471
|
+
event: "COMMENT",
|
|
94472
|
+
body: `### Windmill AI review
|
|
94473
|
+
|
|
94474
|
+
The review could not be completed: ${apiErrorMessage(e) ?? (e instanceof Error ? e.message : e)}`
|
|
94475
|
+
}).catch((postError) => error(`Could not report the failure on the pull request: ${postError}`));
|
|
94476
|
+
}
|
|
94477
|
+
throw e;
|
|
94478
|
+
}
|
|
94479
|
+
if (opts.json)
|
|
94480
|
+
console.log(JSON.stringify({ ...result, post: reviewPayload(result, headSha) }));
|
|
94481
|
+
else
|
|
94482
|
+
printResult(result);
|
|
94483
|
+
if (ctx)
|
|
94484
|
+
await postReview(ctx, headSha, result);
|
|
94485
|
+
if (opts.failOn && result.findings.some((f) => SEVERITY_RANK[f.severity] <= SEVERITY_RANK[opts.failOn])) {
|
|
94486
|
+
process.exitCode = 1;
|
|
94487
|
+
}
|
|
94488
|
+
}
|
|
94489
|
+
var command28 = new Command().description("Review a pull request on a git sync repository with the workspace's AI, the way deployment requests are reviewed. Reads the changes and the base branch's review instructions from git; the instance, workspace and token come from the flags, never from the checkout's wmill.yaml.").option("--base <ref:string>", "The base branch commit. Defaults to the pull_request event's base.").option("--head <ref:string>", "The pull request's commit. Defaults to the event's head, else HEAD.").option("--model <model:string>", "provider:model to review with. Defaults to the workspace's default model.").option("--folder <dir:string>", "The repository directory the workspace is synced into, when it is not the root.").option("--json", "Print the review as JSON").option("--post <target:string>", "Post the review on the pull request. Only `github` is supported.", {
|
|
94490
|
+
value: (v) => {
|
|
94491
|
+
if (v !== "github")
|
|
94492
|
+
throw new Error(`--post supports github only, got ${v}`);
|
|
94493
|
+
return v;
|
|
94494
|
+
}
|
|
94495
|
+
}).option("--pr <number:number>", "The pull request number. Defaults to the pull_request event's.").option("--fail-on <severity:string>", "Exit with 1 when a finding is at least this severe: high, medium or low.", {
|
|
94496
|
+
value: (v) => {
|
|
94497
|
+
if (!["high", "medium", "low"].includes(v))
|
|
94498
|
+
throw new Error(`--fail-on takes high, medium or low, got ${v}`);
|
|
94499
|
+
return v;
|
|
94500
|
+
}
|
|
94501
|
+
}).action(review);
|
|
94502
|
+
var review_default = command28;
|
|
94503
|
+
|
|
93720
94504
|
// src/commands/dev/dev.ts
|
|
93721
94505
|
init_mod3();
|
|
93722
94506
|
init_log();
|
|
@@ -93741,7 +94525,7 @@ await __promiseAll([
|
|
|
93741
94525
|
init_codebase(),
|
|
93742
94526
|
init_local_path_scripts()
|
|
93743
94527
|
]);
|
|
93744
|
-
var
|
|
94528
|
+
var import_yaml49 = __toESM(require_dist(), 1);
|
|
93745
94529
|
import { sep as SEP22 } from "node:path";
|
|
93746
94530
|
import * as http3 from "node:http";
|
|
93747
94531
|
import * as https from "node:https";
|
|
@@ -94218,7 +95002,7 @@ async function dev2(opts) {
|
|
|
94218
95002
|
info(`Wrote inline script: ${filePath}`);
|
|
94219
95003
|
}
|
|
94220
95004
|
}
|
|
94221
|
-
const flowYaml =
|
|
95005
|
+
const flowYaml = import_yaml49.stringify(data.flow);
|
|
94222
95006
|
let currentYaml;
|
|
94223
95007
|
try {
|
|
94224
95008
|
currentYaml = await readTextFile(flowYamlPath);
|
|
@@ -94471,8 +95255,8 @@ async function dev2(opts) {
|
|
|
94471
95255
|
await Promise.all([startServer(), watchChanges()]);
|
|
94472
95256
|
console.log("Stopped dev mode");
|
|
94473
95257
|
}
|
|
94474
|
-
var
|
|
94475
|
-
var dev_default2 =
|
|
95258
|
+
var command29 = new Command().description("Watch local file changes and live-reload the dev page for preview. Does NOT deploy to the remote workspace — use wmill sync push for that.").option("--includes <pattern...:string>", "Filter paths given a glob pattern or path").option("--proxy-port <port:number>", "Port for a localhost reverse proxy to the remote Windmill server").option("--path <path:string>", "Watch a specific windmill path (e.g., u/admin/my_script or f/my_flow)").option("--no-open", "Do not open the browser automatically").action(dev2);
|
|
95259
|
+
var dev_default2 = command29;
|
|
94476
95260
|
|
|
94477
95261
|
// src/main.ts
|
|
94478
95262
|
init_gen();
|
|
@@ -94630,8 +95414,8 @@ Worker Group: ${group.groupName} (${group.workers.length} workers)`);
|
|
|
94630
95414
|
info("Use 'wmill instance add' to add a new instance");
|
|
94631
95415
|
}
|
|
94632
95416
|
}
|
|
94633
|
-
var
|
|
94634
|
-
var workers_default =
|
|
95417
|
+
var command30 = new Command().description("List all workers grouped by worker groups").option("--instance [instance]", "Name of the instance to push to, override the active instance").option("--base-url [baseUrl]", "If used with --token, will be used as the base url for the instance").action(displayWorkers);
|
|
95418
|
+
var workers_default = command30;
|
|
94635
95419
|
|
|
94636
95420
|
// src/commands/queues/queues.ts
|
|
94637
95421
|
init_mod3();
|
|
@@ -94739,8 +95523,8 @@ async function displayQueues(opts, workspace) {
|
|
|
94739
95523
|
info("Use 'wmill instance add' to add a new instance");
|
|
94740
95524
|
}
|
|
94741
95525
|
}
|
|
94742
|
-
var
|
|
94743
|
-
var queues_default =
|
|
95526
|
+
var command31 = new Command().description("List all queues with their metrics").arguments("[workspace:string] the optional workspace to filter by (default to all workspaces)").option("--instance [instance]", "Name of the instance to push to, override the active instance").option("--base-url [baseUrl]", "If used with --token, will be used as the base url for the instance").action(displayQueues);
|
|
95527
|
+
var queues_default = command31;
|
|
94744
95528
|
|
|
94745
95529
|
// src/main.ts
|
|
94746
95530
|
await init_dependencies();
|
|
@@ -95604,8 +96388,8 @@ async function promptMigration() {
|
|
|
95604
96388
|
async function promptsAction(opts) {
|
|
95605
96389
|
await refreshPrompts({ yes: opts.yes === true });
|
|
95606
96390
|
}
|
|
95607
|
-
var
|
|
95608
|
-
var prompts_default =
|
|
96391
|
+
var command32 = new Command().description("Refresh AGENTS.wmill.md and managed skills. User-owned AGENTS.md and CLAUDE.md are never overwritten unless you opt in.").option("--yes", "Non-interactive: append the @AGENTS.wmill.md include to an existing AGENTS.md / CLAUDE.md without prompting. Without it, a non-interactive run leaves an unlinked file untouched.").action(promptsAction);
|
|
96392
|
+
var prompts_default = command32;
|
|
95609
96393
|
|
|
95610
96394
|
// src/commands/init/init.ts
|
|
95611
96395
|
await init_tsconfig();
|
|
@@ -95799,14 +96583,14 @@ async function initAction(opts) {
|
|
|
95799
96583
|
}
|
|
95800
96584
|
}
|
|
95801
96585
|
}
|
|
95802
|
-
var
|
|
95803
|
-
var init_default =
|
|
96586
|
+
var command34 = new Command().description("Bootstrap a windmill project with a wmill.yaml file").option("--use-default", "Use default settings without checking backend").option("--use-backend", "Use backend git-sync settings if available").option("--repository <repo:string>", "Specify repository path (e.g., u/user/repo) when using backend settings").option("--bind-profile", "Automatically bind active workspace profile to current Git branch").option("--no-bind-profile", "Skip workspace profile binding prompt").action(initAction);
|
|
96587
|
+
var init_default = command34;
|
|
95804
96588
|
|
|
95805
96589
|
// src/commands/refresh/refresh.ts
|
|
95806
96590
|
init_mod3();
|
|
95807
96591
|
await init_tsconfig();
|
|
95808
|
-
var
|
|
95809
|
-
var refresh_default =
|
|
96592
|
+
var command35 = new Command().description("Refresh wmill-managed project files (AGENTS.wmill.md, skills, tsconfig.wmill.json)").command("prompts", prompts_default).command("tsconfig", tsconfig_default);
|
|
96593
|
+
var refresh_default = command35;
|
|
95810
96594
|
|
|
95811
96595
|
// src/main.ts
|
|
95812
96596
|
init_freshness_gate();
|
|
@@ -95975,8 +96759,8 @@ Warning: Found ${workers.length} active worker(s) on the instance.`));
|
|
|
95975
96759
|
}
|
|
95976
96760
|
var pull3 = new Command().description("Pull completed and queued jobs from workspace").option("-c, --completed-output <file:string>", "Completed jobs output file (default: completed_jobs.json)").option("-q, --queued-output <file:string>", "Queued jobs output file (default: queued_jobs.json)").option("--skip-worker-check", "Skip checking for active workers before export").arguments("[workspace:string]").action(pullJobs);
|
|
95977
96761
|
var push12 = new Command().description("Push completed and queued jobs to workspace").option("-c, --completed-file <file:string>", "Completed jobs input file (default: completed_jobs.json)").option("-q, --queued-file <file:string>", "Queued jobs input file (default: queued_jobs.json)").option("--skip-worker-check", "Skip checking for active workers before import").arguments("[workspace:string]").action(pushJobs);
|
|
95978
|
-
var
|
|
95979
|
-
var jobs_default =
|
|
96762
|
+
var command36 = new Command().description("Manage jobs (import/export)").command("pull", pull3).command("push", push12);
|
|
96763
|
+
var jobs_default = command36;
|
|
95980
96764
|
|
|
95981
96765
|
// src/commands/job/job.ts
|
|
95982
96766
|
init_mod3();
|
|
@@ -96337,8 +97121,8 @@ async function restart(opts, id) {
|
|
|
96337
97121
|
console.log(newId);
|
|
96338
97122
|
}
|
|
96339
97123
|
var listOptions = (cmd) => cmd.option("--json", "Output as JSON (for piping to jq)").option("--script-path <scriptPath:string>", "Filter by exact script/flow path").option("--created-by <createdBy:string>", "Filter by creator username").option("--running", "Show only running jobs").option("--failed", "Show only failed jobs").option("--success <success:boolean>", "Filter by success status (true/false)").option("--limit <limit:number>", "Number of jobs to return (default 30, max 100)").option("--job-kinds <jobKinds:string>", "Filter by job kinds (default: script,flow,singlestepflow)").option("--label <label:string>", "Filter by job label").option("--all", "Include sub-jobs (flow steps). By default only top-level jobs are shown").option("--parent <parent:string>", "Filter by parent job ID (show sub-jobs of a specific flow)").option("--is-flow-step", "Show only flow step jobs");
|
|
96340
|
-
var
|
|
96341
|
-
var job_default =
|
|
97124
|
+
var command37 = listOptions(new Command().description("Manage jobs (list, inspect, cancel)")).action(list13).command("list", listOptions(new Command().description("List recent jobs"))).action(list13).command("get", "Get job details. For flows: shows step tree with sub-job IDs").arguments("<id:string>").option("--json", "Output as JSON (for piping to jq)").action(get10).command("result", "Get the result of a completed job (machine-friendly)").arguments("<id:string>").action(result).command("logs", "Get job logs. For flows: aggregates all step logs").arguments("<id:string>").action(logs).command("cancel", "Cancel a running or queued job").arguments("<id:string>").option("--reason <reason:string>", "Reason for cancellation").action(cancel).command("rerun", "Re-run a completed job with the same args. Prints the new job UUID on stdout.").arguments("<id:string>").action(rerun).command("restart", "Restart a completed flow at a given top-level step. Prints the new flow job UUID on stdout.").arguments("<id:string>").option("--step <stepId:string>", "Top-level step id to restart the flow from", { required: true }).option("--iteration <n:number>", "For a top-level branchall or for-loop step, the iteration to restart at").action(restart);
|
|
97125
|
+
var job_default = command37;
|
|
96342
97126
|
|
|
96343
97127
|
// src/commands/group/group.ts
|
|
96344
97128
|
init_mod3();
|
|
@@ -96437,8 +97221,8 @@ async function removeUser(opts, name, username) {
|
|
|
96437
97221
|
});
|
|
96438
97222
|
info(colors.green(`User '${username}' removed from group '${name}'.`));
|
|
96439
97223
|
}
|
|
96440
|
-
var
|
|
96441
|
-
var group_default =
|
|
97224
|
+
var command38 = new Command().description("Manage workspace groups").option("--json", "Output as JSON (for piping to jq)").action(list14).command("list", "List all groups in the workspace").option("--json", "Output as JSON (for piping to jq)").action(list14).command("get", "Get group details and members").arguments("<name:string>").option("--json", "Output as JSON (for piping to jq)").action(get11).command("create", "Create a new group").arguments("<name:string>").option("--summary <summary:string>", "Group summary/description").action(create).command("delete", "Delete a group").arguments("<name:string>").action(deleteGroup2).command("add-user", "Add a user to a group").arguments("<name:string> <username:string>").action(addUser2).command("remove-user", "Remove a user from a group").arguments("<name:string> <username:string>").action(removeUser);
|
|
97225
|
+
var group_default = command38;
|
|
96442
97226
|
|
|
96443
97227
|
// src/commands/audit/audit.ts
|
|
96444
97228
|
init_mod3();
|
|
@@ -96515,8 +97299,8 @@ async function get12(opts, id) {
|
|
|
96515
97299
|
}
|
|
96516
97300
|
}
|
|
96517
97301
|
var auditListOptions = (cmd) => cmd.option("--json", "Output as JSON (for piping to jq)").option("--username <username:string>", "Filter by username").option("--operation <operation:string>", "Filter by operation (exact or prefix)").option("--action-kind <actionKind:string>", "Filter by action kind (Create, Update, Delete, Execute)").option("--before <before:string>", "Filter events before this timestamp").option("--after <after:string>", "Filter events after this timestamp").option("--limit <limit:number>", "Number of entries to return (default 30, max 100)");
|
|
96518
|
-
var
|
|
96519
|
-
var audit_default =
|
|
97302
|
+
var command39 = auditListOptions(new Command().description("View audit logs (requires admin)")).action(list15).command("list", auditListOptions(new Command().description("List audit log entries"))).action(list15).command("get", "Get a specific audit log entry").arguments("<id:string>").option("--json", "Output as JSON (for piping to jq)").action(get12);
|
|
97303
|
+
var audit_default = command39;
|
|
96520
97304
|
|
|
96521
97305
|
// src/commands/token/token.ts
|
|
96522
97306
|
init_mod3();
|
|
@@ -96570,8 +97354,8 @@ async function deleteToken2(opts, tokenPrefix) {
|
|
|
96570
97354
|
await deleteToken({ tokenPrefix });
|
|
96571
97355
|
info(colors.green(`Token with prefix '${tokenPrefix}' deleted.`));
|
|
96572
97356
|
}
|
|
96573
|
-
var
|
|
96574
|
-
var token_default =
|
|
97357
|
+
var command40 = new Command().description("Manage API tokens").option("--json", "Output as JSON (for piping to jq)").action(list16).command("list", "List API tokens").option("--json", "Output as JSON (for piping to jq)").action(list16).command("create", "Create a new API token").option("--label <label:string>", "Token label").option("--expiration <expiration:string>", "Token expiration (ISO 8601 timestamp)").action(create2).command("delete", "Delete a token by its prefix").arguments("<token_prefix:string>").action(deleteToken2);
|
|
97358
|
+
var token_default = command40;
|
|
96575
97359
|
|
|
96576
97360
|
// src/commands/trash/trash.ts
|
|
96577
97361
|
init_mod3();
|
|
@@ -96662,8 +97446,8 @@ async function restore(opts, ...ids) {
|
|
|
96662
97446
|
process.exitCode = 1;
|
|
96663
97447
|
}
|
|
96664
97448
|
}
|
|
96665
|
-
var
|
|
96666
|
-
var trash_default =
|
|
97449
|
+
var command41 = new Command().description("List, inspect and restore items deleted in the last three days (requires admin)").option("--json", "Output as JSON (for piping to jq)").option("--kind <kind:string>", "Only items of this kind: script, flow, app, schedule, variable, resource or a trigger kind such as http_trigger").option("--limit <limit:integer>", "Number of items to return (default 100, max 1000)").option("--page <page:integer>", "Page to return, starting at 1").action(list17).command("list", "List trashed items, most recently deleted first").option("--json", "Output as JSON (for piping to jq)").option("--kind <kind:string>", "Only items of this kind: script, flow, app, schedule, variable, resource or a trigger kind such as http_trigger").option("--limit <limit:integer>", "Number of items to return (default 100, max 1000)").option("--page <page:integer>", "Page to return, starting at 1").action(list17).command("get", "Show a trashed item and the data it was deleted with").arguments("<id:integer>").option("--json", "Output as JSON (for piping to jq)").action(get13).command("restore", "Put trashed items back at their paths").arguments("<ids...:integer>").action(restore);
|
|
97450
|
+
var trash_default = command41;
|
|
96667
97451
|
|
|
96668
97452
|
// src/main.ts
|
|
96669
97453
|
await init_generate_metadata();
|
|
@@ -96724,14 +97508,14 @@ ${await res.text()}`);
|
|
|
96724
97508
|
console.log();
|
|
96725
97509
|
}
|
|
96726
97510
|
}
|
|
96727
|
-
var
|
|
96728
|
-
var docs_default =
|
|
97511
|
+
var command42 = new Command().name("docs").description("Search Windmill documentation.").arguments("<query:string>").option("--json", "Output results as JSON.").action(docs);
|
|
97512
|
+
var docs_default = command42;
|
|
96729
97513
|
|
|
96730
97514
|
// src/commands/config/config.ts
|
|
96731
97515
|
init_mod3();
|
|
96732
97516
|
init_log();
|
|
96733
97517
|
init_colors2();
|
|
96734
|
-
var
|
|
97518
|
+
var import_yaml50 = __toESM(require_dist(), 1);
|
|
96735
97519
|
import { writeFile as writeFile25 } from "node:fs/promises";
|
|
96736
97520
|
await __promiseAll([
|
|
96737
97521
|
init_conf(),
|
|
@@ -96786,7 +97570,7 @@ async function migrateAction() {
|
|
|
96786
97570
|
} else {
|
|
96787
97571
|
newConf.workspaces = workspaces;
|
|
96788
97572
|
}
|
|
96789
|
-
await writeFile25(wmillYamlPath,
|
|
97573
|
+
await writeFile25(wmillYamlPath, import_yaml50.stringify(newConf), "utf-8");
|
|
96790
97574
|
info(colors.green(`✅ Migrated '${legacyKey}' to 'workspaces' in ${wmillYamlPath}`));
|
|
96791
97575
|
if (wsNames.length > 0) {
|
|
96792
97576
|
info(` Workspace entries: ${wsNames.join(", ")}`);
|
|
@@ -96795,8 +97579,8 @@ async function migrateAction() {
|
|
|
96795
97579
|
info(` Also removed additional legacy keys: ${legacyKeys.slice(1).join(", ")}`);
|
|
96796
97580
|
}
|
|
96797
97581
|
}
|
|
96798
|
-
var
|
|
96799
|
-
var config_default =
|
|
97582
|
+
var command43 = new Command().name("config").description("Show all available wmill.yaml configuration options").option("--json", "Output as JSON for programmatic consumption").action(configAction).command("migrate").description("Migrate wmill.yaml from gitBranches/environments to workspaces format").action(migrateAction);
|
|
97583
|
+
var config_default = command43;
|
|
96800
97584
|
|
|
96801
97585
|
// src/commands/datatable/datatable.ts
|
|
96802
97586
|
init_mod3();
|
|
@@ -98806,8 +99590,8 @@ async function serve2(opts) {
|
|
|
98806
99590
|
async function psql2(opts) {
|
|
98807
99591
|
await psql(opts);
|
|
98808
99592
|
}
|
|
98809
|
-
var
|
|
98810
|
-
var datatable_default =
|
|
99593
|
+
var command44 = new Command().description("datatable related commands").command("list", "list all datatables in the workspace").option("--json", "Output as JSON (for piping to jq)").action(list18).command("run", "run a SQL query on a datatable").arguments("<sql:string>").option("-n --name <name:string>", "Datatable name (default: main)").option("-s --silent", "Output only the final result as JSON. Useful for scripting.").action(run4).command("migrate", migrateCommand).command("create", "register a datatable database in the workspace (default: instance-backed 'main') so scripts can use datatable://<name>").arguments("[name:string]").option("--resource <resource:string>", "Back the datatable with an existing postgresql resource path instead of the instance database").option("--force", "Allow adding to a workspace that already has datatables (fork metadata on existing ones is not preserved)").action(create3).command("serve", "Serve all datatables as a Postgres-wire endpoint (psql, DBeaver, pgAdmin); the client picks the datatable via the database name in its connection string").option("--port <port:number>", "Port to listen on (default: first free port in 5433-5500)").option("--host <host:string>", "Bind address (default: 127.0.0.1)").option("--password <password:string>", "Password for Postgres clients (default: generate a random password at startup)").action(serve2).command("psql", "Start a serve listener and launch psql connected to it").option("-n --name <name:string>", "Datatable to connect psql to (default: main)").option("--port <port:number>", "Port the proxy listens on (default: first free port in 5433-5500)").option("--host <host:string>", "Bind address for the proxy (default: 127.0.0.1)").option("--password <password:string>", "Password for the temporary Postgres proxy (default: generate a random password at startup)").action(psql2);
|
|
99594
|
+
var datatable_default = command44;
|
|
98811
99595
|
|
|
98812
99596
|
// src/commands/pipeline/pipeline.ts
|
|
98813
99597
|
init_mod3();
|
|
@@ -100097,8 +100881,8 @@ async function dev3(opts, folderArg) {
|
|
|
100097
100881
|
process27.exit(0);
|
|
100098
100882
|
});
|
|
100099
100883
|
}
|
|
100100
|
-
var
|
|
100101
|
-
var dev_default3 =
|
|
100884
|
+
var command45 = new Command().description("Live-preview a data pipeline from local files: watch an `f/<folder>` of `// pipeline` scripts, push the working-tree graph to the dev page, and run the cascade via preview (no deploy).").arguments("[folder:string]").option("--port <port:number>", "Port for the dev WebSocket server.").option("--no-open", "Do not open the browser automatically.").option("--frontend <origin:string>", "Origin serving the /pipeline_dev page (e.g. http://localhost:3000 for a locally-run frontend). Defaults to the workspace remote; use it when the remote's deployed frontend predates the dev page.").action(dev3);
|
|
100885
|
+
var dev_default3 = command45;
|
|
100102
100886
|
|
|
100103
100887
|
// src/commands/pipeline/docs.ts
|
|
100104
100888
|
init_gen();
|
|
@@ -100111,7 +100895,7 @@ await __promiseAll([
|
|
|
100111
100895
|
init_conf()
|
|
100112
100896
|
]);
|
|
100113
100897
|
import { writeFile as writeFile26 } from "node:fs/promises";
|
|
100114
|
-
import { existsSync as existsSync22, readFileSync as
|
|
100898
|
+
import { existsSync as existsSync22, readFileSync as readFileSync9 } from "node:fs";
|
|
100115
100899
|
import * as path29 from "node:path";
|
|
100116
100900
|
var ASSET_KINDS = "s3object,ducklake,datatable,volume,dbt";
|
|
100117
100901
|
function assetUri(kind, p) {
|
|
@@ -100334,7 +101118,7 @@ async function generatePipelineDocs(opts, folder) {
|
|
|
100334
101118
|
if (existsSync22(p)) {
|
|
100335
101119
|
let existing;
|
|
100336
101120
|
try {
|
|
100337
|
-
existing =
|
|
101121
|
+
existing = readFileSync9(p, "utf-8");
|
|
100338
101122
|
} catch {
|
|
100339
101123
|
continue;
|
|
100340
101124
|
}
|
|
@@ -100989,8 +101773,8 @@ Full logs: ${runUrl}`);
|
|
|
100989
101773
|
info(colors.green.bold(`Bounded run complete — ${order.length} script(s) succeeded.`));
|
|
100990
101774
|
}
|
|
100991
101775
|
}
|
|
100992
|
-
var
|
|
100993
|
-
var pipeline_default =
|
|
101776
|
+
var command46 = new Command().description("inspect asset-driven pipelines (scripts marked `// pipeline`, wired by `// on <spec>` annotations)").command("list", "list pipeline folders in the workspace").option("--json", "Output as JSON (for piping to jq)").action(list19).command("show", "render a pipeline folder's DAG (sources, lineage, subscriptions) in the terminal").arguments("<folder:string>").option("--json", "Output the raw asset graph as JSON").option("--local", "Build the graph from local working-tree files (// pipeline scripts) instead of the deployed workspace — no deploy needed.").action(show2).command("run", "run a cascade: from --from (a root OR any mid-DAG model), fan downstream up to the --to end node(s)").arguments("<folder:string>").option("--from <script:string>", "Start script (short name or path). May be any node, including a mid-DAG model — that node plus its transitive downstream runs, upstream is NOT re-run (dbt `--select model+`). Defaults to the folder's sole schedule/manual root.").option("--to <node:string>", "End node(s) to stop at — script names/paths or asset URIs (e.g. datatable://main/staged). Repeatable or comma-separated. Omit to run the full downstream.", { collect: true }).option("--dry-run", "Print the topological run plan without executing.").option("--json", "Output the plan as JSON (for piping to jq).").option("--local", "Run the local working-tree scripts via preview (no deploy) instead of the deployed versions; the graph is built from local files.").option("--upload <binding:string>", "Bind an object to a data_upload/webhook entry point so it runs in the cascade, as SCRIPT[:PARAM]=SOURCE (SOURCE is a local file or an s3://key). Local files are uploaded to the workspace store; the S3Object param is inferred when the script has exactly one. Repeatable.", { collect: true }).option("--arg <binding:string>", "Pass a plain run arg to a script in the cascade, as SCRIPT:PARAM=VALUE (VALUE is parsed as JSON when possible, else taken as a string — e.g. daily_report:partition=2026-07-02). Repeatable.", { collect: true }).option("--partition <value:string>", "Partition value for `// partitioned` scripts in the run (e.g. 2026-06-30) — use it to backfill a past slice. With --local, time kinds (daily/hourly/weekly/monthly) default to the current UTC period when omitted; `dynamic` always needs it. Deployed runs without it defer to backend run-start resolution.").action(run5).command("docs", "generate PIPELINE.md (+ AGENTS.md pointer) describing a folder's pipeline graph and datatable schemas, for an editor / agentic loop").arguments("<folder:string>").option("--local", "Build the graph from local working-tree files instead of the deployed workspace.").action(generatePipelineDocs).command("dev", dev_default3);
|
|
101777
|
+
var pipeline_default = command46;
|
|
100994
101778
|
|
|
100995
101779
|
// src/commands/ducklake/ducklake.ts
|
|
100996
101780
|
init_mod3();
|
|
@@ -101020,8 +101804,8 @@ async function run6(opts, sql) {
|
|
|
101020
101804
|
const name = opts.name ?? DEFAULT_DUCKLAKE_NAME;
|
|
101021
101805
|
await runCatalogQuery(opts, "ducklake", name, sql);
|
|
101022
101806
|
}
|
|
101023
|
-
var
|
|
101024
|
-
var ducklake_default =
|
|
101807
|
+
var command47 = new Command().description("ducklake related commands").command("list", "list all ducklakes in the workspace").option("--json", "Output as JSON (for piping to jq)").action(list20).command("run", "run a SQL query on a ducklake").arguments("<sql:string>").option("-n --name <name:string>", "Ducklake name (default: main)").option("-s --silent", "Output only the final result as JSON. Useful for scripting.").action(run6);
|
|
101808
|
+
var ducklake_default = command47;
|
|
101025
101809
|
|
|
101026
101810
|
// src/commands/object-storage/object-storage.ts
|
|
101027
101811
|
init_mod3();
|
|
@@ -101222,8 +102006,8 @@ async function preview3(opts, fileKey) {
|
|
|
101222
102006
|
`);
|
|
101223
102007
|
}
|
|
101224
102008
|
}
|
|
101225
|
-
var
|
|
101226
|
-
var object_storage_default =
|
|
102009
|
+
var command48 = new Command().alias("s3").description("Object storage (S3) related commands. Operates on the workspace's default object storage; use --storage to target a configured secondary storage.").action(listStorages).command("list", "List configured object storages for the workspace (default + secondary).").option("--json", "Output as JSON (for piping to jq)").action(listStorages).command("files", "List files in an object storage. Optionally filter by prefix.").alias("ls").arguments("[prefix:string]").option("--json", "Output as JSON (for piping to jq)").option("--max-keys <maxKeys:number>", "Page size (default 100)").option("--marker <marker:string>", "Pagination marker from a previous response").option("--storage <storage:string>", "Secondary storage name (omit for the workspace default)").action(listFiles).command("upload", "Upload a local file to object storage at the given file key.").arguments("<local_path:string> <file_key:string>").option("--storage <storage:string>", "Secondary storage name").option("--content-type <contentType:string>", "Content-Type header to set on the object").option("--content-disposition <contentDisposition:string>", "Content-Disposition header to set on the object").action(upload).command("download", "Download an object to a local file (or stdout). Default output path is the basename of the file key in the current directory.").arguments("<file_key:string> [output_path:string]").option("--storage <storage:string>", "Secondary storage name").option("--stdout", "Write file contents to stdout instead of a file").action(download).command("delete", "Delete an object from object storage. Prompts for confirmation unless --yes is set.").arguments("<file_key:string>").option("--storage <storage:string>", "Secondary storage name").option("--yes", "Skip the confirmation prompt").action(del).command("move", "Move an object within the same storage (rename or relocate by key).").arguments("<src_file_key:string> <dest_file_key:string>").option("--storage <storage:string>", "Secondary storage name").action(move).command("info", "Show metadata (size, mime, last-modified) for an object.").arguments("<file_key:string>").option("--json", "Output as JSON (for piping to jq)").option("--storage <storage:string>", "Secondary storage name").action(info2).command("preview", "Preview the contents of an object (text/CSV). Use --bytes-from / --bytes-length to peek at a slice of binary files.").arguments("<file_key:string>").option("--storage <storage:string>", "Secondary storage name").option("--mime <mime:string>", "Override the detected mime type (e.g. text/csv)").option("--bytes-from <bytesFrom:number>", "Start offset in bytes").option("--bytes-length <bytesLength:number>", "Number of bytes to read").option("--csv-separator <csvSeparator:string>", "CSV column separator (default ,)").option("--csv-header", "Treat the first CSV row as a header").action(preview3);
|
|
102010
|
+
var object_storage_default = command48;
|
|
101227
102011
|
|
|
101228
102012
|
// src/main.ts
|
|
101229
102013
|
await init_context();
|
|
@@ -101243,7 +102027,7 @@ async function checkVersionSafe(cmd) {
|
|
|
101243
102027
|
}
|
|
101244
102028
|
mainCommand.version(`${currentVersion} (New version available: ${latestVersion}. Run '${mainCommand.getName()} upgrade' to upgrade to the latest version!)`);
|
|
101245
102029
|
}
|
|
101246
|
-
var
|
|
102030
|
+
var command49 = new Command().name("wmill").action(() => info(`Welcome to Windmill CLI ${VERSION}. Use -h for help.`)).description("Windmill CLI").globalOption("--workspace <workspace:string>", "Specify the target workspace. This overrides the default workspace.").globalOption("--debug --verbose", "Show debug/verbose logs").globalOption("--show-diffs", "Show diff informations when syncing (may show sensitive informations)").globalOption("--token <token:string>", "Specify an API token. This will override any stored token.").globalOption("--base-url <baseUrl:string>", "Specify the base URL of the API. If used, --token and --workspace are required and no local remote/workspace already set will be used.").globalOption("--config-dir <configDir:string>", "Specify a custom config directory. Overrides WMILL_CONFIG_DIR environment variable and default ~/.config location.").env("HEADERS <headers:string>", `Specify headers to use for all requests. e.g: "HEADERS='h1: v1, h2: v2'"`).version(VERSION).versionOption(false).helpOption("-h, --help", "Show this help.", {
|
|
101247
102031
|
action: async function() {
|
|
101248
102032
|
const self2 = this;
|
|
101249
102033
|
const long = self2.getRawArgs().includes(`--${self2.getHelpOption()?.name}`);
|
|
@@ -101255,7 +102039,7 @@ var command48 = new Command().name("wmill").action(() => info(`Welcome to Windmi
|
|
|
101255
102039
|
self2.showHelp({ long });
|
|
101256
102040
|
self2.exit();
|
|
101257
102041
|
}
|
|
101258
|
-
}).command("init", init_default).command("refresh", refresh_default).command("app", app_default).command("flow", flow_default).command("script", script_default).command("workspace", workspace_default).command("resource", resource_default).command("resource-type", resource_type_default).command("user", user_default).command("variable", variable_default).command("hub", hub_default).command("folder", folder_default).command("schedule", schedule_default2).command("trigger", trigger_default).command("dev", dev_default2).command("sync", sync_default).command("lint", lint_default).command("digest", digest_default).command("gitsync-settings", gitsync_settings_default).command("protection-rules", protection_rules_default).command("instance", instance_default).command("worker-groups", worker_groups_default).command("workers", workers_default).command("queues", queues_default).command("dependencies", dependencies_default).command("jobs", jobs_default).command("job", job_default).command("group", group_default).command("audit", audit_default).command("token", token_default).command("trash", trash_default).command("generate-metadata", generate_metadata_default).command("docs", docs_default).command("config", config_default).command("datatable", datatable_default).command("pipeline", pipeline_default).command("ducklake", ducklake_default).command("object-storage", object_storage_default).command("version --version", "Show version information").action(async (opts) => {
|
|
102042
|
+
}).command("init", init_default).command("refresh", refresh_default).command("app", app_default).command("flow", flow_default).command("script", script_default).command("workspace", workspace_default).command("resource", resource_default).command("resource-type", resource_type_default).command("user", user_default).command("variable", variable_default).command("hub", hub_default).command("folder", folder_default).command("schedule", schedule_default2).command("trigger", trigger_default).command("dev", dev_default2).command("sync", sync_default).command("lint", lint_default).command("digest", digest_default).command("review", review_default).command("gitsync-settings", gitsync_settings_default).command("protection-rules", protection_rules_default).command("instance", instance_default).command("worker-groups", worker_groups_default).command("workers", workers_default).command("queues", queues_default).command("dependencies", dependencies_default).command("jobs", jobs_default).command("job", job_default).command("group", group_default).command("audit", audit_default).command("token", token_default).command("trash", trash_default).command("generate-metadata", generate_metadata_default).command("docs", docs_default).command("config", config_default).command("datatable", datatable_default).command("pipeline", pipeline_default).command("ducklake", ducklake_default).command("object-storage", object_storage_default).command("version --version", "Show version information").action(async (opts) => {
|
|
101259
102043
|
console.log("CLI version: " + VERSION);
|
|
101260
102044
|
try {
|
|
101261
102045
|
const provider = new NpmProvider({ package: "windmill-cli" });
|
|
@@ -101285,20 +102069,20 @@ var command48 = new Command().name("wmill").action(() => info(`Welcome to Windmi
|
|
|
101285
102069
|
error(e);
|
|
101286
102070
|
info("Try running with sudo and otherwise check the result of the command: npm uninstall windmill-cli && npm install -g windmill-cli");
|
|
101287
102071
|
})).command("completions", new Command().description("Generate shell completions.").command("bash", new Command().description("Generate bash completions.").action(() => {
|
|
101288
|
-
process.stdout.write(generateShellCompletions(
|
|
102072
|
+
process.stdout.write(generateShellCompletions(command49, "bash") + `
|
|
101289
102073
|
`);
|
|
101290
102074
|
})).command("zsh", new Command().description("Generate zsh completions.").action(() => {
|
|
101291
|
-
process.stdout.write(generateShellCompletions(
|
|
102075
|
+
process.stdout.write(generateShellCompletions(command49, "zsh") + `
|
|
101292
102076
|
`);
|
|
101293
102077
|
})).command("fish", new Command().description("Generate fish completions.").action(() => {
|
|
101294
|
-
process.stdout.write(generateShellCompletions(
|
|
102078
|
+
process.stdout.write(generateShellCompletions(command49, "fish") + `
|
|
101295
102079
|
`);
|
|
101296
102080
|
})));
|
|
101297
102081
|
async function main2() {
|
|
101298
102082
|
try {
|
|
101299
102083
|
const args = process.argv.slice(2);
|
|
101300
102084
|
if (args.length === 0) {
|
|
101301
|
-
|
|
102085
|
+
command49.showHelp();
|
|
101302
102086
|
}
|
|
101303
102087
|
const LOG_LEVEL = args.includes("--verbose") || args.includes("--debug") ? "DEBUG" : "INFO";
|
|
101304
102088
|
setShowDiffs(args.includes("--show-diffs"));
|
|
@@ -101319,7 +102103,7 @@ async function main2() {
|
|
|
101319
102103
|
await init_tsconfig();
|
|
101320
102104
|
await warnIfTsconfigStale().catch(() => {});
|
|
101321
102105
|
}
|
|
101322
|
-
await
|
|
102106
|
+
await command49.parse(args);
|
|
101323
102107
|
} catch (e) {
|
|
101324
102108
|
const apiError = apiErrorMessage(e);
|
|
101325
102109
|
if (apiError !== undefined) {
|
|
@@ -101353,7 +102137,7 @@ if (isMain()) {
|
|
|
101353
102137
|
process.stdin.destroy();
|
|
101354
102138
|
});
|
|
101355
102139
|
}
|
|
101356
|
-
var main_default =
|
|
102140
|
+
var main_default = command49;
|
|
101357
102141
|
export {
|
|
101358
102142
|
VERSION,
|
|
101359
102143
|
WM_FORK_PREFIX,
|