mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-17 08:20:12 +00:00
fix: mcp one-workspace runnables, run card links, directory review (#12072)
* fix: mcp runnables-as-tools keep one workspace; run card heads its result with logs and inputs links Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: mcp run card hides its result heading when the view clears Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: mcp token wizard clears its script selection when the workspace changes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: mcp consent page access setter accepts the unset access Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: mcp draft write tools carry the destructive hint Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: mcp clients get short instructions naming only the server's tools Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: mcp instructions open on the drafts rule, stated without a persona Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: mcp tool descriptions say only what the agent acts on Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: mcp instructions prefer cards and restore the trigger, db schema and agent rules Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: mcp tool descriptions name the next step, get_instructions or a card Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: mcp tools say they are only for the user's windmill workspace Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: mcp instructions open on what the tools are for, for every connection Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * revert: drop the mcp scope sentence and list tool scope notes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ad56e32a11
commit
32da930d25
@@ -1085,6 +1085,14 @@ pub async fn gateway_oauth_approve(
|
||||
if workspace_ids.is_empty() {
|
||||
workspace_ids.extend(form.workspace_id);
|
||||
}
|
||||
// A selection of scripts and flows names paths, which only mean something in one workspace.
|
||||
if !scope.split_whitespace().any(|s| s == "mcp:all")
|
||||
&& (form.all_workspaces || workspace_ids.len() > 1)
|
||||
{
|
||||
return Err(Error::BadRequest(
|
||||
"Selected scripts and flows come from one workspace: pick one".to_string(),
|
||||
));
|
||||
}
|
||||
let workspace_id = if form.all_workspaces {
|
||||
None
|
||||
} else {
|
||||
|
||||
@@ -155,6 +155,9 @@
|
||||
/* An empty slot takes no gap in the card's rhythm. */
|
||||
#result-more:empty, #result-table:empty, #body:empty, #result-slot:not(:has(:not([hidden]))), .actions:not(:has(> :not([hidden]))) { display: none; }
|
||||
.section-title { font-size: var(--t-sm); font-weight: var(--w-semibold); color: var(--fg-em); }
|
||||
/* A finished run's result is headed, with links to its fullscreen Logs and Inputs tabs. */
|
||||
.result-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: -4px; }
|
||||
.result-head .section-title { flex: 1; }
|
||||
/* Windmill sets titles in its sans, semibold; a path never goes bold. */
|
||||
.path { font: var(--w-semibold) var(--t-md)/1.3 var(--sans); color: var(--fg-em); overflow-wrap: anywhere; text-align: left; }
|
||||
button.path { border: 0; padding: 0; min-height: 0; background: none; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
|
||||
@@ -324,6 +327,7 @@
|
||||
</div>
|
||||
<div class="progress-block" id="step" hidden></div>
|
||||
<div class="step" id="stale" hidden>No longer refreshing here. Open it in Windmill for its live status.</div>
|
||||
<div class="result-head" id="result-head" hidden></div>
|
||||
<div class="error-line" id="error-line" hidden></div>
|
||||
<div id="result-slot"><pre class="clip" id="result" hidden></pre></div>
|
||||
<div id="result-more"></div>
|
||||
@@ -837,6 +841,12 @@
|
||||
const failed = ['failure', 'not_started', 'error'].includes(status);
|
||||
// Fullscreen, the tabs carry the result; inline it shows here.
|
||||
const inline = !(fullscreen() && run?.id);
|
||||
const head = $('result-head');
|
||||
head.hidden = !inline || running || !run?.id;
|
||||
head.replaceChildren(...(head.hidden ? [] : [el('span', { class: 'section-title' }, failed ? 'Error' : 'Result'),
|
||||
...[['logs', 'Logs'], ['inputs', 'Inputs']].map(([name, label]) => el('button', {
|
||||
class: 'more-line', type: 'button', onclick: () => (canFullscreen() ? openTab(name) : openLink(run.url))
|
||||
}, label))]));
|
||||
const errorLine = $('error-line');
|
||||
errorLine.hidden = !inline || !failed || run?.result == null;
|
||||
const errorText_ = failed ? run?.result ?? '' : '';
|
||||
@@ -1239,7 +1249,7 @@
|
||||
window.clearTimeout(pollTimer);
|
||||
window.clearInterval(tickTimer);
|
||||
run = null;
|
||||
for (const id of ['step', 'stale', 'error-line', 'result', 'details', 'cancel', 'expand', 'deploy']) $(id).hidden = true;
|
||||
for (const id of ['step', 'stale', 'result-head', 'error-line', 'result', 'details', 'cancel', 'expand', 'deploy']) $(id).hidden = true;
|
||||
$('result-more').replaceChildren();
|
||||
$('duration').textContent = '';
|
||||
$('result-table').replaceChildren();
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -524,7 +524,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
"trigger_kind": {
|
||||
"description": "Required when type is trigger. Identifies which trigger service to call.",
|
||||
"description": "Required when type is trigger: the kind of trigger.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"http",
|
||||
@@ -580,7 +580,7 @@
|
||||
},
|
||||
{
|
||||
"name": "write_script",
|
||||
"description": "Create or overwrite a draft script.",
|
||||
"description": "Create or overwrite a draft script. Call get_instructions first.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -643,7 +643,7 @@
|
||||
},
|
||||
{
|
||||
"name": "write_flow",
|
||||
"description": "Create or overwrite a draft flow.",
|
||||
"description": "Create or overwrite a draft flow. Call get_instructions first.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1014,7 +1014,7 @@
|
||||
},
|
||||
{
|
||||
"name": "test_run_script",
|
||||
"description": "Execute a preview-style test run of a script by path, preferring draft content when it exists. It runs with exactly the `args` you send. For a secret argument prefer `$var:<path>` naming an existing workspace variable; a literal is minted into a short-lived secret before the run, but stays in this call.",
|
||||
"description": "Execute a preview-style test run of a script by path, preferring draft content when it exists. It runs with exactly the `args` you send. For a secret argument prefer `$var:<path>` naming an existing workspace variable; a literal also works, but stays in this conversation. When the user asked for this run, show it to them with show_run, if you have it. Once the draft works and the user wants to review it, show it with show_deploy_review, if you have it.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1038,11 +1038,11 @@
|
||||
]
|
||||
},
|
||||
"background": {
|
||||
"description": "Run in the background without waiting. Set true for jobs you expect to be long (deploys, backfills, big queries) — you will be notified when it finishes. Leave unset for normal runs, which wait briefly and only background automatically if slow.",
|
||||
"description": "Run in the background without waiting. Set true for jobs you expect to be long (deploys, backfills, big queries): the result gives its job id, to follow with get_run. Leave unset for normal runs, which wait briefly and only background automatically if slow.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"wait_seconds": {
|
||||
"description": "How many seconds to wait for the job in-turn before it detaches into the background jobs tray. Defaults to 15. Raise it (capped at 120) for a job you expect to finish in, say, 30–60s and want the result in this same turn. Ignored when background is true. Do not use this to poll — larger values just hold the turn longer.",
|
||||
"description": "How many seconds to wait for the job in-turn before it keeps running in the background. Defaults to 15. Raise it (capped at 120) for a job you expect to finish in, say, 30–60s and want the result in this same turn. Ignored when background is true. Do not use this to poll — larger values just hold the turn longer.",
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
@@ -1055,7 +1055,7 @@
|
||||
},
|
||||
{
|
||||
"name": "run_script",
|
||||
"description": "Run a DEPLOYED script for real, under the user's own permissions. It runs with exactly the `args` you send. For a secret argument prefer `$var:<path>` naming an existing workspace variable; a literal is minted into a short-lived secret before the run, but stays in this call. A required file is the user's to attach, so call this even when you cannot supply one rather than asking in chat. Use only when the user names the deployed version (\"the deployed X\", \"in production\", \"for real\").",
|
||||
"description": "Run a DEPLOYED script for real, under the user's own permissions. It runs with exactly the `args` you send. For a secret argument prefer `$var:<path>` naming an existing workspace variable; a literal also works, but stays in this conversation. A required file is the user's to attach, so call this even when you cannot supply one rather than asking in chat. Use only when the user names the deployed version (\"the deployed X\", \"in production\", \"for real\"). Then show the run to the user with show_run, if you have it.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1079,11 +1079,11 @@
|
||||
]
|
||||
},
|
||||
"background": {
|
||||
"description": "Run in the background without waiting. Set true for jobs you expect to be long (deploys, backfills, big queries) — you will be notified when it finishes. Leave unset for normal runs, which wait briefly and only background automatically if slow.",
|
||||
"description": "Run in the background without waiting. Set true for jobs you expect to be long (deploys, backfills, big queries): the result gives its job id, to follow with get_run. Leave unset for normal runs, which wait briefly and only background automatically if slow.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"wait_seconds": {
|
||||
"description": "How many seconds to wait for the job in-turn before it detaches into the background jobs tray. Defaults to 15. Raise it (capped at 120) for a job you expect to finish in, say, 30–60s and want the result in this same turn. Ignored when background is true. Do not use this to poll — larger values just hold the turn longer.",
|
||||
"description": "How many seconds to wait for the job in-turn before it keeps running in the background. Defaults to 15. Raise it (capped at 120) for a job you expect to finish in, say, 30–60s and want the result in this same turn. Ignored when background is true. Do not use this to poll — larger values just hold the turn longer.",
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
@@ -1096,7 +1096,7 @@
|
||||
},
|
||||
{
|
||||
"name": "test_run_flow",
|
||||
"description": "Execute a preview-style test run of a flow by path, preferring draft content when it exists. It runs with exactly the `args` you send. For a secret argument prefer `$var:<path>` naming an existing workspace variable; a literal is minted into a short-lived secret before the run, but stays in this call.",
|
||||
"description": "Execute a preview-style test run of a flow by path, preferring draft content when it exists. It runs with exactly the `args` you send. For a secret argument prefer `$var:<path>` naming an existing workspace variable; a literal also works, but stays in this conversation. When the user asked for this run, show it to them with show_run, if you have it. Once the draft works and the user wants to review it, show it with show_deploy_review, if you have it.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1124,11 +1124,11 @@
|
||||
"type": "string"
|
||||
},
|
||||
"background": {
|
||||
"description": "Run in the background without waiting. Set true for jobs you expect to be long (deploys, backfills, big queries) — you will be notified when it finishes. Leave unset for normal runs, which wait briefly and only background automatically if slow.",
|
||||
"description": "Run in the background without waiting. Set true for jobs you expect to be long (deploys, backfills, big queries): the result gives its job id, to follow with get_run. Leave unset for normal runs, which wait briefly and only background automatically if slow.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"wait_seconds": {
|
||||
"description": "How many seconds to wait for the job in-turn before it detaches into the background jobs tray. Defaults to 15. Raise it (capped at 120) for a job you expect to finish in, say, 30–60s and want the result in this same turn. Ignored when background is true. Do not use this to poll — larger values just hold the turn longer.",
|
||||
"description": "How many seconds to wait for the job in-turn before it keeps running in the background. Defaults to 15. Raise it (capped at 120) for a job you expect to finish in, say, 30–60s and want the result in this same turn. Ignored when background is true. Do not use this to poll — larger values just hold the turn longer.",
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
@@ -1141,7 +1141,7 @@
|
||||
},
|
||||
{
|
||||
"name": "run_flow",
|
||||
"description": "Run a DEPLOYED flow for real, under the user's own permissions. It runs with exactly the `args` you send. For a secret argument prefer `$var:<path>` naming an existing workspace variable; a literal is minted into a short-lived secret before the run, but stays in this call. A required file is the user's to attach, so call this even when you cannot supply one rather than asking in chat. Use only when the user names the deployed version (\"the deployed X\", \"in production\", \"for real\").",
|
||||
"description": "Run a DEPLOYED flow for real, under the user's own permissions. It runs with exactly the `args` you send. For a secret argument prefer `$var:<path>` naming an existing workspace variable; a literal also works, but stays in this conversation. A required file is the user's to attach, so call this even when you cannot supply one rather than asking in chat. Use only when the user names the deployed version (\"the deployed X\", \"in production\", \"for real\"). Then show the run to the user with show_run, if you have it.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1165,11 +1165,11 @@
|
||||
]
|
||||
},
|
||||
"background": {
|
||||
"description": "Run in the background without waiting. Set true for jobs you expect to be long (deploys, backfills, big queries) — you will be notified when it finishes. Leave unset for normal runs, which wait briefly and only background automatically if slow.",
|
||||
"description": "Run in the background without waiting. Set true for jobs you expect to be long (deploys, backfills, big queries): the result gives its job id, to follow with get_run. Leave unset for normal runs, which wait briefly and only background automatically if slow.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"wait_seconds": {
|
||||
"description": "How many seconds to wait for the job in-turn before it detaches into the background jobs tray. Defaults to 15. Raise it (capped at 120) for a job you expect to finish in, say, 30–60s and want the result in this same turn. Ignored when background is true. Do not use this to poll — larger values just hold the turn longer.",
|
||||
"description": "How many seconds to wait for the job in-turn before it keeps running in the background. Defaults to 15. Raise it (capped at 120) for a job you expect to finish in, say, 30–60s and want the result in this same turn. Ignored when background is true. Do not use this to poll — larger values just hold the turn longer.",
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
@@ -1182,7 +1182,7 @@
|
||||
},
|
||||
{
|
||||
"name": "test_run_agent",
|
||||
"description": "Execute a test run of an AI agent by path, preferring its draft when one exists, so an agent you drafted can be tried before the user deploys it. It runs with exactly the `args` you send.",
|
||||
"description": "Execute a test run of an AI agent by path, preferring its draft when one exists, so an agent you drafted can be tried before the user deploys it. It runs with exactly the `args` you send. When the user asked for this run, show it to them with show_run, if you have it.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1209,11 +1209,11 @@
|
||||
"type": "string"
|
||||
},
|
||||
"background": {
|
||||
"description": "Run in the background without waiting. Set true for jobs you expect to be long (deploys, backfills, big queries) — you will be notified when it finishes. Leave unset for normal runs, which wait briefly and only background automatically if slow.",
|
||||
"description": "Run in the background without waiting. Set true for jobs you expect to be long (deploys, backfills, big queries): the result gives its job id, to follow with get_run. Leave unset for normal runs, which wait briefly and only background automatically if slow.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"wait_seconds": {
|
||||
"description": "How many seconds to wait for the job in-turn before it detaches into the background jobs tray. Defaults to 15. Raise it (capped at 120) for a job you expect to finish in, say, 30–60s and want the result in this same turn. Ignored when background is true. Do not use this to poll — larger values just hold the turn longer.",
|
||||
"description": "How many seconds to wait for the job in-turn before it keeps running in the background. Defaults to 15. Raise it (capped at 120) for a job you expect to finish in, say, 30–60s and want the result in this same turn. Ignored when background is true. Do not use this to poll — larger values just hold the turn longer.",
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
@@ -1227,7 +1227,7 @@
|
||||
},
|
||||
{
|
||||
"name": "run_agent",
|
||||
"description": "Run a DEPLOYED AI agent for real, as its own page runs it. It runs with exactly the `args` you send. Use only when the user names the deployed version (\"the deployed X\", \"in production\", \"for real\").",
|
||||
"description": "Run a DEPLOYED AI agent for real, as its own page runs it. It runs with exactly the `args` you send. Use only when the user names the deployed version (\"the deployed X\", \"in production\", \"for real\"). Then show the run to the user with show_run, if you have it.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1254,11 +1254,11 @@
|
||||
"type": "string"
|
||||
},
|
||||
"background": {
|
||||
"description": "Run in the background without waiting. Set true for jobs you expect to be long (deploys, backfills, big queries) — you will be notified when it finishes. Leave unset for normal runs, which wait briefly and only background automatically if slow.",
|
||||
"description": "Run in the background without waiting. Set true for jobs you expect to be long (deploys, backfills, big queries): the result gives its job id, to follow with get_run. Leave unset for normal runs, which wait briefly and only background automatically if slow.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"wait_seconds": {
|
||||
"description": "How many seconds to wait for the job in-turn before it detaches into the background jobs tray. Defaults to 15. Raise it (capped at 120) for a job you expect to finish in, say, 30–60s and want the result in this same turn. Ignored when background is true. Do not use this to poll — larger values just hold the turn longer.",
|
||||
"description": "How many seconds to wait for the job in-turn before it keeps running in the background. Defaults to 15. Raise it (capped at 120) for a job you expect to finish in, say, 30–60s and want the result in this same turn. Ignored when background is true. Do not use this to poll — larger values just hold the turn longer.",
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
@@ -1272,7 +1272,7 @@
|
||||
},
|
||||
{
|
||||
"name": "test_run_step",
|
||||
"description": "Execute a test run of one step in a flow by path, preferring draft flow/script content when it exists. `args` are the step's OWN inputs, not the flow's: a step is normally fed by its input transforms, so send what that step's code takes, not what the flow takes. An AI agent step takes the inputs a run supplies rather than code arguments, `user_message` above all; its form opens on the step's own configuration, so send only what this run should change. An AI decision step takes `state`, what its questions are asked about; its provider and questions are the step's own. It runs with exactly the `args` you send. For a secret argument prefer `$var:<path>` naming an existing workspace variable; a literal is minted into a short-lived secret before the run, but stays in this call.",
|
||||
"description": "Execute a test run of one step in a flow by path, preferring draft flow/script content when it exists. `args` are the step's OWN inputs, not the flow's: a step is normally fed by its input transforms, so send what that step's code takes, not what the flow takes. An AI agent step takes the inputs a run supplies rather than code arguments, `user_message` above all; its form opens on the step's own configuration, so send only what this run should change. An AI decision step takes `state`, what its questions are asked about; its provider and questions are the step's own. It runs with exactly the `args` you send. For a secret argument prefer `$var:<path>` naming an existing workspace variable; a literal also works, but stays in this conversation.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1300,11 +1300,11 @@
|
||||
]
|
||||
},
|
||||
"background": {
|
||||
"description": "Run in the background without waiting. Set true for jobs you expect to be long (deploys, backfills, big queries) — you will be notified when it finishes. Leave unset for normal runs, which wait briefly and only background automatically if slow.",
|
||||
"description": "Run in the background without waiting. Set true for jobs you expect to be long (deploys, backfills, big queries): the result gives its job id, to follow with get_run. Leave unset for normal runs, which wait briefly and only background automatically if slow.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"wait_seconds": {
|
||||
"description": "How many seconds to wait for the job in-turn before it detaches into the background jobs tray. Defaults to 15. Raise it (capped at 120) for a job you expect to finish in, say, 30–60s and want the result in this same turn. Ignored when background is true. Do not use this to poll — larger values just hold the turn longer.",
|
||||
"description": "How many seconds to wait for the job in-turn before it keeps running in the background. Defaults to 15. Raise it (capped at 120) for a job you expect to finish in, say, 30–60s and want the result in this same turn. Ignored when background is true. Do not use this to poll — larger values just hold the turn longer.",
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
@@ -1318,7 +1318,7 @@
|
||||
},
|
||||
{
|
||||
"name": "list_runs",
|
||||
"description": "List recent runs (jobs), most recent first. Optionally filter by path, creator, label, or status. Returns compact metadata only — use get_run with a returned id to see what a run was called with, returned and logged.",
|
||||
"description": "List recent runs (jobs), most recent first. Optionally filter by path, creator, label, or status. Returns compact metadata only — use get_run with a returned id to see what a run was called with, returned and logged. To show runs to the user, pass their ids to show_runs, if you have it.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1619,7 +1619,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
"trigger_kind": {
|
||||
"description": "Required when type is trigger. Identifies which trigger service to call.",
|
||||
"description": "Required when type is trigger: the kind of trigger.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"http",
|
||||
@@ -1694,7 +1694,7 @@
|
||||
},
|
||||
{
|
||||
"name": "write_resource",
|
||||
"description": "Create or overwrite a draft resource.",
|
||||
"description": "Create or overwrite a draft resource. Call get_instructions first.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1936,7 +1936,7 @@
|
||||
},
|
||||
{
|
||||
"name": "init_app",
|
||||
"description": "Initialize a draft raw app from a framework template.",
|
||||
"description": "Initialize a draft raw app from a framework template. Call get_instructions first.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -2292,11 +2292,11 @@
|
||||
]
|
||||
},
|
||||
"background": {
|
||||
"description": "Run in the background without waiting. Set true for jobs you expect to be long (deploys, backfills, big queries) — you will be notified when it finishes. Leave unset for normal runs, which wait briefly and only background automatically if slow.",
|
||||
"description": "Run in the background without waiting. Set true for jobs you expect to be long (deploys, backfills, big queries): the result gives its job id, to follow with get_run. Leave unset for normal runs, which wait briefly and only background automatically if slow.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"wait_seconds": {
|
||||
"description": "How many seconds to wait for the job in-turn before it detaches into the background jobs tray. Defaults to 15. Raise it (capped at 120) for a job you expect to finish in, say, 30–60s and want the result in this same turn. Ignored when background is true. Do not use this to poll — larger values just hold the turn longer.",
|
||||
"description": "How many seconds to wait for the job in-turn before it keeps running in the background. Defaults to 15. Raise it (capped at 120) for a job you expect to finish in, say, 30–60s and want the result in this same turn. Ignored when background is true. Do not use this to poll — larger values just hold the turn longer.",
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
@@ -2382,11 +2382,11 @@
|
||||
"pattern": "^[A-Za-z0-9_-]{1,63}$"
|
||||
},
|
||||
"background": {
|
||||
"description": "Run in the background without waiting. Set true for queries you expect to be slow (large scans, heavy migrations) — you will be notified when it finishes. Leave unset for normal queries, which wait briefly and only background automatically if slow.",
|
||||
"description": "Run in the background without waiting. Set true for queries you expect to be slow (large scans, heavy migrations): the result gives its job id, to follow with get_run. Leave unset for normal queries, which wait briefly and only background automatically if slow.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"wait_seconds": {
|
||||
"description": "How many seconds to wait for the query in-turn before it detaches into the background jobs tray. Defaults to 15. Raise it (capped at 120) for a query you expect to finish in ~30–60s and want the result in this same turn. Ignored when background is true.",
|
||||
"description": "How many seconds to wait for the query in-turn before it keeps running in the background. Defaults to 15. Raise it (capped at 120) for a query you expect to finish in ~30–60s and want the result in this same turn. Ignored when background is true.",
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -104,11 +104,23 @@ const EDITOR_ONLY: &[&str] = &[
|
||||
"read_file",
|
||||
];
|
||||
|
||||
/// Tools whose effect discarding a draft cannot undo: they reach the deployed workspace or a
|
||||
/// live datatable, run code, cancel a job, or delete work. Stands in for the session's
|
||||
/// confirmation card. The ChatGPT and Claude directories reject a write that deletes,
|
||||
/// cancels or cannot be taken back without this hint, even when it could be redone.
|
||||
/// Tools that can lose work or cannot be taken back: they reach the deployed workspace or a
|
||||
/// live datatable, run code, cancel a job, delete work, or replace a draft's content, which
|
||||
/// discarding the draft does not restore. Stands in for the session's confirmation card. The
|
||||
/// ChatGPT and Claude directories reject such a tool without this hint.
|
||||
const DESTRUCTIVE: &[&str] = &[
|
||||
"write_script",
|
||||
"edit_script",
|
||||
"write_flow",
|
||||
"patch_flow_json",
|
||||
"set_flow_module_code",
|
||||
"write_schedule",
|
||||
"write_trigger",
|
||||
"write_resource",
|
||||
"write_variable",
|
||||
"write_app_file",
|
||||
"patch_app_file",
|
||||
"write_app_runnable",
|
||||
"deploy_workspace_item",
|
||||
"delete_workspace_item",
|
||||
"create_resource_type",
|
||||
@@ -139,8 +151,10 @@ const CARD_ACTIONS: &[&str] = &["deploy_workspace_item", "cancel_job"];
|
||||
|
||||
/// Tools that reach a system outside Windmill on the workspace's behalf: running code can
|
||||
/// reach any system the workspace can, and `get_db_schema` connects to a resource's
|
||||
/// database. Reading public reference data (hub, npm, docs) does not count.
|
||||
/// database, and `search_npm_packages` queries the npm registry, which Windmill does not
|
||||
/// control. Reading Windmill's own hub and docs does not count.
|
||||
const OPEN_WORLD: &[&str] = &[
|
||||
"search_npm_packages",
|
||||
"run_script",
|
||||
"run_flow",
|
||||
"run_agent",
|
||||
|
||||
@@ -524,7 +524,7 @@ const readWorkspaceItemSchema = z.object({
|
||||
),
|
||||
trigger_kind: triggerKindSchema
|
||||
.optional()
|
||||
.describe('Required when type is trigger. Identifies which trigger service to call.'),
|
||||
.describe('Required when type is trigger: the kind of trigger.'),
|
||||
version: z
|
||||
.enum(['deployed'])
|
||||
.optional()
|
||||
@@ -853,7 +853,7 @@ const deleteWorkspaceItemSchema = z.object({
|
||||
path: z.string().describe('Workspace path of the item to delete.'),
|
||||
trigger_kind: triggerKindSchema
|
||||
.optional()
|
||||
.describe('Required when type is trigger. Identifies which trigger service to call.')
|
||||
.describe('Required when type is trigger: the kind of trigger.')
|
||||
})
|
||||
|
||||
const discardLocalDraftSchema = z.object({
|
||||
@@ -1024,7 +1024,7 @@ const testRunScriptSchema = z.object({
|
||||
const testRunScriptToolDef = createToolDef(
|
||||
testRunScriptSchema,
|
||||
'test_run_script',
|
||||
'Execute a preview-style test run of a script by path, preferring draft content when it exists. The user gets an argument form prefilled with `args` and may edit or dismiss it before it runs, so fill in every argument you can infer. For a secret argument prefer `$var:<path>` naming an existing workspace variable; a literal is minted into a short-lived secret before the run, but stays in this call.',
|
||||
'Execute a preview-style test run of a script by path, preferring draft content when it exists. The user gets an argument form prefilled with `args` and may edit or dismiss it before it runs, so fill in every argument you can infer. For a secret argument prefer `$var:<path>` naming an existing workspace variable; a literal also works, but stays in this conversation.',
|
||||
{ strict: false }
|
||||
)
|
||||
|
||||
@@ -1038,7 +1038,7 @@ const runScriptSchema = z.object({
|
||||
const runScriptToolDef = createToolDef(
|
||||
runScriptSchema,
|
||||
'run_script',
|
||||
'Run a DEPLOYED script for real, under the user\'s own permissions. Fill in every argument you can infer: the user gets an argument form prefilled with `args` and decides what runs. In an AI session the user can open that form on the script\'s own deployed page instead; either way this call waits for them and runs what they confirm. For a secret argument prefer `$var:<path>` naming an existing workspace variable; a literal is minted into a short-lived secret before the run, but stays in this call. A required file is the user\'s to attach, so call this even when you cannot supply one rather than asking in chat. Use only when the user names the deployed version ("the deployed X", "in production", "for real").',
|
||||
'Run a DEPLOYED script for real, under the user\'s own permissions. Fill in every argument you can infer: the user gets an argument form prefilled with `args` and decides what runs. In an AI session the user can open that form on the script\'s own deployed page instead; either way this call waits for them and runs what they confirm. For a secret argument prefer `$var:<path>` naming an existing workspace variable; a literal also works, but stays in this conversation. A required file is the user\'s to attach, so call this even when you cannot supply one rather than asking in chat. Use only when the user names the deployed version ("the deployed X", "in production", "for real").',
|
||||
{ strict: false }
|
||||
)
|
||||
|
||||
@@ -1063,7 +1063,7 @@ const testRunFlowSchema = z.object({
|
||||
const testRunFlowToolDef = createToolDef(
|
||||
testRunFlowSchema,
|
||||
'test_run_flow',
|
||||
'Execute a preview-style test run of a flow by path, preferring draft content when it exists. The user gets an argument form prefilled with `args` and may edit or dismiss it before it runs, so fill in every argument you can infer. For a secret argument prefer `$var:<path>` naming an existing workspace variable; a literal is minted into a short-lived secret before the run, but stays in this call.',
|
||||
'Execute a preview-style test run of a flow by path, preferring draft content when it exists. The user gets an argument form prefilled with `args` and may edit or dismiss it before it runs, so fill in every argument you can infer. For a secret argument prefer `$var:<path>` naming an existing workspace variable; a literal also works, but stays in this conversation.',
|
||||
{ strict: false }
|
||||
)
|
||||
|
||||
@@ -1077,7 +1077,7 @@ const runFlowSchema = z.object({
|
||||
const runFlowToolDef = createToolDef(
|
||||
runFlowSchema,
|
||||
'run_flow',
|
||||
'Run a DEPLOYED flow for real, under the user\'s own permissions. Fill in every argument you can infer: the user gets an argument form prefilled with `args` and decides what runs. In an AI session the user can open that form on the flow\'s own deployed page instead; either way this call waits for them and runs what they confirm. For a secret argument prefer `$var:<path>` naming an existing workspace variable; a literal is minted into a short-lived secret before the run, but stays in this call. A required file is the user\'s to attach, so call this even when you cannot supply one rather than asking in chat. Use only when the user names the deployed version ("the deployed X", "in production", "for real").',
|
||||
'Run a DEPLOYED flow for real, under the user\'s own permissions. Fill in every argument you can infer: the user gets an argument form prefilled with `args` and decides what runs. In an AI session the user can open that form on the flow\'s own deployed page instead; either way this call waits for them and runs what they confirm. For a secret argument prefer `$var:<path>` naming an existing workspace variable; a literal also works, but stays in this conversation. A required file is the user\'s to attach, so call this even when you cannot supply one rather than asking in chat. Use only when the user names the deployed version ("the deployed X", "in production", "for real").',
|
||||
{ strict: false }
|
||||
)
|
||||
|
||||
@@ -1131,7 +1131,7 @@ const testRunStepSchema = z.object({
|
||||
const testRunStepToolDef = createToolDef(
|
||||
testRunStepSchema,
|
||||
'test_run_step',
|
||||
"Execute a test run of one step in a flow by path, preferring draft flow/script content when it exists. `args` are the step's OWN inputs, not the flow's: a step is normally fed by its input transforms, so send what that step's code takes, not what the flow takes. An AI agent step takes the inputs a run supplies rather than code arguments, `user_message` above all; its form opens on the step's own configuration, so send only what this run should change. An AI decision step takes `state`, what its questions are asked about; its provider and questions are the step's own. The user gets an argument form prefilled with `args` and may edit or dismiss it before it runs, so fill in every argument you can infer. For a secret argument prefer `$var:<path>` naming an existing workspace variable; a literal is minted into a short-lived secret before the run, but stays in this call.",
|
||||
"Execute a test run of one step in a flow by path, preferring draft flow/script content when it exists. `args` are the step's OWN inputs, not the flow's: a step is normally fed by its input transforms, so send what that step's code takes, not what the flow takes. An AI agent step takes the inputs a run supplies rather than code arguments, `user_message` above all; its form opens on the step's own configuration, so send only what this run should change. An AI decision step takes `state`, what its questions are asked about; its provider and questions are the step's own. The user gets an argument form prefilled with `args` and may edit or dismiss it before it runs, so fill in every argument you can infer. For a secret argument prefer `$var:<path>` naming an existing workspace variable; a literal also works, but stays in this conversation.",
|
||||
{ strict: false }
|
||||
)
|
||||
|
||||
@@ -1547,6 +1547,39 @@ function buildFolderGuidance(
|
||||
const listJoin = (items: (string | false)[], type: 'conjunction' | 'disjunction' = 'conjunction') =>
|
||||
new Intl.ListFormat('en', { type }).format(items.filter((i): i is string => !!i))
|
||||
|
||||
// The prompt an external MCP client reads. A directory reviewer reads it as a description of
|
||||
// what the server does, so it names only the server's own tools and leaves how each one works
|
||||
// to its description and to get_instructions. OpenAI asks for the most important details in
|
||||
// the first 512 characters and some clients keep only the first 4096, so the drafts rule
|
||||
// opens and the rules come before the path conventions.
|
||||
function buildExternalPrompt(username: string, paths: string, skills: AiSkillListItem[]) {
|
||||
return `This server works in a Windmill workspace as the user "${username}".
|
||||
|
||||
Rules:
|
||||
- What you write is a per-user draft, saved server-side and visible only to this user. Nothing reaches the workspace until deploy_workspace_item deploys it, which you call only when the user asks.
|
||||
- The user sees no Windmill page next to this conversation. Tool results carry links instead: a run's page, a draft's editor (\`url\`), an app draft's editor with its live preview (\`preview_url\`), a deployed item's page. Whenever the user will want to see what you built or ran, or has to do a step in Windmill themselves: show it with show_run, show_runs, show_item or show_deploy_review when you have them (each card carries the link), otherwise open the link in a browser the user can see if you have one, and otherwise give the link.
|
||||
- Find items with list_workspace_items and read one with read_workspace_item before changing it. An agent is a resource of type \`ai_agent\`: test it with test_run_agent and run a deployed one with run_agent, never run_flow or run_script.
|
||||
- Call get_instructions before writing a script, flow, agent, resource or app, a data pipeline or a datatable migration. For a script, pass its language. Call get_trigger_schema before write_trigger, since each trigger kind takes different fields, and get_db_schema before writing SQL against a database resource.
|
||||
- After writing a script, flow, agent or app runnable, test it with test_run_script, test_run_flow, test_run_step, test_run_agent or test_run_app_runnable before saying it works. They run the draft, so nothing needs deploying.
|
||||
- A request to run something also goes to the test_run tools. Use run_script, run_flow or run_agent only when the user asks for the deployed version, after reading it with version "deployed" so the arguments match.
|
||||
- To undo your own work, discard its draft with discard_local_draft. delete_workspace_item removes an item that is deployed.
|
||||
- Listings return only what this user can see. When an item they name is missing, say it may be in a folder they cannot read, not that it does not exist.
|
||||
- No one can read a variable's value through these tools. When editing a variable, pass only the fields that change.
|
||||
- Before writing code against a third-party API, look for its integration with search_hub_scripts and get_hub_integration.
|
||||
- Only raw apps (\`rawApp\` true) can be read, edited and deployed here. When a deploy says it widens who may open an app, tell the user in plain words.
|
||||
- Datatables are set up in the workspace settings. Start from list_datatables; one with \`migrations_enabled\` changes its schema through migrations only.
|
||||
- create_resource_type adds a resource type: show the user the schema first and create it once they agree.
|
||||
- For how Windmill itself works, use search_docs and read_docs_page, and link the page you relied on.${paths}${
|
||||
skills.length > 0
|
||||
? `
|
||||
|
||||
Skills:
|
||||
- This workspace keeps skills, guidance documents for specific kinds of tasks, listed below by path and description. read_skill returns one: read it when a request matches its description, then do the work with the tools above.
|
||||
${skills.map((s) => `- ${s.path}: ${s.description}`).join('\n')}`
|
||||
: ''
|
||||
}`
|
||||
}
|
||||
|
||||
const buildGlobalSystemPrompt = (
|
||||
username: string,
|
||||
previewTools: boolean,
|
||||
@@ -1554,8 +1587,8 @@ const buildGlobalSystemPrompt = (
|
||||
skills: AiSkillListItem[] = [],
|
||||
mcpServers: McpServer[] = [],
|
||||
access?: SessionAccess,
|
||||
// The prompt as an external MCP client reads it: the same rules, minus the tools and
|
||||
// surfaces only the Windmill UI has (pages, the run form, questions, the open editor).
|
||||
// The prompt an external MCP client reads (`buildExternalPrompt`): it shares only the path
|
||||
// conventions, which carry the folder guidance.
|
||||
external = false
|
||||
) => {
|
||||
// Each `can*` mirrors the capability the matching tools declare in `requires`, so a
|
||||
@@ -1696,23 +1729,14 @@ const buildGlobalSystemPrompt = (
|
||||
const runRule = `${when(
|
||||
canRunPreview,
|
||||
`
|
||||
- Default to ${testRunTools} for any run request, an existing script included; they prefer drafts and need no deployment. Use run_script or run_flow only when the user names the deployed version ("the deployed X", "in production", "for real") — a bare "run X" is not that. For those two, read the item with read_workspace_item version: "deployed" first so the arguments match the deployed schema. ${
|
||||
external
|
||||
? `${testRunList}, run_script and run_flow run with exactly the arguments you send, so fill in every argument the schema asks for. test_run_step takes the step's own inputs, not the flow's.`
|
||||
: `${testRunList}, run_script and run_flow all show the user an argument form prefilled with what you sent, so fill in every argument you can infer rather than asking for it in chat. test_run_step's form is the step's own inputs, not the flow's.`
|
||||
}`
|
||||
- Default to ${testRunTools} for any run request, an existing script included; they prefer drafts and need no deployment. Use run_script or run_flow only when the user names the deployed version ("the deployed X", "in production", "for real") — a bare "run X" is not that. For those two, read the item with read_workspace_item version: "deployed" first so the arguments match the deployed schema. ${testRunList}, run_script and run_flow all show the user an argument form prefilled with what you sent, so fill in every argument you can infer rather than asking for it in chat. test_run_step's form is the step's own inputs, not the flow's.`
|
||||
)}${when(
|
||||
!canRunPreview,
|
||||
`
|
||||
- run_script and run_flow are how you run anything here: they run the DEPLOYED item under this user's own permissions, and show them an argument form prefilled with what you sent. Read the item with read_workspace_item version: "deployed" first so the arguments match the deployed schema, and fill in every argument you can infer rather than asking for it in chat.`
|
||||
)}`
|
||||
|
||||
const intro = `${external ? 'You are working in a Windmill workspace through its MCP server.' : "You are Windmill's global workspace assistant."}${when(
|
||||
external,
|
||||
`
|
||||
|
||||
The user sees no Windmill page next to this conversation. Tool results carry links instead: a run's page, a script, flow or agent draft's url (its editor), an app draft's preview_url (the app editor with its live preview, which these instructions call "the preview"), a deployed item's url. Whenever the user will want to see what you built or ran, or has to do a step in Windmill themselves, open the link in a browser they can see from this conversation if you have one, and otherwise give them the link to open.`
|
||||
)}
|
||||
const intro = `You are Windmill's global workspace assistant.
|
||||
|
||||
The current user's workspace username is "${username}".${instanceLine}
|
||||
|
||||
@@ -1764,33 +1788,25 @@ Path conventions:
|
||||
canCreateFolder && !canWriteAnyDraft,
|
||||
'\n- You can create a shared folder with `create_folder` when the user explicitly asks for one. You cannot create anything inside it here, so do not offer to.'
|
||||
)}`
|
||||
// An MCP client may keep only the first 4096 characters of its instructions, so there
|
||||
// these rules come before the path conventions and are left out of the later list.
|
||||
const coreRules = `${draftsOnlyRule}
|
||||
${findItemsRule}${deployRule}${when(canWriteDraft, `\n${instructionsRule}`)}${when(
|
||||
canRunPreview && canWriteDraft,
|
||||
`\n${testDraftRule}`
|
||||
)}${runRule}`
|
||||
if (external) return buildExternalPrompt(username, paths, skills)
|
||||
|
||||
return `${intro}${when(external, `\n\nRules:${coreRules}`)}${paths}
|
||||
return `${intro}${paths}
|
||||
|
||||
${external ? 'More rules:' : `Rules:${draftsOnlyRule}\n${findItemsRule}`}
|
||||
Rules:${draftsOnlyRule}
|
||||
${findItemsRule}
|
||||
${groupMembershipRule}- Listings and reads return only what this user can see: items in folders they cannot read are hidden from you both. When an item the user names is missing, say it is not among what they can see and may be in a folder they cannot read, where someone with access can run it — never state that it does not exist or is not deployed.
|
||||
- An agent, as the Agents page lists it, is a resource of type \`ai_agent\`: read it with read_workspace_item type "resource".${when(
|
||||
// An agent draft is a resource draft that the server checks under the flow builder right.
|
||||
canDraftResources && canWriteFlowDraft,
|
||||
` You may draft a new agent or a change to one, after calling get_instructions with subject "agent". The user can review it on the agent's page, ${external ? 'the url write_resource returns' : '\`/agents/edit/<path>\`'}.`
|
||||
` You may draft a new agent or a change to one, after calling get_instructions with subject "agent". The user can review it on the agent's page, \`/agents/edit/<path>\`.`
|
||||
)}${when(
|
||||
buildsFlows,
|
||||
' Its tools, like flow steps, may only reference deployed scripts and flows by path: the server refuses inline code and hub scripts.'
|
||||
)}${when(
|
||||
canRunFlowPreview,
|
||||
' Test an agent, its draft included, with test_run_agent.'
|
||||
)} Run a deployed agent with run_agent, never with run_flow or run_script.${when(
|
||||
!external,
|
||||
`
|
||||
- If the user message includes an ACTIVE EDITOR section, treat it as the currently open item and use it for references like "this", "current", or "open editor".`
|
||||
)}${activePreviewRule}${when(!external, deployRule)}${when(
|
||||
)} Run a deployed agent with run_agent, never with run_flow or run_script.
|
||||
- If the user message includes an ACTIVE EDITOR section, treat it as the currently open item and use it for references like "this", "current", or "open editor".${activePreviewRule}${deployRule}${when(
|
||||
canWriteAnyDraft,
|
||||
`
|
||||
- To undo something you created or changed in this chat, use discard_local_draft: everything you write is a draft until it is explicitly deployed, so "delete it" / "never mind" / "remove that" about your own work means discarding the draft (it also clears the matching open editor draft).${when(
|
||||
@@ -1828,10 +1844,12 @@ ${groupMembershipRule}- Listings and reads return only what this user can see: i
|
||||
- Hub scripts are prebuilt, vetted integrations for third-party services, hosted outside the workspace under \`hub/<version>/<app>/<name>\` paths. Check search_hub_scripts before hand-writing code against a third-party API, even when the user never mentions the hub; read a result with read_workspace_item type "script" and its hub path to get its code, language, and input schema. Use what you find in whichever way fits: reference the hub path directly from a flow module or app runnable when a script already does the job, copy it into a workspace draft and adapt it when it is close (note the source hub path in a comment at the top of the code), or take it as a worked example and write your own. A script that does not do what the user asked is still worth reading when it is the only example of that integration: pass its \`integration\` back to search_hub_scripts to list that integration's other scripts with their descriptions, or use the \`suggested_integrations\` a search hands back when it finds nothing.
|
||||
- Before writing your own code against an integration the hub covers, call get_hub_integration with its slug: it returns the resource type to take, its auth fields and the integration's most-used scripts, which beats inferring them from script bodies. Call it for the integration you are about to write against, whichever it is. A search marks an integration \`documented\` when the hub additionally holds provider knowledge checked against the live API — pagination, enums, error codes and gotchas — so read that closely where it appears rather than trusting your own memory of the API.
|
||||
- If you have a web search tool and the hub does not cover a third-party API, search for the vendor's own API documentation rather than writing its endpoints and auth from memory, and link the page you relied on. Reserve it for external APIs: search_docs answers questions about Windmill itself.
|
||||
${when(canCreateResourceType, `- create_resource_type creates a resource type the workspace lacks. ${external ? 'Show the user the schema you propose and create it once they agree.' : 'The user confirms the schema in the call itself, so that is where you propose it rather than asking first in chat.'}\n`)}${when(!canCreateResourceType, '- This user cannot create a resource type here, in chat or on the Resources page, since the workspace refuses their direct deployment: when one is needed, give them its name and JSON Schema to pass to a workspace admin, who can add it.\n')}${when(canRunPreview, '- Use get_db_schema with a database resource path to fetch its tables and columns before writing SQL (or a script querying that database).\n')}${when(!external, `${instructionsRule}\n`)}${pipelineBullet}`
|
||||
${when(canCreateResourceType, `- create_resource_type creates a resource type the workspace lacks. The user confirms the schema in the call itself, so that is where you propose it rather than asking first in chat.\n`)}${when(!canCreateResourceType, '- This user cannot create a resource type here, in chat or on the Resources page, since the workspace refuses their direct deployment: when one is needed, give them its name and JSON Schema to pass to a workspace admin, who can add it.\n')}${when(canRunPreview, '- Use get_db_schema with a database resource path to fetch its tables and columns before writing SQL (or a script querying that database).\n')}${instructionsRule}
|
||||
${pipelineBullet}`
|
||||
)}${when(
|
||||
canRunPreview && canWriteDraft,
|
||||
`${when(!external, `\n${testDraftRule}`)}
|
||||
`
|
||||
${testDraftRule}
|
||||
- Do the same for a raw app: run test_run_app_runnable on each backend runnable you wrote or changed before saying the app works. A bundle that compiles proves nothing about whether the runnables run. An inline runnable executes the app's draft code; a path runnable executes the DEPLOYED script/flow it names, so a path runnable aimed at something you have not deployed fails here — that failure is the point: report it and offer to deploy that one target. The app itself does not need deploying to be tested.`
|
||||
)}${when(
|
||||
buildsFlows && (!access || access.has('run_flow_preview')),
|
||||
@@ -1839,21 +1857,15 @@ ${when(canCreateResourceType, `- create_resource_type creates a resource type th
|
||||
- After creating or editing a flow draft, run test_run_flow with representative args before reporting that it works. It prefers drafts, so testing does not require deployment.`
|
||||
)}
|
||||
- Use list_runs to find recent runs (optionally filtered by path, creator, label, or status), then get_run with a returned id to see what that run was called with, what it returned and what it logged — without starting a new test run.
|
||||
- get_run also covers what a flow run did per step — statuses and results across the whole execution tree, subflow steps and loop iterations included — and works while the flow is still running. Pass step to read one step's result in full (capped at 12k chars).${when(
|
||||
!external,
|
||||
`
|
||||
- get_run also covers what a flow run did per step — statuses and results across the whole execution tree, subflow steps and loop iterations included — and works while the flow is still running. Pass step to read one step's result in full (capped at 12k chars).
|
||||
- Use open_page to show a workspace page with filters applied — Runs, Schedules, Variables, Resources, Assets, Audit logs, or Workspace settings on a specific tab (e.g. "open the failed runs of f/foo/bar", "open the schedule for X", "open the git sync settings"). Carry over every filter the user described — Runs takes the page's whole filter set (time window, path, user, folder, label, tag, worker, trigger kind, args/result, ...), so don't drop a criterion just because it wasn't in the request's main clause. Only the pages listed for this user in the tool are available; don't offer pages that aren't listed. Don't use it as a substitute for list_runs when you just need the data yourself.
|
||||
- Whenever you ask the user to perform a manual step in the UI — fill in a resource's credentials, set a secret variable's value, adjust a schedule or setting — call open_page in the same message, targeted at that item (pass open with its path to land in its editor, or the page's filters otherwise). Never just describe where to click.`
|
||||
)}${when(
|
||||
canWriteDraft && !external,
|
||||
- Whenever you ask the user to perform a manual step in the UI — fill in a resource's credentials, set a secret variable's value, adjust a schedule or setting — call open_page in the same message, targeted at that item (pass open with its path to land in its editor, or the page's filters otherwise). Never just describe where to click.${when(
|
||||
canWriteDraft,
|
||||
`
|
||||
- Do not offer or open the Compare & Deploy page for normal draft review. Only use open_page with page "compare" when the user explicitly asks to deploy a forked workspace's changes to its parent workspace.`
|
||||
)}${when(!external, runRule)}${when(
|
||||
!external,
|
||||
`
|
||||
)}${runRule}
|
||||
- When a required decision is ambiguous, use askUserQuestion with two to ten clear proposed answer strings instead of guessing. The user can also type a custom answer when none of the proposed answers fit. Set multiSelect: true only when the answers can genuinely co-apply and the user may pick several (not mutually exclusive).
|
||||
- When the user asks you to remember a lasting preference, always/never do something, or change/stop a behavior going forward, call update_user_instructions to persist it. It edits only the USER INSTRUCTIONS block (not WORKSPACE INSTRUCTIONS). Keep each instruction concise; do not use it for one-off requests scoped to the current task.`
|
||||
)}
|
||||
- When the user asks you to remember a lasting preference, always/never do something, or change/stop a behavior going forward, call update_user_instructions to persist it. It edits only the USER INSTRUCTIONS block (not WORKSPACE INSTRUCTIONS). Keep each instruction concise; do not use it for one-off requests scoped to the current task.
|
||||
- Keep context targeted.${
|
||||
previewTools
|
||||
? `${when(
|
||||
@@ -1913,7 +1925,7 @@ Raw apps:
|
||||
- Use init_app for a new app, with framework react19 unless the user named one or points at an app to follow: do not ask about the framework, and write the summary and pick the path (path conventions above) yourself. ${
|
||||
buildsApps
|
||||
? 'An app this user builds reads and stores data only through the deployed runnables it calls: do not ask about a data setup or pass init_app a data config.'
|
||||
: `When the app has to store data and the user did not say where, settle the data setup with ${external ? 'the user' : 'askUserQuestion'} BEFORE init_app or any SQL (get_instructions subject "app" lists the questions${external ? '' : ', one askUserQuestion each'}), then pass the outcome as init_app's data.`
|
||||
: `When the app has to store data and the user did not say where, settle the data setup with askUserQuestion BEFORE init_app or any SQL (get_instructions subject "app" lists the questions, one askUserQuestion each), then pass the outcome as init_app's data.`
|
||||
}
|
||||
${when(canDeployAnyKind, '- Use deploy_workspace_item after explicit user deploy intent; raw app deploy bundles JS/CSS before saving.')}`
|
||||
)}
|
||||
|
||||
@@ -68,13 +68,54 @@ const DESCRIPTION_REWRITES: [tool: string, from: string, to: string][] = [
|
||||
['set_workspace_settings', ' The user reviews the changes before they apply.', '']
|
||||
]
|
||||
|
||||
// The chat follows a backgrounded job in its jobs tray and tells the model when it ends; an
|
||||
// MCP client gets the job id back and follows it with get_run. Applied to every tool's
|
||||
// parameter of that name, and each must match at least once.
|
||||
const PARAM_REWRITES: [param: string, from: string, to: string][] = [
|
||||
[
|
||||
'background',
|
||||
' — you will be notified when it finishes.',
|
||||
': the result gives its job id, to follow with get_run.'
|
||||
],
|
||||
['wait_seconds', 'detaches into the background jobs tray', 'keeps running in the background']
|
||||
]
|
||||
|
||||
// The step an MCP client should take next, said where the model decides on it: ChatGPT gives
|
||||
// the server instructions past their first lines little weight. The show tools exist only
|
||||
// for a client that draws cards, hence "if you have it".
|
||||
const GET_INSTRUCTIONS_FIRST = ' Call get_instructions first.'
|
||||
const SHOW_USER_RUN =
|
||||
' When the user asked for this run, show it to them with show_run, if you have it.'
|
||||
const SHOW_DEPLOY_REVIEW =
|
||||
' Once the draft works and the user wants to review it, show it with show_deploy_review, if you have it.'
|
||||
const DESCRIPTION_APPENDS: [tool: string, text: string][] = [
|
||||
['write_script', GET_INSTRUCTIONS_FIRST],
|
||||
['write_flow', GET_INSTRUCTIONS_FIRST],
|
||||
['write_resource', GET_INSTRUCTIONS_FIRST],
|
||||
['init_app', GET_INSTRUCTIONS_FIRST],
|
||||
['run_script', ' Then show the run to the user with show_run, if you have it.'],
|
||||
['run_flow', ' Then show the run to the user with show_run, if you have it.'],
|
||||
['run_agent', ' Then show the run to the user with show_run, if you have it.'],
|
||||
['test_run_script', SHOW_USER_RUN + SHOW_DEPLOY_REVIEW],
|
||||
['test_run_flow', SHOW_USER_RUN + SHOW_DEPLOY_REVIEW],
|
||||
['test_run_agent', SHOW_USER_RUN],
|
||||
['list_runs', ' To show runs to the user, pass their ids to show_runs, if you have it.']
|
||||
]
|
||||
|
||||
// A rewrite only proves its old sentence is still there; this catches one added next to it.
|
||||
const CHAT_ONLY_PROMISE = /argument form|the user (confirms|reviews|approves)/i
|
||||
|
||||
function toolDefs() {
|
||||
return globalToolsFor({ sessionPreview: false }).map((tool) => {
|
||||
const unmatched = new Set(PARAM_REWRITES)
|
||||
const unappended = new Set(DESCRIPTION_APPENDS.map(([name]) => name))
|
||||
const defs = globalToolsFor({ sessionPreview: false }).map((tool) => {
|
||||
const fn = tool.def.function
|
||||
let description = fn.description ?? ''
|
||||
for (const [name, text] of DESCRIPTION_APPENDS) {
|
||||
if (name !== fn.name) continue
|
||||
description += text
|
||||
unappended.delete(name)
|
||||
}
|
||||
for (const [name, from, to] of DESCRIPTION_REWRITES) {
|
||||
if (name !== fn.name) continue
|
||||
if (!description.includes(from)) {
|
||||
@@ -85,14 +126,31 @@ function toolDefs() {
|
||||
if (CHAT_ONLY_PROMISE.test(description)) {
|
||||
throw new Error(`${fn.name}: its description promises a chat-only confirmation`)
|
||||
}
|
||||
const parameters = structuredClone(fn.parameters) as {
|
||||
properties?: Record<string, { description?: string }>
|
||||
}
|
||||
for (const rewrite of PARAM_REWRITES) {
|
||||
const [param, from, to] = rewrite
|
||||
const prop = parameters.properties?.[param]
|
||||
if (!prop?.description?.includes(from)) continue
|
||||
prop.description = prop.description.replace(from, to)
|
||||
unmatched.delete(rewrite)
|
||||
}
|
||||
return {
|
||||
name: fn.name,
|
||||
description,
|
||||
parameters: fn.parameters,
|
||||
parameters,
|
||||
// The session's own read-only marker: what plan mode lets through.
|
||||
read_only: tool.planModeSafe === true
|
||||
}
|
||||
})
|
||||
for (const [param, from] of unmatched) {
|
||||
throw new Error(`no ${param} parameter contains "${from}" any more`)
|
||||
}
|
||||
for (const name of unappended) {
|
||||
throw new Error(`${name} is no longer a session tool`)
|
||||
}
|
||||
return defs
|
||||
}
|
||||
|
||||
const WRITABLE = '{{writable_folders}}'
|
||||
|
||||
@@ -140,11 +140,14 @@
|
||||
The client can run these scripts and flows and nothing else: it cannot explore the workspace,
|
||||
read runs, build, or run anything outside the selection.
|
||||
</p>
|
||||
<McpScopeSelector
|
||||
{workspaceId}
|
||||
bind:scope={selection}
|
||||
initialScope={initialSelection}
|
||||
runnablesOnly
|
||||
/>
|
||||
<!-- A selection names paths of one workspace, so switching workspace starts it over. -->
|
||||
{#key workspaceId}
|
||||
<McpScopeSelector
|
||||
{workspaceId}
|
||||
bind:scope={selection}
|
||||
initialScope={initialSelection}
|
||||
runnablesOnly
|
||||
/>
|
||||
{/key}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -168,6 +168,15 @@
|
||||
mcpLabelAutofilled = false
|
||||
}
|
||||
|
||||
// Selected scripts and flows are listed per workspace, so a selection keeps one of them.
|
||||
function setMcpAccess(access: McpAccess) {
|
||||
mcpAccess = access
|
||||
if (access === 'selected') {
|
||||
mcpAllWorkspaces = false
|
||||
mcpWorkspaces = mcpWorkspaces.slice(0, 1)
|
||||
}
|
||||
}
|
||||
|
||||
async function createToken(mcpMode: boolean = false): Promise<void> {
|
||||
try {
|
||||
let date: Date | undefined
|
||||
@@ -259,10 +268,6 @@
|
||||
// The server builds this URL's OAuth metadata from the same API base url, and a client
|
||||
// rejects a mismatch. One URL whatever the access: the token's scopes decide which tools it gets.
|
||||
const mcpUrl = $derived(`${apiBaseUrl('mcp')}/api/mcp`)
|
||||
// Selected scripts and flows are listed per workspace: across several, a path could be two.
|
||||
const selectionNeedsOneWorkspace = $derived(
|
||||
mcpAccess === 'selected' && (mcpAllWorkspaces || mcpWorkspaces.length !== 1)
|
||||
)
|
||||
|
||||
$effect(() => {
|
||||
const requestedMcpMode = mcpOnly || openWithMcpMode
|
||||
@@ -288,19 +293,14 @@
|
||||
|
||||
{#snippet mcpTokenForm()}
|
||||
<div class="flex flex-col gap-3">
|
||||
{#if !lockWorkspace}
|
||||
{@render mcpWorkspacePicker()}
|
||||
{/if}
|
||||
<McpAccessPicker
|
||||
workspaceId={scopeWorkspaceId}
|
||||
bind:scopes={mcpScopes}
|
||||
bind:access={mcpAccess}
|
||||
bind:access={() => mcpAccess, setMcpAccess}
|
||||
/>
|
||||
{#if !lockWorkspace}
|
||||
{@render mcpWorkspacePicker()}
|
||||
{#if selectionNeedsOneWorkspace}
|
||||
<p class="text-2xs text-secondary">
|
||||
Selected scripts and flows come from one workspace: pick one.
|
||||
</p>
|
||||
{/if}
|
||||
{/if}
|
||||
{#if !mcpOnly}
|
||||
<div>
|
||||
<span class="block mb-1 text-emphasis text-xs font-semibold"
|
||||
@@ -326,7 +326,7 @@
|
||||
<div class="flex">
|
||||
<Button
|
||||
onclick={() => createToken(true)}
|
||||
disabled={!mcpReachesWorkspaces || selectionNeedsOneWorkspace || mcpScopes.length === 0}
|
||||
disabled={!mcpReachesWorkspaces || mcpScopes.length === 0}
|
||||
variant="default"
|
||||
unifiedSize="sm"
|
||||
>
|
||||
@@ -338,24 +338,33 @@
|
||||
|
||||
{#snippet mcpWorkspacePicker()}
|
||||
<div class="flex flex-col gap-1">
|
||||
<span class="block text-emphasis text-xs font-semibold">Workspaces</span>
|
||||
<Toggle
|
||||
bind:checked={mcpAllWorkspaces}
|
||||
options={{ right: 'All my workspaces, including ones I join later' }}
|
||||
size="xs"
|
||||
/>
|
||||
{#if !mcpAllWorkspaces}
|
||||
<MultiSelect
|
||||
bind:value={mcpWorkspaces}
|
||||
{#if mcpAccess === 'selected'}
|
||||
<span class="block text-emphasis text-xs font-semibold">Workspace</span>
|
||||
<Select
|
||||
bind:value={() => mcpWorkspaces[0], (v) => (mcpWorkspaces = v ? [v] : [])}
|
||||
items={workspaces.map((w) => ({ label: w.name, value: w.id }))}
|
||||
placeholder="Pick workspaces"
|
||||
reorderable={false}
|
||||
placeholder="Pick a workspace"
|
||||
/>
|
||||
{/if}
|
||||
{#if mcpAllWorkspaces || mcpWorkspaces.length > 1}
|
||||
<p class="text-xs text-tertiary">
|
||||
Tools take a <code>workspace_id</code> argument naming the workspace they act in.
|
||||
</p>
|
||||
{:else}
|
||||
<span class="block text-emphasis text-xs font-semibold">Workspaces</span>
|
||||
<Toggle
|
||||
bind:checked={mcpAllWorkspaces}
|
||||
options={{ right: 'All my workspaces, including ones I join later' }}
|
||||
size="xs"
|
||||
/>
|
||||
{#if !mcpAllWorkspaces}
|
||||
<MultiSelect
|
||||
bind:value={mcpWorkspaces}
|
||||
items={workspaces.map((w) => ({ label: w.name, value: w.id }))}
|
||||
placeholder="Pick workspaces"
|
||||
reorderable={false}
|
||||
/>
|
||||
{/if}
|
||||
{#if mcpAllWorkspaces || mcpWorkspaces.length > 1}
|
||||
<p class="text-xs text-tertiary">
|
||||
Tools take a <code>workspace_id</code> argument naming the workspace they act in.
|
||||
</p>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
{/snippet}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import CenteredModal from '$lib/components/CenteredModal.svelte'
|
||||
import { Button } from '$lib/components/common'
|
||||
import MultiSelect from '$lib/components/select/MultiSelect.svelte'
|
||||
import Select from '$lib/components/select/Select.svelte'
|
||||
import Toggle from '$lib/components/Toggle.svelte'
|
||||
import McpAccessPicker, { type McpAccess } from '$lib/components/mcp/McpAccessPicker.svelte'
|
||||
import { WorkspaceService } from '$lib/gen'
|
||||
@@ -61,10 +62,14 @@
|
||||
let allWorkspaces = $state(false)
|
||||
let loadingWorkspaces = $state(false)
|
||||
const grantsWorkspace = $derived(!isGateway || allWorkspaces || pickedWorkspaces.length > 0)
|
||||
// Selected scripts and flows are listed per workspace: across several, a path could be two.
|
||||
const selectionNeedsOneWorkspace = $derived(
|
||||
isGateway && access === 'selected' && (allWorkspaces || pickedWorkspaces.length !== 1)
|
||||
)
|
||||
// Selected scripts and flows are listed per workspace, so a selection keeps one of them.
|
||||
function setAccess(next: McpAccess | undefined) {
|
||||
access = next
|
||||
if (next === 'selected') {
|
||||
allWorkspaces = false
|
||||
pickedWorkspaces = pickedWorkspaces.slice(0, 1)
|
||||
}
|
||||
}
|
||||
// The workspace the scope picker browses scripts and flows in.
|
||||
const scopeWorkspaceId = $derived(
|
||||
isGateway ? (pickedWorkspaces[0] ?? (allWorkspaces ? workspaces[0]?.value : '')) : workspaceId
|
||||
@@ -209,9 +214,19 @@
|
||||
|
||||
{#if isGateway}
|
||||
<div class="mb-6 flex flex-col gap-2">
|
||||
<p class="text-xs font-semibold text-emphasis">Workspaces it may work in:</p>
|
||||
<p class="text-xs font-semibold text-emphasis">
|
||||
{access === 'selected'
|
||||
? 'Workspace of its scripts and flows:'
|
||||
: 'Workspaces it may work in:'}
|
||||
</p>
|
||||
{#if loadingWorkspaces}
|
||||
<p class="text-xs text-secondary">Loading workspaces...</p>
|
||||
{:else if access === 'selected'}
|
||||
<Select
|
||||
items={workspaces}
|
||||
bind:value={() => pickedWorkspaces[0], (v) => (pickedWorkspaces = v ? [v] : [])}
|
||||
placeholder="Choose a workspace"
|
||||
/>
|
||||
{:else}
|
||||
<Toggle
|
||||
bind:checked={allWorkspaces}
|
||||
@@ -239,13 +254,8 @@
|
||||
workspaceId={scopeWorkspaceId ?? ''}
|
||||
initialScopes={requestedScopes}
|
||||
bind:scopes
|
||||
bind:access
|
||||
bind:access={() => access, setAccess}
|
||||
/>
|
||||
{#if selectionNeedsOneWorkspace}
|
||||
<p class="text-2xs text-secondary">
|
||||
Selected scripts and flows come from one workspace: pick one.
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="flex flex-row justify-around gap-x-4">
|
||||
@@ -253,10 +263,7 @@
|
||||
<Button
|
||||
variant="accent"
|
||||
size="lg"
|
||||
disabled={loading ||
|
||||
!grantsWorkspace ||
|
||||
selectionNeedsOneWorkspace ||
|
||||
scopes.length === 0}
|
||||
disabled={loading || !grantsWorkspace || scopes.length === 0}
|
||||
{loading}
|
||||
onClick={onApprove}>Approve</Button
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user