mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-28 08:06:16 +00:00
Merge remote-tracking branch 'origin/main' into unify-ai-session-home-chatbox
This commit is contained in:
@@ -239,7 +239,7 @@ jobs:
|
||||
${{ steps.extract-ee.outputs.destination }}/*
|
||||
${{ steps.extract-duckdb-ffi-internal.outputs.destination }}/*
|
||||
|
||||
attach_ee_debug_to_release:
|
||||
upload_ee_debug_to_s3:
|
||||
needs: [build_ee]
|
||||
runs-on: ubicloud
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
||||
@@ -284,14 +284,21 @@ jobs:
|
||||
WM_BUILD_VERSION=${{ github.sha }}
|
||||
outputs: type=local,dest=./debuginfo
|
||||
|
||||
- name: Rename debug file with corresponding architecture
|
||||
# The debug file names every EE function with its source file and line, so it
|
||||
# goes to a private bucket, never to the public release.
|
||||
- name: Upload debug file to private bucket
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
AWS_DEFAULT_REGION: us-east-1
|
||||
TAG: ${{ github.ref_name }}
|
||||
ARCH: ${{ matrix.arch }}
|
||||
run: |
|
||||
mv ./debuginfo/windmill.debug ./debuginfo/windmill-ee-${{ matrix.arch }}.debug
|
||||
|
||||
- name: Attach debug file to release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: ./debuginfo/windmill-ee-${{ matrix.arch }}.debug
|
||||
aws --version
|
||||
aws configure set default.s3.multipart_chunksize 64MB
|
||||
aws s3 cp ./debuginfo/windmill.debug \
|
||||
"s3://windmill-ee-debuginfo/$TAG/windmill-ee-$ARCH.debug" \
|
||||
--storage-class GLACIER_IR --only-show-errors
|
||||
|
||||
# attach_arm64_binary_to_release:
|
||||
# needs: [build, build_ee]
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
".": "1.835.0"
|
||||
".": "1.837.0"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,43 @@
|
||||
# Changelog
|
||||
|
||||
## [1.837.0](https://github.com/windmill-labs/windmill/compare/v1.836.0...v1.837.0) (2026-10-15)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* agents run on behalf of their deployer ([#11430](https://github.com/windmill-labs/windmill/issues/11430)) ([0b98054](https://github.com/windmill-labs/windmill/commit/0b980546b104cf46f385133af553dfbe5f533eca))
|
||||
|
||||
## [1.836.0](https://github.com/windmill-labs/windmill/compare/v1.835.0...v1.836.0) (2026-10-15)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **cli:** sync an app's custom path as a workspace-specific file ([#11786](https://github.com/windmill-labs/windmill/issues/11786)) ([718aad7](https://github.com/windmill-labs/windmill/commit/718aad7396397fe12295a27a947c76221f37ad10))
|
||||
* let operators save resource and variable drafts ([#11736](https://github.com/windmill-labs/windmill/issues/11736)) ([8c0185d](https://github.com/windmill-labs/windmill/commit/8c0185d55a1a8c6fbc5e41b8b9d77865563f515b))
|
||||
* let raw app backend runnables import each other ([#11777](https://github.com/windmill-labs/windmill/issues/11777)) ([526da60](https://github.com/windmill-labs/windmill/commit/526da60da92832cc6e9c2942cea1f7729b3a05fd))
|
||||
* let the session agent read folder and group permissions ([#11796](https://github.com/windmill-labs/windmill/issues/11796)) ([eda43dd](https://github.com/windmill-labs/windmill/commit/eda43ddc41c10b3f7263103016275926a33bf768))
|
||||
* resolve canceled jobs and re-run them in limited batches ([#11797](https://github.com/windmill-labs/windmill/issues/11797)) ([f827ba0](https://github.com/windmill-labs/windmill/commit/f827ba05667e3ca5bcd3bc89dac7f51b85dd32b3))
|
||||
* run duckdb jobs out of process under job isolation, drop the engine fork, bump to 1.5.6 ([#11780](https://github.com/windmill-labs/windmill/issues/11780)) ([f9513e8](https://github.com/windmill-labs/windmill/commit/f9513e82eed3721ecbfd87004d1cd385ac740903))
|
||||
* run previews as the runnable's on_behalf_of identity ([#11778](https://github.com/windmill-labs/windmill/issues/11778)) ([4f71231](https://github.com/windmill-labs/windmill/commit/4f712318c3b52366b03bf7f941ecae4730fbf967))
|
||||
* sandbox new low-code and raw apps by default ([#11760](https://github.com/windmill-labs/windmill/issues/11760)) ([813c080](https://github.com/windmill-labs/windmill/commit/813c080d4684eecd144ef82706b04339c8f8d35a))
|
||||
* share AI sessions read-only by link, optionally public ([#11799](https://github.com/windmill-labs/windmill/issues/11799)) ([a9aa2b8](https://github.com/windmill-labs/windmill/commit/a9aa2b8229da0d54ed68eb40e4426e6983ff631e))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **cli:** include script modules in wmill dev previews ([#11787](https://github.com/windmill-labs/windmill/issues/11787)) ([b563f5c](https://github.com/windmill-labs/windmill/commit/b563f5cb5121c431f525c2e0266994c6d655185b))
|
||||
* let raw app SDK tokens read the viewer's identity without a toggle ([#11790](https://github.com/windmill-labs/windmill/issues/11790)) ([7da2344](https://github.com/windmill-labs/windmill/commit/7da234481333fcbdc348215589e2d3bfe5394b4a))
|
||||
* let Teams handlers post with job tokens again ([#11792](https://github.com/windmill-labs/windmill/issues/11792)) ([64e1630](https://github.com/windmill-labs/windmill/commit/64e1630d497af1b50a772aa66ef123f675ea6bb1))
|
||||
* relock apps in place so imported script changes reach them ([#11789](https://github.com/windmill-labs/windmill/issues/11789)) ([aca7fed](https://github.com/windmill-labs/windmill/commit/aca7fed33ddffa17b0e78d50a39ded032f6d8ba2))
|
||||
* relock scripts and flow steps whose code changed on deploy ([#11794](https://github.com/windmill-labs/windmill/issues/11794)) ([1f1df12](https://github.com/windmill-labs/windmill/commit/1f1df1254ebc417a8344801b571c4be8e98636c4))
|
||||
* send Azure Foundry gpt-5.5+ models to the Responses API ([#11788](https://github.com/windmill-labs/windmill/issues/11788)) ([ab89835](https://github.com/windmill-labs/windmill/commit/ab8983543b0641c96a8b4a2cbd829cc4040e9f41))
|
||||
* show the app's summary in the app viewer's page header ([#11782](https://github.com/windmill-labs/windmill/issues/11782)) ([3bee9c9](https://github.com/windmill-labs/windmill/commit/3bee9c94012474b7bb230d719fa34df0c0a6c25e))
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* drive schedule already-exists check from an indexed queue lookup ([#11783](https://github.com/windmill-labs/windmill/issues/11783)) ([7eee210](https://github.com/windmill-labs/windmill/commit/7eee210d761d332f8165b4f8a6f0ee6f1ec8864f))
|
||||
|
||||
## [1.835.0](https://github.com/windmill-labs/windmill/compare/v1.834.0...v1.835.0) (2026-10-14)
|
||||
|
||||
|
||||
|
||||
@@ -3230,3 +3230,56 @@
|
||||
- *refusal
|
||||
- - admin
|
||||
skipJudge: true
|
||||
|
||||
# An agent from the Agents page is an `ai_agent` resource. Asked about one by name, the model
|
||||
# has to read it as a resource rather than look for a flow or script of that name.
|
||||
- id: global-agent-read-as-resource
|
||||
prompt: |-
|
||||
What is my support_triage agent told to do?
|
||||
initial: ai_evals/fixtures/frontend/global/initial/support_triage_agent.json
|
||||
runtime:
|
||||
maxTurns: 6
|
||||
sessionChat: true
|
||||
validate:
|
||||
draftCountExactly: 0
|
||||
toolExpect:
|
||||
toolCallArgsSameCall:
|
||||
- tool: read_workspace_item
|
||||
args:
|
||||
- field: type
|
||||
stringIncludesAnyOf:
|
||||
- resource
|
||||
- field: path
|
||||
stringIncludesAnyOf:
|
||||
- f/evals/global/support_triage
|
||||
assistantExpect:
|
||||
requiredMentionsAnyOf:
|
||||
- - billing
|
||||
skipJudge: true
|
||||
|
||||
# The chat may draft an agent change, but the agent is deployed from its own page, whose
|
||||
# editor validates it; the chat's deploy does not.
|
||||
- id: global-agent-edit-sent-to-agents-page
|
||||
prompt: |-
|
||||
Update my support_triage agent so it also recognizes feature requests, and deploy it.
|
||||
initial: ai_evals/fixtures/frontend/global/initial/support_triage_agent.json
|
||||
runtime:
|
||||
maxTurns: 6
|
||||
sessionChat: true
|
||||
validate:
|
||||
draftCountExactly: 1
|
||||
requiredDrafts:
|
||||
- type: resource
|
||||
path: f/evals/global/support_triage
|
||||
valueIncludes:
|
||||
- ai_agent
|
||||
- feature
|
||||
toolExpect:
|
||||
forbiddenToolsUsed:
|
||||
- deploy_workspace_item
|
||||
assistantExpect:
|
||||
requiredMentionsAnyOf:
|
||||
- - /agents/edit
|
||||
- Agents page
|
||||
- agent editor
|
||||
skipJudge: true
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"workspace": {
|
||||
"resources": [
|
||||
{
|
||||
"path": "f/evals/global/support_triage",
|
||||
"resource_type": "ai_agent",
|
||||
"description": "Triages incoming support tickets",
|
||||
"value": {
|
||||
"provider": { "kind": "anthropic", "model": "claude-sonnet-5", "resource": "" },
|
||||
"output_type": "text",
|
||||
"system_prompt": "Classify each ticket as billing, bug or question, then reply with the label only.",
|
||||
"memory": { "kind": "off" },
|
||||
"tools": []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT l.id IS NOT NULL as \"has_lite!\",\n coalesce(jsonb_path_exists(l.value, '$.**.inlineScript.id ? (@ == $id)',\n jsonb_build_object('id', $3::bigint)), false) as \"is_deployed_row!\"\n FROM app a\n LEFT JOIN app_version_lite l ON l.id = a.versions[array_upper(a.versions, 1)]\n WHERE a.path = $1 AND a.workspace_id = $2",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "has_lite!",
|
||||
"type_info": "Bool"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "is_deployed_row!",
|
||||
"type_info": "Bool"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Text",
|
||||
"Int8"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
null,
|
||||
null
|
||||
]
|
||||
},
|
||||
"hash": "0d0156a21dd4bf64ad74ed6a44cbdd22c18a5f748497824d41b1b6eae975b091"
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO job_resolution (job_id, workspace_id, resolved_by, note, automatic)\n SELECT c.id, c.workspace_id, $4, COALESCE($5, $7), false\n FROM v2_job_completed c\n JOIN v2_job j ON j.id = c.id\n WHERE c.id = ANY($1)\n AND c.workspace_id = $2\n AND ($3::TEXT[] IS NULL OR j.tag = ANY($3))\n AND c.status = 'failure'\n -- Resolution is a top-level triage state: a step resolved on its own\n -- would render orange inside a flow whose status is still red.\n AND j.flow_step_id IS NULL\n -- A supersession claim has to be proven, not trusted: a later success of the\n -- same identified runnable, itself visible to the caller. An unproven claim\n -- resolves nothing, so the caller learns it was rejected instead of having\n -- the fiction recorded as provenance.\n AND ($6::UUID IS NULL OR EXISTS (\n SELECT 1 FROM v2_job_completed sc\n JOIN v2_job sj ON sj.id = sc.id\n WHERE sc.id = $6\n AND sc.workspace_id = $2\n -- Tag scope is a read restriction enforced outside RLS, so it has\n -- to bind the evidence as well: otherwise the result reveals\n -- whether an out-of-scope run succeeded.\n AND ($3::TEXT[] IS NULL OR sj.tag = ANY($3))\n AND sc.status = 'success'\n AND sc.completed_at >= c.completed_at\n AND (j.runnable_id IS NOT NULL OR j.runnable_path IS NOT NULL)\n AND sj.runnable_id IS NOT DISTINCT FROM j.runnable_id\n AND sj.runnable_path IS NOT DISTINCT FROM j.runnable_path\n ))\n ON CONFLICT (job_id) DO UPDATE SET\n resolved_at = now(),\n -- Both COALESCEd: `resolution_attribution` returns NULLs outside EE and once the\n -- licence lapses, and bulk selections routinely include already-resolved rows,\n -- so overwriting would erase metadata recorded while it was valid. Clear either\n -- by unresolving first.\n resolved_by = COALESCE($4, job_resolution.resolved_by),\n -- A person's explanation replaces what was there; machine provenance only fills\n -- a blank, so re-running an already-explained failure never erases their words.\n note = COALESCE($5, job_resolution.note, $7),\n -- A human taking over an automatic resolution makes it no longer automatic.\n automatic = false\n RETURNING job_id",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "job_id",
|
||||
"type_info": "Uuid"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"UuidArray",
|
||||
"Text",
|
||||
"TextArray",
|
||||
"Varchar",
|
||||
"Text",
|
||||
"Uuid",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "13d8e65ffd3ef6bcfb963525fc3ec0859463b1c153950f894a830a4b5ec33fcc"
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT resource_type, value AS \"value: sqlx::types::Json<Box<RawValue>>\"\n FROM resource WHERE workspace_id = $1 AND path = $2",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "resource_type",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "value: sqlx::types::Json<Box<RawValue>>",
|
||||
"type_info": "Jsonb"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "15f53f40a49b538ca0d4456f69b8d801e8c121f1e0cd904a77ce55bcf9bc5053"
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO resource (workspace_id, path, value, description, resource_type, extra_perms, edited_at, created_by)\n SELECT $2, path, value, description, resource_type, extra_perms, edited_at, created_by\n FROM resource\n WHERE workspace_id = $1",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Varchar"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "748b63f877498d6d279fdf23894611e11c7a05d69b4b7907f8909aec82fb1eb2"
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE ai_shared_session SET is_public = $4\n WHERE workspace_id = $1 AND id = $2 AND email = $3\n RETURNING id, name, is_public, message_count, created_by, shared_at",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": "Uuid"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "name",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "is_public",
|
||||
"type_info": "Bool"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "message_count",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"name": "created_by",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 5,
|
||||
"name": "shared_at",
|
||||
"type_info": "Timestamptz"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Uuid",
|
||||
"Text",
|
||||
"Bool"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "7cc9d80bc4c77c996521a7c82ca42162e96499987b17a34bde7bc32d54e6260e"
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO ai_shared_session\n (workspace_id, session_id, email, created_by, name, is_public, message_count, snapshot)\n VALUES ($1, $2, $3, $4, $5, COALESCE($6, false), $7, $8)\n ON CONFLICT (workspace_id, email, session_id) DO UPDATE\n SET created_by = EXCLUDED.created_by,\n name = EXCLUDED.name,\n is_public = COALESCE($6, ai_shared_session.is_public),\n message_count = EXCLUDED.message_count,\n snapshot = EXCLUDED.snapshot,\n shared_at = now()\n RETURNING id, is_public, shared_at, (xmax = 0) AS \"inserted!\"",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": "Uuid"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "is_public",
|
||||
"type_info": "Bool"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "shared_at",
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "inserted!",
|
||||
"type_info": "Bool"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Varchar",
|
||||
"Varchar",
|
||||
"Varchar",
|
||||
"Varchar",
|
||||
"Bool",
|
||||
"Int4",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
null
|
||||
]
|
||||
},
|
||||
"hash": "8c35d87481de9eb1496d47e78660a57fd10fc5b32f4e68ab7a217d85264623b6"
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO resource (workspace_id, path, value, description, resource_type, extra_perms, edited_at, created_by)\n SELECT $2, path,\n CASE WHEN $3::text IS NOT NULL AND resource_type = 'ai_agent'\n AND jsonb_typeof(value) = 'object' AND value ? 'on_behalf_of'\n THEN jsonb_set(value, '{on_behalf_of}', to_jsonb($3::text))\n ELSE value END,\n description, resource_type, extra_perms, edited_at, created_by\n FROM resource\n WHERE workspace_id = $1",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Varchar",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "bf763c3ae4951537033d18ce48d3eb83d5c19e32aef199bf161e8ba8d1adf176"
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT id, name, is_public, message_count, created_by, shared_at FROM ai_shared_session\n WHERE workspace_id = $1 AND email = $2 AND session_id = $3",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": "Uuid"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "name",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "is_public",
|
||||
"type_info": "Bool"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "message_count",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"name": "created_by",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 5,
|
||||
"name": "shared_at",
|
||||
"type_info": "Timestamptz"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Text",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "c8e3e103645e0428d4b784f200595309a55635083a541745552c397a36ac08c4"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "DELETE FROM ai_shared_session\n WHERE workspace_id = $1 AND id = $2 AND (email = $3 OR $4::bool)\n RETURNING name",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "name",
|
||||
"type_info": "Varchar"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Uuid",
|
||||
"Text",
|
||||
"Bool"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "cb421ceb68ab798bde4192a8da9a133ea859f243f518197cde803ef0c86eab33"
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO job_resolution (job_id, workspace_id, resolved_by, note, automatic)\n SELECT c.id, c.workspace_id, $4, $5, false\n FROM v2_job_completed c\n JOIN v2_job j ON j.id = c.id\n WHERE c.id = $1\n AND c.workspace_id = $2\n AND ($3::TEXT[] IS NULL OR j.tag = ANY($3))\n AND c.status IN ('failure', 'canceled')\n AND j.flow_step_id IS NULL\n ON CONFLICT (job_id) DO NOTHING\n RETURNING job_id",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "job_id",
|
||||
"type_info": "Uuid"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid",
|
||||
"Text",
|
||||
"TextArray",
|
||||
"Varchar",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "dbd821d6d58aff9ed34cf3f14982ffe92d3cd13915be8a07f9364a14a01e549f"
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO job_resolution (job_id, workspace_id, resolved_by, note, automatic)\n SELECT c.id, c.workspace_id, $4, COALESCE($5, $7), false\n FROM v2_job_completed c\n JOIN v2_job j ON j.id = c.id\n WHERE c.id = ANY($1)\n AND c.workspace_id = $2\n AND ($3::TEXT[] IS NULL OR j.tag = ANY($3))\n AND c.status IN ('failure', 'canceled')\n -- Resolution is a top-level triage state: a step resolved on its own\n -- would render orange inside a flow whose status is still red.\n AND j.flow_step_id IS NULL\n -- A supersession claim has to be proven, not trusted: a later success of the\n -- same identified runnable, itself visible to the caller. An unproven claim\n -- resolves nothing, so the caller learns it was rejected instead of having\n -- the fiction recorded as provenance.\n AND ($6::UUID IS NULL OR EXISTS (\n SELECT 1 FROM v2_job_completed sc\n JOIN v2_job sj ON sj.id = sc.id\n WHERE sc.id = $6\n AND sc.workspace_id = $2\n -- Tag scope is a read restriction enforced outside RLS, so it has\n -- to bind the evidence as well: otherwise the result reveals\n -- whether an out-of-scope run succeeded.\n AND ($3::TEXT[] IS NULL OR sj.tag = ANY($3))\n AND sc.status = 'success'\n AND sc.completed_at >= c.completed_at\n AND (j.runnable_id IS NOT NULL OR j.runnable_path IS NOT NULL)\n AND sj.runnable_id IS NOT DISTINCT FROM j.runnable_id\n AND sj.runnable_path IS NOT DISTINCT FROM j.runnable_path\n ))\n ON CONFLICT (job_id) DO UPDATE SET\n resolved_at = now(),\n -- Both COALESCEd: `resolution_attribution` returns NULLs outside EE and once the\n -- licence lapses, and bulk selections routinely include already-resolved rows,\n -- so overwriting would erase metadata recorded while it was valid. Clear either\n -- by unresolving first.\n resolved_by = COALESCE($4, job_resolution.resolved_by),\n -- A person's explanation replaces what was there; machine provenance only fills\n -- a blank, so re-running an already-explained failure never erases their words.\n note = COALESCE($5, job_resolution.note, $7),\n -- A human taking over an automatic resolution makes it no longer automatic.\n automatic = false\n RETURNING job_id",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "job_id",
|
||||
"type_info": "Uuid"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"UuidArray",
|
||||
"Text",
|
||||
"TextArray",
|
||||
"Varchar",
|
||||
"Text",
|
||||
"Uuid",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "e4bb7af19003baca7f4d88e954b603843edce422c522c035b81b88cb169b88b1"
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT l.id IS NOT NULL as \"has_lite!\",\n CASE WHEN $3::bigint IS NULL THEN NOT EXISTS (\n SELECT 1 FROM app_script s\n WHERE s.app = a.id AND s.code_sha256 = $4::text\n AND jsonb_path_exists(l.value, '$.**.inlineScript.id ? (@ == $id)',\n jsonb_build_object('id', s.id)))\n ELSE coalesce(jsonb_path_exists(l.value, '$.**.inlineScript.id ? (@ == $id)',\n jsonb_build_object('id', $3::bigint)), false)\n END as \"may_run!\"\n FROM app a\n LEFT JOIN app_version_lite l ON l.id = a.versions[array_upper(a.versions, 1)]\n WHERE a.path = $1 AND a.workspace_id = $2",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "has_lite!",
|
||||
"type_info": "Bool"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "may_run!",
|
||||
"type_info": "Bool"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Text",
|
||||
"Int8",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
null,
|
||||
null
|
||||
]
|
||||
},
|
||||
"hash": "eafb6d792370bf4d42cb79d0264e2eaf32f8f756920bd9fe9b302cba8e7d8814"
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT id, email, name, is_public, message_count, created_by, snapshot, shared_at\n FROM ai_shared_session\n WHERE workspace_id = $1 AND id = $2",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": "Uuid"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "email",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "name",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "is_public",
|
||||
"type_info": "Bool"
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"name": "message_count",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 5,
|
||||
"name": "created_by",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 6,
|
||||
"name": "snapshot",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 7,
|
||||
"name": "shared_at",
|
||||
"type_info": "Timestamptz"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Uuid"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "edce6243bcdfbb6380ae2b6d8a63a863c3f265ea043cc653f9732bb87860b8d9"
|
||||
}
|
||||
Generated
+91
-90
@@ -2571,9 +2571,9 @@ checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
|
||||
|
||||
[[package]]
|
||||
name = "combine"
|
||||
version = "4.6.8"
|
||||
version = "4.6.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfc320937d09e6de266b31b9afb480f197d7a861be86be7cb2ea7e5d1bfffc5e"
|
||||
checksum = "4356eba6976435498d05a311ee9fc486da3bc81c200d3f0d7dd9703b41913f92"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"memchr",
|
||||
@@ -3926,9 +3926,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "defmt"
|
||||
version = "1.1.1"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2953bfe4f93bbd20cc71198842756f77d161884c99ebbabc41d80231ded88d1"
|
||||
checksum = "e4a0795ac740cb54d7b3775c9c17345f6aaecf884c01733b39d6017738e0e3e1"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"defmt-macros",
|
||||
@@ -3936,21 +3936,21 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "defmt-macros"
|
||||
version = "1.1.1"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bad9c72e7ca2137e0dc3813245a0d282fd6daad32fd800af018306a9169b5fe8"
|
||||
checksum = "840bb056bd99c495c9188198a258ab787c79f306d864db3e6e8451442d6d8366"
|
||||
dependencies = [
|
||||
"defmt-parser",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "defmt-parser"
|
||||
version = "1.0.0"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10d60334b3b2e7c9d91ef8150abfb6fa4c1c39ebbcf4a81c2e346aad939fee3e"
|
||||
checksum = "71958f69fb2de856c5dd51ac9377e986ca1aa5919f931bf5395a807277f889a0"
|
||||
dependencies = [
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
@@ -5554,9 +5554,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "frostem"
|
||||
version = "1.20260821.7"
|
||||
version = "1.20260821.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28c70238056ad1dbfdf035222a571d2e9baf5b6a4c308cfa87bc8cbe7f2f3840"
|
||||
checksum = "9e2488a10218a17366ce6bd38b6d081b4387a9548d350029db9feddc9bb44d6d"
|
||||
|
||||
[[package]]
|
||||
name = "fs4"
|
||||
@@ -15486,7 +15486,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-nats",
|
||||
@@ -15576,7 +15576,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-ai"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"async-stream",
|
||||
"async-trait",
|
||||
@@ -15611,7 +15611,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-alerting"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"chrono",
|
||||
@@ -15624,7 +15624,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"argon2",
|
||||
@@ -15767,7 +15767,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api-agent-workers"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"chrono",
|
||||
@@ -15790,7 +15790,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api-assets"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"chrono",
|
||||
@@ -15807,7 +15807,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api-auth"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"axum",
|
||||
@@ -15833,7 +15833,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api-client"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"reqwest 0.12.28",
|
||||
"serde",
|
||||
@@ -15843,7 +15843,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api-configs"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"chrono",
|
||||
@@ -15860,7 +15860,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api-debug"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"base64 0.22.1",
|
||||
@@ -15882,7 +15882,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api-embeddings"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"axum",
|
||||
@@ -15905,7 +15905,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api-flow-conversations"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"chrono",
|
||||
@@ -15921,7 +15921,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api-flows"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"chrono",
|
||||
@@ -15943,7 +15943,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api-groups"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"chrono",
|
||||
@@ -15965,7 +15965,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api-inputs"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"chrono",
|
||||
@@ -15979,7 +15979,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api-integration-tests"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-nats",
|
||||
@@ -16015,7 +16015,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api-jobs"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"axum",
|
||||
@@ -16041,7 +16041,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api-npm-proxy"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"chrono",
|
||||
@@ -16069,7 +16069,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api-openapi"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"axum",
|
||||
@@ -16091,7 +16091,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api-schedule"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"chrono",
|
||||
@@ -16111,7 +16111,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api-scripts"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"axum",
|
||||
@@ -16153,13 +16153,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api-settings"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"axum",
|
||||
"base64 0.22.1",
|
||||
"bytes",
|
||||
"chrono",
|
||||
"ed25519-dalek",
|
||||
"futures",
|
||||
"lazy_static",
|
||||
"regex",
|
||||
@@ -16182,7 +16183,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api-sse"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"serde",
|
||||
@@ -16194,7 +16195,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api-users"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"argon2",
|
||||
"axum",
|
||||
@@ -16218,7 +16219,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api-workers"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"chrono",
|
||||
@@ -16232,7 +16233,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-api-workspaces"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"chrono",
|
||||
@@ -16271,7 +16272,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-audit"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"lazy_static",
|
||||
@@ -16286,7 +16287,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-autoscaling"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"axum",
|
||||
@@ -16305,7 +16306,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-common"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"aes-gcm",
|
||||
"aho-corasick",
|
||||
@@ -16421,7 +16422,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-dep-map"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"futures",
|
||||
@@ -16441,7 +16442,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-git-sync"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"regex",
|
||||
"serde",
|
||||
@@ -16458,7 +16459,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-indexer"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"astral-tokio-tar",
|
||||
@@ -16485,7 +16486,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-jseval"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"futures",
|
||||
@@ -16502,7 +16503,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-macros"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"itertools 0.14.0",
|
||||
"lazy_static",
|
||||
@@ -16518,7 +16519,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-mcp"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@@ -16540,7 +16541,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-native-triggers"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@@ -16571,7 +16572,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-oauth"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"arc-swap",
|
||||
@@ -16596,7 +16597,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-object-store"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-stream",
|
||||
@@ -16632,7 +16633,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-operator"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"futures",
|
||||
@@ -16651,7 +16652,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"convert_case 0.6.0",
|
||||
"serde",
|
||||
@@ -16660,7 +16661,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-bash"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"lazy_static",
|
||||
@@ -16672,7 +16673,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-csharp"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"serde_json",
|
||||
@@ -16684,7 +16685,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-go"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"gosyn",
|
||||
@@ -16696,7 +16697,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-graphql"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"lazy_static",
|
||||
@@ -16708,7 +16709,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-java"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"serde_json",
|
||||
@@ -16720,7 +16721,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-nu"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"nu-parser",
|
||||
@@ -16731,7 +16732,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-php"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"itertools 0.14.0",
|
||||
@@ -16742,7 +16743,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-py"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"itertools 0.14.0",
|
||||
@@ -16754,7 +16755,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-py-asset"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"ruff_python_ast",
|
||||
@@ -16765,7 +16766,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-py-imports"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-recursion",
|
||||
@@ -16788,7 +16789,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-r"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"serde_json",
|
||||
@@ -16800,7 +16801,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-ruby"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"lazy_static",
|
||||
@@ -16814,7 +16815,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-rust"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"convert_case 0.6.0",
|
||||
@@ -16831,7 +16832,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-sql"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"lazy_static",
|
||||
@@ -16844,7 +16845,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-sql-asset"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"serde",
|
||||
@@ -16856,7 +16857,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-ts"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"lazy_static",
|
||||
@@ -16874,7 +16875,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-ts-asset"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"serde-wasm-bindgen",
|
||||
@@ -16890,7 +16891,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-wac"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"ruff_python_ast",
|
||||
@@ -16907,7 +16908,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-yaml"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"lazy_static",
|
||||
@@ -16921,7 +16922,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-queue"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-recursion",
|
||||
@@ -16960,7 +16961,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-runtime-nativets"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"const_format",
|
||||
@@ -16998,7 +16999,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-sql-datatype-parser-wasm"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"getrandom 0.3.4",
|
||||
"wasm-bindgen",
|
||||
@@ -17009,7 +17010,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-store"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-recursion",
|
||||
@@ -17044,7 +17045,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-test-utils"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@@ -17068,7 +17069,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-trigger"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@@ -17101,7 +17102,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-trigger-amqp"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@@ -17128,7 +17129,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-trigger-azure"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@@ -17161,7 +17162,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-trigger-email"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@@ -17181,7 +17182,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-trigger-gcp"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@@ -17215,7 +17216,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-trigger-http"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@@ -17252,7 +17253,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-trigger-kafka"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@@ -17275,7 +17276,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-trigger-mqtt"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@@ -17299,7 +17300,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-trigger-nats"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-nats",
|
||||
@@ -17323,7 +17324,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-trigger-postgres"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@@ -17358,7 +17359,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-trigger-sqs"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@@ -17386,7 +17387,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-trigger-websocket"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@@ -17411,7 +17412,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-types"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bitflags 2.13.2",
|
||||
@@ -17430,7 +17431,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-worker"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-once-cell",
|
||||
@@ -17548,7 +17549,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-worker-volumes"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures",
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "windmill"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
@@ -88,7 +88,7 @@ members = [
|
||||
exclude = ["./windmill-duckdb-ffi-internal", "./parsers/windmill-parser-wasm"]
|
||||
|
||||
[workspace.package]
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
authors = ["Ruben Fiszel <ruben@windmill.dev>"]
|
||||
edition = "2021"
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
3b6bd2b15d9bddb0bb8f1de08b30b897db0415b4
|
||||
664708fff04d4f9e0660bcae3edb307fb2c9481b
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
-- Nothing to undo: older versions ignore both keys, and clearing them would drop toggles set since.
|
||||
@@ -0,0 +1,19 @@
|
||||
-- An AI agent's `run_on_behalf_of` makes runs from its page take the identity in its
|
||||
-- `on_behalf_of`, which the server resolves on every write. Before this, both keys were ordinary
|
||||
-- JSON any writer of the agent could set, so a value written then could name someone else's
|
||||
-- identity unchecked: clear them, and every agent starts with the toggle off.
|
||||
UPDATE resource
|
||||
SET value = value - 'on_behalf_of' - 'run_on_behalf_of'
|
||||
WHERE resource_type = 'ai_agent'
|
||||
AND jsonb_typeof(value) = 'object'
|
||||
AND (value ? 'on_behalf_of' OR value ? 'run_on_behalf_of');
|
||||
|
||||
-- A deleted agent comes back from the trash as stored, so its copy there is cleared too.
|
||||
UPDATE trashbin
|
||||
SET item_data = jsonb_set(item_data, '{row,value}',
|
||||
(item_data->'row'->'value') - 'on_behalf_of' - 'run_on_behalf_of')
|
||||
WHERE item_kind = 'resource'
|
||||
AND item_data->'row'->>'resource_type' = 'ai_agent'
|
||||
AND jsonb_typeof(item_data->'row'->'value') = 'object'
|
||||
AND (item_data->'row'->'value' ? 'on_behalf_of'
|
||||
OR item_data->'row'->'value' ? 'run_on_behalf_of');
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS ai_shared_session;
|
||||
@@ -0,0 +1,30 @@
|
||||
-- A read-only snapshot of an AI session transcript that its author shared by link. Sessions
|
||||
-- otherwise live only in the author's browser; this row exists only while the share does.
|
||||
-- Non-public shares are readable by members of the workspace, public ones by anyone with the
|
||||
-- link, which is why `id` is a random UUID and never derived from the session.
|
||||
CREATE TABLE ai_shared_session (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
workspace_id VARCHAR(50) NOT NULL REFERENCES workspace(id) ON DELETE CASCADE,
|
||||
-- The browser-side session id. Unique per author so sharing the same session again
|
||||
-- moves its one link forward rather than minting a second one.
|
||||
session_id VARCHAR(255) NOT NULL,
|
||||
email VARCHAR(255) NOT NULL,
|
||||
created_by VARCHAR(255) NOT NULL,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
is_public BOOLEAN NOT NULL DEFAULT false,
|
||||
message_count INTEGER NOT NULL,
|
||||
-- JSON kept as text: jsonb refuses the \u0000 escape a transcript can carry.
|
||||
snapshot TEXT NOT NULL,
|
||||
shared_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
UNIQUE (workspace_id, email, session_id)
|
||||
);
|
||||
|
||||
GRANT ALL ON ai_shared_session TO windmill_admin;
|
||||
GRANT ALL ON ai_shared_session TO windmill_user;
|
||||
|
||||
-- The handlers go through the raw pool and scope every query to the workspace themselves.
|
||||
-- An admin-only policy is the backstop for a future query that reaches this table through
|
||||
-- UserDB.
|
||||
ALTER TABLE ai_shared_session ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
CREATE POLICY admin_policy ON ai_shared_session FOR ALL TO windmill_admin USING (true);
|
||||
+24
-24
@@ -6340,7 +6340,7 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windmill-common"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"aes-gcm",
|
||||
"aho-corasick",
|
||||
@@ -6430,7 +6430,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-macros"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -6442,7 +6442,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"convert_case",
|
||||
"serde",
|
||||
@@ -6451,7 +6451,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-bash"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"lazy_static",
|
||||
@@ -6463,7 +6463,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-csharp"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"serde_json",
|
||||
@@ -6475,7 +6475,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-go"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"gosyn",
|
||||
@@ -6487,7 +6487,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-graphql"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"lazy_static",
|
||||
@@ -6499,7 +6499,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-java"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"serde_json",
|
||||
@@ -6511,7 +6511,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-nu"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"nu-parser",
|
||||
@@ -6522,7 +6522,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-php"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"itertools 0.14.0",
|
||||
@@ -6533,7 +6533,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-py"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"itertools 0.14.0",
|
||||
@@ -6545,7 +6545,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-py-asset"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"ruff_python_ast",
|
||||
@@ -6556,7 +6556,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-py-imports"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-recursion",
|
||||
@@ -6579,7 +6579,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-r"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"serde_json",
|
||||
@@ -6591,7 +6591,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-ruby"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"lazy_static",
|
||||
@@ -6605,7 +6605,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-rust"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"convert_case",
|
||||
@@ -6622,7 +6622,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-sql"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"lazy_static",
|
||||
@@ -6635,7 +6635,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-sql-asset"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"serde",
|
||||
@@ -6647,7 +6647,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-ts"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"lazy_static",
|
||||
@@ -6665,7 +6665,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-ts-asset"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"serde-wasm-bindgen",
|
||||
@@ -6681,7 +6681,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-wac"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"ruff_python_ast",
|
||||
@@ -6698,7 +6698,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-wasm"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"getrandom 0.2.17",
|
||||
@@ -6730,7 +6730,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-parser-yaml"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"lazy_static",
|
||||
@@ -6744,7 +6744,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windmill-types"
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bitflags",
|
||||
|
||||
@@ -12,7 +12,7 @@ resolver = "2"
|
||||
members = ["."]
|
||||
|
||||
[workspace.package]
|
||||
version = "1.835.0"
|
||||
version = "1.837.0"
|
||||
edition = "2021"
|
||||
authors = ["Ruben Fiszel <ruben@windmill.dev>"]
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ ai_agent_memory: workspace_id(char), conversation_id(uuid), step_id(char), messa
|
||||
ai_free_token_daily_usage: day(date), cost_nanos(bigint), updated_at(ts)
|
||||
ai_free_token_usage: email(char), cost_nanos(bigint), updated_at(ts)
|
||||
ai_shared_artifact: id(uuid), workspace_id(char), artifact_id(char), email(char), created_by(char), name(char), kind(char), version(int), content(text), shared_at(ts)
|
||||
ai_shared_session: id(uuid), workspace_id(char), session_id(char), email(char), created_by(char), name(char), is_public(bool), message_count(int), snapshot(text), shared_at(ts)
|
||||
FK: (workspace_id) -> workspace(id)
|
||||
ai_token_usage: workspace_id(char), day(date), email(char), provider(char), model(char), session_id(char), input_tokens(bigint), cache_read_tokens(bigint), cache_write_tokens(bigint), output_tokens(bigint), reported_cost_nano_usd(bigint), requests(bigint), updated_at(ts)
|
||||
FK: (workspace_id) -> workspace(id)
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
//! Shared AI sessions: a private share is served only to members of its workspace, a public
|
||||
//! one to anyone holding the link, and only its author decides which it is.
|
||||
|
||||
use serde_json::{json, Value};
|
||||
use sqlx::{Pool, Postgres};
|
||||
use windmill_test_utils::*;
|
||||
|
||||
const ADMIN: &str = "Bearer SECRET_TOKEN";
|
||||
const MEMBER: &str = "Bearer SECRET_TOKEN_2";
|
||||
const OTHER_MEMBER: &str = "Bearer SECRET_TOKEN_3";
|
||||
const OUTSIDER: &str = "Bearer OUTSIDER_TOKEN";
|
||||
|
||||
#[sqlx::test(fixtures("base"))]
|
||||
async fn private_share_is_for_members_and_public_share_for_anyone(
|
||||
db: Pool<Postgres>,
|
||||
) -> anyhow::Result<()> {
|
||||
initialize_tracing().await;
|
||||
sqlx::raw_sql(
|
||||
"INSERT INTO password(email, password_hash, login_type, super_admin, verified, name)
|
||||
VALUES ('outsider@windmill.dev', 'not-a-real-hash', 'password', false, true, 'Outsider');
|
||||
INSERT INTO token(token_hash, token_prefix, token, email, label, super_admin)
|
||||
VALUES (encode(sha256('OUTSIDER_TOKEN'::bytea), 'hex'), 'OUTSIDER_T', 'OUTSIDER_TOKEN',
|
||||
'outsider@windmill.dev', 'outsider token', false);",
|
||||
)
|
||||
.execute(&db)
|
||||
.await?;
|
||||
let server = ApiServer::start(db.clone()).await?;
|
||||
let port = server.addr.port();
|
||||
let authed = format!("http://localhost:{port}/api/w/test-workspace/ai/shared_sessions");
|
||||
let get = |id: &str| {
|
||||
format!("http://localhost:{port}/api/w/test-workspace/ai_u/shared_sessions/get/{id}")
|
||||
};
|
||||
let client = reqwest::Client::new();
|
||||
|
||||
let resp = client
|
||||
.post(format!("{authed}/share"))
|
||||
.header("Authorization", MEMBER)
|
||||
.json(&json!({
|
||||
"session_id": "session-1",
|
||||
"name": "Debugging",
|
||||
"message_count": 1,
|
||||
"snapshot": { "messages": [{ "role": "user", "content": "hi" }], "artifacts": [] },
|
||||
}))
|
||||
.send()
|
||||
.await?;
|
||||
assert_eq!(resp.status(), 200, "{}", resp.text().await?);
|
||||
let share: Value = resp.json().await?;
|
||||
assert_eq!(share["is_public"], false, "a new share must start private");
|
||||
let id = share["id"].as_str().unwrap().to_string();
|
||||
|
||||
let status = |token: Option<&'static str>| {
|
||||
let mut req = client.get(get(&id));
|
||||
if let Some(token) = token {
|
||||
req = req.header("Authorization", token);
|
||||
}
|
||||
async move { anyhow::Ok(req.send().await?.status().as_u16()) }
|
||||
};
|
||||
|
||||
assert_eq!(status(Some(OTHER_MEMBER)).await?, 200);
|
||||
assert_eq!(
|
||||
status(None).await?,
|
||||
401,
|
||||
"a private share was served anonymously"
|
||||
);
|
||||
assert_eq!(
|
||||
status(Some(OUTSIDER)).await?,
|
||||
401,
|
||||
"a private share was served to a non-member"
|
||||
);
|
||||
|
||||
let resp = client
|
||||
.post(format!("{authed}/set_public/{id}"))
|
||||
.header("Authorization", OTHER_MEMBER)
|
||||
.json(&json!({ "is_public": true }))
|
||||
.send()
|
||||
.await?;
|
||||
assert_eq!(
|
||||
resp.status(),
|
||||
404,
|
||||
"a member who is not the author made the share public"
|
||||
);
|
||||
|
||||
let resp = client
|
||||
.post(format!("{authed}/set_public/{id}"))
|
||||
.header("Authorization", MEMBER)
|
||||
.json(&json!({ "is_public": true }))
|
||||
.send()
|
||||
.await?;
|
||||
assert_eq!(resp.status(), 200, "{}", resp.text().await?);
|
||||
|
||||
let resp = client.get(get(&id)).send().await?;
|
||||
assert_eq!(
|
||||
resp.status(),
|
||||
200,
|
||||
"a public share was not served anonymously"
|
||||
);
|
||||
let body: Value = resp.json().await?;
|
||||
assert_eq!(body["snapshot"]["messages"][0]["content"], "hi");
|
||||
assert_eq!(body["can_unshare"], false);
|
||||
|
||||
let delete = |token: &'static str| {
|
||||
client
|
||||
.delete(format!("{authed}/delete/{id}"))
|
||||
.header("Authorization", token)
|
||||
.send()
|
||||
};
|
||||
assert_eq!(
|
||||
delete(OTHER_MEMBER).await?.status(),
|
||||
404,
|
||||
"a member who is neither the author nor an admin took the share down"
|
||||
);
|
||||
assert_eq!(
|
||||
delete(ADMIN).await?.status(),
|
||||
200,
|
||||
"an admin could not take the share down"
|
||||
);
|
||||
assert_eq!(status(Some(OTHER_MEMBER)).await?, 404);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -289,7 +289,10 @@ async fn test_app_script_run_derives_path(db: Pool<Postgres>) -> anyhow::Result<
|
||||
.await?;
|
||||
let status = resp.status();
|
||||
let body = resp.text().await?;
|
||||
assert_eq!(status, 200, "deployed app script run must be accepted: {body}");
|
||||
assert_eq!(
|
||||
status, 200,
|
||||
"deployed app script run must be accepted: {body}"
|
||||
);
|
||||
let uuid = uuid::Uuid::parse_str(body.trim())?;
|
||||
let (_, _, _, _, runnable_path) = job_fields(&db, uuid).await?;
|
||||
assert_eq!(
|
||||
@@ -300,3 +303,103 @@ async fn test_app_script_run_derives_path(db: Pool<Postgres>) -> anyhow::Result<
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Once the deployed version has its lite value, a deployed row's code runs only through
|
||||
/// that row, while id-less SQL the frontend builds at runtime (database studio queries)
|
||||
/// still runs on its content pin.
|
||||
#[sqlx::test(fixtures("base"))]
|
||||
async fn test_run_mode_id_less_code_with_lite(db: Pool<Postgres>) -> anyhow::Result<()> {
|
||||
initialize_tracing().await;
|
||||
let server = ApiServer::start(db.clone()).await?;
|
||||
let port = server.addr.port();
|
||||
let ws = format!("http://localhost:{port}/api/w/test-workspace");
|
||||
|
||||
const RUNTIME_CONTENT: &str = "SELECT 1;\n";
|
||||
const DEPLOYED_CONTENT: &str = "SELECT 2;\n";
|
||||
let app_path = "u/test-user/lite_id_less";
|
||||
let resp = authed(client().post(format!("{ws}/apps/create")), "SECRET_TOKEN")
|
||||
.json(&json!({
|
||||
"path": app_path,
|
||||
"summary": "",
|
||||
"value": {},
|
||||
"policy": {
|
||||
"execution_mode": "viewer",
|
||||
"triggerables_v2": {
|
||||
format!("comp:{}", rawscript_pin(DEPLOYED_CONTENT)): { "static_inputs": {}, "one_of_inputs": {} },
|
||||
format!("comp:{}", rawscript_pin(RUNTIME_CONTENT)): { "static_inputs": {}, "one_of_inputs": {} }
|
||||
}
|
||||
}
|
||||
}))
|
||||
.send()
|
||||
.await?;
|
||||
assert_eq!(resp.status(), 201, "create app: {}", resp.text().await?);
|
||||
|
||||
let sha = rawscript_pin(DEPLOYED_CONTENT)
|
||||
.trim_start_matches("rawscript/")
|
||||
.to_string();
|
||||
let script_id: i64 = sqlx::query_scalar(
|
||||
"INSERT INTO app_script (app, hash, code, code_sha256)
|
||||
SELECT id, $2, $3, $2 FROM app WHERE path = $1 RETURNING id",
|
||||
)
|
||||
.bind(app_path)
|
||||
.bind(&sha)
|
||||
.bind(DEPLOYED_CONTENT)
|
||||
.fetch_one(&db)
|
||||
.await?;
|
||||
sqlx::query(
|
||||
"INSERT INTO app_version_lite (id, value)
|
||||
SELECT versions[array_upper(versions, 1)], $2 FROM app WHERE path = $1",
|
||||
)
|
||||
.bind(app_path)
|
||||
.bind(
|
||||
json!({ "grid": [{ "data": { "componentInput": { "runnable": {
|
||||
"inlineScript": { "id": script_id, "language": "postgresql" }
|
||||
} } } }] }),
|
||||
)
|
||||
.execute(&db)
|
||||
.await?;
|
||||
|
||||
let run = |content: &'static str, language: &'static str| {
|
||||
authed(
|
||||
client().post(format!("{ws}/apps_u/execute_component/{app_path}")),
|
||||
"SECRET_TOKEN_2",
|
||||
)
|
||||
.json(&json!({
|
||||
"args": {},
|
||||
"component": "comp",
|
||||
"raw_code": { "language": language, "content": content }
|
||||
}))
|
||||
.send()
|
||||
};
|
||||
|
||||
let resp = run(RUNTIME_CONTENT, "postgresql").await?;
|
||||
let status = resp.status();
|
||||
assert_eq!(
|
||||
status,
|
||||
200,
|
||||
"id-less runtime-built code must run: {}",
|
||||
resp.text().await?
|
||||
);
|
||||
|
||||
// The pin covers content only (it also pins frontend scripts), so a pinned content
|
||||
// must not run id-less in a language the database studio never emits.
|
||||
let resp = run(RUNTIME_CONTENT, "bash").await?;
|
||||
let status = resp.status();
|
||||
assert_eq!(
|
||||
status,
|
||||
401,
|
||||
"id-less code must not run as a non-SQL language: {}",
|
||||
resp.text().await?
|
||||
);
|
||||
|
||||
let resp = run(DEPLOYED_CONTENT, "postgresql").await?;
|
||||
let status = resp.status();
|
||||
assert_eq!(
|
||||
status,
|
||||
401,
|
||||
"a deployed row's code must not run id-less: {}",
|
||||
resp.text().await?
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -29,12 +29,21 @@ const FLOW_VERSION: i64 = 2222222222;
|
||||
/// Mark a queued job as completed with success — needed so it's eligible for
|
||||
/// `list_selected_job_groups` / `batch_rerun_jobs` (both join `v2_job_completed`).
|
||||
async fn complete_job(db: &Pool<Postgres>, job_id: Uuid) -> anyhow::Result<()> {
|
||||
complete_job_with_status(db, job_id, "success").await
|
||||
}
|
||||
|
||||
async fn complete_job_with_status(
|
||||
db: &Pool<Postgres>,
|
||||
job_id: Uuid,
|
||||
status: &str,
|
||||
) -> anyhow::Result<()> {
|
||||
sqlx::query(
|
||||
"INSERT INTO v2_job_completed (workspace_id, id, result, status, duration_ms, started_at, completed_at)
|
||||
VALUES ($1, $2, '{}'::jsonb, 'success', 0, now(), now())",
|
||||
VALUES ($1, $2, '{}'::jsonb, $3::job_status, 0, now(), now())",
|
||||
)
|
||||
.bind(WORKSPACE)
|
||||
.bind(job_id)
|
||||
.bind(status)
|
||||
.execute(db)
|
||||
.await?;
|
||||
Ok(())
|
||||
@@ -660,3 +669,56 @@ async fn batch_rerun_denies_invisible_source_job(db: Pool<Postgres>) -> anyhow::
|
||||
assert_eq!(pushed, 0);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Re-running a failed or canceled job resolves it, pointing at the re-run, which is what lets
|
||||
/// "hide resolved" exclude it from the next batch. A success has nothing to resolve.
|
||||
#[sqlx::test(fixtures("base", "batch_rerun"))]
|
||||
async fn batch_rerun_resolves_failed_and_canceled_sources(
|
||||
db: Pool<Postgres>,
|
||||
) -> anyhow::Result<()> {
|
||||
initialize_tracing().await;
|
||||
let server = ApiServer::start(db.clone()).await?;
|
||||
let client = windmill_api_client::create_client(
|
||||
&format!("http://localhost:{}", server.addr.port()),
|
||||
"SECRET_TOKEN".to_string(),
|
||||
);
|
||||
|
||||
let mut sources = vec![];
|
||||
for status in ["success", "failure", "canceled"] {
|
||||
let id = RunJob::from(script_payload())
|
||||
.arg("name".to_string(), json!(status))
|
||||
.push(&db)
|
||||
.await;
|
||||
complete_job_with_status(&db, id, status).await?;
|
||||
sources.push(id);
|
||||
}
|
||||
|
||||
let results = batch_rerun(
|
||||
&client,
|
||||
json!({
|
||||
"job_ids": sources,
|
||||
"script_options_by_path": {},
|
||||
"flow_options_by_path": {},
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
assert!(results.iter().all(|r| r.is_ok()), "{results:?}");
|
||||
|
||||
let resolved: Vec<(String, String)> = sqlx::query_as(
|
||||
"SELECT o.args->>'name', n.args->>'name'
|
||||
FROM job_resolution r
|
||||
JOIN v2_job o ON o.id = r.job_id
|
||||
JOIN v2_job n ON r.note = 'Re-run as ' || n.id
|
||||
ORDER BY 1",
|
||||
)
|
||||
.fetch_all(&db)
|
||||
.await?;
|
||||
assert_eq!(
|
||||
resolved,
|
||||
vec![
|
||||
("canceled".to_string(), "canceled".to_string()),
|
||||
("failure".to_string(), "failure".to_string()),
|
||||
]
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -16,9 +16,17 @@ const CONV: Uuid = Uuid::from_u128(0x5eed);
|
||||
/// Takes the conversation for a turn, as a run does, without keeping what it writes.
|
||||
async fn take_conversation(db: &Pool<Postgres>) -> windmill_common::error::Result<Uuid> {
|
||||
let mut tx = db.begin().await?;
|
||||
let result =
|
||||
get_or_create_conversation_with_id(&mut tx, WS, "f/flow", "test-user", "t", CONV, false)
|
||||
.await;
|
||||
let result = get_or_create_conversation_with_id(
|
||||
&mut tx,
|
||||
WS,
|
||||
"f/flow",
|
||||
"test-user",
|
||||
false,
|
||||
"t",
|
||||
CONV,
|
||||
false,
|
||||
)
|
||||
.await;
|
||||
tx.rollback().await?;
|
||||
result.map(|c| c.id)
|
||||
}
|
||||
|
||||
@@ -363,7 +363,8 @@ async fn test_deploy_without_the_field_keeps_the_restriction(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The OIDC `job_token_scopes` claim states the scopes of the token that asked for it.
|
||||
/// The OIDC `job_token_scopes` claim states the scopes of the token that asked for it, in a
|
||||
/// payload that strict JSON parsers accept (no duplicate `email` key).
|
||||
#[cfg(all(feature = "enterprise", feature = "private", feature = "openidconnect"))]
|
||||
#[sqlx::test(fixtures("base"))]
|
||||
async fn test_oidc_claim_carries_the_presented_scopes(db: Pool<Postgres>) -> anyhow::Result<()> {
|
||||
@@ -404,10 +405,12 @@ async fn test_oidc_claim_carries_the_presented_scopes(db: Pool<Postgres>) -> any
|
||||
let status = resp.status();
|
||||
let id_token = resp.text().await?;
|
||||
assert_eq!(status, StatusCode::OK, "{id_token}");
|
||||
let payload = id_token.split('.').nth(1).expect("a JWT payload");
|
||||
let claims: serde_json::Value = serde_json::from_slice(
|
||||
&base64::engine::general_purpose::URL_SAFE_NO_PAD.decode(payload)?,
|
||||
)?;
|
||||
let payload = base64::engine::general_purpose::URL_SAFE_NO_PAD
|
||||
.decode(id_token.split('.').nth(1).expect("a JWT payload"))?;
|
||||
// serde_json keeps the last of duplicate keys, so count them on the raw payload.
|
||||
let raw = String::from_utf8(payload.clone())?;
|
||||
assert_eq!(raw.matches("\"email\":").count(), 1, "{raw}");
|
||||
let claims: serde_json::Value = serde_json::from_slice(&payload)?;
|
||||
assert_eq!(claims["job_token_scopes"], expected, "{job}");
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ async fn seed(db: &Pool<Postgres>, url: &str) -> anyhow::Result<()> {
|
||||
let mc = windmill_common::variables::build_crypt(db, "test-workspace").await?;
|
||||
sqlx::query(
|
||||
"INSERT INTO variable (workspace_id, path, value, is_secret, description, extra_perms)
|
||||
VALUES ('test-workspace', 'u/test-user/mcp_header', $1, true, '', '{}')",
|
||||
VALUES ('test-workspace', 'u/test-user/header_secret', $1, true, '', '{}')",
|
||||
)
|
||||
.bind(windmill_common::variables::encrypt(&mc, SECRET_VALUE))
|
||||
.execute(db)
|
||||
@@ -27,7 +27,7 @@ async fn seed(db: &Pool<Postgres>, url: &str) -> anyhow::Result<()> {
|
||||
.bind(serde_json::json!({
|
||||
"name": "mcp",
|
||||
"url": url,
|
||||
"headers": { "X-Api-Key": "$var:u/test-user/mcp_header", "X-Plain": "plain" }
|
||||
"headers": { "X-Api-Key": "$var:u/test-user/header_secret", "X-Plain": "plain" }
|
||||
}))
|
||||
.execute(db)
|
||||
.await?;
|
||||
@@ -102,9 +102,45 @@ async fn test_mcp_header_var_ref_requires_variable_scope(db: Pool<Postgres>) ->
|
||||
let body = resp.text().await?;
|
||||
assert_eq!(status, reqwest::StatusCode::FORBIDDEN, "{body}");
|
||||
assert!(
|
||||
body.contains("variables:read:u/test-user/mcp_header"),
|
||||
body.contains("variables:read:u/test-user/header_secret"),
|
||||
"{body}"
|
||||
);
|
||||
|
||||
// The token is held to the same scope, and a wildcard resource scope covers both.
|
||||
sqlx::query(
|
||||
"UPDATE resource SET value = jsonb_build_object('name', 'mcp', 'url', value->>'url',
|
||||
'token', '$var:u/test-user/header_secret') WHERE path = 'u/test-user/mcp'",
|
||||
)
|
||||
.execute(&db)
|
||||
.await?;
|
||||
for (token, scope, denied) in [
|
||||
("EXACT_TOKEN", "resources:read:u/test-user/mcp", true),
|
||||
("WILDCARD_TOKEN", "resources:read:u/test-user/*", false),
|
||||
] {
|
||||
sqlx::query(
|
||||
"INSERT INTO token (token_hash, token_prefix, token, email, label, super_admin, scopes)
|
||||
VALUES (encode(sha256($1::bytea), 'hex'), left($1, 10), $1,
|
||||
'test@windmill.dev', 'scoped', false, ARRAY[$2])",
|
||||
)
|
||||
.bind(token)
|
||||
.bind(scope)
|
||||
.execute(&db)
|
||||
.await?;
|
||||
let resp = reqwest::Client::new()
|
||||
.get(format!(
|
||||
"http://localhost:{}/api/w/test-workspace/resources/mcp_tools/u/test-user/mcp",
|
||||
server.addr.port()
|
||||
))
|
||||
.bearer_auth(token)
|
||||
.send()
|
||||
.await?;
|
||||
let body = resp.text().await?;
|
||||
assert_eq!(
|
||||
body.contains("variables:read:u/test-user/header_secret"),
|
||||
denied,
|
||||
"{scope}: {body}"
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -325,6 +325,7 @@ async fn test_new_turns_wait_for_conversation_cleanup_and_recreate(
|
||||
WS,
|
||||
"f/flow",
|
||||
"test-user",
|
||||
false,
|
||||
"hi again",
|
||||
conv_id,
|
||||
false,
|
||||
|
||||
@@ -73,7 +73,12 @@ pub fn check_route_access(
|
||||
.to_string(),
|
||||
));
|
||||
}
|
||||
if required_domain == ScopeDomain::Users && suffix != "users/whoami" {
|
||||
if required_domain == ScopeDomain::Users {
|
||||
// Whoami returns what the bundle already has in `window.ctx`, so it
|
||||
// needs no declared scope.
|
||||
if suffix == "users/whoami" {
|
||||
return Ok(());
|
||||
}
|
||||
return Err(Error::PermissionDenied(
|
||||
"Access denied. A raw app frontend SDK token can only read the viewer's own identity."
|
||||
.to_string(),
|
||||
@@ -418,8 +423,9 @@ pub fn guest_session_scopes(app_path: &str) -> windmill_common::error::Result<Ve
|
||||
])
|
||||
}
|
||||
|
||||
/// Sentinel in raw-app SDK tokens. Grants nothing; `check_route_access` uses it
|
||||
/// to narrow the declared scopes to what the viewer's prompt promised.
|
||||
/// Sentinel in raw-app SDK tokens. `check_route_access` uses it to narrow the
|
||||
/// declared scopes to what the viewer's prompt promised; the only thing it grants
|
||||
/// is the bearer's own `users/whoami`.
|
||||
pub const RAW_APP_SDK_SENTINEL: &str = "raw_app_sdk";
|
||||
|
||||
pub fn has_raw_app_sdk_sentinel(scopes: Option<&[String]>) -> bool {
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
use serde_json::json;
|
||||
use sqlx::{Pool, Postgres};
|
||||
|
||||
use windmill_test_utils::*;
|
||||
|
||||
const AGENT: &str = "u/test-user-3/agent";
|
||||
|
||||
async fn post(
|
||||
base_url: &str,
|
||||
token: &str,
|
||||
route: &str,
|
||||
body: serde_json::Value,
|
||||
) -> anyhow::Result<(u16, String)> {
|
||||
let resp = reqwest::Client::new()
|
||||
.post(format!("{base_url}/w/test-workspace/{route}"))
|
||||
.header("Authorization", format!("Bearer {token}"))
|
||||
.json(&body)
|
||||
.send()
|
||||
.await?;
|
||||
Ok((resp.status().as_u16(), resp.text().await?))
|
||||
}
|
||||
|
||||
async fn agent_identity(db: &Pool<Postgres>) -> anyhow::Result<Option<String>> {
|
||||
Ok(sqlx::query_scalar::<_, Option<String>>(
|
||||
"SELECT value->>'on_behalf_of' FROM resource
|
||||
WHERE workspace_id = 'test-workspace' AND path = $1",
|
||||
)
|
||||
.bind(AGENT)
|
||||
.fetch_one(db)
|
||||
.await?)
|
||||
}
|
||||
|
||||
async fn job_identity(db: &Pool<Postgres>, id: &str) -> anyhow::Result<(String, String)> {
|
||||
Ok(
|
||||
sqlx::query_as("SELECT permissioned_as, created_by FROM v2_job WHERE id = $1::uuid")
|
||||
.bind(id)
|
||||
.fetch_one(db)
|
||||
.await?,
|
||||
)
|
||||
}
|
||||
|
||||
/// The identity an agent runs as is in its value, which anyone who can write the agent writes: it
|
||||
/// is kept only for an admin asking to keep it, and every other write makes it the writer's own,
|
||||
/// so a writer cannot change what runs while it keeps running as someone else. It exists only
|
||||
/// while the agent opts into running as it.
|
||||
#[sqlx::test(migrations = "../migrations", fixtures("base"))]
|
||||
async fn test_agent_write_resets_identity(db: Pool<Postgres>) -> anyhow::Result<()> {
|
||||
initialize_tracing().await;
|
||||
let server = ApiServer::start(db.clone()).await?;
|
||||
let base_url = format!("http://localhost:{}/api", server.addr.port());
|
||||
let value = json!({ "system_prompt": "hi", "on_behalf_of": "u/test-user-2",
|
||||
"run_on_behalf_of": true });
|
||||
|
||||
let (status, body) = post(
|
||||
&base_url,
|
||||
"SECRET_TOKEN",
|
||||
"resources/create",
|
||||
json!({ "path": AGENT, "resource_type": "ai_agent", "value": value,
|
||||
"preserve_on_behalf_of": true }),
|
||||
)
|
||||
.await?;
|
||||
assert!((200..300).contains(&status), "create: {status} {body}");
|
||||
assert_eq!(agent_identity(&db).await?.as_deref(), Some("u/test-user-2"));
|
||||
|
||||
// The agent's owner, not an admin, asking to keep it.
|
||||
let (status, body) = post(
|
||||
&base_url,
|
||||
"SECRET_TOKEN_3",
|
||||
&format!("resources/update/{AGENT}"),
|
||||
json!({ "value": value, "preserve_on_behalf_of": true }),
|
||||
)
|
||||
.await?;
|
||||
assert!((200..300).contains(&status), "update: {status} {body}");
|
||||
assert_eq!(agent_identity(&db).await?.as_deref(), Some("u/test-user-3"));
|
||||
|
||||
let mut off = value.clone();
|
||||
off["run_on_behalf_of"] = json!(false);
|
||||
let (status, body) = post(
|
||||
&base_url,
|
||||
"SECRET_TOKEN",
|
||||
&format!("resources/update/{AGENT}"),
|
||||
json!({ "value": off, "preserve_on_behalf_of": true }),
|
||||
)
|
||||
.await?;
|
||||
assert!((200..300).contains(&status), "toggle off: {status} {body}");
|
||||
assert_eq!(agent_identity(&db).await?, None);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Reading an agent is what allows running it. The run is the caller's unless the agent opts into
|
||||
/// running as its identity: then `test-user-2`, a plain member, runs as `test-user-3`.
|
||||
#[sqlx::test(migrations = "../migrations", fixtures("base"))]
|
||||
async fn test_agent_run_identity_and_needs_read(db: Pool<Postgres>) -> anyhow::Result<()> {
|
||||
initialize_tracing().await;
|
||||
let server = ApiServer::start(db.clone()).await?;
|
||||
let base_url = format!("http://localhost:{}/api", server.addr.port());
|
||||
|
||||
sqlx::query(
|
||||
"INSERT INTO resource (workspace_id, path, value, resource_type, extra_perms, created_by)
|
||||
VALUES ('test-workspace', $1, $2, 'ai_agent', '{}', 'test-user-3')",
|
||||
)
|
||||
.bind(AGENT)
|
||||
.bind(json!({ "system_prompt": "hi", "on_behalf_of": "u/test-user-3" }))
|
||||
.execute(&db)
|
||||
.await?;
|
||||
|
||||
let run = format!("jobs/run/agent/{AGENT}");
|
||||
let (status, body) = post(&base_url, "SECRET_TOKEN_2", &run, json!({})).await?;
|
||||
assert_eq!(status, 404, "an unreadable agent: {body}");
|
||||
|
||||
sqlx::query(
|
||||
"UPDATE resource SET extra_perms = '{\"u/test-user-2\": false}'
|
||||
WHERE workspace_id = 'test-workspace' AND path = $1",
|
||||
)
|
||||
.bind(AGENT)
|
||||
.execute(&db)
|
||||
.await?;
|
||||
let (status, body) = post(
|
||||
&base_url,
|
||||
"SECRET_TOKEN_2",
|
||||
&run,
|
||||
json!({ "user_message": "hi" }),
|
||||
)
|
||||
.await?;
|
||||
assert_eq!(status, 201, "a readable agent: {body}");
|
||||
assert_eq!(
|
||||
job_identity(&db, &body).await?,
|
||||
("u/test-user-2".into(), "test-user-2".into())
|
||||
);
|
||||
|
||||
sqlx::query(
|
||||
"UPDATE resource SET value = value || '{\"run_on_behalf_of\": true}'
|
||||
WHERE workspace_id = 'test-workspace' AND path = $1",
|
||||
)
|
||||
.bind(AGENT)
|
||||
.execute(&db)
|
||||
.await?;
|
||||
let (status, body) = post(
|
||||
&base_url,
|
||||
"SECRET_TOKEN_2",
|
||||
&run,
|
||||
json!({ "user_message": "hi" }),
|
||||
)
|
||||
.await?;
|
||||
assert_eq!(status, 201, "an agent run on behalf of: {body}");
|
||||
assert_eq!(
|
||||
job_identity(&db, &body).await?,
|
||||
("u/test-user-3".into(), "test-user-2".into())
|
||||
);
|
||||
|
||||
// The worker would resolve it with the identity's token, however the JSON spells the `$`.
|
||||
for raw in [
|
||||
r#"{"user_message":"$var:u/test-user-3/secret"}"#,
|
||||
r#"{"user_message":"\u0024var:u/test-user-3/secret"}"#,
|
||||
] {
|
||||
let resp = reqwest::Client::new()
|
||||
.post(format!("{base_url}/w/test-workspace/{run}"))
|
||||
.header("Authorization", "Bearer SECRET_TOKEN_2")
|
||||
.header("Content-Type", "application/json")
|
||||
.body(raw)
|
||||
.send()
|
||||
.await?;
|
||||
assert_eq!(resp.status().as_u16(), 400, "a reference in {raw}");
|
||||
}
|
||||
|
||||
// The run takes its conversation outside the caller's row policy, so a reader must not
|
||||
// continue another user's conversation; an admin still may, as the policy allows.
|
||||
let chat = format!("{run}?memory_id=7d3f6a52-1c4e-4b8a-9f2d-0e5c6b7a8d91");
|
||||
let msg = json!({ "user_message": "hi" });
|
||||
let (status, body) = post(&base_url, "SECRET_TOKEN_3", &chat, msg.clone()).await?;
|
||||
assert_eq!(status, 201, "the owner starts it: {body}");
|
||||
let (status, body) = post(&base_url, "SECRET_TOKEN_2", &chat, msg.clone()).await?;
|
||||
assert_eq!(status, 400, "another reader: {body}");
|
||||
assert!(body.contains("another user"), "{body}");
|
||||
let (status, body) = post(&base_url, "SECRET_TOKEN", &chat, msg).await?;
|
||||
assert_eq!(
|
||||
status, 409,
|
||||
"an admin passes ownership, held only by the running turn: {body}"
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The identity is a username inside the value, so renaming the user has to move it there too.
|
||||
#[sqlx::test(migrations = "../migrations", fixtures("base"))]
|
||||
async fn test_agent_identity_follows_user_rename(db: Pool<Postgres>) -> anyhow::Result<()> {
|
||||
initialize_tracing().await;
|
||||
let server = ApiServer::start(db.clone()).await?;
|
||||
let base_url = format!("http://localhost:{}/api", server.addr.port());
|
||||
|
||||
sqlx::query(
|
||||
"INSERT INTO resource (workspace_id, path, value, resource_type, created_by)
|
||||
VALUES ('test-workspace', $1, $2, 'ai_agent', 'test-user-3')",
|
||||
)
|
||||
.bind(AGENT)
|
||||
.bind(json!({ "run_on_behalf_of": true, "on_behalf_of": "u/test-user-2" }))
|
||||
.execute(&db)
|
||||
.await?;
|
||||
let email: String =
|
||||
sqlx::query_scalar("SELECT email FROM usr WHERE username = 'test-user-2' LIMIT 1")
|
||||
.fetch_one(&db)
|
||||
.await?;
|
||||
|
||||
let resp = reqwest::Client::new()
|
||||
.post(format!("{base_url}/users/rename/{email}"))
|
||||
.header("Authorization", "Bearer SECRET_TOKEN")
|
||||
.json(&json!({ "new_username": "renamed" }))
|
||||
.send()
|
||||
.await?;
|
||||
let status = resp.status().as_u16();
|
||||
assert_eq!(status, 200, "rename: {}", resp.text().await?);
|
||||
assert_eq!(agent_identity(&db).await?.as_deref(), Some("u/renamed"));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
use serde_json::json;
|
||||
use sqlx::{Pool, Postgres};
|
||||
|
||||
use windmill_test_utils::*;
|
||||
|
||||
const AGENT: &str = "u/test-user-3/agent";
|
||||
|
||||
async fn run(base_url: &str, token: &str) -> anyhow::Result<(u16, String)> {
|
||||
let resp = reqwest::Client::new()
|
||||
.post(format!(
|
||||
"{base_url}/w/test-workspace/jobs/run/agent/{AGENT}"
|
||||
))
|
||||
.header("Authorization", format!("Bearer {token}"))
|
||||
.json(&json!({ "user_message": "hi" }))
|
||||
.send()
|
||||
.await?;
|
||||
Ok((resp.status().as_u16(), resp.text().await?))
|
||||
}
|
||||
|
||||
/// Reading an agent is what allows running it, and the run is the caller's own: `test-user-2`, a
|
||||
/// plain member, runs `test-user-3`'s agent once it may read it, lending nobody's permissions.
|
||||
#[sqlx::test(migrations = "../migrations", fixtures("base"))]
|
||||
async fn test_agent_run_needs_read_and_runs_as_caller(db: Pool<Postgres>) -> anyhow::Result<()> {
|
||||
initialize_tracing().await;
|
||||
let server = ApiServer::start(db.clone()).await?;
|
||||
let base_url = format!("http://localhost:{}/api", server.addr.port());
|
||||
|
||||
sqlx::query(
|
||||
"INSERT INTO resource (workspace_id, path, value, resource_type, extra_perms, created_by)
|
||||
VALUES ('test-workspace', $1, $2, 'ai_agent', '{}', 'test-user-3')",
|
||||
)
|
||||
.bind(AGENT)
|
||||
.bind(json!({ "system_prompt": "hi" }))
|
||||
.execute(&db)
|
||||
.await?;
|
||||
|
||||
let (status, body) = run(&base_url, "SECRET_TOKEN_2").await?;
|
||||
assert_eq!(status, 404, "an unreadable agent: {body}");
|
||||
|
||||
sqlx::query(
|
||||
"UPDATE resource SET extra_perms = '{\"u/test-user-2\": false}'
|
||||
WHERE workspace_id = 'test-workspace' AND path = $1",
|
||||
)
|
||||
.bind(AGENT)
|
||||
.execute(&db)
|
||||
.await?;
|
||||
let (status, body) = run(&base_url, "SECRET_TOKEN_2").await?;
|
||||
assert_eq!(status, 201, "a readable agent: {body}");
|
||||
|
||||
let (permissioned_as, created_by) = sqlx::query_as::<_, (String, String)>(
|
||||
"SELECT permissioned_as, created_by FROM v2_job WHERE id = $1::uuid",
|
||||
)
|
||||
.bind(&body)
|
||||
.fetch_one(&db)
|
||||
.await?;
|
||||
assert_eq!(permissioned_as, "u/test-user-2");
|
||||
assert_eq!(created_by, "test-user-2");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -62,14 +62,31 @@ async fn fork_with_public_app(
|
||||
|
||||
/// An app policy's `on_behalf_of` is the identity anonymous and publisher executions queue jobs
|
||||
/// under, and the fork's endpoint outlives any revocation in the parent — so a creator who may
|
||||
/// not preserve someone else's identity must not receive one by forking. `test-user-2` is a
|
||||
/// plain member of the parent.
|
||||
/// not preserve someone else's identity must not receive one by forking. The same goes for the
|
||||
/// one an agent's value carries. `test-user-2` is a plain member of the parent.
|
||||
#[sqlx::test(migrations = "../migrations", fixtures("base"))]
|
||||
async fn test_fork_repoints_app_identity_for_unprivileged_creator(
|
||||
db: Pool<Postgres>,
|
||||
) -> anyhow::Result<()> {
|
||||
sqlx::query(
|
||||
"INSERT INTO resource (workspace_id, path, value, resource_type, extra_perms, created_by)
|
||||
VALUES ('test-workspace', 'u/test-user/agent', $1, 'ai_agent', '{}', 'test-user')",
|
||||
)
|
||||
.bind(json!({ "system_prompt": "hi", "on_behalf_of": "u/test-user" }))
|
||||
.execute(&db)
|
||||
.await?;
|
||||
let (policy, custom_path) = fork_with_public_app(&db, "SECRET_TOKEN_2").await?;
|
||||
|
||||
assert_eq!(
|
||||
sqlx::query_scalar::<_, String>(
|
||||
"SELECT value->>'on_behalf_of' FROM resource
|
||||
WHERE workspace_id = 'wm-fork-app' AND path = 'u/test-user/agent'"
|
||||
)
|
||||
.fetch_one(&db)
|
||||
.await?,
|
||||
"u/test-user-2"
|
||||
);
|
||||
|
||||
assert_eq!(policy["on_behalf_of"], json!("u/test-user-2"));
|
||||
assert_eq!(policy["on_behalf_of_email"], json!("test2@windmill.dev"));
|
||||
// `execution_mode` rides along untouched — see `clone_apps`.
|
||||
@@ -312,8 +329,9 @@ async fn test_fork_keeps_only_resolvable_on_behalf_of(db: Pool<Postgres>) -> any
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Apps, schedules, triggers and their drafts cannot drop an identity the way scripts and flows
|
||||
/// do, so one naming nobody in the fork goes to its creator while one that still resolves stays.
|
||||
/// Apps, agents, schedules, triggers and their drafts cannot drop an identity the way scripts and
|
||||
/// flows do, so one naming nobody in the fork goes to its creator while one that still resolves
|
||||
/// stays.
|
||||
/// Forked as an admin, whose app policies the clone otherwise keeps.
|
||||
#[sqlx::test(migrations = "../migrations", fixtures("base"))]
|
||||
async fn test_fork_repoints_unresolvable_identities(db: Pool<Postgres>) -> anyhow::Result<()> {
|
||||
@@ -367,6 +385,13 @@ async fn test_fork_repoints_unresolvable_identities(db: Pool<Postgres>) -> anyho
|
||||
))
|
||||
.execute(&db)
|
||||
.await?;
|
||||
sqlx::query(
|
||||
"INSERT INTO resource (workspace_id, path, value, resource_type, extra_perms, created_by)
|
||||
VALUES ('test-workspace', 'u/test-user/stranger', $1, 'ai_agent', '{}', 'test-user')",
|
||||
)
|
||||
.bind(json!({ "system_prompt": "hi", "on_behalf_of": "u/test-user-2" }))
|
||||
.execute(&db)
|
||||
.await?;
|
||||
sqlx::query(
|
||||
"INSERT INTO schedule (workspace_id, path, edited_by, schedule, script_path, email, permissioned_as, enabled)
|
||||
VALUES ('test-workspace', 'u/test-user/stranger', 'test-user', '0 0 * * * *', 'u/test-user/s', 'test2@windmill.dev', 'u/test-user-2', false)",
|
||||
@@ -424,6 +449,10 @@ async fn test_fork_repoints_unresolvable_identities(db: Pool<Postgres>) -> anyho
|
||||
text("SELECT value->>'permissioned_as' FROM draft WHERE workspace_id = 'wm-fork-repoint' AND typ = 'trigger_websocket'").await?,
|
||||
"u/test-user"
|
||||
);
|
||||
assert_eq!(
|
||||
text("SELECT value->>'on_behalf_of' FROM resource WHERE workspace_id = 'wm-fork-repoint' AND path = 'u/test-user/stranger'").await?,
|
||||
"u/test-user"
|
||||
);
|
||||
assert_eq!(
|
||||
text("SELECT permissioned_as || ' ' || email FROM schedule WHERE workspace_id = 'wm-fork-repoint'").await?,
|
||||
"u/test-user test@windmill.dev"
|
||||
|
||||
@@ -90,6 +90,25 @@ async fn test_offboard_to_user(db: Pool<Postgres>) -> anyhow::Result<()> {
|
||||
.execute(&db)
|
||||
.await?;
|
||||
|
||||
// An agent records who it runs as inside its value, on a path the user does not own.
|
||||
sqlx::query(
|
||||
"INSERT INTO resource (workspace_id, path, value, resource_type, created_by)
|
||||
VALUES ('test-workspace', 'f/shared/agent', $1, 'ai_agent', 'test-user')",
|
||||
)
|
||||
.bind(json!({ "run_on_behalf_of": true, "on_behalf_of": "u/test-user-2" }))
|
||||
.execute(&db)
|
||||
.await?;
|
||||
let preview: serde_json::Value =
|
||||
authed(client().get(ws_url(port, "offboard_preview/test-user-2")))
|
||||
.send()
|
||||
.await?
|
||||
.json()
|
||||
.await?;
|
||||
assert_eq!(
|
||||
preview["executing_on_behalf"]["resources"],
|
||||
json!(["f/shared/agent"])
|
||||
);
|
||||
|
||||
let resp = authed(client().post(ws_url(port, "offboard/test-user-2")))
|
||||
.json(&json!({
|
||||
"reassign_to": "u/test-user",
|
||||
@@ -100,6 +119,14 @@ async fn test_offboard_to_user(db: Pool<Postgres>) -> anyhow::Result<()> {
|
||||
.await?;
|
||||
assert_eq!(resp.status(), 200);
|
||||
|
||||
let agent_obo: Option<String> = sqlx::query_scalar(
|
||||
"SELECT value->>'on_behalf_of' FROM resource
|
||||
WHERE path = 'f/shared/agent' AND workspace_id = 'test-workspace'",
|
||||
)
|
||||
.fetch_one(&db)
|
||||
.await?;
|
||||
assert_eq!(agent_obo.as_deref(), Some("u/test-user"));
|
||||
|
||||
let body: serde_json::Value = resp.json().await?;
|
||||
assert!(body["conflicts"].as_array().map_or(true, |a| a.is_empty()));
|
||||
assert!(body["summary"].is_object());
|
||||
@@ -117,7 +144,10 @@ async fn test_offboard_to_user(db: Pool<Postgres>) -> anyhow::Result<()> {
|
||||
.fetch_one(&db)
|
||||
.await?;
|
||||
assert_eq!(
|
||||
(obo.on_behalf_of.as_deref(), obo.on_behalf_of_email.as_deref()),
|
||||
(
|
||||
obo.on_behalf_of.as_deref(),
|
||||
obo.on_behalf_of_email.as_deref()
|
||||
),
|
||||
(Some("u/test-user"), Some("test@windmill.dev")),
|
||||
"the reassignment moves the whole identity, not just the half this release reads"
|
||||
);
|
||||
|
||||
@@ -648,6 +648,15 @@ async fn test_interpolated_references_need_the_token_scopes(
|
||||
read_probe(json!({"v": "$var:u/test-user/secret"}), with_var.clone()).await;
|
||||
assert_eq!((status, body.as_str()), (200, r#"{"v":"CANARY"}"#));
|
||||
|
||||
// A wildcard resource pattern extends to the variables it matches, and only to those.
|
||||
let wildcard = mint(json!(["resources:read:u/test-user/*"])).await;
|
||||
let (status, body) =
|
||||
read_probe(json!({"v": "$var:u/test-user/secret"}), wildcard.clone()).await;
|
||||
assert_eq!((status, body.as_str()), (200, r#"{"v":"CANARY"}"#));
|
||||
let elsewhere = mint(json!(["resources:read:u/test-user/probe,f/other/*"])).await;
|
||||
let (status, body) = read_probe(json!({"v": "$var:u/test-user/secret"}), elsewhere).await;
|
||||
assert_eq!(status, 403, "{body}");
|
||||
|
||||
// The resource's own linked secrets (at its path, or `<path>_<field>`) are part of it.
|
||||
for (path, value) in [
|
||||
("u/test-user/probe", "LINKED"),
|
||||
|
||||
@@ -946,6 +946,7 @@ pub async fn handle_chat_conversation_messages(
|
||||
w_id,
|
||||
flow_path,
|
||||
&authed.username,
|
||||
authed.is_admin,
|
||||
&user_message,
|
||||
memory_id,
|
||||
is_test,
|
||||
|
||||
@@ -13,7 +13,7 @@ default = []
|
||||
enterprise = ["license"]
|
||||
private = ["windmill-common/private", "windmill-audit/private"]
|
||||
parquet = ["windmill-common/parquet", "windmill-object-store/parquet"]
|
||||
license = ["dep:rsa"]
|
||||
license = ["dep:rsa", "dep:ed25519-dalek"]
|
||||
|
||||
[dependencies]
|
||||
windmill-ai = { workspace = true, default-features = false }
|
||||
@@ -38,4 +38,5 @@ uuid.workspace = true
|
||||
base64.workspace = true
|
||||
sha2.workspace = true
|
||||
rsa = { workspace = true, optional = true }
|
||||
ed25519-dalek = { workspace = true, optional = true }
|
||||
windmill-object-store.workspace = true
|
||||
|
||||
@@ -2120,6 +2120,15 @@ async fn change_user_email(
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
|
||||
sqlx::query(
|
||||
"UPDATE resource SET value = jsonb_set(value, '{on_behalf_of}', to_jsonb($1::text))
|
||||
WHERE resource_type = 'ai_agent' AND value->>'on_behalf_of' = $2",
|
||||
)
|
||||
.bind(&new_principal)
|
||||
.bind(&old_principal)
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
|
||||
sqlx::query!(
|
||||
"UPDATE script SET on_behalf_of = $1 WHERE on_behalf_of = $2",
|
||||
&new_principal,
|
||||
|
||||
@@ -7130,7 +7130,7 @@ async fn clone_workspace_data(
|
||||
clone_resource_types(tx, source_workspace_id, target_workspace_id).await?;
|
||||
|
||||
// Clone resources
|
||||
clone_resources(tx, source_workspace_id, target_workspace_id).await?;
|
||||
clone_resources(tx, source_workspace_id, target_workspace_id, authed).await?;
|
||||
|
||||
// Clone variables (including external secret backend replication)
|
||||
clone_variables(tx, db, source_workspace_id, target_workspace_id).await?;
|
||||
@@ -7667,18 +7667,30 @@ async fn clone_resource_types(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// An agent's value carries the identity it runs as, re-pointed at the fork's creator when they
|
||||
/// may not preserve someone else's, as `clone_apps` does an app's policy. The rest is swept by
|
||||
/// `repoint_unresolvable_cloned_identities` once the fork's membership is final.
|
||||
async fn clone_resources(
|
||||
tx: &mut Transaction<'_, Postgres>,
|
||||
source_workspace_id: &str,
|
||||
target_workspace_id: &str,
|
||||
authed: &ApiAuthed,
|
||||
) -> Result<()> {
|
||||
let repoint = (!windmill_common::can_preserve_on_behalf_of(authed))
|
||||
.then(|| username_to_permissioned_as(&authed.username));
|
||||
sqlx::query!(
|
||||
"INSERT INTO resource (workspace_id, path, value, description, resource_type, extra_perms, edited_at, created_by)
|
||||
SELECT $2, path, value, description, resource_type, extra_perms, edited_at, created_by
|
||||
SELECT $2, path,
|
||||
CASE WHEN $3::text IS NOT NULL AND resource_type = 'ai_agent'
|
||||
AND jsonb_typeof(value) = 'object' AND value ? 'on_behalf_of'
|
||||
THEN jsonb_set(value, '{on_behalf_of}', to_jsonb($3::text))
|
||||
ELSE value END,
|
||||
description, resource_type, extra_perms, edited_at, created_by
|
||||
FROM resource
|
||||
WHERE workspace_id = $1",
|
||||
source_workspace_id,
|
||||
target_workspace_id,
|
||||
repoint,
|
||||
)
|
||||
.execute(&mut **tx)
|
||||
.await?;
|
||||
@@ -8165,6 +8177,18 @@ async fn repoint_unresolvable_cloned_identities(
|
||||
.await?;
|
||||
}
|
||||
|
||||
sqlx::query(&format!(
|
||||
"UPDATE resource SET value = jsonb_set(value, '{{on_behalf_of}}', to_jsonb($2::text))
|
||||
WHERE workspace_id = $1 AND resource_type = 'ai_agent'
|
||||
AND jsonb_typeof(value) = 'object' AND value ? 'on_behalf_of'
|
||||
AND NOT ({})",
|
||||
principal_resolves_sql("(value->>'on_behalf_of')")
|
||||
))
|
||||
.bind(target_workspace_id)
|
||||
.bind(&principal)
|
||||
.execute(&mut **tx)
|
||||
.await?;
|
||||
|
||||
// `email` is still written for workers that predate `permissioned_as`.
|
||||
sqlx::query(&format!(
|
||||
"UPDATE schedule SET permissioned_as = $2, email = $3
|
||||
@@ -13941,17 +13965,18 @@ async fn compare_two_flows(
|
||||
});
|
||||
}
|
||||
|
||||
/// The policy minus the identity pair. Deploying cannot converge a difference there — the
|
||||
/// target recomputes the identity from the deployer's own choice, which offers its current
|
||||
/// value, the deployer, or a typed-in one, never the source's — so listing an app for it
|
||||
/// alone leaves an entry no deploy can clear. `script` and `flow` compare no identity either.
|
||||
fn policy_without_identity(policy: &serde_json::Value) -> serde_json::Value {
|
||||
let mut policy = policy.clone();
|
||||
if let Some(obj) = policy.as_object_mut() {
|
||||
/// An app's policy or an agent's value minus the identity it carries. Deploying cannot converge
|
||||
/// a difference there — the target recomputes the identity from the deployer's own choice, which
|
||||
/// offers its current value, the deployer, or a typed-in one, never the source's — so listing an
|
||||
/// item for it alone leaves an entry no deploy can clear. `script` and `flow` compare no identity
|
||||
/// either.
|
||||
fn without_identity(value: &serde_json::Value) -> serde_json::Value {
|
||||
let mut value = value.clone();
|
||||
if let Some(obj) = value.as_object_mut() {
|
||||
obj.remove("on_behalf_of");
|
||||
obj.remove("on_behalf_of_email");
|
||||
}
|
||||
policy
|
||||
value
|
||||
}
|
||||
|
||||
async fn compare_two_apps(
|
||||
@@ -13994,7 +14019,7 @@ async fn compare_two_apps(
|
||||
// Check metadata and content differences
|
||||
if let (Some(source), Some(target)) = (&source_app, &target_app) {
|
||||
if source.summary != target.summary
|
||||
|| policy_without_identity(&source.policy) != policy_without_identity(&target.policy)
|
||||
|| without_identity(&source.policy) != without_identity(&target.policy)
|
||||
|| source.value != target.value
|
||||
|| source.raw_app != target.raw_app
|
||||
{
|
||||
@@ -14072,7 +14097,14 @@ async fn compare_two_resources(
|
||||
|
||||
// Check metadata differences
|
||||
if let (Some(source), Some(target)) = (&source_resource, &target_resource) {
|
||||
if source.value != target.value
|
||||
let agent = source.resource_type == "ai_agent" && target.resource_type == "ai_agent";
|
||||
let values_differ = if agent {
|
||||
source.value.as_ref().map(without_identity)
|
||||
!= target.value.as_ref().map(without_identity)
|
||||
} else {
|
||||
source.value != target.value
|
||||
};
|
||||
if values_differ
|
||||
|| source.description != target.description
|
||||
|| source.resource_type != target.resource_type
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
openapi: "3.0.3"
|
||||
|
||||
info:
|
||||
version: 1.835.0
|
||||
version: 1.837.0
|
||||
title: Windmill API
|
||||
|
||||
contact:
|
||||
@@ -14677,6 +14677,168 @@ paths:
|
||||
schema:
|
||||
type: string
|
||||
|
||||
/w/{workspace}/ai/shared_sessions/share:
|
||||
post:
|
||||
summary: share an AI session transcript by link
|
||||
description: >
|
||||
Stores a read-only snapshot of the session that members of the workspace can open by
|
||||
id, or anyone with the link once it is public. Sharing the same session again updates
|
||||
that snapshot and keeps its id.
|
||||
operationId: shareAiSession
|
||||
tags:
|
||||
- ai
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/WorkspaceId"
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
required:
|
||||
- session_id
|
||||
- name
|
||||
- message_count
|
||||
- snapshot
|
||||
properties:
|
||||
session_id:
|
||||
type: string
|
||||
description: the session's id in the author's browser
|
||||
name:
|
||||
type: string
|
||||
is_public:
|
||||
type: boolean
|
||||
description: left as it is on an existing share when absent; a new share starts private
|
||||
message_count:
|
||||
type: integer
|
||||
minimum: 0
|
||||
snapshot:
|
||||
type: object
|
||||
additionalProperties: true
|
||||
responses:
|
||||
"200":
|
||||
description: the shared snapshot
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/SharedAiSessionInfo"
|
||||
|
||||
/w/{workspace}/ai/shared_sessions/status:
|
||||
get:
|
||||
summary: get the calling user's share of one of their AI sessions
|
||||
operationId: getAiSessionShareStatus
|
||||
tags:
|
||||
- ai
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/WorkspaceId"
|
||||
- name: session_id
|
||||
in: query
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: the share, if any
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
share:
|
||||
$ref: "#/components/schemas/SharedAiSessionInfo"
|
||||
|
||||
/w/{workspace}/ai/shared_sessions/set_public/{id}:
|
||||
post:
|
||||
summary: make a shared AI session public, or reserve it to workspace members
|
||||
operationId: setAiSessionSharePublic
|
||||
tags:
|
||||
- ai
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/WorkspaceId"
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
format: uuid
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
required:
|
||||
- is_public
|
||||
properties:
|
||||
is_public:
|
||||
type: boolean
|
||||
responses:
|
||||
"200":
|
||||
description: the updated share
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/SharedAiSessionInfo"
|
||||
|
||||
/w/{workspace}/ai_u/shared_sessions/get/{id}:
|
||||
get:
|
||||
summary: get a shared AI session
|
||||
description: >
|
||||
A public share is served without authentication; any other one only to a member of
|
||||
the workspace.
|
||||
operationId: getSharedAiSession
|
||||
tags:
|
||||
- ai
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/WorkspaceId"
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
format: uuid
|
||||
responses:
|
||||
"200":
|
||||
description: the shared session
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/SharedAiSessionInfo"
|
||||
- type: object
|
||||
required:
|
||||
- snapshot
|
||||
- can_unshare
|
||||
properties:
|
||||
snapshot:
|
||||
type: object
|
||||
additionalProperties: true
|
||||
can_unshare:
|
||||
type: boolean
|
||||
description: whether the caller authored the share or is a workspace admin
|
||||
|
||||
/w/{workspace}/ai/shared_sessions/delete/{id}:
|
||||
delete:
|
||||
summary: stop sharing an AI session
|
||||
operationId: unshareAiSession
|
||||
tags:
|
||||
- ai
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/WorkspaceId"
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
format: uuid
|
||||
responses:
|
||||
"200":
|
||||
description: share deleted
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
|
||||
/w/{workspace}/apps/get_data/v/{secretWithExtension}:
|
||||
get:
|
||||
summary: get raw app data by
|
||||
@@ -16117,6 +16279,9 @@ paths:
|
||||
/w/{workspace}/jobs/run/batch_rerun_jobs:
|
||||
post:
|
||||
summary: re-run multiple jobs
|
||||
description: >-
|
||||
Re-runs each job and marks every failed or canceled original that was re-run as
|
||||
resolved, with the new job's id in its note. Operators re-run without resolving.
|
||||
operationId: batchReRunJobs
|
||||
tags:
|
||||
- job
|
||||
@@ -16618,8 +16783,9 @@ paths:
|
||||
summary: run a saved AI agent
|
||||
description: |
|
||||
Runs the `ai_agent` resource at `path` as stored, for any caller who can read it
|
||||
(operators included), as the caller, who needs access to the agent's AI resource and to
|
||||
whatever its tools use. With `memory_id`, the run is a turn
|
||||
(operators included). The run is the caller's, or the agent's `on_behalf_of` when its
|
||||
`run_on_behalf_of` is set; the caller's inputs may then not reference variables or
|
||||
resources. With `memory_id`, the run is a turn
|
||||
of the caller's conversation with the agent; without, a single run.
|
||||
operationId: runAgent
|
||||
tags:
|
||||
@@ -16878,6 +17044,7 @@ paths:
|
||||
- job
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/WorkspaceId"
|
||||
- $ref: "#/components/parameters/OrderDesc"
|
||||
- $ref: "#/components/parameters/CreatedBy"
|
||||
- $ref: "#/components/parameters/Label"
|
||||
- $ref: "#/components/parameters/Worker"
|
||||
@@ -16910,8 +17077,8 @@ paths:
|
||||
type: boolean
|
||||
- name: resolved
|
||||
description: >-
|
||||
filter on whether a failure has been marked as handled. true keeps only
|
||||
resolved failures, false hides them
|
||||
filter on whether a failed or canceled run has been marked as handled. true
|
||||
keeps only resolved runs, false hides them
|
||||
in: query
|
||||
schema:
|
||||
type: boolean
|
||||
@@ -17222,8 +17389,8 @@ paths:
|
||||
type: boolean
|
||||
- name: resolved
|
||||
description: >-
|
||||
filter on whether a failure has been marked as handled. true keeps only
|
||||
resolved failures, false hides them
|
||||
filter on whether a failed or canceled run has been marked as handled. true
|
||||
keeps only resolved runs, false hides them
|
||||
in: query
|
||||
schema:
|
||||
type: boolean
|
||||
@@ -17409,8 +17576,8 @@ paths:
|
||||
type: boolean
|
||||
- name: resolved
|
||||
description: >-
|
||||
filter on whether a failure has been marked as handled. true keeps only
|
||||
resolved failures, false hides them
|
||||
filter on whether a failed or canceled run has been marked as handled. true
|
||||
keeps only resolved runs, false hides them
|
||||
in: query
|
||||
schema:
|
||||
type: boolean
|
||||
@@ -18268,11 +18435,12 @@ paths:
|
||||
|
||||
/w/{workspace}/jobs/completed/resolve:
|
||||
post:
|
||||
summary: mark failed jobs as resolved
|
||||
summary: mark failed or canceled jobs as resolved
|
||||
description: >-
|
||||
Marks failed jobs as handled so triage surfaces stop showing them as failures.
|
||||
The job status itself is unchanged. Returns the ids actually resolved: ids that
|
||||
are not visible to the caller or did not fail are silently skipped.
|
||||
Marks failed or canceled jobs as handled so triage surfaces stop showing them as
|
||||
unhandled. The job status itself is unchanged. Returns the ids actually resolved: ids
|
||||
that are not visible to the caller or neither failed nor were canceled are silently
|
||||
skipped.
|
||||
operationId: resolveCompletedJobs
|
||||
tags:
|
||||
- job
|
||||
@@ -26130,8 +26298,8 @@ paths:
|
||||
type: boolean
|
||||
- name: resolved
|
||||
description: >-
|
||||
filter on whether a failure has been marked as handled. true keeps only
|
||||
resolved failures, false hides them
|
||||
filter on whether a failed or canceled run has been marked as handled. true
|
||||
keeps only resolved runs, false hides them
|
||||
in: query
|
||||
schema:
|
||||
type: boolean
|
||||
@@ -30251,6 +30419,31 @@ components:
|
||||
- shared_at
|
||||
- expires_at
|
||||
|
||||
SharedAiSessionInfo:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
format: uuid
|
||||
name:
|
||||
type: string
|
||||
is_public:
|
||||
type: boolean
|
||||
message_count:
|
||||
type: integer
|
||||
created_by:
|
||||
type: string
|
||||
shared_at:
|
||||
type: string
|
||||
format: date-time
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
- is_public
|
||||
- message_count
|
||||
- created_by
|
||||
- shared_at
|
||||
|
||||
InstanceAIProviderSummary:
|
||||
type: object
|
||||
properties:
|
||||
@@ -31052,7 +31245,7 @@ components:
|
||||
type: boolean
|
||||
resolved:
|
||||
type: boolean
|
||||
description: whether this failure has been marked as handled
|
||||
description: whether this failed or canceled run has been marked as handled
|
||||
resolved_by:
|
||||
type: string
|
||||
description: >-
|
||||
@@ -32494,6 +32687,9 @@ components:
|
||||
type: string
|
||||
ws_specific:
|
||||
type: boolean
|
||||
preserve_on_behalf_of:
|
||||
type: boolean
|
||||
description: ai_agent only. Keep the identity `value.on_behalf_of` names (`u/<username>`, `g/<group>`) rather than the caller's own. Honoured for admins and members of wm_deployers; otherwise every write of an agent sets it to the caller.
|
||||
required:
|
||||
- path
|
||||
- value
|
||||
@@ -32518,6 +32714,9 @@ components:
|
||||
type: string
|
||||
ws_specific:
|
||||
type: boolean
|
||||
preserve_on_behalf_of:
|
||||
type: boolean
|
||||
description: ai_agent only. Keep the identity `value.on_behalf_of` names (`u/<username>`, `g/<group>`) rather than the caller's own. Honoured for admins and members of wm_deployers; otherwise every write of an agent sets it to the caller.
|
||||
|
||||
Resource:
|
||||
type: object
|
||||
@@ -36871,7 +37070,8 @@ components:
|
||||
the app bundle so `windmill-client` calls run as the viewer. Must
|
||||
be a subset of the server's curated allowlist (jobs:run, jobs:read,
|
||||
users:read, resources:read, variables:read, flow_conversations:read,
|
||||
flow_conversations:write).
|
||||
flow_conversations:write). Every such token can call whoami without
|
||||
consent, whether `users:read` is declared or not.
|
||||
|
||||
ListableApp:
|
||||
type: object
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
//!
|
||||
//! The run is built here from the stored agent rather than sent by the client, which is what lets
|
||||
//! anyone who can read the agent run it, operators included, the way a deployed flow runs by path:
|
||||
//! a preview takes arbitrary code, this takes only the run's inputs. It runs as the caller, who
|
||||
//! needs access to the agent's AI resource and to whatever its tools use.
|
||||
//! a preview takes arbitrary code, this takes only the run's inputs. It runs as the caller, or as
|
||||
//! the agent's `on_behalf_of` when its `run_on_behalf_of` is set; the server resolves
|
||||
//! `on_behalf_of` on every write of the agent.
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
@@ -20,13 +21,16 @@ use windmill_common::{
|
||||
jobs::JobPayload,
|
||||
users::username_to_permissioned_as,
|
||||
utils::{not_found_if_none, StripPath},
|
||||
variables::arg_needs_interpolation,
|
||||
};
|
||||
use windmill_queue::{push, PushArgs, PushIsolationLevel};
|
||||
|
||||
use crate::ai_evals::run::config_to_draft;
|
||||
use crate::ai_evals::subject::AgentDraft;
|
||||
use crate::db::{ApiAuthed, DB};
|
||||
use crate::jobs::{handle_chat_conversation_messages, set_flow_memory_id, RunJobQuery};
|
||||
use crate::jobs::{
|
||||
handle_chat_conversation_messages, run_end_user_email, set_flow_memory_id, RunJobQuery,
|
||||
};
|
||||
|
||||
/// The id the agent's step carries in the run, as the editor's chat names it. A token scoped to
|
||||
/// `jobs:run:agents:<path>` reads its runs back by it (`require_job_within_read_scope`).
|
||||
@@ -59,11 +63,20 @@ pub(crate) async fn run_agent(
|
||||
.fetch_optional(&mut *tx)
|
||||
.await?;
|
||||
tx.commit().await?;
|
||||
let Some(sqlx::types::Json(value)) = not_found_if_none(value, "Agent", path)? else {
|
||||
let Some(sqlx::types::Json(mut value)) = not_found_if_none(value, "Agent", path)? else {
|
||||
return Err(Error::BadRequest(format!(
|
||||
"Agent {path} has no configuration"
|
||||
)));
|
||||
};
|
||||
// Who the agent runs as, not one of its inputs: its identity when it opts in, as a deployed
|
||||
// flow does.
|
||||
let obj = value.as_object_mut();
|
||||
let (agent_obo, run_obo) = obj
|
||||
.map(|o| (o.remove("on_behalf_of"), o.remove("run_on_behalf_of")))
|
||||
.unwrap_or_default();
|
||||
let agent_obo = agent_obo
|
||||
.filter(|_| run_obo.and_then(|v| v.as_bool()).unwrap_or(false))
|
||||
.and_then(|v| v.as_str().map(str::to_string));
|
||||
let config = config_to_draft(value)?;
|
||||
|
||||
// A chat turn is filed where the agent's chat lists its conversations, which a flow cannot
|
||||
@@ -83,11 +96,47 @@ pub(crate) async fn run_agent(
|
||||
&["memory_id", "previous_messages"],
|
||||
)?;
|
||||
|
||||
let push_authed = authed.clone().into();
|
||||
let on_behalf_of =
|
||||
windmill_common::on_behalf_of_from_permissioned_as(agent_obo.as_deref(), &w_id, &db)
|
||||
.await?;
|
||||
// As `run_flow` picks the identity of a deployed flow: the agent's own when it has one, the
|
||||
// caller's otherwise, which lends nobody's permissions.
|
||||
let (email, permissioned_as, push_authed, isolation) = if let Some(obo) = on_behalf_of.as_ref()
|
||||
{
|
||||
(
|
||||
&obo.email,
|
||||
obo.permissioned_as.clone(),
|
||||
None,
|
||||
PushIsolationLevel::IsolatedRoot(db.clone()),
|
||||
)
|
||||
} else {
|
||||
(
|
||||
&authed.email,
|
||||
username_to_permissioned_as(&authed.username),
|
||||
Some(authed.clone().into()),
|
||||
PushIsolationLevel::Isolated(user_db.clone(), authed.clone().into()),
|
||||
)
|
||||
};
|
||||
if let Some(obo) = on_behalf_of.as_ref() {
|
||||
// The worker would interpolate such an input with the job's token, which is the
|
||||
// identity's. Checked on the decoded value: the raw JSON can spell `$` as `\u0024`.
|
||||
if args.values().any(|v| {
|
||||
serde_json::from_str::<serde_json::Value>(v.get())
|
||||
.is_ok_and(|v| arg_needs_interpolation(&v.to_string()))
|
||||
}) {
|
||||
return Err(Error::BadRequest(format!(
|
||||
"Agent {path} runs on behalf of {}, so its inputs cannot reference variables or resources",
|
||||
obo.permissioned_as
|
||||
)));
|
||||
}
|
||||
#[cfg(all(feature = "parquet", feature = "private"))]
|
||||
check_attachments_readable(&db, &authed, &w_id, &args).await?;
|
||||
}
|
||||
let scope_ceiling = windmill_api_auth::caller_scope_ceiling(&db, &authed).await?;
|
||||
let end_user_email = run_end_user_email(&db, &w_id, &authed, None).await?;
|
||||
let (uuid, mut tx) = push(
|
||||
&db,
|
||||
PushIsolationLevel::Isolated(user_db.clone(), authed.clone().into()),
|
||||
isolation,
|
||||
&w_id,
|
||||
JobPayload::RawFlow {
|
||||
value: flow_value,
|
||||
@@ -96,8 +145,8 @@ pub(crate) async fn run_agent(
|
||||
},
|
||||
PushArgs::from(&args),
|
||||
authed.display_username(),
|
||||
&authed.email,
|
||||
username_to_permissioned_as(&authed.username),
|
||||
email,
|
||||
permissioned_as,
|
||||
authed.token_prefix.as_deref(),
|
||||
authed.username_override.as_deref(),
|
||||
None,
|
||||
@@ -114,9 +163,9 @@ pub(crate) async fn run_agent(
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Some(&push_authed),
|
||||
push_authed.as_ref(),
|
||||
false,
|
||||
None,
|
||||
end_user_email,
|
||||
authed.trigger_or_fallback(None),
|
||||
None,
|
||||
scope_ceiling.as_deref(),
|
||||
@@ -127,7 +176,8 @@ pub(crate) async fn run_agent(
|
||||
set_flow_memory_id(&mut tx, uuid, memory_id).await?;
|
||||
}
|
||||
if chat {
|
||||
// A real conversation, not a test one: this is the agent as deployed, not a draft.
|
||||
// The caller's conversation, whoever the agent runs as, and a real one: this is the
|
||||
// agent as deployed, not a draft under test.
|
||||
handle_chat_conversation_messages(
|
||||
&mut tx,
|
||||
&authed,
|
||||
@@ -146,6 +196,50 @@ pub(crate) async fn run_agent(
|
||||
Ok((StatusCode::CREATED, uuid.to_string()))
|
||||
}
|
||||
|
||||
/// The step fetches the message's files with its job's token, so a run as the agent's identity
|
||||
/// would read any file that identity can: a caller attaches only what they could download
|
||||
/// themselves, checked as `sign_s3_objects` checks a key before signing it.
|
||||
#[cfg(all(feature = "parquet", feature = "private"))]
|
||||
async fn check_attachments_readable(
|
||||
db: &DB,
|
||||
authed: &ApiAuthed,
|
||||
w_id: &str,
|
||||
args: &HashMap<String, Box<RawValue>>,
|
||||
) -> Result<()> {
|
||||
use crate::job_helpers_oss::{
|
||||
get_large_file_storage, get_workspace_s3_resource_and_check_paths,
|
||||
};
|
||||
use windmill_common::db::DbWithOptAuthed;
|
||||
use windmill_types::s3::{S3Object, S3Permission};
|
||||
|
||||
let Some(raw) = args.get("user_attachments") else {
|
||||
return Ok(());
|
||||
};
|
||||
let attachments: Option<Vec<S3Object>> = serde_json::from_str(raw.get())
|
||||
.map_err(|e| Error::BadRequest(format!("invalid user_attachments: {e}")))?;
|
||||
for attachment in attachments.iter().flatten().filter(|a| !a.s3.is_empty()) {
|
||||
// The path check is skipped, not failed, when the storage does not resolve.
|
||||
if get_large_file_storage(db, w_id, attachment.storage.clone())
|
||||
.await?
|
||||
.is_none()
|
||||
{
|
||||
return Err(windmill_object_store::workspace_storage_not_found(
|
||||
attachment.storage.as_deref(),
|
||||
));
|
||||
}
|
||||
get_workspace_s3_resource_and_check_paths(
|
||||
&DbWithOptAuthed::from_authed(authed, db.clone(), None),
|
||||
Some(authed),
|
||||
w_id,
|
||||
attachment.storage.clone(),
|
||||
&[(&attachment.s3, S3Permission::READ)],
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The agent as a one-step flow, validated by deserializing through `FlowValue` rather than
|
||||
/// trusted as raw JSON. Its own transforms are the step's, minus `without`, and the run's inputs
|
||||
/// supply the message and the attachments over the top. Always inlined, never a link to the
|
||||
|
||||
@@ -713,6 +713,10 @@ pub fn workspaced_service() -> Router {
|
||||
.nest(
|
||||
"/shared_artifacts",
|
||||
crate::ai_shared_artifacts::workspaced_service(),
|
||||
)
|
||||
.nest(
|
||||
"/shared_sessions",
|
||||
crate::ai_shared_sessions::workspaced_service(),
|
||||
);
|
||||
|
||||
#[cfg(feature = "bedrock")]
|
||||
|
||||
@@ -0,0 +1,368 @@
|
||||
/*
|
||||
* Author: Ruben Fiszel
|
||||
* Copyright: Windmill Labs, Inc 2026
|
||||
* This file and its contents are licensed under the AGPLv3 License.
|
||||
* Please see the included NOTICE for copyright information and
|
||||
* LICENSE-AGPL for a copy of the license.
|
||||
*/
|
||||
|
||||
//! Read-only snapshots of AI session transcripts, shared by their author.
|
||||
//!
|
||||
//! Sessions live in the author's browser; a row here exists only because the author asked for
|
||||
//! a link. A share is readable by the members of its workspace, or by anyone holding the link
|
||||
//! once its author makes it public. The snapshot is whatever the author's browser sent, so the
|
||||
//! viewer treats it as untrusted data.
|
||||
|
||||
use crate::db::{ApiAuthed, DB};
|
||||
use axum::{
|
||||
extract::{DefaultBodyLimit, Extension, Json, Path, Query},
|
||||
routing::{delete, get, post},
|
||||
Router,
|
||||
};
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::value::RawValue;
|
||||
use uuid::Uuid;
|
||||
use windmill_api_auth::{is_effectively_unscoped, OptAuthed};
|
||||
use windmill_audit::{audit_oss::audit_log, ActionKind};
|
||||
use windmill_common::error::{Error, JsonResult, Result};
|
||||
|
||||
const MAX_SNAPSHOT_BYTES: usize = 10 * 1024 * 1024;
|
||||
const MAX_NAME_CHARS: usize = 255;
|
||||
const MAX_SESSION_ID_CHARS: usize = 255;
|
||||
const SHARE_BODY_LIMIT: usize = MAX_SNAPSHOT_BYTES + 64 * 1024;
|
||||
|
||||
pub fn workspaced_service() -> Router {
|
||||
Router::new()
|
||||
.route(
|
||||
"/share",
|
||||
post(share_session).layer(DefaultBodyLimit::max(SHARE_BODY_LIMIT)),
|
||||
)
|
||||
.route("/status", get(get_share_status))
|
||||
.route("/set_public/{id}", post(set_public))
|
||||
.route("/delete/{id}", delete(unshare_session))
|
||||
}
|
||||
|
||||
/// Mounted outside the authenticated router: a public share is served to anyone.
|
||||
pub fn workspaced_unauthed_service() -> Router {
|
||||
Router::new().route("/get/{id}", get(get_shared_session))
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct ShareSession {
|
||||
session_id: String,
|
||||
name: String,
|
||||
/// Left as it is on an existing share when absent; a new share starts private.
|
||||
is_public: Option<bool>,
|
||||
message_count: i32,
|
||||
snapshot: Box<RawValue>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct SharedSessionInfo {
|
||||
id: Uuid,
|
||||
name: String,
|
||||
is_public: bool,
|
||||
message_count: i32,
|
||||
created_by: String,
|
||||
shared_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct SharedSession {
|
||||
#[serde(flatten)]
|
||||
info: SharedSessionInfo,
|
||||
snapshot: Box<RawValue>,
|
||||
/// Whether the caller may stop sharing it: its author, or a workspace admin.
|
||||
can_unshare: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct ShareStatus {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
share: Option<SharedSessionInfo>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct ShareStatusQuery {
|
||||
session_id: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct SetPublic {
|
||||
is_public: bool,
|
||||
}
|
||||
|
||||
/// Sharing exposes the author's own browser state, so only the author's own unscoped token may
|
||||
/// do it: a job token can carry an `on_behalf_of` identity, and every scoped token (guest,
|
||||
/// embed, app policy, MCP) was minted for something narrower.
|
||||
fn require_plain_user_token(authed: &ApiAuthed) -> Result<()> {
|
||||
if authed.job_id.is_some() || !is_effectively_unscoped(authed.scopes.as_deref()) {
|
||||
return Err(Error::PermissionDenied(
|
||||
"Shared AI sessions are only reachable with an unscoped user token".to_string(),
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// It is compared against a `VARCHAR(255)` column, and Postgres answers a NUL in a text
|
||||
/// parameter with an opaque 500.
|
||||
fn check_session_id(session_id: &str) -> Result<()> {
|
||||
if session_id.is_empty() || session_id.chars().count() > MAX_SESSION_ID_CHARS {
|
||||
return Err(Error::BadRequest(format!(
|
||||
"Session id must be between 1 and {MAX_SESSION_ID_CHARS} characters"
|
||||
)));
|
||||
}
|
||||
if session_id.contains('\0') {
|
||||
return Err(Error::BadRequest(
|
||||
"Session id cannot contain NUL characters".to_string(),
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Share a session, or move the caller's existing link for it to this snapshot.
|
||||
async fn share_session(
|
||||
authed: ApiAuthed,
|
||||
Extension(db): Extension<DB>,
|
||||
Path(w_id): Path<String>,
|
||||
Json(payload): Json<ShareSession>,
|
||||
) -> JsonResult<SharedSessionInfo> {
|
||||
require_plain_user_token(&authed)?;
|
||||
check_session_id(&payload.session_id)?;
|
||||
let name = payload.name.trim();
|
||||
if name.is_empty() || name.chars().count() > MAX_NAME_CHARS || name.contains('\0') {
|
||||
return Err(Error::BadRequest(format!(
|
||||
"Session name must be between 1 and {MAX_NAME_CHARS} characters, without NUL"
|
||||
)));
|
||||
}
|
||||
let snapshot = payload.snapshot.get();
|
||||
if snapshot.len() > MAX_SNAPSHOT_BYTES {
|
||||
return Err(Error::BadRequest(format!(
|
||||
"Session snapshot is {} bytes, above the {MAX_SNAPSHOT_BYTES} byte limit",
|
||||
snapshot.len()
|
||||
)));
|
||||
}
|
||||
if !snapshot.trim_start().starts_with('{') {
|
||||
return Err(Error::BadRequest(
|
||||
"Session snapshot must be a JSON object".to_string(),
|
||||
));
|
||||
}
|
||||
if payload.message_count < 0 {
|
||||
return Err(Error::BadRequest(
|
||||
"Message count cannot be negative".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
let mut tx = db.begin().await?;
|
||||
let row = sqlx::query!(
|
||||
r#"INSERT INTO ai_shared_session
|
||||
(workspace_id, session_id, email, created_by, name, is_public, message_count, snapshot)
|
||||
VALUES ($1, $2, $3, $4, $5, COALESCE($6, false), $7, $8)
|
||||
ON CONFLICT (workspace_id, email, session_id) DO UPDATE
|
||||
SET created_by = EXCLUDED.created_by,
|
||||
name = EXCLUDED.name,
|
||||
is_public = COALESCE($6, ai_shared_session.is_public),
|
||||
message_count = EXCLUDED.message_count,
|
||||
snapshot = EXCLUDED.snapshot,
|
||||
shared_at = now()
|
||||
RETURNING id, is_public, shared_at, (xmax = 0) AS "inserted!""#,
|
||||
&w_id,
|
||||
&payload.session_id,
|
||||
&authed.email,
|
||||
&authed.username,
|
||||
name,
|
||||
payload.is_public,
|
||||
payload.message_count,
|
||||
snapshot,
|
||||
)
|
||||
.fetch_one(&mut *tx)
|
||||
.await?;
|
||||
|
||||
let id = row.id.to_string();
|
||||
let public = row.is_public.to_string();
|
||||
audit_log(
|
||||
&mut *tx,
|
||||
&authed,
|
||||
"ai.shared_sessions.share",
|
||||
if row.inserted {
|
||||
ActionKind::Create
|
||||
} else {
|
||||
ActionKind::Update
|
||||
},
|
||||
&w_id,
|
||||
Some(&id),
|
||||
Some([("name", name), ("public", public.as_str())].into()),
|
||||
)
|
||||
.await?;
|
||||
tx.commit().await?;
|
||||
|
||||
Ok(Json(SharedSessionInfo {
|
||||
id: row.id,
|
||||
name: name.to_string(),
|
||||
is_public: row.is_public,
|
||||
message_count: payload.message_count,
|
||||
created_by: authed.username.clone(),
|
||||
shared_at: row.shared_at,
|
||||
}))
|
||||
}
|
||||
|
||||
/// The caller's own share of one of their sessions, if any.
|
||||
async fn get_share_status(
|
||||
authed: ApiAuthed,
|
||||
Extension(db): Extension<DB>,
|
||||
Path(w_id): Path<String>,
|
||||
Query(query): Query<ShareStatusQuery>,
|
||||
) -> JsonResult<ShareStatus> {
|
||||
require_plain_user_token(&authed)?;
|
||||
check_session_id(&query.session_id)?;
|
||||
let share = sqlx::query_as!(
|
||||
SharedSessionInfo,
|
||||
"SELECT id, name, is_public, message_count, created_by, shared_at FROM ai_shared_session
|
||||
WHERE workspace_id = $1 AND email = $2 AND session_id = $3",
|
||||
&w_id,
|
||||
&authed.email,
|
||||
&query.session_id,
|
||||
)
|
||||
.fetch_optional(&db)
|
||||
.await?;
|
||||
|
||||
Ok(Json(ShareStatus { share }))
|
||||
}
|
||||
|
||||
/// Only the author changes who can open their link; an admin may only take it down.
|
||||
async fn set_public(
|
||||
authed: ApiAuthed,
|
||||
Extension(db): Extension<DB>,
|
||||
Path((w_id, id)): Path<(String, Uuid)>,
|
||||
Json(payload): Json<SetPublic>,
|
||||
) -> JsonResult<SharedSessionInfo> {
|
||||
require_plain_user_token(&authed)?;
|
||||
let mut tx = db.begin().await?;
|
||||
let info = sqlx::query_as!(
|
||||
SharedSessionInfo,
|
||||
"UPDATE ai_shared_session SET is_public = $4
|
||||
WHERE workspace_id = $1 AND id = $2 AND email = $3
|
||||
RETURNING id, name, is_public, message_count, created_by, shared_at",
|
||||
&w_id,
|
||||
id,
|
||||
&authed.email,
|
||||
payload.is_public,
|
||||
)
|
||||
.fetch_optional(&mut *tx)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
Error::NotFound(format!(
|
||||
"Shared session {id} not found, or not shared by you"
|
||||
))
|
||||
})?;
|
||||
|
||||
let id_str = id.to_string();
|
||||
let public = info.is_public.to_string();
|
||||
audit_log(
|
||||
&mut *tx,
|
||||
&authed,
|
||||
"ai.shared_sessions.set_public",
|
||||
ActionKind::Update,
|
||||
&w_id,
|
||||
Some(&id_str),
|
||||
Some([("name", info.name.as_str()), ("public", public.as_str())].into()),
|
||||
)
|
||||
.await?;
|
||||
tx.commit().await?;
|
||||
|
||||
Ok(Json(info))
|
||||
}
|
||||
|
||||
/// A public share is served to anyone with the link; any other one only to a member of its
|
||||
/// workspace, which is what an `ApiAuthed` resolved on a `/w/{workspace_id}` path is.
|
||||
async fn get_shared_session(
|
||||
OptAuthed(opt_authed): OptAuthed,
|
||||
Extension(db): Extension<DB>,
|
||||
Path((w_id, id)): Path<(String, Uuid)>,
|
||||
) -> JsonResult<SharedSession> {
|
||||
let row = sqlx::query!(
|
||||
"SELECT id, email, name, is_public, message_count, created_by, snapshot, shared_at
|
||||
FROM ai_shared_session
|
||||
WHERE workspace_id = $1 AND id = $2",
|
||||
&w_id,
|
||||
id,
|
||||
)
|
||||
.fetch_optional(&db)
|
||||
.await?;
|
||||
|
||||
let not_found = || {
|
||||
Error::NotFound(format!(
|
||||
"Shared session {id} not found: it may have been unshared, or be visible only to members of {w_id}"
|
||||
))
|
||||
};
|
||||
let member = opt_authed
|
||||
.as_ref()
|
||||
.filter(|a| a.job_id.is_none() && is_effectively_unscoped(a.scopes.as_deref()));
|
||||
let row = match row {
|
||||
Some(row) if row.is_public || member.is_some() => row,
|
||||
// A missing share and a private one answer a stranger alike, so the link does not
|
||||
// confirm that a private share exists.
|
||||
_ if member.is_none() => {
|
||||
return Err(Error::NotAuthorized(format!(
|
||||
"Shared session {id} is not public: sign in as a member of {w_id} to open it"
|
||||
)))
|
||||
}
|
||||
_ => return Err(not_found()),
|
||||
};
|
||||
|
||||
Ok(Json(SharedSession {
|
||||
can_unshare: member.is_some_and(|a| row.email == a.email || a.is_admin),
|
||||
snapshot: RawValue::from_string(row.snapshot).map_err(|e| {
|
||||
Error::internal_err(format!("Stored session snapshot is not valid JSON: {e}"))
|
||||
})?,
|
||||
info: SharedSessionInfo {
|
||||
id: row.id,
|
||||
name: row.name,
|
||||
is_public: row.is_public,
|
||||
message_count: row.message_count,
|
||||
created_by: row.created_by,
|
||||
shared_at: row.shared_at,
|
||||
},
|
||||
}))
|
||||
}
|
||||
|
||||
async fn unshare_session(
|
||||
authed: ApiAuthed,
|
||||
Extension(db): Extension<DB>,
|
||||
Path((w_id, id)): Path<(String, Uuid)>,
|
||||
) -> Result<String> {
|
||||
require_plain_user_token(&authed)?;
|
||||
let mut tx = db.begin().await?;
|
||||
let name = sqlx::query_scalar!(
|
||||
"DELETE FROM ai_shared_session
|
||||
WHERE workspace_id = $1 AND id = $2 AND (email = $3 OR $4::bool)
|
||||
RETURNING name",
|
||||
&w_id,
|
||||
id,
|
||||
&authed.email,
|
||||
authed.is_admin,
|
||||
)
|
||||
.fetch_optional(&mut *tx)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
Error::NotFound(format!(
|
||||
"Shared session {id} not found, or not shared by you"
|
||||
))
|
||||
})?;
|
||||
|
||||
let id_str = id.to_string();
|
||||
audit_log(
|
||||
&mut *tx,
|
||||
&authed,
|
||||
"ai.shared_sessions.unshare",
|
||||
ActionKind::Delete,
|
||||
&w_id,
|
||||
Some(&id_str),
|
||||
Some([("name", name.as_str())].into()),
|
||||
)
|
||||
.await?;
|
||||
tx.commit().await?;
|
||||
|
||||
Ok(format!("Stopped sharing {name}"))
|
||||
}
|
||||
@@ -68,6 +68,7 @@ use windmill_common::{
|
||||
get_payload_tag_from_prefixed_path, resolve_delete_after_secs, schedule_job_deletion,
|
||||
JobPayload, JobTriggerKind, RawCode,
|
||||
},
|
||||
scripts::ScriptLang,
|
||||
triggers::TriggerMetadata,
|
||||
user_drafts::{overlay_or_draft_only, DraftUserRef, UserDraftItemKind, WithDraftOverlay},
|
||||
users::username_to_permissioned_as,
|
||||
@@ -4682,23 +4683,46 @@ async fn execute_component(
|
||||
// The policy key covers only an inline script's own code, not the lock and modules
|
||||
// its `app_script` row runs with, so it cannot tell the deployed row from an older
|
||||
// one (or from id-less code, which runs with neither). Once the deployed version has
|
||||
// its lite value, inline code runs only through the rows that value points at.
|
||||
// its lite value, a deployed row's code runs only through that row, and id-less code
|
||||
// only as the database studio's runtime-built queries, which have no row. Those are
|
||||
// limited to the languages it emits: the pin covers content, not language, and the
|
||||
// policy also pins frontend scripts, which must never run as e.g. bash.
|
||||
// Checked on every run: a deploy moves it.
|
||||
if is_inline_raw_code {
|
||||
if let Some(raw_code) = payload.raw_code.as_ref() {
|
||||
let id_less_sql = payload.id.is_none()
|
||||
&& matches!(
|
||||
raw_code.language,
|
||||
ScriptLang::Postgresql
|
||||
| ScriptLang::Mysql
|
||||
| ScriptLang::Mssql
|
||||
| ScriptLang::Snowflake
|
||||
| ScriptLang::Bigquery
|
||||
| ScriptLang::DuckDb
|
||||
);
|
||||
let id_less_sha256 = id_less_sql
|
||||
.then(|| format!("{:x}", Sha256::digest(raw_code.content.as_bytes())));
|
||||
let deployed = sqlx::query!(
|
||||
"SELECT l.id IS NOT NULL as \"has_lite!\",
|
||||
coalesce(jsonb_path_exists(l.value, '$.**.inlineScript.id ? (@ == $id)',
|
||||
jsonb_build_object('id', $3::bigint)), false) as \"is_deployed_row!\"
|
||||
CASE WHEN $3::bigint IS NULL THEN NOT EXISTS (
|
||||
SELECT 1 FROM app_script s
|
||||
WHERE s.app = a.id AND s.code_sha256 = $4::text
|
||||
AND jsonb_path_exists(l.value, '$.**.inlineScript.id ? (@ == $id)',
|
||||
jsonb_build_object('id', s.id)))
|
||||
ELSE coalesce(jsonb_path_exists(l.value, '$.**.inlineScript.id ? (@ == $id)',
|
||||
jsonb_build_object('id', $3::bigint)), false)
|
||||
END as \"may_run!\"
|
||||
FROM app a
|
||||
LEFT JOIN app_version_lite l ON l.id = a.versions[array_upper(a.versions, 1)]
|
||||
WHERE a.path = $1 AND a.workspace_id = $2",
|
||||
path,
|
||||
&w_id,
|
||||
payload.id,
|
||||
id_less_sha256,
|
||||
)
|
||||
.fetch_optional(&db)
|
||||
.await?;
|
||||
if deployed.is_some_and(|d| d.has_lite && !d.is_deployed_row) {
|
||||
let may_run = payload.id.is_some() || id_less_sql;
|
||||
if deployed.is_some_and(|d| d.has_lite && !(may_run && d.may_run)) {
|
||||
return Err(Error::NotAuthorized(format!(
|
||||
"This runnable is not part of the deployed version of app {path}, reload the app"
|
||||
)));
|
||||
@@ -6779,8 +6803,8 @@ mod embed_token_tests {
|
||||
"POST",
|
||||
),
|
||||
("/api/w/test/jobs/restart/f/some-uuid", "POST"),
|
||||
// `users:read` is presented to the viewer as "read your identity", so
|
||||
// the workspace member directory must stay out of reach.
|
||||
// `users:read` reaches whoami only: the workspace member directory must
|
||||
// stay out of reach.
|
||||
("/api/w/test/users/list", "GET"),
|
||||
("/api/w/test/users/list_usage", "GET"),
|
||||
("/api/w/test/users/username_to_email/admin", "GET"),
|
||||
@@ -6791,6 +6815,15 @@ mod embed_token_tests {
|
||||
"SDK token should deny {method} {path}"
|
||||
);
|
||||
}
|
||||
|
||||
// Whoami needs no declared scope.
|
||||
let jobs_only = [
|
||||
"jobs:run".to_string(),
|
||||
windmill_api_auth::scopes::RAW_APP_SDK_SENTINEL.to_string(),
|
||||
];
|
||||
assert!(
|
||||
check_scopes_for_route(Some(&jobs_only[..]), "/api/w/test/users/whoami", "GET").is_ok()
|
||||
);
|
||||
}
|
||||
|
||||
/// The token carries path-scoped `apps:run:<own path>` and `apps:read:<own path>`
|
||||
|
||||
@@ -7058,6 +7058,7 @@ async fn batch_rerun_handle_job(
|
||||
)
|
||||
.await;
|
||||
if let Ok((uuid, _, _, _)) = result {
|
||||
resolve_batch_rerun_source(authed, user_db, w_id, job.id, uuid).await;
|
||||
return Ok(uuid.to_string());
|
||||
}
|
||||
}
|
||||
@@ -7091,6 +7092,7 @@ async fn batch_rerun_handle_job(
|
||||
.map(|r| r.0)
|
||||
};
|
||||
if let Ok(uuid) = result {
|
||||
resolve_batch_rerun_source(authed, user_db, w_id, job.id, uuid).await;
|
||||
return Ok(uuid.to_string());
|
||||
}
|
||||
}
|
||||
@@ -7101,6 +7103,67 @@ async fn batch_rerun_handle_job(
|
||||
))
|
||||
}
|
||||
|
||||
/// Marks a failed or canceled source of a batch re-run as handled, with the re-run as its note.
|
||||
/// This is the only moment the link exists (the re-run is pushed with no back-pointer), and it
|
||||
/// is what lets "hide resolved" exclude already re-run jobs from the next batch. Never fails the
|
||||
/// re-run, which is already queued: a source that cannot be resolved is logged and left as is.
|
||||
async fn resolve_batch_rerun_source(
|
||||
authed: &ApiAuthed,
|
||||
user_db: &UserDB,
|
||||
w_id: &str,
|
||||
source: Uuid,
|
||||
rerun: Uuid,
|
||||
) {
|
||||
if authed.is_operator {
|
||||
return;
|
||||
}
|
||||
let result: error::Result<()> = async {
|
||||
let mut tx = user_db.clone().begin(authed).await?;
|
||||
let tags = get_scope_tags(authed);
|
||||
let (resolved_by, _) = resolution_attribution(authed, None);
|
||||
// Same authorization and eligibility as `resolve_completed_jobs`. DO NOTHING keeps a
|
||||
// resolution someone already explained.
|
||||
let resolved = sqlx::query_scalar!(
|
||||
"INSERT INTO job_resolution (job_id, workspace_id, resolved_by, note, automatic)
|
||||
SELECT c.id, c.workspace_id, $4, $5, false
|
||||
FROM v2_job_completed c
|
||||
JOIN v2_job j ON j.id = c.id
|
||||
WHERE c.id = $1
|
||||
AND c.workspace_id = $2
|
||||
AND ($3::TEXT[] IS NULL OR j.tag = ANY($3))
|
||||
AND c.status IN ('failure', 'canceled')
|
||||
AND j.flow_step_id IS NULL
|
||||
ON CONFLICT (job_id) DO NOTHING
|
||||
RETURNING job_id",
|
||||
source,
|
||||
w_id,
|
||||
tags.as_ref().map(|v| v.as_slice()) as Option<&[&str]>,
|
||||
resolved_by,
|
||||
format!("Re-run as {rerun}"),
|
||||
)
|
||||
.fetch_optional(&mut *tx)
|
||||
.await?;
|
||||
if resolved.is_some() {
|
||||
audit_log(
|
||||
&mut *tx,
|
||||
authed,
|
||||
"jobs.resolve",
|
||||
ActionKind::Update,
|
||||
w_id,
|
||||
Some(&source.to_string()),
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
tx.commit().await?;
|
||||
Ok(())
|
||||
}
|
||||
.await;
|
||||
if let Err(e) = result {
|
||||
tracing::error!("Could not resolve job {source} after re-running it as {rerun}: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn run_flow_by_path(
|
||||
authed: ApiAuthed,
|
||||
Extension(db): Extension<DB>,
|
||||
@@ -9219,7 +9282,6 @@ async fn run_inline_preview_script(
|
||||
end_user_email,
|
||||
viewer_data_access,
|
||||
lang: preview.language,
|
||||
job_dir: "".to_string(),
|
||||
worker_name: "".to_string(),
|
||||
worker_dir: "".to_string(),
|
||||
client: AuthedClient {
|
||||
@@ -9370,7 +9432,6 @@ async fn run_inline_script_inner(
|
||||
permissioned_as: username_to_permissioned_as(&authed.username),
|
||||
permissioned_as_email: authed.email.clone(),
|
||||
end_user_email,
|
||||
job_dir: "".to_string(),
|
||||
worker_name: "".to_string(),
|
||||
worker_dir: "".to_string(),
|
||||
client: AuthedClient {
|
||||
@@ -12531,8 +12592,8 @@ fn check_resolution_request(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Marks failed jobs as handled. Returns the ids actually affected: an id that is not
|
||||
/// visible to the caller, carries an out-of-scope tag, or did not fail is silently
|
||||
/// Marks failed or canceled jobs as handled. Returns the ids actually affected: an id that is
|
||||
/// not visible to the caller, carries an out-of-scope tag, or did not fail nor get canceled is silently
|
||||
/// absent rather than an error, so a bulk selection never fails as a whole.
|
||||
async fn resolve_completed_jobs(
|
||||
authed: ApiAuthed,
|
||||
@@ -12547,7 +12608,7 @@ async fn resolve_completed_jobs(
|
||||
let system_note = req.superseded_by.map(|_| SUPERSEDED_NOTE);
|
||||
// The join on v2_job is what authorizes this write: v2_job_completed has RLS
|
||||
// disabled, so v2_job's policies are the only thing scoping rows to the caller.
|
||||
// `status = 'failure'` keeps the invariant that only a failure can be resolved.
|
||||
// Only a failed or canceled run can be resolved: a success has nothing to handle.
|
||||
let resolved = sqlx::query_scalar!(
|
||||
"INSERT INTO job_resolution (job_id, workspace_id, resolved_by, note, automatic)
|
||||
SELECT c.id, c.workspace_id, $4, COALESCE($5, $7), false
|
||||
@@ -12556,7 +12617,7 @@ async fn resolve_completed_jobs(
|
||||
WHERE c.id = ANY($1)
|
||||
AND c.workspace_id = $2
|
||||
AND ($3::TEXT[] IS NULL OR j.tag = ANY($3))
|
||||
AND c.status = 'failure'
|
||||
AND c.status IN ('failure', 'canceled')
|
||||
-- Resolution is a top-level triage state: a step resolved on its own
|
||||
-- would render orange inside a flow whose status is still red.
|
||||
AND j.flow_step_id IS NULL
|
||||
|
||||
@@ -77,6 +77,7 @@ mod ai_sessions;
|
||||
#[cfg(feature = "parquet")]
|
||||
pub use ai_sessions::sweep_expired_ai_session_backups;
|
||||
mod ai_shared_artifacts;
|
||||
mod ai_shared_sessions;
|
||||
mod apps;
|
||||
mod apps_raw_bundle;
|
||||
pub use apps::invalidate_app_policy_cache;
|
||||
@@ -924,6 +925,10 @@ pub async fn run_server(
|
||||
.layer(from_extractor::<OptAuthed>())
|
||||
.layer(cors.clone()),
|
||||
)
|
||||
.nest(
|
||||
"/w/{workspace_id}/ai_u/shared_sessions",
|
||||
ai_shared_sessions::workspaced_unauthed_service(),
|
||||
)
|
||||
.layer(from_extractor::<OptAuthed>())
|
||||
// Deprecated, here for backwards compatibility: user should use /mcp/w/{workspace_id}/mcp instead
|
||||
.nest(
|
||||
|
||||
@@ -599,6 +599,10 @@ pub fn all_tools() -> Vec<EndpointTool> {
|
||||
"include_draft_only": {
|
||||
"type": "boolean",
|
||||
"description": "When true, append per-user draft resources whose path has\nno deployed resource. Synthesized rows carry\n`draft_only: true`.\n"
|
||||
},
|
||||
"starred_only": {
|
||||
"type": "boolean",
|
||||
"description": "Only the `ai_agent` resources the caller starred"
|
||||
}
|
||||
},
|
||||
"required": []
|
||||
@@ -1336,7 +1340,7 @@ is, a different one moves it there and archives the old path"),
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Raw apps: author-declared scopes for the frontend SDK token. Takes effect only when `sandbox` is also true — an unsandboxed bundle runs with the viewer's own session, so no token is advertised or minted for it and this list stays inert. On a sandboxed app a non-empty list lets viewers mint (after consenting) a short-lived token carrying their own identity restricted to these scopes, handed to the app bundle so `windmill-client` calls run as the viewer. Must be a subset of the server's curated allowlist (jobs:run, jobs:read, users:read, resources:read, variables:read, flow_conversations:read, flow_conversations:write).\n"
|
||||
"description": "Raw apps: author-declared scopes for the frontend SDK token. Takes effect only when `sandbox` is also true — an unsandboxed bundle runs with the viewer's own session, so no token is advertised or minted for it and this list stays inert. On a sandboxed app a non-empty list lets viewers mint (after consenting) a short-lived token carrying their own identity restricted to these scopes, handed to the app bundle so `windmill-client` calls run as the viewer. Must be a subset of the server's curated allowlist (jobs:run, jobs:read, users:read, resources:read, variables:read, flow_conversations:read, flow_conversations:write). Every such token can call whoami without consent, whether `users:read` is declared or not.\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1453,7 +1457,7 @@ is, a different one moves it there and archives the old path"),
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Raw apps: author-declared scopes for the frontend SDK token. Takes effect only when `sandbox` is also true — an unsandboxed bundle runs with the viewer's own session, so no token is advertised or minted for it and this list stays inert. On a sandboxed app a non-empty list lets viewers mint (after consenting) a short-lived token carrying their own identity restricted to these scopes, handed to the app bundle so `windmill-client` calls run as the viewer. Must be a subset of the server's curated allowlist (jobs:run, jobs:read, users:read, resources:read, variables:read, flow_conversations:read, flow_conversations:write).\n"
|
||||
"description": "Raw apps: author-declared scopes for the frontend SDK token. Takes effect only when `sandbox` is also true — an unsandboxed bundle runs with the viewer's own session, so no token is advertised or minted for it and this list stays inert. On a sandboxed app a non-empty list lets viewers mint (after consenting) a short-lived token carrying their own identity restricted to these scopes, handed to the app bundle so `windmill-client` calls run as the viewer. Must be a subset of the server's curated allowlist (jobs:run, jobs:read, users:read, resources:read, variables:read, flow_conversations:read, flow_conversations:write). Every such token can call whoami without consent, whether `users:read` is declared or not.\n"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1842,7 +1846,7 @@ is, a different one moves it there and archives the old path"),
|
||||
},
|
||||
"resolved": {
|
||||
"type": "boolean",
|
||||
"description": "filter on whether a failure has been marked as handled. true keeps only resolved failures, false hides them"
|
||||
"description": "filter on whether a failed or canceled run has been marked as handled. true keeps only resolved runs, false hides them"
|
||||
},
|
||||
"is_flow_step": {
|
||||
"type": "boolean",
|
||||
|
||||
@@ -25,8 +25,8 @@ use crate::jobs::{
|
||||
use super::auto_generated_endpoints::all_tools;
|
||||
use super::utils::{
|
||||
build_query_string, build_request_body, create_http_request, get_hub_script_schema,
|
||||
get_item_schema, get_items, get_resources, get_resources_types, get_scripts_from_hub,
|
||||
parse_response_body, prepare_push_args, substitute_path_params,
|
||||
get_item_paths, get_item_schema, get_items, get_resources, get_resources_types,
|
||||
get_scripts_from_hub, parse_response_body, prepare_push_args, substitute_path_params,
|
||||
};
|
||||
|
||||
use std::sync::Arc;
|
||||
@@ -118,6 +118,27 @@ impl McpBackend for WindmillBackend {
|
||||
.map_err(|e| ErrorData::internal_error(e.message, None))
|
||||
}
|
||||
|
||||
async fn list_runnable_paths(
|
||||
&self,
|
||||
auth: &ApiAuthed,
|
||||
workspace_id: &str,
|
||||
item_type: &str,
|
||||
favorites_only: bool,
|
||||
path_filter: Option<PathFilter<'_>>,
|
||||
) -> BackendResult<Vec<String>> {
|
||||
let scope_type = if favorites_only { "favorites" } else { "all" };
|
||||
get_item_paths(
|
||||
&self.user_db,
|
||||
auth,
|
||||
workspace_id,
|
||||
scope_type,
|
||||
item_type,
|
||||
path_filter,
|
||||
)
|
||||
.await
|
||||
.map_err(|e| ErrorData::internal_error(e.message, None))
|
||||
}
|
||||
|
||||
async fn list_resource_types(
|
||||
&self,
|
||||
auth: &ApiAuthed,
|
||||
|
||||
@@ -171,18 +171,16 @@ pub async fn get_resources(
|
||||
Ok(rows)
|
||||
}
|
||||
|
||||
/// Generic function to get items (scripts or flows) from the database
|
||||
pub async fn get_items<T: for<'a> sqlx::FromRow<'a, sqlx::postgres::PgRow> + Send + Unpin>(
|
||||
user_db: &UserDB,
|
||||
/// The scripts or flows a listing covers: the caller's workspace, unarchived,
|
||||
/// callable, and narrowed by favorites and `path_filter`.
|
||||
fn items_query(
|
||||
authed: &ApiAuthed,
|
||||
workspace_id: &str,
|
||||
scope_type: &str,
|
||||
item_type: &str,
|
||||
path_filter: Option<PathFilter<'_>>,
|
||||
) -> Result<Vec<T>, ErrorData> {
|
||||
) -> SqlBuilder {
|
||||
let mut sqlb = SqlBuilder::select_from(&format!("{} as o", item_type));
|
||||
let fields = vec!["o.path", "o.summary", "o.description", "o.schema"];
|
||||
sqlb.fields(&fields);
|
||||
if scope_type == "favorites" {
|
||||
sqlb.join("favorite")
|
||||
.on("favorite.favorite_kind = ? AND favorite.workspace_id = o.workspace_id AND favorite.path = o.path AND favorite.usr = ?".bind(&item_type)
|
||||
@@ -209,17 +207,29 @@ pub async fn get_items<T: for<'a> sqlx::FromRow<'a, sqlx::postgres::PgRow> + Sen
|
||||
sqlb.and_where(cond);
|
||||
}
|
||||
}
|
||||
Some(PathFilter::LastSegment(segments)) => {
|
||||
if segments.is_empty() {
|
||||
sqlb.and_where("false");
|
||||
} else {
|
||||
let conds: Vec<String> = segments
|
||||
.iter()
|
||||
.map(|s| {
|
||||
"o.path LIKE ? ESCAPE '\\'".bind(&format!("%/{}", escape_like(s)))
|
||||
})
|
||||
.collect();
|
||||
sqlb.and_where(format!("({})", conds.join(" OR ")));
|
||||
}
|
||||
}
|
||||
}
|
||||
sqlb
|
||||
}
|
||||
|
||||
sqlb.order_by(
|
||||
if item_type == "flow" {
|
||||
"o.edited_at"
|
||||
} else {
|
||||
"o.created_at"
|
||||
},
|
||||
false,
|
||||
)
|
||||
.limit(ITEMS_FETCH_MAX_LIMIT);
|
||||
async fn fetch_items<T: for<'a> sqlx::FromRow<'a, sqlx::postgres::PgRow> + Send + Unpin>(
|
||||
user_db: &UserDB,
|
||||
authed: &ApiAuthed,
|
||||
sqlb: &SqlBuilder,
|
||||
item_type: &str,
|
||||
) -> Result<Vec<T>, ErrorData> {
|
||||
let sql = sqlb.sql().map_err(|e| {
|
||||
tracing::error!("failed to build sql: {}", e);
|
||||
ErrorData::internal_error(format!("failed to build sql: {}", e), None)
|
||||
@@ -242,6 +252,44 @@ pub async fn get_items<T: for<'a> sqlx::FromRow<'a, sqlx::postgres::PgRow> + Sen
|
||||
Ok(rows)
|
||||
}
|
||||
|
||||
/// Generic function to get items (scripts or flows) from the database
|
||||
pub async fn get_items<T: for<'a> sqlx::FromRow<'a, sqlx::postgres::PgRow> + Send + Unpin>(
|
||||
user_db: &UserDB,
|
||||
authed: &ApiAuthed,
|
||||
workspace_id: &str,
|
||||
scope_type: &str,
|
||||
item_type: &str,
|
||||
path_filter: Option<PathFilter<'_>>,
|
||||
) -> Result<Vec<T>, ErrorData> {
|
||||
let mut sqlb = items_query(authed, workspace_id, scope_type, item_type, path_filter);
|
||||
sqlb.fields(&["o.path", "o.summary", "o.description", "o.schema"]);
|
||||
sqlb.order_by(
|
||||
if item_type == "flow" {
|
||||
"o.edited_at"
|
||||
} else {
|
||||
"o.created_at"
|
||||
},
|
||||
false,
|
||||
)
|
||||
.limit(ITEMS_FETCH_MAX_LIMIT);
|
||||
fetch_items(user_db, authed, &sqlb, item_type).await
|
||||
}
|
||||
|
||||
/// Every path `get_items` would return with no fetch cap.
|
||||
pub async fn get_item_paths(
|
||||
user_db: &UserDB,
|
||||
authed: &ApiAuthed,
|
||||
workspace_id: &str,
|
||||
scope_type: &str,
|
||||
item_type: &str,
|
||||
path_filter: Option<PathFilter<'_>>,
|
||||
) -> Result<Vec<String>, ErrorData> {
|
||||
let mut sqlb = items_query(authed, workspace_id, scope_type, item_type, path_filter);
|
||||
sqlb.distinct().field("o.path");
|
||||
let rows: Vec<(String,)> = fetch_items(user_db, authed, &sqlb, item_type).await?;
|
||||
Ok(rows.into_iter().map(|(path,)| path).collect())
|
||||
}
|
||||
|
||||
/// Get scripts from the Hub
|
||||
pub async fn get_scripts_from_hub(
|
||||
db: &DB,
|
||||
|
||||
@@ -10,7 +10,10 @@ use windmill_common::{
|
||||
error::{Error, JsonResult, Result},
|
||||
utils::{not_found_if_none, StripPath},
|
||||
};
|
||||
use windmill_store::{resources::explain_resource_perm_error, variables::get_value_internal};
|
||||
use windmill_store::{
|
||||
resources::{check_resource_var_ref_scope, explain_resource_perm_error},
|
||||
variables::get_value_internal,
|
||||
};
|
||||
|
||||
/// A connected MCP server is a third party the user chose, reached over a
|
||||
/// connection this request holds open: without a deadline one that never answers
|
||||
@@ -67,12 +70,22 @@ async fn connect_mcp_client(
|
||||
serde_json::from_str::<windmill_mcp::McpResource>(resource_value.0.get())
|
||||
.map_err(|e| Error::BadRequest(format!("Failed to parse MCP resource: {}", e)))?;
|
||||
|
||||
// The token, URL and header secrets are read on the caller's behalf and sent to a URL
|
||||
// the resource chose, so each needs the same scope as a resource reference. The token
|
||||
// is checked before the OAuth refresh touches its variable.
|
||||
let token_var_path = mcp_resource
|
||||
.token
|
||||
.as_deref()
|
||||
.map(|t| t.trim_start_matches("$var:"))
|
||||
.filter(|p| !p.trim().is_empty());
|
||||
if let Some(token_var_path) = token_var_path {
|
||||
check_resource_var_ref_scope(authed, path, token_var_path)?;
|
||||
}
|
||||
|
||||
#[cfg(feature = "oauth2")]
|
||||
{
|
||||
tracing::info!("Checking if token needs refresh before creating MCP client");
|
||||
if let Some(ref token_path) = mcp_resource.token {
|
||||
let token_var_path = token_path.trim_start_matches("$var:");
|
||||
|
||||
if let Some(token_var_path) = token_var_path {
|
||||
let token_info = sqlx::query!(
|
||||
r#"
|
||||
SELECT
|
||||
@@ -113,14 +126,9 @@ async fn connect_mcp_client(
|
||||
// Resolve the token through the caller's permissioned (RLS + audit) path so
|
||||
// a developer cannot exfiltrate a secret they are not allowed to read by
|
||||
// pointing an MCP resource's token at it.
|
||||
let token = if let Some(token_path) = &mcp_resource.token {
|
||||
let token_var_path = token_path.trim_start_matches("$var:");
|
||||
if token_var_path.trim().is_empty() {
|
||||
None
|
||||
} else {
|
||||
let db_authed = DbWithOptAuthed::from_authed(authed, db.clone(), Some(user_db.clone()));
|
||||
Some(get_value_internal(&db_authed, w_id, token_var_path, false).await?)
|
||||
}
|
||||
let token = if let Some(token_var_path) = token_var_path {
|
||||
let db_authed = DbWithOptAuthed::from_authed(authed, db.clone(), Some(user_db.clone()));
|
||||
Some(get_value_internal(&db_authed, w_id, token_var_path, false).await?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@@ -130,7 +138,7 @@ async fn connect_mcp_client(
|
||||
.chain(mcp_resource.headers.iter_mut().flatten().map(|(_, v)| v))
|
||||
{
|
||||
if let Some(var_path) = value.strip_prefix("$var:") {
|
||||
check_scopes(authed, || format!("variables:read:{}", var_path))?;
|
||||
check_resource_var_ref_scope(authed, path, var_path)?;
|
||||
let db_authed = DbWithOptAuthed::from_authed(authed, db.clone(), Some(user_db.clone()));
|
||||
*value = get_value_internal(&db_authed, w_id, var_path, false).await?;
|
||||
}
|
||||
|
||||
@@ -266,6 +266,17 @@ async fn get_offboard_preview(
|
||||
departing.as_deref(), &user_prefix, w_id
|
||||
).fetch_all(db).await?;
|
||||
|
||||
// An agent's identity sits in its value, under any path, the user's own included: those
|
||||
// move with the path but keep running as the departing user until re-pointed.
|
||||
let obo_agents: Vec<String> = sqlx::query_scalar(
|
||||
"SELECT path FROM resource WHERE resource_type = 'ai_agent'
|
||||
AND value->>'on_behalf_of' = $1 AND workspace_id = $2",
|
||||
)
|
||||
.bind(departing.as_deref())
|
||||
.bind(w_id)
|
||||
.fetch_all(db)
|
||||
.await?;
|
||||
|
||||
let obo_schedules = sqlx::query_scalar!(
|
||||
"SELECT path FROM schedule WHERE permissioned_as = $1 AND NOT path LIKE $2 AND workspace_id = $3",
|
||||
&user_owner, &user_prefix, w_id
|
||||
@@ -354,6 +365,7 @@ async fn get_offboard_preview(
|
||||
scripts: obo_scripts,
|
||||
flows: obo_flows,
|
||||
apps: obo_apps,
|
||||
resources: obo_agents,
|
||||
schedules: obo_schedules,
|
||||
triggers: obo_triggers,
|
||||
..Default::default()
|
||||
@@ -1007,6 +1019,16 @@ async fn offboard_user_from_workspace<'c>(
|
||||
.await?
|
||||
.unwrap_or(0);
|
||||
|
||||
sqlx::query(
|
||||
"UPDATE resource SET value = jsonb_set(value, '{on_behalf_of}', to_jsonb($1::text))
|
||||
WHERE resource_type = 'ai_agent' AND value->>'on_behalf_of' = $2 AND workspace_id = $3",
|
||||
)
|
||||
.bind(new_permissioned_as)
|
||||
.bind(departing.as_deref())
|
||||
.bind(w_id)
|
||||
.execute(&mut **tx)
|
||||
.await?;
|
||||
|
||||
// ---- eval datasets ----
|
||||
// The foreign keys cascade the rename onto cases and experiments; the paths held inside JSONB
|
||||
// (an experiment's subject, a dataset's scorers) are rewritten separately since the cascade
|
||||
|
||||
@@ -297,8 +297,21 @@ async fn rename_user(
|
||||
// keeps a like-named member of some other workspace out of it.
|
||||
if let Some(old_username) = old_instance_username.filter(|u| *u != ru.new_username) {
|
||||
let old_principal = windmill_common::users::username_to_permissioned_as(&old_username);
|
||||
let new_principal =
|
||||
windmill_common::users::username_to_permissioned_as(&ru.new_username);
|
||||
let new_principal = windmill_common::users::username_to_permissioned_as(&ru.new_username);
|
||||
// An agent records no address, so a workspace where the name is a member's own is
|
||||
// left to the per-workspace sweep: there the principal is that member.
|
||||
sqlx::query(
|
||||
"UPDATE resource SET value = jsonb_set(value, '{on_behalf_of}', to_jsonb($1::text))
|
||||
WHERE resource_type = 'ai_agent' AND value->>'on_behalf_of' = $2
|
||||
AND NOT EXISTS (SELECT 1 FROM usr
|
||||
WHERE usr.workspace_id = resource.workspace_id
|
||||
AND usr.username = $3)",
|
||||
)
|
||||
.bind(&new_principal)
|
||||
.bind(&old_principal)
|
||||
.bind(&old_username)
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
sqlx::query!(
|
||||
"UPDATE app SET policy = jsonb_set(policy, ARRAY['on_behalf_of'], to_jsonb($1::text))
|
||||
WHERE policy->>'on_behalf_of' = $2 AND policy->>'on_behalf_of_email' = $3",
|
||||
@@ -817,6 +830,17 @@ async fn update_username_in_workpsace<'c>(
|
||||
.execute(&mut **tx)
|
||||
.await?;
|
||||
|
||||
sqlx::query(
|
||||
"UPDATE resource SET value = jsonb_set(value, '{on_behalf_of}', to_jsonb('u/' || $1))
|
||||
WHERE resource_type = 'ai_agent' AND value->>'on_behalf_of' = ('u/' || $2)
|
||||
AND workspace_id = $3",
|
||||
)
|
||||
.bind(new_username)
|
||||
.bind(old_username)
|
||||
.bind(w_id)
|
||||
.execute(&mut **tx)
|
||||
.await?;
|
||||
|
||||
// An app draft carries a copy of the deployed policy, so the rename must reach it
|
||||
// there too — same reason as the script/flow draft sweep above.
|
||||
sqlx::query!(
|
||||
|
||||
@@ -894,7 +894,14 @@ pub(crate) async fn tarball_workspace(
|
||||
.fetch_all(&mut *tx)
|
||||
.await?;
|
||||
|
||||
for resource in resources {
|
||||
for mut resource in resources {
|
||||
// An agent's identity belongs to this workspace, and whoever writes it elsewhere gets
|
||||
// their own, as `to_string_without_metadata` leaves out a flow's.
|
||||
if resource.resource_type == "ai_agent" {
|
||||
if let Some(obj) = resource.value.as_mut().and_then(|v| v.as_object_mut()) {
|
||||
obj.remove("on_behalf_of");
|
||||
}
|
||||
}
|
||||
let resource_str =
|
||||
&to_string_without_metadata(&resource, ExtraPermsBehavior::Drop, None).unwrap();
|
||||
archive
|
||||
|
||||
@@ -64,12 +64,13 @@ pub async fn get_or_create_conversation_with_id(
|
||||
w_id: &str,
|
||||
flow_path: &str,
|
||||
username: &str,
|
||||
is_admin: bool,
|
||||
title: &str,
|
||||
conversation_id: Uuid,
|
||||
is_test: bool,
|
||||
) -> Result<FlowConversation> {
|
||||
if let Some(existing) = lock_conversation(tx, w_id, conversation_id).await? {
|
||||
let existing = same_kind(existing, is_test)?;
|
||||
let existing = same_kind(owned(existing, username, is_admin)?, is_test)?;
|
||||
refuse_running_turn(tx, conversation_id).await?;
|
||||
return Ok(existing);
|
||||
}
|
||||
@@ -106,7 +107,7 @@ pub async fn get_or_create_conversation_with_id(
|
||||
"conversation {conversation_id} belongs to another workspace"
|
||||
))
|
||||
})?;
|
||||
let existing = same_kind(existing, is_test)?;
|
||||
let existing = same_kind(owned(existing, username, is_admin)?, is_test)?;
|
||||
refuse_running_turn(tx, conversation_id).await?;
|
||||
Ok(existing)
|
||||
}
|
||||
@@ -176,6 +177,19 @@ pub async fn running_turns<'e, E: sqlx::PgExecutor<'e>>(
|
||||
.collect())
|
||||
}
|
||||
|
||||
/// The `see_own` policy on `flow_conversation`, for a turn whose transaction bypasses it: a run
|
||||
/// as a flow's or agent's `on_behalf_of` takes the conversation in a root transaction, and must
|
||||
/// not continue, or read the memory of, another user's conversation.
|
||||
fn owned(existing: FlowConversation, username: &str, is_admin: bool) -> Result<FlowConversation> {
|
||||
if is_admin || existing.created_by == username {
|
||||
return Ok(existing);
|
||||
}
|
||||
Err(crate::error::Error::BadRequest(format!(
|
||||
"conversation {} belongs to another user; start a new conversation",
|
||||
existing.id
|
||||
)))
|
||||
}
|
||||
|
||||
/// `memory_id` is the caller's to choose, so a preview run could name a deployed
|
||||
/// conversation and the reverse. A conversation's kind is fixed at creation and nothing
|
||||
/// would show the mixing afterwards, so the turn is refused before it starts.
|
||||
|
||||
@@ -483,7 +483,6 @@ pub struct RunInlinePreviewScriptFnParams {
|
||||
pub worker_name: String,
|
||||
pub conn: crate::worker::Connection,
|
||||
pub client: AuthedClient,
|
||||
pub job_dir: String,
|
||||
pub worker_dir: String,
|
||||
pub killpill_rx: tokio::sync::broadcast::Receiver<()>,
|
||||
}
|
||||
@@ -507,7 +506,6 @@ pub struct RunInlineScriptFnParams {
|
||||
pub worker_name: String,
|
||||
pub conn: crate::worker::Connection,
|
||||
pub client: AuthedClient,
|
||||
pub job_dir: String,
|
||||
pub worker_dir: String,
|
||||
pub killpill_rx: tokio::sync::broadcast::Receiver<()>,
|
||||
pub user_db: Option<(crate::db::UserDB, crate::db::Authed)>,
|
||||
|
||||
@@ -30,6 +30,11 @@ pub const MIN_VERSION_SUPPORTS_JOB_TOKEN_SCOPES: VC = vc(1, 822, 0, "Restricted
|
||||
// Also gates widening `variable.value`, which needs every process to retire the connections
|
||||
// the widening poisons (`db::retire_connections_opened_before_now`): that also ships in 1.832.
|
||||
pub const MIN_VERSION_SUPPORTS_AEAD_SECRETS: VC = vc(1, 832, 0, "AES-GCM secret encryption");
|
||||
// A renewed license key replaces the one every process reads, and a worker that predates
|
||||
// Ed25519 support rejects an Ed25519-signed key and stops pulling jobs, so renewal only offers
|
||||
// to accept one once this is met. Only worker versions are seen here, not servers. Must name
|
||||
// the release this ships in.
|
||||
pub const MIN_VERSION_SUPPORTS_ED25519_LICENSE: VC = vc(1, 838, 0, "Ed25519 license keys");
|
||||
pub const MIN_VERSION_SUPPORTS_NODE_DEBOUNCING: VC = vc(1, 658, 0, "Flow node debouncing");
|
||||
pub const MIN_VERSION_SUPPORTS_TOKEN_HASH: VC = vc(1, 659, 0, "Token hash storage");
|
||||
pub const MIN_VERSION_SUPPORTS_SYNC_JOBS_DEBOUNCING: VC = vc(1, 602, 0, "Sync jobs debouncing");
|
||||
|
||||
@@ -23,6 +23,15 @@ use std::sync::atomic::{AtomicBool, Ordering};
|
||||
lazy_static::lazy_static! {
|
||||
pub static ref SECRET_SALT: Option<String> = std::env::var("SECRET_SALT").ok();
|
||||
static ref RESERVED_WM_VAR_NAME: regex::Regex = regex::Regex::new(r"^WM_[A-Z_]+$").unwrap();
|
||||
static ref RE_RES_VAR: regex::Regex =
|
||||
regex::Regex::new(r#"\$(?:var|jsonvar|res|encrypted)\:"#).unwrap();
|
||||
}
|
||||
|
||||
/// Whether a job argument, as JSON text, holds a `$var:`/`$jsonvar:`/`$res:`/`$encrypted:`
|
||||
/// reference, which makes the worker interpolate the whole argument with the job's token,
|
||||
/// `$`-prefixed reserved variables included.
|
||||
pub fn arg_needs_interpolation(json: &str) -> bool {
|
||||
RE_RES_VAR.is_match(json)
|
||||
}
|
||||
|
||||
/// Escape a string so it can be safely embedded inside a single-quoted JS
|
||||
|
||||
@@ -193,7 +193,7 @@ pub enum ObjectType {
|
||||
DatatableMigration,
|
||||
}
|
||||
|
||||
pub const LATEST_GIT_SYNC_SCRIPT_PATH: &str = "hub/29151/sync-script-to-git-repo-windmill";
|
||||
pub const LATEST_GIT_SYNC_SCRIPT_PATH: &str = "hub/29785/sync-script-to-git-repo-windmill";
|
||||
|
||||
/// Hub script that applies a repository's state back into a workspace
|
||||
/// (the repo → Windmill / "pull" direction). Same script the UI runs from
|
||||
@@ -201,7 +201,7 @@ pub const LATEST_GIT_SYNC_SCRIPT_PATH: &str = "hub/29151/sync-script-to-git-repo
|
||||
/// ignores the slug, so the slug is kept free of characters that would be
|
||||
/// percent-encoded into the run URL (a `:` becomes `%3A`, which some hardened
|
||||
/// reverse proxies reject as double-encoding when the client re-encodes it).
|
||||
pub const GIT_SYNC_PULL_SCRIPT_PATH: &str = "hub/29150/git-sync-init-repository-windmill";
|
||||
pub const GIT_SYNC_PULL_SCRIPT_PATH: &str = "hub/29784/git-sync-init-repository-windmill";
|
||||
|
||||
/// Prefix used to identify fork workspaces. A workspace whose id starts with this string is a
|
||||
/// fork of another workspace.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//! to make them compatible with MCP tool naming requirements.
|
||||
|
||||
use super::types::SchemaType;
|
||||
use std::collections::HashSet;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use windmill_common::utils::calculate_hash;
|
||||
|
||||
/// Max tool name length. The MCP spec allows 64 chars, but some clients
|
||||
@@ -44,6 +44,89 @@ pub fn transform_path(path: &str, type_str: &str) -> String {
|
||||
format!("{}-{}{}", upper_prefix, truncated, hash_suffix)
|
||||
}
|
||||
|
||||
/// Name every script and flow a token can see, in the same order as `items`
|
||||
/// (`(item_type, path)` pairs).
|
||||
///
|
||||
/// An item is named after its last path segment, with parent segments prepended
|
||||
/// (`billing_send_email`) only while that name is shared with another item or with a
|
||||
/// `reserved` name. A name that is still shared once every segment is used falls back
|
||||
/// to the `s-`/`f-` encoding of `transform_path`, which is unique per item.
|
||||
///
|
||||
/// A short name is never one `parse_tool_prefix` accepts, so a call can tell the two
|
||||
/// schemes apart. Resolving a short name relies on an item's name depending only on
|
||||
/// the items whose last segment is one of `short_name_last_segments(name)`: keep any
|
||||
/// new disambiguation step confined to candidates that end with the item's own
|
||||
/// last segment.
|
||||
pub fn assign_tool_names(items: &[(&str, &str)], reserved: &HashSet<&str>) -> Vec<String> {
|
||||
let candidates: Vec<Vec<String>> = items
|
||||
.iter()
|
||||
.map(|(item_type, path)| name_candidates(item_type, path, reserved))
|
||||
.collect();
|
||||
let mut depth = vec![0usize; items.len()];
|
||||
loop {
|
||||
let mut holders: HashMap<&str, usize> = HashMap::new();
|
||||
for (c, d) in candidates.iter().zip(&depth) {
|
||||
*holders.entry(c[*d].as_str()).or_default() += 1;
|
||||
}
|
||||
let next: Vec<usize> = candidates
|
||||
.iter()
|
||||
.zip(&depth)
|
||||
.map(|(c, d)| {
|
||||
if holders[c[*d].as_str()] > 1 && d + 1 < c.len() {
|
||||
d + 1
|
||||
} else {
|
||||
*d
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
if next == depth {
|
||||
break;
|
||||
}
|
||||
depth = next;
|
||||
}
|
||||
candidates
|
||||
.into_iter()
|
||||
.zip(depth)
|
||||
.map(|(mut c, d)| c.swap_remove(d))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Every name `path` may get, shortest first, ending with its `transform_path` encoding.
|
||||
fn name_candidates(item_type: &str, path: &str, reserved: &HashSet<&str>) -> Vec<String> {
|
||||
let segments: Vec<&str> = path.split('/').collect();
|
||||
let mut candidates: Vec<String> = (1..=segments.len())
|
||||
.map(|k| segments[segments.len() - k..].join("_"))
|
||||
.filter(|name| {
|
||||
!name.is_empty()
|
||||
&& name.len() <= MAX_PATH_LENGTH
|
||||
&& name
|
||||
.chars()
|
||||
.all(|c| c.is_ascii_alphanumeric() || c == '_' || c == '-')
|
||||
&& !reserved.contains(name.as_str())
|
||||
&& parse_tool_prefix(name).is_err()
|
||||
})
|
||||
.collect();
|
||||
candidates.push(transform_path(path, item_type));
|
||||
candidates
|
||||
}
|
||||
|
||||
/// Whether `name` uses the `s-`/`f-`/`hs-` encoding rather than a short name.
|
||||
pub fn is_encoded_tool_name(name: &str) -> bool {
|
||||
parse_tool_prefix(name).is_ok()
|
||||
}
|
||||
|
||||
/// The last path segments an item named `name` by `assign_tool_names` can have:
|
||||
/// each `_`-separated suffix of the name, since segments may contain `_` themselves.
|
||||
/// None for a name longer than any short name: the suffixes of a caller-supplied
|
||||
/// name grow quadratically with its length.
|
||||
pub fn short_name_last_segments(name: &str) -> Vec<String> {
|
||||
if name.len() > MAX_PATH_LENGTH {
|
||||
return vec![];
|
||||
}
|
||||
let parts: Vec<&str> = name.split('_').collect();
|
||||
(0..parts.len()).map(|i| parts[i..].join("_")).collect()
|
||||
}
|
||||
|
||||
/// Transform the path for hub scripts
|
||||
///
|
||||
/// For short names (≤40 chars): `hs-{id}-{summary}`
|
||||
@@ -69,7 +152,11 @@ pub fn transform_hub_path(version_id: u64, summary: &str) -> String {
|
||||
/// Returns `(type_str, is_hub, is_hashed)`.
|
||||
/// Hashed names use an uppercase first character as the signal.
|
||||
pub fn parse_tool_prefix(name: &str) -> Result<(&str, bool, bool), String> {
|
||||
let is_hashed = name.chars().next().map(|c| c.is_ascii_uppercase()).unwrap_or(false);
|
||||
let is_hashed = name
|
||||
.chars()
|
||||
.next()
|
||||
.map(|c| c.is_ascii_uppercase())
|
||||
.unwrap_or(false);
|
||||
let lower = name.to_ascii_lowercase();
|
||||
let (type_str, is_hub) = if lower.starts_with("hs-") {
|
||||
("script", true)
|
||||
@@ -376,6 +463,81 @@ mod tests {
|
||||
assert!(!hashed);
|
||||
}
|
||||
|
||||
const UNIVERSE: &[(&str, &str)] = &[
|
||||
("script", "f/billing/send_email"),
|
||||
("script", "f/support/send_email"),
|
||||
("script", "f/q/billing_send_email"),
|
||||
("flow", "u/admin/onboard"),
|
||||
("script", "u/admin/onboard"),
|
||||
("script", "u/alice/report"),
|
||||
("script", "u/alice/listScripts"),
|
||||
("flow", "f/a_b/c"),
|
||||
("flow", "f/a/b_c"),
|
||||
("script", "f/x/c"),
|
||||
("script", "u/admin/b_c"),
|
||||
("script", "u/admin/s-legacy_looking"),
|
||||
];
|
||||
|
||||
#[test]
|
||||
fn test_assign_tool_names() {
|
||||
let reserved: HashSet<&str> = ["listScripts"].into_iter().collect();
|
||||
let names = assign_tool_names(UNIVERSE, &reserved);
|
||||
assert_eq!(
|
||||
names,
|
||||
vec![
|
||||
"f_billing_send_email".to_string(),
|
||||
"support_send_email".to_string(),
|
||||
"q_billing_send_email".to_string(),
|
||||
"f-u_admin_onboard".to_string(),
|
||||
"s-u_admin_onboard".to_string(),
|
||||
"report".to_string(),
|
||||
"alice_listScripts".to_string(),
|
||||
"f-f_a__b_c".to_string(),
|
||||
"f-f_a_b__c".to_string(),
|
||||
"x_c".to_string(),
|
||||
"admin_b_c".to_string(),
|
||||
"admin_s-legacy_looking".to_string(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/// A call resolves a short name from only the items whose last segment can end
|
||||
/// that name, so naming that subset must give every item the name it was listed
|
||||
/// under.
|
||||
#[test]
|
||||
fn test_short_names_resolve_from_last_segment_subset() {
|
||||
let reserved: HashSet<&str> = ["listScripts"].into_iter().collect();
|
||||
let names = assign_tool_names(UNIVERSE, &reserved);
|
||||
for (item, name) in UNIVERSE.iter().zip(&names) {
|
||||
if is_encoded_tool_name(name) {
|
||||
continue;
|
||||
}
|
||||
let segments = short_name_last_segments(name);
|
||||
let subset: Vec<(&str, &str)> = UNIVERSE
|
||||
.iter()
|
||||
.filter(|(_, p)| segments.iter().any(|s| p.ends_with(&format!("/{s}"))))
|
||||
.copied()
|
||||
.collect();
|
||||
let subset_names = assign_tool_names(&subset, &reserved);
|
||||
let resolved: Vec<_> = subset
|
||||
.iter()
|
||||
.zip(&subset_names)
|
||||
.filter(|(_, n)| *n == name)
|
||||
.map(|(i, _)| *i)
|
||||
.collect();
|
||||
assert_eq!(resolved, vec![*item], "{name}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_short_name_last_segments_bounded() {
|
||||
assert_eq!(
|
||||
short_name_last_segments("a_b_c"),
|
||||
vec!["a_b_c".to_string(), "b_c".to_string(), "c".to_string()]
|
||||
);
|
||||
assert!(short_name_last_segments(&"_".repeat(100_000)).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_reverse_transform_short_names() {
|
||||
let (type_str, path, is_hub) = reverse_transform("s-u_admin_script").unwrap();
|
||||
@@ -430,7 +592,10 @@ mod tests {
|
||||
#[test]
|
||||
fn test_extract_path_prefix_handles_hs_prefix() {
|
||||
// Hs- is 3 chars, not 2 — ensure the prefix is stripped correctly
|
||||
let hashed = transform_hub_path(12345, "a]very long hub script summary that exceeds the limit");
|
||||
let hashed = transform_hub_path(
|
||||
12345,
|
||||
"a]very long hub script summary that exceeds the limit",
|
||||
);
|
||||
let (_, is_hub, is_hashed) = parse_tool_prefix(&hashed).unwrap();
|
||||
assert!(is_hub);
|
||||
assert!(is_hashed);
|
||||
|
||||
@@ -145,7 +145,8 @@ pub struct ItemSchema {
|
||||
|
||||
/// Trait for objects that can be converted to MCP tools
|
||||
pub trait ToolableItem {
|
||||
/// Get the MCP-compatible tool name (path transformed with escaping/hashing)
|
||||
/// Get the `s-`/`f-`/`hs-` encoded tool name (path transformed with escaping/hashing).
|
||||
/// Scripts and flows are listed under `assign_tool_names` instead.
|
||||
fn get_transformed_path(&self) -> String;
|
||||
/// Get the original full path of this item (for display in tool title)
|
||||
fn get_full_path(&self) -> &str;
|
||||
|
||||
@@ -40,6 +40,9 @@ pub enum PathFilter<'a> {
|
||||
/// `is_resource_allowed`: a `*` pattern matches everything, an empty list
|
||||
/// matches nothing.
|
||||
Patterns(&'a [String]),
|
||||
/// Paths whose last segment is one of these — the candidates a short tool name
|
||||
/// can resolve to.
|
||||
LastSegment(&'a [String]),
|
||||
}
|
||||
|
||||
/// Authentication context required by the MCP server
|
||||
@@ -106,6 +109,18 @@ pub trait McpBackend: Send + Sync + Clone + 'static {
|
||||
path_filter: Option<PathFilter<'_>>,
|
||||
) -> BackendResult<Vec<FlowInfo>>;
|
||||
|
||||
/// Every path of `item_type` ("script" or "flow") the listing would include, with
|
||||
/// no fetch cap: tool names are disambiguated against all of them, not only the
|
||||
/// items that make it into the capped listing.
|
||||
async fn list_runnable_paths(
|
||||
&self,
|
||||
auth: &Self::Auth,
|
||||
workspace_id: &str,
|
||||
item_type: &str,
|
||||
favorites_only: bool,
|
||||
path_filter: Option<PathFilter<'_>>,
|
||||
) -> BackendResult<Vec<String>>;
|
||||
|
||||
/// List resource types in workspace
|
||||
async fn list_resource_types(
|
||||
&self,
|
||||
|
||||
@@ -6,8 +6,9 @@
|
||||
use crate::common::schema::extract_resource_types_from_schema;
|
||||
use crate::common::scope::parse_mcp_scopes;
|
||||
use crate::common::transform::{
|
||||
extract_hub_version_id_from_hashed, extract_path_prefix_from_hashed, parse_tool_prefix,
|
||||
reverse_transform, reverse_transform_key,
|
||||
assign_tool_names, extract_hub_version_id_from_hashed, extract_path_prefix_from_hashed,
|
||||
is_encoded_tool_name, parse_tool_prefix, reverse_transform, reverse_transform_key,
|
||||
short_name_last_segments,
|
||||
};
|
||||
use crate::common::types::{
|
||||
McpToken, MultiWorkspaceMcp, ResourceInfo, SchemaType, ToolableItem, WorkspaceId,
|
||||
@@ -658,6 +659,51 @@ impl<B: McpBackend> ServerHandler for Runner<B> {
|
||||
}
|
||||
|
||||
impl<B: McpBackend> Runner<B> {
|
||||
/// Name every script and flow the token can see under the given path filters, as
|
||||
/// `(item_type, path, tool_name)`. Listing and calling must both go through here
|
||||
/// so that a listed name resolves to the item it was listed for.
|
||||
async fn name_runnables(
|
||||
&self,
|
||||
auth: &B::Auth,
|
||||
workspace_id: &str,
|
||||
scope_config: &crate::common::scope::McpScopeConfig,
|
||||
script_filter: Option<PathFilter<'_>>,
|
||||
flow_filter: Option<PathFilter<'_>>,
|
||||
) -> Result<Vec<(&'static str, String, String)>, ErrorData> {
|
||||
let favorites_only = scope_config.favorites;
|
||||
let (scripts, flows) = tokio::try_join!(
|
||||
self.backend.list_runnable_paths(
|
||||
auth,
|
||||
workspace_id,
|
||||
"script",
|
||||
favorites_only,
|
||||
script_filter
|
||||
),
|
||||
self.backend.list_runnable_paths(
|
||||
auth,
|
||||
workspace_id,
|
||||
"flow",
|
||||
favorites_only,
|
||||
flow_filter
|
||||
),
|
||||
)?;
|
||||
let items: Vec<(&'static str, String)> = scripts
|
||||
.into_iter()
|
||||
.map(|p| ("script", p))
|
||||
.chain(flows.into_iter().map(|p| ("flow", p)))
|
||||
.filter(|(t, p)| !scope_config.granular || scope_config.is_allowed(t, p))
|
||||
.collect();
|
||||
let endpoint_tools = self.backend.all_endpoint_tools();
|
||||
let reserved: HashSet<&str> = endpoint_tools.iter().map(|t| t.name.as_ref()).collect();
|
||||
let pairs: Vec<(&str, &str)> = items.iter().map(|(t, p)| (*t, p.as_str())).collect();
|
||||
let names = assign_tool_names(&pairs, &reserved);
|
||||
Ok(items
|
||||
.into_iter()
|
||||
.zip(names)
|
||||
.map(|((t, p), n)| (t, p, n))
|
||||
.collect())
|
||||
}
|
||||
|
||||
/// List tools for a single, bound workspace (URL-path or token-bound).
|
||||
async fn list_tools_single(
|
||||
&self,
|
||||
@@ -686,11 +732,12 @@ impl<B: McpBackend> Runner<B> {
|
||||
.granular
|
||||
.then(|| PathFilter::Patterns(scope_config.flows.as_slice()));
|
||||
|
||||
let (scripts, flows, resource_types, hub_scripts) = tokio::try_join!(
|
||||
let (scripts, flows, named, resource_types, hub_scripts) = tokio::try_join!(
|
||||
self.backend
|
||||
.list_scripts(auth, workspace_id, favorites_only, script_filter),
|
||||
self.backend
|
||||
.list_flows(auth, workspace_id, favorites_only, flow_filter),
|
||||
self.name_runnables(auth, workspace_id, scope_config, script_filter, flow_filter),
|
||||
self.backend.list_resource_types(auth, workspace_id),
|
||||
async {
|
||||
if let Some(ref apps) = scope_config.hub_apps {
|
||||
@@ -746,9 +793,22 @@ impl<B: McpBackend> Runner<B> {
|
||||
let resources_cache: HashMap<String, Vec<ResourceInfo>> =
|
||||
resource_results.into_iter().collect();
|
||||
|
||||
let names: HashMap<(&str, &str), &str> = named
|
||||
.iter()
|
||||
.map(|(t, p, n)| ((*t, p.as_str()), n.as_str()))
|
||||
.collect();
|
||||
// An item created between the two queries has no short name yet.
|
||||
let name_of = |item: &dyn ToolableItem| {
|
||||
names
|
||||
.get(&(item.item_type(), item.get_full_path()))
|
||||
.map(|n| n.to_string())
|
||||
.unwrap_or_else(|| item.get_transformed_path())
|
||||
};
|
||||
|
||||
for script in &filtered_scripts {
|
||||
tools.push(create_tool_from_item(
|
||||
script,
|
||||
name_of(script),
|
||||
self.backend.as_ref(),
|
||||
&resources_cache,
|
||||
&resource_types,
|
||||
@@ -758,6 +818,7 @@ impl<B: McpBackend> Runner<B> {
|
||||
for flow in &filtered_flows {
|
||||
tools.push(create_tool_from_item(
|
||||
flow,
|
||||
name_of(flow),
|
||||
self.backend.as_ref(),
|
||||
&resources_cache,
|
||||
&resource_types,
|
||||
@@ -767,6 +828,7 @@ impl<B: McpBackend> Runner<B> {
|
||||
for hub_script in &hub_scripts {
|
||||
tools.push(create_tool_from_item(
|
||||
hub_script,
|
||||
hub_script.get_transformed_path(),
|
||||
self.backend.as_ref(),
|
||||
&resources_cache,
|
||||
&resource_types,
|
||||
@@ -847,49 +909,71 @@ impl<B: McpBackend> Runner<B> {
|
||||
}
|
||||
|
||||
// Resolve the tool name to (type, path, is_hub)
|
||||
let (type_str, is_hub, is_hashed) = parse_tool_prefix(name.as_ref()).map_err(|e| {
|
||||
ErrorData::internal_error(format!("Failed to parse tool name: {}", e), None)
|
||||
})?;
|
||||
|
||||
let (tool_type, path, is_hub) = if !is_hashed {
|
||||
reverse_transform(name.as_ref()).map_err(|e| {
|
||||
ErrorData::internal_error(format!("Failed to parse tool name: {}", e), None)
|
||||
})?
|
||||
} else if is_hub {
|
||||
let version_id = extract_hub_version_id_from_hashed(name.as_ref()).map_err(|e| {
|
||||
ErrorData::internal_error(format!("Failed to extract hub version_id: {}", e), None)
|
||||
})?;
|
||||
(type_str, version_id, true)
|
||||
let (tool_type, path, is_hub) = if !is_encoded_tool_name(name.as_ref()) {
|
||||
let segments = short_name_last_segments(name.as_ref());
|
||||
let filter = Some(PathFilter::LastSegment(segments.as_slice()));
|
||||
let named = self
|
||||
.name_runnables(auth, workspace_id, scope_config, filter, filter)
|
||||
.await?;
|
||||
let (tool_type, path, _) = named
|
||||
.into_iter()
|
||||
.find(|(_, _, n)| n == name.as_ref())
|
||||
.ok_or_else(|| {
|
||||
ErrorData::internal_error(format!("No tool named '{}'", name), None)
|
||||
})?;
|
||||
(tool_type, path, false)
|
||||
} else {
|
||||
let path_prefix = extract_path_prefix_from_hashed(name.as_ref());
|
||||
let path_filter = path_prefix.as_deref().map(PathFilter::Prefix);
|
||||
let favorites_only = scope_config.favorites;
|
||||
let matched_path = if type_str == "script" {
|
||||
find_matching_path(
|
||||
self.backend
|
||||
.list_scripts(auth, workspace_id, favorites_only, path_filter)
|
||||
.await
|
||||
.map_err(|e| ErrorData::internal_error(e.message, None))?,
|
||||
name.as_ref(),
|
||||
)
|
||||
} else {
|
||||
find_matching_path(
|
||||
self.backend
|
||||
.list_flows(auth, workspace_id, favorites_only, path_filter)
|
||||
.await
|
||||
.map_err(|e| ErrorData::internal_error(e.message, None))?,
|
||||
name.as_ref(),
|
||||
)
|
||||
};
|
||||
|
||||
let matched_path = matched_path.ok_or_else(|| {
|
||||
ErrorData::internal_error(
|
||||
format!("No {} found matching hashed tool name '{}'", type_str, name),
|
||||
None,
|
||||
)
|
||||
// The `s-`/`f-`/`hs-` encoding: what hub scripts and items whose short
|
||||
// names all collide are listed under, and what clients listed before short
|
||||
// names existed still call.
|
||||
let (type_str, is_hub, is_hashed) = parse_tool_prefix(name.as_ref()).map_err(|e| {
|
||||
ErrorData::internal_error(format!("Failed to parse tool name: {}", e), None)
|
||||
})?;
|
||||
|
||||
(type_str, matched_path, false)
|
||||
if !is_hashed {
|
||||
reverse_transform(name.as_ref()).map_err(|e| {
|
||||
ErrorData::internal_error(format!("Failed to parse tool name: {}", e), None)
|
||||
})?
|
||||
} else if is_hub {
|
||||
let version_id =
|
||||
extract_hub_version_id_from_hashed(name.as_ref()).map_err(|e| {
|
||||
ErrorData::internal_error(
|
||||
format!("Failed to extract hub version_id: {}", e),
|
||||
None,
|
||||
)
|
||||
})?;
|
||||
(type_str, version_id, true)
|
||||
} else {
|
||||
let path_prefix = extract_path_prefix_from_hashed(name.as_ref());
|
||||
let path_filter = path_prefix.as_deref().map(PathFilter::Prefix);
|
||||
let favorites_only = scope_config.favorites;
|
||||
let matched_path = if type_str == "script" {
|
||||
find_matching_path(
|
||||
self.backend
|
||||
.list_scripts(auth, workspace_id, favorites_only, path_filter)
|
||||
.await
|
||||
.map_err(|e| ErrorData::internal_error(e.message, None))?,
|
||||
name.as_ref(),
|
||||
)
|
||||
} else {
|
||||
find_matching_path(
|
||||
self.backend
|
||||
.list_flows(auth, workspace_id, favorites_only, path_filter)
|
||||
.await
|
||||
.map_err(|e| ErrorData::internal_error(e.message, None))?,
|
||||
name.as_ref(),
|
||||
)
|
||||
};
|
||||
|
||||
let matched_path = matched_path.ok_or_else(|| {
|
||||
ErrorData::internal_error(
|
||||
format!("No {} found matching hashed tool name '{}'", type_str, name),
|
||||
None,
|
||||
)
|
||||
})?;
|
||||
|
||||
(type_str, matched_path, false)
|
||||
}
|
||||
};
|
||||
|
||||
// Validate script/flow scope
|
||||
|
||||
@@ -178,18 +178,18 @@ fn omission_hint(input_schema: &Map<String, Value>, item_type: &str) -> Option<S
|
||||
))
|
||||
}
|
||||
|
||||
/// Create an MCP Tool from a ToolableItem
|
||||
/// Create an MCP Tool named `path` from a ToolableItem
|
||||
///
|
||||
/// The resources_cache should be pre-populated with all resource types
|
||||
/// that may be referenced by the item's schema.
|
||||
pub fn create_tool_from_item<T: ToolableItem, B: McpBackend>(
|
||||
item: &T,
|
||||
path: String,
|
||||
backend: &B,
|
||||
resources_cache: &HashMap<String, Vec<ResourceInfo>>,
|
||||
resources_types: &[ResourceType],
|
||||
) -> Tool {
|
||||
let is_hub = item.is_hub();
|
||||
let path = item.get_transformed_path();
|
||||
let item_type = item.item_type();
|
||||
let mut description = format!(
|
||||
"This is a {} named `{}` with the following description: `{}`.{}",
|
||||
|
||||
@@ -17,6 +17,7 @@ use windmill_api_auth::{
|
||||
};
|
||||
use windmill_common::db::DB;
|
||||
use windmill_common::per_minute_counter::PerMinuteCounter;
|
||||
use windmill_common::scopes::ScopeDefinition;
|
||||
use windmill_common::ssrf::{
|
||||
is_private_ip, private_git_host_allowed, private_git_host_hint, GitRemoteCaller,
|
||||
};
|
||||
@@ -236,6 +237,10 @@ pub struct CreateResource {
|
||||
pub labels: Option<Vec<String>>,
|
||||
#[serde(default)]
|
||||
pub ws_specific: Option<bool>,
|
||||
/// `ai_agent` only: keep the identity `value.on_behalf_of` names, for a caller allowed to
|
||||
/// (see `resolve_agent_on_behalf_of`).
|
||||
#[serde(default)]
|
||||
pub preserve_on_behalf_of: Option<bool>,
|
||||
}
|
||||
#[derive(Deserialize)]
|
||||
struct EditResource {
|
||||
@@ -245,6 +250,7 @@ struct EditResource {
|
||||
resource_type: Option<String>,
|
||||
labels: Option<Vec<String>>,
|
||||
ws_specific: Option<bool>,
|
||||
preserve_on_behalf_of: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
@@ -902,18 +908,61 @@ pub async fn transform_json_value(
|
||||
/// RLS resolves a reference as the token's user, not as the token: a token scoped to one
|
||||
/// resource would otherwise read, through that resource, every variable or resource its
|
||||
/// user can. Job tokens carry no scopes, so what a runnable resolves is unaffected.
|
||||
/// `resource_path` is the resource being expanded: its own linked secrets
|
||||
/// ([`is_owned_linked_var`]) are covered by the read of it.
|
||||
/// `resource_path` is the resource being expanded: see [`check_resource_var_ref_scope`].
|
||||
fn check_interpolation_scope(
|
||||
db_with_opt_authed: &DbWithOptAuthed<'_, ApiAuthed>,
|
||||
domain: &str,
|
||||
path: &str,
|
||||
resource_path: Option<&str>,
|
||||
) -> Result<()> {
|
||||
match db_with_opt_authed.authed() {
|
||||
Some(_) if resource_path.is_some_and(|r| is_owned_linked_var(r, path)) => Ok(()),
|
||||
Some(authed) => check_scopes(authed, || format!("{domain}:read:{path}")),
|
||||
None => Ok(()),
|
||||
match (db_with_opt_authed.authed(), resource_path) {
|
||||
(Some(authed), Some(r)) if domain == "variables" => {
|
||||
check_resource_var_ref_scope(authed, r, path)
|
||||
}
|
||||
(Some(authed), _) => check_scopes(authed, || format!("{domain}:read:{path}")),
|
||||
(None, _) => Ok(()),
|
||||
}
|
||||
}
|
||||
|
||||
/// The scope a token needs to resolve variable `var_path` referenced by resource
|
||||
/// `resource_path`: `variables:read` on it, unless it is the resource's own linked secret
|
||||
/// ([`is_owned_linked_var`]) or a wildcard pattern of the token's `resources:` scopes
|
||||
/// matches it. An exact path, or a scope naming no path at all, grants no variable: RLS
|
||||
/// lets the token resolve any variable its user can read.
|
||||
pub fn check_resource_var_ref_scope(
|
||||
authed: &ApiAuthed,
|
||||
resource_path: &str,
|
||||
var_path: &str,
|
||||
) -> Result<()> {
|
||||
if is_owned_linked_var(resource_path, var_path) {
|
||||
return Ok(());
|
||||
}
|
||||
let denied = match check_scopes(authed, || format!("variables:read:{var_path}")) {
|
||||
Ok(()) => return Ok(()),
|
||||
Err(e) => e,
|
||||
};
|
||||
let required = ScopeDefinition::new("variables", "read", None, Some(vec![var_path.into()]));
|
||||
let covered = authed.scopes.iter().flatten().any(|scope| {
|
||||
let Ok(scope) = ScopeDefinition::from_scope_string(scope) else {
|
||||
return false;
|
||||
};
|
||||
if scope.domain != "resources" {
|
||||
return false;
|
||||
}
|
||||
let patterns = scope
|
||||
.resource
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.filter(|r| r.contains('*'))
|
||||
.collect::<Vec<_>>();
|
||||
!patterns.is_empty()
|
||||
&& ScopeDefinition::new("variables", &scope.action, None, Some(patterns))
|
||||
.includes(&required)
|
||||
});
|
||||
if covered {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(denied)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1254,7 +1303,20 @@ async fn create_resource(
|
||||
check_path_conflict(&mut tx, &w_id, &resource.path).await?;
|
||||
}
|
||||
|
||||
let res_value = resource.value.unwrap_or_default();
|
||||
let mut res_value = resource.value.unwrap_or_default();
|
||||
if resource.resource_type == "ai_agent" {
|
||||
res_value = resolve_agent_raw_value(
|
||||
&mut tx,
|
||||
&authed,
|
||||
&db,
|
||||
&w_id,
|
||||
&resource.path,
|
||||
&res_value,
|
||||
resource.preserve_on_behalf_of.unwrap_or(false),
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
let raw_json = sqlx::types::Json(res_value.as_ref());
|
||||
|
||||
if resource.path.starts_with("f/app_themes/") {
|
||||
@@ -2095,9 +2157,6 @@ async fn update_resource(
|
||||
if let Some(npath) = &ns.path {
|
||||
sqlb.set_str("path", npath);
|
||||
}
|
||||
if let Some(nvalue) = &ns.value {
|
||||
sqlb.set_str("value", nvalue.to_string());
|
||||
}
|
||||
if let Some(nrt) = &ns.resource_type {
|
||||
sqlb.set_str("resource_type", nrt);
|
||||
}
|
||||
@@ -2205,6 +2264,49 @@ async fn update_resource(
|
||||
}
|
||||
}
|
||||
|
||||
lock_resource_row(&mut tx, &w_id, path).await?;
|
||||
let current = sqlx::query!(
|
||||
"SELECT resource_type, value AS \"value: sqlx::types::Json<Box<RawValue>>\"
|
||||
FROM resource WHERE workspace_id = $1 AND path = $2",
|
||||
&w_id,
|
||||
path
|
||||
)
|
||||
.fetch_optional(&mut *tx)
|
||||
.await?;
|
||||
let resource_type = ns
|
||||
.resource_type
|
||||
.clone()
|
||||
.or_else(|| current.as_ref().map(|c| c.resource_type.clone()));
|
||||
// Retyping a resource into an agent makes its value an agent's, identity included, so it is
|
||||
// resolved as a written one is.
|
||||
let retyped = ns.resource_type.as_deref() == Some("ai_agent")
|
||||
&& current
|
||||
.as_ref()
|
||||
.is_some_and(|c| c.resource_type != "ai_agent");
|
||||
let nvalue = match &ns.value {
|
||||
Some(v) => Some(v.clone()),
|
||||
None if retyped => current.and_then(|c| c.value).map(|v| v.0),
|
||||
None => None,
|
||||
};
|
||||
if let Some(nvalue) = nvalue {
|
||||
let nvalue = if resource_type.as_deref() == Some("ai_agent") {
|
||||
resolve_agent_raw_value(
|
||||
&mut tx,
|
||||
&authed,
|
||||
&db,
|
||||
&w_id,
|
||||
ns.path.as_deref().unwrap_or(path),
|
||||
&nvalue,
|
||||
ns.preserve_on_behalf_of.unwrap_or(false),
|
||||
false,
|
||||
)
|
||||
.await?
|
||||
} else {
|
||||
nvalue
|
||||
};
|
||||
sqlb.set_str("value", nvalue.to_string());
|
||||
}
|
||||
|
||||
let sql = sqlb.sql().map_err(|e| Error::internal_err(e.to_string()))?;
|
||||
let npath_o: Option<String> = sqlx::query_scalar(&sql)
|
||||
.fetch_optional(&mut *tx)
|
||||
@@ -2374,6 +2476,110 @@ async fn update_resource_value(
|
||||
Ok(format!("value of resource {} updated", path))
|
||||
}
|
||||
|
||||
/// Rewrites the identity an `ai_agent` runs as (`value.on_behalf_of`), resolved on every write of
|
||||
/// it as a flow's `on_behalf_of` is on every deploy. It exists only while the agent's
|
||||
/// `run_on_behalf_of` is set: then the writer's own, unless one allowed to keep the one the value
|
||||
/// names asks to, and a folder's default for a new agent. The value is written by anyone who can
|
||||
/// write the agent, so the key it arrives with is only a request.
|
||||
async fn resolve_agent_on_behalf_of(
|
||||
tx: &mut Transaction<'_, Postgres>,
|
||||
authed: &ApiAuthed,
|
||||
db: &DB,
|
||||
w_id: &str,
|
||||
path: &str,
|
||||
value: &mut serde_json::Value,
|
||||
preserve: bool,
|
||||
created: bool,
|
||||
) -> Result<()> {
|
||||
let Some(obj) = value.as_object_mut() else {
|
||||
return Ok(());
|
||||
};
|
||||
let mut requested = obj
|
||||
.remove("on_behalf_of")
|
||||
.and_then(|v| v.as_str().map(str::to_string));
|
||||
if obj.get("run_on_behalf_of").and_then(|v| v.as_bool()) != Some(true) {
|
||||
return Ok(());
|
||||
}
|
||||
let mut preserve = preserve;
|
||||
let explicit =
|
||||
requested.is_some() && preserve && windmill_common::can_preserve_on_behalf_of(authed);
|
||||
if created && !explicit && windmill_common::can_preserve_on_behalf_of(authed) {
|
||||
if let Some((_, folder_default)) =
|
||||
windmill_common::folders::resolve_folder_default_on_behalf_of(db, w_id, path).await?
|
||||
{
|
||||
requested = Some(folder_default);
|
||||
preserve = true;
|
||||
}
|
||||
}
|
||||
let own = windmill_common::users::username_to_permissioned_as(&authed.username);
|
||||
// Nothing requested is the writer's own.
|
||||
let resolved = windmill_common::resolve_on_behalf_of(
|
||||
None,
|
||||
Some(requested.as_deref().unwrap_or(&own)),
|
||||
preserve,
|
||||
authed,
|
||||
w_id,
|
||||
db,
|
||||
)
|
||||
.await?;
|
||||
if let Some(resolved) = resolved.as_ref() {
|
||||
obj.insert("on_behalf_of".to_string(), resolved.clone().into());
|
||||
}
|
||||
if let Some(kept) = windmill_common::check_on_behalf_of_preservation(
|
||||
resolved.as_deref(),
|
||||
preserve,
|
||||
authed,
|
||||
&own,
|
||||
) {
|
||||
audit_log(
|
||||
&mut **tx,
|
||||
authed,
|
||||
"resources.on_behalf_of",
|
||||
if created {
|
||||
ActionKind::Create
|
||||
} else {
|
||||
ActionKind::Update
|
||||
},
|
||||
w_id,
|
||||
Some(path),
|
||||
Some([("on_behalf_of", kept.as_str())].into()),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Held until the write commits: whether a value is resolved as an agent's depends on the type
|
||||
/// read after this, and a concurrent retype into an agent must not land between the two.
|
||||
async fn lock_resource_row(
|
||||
tx: &mut Transaction<'_, Postgres>,
|
||||
w_id: &str,
|
||||
path: &str,
|
||||
) -> Result<()> {
|
||||
sqlx::query("SELECT 1 FROM resource WHERE workspace_id = $1 AND path = $2 FOR UPDATE")
|
||||
.bind(w_id)
|
||||
.bind(path)
|
||||
.execute(&mut **tx)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// `resolve_agent_on_behalf_of` on a value as the request carried it.
|
||||
async fn resolve_agent_raw_value(
|
||||
tx: &mut Transaction<'_, Postgres>,
|
||||
authed: &ApiAuthed,
|
||||
db: &DB,
|
||||
w_id: &str,
|
||||
path: &str,
|
||||
value: &RawValue,
|
||||
preserve: bool,
|
||||
created: bool,
|
||||
) -> Result<Box<RawValue>> {
|
||||
let mut parsed: serde_json::Value = serde_json::from_str(value.get())?;
|
||||
resolve_agent_on_behalf_of(tx, authed, db, w_id, path, &mut parsed, preserve, created).await?;
|
||||
Ok(serde_json::value::to_raw_value(&parsed)?)
|
||||
}
|
||||
|
||||
/// Write a resource's value and run everything that has to follow it: a version row, the audit
|
||||
/// entry, deployment metadata, the webhook, and dependent CI tests. Shared with version restore
|
||||
/// so a restored value is indistinguishable downstream from any other edit.
|
||||
@@ -2402,6 +2608,21 @@ async fn set_resource_value(
|
||||
|
||||
let mut tx = user_db.clone().begin(authed).await?;
|
||||
|
||||
let mut value = value;
|
||||
if let Some(v) = value.as_mut() {
|
||||
lock_resource_row(&mut tx, w_id, path).await?;
|
||||
let resource_type = sqlx::query_scalar!(
|
||||
"SELECT resource_type FROM resource WHERE workspace_id = $1 AND path = $2",
|
||||
w_id,
|
||||
path
|
||||
)
|
||||
.fetch_optional(&mut *tx)
|
||||
.await?;
|
||||
if resource_type.as_deref() == Some("ai_agent") {
|
||||
resolve_agent_on_behalf_of(&mut tx, authed, db, w_id, path, v, false, false).await?;
|
||||
}
|
||||
}
|
||||
|
||||
// `RETURNING resource_type` rather than a second lookup: the advisory below has to know the
|
||||
// type to leave `state` and `cache` alone, and this statement already runs.
|
||||
let updated = sqlx::query_scalar!(
|
||||
|
||||
@@ -19,6 +19,7 @@ use std::{collections::HashMap, sync::Arc, time::Duration};
|
||||
use uuid::Uuid;
|
||||
use windmill_ai::{ai_types::OpenAIToolCall, query_builder::StreamEventSink, types::*};
|
||||
use windmill_common::jobs::JobPayload;
|
||||
use windmill_common::variables::arg_needs_interpolation;
|
||||
|
||||
#[cfg(feature = "mcp")]
|
||||
use windmill_mcp::McpClient;
|
||||
@@ -153,6 +154,8 @@ pub async fn execute_tool_calls(
|
||||
final_events_str,
|
||||
)
|
||||
.await?;
|
||||
} else if tool.module.is_some() && interpolating_args(tool_call) {
|
||||
refuse_tool_call(&mut ctx, tool_call, &mut messages, final_events_str).await?;
|
||||
} else if tool.module.is_some() {
|
||||
let mut batch = vec![(tool_call, tool)];
|
||||
while let Some(next_call) = calls.peek() {
|
||||
@@ -168,6 +171,9 @@ pub async fn execute_tool_calls(
|
||||
}) else {
|
||||
break;
|
||||
};
|
||||
if interpolating_args(next_call) {
|
||||
break;
|
||||
}
|
||||
batch.push((calls.next().unwrap(), next_tool));
|
||||
}
|
||||
execute_windmill_tools(&mut ctx, &batch, actions, &mut messages, final_events_str)
|
||||
@@ -189,6 +195,44 @@ pub async fn execute_tool_calls(
|
||||
Ok((messages, final_content, used_structured_output_tool))
|
||||
}
|
||||
|
||||
/// Whether the model wrote an argument the tool's job would interpolate with the agent's token,
|
||||
/// which may be an identity it runs on behalf of. Only the step's own input transforms may name
|
||||
/// variables and resources; the model's arguments are text from whoever talks to it.
|
||||
fn interpolating_args(tool_call: &OpenAIToolCall) -> bool {
|
||||
serde_json::from_str::<serde_json::Value>(&tool_call.function.arguments)
|
||||
.is_ok_and(|v| arg_needs_interpolation(&v.to_string()))
|
||||
}
|
||||
|
||||
async fn refuse_tool_call(
|
||||
ctx: &mut ToolExecutionContext<'_>,
|
||||
tool_call: &OpenAIToolCall,
|
||||
messages: &mut Vec<OpenAIMessage>,
|
||||
final_events_str: &mut String,
|
||||
) -> Result<(), Error> {
|
||||
let error_msg = "Tool call refused: its arguments cannot reference variables or resources \
|
||||
($var:, $jsonvar:, $res:, $encrypted:)"
|
||||
.to_string();
|
||||
messages.push(OpenAIMessage {
|
||||
role: "tool".to_string(),
|
||||
content: Some(OpenAIContent::Text(error_msg.clone())),
|
||||
tool_call_id: Some(tool_call.id.clone()),
|
||||
..Default::default()
|
||||
});
|
||||
if let Some(stream_event_processor) = ctx.stream_event_processor {
|
||||
let event = StreamingEvent::ToolResult {
|
||||
call_id: tool_call.id.clone(),
|
||||
function_name: tool_call.function.name.clone(),
|
||||
result: error_msg.clone(),
|
||||
success: false,
|
||||
};
|
||||
stream_event_processor.send(event, final_events_str).await?;
|
||||
}
|
||||
let (content, extras) = windmill_tool_row(tool_call, false, &error_msg);
|
||||
let agent_job_id = ctx.job.id;
|
||||
add_tool_message_to_chat(ctx, Some(agent_job_id), &content, false, Some(extras)).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Execute an MCP tool call
|
||||
async fn execute_mcp_tool_call(
|
||||
ctx: &mut ToolExecutionContext<'_>,
|
||||
@@ -618,10 +662,8 @@ async fn enqueue_windmill_tool(
|
||||
// narrows that further.
|
||||
windmill_common::scopes::intersect_job_token_scopes(
|
||||
ctx.job.job_token_scopes.as_deref(),
|
||||
windmill_common::scopes::step_job_token_scopes(
|
||||
tool_module.job_token_scopes.as_deref(),
|
||||
)
|
||||
.as_deref(),
|
||||
windmill_common::scopes::step_job_token_scopes(tool_module.job_token_scopes.as_deref())
|
||||
.as_deref(),
|
||||
)
|
||||
.as_deref(),
|
||||
)
|
||||
@@ -1051,7 +1093,7 @@ async fn add_tool_message_to_chat(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{extract_ai_agent_output, windmill_tool_row};
|
||||
use super::{extract_ai_agent_output, interpolating_args, windmill_tool_row};
|
||||
use serde_json::value::RawValue;
|
||||
use windmill_ai::ai_types::{OpenAIFunction, OpenAIToolCall};
|
||||
|
||||
@@ -1088,6 +1130,21 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_model_written_reference_is_caught_however_it_is_spelled() {
|
||||
let call = |arguments: &str| OpenAIToolCall {
|
||||
id: "call_1".to_string(),
|
||||
function: OpenAIFunction { name: "t".to_string(), arguments: arguments.to_string() },
|
||||
r#type: "function".to_string(),
|
||||
extra_content: None,
|
||||
};
|
||||
assert!(interpolating_args(&call(r#"{"x":"$var:u/a/s"}"#)));
|
||||
assert!(interpolating_args(&call(
|
||||
r#"{"x":{"y":["\u0024res:u/a/r"]}}"#
|
||||
)));
|
||||
assert!(!interpolating_args(&call(r#"{"x":"$5 and var: 3"}"#)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extracts_only_the_output_of_an_agent_result() {
|
||||
let envelope = RawValue::from_string(
|
||||
|
||||
@@ -13,6 +13,7 @@ use sqlx::types::Json;
|
||||
use sqlx::{Pool, Postgres};
|
||||
use tokio::process::Command;
|
||||
use tokio::{fs::File, io::AsyncReadExt};
|
||||
use windmill_common::variables::arg_needs_interpolation;
|
||||
|
||||
use windmill_common::flows::Step;
|
||||
use windmill_common::global_settings::NSJAIL_TMP_BACKING_DISK;
|
||||
@@ -173,15 +174,11 @@ pub async fn write_file_binary(dir: &str, path: &str, content: &[u8]) -> error::
|
||||
Ok(file)
|
||||
}
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref RE_RES_VAR: Regex = Regex::new(r#"\$(?:var|jsonvar|res|encrypted)\:"#).unwrap();
|
||||
}
|
||||
|
||||
/// Returns true if any value in `vs` contains a `$var:`/`$jsonvar:`/`$res:`/`$encrypted:`
|
||||
/// reference that would need interpolation by `transform_json`. Cheap pre-check that
|
||||
/// callers can use to skip the DB roundtrip + clone path when nothing requires resolution.
|
||||
pub(crate) fn map_needs_resolution(vs: &HashMap<String, Box<RawValue>>) -> bool {
|
||||
vs.values().any(|v| (*RE_RES_VAR).is_match(v.get()))
|
||||
vs.values().any(|v| arg_needs_interpolation(v.get()))
|
||||
}
|
||||
|
||||
pub async fn transform_json<'a>(
|
||||
@@ -194,7 +191,7 @@ pub async fn transform_json<'a>(
|
||||
let mut has_match = false;
|
||||
for (_, v) in vs {
|
||||
let inner_vs = v.get();
|
||||
if (*RE_RES_VAR).is_match(inner_vs) {
|
||||
if arg_needs_interpolation(inner_vs) {
|
||||
has_match = true;
|
||||
break;
|
||||
}
|
||||
@@ -205,7 +202,7 @@ pub async fn transform_json<'a>(
|
||||
let mut r = HashMap::new();
|
||||
for (k, v) in vs {
|
||||
let inner_vs = v.get();
|
||||
if (*RE_RES_VAR).is_match(inner_vs) {
|
||||
if arg_needs_interpolation(inner_vs) {
|
||||
let value = serde_json::from_str(inner_vs).map_err(|e| {
|
||||
error::Error::internal_err(format!("Error while parsing inner arg: {e:#}"))
|
||||
})?;
|
||||
@@ -232,7 +229,7 @@ pub async fn transform_json_as_values<'a>(
|
||||
let mut r: HashMap<String, serde_json::Value> = HashMap::new();
|
||||
for (k, v) in vs {
|
||||
let inner_vs = v.get();
|
||||
if (*RE_RES_VAR).is_match(inner_vs) {
|
||||
if arg_needs_interpolation(inner_vs) {
|
||||
let value = serde_json::from_str(inner_vs).map_err(|e| {
|
||||
error::Error::internal_err(format!("Error while parsing inner arg: {e:#}"))
|
||||
})?;
|
||||
|
||||
@@ -7245,6 +7245,33 @@ pub async fn parse_sig_of_lang(
|
||||
})
|
||||
}
|
||||
|
||||
/// Inline runs happen outside any worker's job loop, so they get no job dir from it. Executors
|
||||
/// write there (DuckDB's spill and result files), so each run needs its own: an empty one
|
||||
/// resolves to `/`, shared by every concurrent run and unwritable to a non-root server.
|
||||
/// Removed on drop: no job loop owns it, and the run's future is dropped mid-await when the
|
||||
/// HTTP client disconnects.
|
||||
struct InlineJobDir(String);
|
||||
|
||||
impl Drop for InlineJobDir {
|
||||
fn drop(&mut self) {
|
||||
let dir = std::mem::take(&mut self.0);
|
||||
match tokio::runtime::Handle::try_current() {
|
||||
Ok(handle) => {
|
||||
handle.spawn_blocking(move || std::fs::remove_dir_all(dir));
|
||||
}
|
||||
Err(_) => {
|
||||
let _ = std::fs::remove_dir_all(dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn create_inline_job_dir() -> error::Result<InlineJobDir> {
|
||||
let job_dir = format!("{}/inline/{}", *WINDMILL_DIR, Uuid::new_v4());
|
||||
tokio::fs::create_dir_all(&job_dir).await?;
|
||||
Ok(InlineJobDir(job_dir))
|
||||
}
|
||||
|
||||
pub fn init_worker_internal_server_inline_utils(
|
||||
killpill_rx: tokio::sync::broadcast::Receiver<()>,
|
||||
base_internal_url: String,
|
||||
@@ -7275,13 +7302,14 @@ pub fn init_worker_internal_server_inline_utils(
|
||||
let mut occupancy_metrics = OccupancyMetrics::new(Instant::now());
|
||||
let mut has_stream: bool = false;
|
||||
let mut killpill_rx = params.killpill_rx;
|
||||
let job_dir = create_inline_job_dir().await?;
|
||||
|
||||
run_language_executor(
|
||||
&job,
|
||||
¶ms.conn,
|
||||
¶ms.client,
|
||||
None,
|
||||
¶ms.job_dir,
|
||||
&job_dir.0,
|
||||
¶ms.worker_dir,
|
||||
&mut mem_peak,
|
||||
&mut canceled_by,
|
||||
@@ -7336,13 +7364,14 @@ pub fn init_worker_internal_server_inline_utils(
|
||||
let mut occupancy_metrics = OccupancyMetrics::new(Instant::now());
|
||||
let mut has_stream: bool = false;
|
||||
let mut killpill_rx = params.killpill_rx;
|
||||
let job_dir = create_inline_job_dir().await?;
|
||||
|
||||
run_language_executor(
|
||||
&job,
|
||||
¶ms.conn,
|
||||
¶ms.client,
|
||||
None,
|
||||
¶ms.job_dir,
|
||||
&job_dir.0,
|
||||
¶ms.worker_dir,
|
||||
&mut mem_peak,
|
||||
&mut canceled_by,
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import { sleep } from "https://deno.land/x/sleep@v1.2.1/mod.ts";
|
||||
import * as windmill from "https://deno.land/x/windmill@v1.174.0/mod.ts";
|
||||
import * as api from "https://deno.land/x/windmill@v1.174.0/windmill-api/index.ts";
|
||||
|
||||
export const VERSION = "v1.835.0";
|
||||
export const VERSION = "v1.837.0";
|
||||
|
||||
export async function login(email: string, password: string): Promise<string> {
|
||||
return await windmill.UserService.login({
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@windmill-labs/chat-sdk",
|
||||
"version": "1.835.0",
|
||||
"version": "1.837.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@windmill-labs/chat-sdk",
|
||||
"version": "1.835.0",
|
||||
"version": "1.837.0",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@ai-sdk/react": "^4.0.102",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@windmill-labs/chat-sdk",
|
||||
"description": "Build chat interfaces on Windmill flows deployed in chat mode, from any frontend or raw app",
|
||||
"version": "1.835.0",
|
||||
"version": "1.837.0",
|
||||
"author": "Ruben Fiszel",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://github.com/windmill-labs/windmill/tree/main/chat-sdk#readme",
|
||||
|
||||
@@ -20,6 +20,11 @@ import { Resource } from "../../../gen/types.gen.ts";
|
||||
import { readInlinePathSync, readTextFile } from "../../utils/utils.ts";
|
||||
import { isWorkspaceSpecificFile } from "../../core/specific_items.ts";
|
||||
import { getCurrentGitBranch } from "../../utils/git.ts";
|
||||
import {
|
||||
buildPermissionedAsContext,
|
||||
type PermissionedAsContext,
|
||||
} from "../../core/permissioned_as.ts";
|
||||
import { readEffectiveSyncBehavior } from "../../core/conf.ts";
|
||||
|
||||
export interface ResourceFile {
|
||||
value: any;
|
||||
@@ -83,6 +88,7 @@ export async function pushResource(
|
||||
// only round-trip the canonical layout); the standalone `resource push`
|
||||
// command pushes a single explicit file, where any pointer is fine.
|
||||
enforceCanonicalFileset?: boolean,
|
||||
permissionedAsContext?: PermissionedAsContext,
|
||||
): Promise<void> {
|
||||
remotePath = removeType(remotePath, "resource");
|
||||
try {
|
||||
@@ -93,6 +99,11 @@ export async function pushResource(
|
||||
} catch {
|
||||
// flow doesn't exist
|
||||
}
|
||||
const claimed = agentOnBehalfOf(
|
||||
resource,
|
||||
localResource,
|
||||
permissionedAsContext
|
||||
);
|
||||
|
||||
// Helper function to resolve inline content
|
||||
const resolveInlineContent = async () => {
|
||||
@@ -133,11 +144,23 @@ export async function pushResource(
|
||||
|
||||
// Only resolve inline content if we're actually updating
|
||||
await resolveInlineContent();
|
||||
if (claimed) {
|
||||
log.info(`Preserving ${claimed} as permissioned_as for agent ${remotePath}`);
|
||||
}
|
||||
|
||||
await wmill.updateResource({
|
||||
workspace: workspace,
|
||||
path: remotePath.replaceAll(SEP, "/"),
|
||||
requestBody: { ...localResource, ...(wsSpecific !== undefined ? { ws_specific: wsSpecific } : {}) },
|
||||
requestBody: {
|
||||
...localResource,
|
||||
...(wsSpecific !== undefined ? { ws_specific: wsSpecific } : {}),
|
||||
...(claimed
|
||||
? {
|
||||
value: { ...localResource.value, on_behalf_of: claimed },
|
||||
preserve_on_behalf_of: true,
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
});
|
||||
} else {
|
||||
// New resource - resolve inline content
|
||||
@@ -163,6 +186,42 @@ export async function pushResource(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An agent with `run_on_behalf_of` runs as the identity in its value's
|
||||
* `on_behalf_of`, which the backend sets to whoever writes the agent and clears
|
||||
* while the toggle is off. Like an app's, it is never taken from the
|
||||
* tracked file, which the pull leaves it out of: the deployed one is claimed
|
||||
* back only by a pusher the backend lets keep it, an admin or a `wm_deployers`
|
||||
* member. Strips the key from `localResource` (and from the deployed value, so
|
||||
* an unchanged agent still compares equal) and returns the identity to claim.
|
||||
*/
|
||||
export function agentOnBehalfOf(
|
||||
deployed: ResourceFile | Resource | undefined,
|
||||
localResource: ResourceFile,
|
||||
permissionedAsContext: PermissionedAsContext | undefined
|
||||
): string | undefined {
|
||||
// What the push writes is the tracked file's type: an agent retyped into
|
||||
// another resource keeps its value exactly as the file states it.
|
||||
if (localResource.resource_type !== "ai_agent") {
|
||||
return undefined;
|
||||
}
|
||||
const local = localResource.value;
|
||||
if (local && typeof local === "object") {
|
||||
delete local.on_behalf_of;
|
||||
}
|
||||
const value = deployed?.resource_type === "ai_agent" ? deployed.value : undefined;
|
||||
const onBehalfOf =
|
||||
value && typeof value === "object" ? value.on_behalf_of : undefined;
|
||||
if (deployed && onBehalfOf !== undefined) {
|
||||
const { on_behalf_of: _, ...rest } = value;
|
||||
deployed.value = rest;
|
||||
}
|
||||
if (!onBehalfOf || !permissionedAsContext?.userIsAdminOrDeployer) {
|
||||
return undefined;
|
||||
}
|
||||
return onBehalfOf;
|
||||
}
|
||||
|
||||
type PushOptions = GlobalOptions;
|
||||
async function push(opts: PushOptions, filePath: string, remotePath: string) {
|
||||
const workspace = await resolveWorkspace(opts);
|
||||
@@ -184,7 +243,13 @@ async function push(opts: PushOptions, filePath: string, remotePath: string) {
|
||||
remotePath,
|
||||
undefined,
|
||||
parseFromFile(filePath),
|
||||
filePath // Pass the local file path for branch-specific inline content resolution
|
||||
filePath, // Pass the local file path for branch-specific inline content resolution
|
||||
undefined,
|
||||
undefined,
|
||||
await buildPermissionedAsContext(
|
||||
workspace.workspaceId,
|
||||
await readEffectiveSyncBehavior(opts, workspace)
|
||||
)
|
||||
);
|
||||
log.info(colors.bold.underline.green(`Resource ${remotePath} pushed`));
|
||||
}
|
||||
|
||||
@@ -6065,6 +6065,7 @@ export async function push(
|
||||
resourceFilePath,
|
||||
isFileResWsSpecific ? true : undefined,
|
||||
true,
|
||||
permissionedAsContext,
|
||||
);
|
||||
}
|
||||
// Already-synced parents got the full content this run.
|
||||
|
||||
@@ -10,4 +10,4 @@ export const WM_FORK_PREFIX = "wm-fork";
|
||||
// (e.g. utils.ts) can read it without importing main.ts and creating a circular
|
||||
// dependency (main → workspace → utils → main) that triggers a TDZ.
|
||||
// Re-exported from main.ts for backwards compatibility.
|
||||
export const VERSION = "1.835.0";
|
||||
export const VERSION = "1.837.0";
|
||||
|
||||
@@ -250,6 +250,18 @@ export async function preCheckPermissionedAs(
|
||||
if (match) {
|
||||
currentOwner = match[1];
|
||||
}
|
||||
} else if (typeStr === "resource") {
|
||||
// An agent with `run_on_behalf_of` runs as someone, and the file never says who.
|
||||
if (
|
||||
/["']?resource_type["']?\s*:\s*["']?ai_agent\b/.test(beforeContent) &&
|
||||
/["']?run_on_behalf_of["']?\s*:\s*true\b/.test(beforeContent)
|
||||
) {
|
||||
wouldChangeItems.push({
|
||||
path: change.path,
|
||||
currentOwner: "(agent owner)",
|
||||
});
|
||||
}
|
||||
continue;
|
||||
} else if (typeStr.endsWith("_trigger")) {
|
||||
wouldChangeItems.push({
|
||||
path: change.path,
|
||||
|
||||
Generated
+8
-2
@@ -6926,14 +6926,14 @@ An app's custom URL is not in \`raw_app.yaml\`: each workspace has its own file
|
||||
|
||||
## Sandbox isolation and frontend API access
|
||||
|
||||
New apps are sandboxed: the frontend is isolated from the viewer's own Windmill session and reaches Windmill only through its backend runnables, plus whatever frontend API scopes the app declares, which each viewer approves before the app runs. With isolation turned off, the frontend runs with the viewer's full session. The scopes are \`jobs:run\`, \`jobs:read\`, \`users:read\`, \`resources:read\`, \`variables:read\`, \`flow_conversations:read\` and \`flow_conversations:write\`; grant only the ones the frontend calls.
|
||||
New apps are sandboxed: the frontend is isolated from the viewer's own Windmill session and reaches Windmill only through its backend runnables, plus whatever frontend API scopes the app declares, which each viewer approves before the app runs. With isolation turned off, the frontend runs with the viewer's full session. The scopes are \`jobs:run\`, \`jobs:read\`, \`resources:read\`, \`variables:read\`, \`flow_conversations:read\` and \`flow_conversations:write\`; grant only the ones the frontend calls. The viewer's identity needs no scope: it is in \`window.ctx\`, and whoami works with any of them.
|
||||
|
||||
Inside the sandbox, IndexedDB is unavailable, third-party sign-in and OAuth redirects fail, and requests to other services carry \`Origin: null\`, which an API that checks the origin rejects. Work around these first: call the service from a backend runnable, keep state in a data table or \`localStorage\`, or grant the frontend API scope the code needs. Suggest turning isolation off only when none of that works, and say plainly that it is a security risk: the app's code, and any XSS bug in it, then runs with the full Windmill permissions of everyone who opens the app.
|
||||
In \`raw_app.yaml\`:
|
||||
|
||||
\`\`\`yaml
|
||||
sandbox: true
|
||||
frontend_api: [jobs:run, users:read]
|
||||
frontend_api: [jobs:run]
|
||||
\`\`\`
|
||||
|
||||
A file with a \`sandbox\` key states both settings: \`sandbox: false\` turns isolation off, and a missing \`frontend_api\` means no scopes. A file without the key leaves the deployed app's isolation and scopes as they are, so removing \`sandbox: true\` does not unsandbox it. \`frontend_api\` needs \`sandbox: true\`; the push fails otherwise.
|
||||
@@ -7173,6 +7173,12 @@ Example: \`f/databases/postgres_prod.resource.json\`
|
||||
- \`value\` - Object containing the resource configuration
|
||||
- \`resource_type\` - Name of the resource type (e.g., "postgresql", "slack")
|
||||
|
||||
## Agents
|
||||
|
||||
An agent, as the Agents page lists it, is a resource of type \`ai_agent\`. Its value holds the
|
||||
agent's provider, system prompt, tools and memory settings, and a flow step uses a saved agent by
|
||||
linking its path.
|
||||
|
||||
## Variable References
|
||||
|
||||
Reference variables in resource values:
|
||||
|
||||
+1
-1
@@ -254,7 +254,7 @@ export async function pushObj(
|
||||
} else if (typeEnding === "resource") {
|
||||
if (!alreadySynced.includes(p)) {
|
||||
alreadySynced.push(p);
|
||||
await pushResource(workspace, p, befObj, newObj, originalLocalPath || p, wsSpecific, true);
|
||||
await pushResource(workspace, p, befObj, newObj, originalLocalPath || p, wsSpecific, true, permissionedAsContext);
|
||||
}
|
||||
} else if (typeEnding === "resource-type") {
|
||||
await pushResourceType(workspace, p, befObj, newObj);
|
||||
|
||||
@@ -105,3 +105,28 @@ test("deployItem: never sends the source workspace's on_behalf_of", async () =>
|
||||
expect("on_behalf_of" in JSON.parse(JSON.stringify(identity))).toBe(false);
|
||||
}
|
||||
});
|
||||
|
||||
// An agent carries its principal inside its resource value, and is handed the chosen one as a
|
||||
// principal. The source's must never be sent: without a choice the key is dropped, leaving the
|
||||
// backend to make the agent the deployer's.
|
||||
test("deployItem: an agent takes the chosen principal, never the source's", async () => {
|
||||
const captured: any[] = [];
|
||||
const provider = {
|
||||
existsResource: async () => true,
|
||||
getResource: async () => ({
|
||||
path: "f/x/agent",
|
||||
resource_type: "ai_agent",
|
||||
description: "",
|
||||
value: { system_prompt: "hi", on_behalf_of: "u/alice" },
|
||||
}),
|
||||
updateResource: async (p: any) => void captured.push(p.requestBody),
|
||||
} as any;
|
||||
|
||||
await deployItem(provider, "resource" as any, "f/x/agent", "src", "dst", "u/bob");
|
||||
await deployItem(provider, "resource" as any, "f/x/agent", "src", "dst", undefined);
|
||||
|
||||
expect(captured[0].value).toEqual({ system_prompt: "hi", on_behalf_of: "u/bob" });
|
||||
expect(captured[0].preserve_on_behalf_of).toBe(true);
|
||||
expect(captured[1].value).toEqual({ system_prompt: "hi" });
|
||||
expect(captured[1].preserve_on_behalf_of).toBe(false);
|
||||
});
|
||||
|
||||
@@ -145,3 +145,16 @@ test("an app is listed once however many of its files changed", async () => {
|
||||
|
||||
expect(message).toContain("2 item(s)");
|
||||
});
|
||||
|
||||
// An agent has an identity only while `run_on_behalf_of` is on, so only then
|
||||
// can a push take it over.
|
||||
test("an agent warns only while it runs on behalf of someone", async () => {
|
||||
const agent = (run: boolean) => ({
|
||||
name: "edited" as const,
|
||||
path: "f/test/bot.resource.yaml",
|
||||
before: `resource_type: ai_agent\nvalue:\n system_prompt: hi\n run_on_behalf_of: ${run}\n`,
|
||||
});
|
||||
|
||||
expect(await precheck([agent(true)])).toContain("f/test/bot.resource.yaml");
|
||||
expect(await precheck([agent(false)])).toBeUndefined();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* An agent's run-as identity lives in its value, which the pull leaves out. A
|
||||
* push must neither see that gap as a change nor let the file pick who the
|
||||
* agent runs as: only the deployed identity is claimed back, and only by a
|
||||
* pusher the backend lets keep it.
|
||||
*/
|
||||
|
||||
import { expect, test } from "bun:test";
|
||||
import { isSuperset } from "../src/types.ts";
|
||||
import { agentOnBehalfOf } from "../src/commands/resource/resource.ts";
|
||||
|
||||
const ctx = (userIsAdminOrDeployer: boolean) => ({
|
||||
userCache: new Map(),
|
||||
userIsAdminOrDeployer,
|
||||
userEmail: "me@x.dev",
|
||||
});
|
||||
|
||||
function agents(localObo?: string) {
|
||||
const deployed = {
|
||||
resource_type: "ai_agent",
|
||||
value: { system_prompt: "hi", on_behalf_of: "u/bob" },
|
||||
} as any;
|
||||
const local = {
|
||||
resource_type: "ai_agent",
|
||||
value: { system_prompt: "hi", ...(localObo ? { on_behalf_of: localObo } : {}) },
|
||||
} as any;
|
||||
return { deployed, local };
|
||||
}
|
||||
|
||||
test("an unchanged agent still compares equal to the deployed one", () => {
|
||||
const { deployed, local } = agents();
|
||||
agentOnBehalfOf(deployed, local, ctx(true));
|
||||
expect(isSuperset(local, deployed)).toBe(true);
|
||||
});
|
||||
|
||||
test("an admin or deployer claims the deployed identity, never the file's", () => {
|
||||
const { deployed, local } = agents("u/admin");
|
||||
expect(agentOnBehalfOf(deployed, local, ctx(true))).toBe("u/bob");
|
||||
expect(local.value.on_behalf_of).toBeUndefined();
|
||||
});
|
||||
|
||||
test("anyone else claims nothing", () => {
|
||||
const { deployed, local } = agents("u/bob");
|
||||
expect(agentOnBehalfOf(deployed, local, ctx(false))).toBeUndefined();
|
||||
expect(agentOnBehalfOf(agents().deployed, agents().local, undefined)).toBeUndefined();
|
||||
expect(local.value.on_behalf_of).toBeUndefined();
|
||||
});
|
||||
|
||||
test("other resources are left alone, an agent retyped into one included", () => {
|
||||
for (const deployedType of ["json", "ai_agent"]) {
|
||||
const deployed = { resource_type: deployedType, value: { on_behalf_of: "u/bob" } } as any;
|
||||
const local = { resource_type: "json", value: { on_behalf_of: "u/x" } } as any;
|
||||
expect(agentOnBehalfOf(deployed, local, ctx(true))).toBeUndefined();
|
||||
expect(local.value.on_behalf_of).toBe("u/x");
|
||||
expect(deployed.value.on_behalf_of).toBe("u/bob");
|
||||
}
|
||||
});
|
||||
@@ -637,15 +637,26 @@ export async function deployItem(
|
||||
workspace: workspaceFrom,
|
||||
path,
|
||||
});
|
||||
let value = resource.value ?? "";
|
||||
// An agent's value carries the principal it runs as, as a trigger's row does: the source's
|
||||
// names nobody in the target, so it is replaced by the chosen one or dropped, leaving the
|
||||
// backend to make it the deployer's.
|
||||
const agent = resource.resource_type === "ai_agent" && typeof value === "object";
|
||||
if (agent) {
|
||||
const { on_behalf_of: _, ...rest } = value;
|
||||
value = onBehalfOf ? { ...rest, on_behalf_of: onBehalfOf } : rest;
|
||||
}
|
||||
const agentPreserve = agent ? { preserve_on_behalf_of: preserveOnBehalfOf } : {};
|
||||
if (alreadyExists) {
|
||||
await provider.updateResource({
|
||||
workspace: workspaceTo,
|
||||
path,
|
||||
requestBody: {
|
||||
path,
|
||||
value: resource.value ?? "",
|
||||
value,
|
||||
description: resource.description ?? "",
|
||||
labels: resource.labels,
|
||||
...agentPreserve,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
@@ -653,10 +664,11 @@ export async function deployItem(
|
||||
workspace: workspaceTo,
|
||||
requestBody: {
|
||||
path,
|
||||
value: resource.value ?? "",
|
||||
value,
|
||||
resource_type: resource.resource_type,
|
||||
description: resource.description ?? "",
|
||||
labels: resource.labels,
|
||||
...agentPreserve,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -917,6 +929,11 @@ export async function getItemValue(
|
||||
return variable.value;
|
||||
} else if (kind === "resource") {
|
||||
const resource = await provider.getResource({ workspace, path });
|
||||
// Each workspace resolves its own agent identity, which a deploy never copies.
|
||||
if (resource.resource_type === "ai_agent" && resource.value) {
|
||||
const { on_behalf_of: _, ...value } = resource.value;
|
||||
return value;
|
||||
}
|
||||
return resource.value;
|
||||
} else if (kind === "resource_type") {
|
||||
const rt = await provider.getResourceType({ workspace, path });
|
||||
@@ -1002,7 +1019,8 @@ function stripTriggerOrScheduleRuntimeFields(row: unknown): unknown {
|
||||
|
||||
/**
|
||||
* Fetch the on_behalf_of value for a deployable item.
|
||||
* Returns an email for flows/scripts/apps, or undefined if not applicable.
|
||||
* Returns an email for flows/scripts/apps, a principal (u/username, g/group) for
|
||||
* triggers/schedules and agents, or undefined if not applicable.
|
||||
*/
|
||||
export async function getOnBehalfOf(
|
||||
provider: DeployProvider,
|
||||
@@ -1020,6 +1038,12 @@ export async function getOnBehalfOf(
|
||||
} else if (kind === "app" || kind === "raw_app") {
|
||||
const app = await provider.getAppByPath({ workspace, path });
|
||||
return app.policy?.on_behalf_of_email;
|
||||
} else if (kind === "resource") {
|
||||
// Only an agent runs as anyone, and like a trigger it records the principal.
|
||||
const resource = await provider.getResource({ workspace, path });
|
||||
return resource.resource_type === "ai_agent"
|
||||
? resource.value?.on_behalf_of
|
||||
: undefined;
|
||||
} else if (kind === "schedule") {
|
||||
const schedule = await provider.getSchedule({ workspace, path });
|
||||
return schedule.permissioned_as;
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@windmill-labs/components",
|
||||
"version": "1.835.0",
|
||||
"version": "1.837.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@windmill-labs/components",
|
||||
"version": "1.835.0",
|
||||
"version": "1.837.0",
|
||||
"hasInstallScript": true,
|
||||
"license": "AGPL-3.0",
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@windmill-labs/components",
|
||||
"version": "1.835.0",
|
||||
"version": "1.837.0",
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
"dev:ui-builder": "mv static/ui_builder static/ui_builder.dev-disabled 2>/dev/null || true ; trap 'mv static/ui_builder.dev-disabled static/ui_builder 2>/dev/null || true' EXIT ; vite dev",
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="/logo.svg" />
|
||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
||||
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#fbfbfd" />
|
||||
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#3b4252" />
|
||||
<meta name="mobile-web-app-capable" content="yes" />
|
||||
<style type="text/css">
|
||||
.st2 {
|
||||
fill: #bcd4fc;
|
||||
|
||||
@@ -612,12 +612,13 @@
|
||||
}
|
||||
|
||||
async function fetchOnBehalfOfInfo(diffs: WorkspaceItemDiff[]) {
|
||||
// Runnables carry an email; triggers/schedules carry `permissioned_as`.
|
||||
// `getOnBehalfOf` handles the dispatch — we just need to skip kinds that
|
||||
// have no on_behalf_of concept (resource, variable, folder, resource_type).
|
||||
// Runnables carry an email; triggers/schedules and agents carry `permissioned_as`.
|
||||
// `getOnBehalfOf` handles the dispatch (a resource that is not an agent has none) — we
|
||||
// just need to skip kinds that have no on_behalf_of concept (variable, folder, resource_type).
|
||||
const itemsWithOnBehalfOf = diffs.filter(
|
||||
(d) =>
|
||||
['flow', 'script', 'app', 'raw_app'].includes(d.kind) || isTriggerOrScheduleKind(d.kind)
|
||||
['flow', 'script', 'app', 'raw_app', 'resource'].includes(d.kind) ||
|
||||
isTriggerOrScheduleKind(d.kind)
|
||||
)
|
||||
const pair = [
|
||||
{ workspace: currentWorkspaceId, side: 'fork' as const },
|
||||
@@ -679,17 +680,22 @@
|
||||
})
|
||||
)
|
||||
|
||||
/** Triggers, schedules and agents record who they run as by principal, the rest by address. */
|
||||
function usesPrincipal(kind: Kind): boolean {
|
||||
return kind === 'trigger' || isTriggerOrScheduleKind(kind) || kind === 'resource'
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the on_behalf_of value for deployment based on user's choice.
|
||||
* Returns an email for flows/scripts/apps, or permissioned_as (u/username, g/group) for triggers/schedules.
|
||||
* Returns an email for flows/scripts/apps, or permissioned_as (u/username, g/group) for
|
||||
* triggers/schedules and agents.
|
||||
*/
|
||||
function getOnBehalfOfForDeploy(itemKey: string, kind: Kind): string | undefined {
|
||||
const choice = onBehalfOfChoice[itemKey]
|
||||
if (choice === 'target') return getTargetOnBehalfOf(itemKey)
|
||||
if (choice === 'custom') {
|
||||
const details = customOnBehalfOf[itemKey]
|
||||
const wantsPermissionedAs = kind === 'trigger' || isTriggerOrScheduleKind(kind)
|
||||
return wantsPermissionedAs ? details?.permissionedAs : details?.email
|
||||
return usesPrincipal(kind) ? details?.permissionedAs : details?.email
|
||||
}
|
||||
// 'me' or undefined = don't pass, backend will use deploying user's identity
|
||||
return undefined
|
||||
@@ -701,7 +707,7 @@
|
||||
* returning undefined clears the source item's value rather than keeping it.
|
||||
*/
|
||||
function getOnBehalfOfPermissionedAsForDeploy(itemKey: string, kind: Kind): string | undefined {
|
||||
if (kind === 'trigger' || isTriggerOrScheduleKind(kind)) return undefined
|
||||
if (usesPrincipal(kind)) return undefined
|
||||
if (onBehalfOfChoice[itemKey] !== 'custom') return undefined
|
||||
return customOnBehalfOf[itemKey]?.permissionedAs
|
||||
}
|
||||
|
||||
@@ -110,16 +110,22 @@
|
||||
return needsOnBehalfOfSelection(kind, sourceOnBehalfOfInfo[statusPath])
|
||||
}
|
||||
|
||||
/** Triggers and agents record who they run as by principal, the rest by address. */
|
||||
function usesPrincipal(kind: Kind): boolean {
|
||||
return kind === 'trigger' || kind === 'resource'
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the on_behalf_of value for deployment based on user's choice.
|
||||
* Returns an email for flows/scripts/apps, or permissioned_as (u/username, g/group) for triggers/schedules.
|
||||
* Returns an email for flows/scripts/apps, or permissioned_as (u/username, g/group) for
|
||||
* triggers/schedules and agents.
|
||||
*/
|
||||
function getOnBehalfOfForDeploy(statusPath: string, kind: Kind): string | undefined {
|
||||
const choice = onBehalfOfChoice[statusPath]
|
||||
if (choice === 'target') return targetOnBehalfOfInfo[statusPath]
|
||||
if (choice === 'custom') {
|
||||
const details = customOnBehalfOf[statusPath]
|
||||
return kind === 'trigger' ? details?.permissionedAs : details?.email
|
||||
return usesPrincipal(kind) ? details?.permissionedAs : details?.email
|
||||
}
|
||||
// 'me' or undefined = don't pass, backend will use deploying user's identity
|
||||
return undefined
|
||||
@@ -134,7 +140,7 @@
|
||||
statusPath: string,
|
||||
kind: Kind
|
||||
): string | undefined {
|
||||
if (kind === 'trigger' || onBehalfOfChoice[statusPath] !== 'custom') return undefined
|
||||
if (usesPrincipal(kind) || onBehalfOfChoice[statusPath] !== 'custom') return undefined
|
||||
return customOnBehalfOf[statusPath]?.permissionedAs
|
||||
}
|
||||
|
||||
@@ -205,7 +211,7 @@
|
||||
|
||||
// Fetch on_behalf_of_email for flows, scripts, apps, and triggers from both workspaces
|
||||
for (const dep of sortedSet.filter((d) =>
|
||||
['flow', 'script', 'app', 'trigger'].includes(d.kind)
|
||||
['flow', 'script', 'app', 'trigger', 'resource'].includes(d.kind)
|
||||
)) {
|
||||
const key = computeStatusPath(dep.kind, dep.path)
|
||||
let source: string | undefined
|
||||
|
||||
@@ -18,7 +18,13 @@
|
||||
linkedAgentToolsVersion,
|
||||
migrateLinkedAgentToolsScope
|
||||
} from '$lib/components/flows/linkedAgentToolsStore.svelte'
|
||||
import { enterpriseLicense, userStore, userWorkspaces, usedTriggerKinds } from '$lib/stores'
|
||||
import {
|
||||
enterpriseLicense,
|
||||
userStore,
|
||||
userWorkspaces,
|
||||
usedTriggerKinds,
|
||||
workspaceStore
|
||||
} from '$lib/stores'
|
||||
import {
|
||||
generateRandomString,
|
||||
orderedJsonStringify,
|
||||
@@ -49,6 +55,7 @@
|
||||
import WorkspaceScriptSettingsDrawer from './flows/content/WorkspaceScriptSettingsDrawer.svelte'
|
||||
import FlowEditorDrawer from './flows/content/FlowEditorDrawer.svelte'
|
||||
import { dfs as dfsApply } from './flows/dfs'
|
||||
import { dropStaleStepLocks } from './flows/staleStepLocks'
|
||||
import {
|
||||
claimLinkedToolsFetch,
|
||||
invalidateLinkedToolsFetches,
|
||||
@@ -551,15 +558,14 @@
|
||||
// One lookup for the whole list: an agent lives in a folder, and the groups and admin
|
||||
// flag that answer for it are per workspace, so the nav user would answer for the wrong
|
||||
// membership when a session editor operates on another workspace.
|
||||
const user = await getUserExt(opWorkspace ?? '').catch(() => undefined)
|
||||
const user =
|
||||
(await getUserExt(opWorkspace ?? '')) ??
|
||||
(opWorkspace === $workspaceStore ? $userStore : undefined)
|
||||
const operatorSettings = $userWorkspaces.find(
|
||||
(w) => w.id === opWorkspace
|
||||
)?.operator_settings
|
||||
agentCanWrite = Object.fromEntries(
|
||||
draftAgents.map((a) => [
|
||||
a.path,
|
||||
agentDraftCanWrite(a, user ?? $userStore ?? undefined, operatorSettings)
|
||||
])
|
||||
draftAgents.map((a) => [a.path, agentDraftCanWrite(a, user, operatorSettings)])
|
||||
)
|
||||
// The path is passed, so a draft that renames the agent is refused here too: a rename is
|
||||
// the agent editor's to deploy, and this dialog lists the agent under the path the flow
|
||||
@@ -627,6 +633,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
// The editor clears a step's lock when its code is edited, but a draft written elsewhere
|
||||
// can hold a step whose code changed and whose lock did not. A failed lookup skips the
|
||||
// check rather than blocking the deploy.
|
||||
const liveFlowValue = isNewFlow
|
||||
? undefined
|
||||
: await FlowService.getFlowByPath({ workspace: opWorkspace!, path: initialPath })
|
||||
.then((f) => f.value)
|
||||
.catch(() => undefined)
|
||||
dropStaleStepLocks(flow.value, liveFlowValue)
|
||||
|
||||
if (isNewFlow) {
|
||||
await FlowService.createFlow({
|
||||
workspace: opWorkspace!,
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<Badge {large} color="orange" title={job.resolution_note}>
|
||||
<!-- `resolved_by` is absent both for an automatic resolution and for a manual one
|
||||
outside EE, so the automatic wording comes from `resolved_automatically`. -->
|
||||
Failed after {msToReadableTime(job.duration_ms)}, resolved{job.resolved_automatically
|
||||
{job.canceled ? 'Canceled' : 'Failed'} after {msToReadableTime(job.duration_ms)}, resolved{job.resolved_automatically
|
||||
? ' automatically'
|
||||
: job.resolved_by
|
||||
? ` by ${job.resolved_by}`
|
||||
@@ -49,7 +49,7 @@
|
||||
</Badge>
|
||||
{:else if job && 'success' in job}
|
||||
<Badge {large} color="red">
|
||||
Failed after {msToReadableTime(job.duration_ms)}
|
||||
{job.canceled ? 'Canceled' : 'Failed'} after {msToReadableTime(job.duration_ms)}
|
||||
{#if job.self_wait_time_ms || job.aggregate_wait_time_ms}
|
||||
<WaitTimeWarning
|
||||
self_wait_time_ms={job.self_wait_time_ms}
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
kind === 'app' ||
|
||||
kind === 'raw_app' ||
|
||||
kind === 'trigger' ||
|
||||
isTriggerOrScheduleKind(kind)
|
||||
isTriggerOrScheduleKind(kind) ||
|
||||
// Only an agent's value carries an identity, so no other resource has a source value.
|
||||
kind === 'resource'
|
||||
if (!supported) return false
|
||||
return !!sourceValue
|
||||
}
|
||||
|
||||
@@ -652,6 +652,11 @@
|
||||
const s = states[ws].draft!
|
||||
const ini = initialStates[ws]
|
||||
if (existedInitially[ws]) {
|
||||
const fetched = fetchedResources[ws]
|
||||
// An agent keeps the identity its value names, as its own editor keeps it: without
|
||||
// the flag an admin's save would take it over. The backend resets it to the writer
|
||||
// for anyone not allowed to keep it.
|
||||
const keepAgentObo = fetched?.resource_type === 'ai_agent' && !!s.args?.on_behalf_of
|
||||
await ResourceService.updateResource({
|
||||
workspace: ws,
|
||||
path: ini.path,
|
||||
@@ -660,10 +665,10 @@
|
||||
value: s.args,
|
||||
description: s.description,
|
||||
labels: s.labels,
|
||||
ws_specific: s.wsSpecific
|
||||
ws_specific: s.wsSpecific,
|
||||
preserve_on_behalf_of: keepAgentObo ? true : undefined
|
||||
}
|
||||
})
|
||||
const fetched = fetchedResources[ws]
|
||||
if (fetched?.resource_type === 'json_schema') {
|
||||
clearJsonSchemaResourceCache(ini.path, ws)
|
||||
}
|
||||
|
||||
@@ -152,6 +152,7 @@
|
||||
title: string
|
||||
confirmBtnText: string
|
||||
loading?: boolean
|
||||
description?: string
|
||||
preContent?: string
|
||||
onConfirm?: (forceCancel: boolean) => void
|
||||
type?: ConfirmationModal['$$prop_def']['type']
|
||||
@@ -437,6 +438,7 @@
|
||||
|
||||
async function reRunJobs(jobIdsToReRun: string[], batchReRunOptions: BatchReRunOptions) {
|
||||
if (!$operatingWorkspace) return
|
||||
const batching = filterMatchedIds !== undefined
|
||||
|
||||
if (askingForConfirmation) {
|
||||
askingForConfirmation.loading = true
|
||||
@@ -486,7 +488,11 @@
|
||||
}
|
||||
if (reRanUuids.length !== jobIdsToReRun.length) {
|
||||
sendUserToast(
|
||||
`Failed to re-run ${jobIdsToReRun.length - reRanUuids.length} jobs. Check console for details`,
|
||||
`Failed to re-run ${jobIdsToReRun.length - reRanUuids.length} jobs. Check console for details` +
|
||||
// Only a re-run resolves its source, so these stay first in line.
|
||||
(batching
|
||||
? '. They stay unresolved and the next batch will try them again: resolve them to skip them'
|
||||
: ''),
|
||||
true
|
||||
)
|
||||
// We do not get explicit error from backend if the job script don't exist
|
||||
@@ -509,13 +515,31 @@
|
||||
jobsLoader?.loadJobs(true, true)
|
||||
}
|
||||
|
||||
// Every failed or canceled job "Re-run all jobs matching filters" found, oldest first, so a
|
||||
// batch limit takes the oldest ones. Re-running resolves them, so under "Hide resolved runs"
|
||||
// the next click picks up where the previous batch stopped.
|
||||
let filterMatchedIds: string[] | undefined = $state()
|
||||
let rerunLimit: number | undefined = $state()
|
||||
// The pane closes from several places, the table included; a stale match list would then
|
||||
// offer its limit over a selection it no longer describes.
|
||||
$effect(() => {
|
||||
if (!batchRerunOptionsIsOpen) untrack(() => (filterMatchedIds = undefined))
|
||||
})
|
||||
|
||||
function setRerunLimit(limit: number | undefined) {
|
||||
if (!filterMatchedIds) return
|
||||
rerunLimit = limit && limit > 0 ? limit : undefined
|
||||
selectedIds = filterMatchedIds.slice(0, rerunLimit ?? filterMatchedIds.length)
|
||||
}
|
||||
|
||||
async function onRerunAllJobsMatchingFilters() {
|
||||
const selectedFilters = getSelectedFilters()
|
||||
selectedIds = []
|
||||
|
||||
const loadingToast = sendUserToast('Loading job ids', 'info')
|
||||
|
||||
if (filters.val.job_kinds !== 'runs') {
|
||||
// Selecting "runs" deletes the key, since it is the default.
|
||||
if ((filters.val.job_kinds ?? 'runs') !== 'runs') {
|
||||
sendUserToast('Batch re-run is only supported for scripts and flows', true)
|
||||
loadingToast.destroy()
|
||||
return
|
||||
@@ -524,11 +548,21 @@
|
||||
// workspace. started_at >= minTs implies completed_at >= minTs, so completedAfter adds a
|
||||
// lossless indexed lower bound ((workspace_id, completed_at DESC)); started_at stays the
|
||||
// exact recheck. (completedBefore is omitted: it would drop jobs that finish after maxTs.)
|
||||
selectedIds = await JobService.listFilteredJobsUuids({
|
||||
const ids = await JobService.listFilteredJobsUuids({
|
||||
...selectedFilters,
|
||||
completedAfter: selectedFilters.startedAfter,
|
||||
jobKinds: 'script,flow'
|
||||
orderDesc: false
|
||||
})
|
||||
// Batching needs both halves of its promise: only failed or canceled sources are resolved
|
||||
// by a re-run, and only a status filter keeps the queue out of the lookup, whose union
|
||||
// drops the ordering. Anything else re-runs every match, as one batch.
|
||||
if (selectedFilters.status === 'failure' || selectedFilters.status === 'canceled') {
|
||||
filterMatchedIds = ids
|
||||
setRerunLimit(rerunLimit)
|
||||
} else {
|
||||
filterMatchedIds = undefined
|
||||
selectedIds = ids
|
||||
}
|
||||
loadingToast.destroy()
|
||||
batchRerunOptionsIsOpen = true
|
||||
}
|
||||
@@ -538,6 +572,10 @@
|
||||
askingForConfirmation = {
|
||||
title: `Confirm re-running the selected jobs`,
|
||||
confirmBtnText: `Re-run ${jobIdsToReRun.length} jobs`,
|
||||
// The server skips resolution for operators, who cannot resolve.
|
||||
description: operatingUser.current?.operator
|
||||
? undefined
|
||||
: "Failed or canceled jobs among them will be marked resolved, with the new run's id as the note.",
|
||||
type: 'reload',
|
||||
onConfirm: async () => {
|
||||
await reRunJobs(jobIdsToReRun, batchReRunOptions)
|
||||
@@ -867,6 +905,9 @@
|
||||
askingForConfirmation = undefined
|
||||
}}
|
||||
>
|
||||
{#if askingForConfirmation?.description}
|
||||
<p class="text-xs text-secondary">{askingForConfirmation.description}</p>
|
||||
{/if}
|
||||
{#if askingForConfirmation?.preContent}
|
||||
<pre>{askingForConfirmation.preContent}</pre>
|
||||
<Toggle
|
||||
@@ -1121,6 +1162,7 @@
|
||||
action: () => {
|
||||
manualSelectionMode = 'rerun'
|
||||
selectedIds = []
|
||||
filterMatchedIds = undefined
|
||||
batchRerunOptionsIsOpen = true
|
||||
}
|
||||
},
|
||||
@@ -1128,7 +1170,7 @@
|
||||
? [
|
||||
{
|
||||
// Operators are rejected by the endpoint, so offering it would only 403.
|
||||
displayName: 'Resolve failed jobs',
|
||||
displayName: 'Resolve failed or canceled jobs',
|
||||
action: () => (
|
||||
(manualSelectionMode = 'resolve'),
|
||||
(selectedIds = []),
|
||||
@@ -1210,7 +1252,7 @@
|
||||
class="rounded-md bg-surface-tertiary border absolute inset-0 mb-4 flex flex-col items-center justify-center gap-3 p-4"
|
||||
>
|
||||
<p class="text-xs text-secondary text-center max-w-xs">
|
||||
Resolving keeps the run a failure but stops it showing as one in the runs list.
|
||||
Resolving keeps the run's status but marks it as handled in the runs list.
|
||||
</p>
|
||||
<TextInput
|
||||
bind:value={resolutionNote}
|
||||
@@ -1303,15 +1345,59 @@
|
||||
{/snippet}
|
||||
|
||||
{#snippet batchRerunOptions()}
|
||||
{#await import('$lib/components/runs/BatchReRunOptionsPane.svelte') then BatchReRunOptionsPane}
|
||||
<BatchReRunOptionsPane.default
|
||||
{selectedIds}
|
||||
onCancel={() => ((batchRerunOptionsIsOpen = false), (manualSelectionMode = undefined))}
|
||||
onConfirm={async (options) => {
|
||||
await onReRunSelectedJobs(options)
|
||||
}}
|
||||
/>
|
||||
{/await}
|
||||
<div class="flex flex-col h-full">
|
||||
{#if filterMatchedIds}
|
||||
<div class="flex flex-col gap-1 pb-2 text-xs text-secondary">
|
||||
<div class="flex flex-row items-center gap-2">
|
||||
<span>{filterMatchedIds.length} jobs match the filters, re-run at most</span>
|
||||
<TextInput
|
||||
inputProps={{ type: 'number', min: 1, placeholder: 'All' }}
|
||||
size="sm"
|
||||
class="w-24"
|
||||
bind:value={
|
||||
() => rerunLimit?.toString() ?? '',
|
||||
(v) => setRerunLimit(v ? parseInt(v.toString()) : undefined)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
{#if filters.val.resolved === 'unresolved'}
|
||||
<span class="text-hint">
|
||||
Oldest first. Re-run jobs are marked resolved, so the next batch starts where this one
|
||||
stops.
|
||||
</span>
|
||||
{:else}
|
||||
<div class="flex flex-row items-center gap-2 text-orange-600 dark:text-orange-400">
|
||||
<TriangleAlertIcon size={14} class="shrink-0" />
|
||||
<span>
|
||||
Resolved runs are included, so the next batch will pick these same jobs again.
|
||||
</span>
|
||||
<Button
|
||||
variant="default"
|
||||
unifiedSize="xs"
|
||||
btnClasses="shrink-0"
|
||||
onClick={() => {
|
||||
filters.val.resolved = 'unresolved'
|
||||
onRerunAllJobsMatchingFilters()
|
||||
}}
|
||||
>
|
||||
Hide resolved runs
|
||||
</Button>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
<div class="flex-1 min-h-0 flex flex-col">
|
||||
{#await import('$lib/components/runs/BatchReRunOptionsPane.svelte') then BatchReRunOptionsPane}
|
||||
<BatchReRunOptionsPane.default
|
||||
{selectedIds}
|
||||
onCancel={() => ((batchRerunOptionsIsOpen = false), (manualSelectionMode = undefined))}
|
||||
onConfirm={async (options) => {
|
||||
await onReRunSelectedJobs(options)
|
||||
}}
|
||||
/>
|
||||
{/await}
|
||||
</div>
|
||||
</div>
|
||||
{/snippet}
|
||||
|
||||
{#snippet jobPreview(pending?: Snippet)}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
type OnBehalfOfChoice
|
||||
} from '$lib/components/OnBehalfOfSelector.svelte'
|
||||
import { canUserBypassRuleKind, protectionRulesState } from '$lib/workspaceProtectionRules.svelte'
|
||||
import { FRONTEND_SDK_SCOPES } from '$lib/components/raw_apps/sdkScopes'
|
||||
import { FRONTEND_SDK_SCOPES, sdkScopesToConfirm } from '$lib/components/raw_apps/sdkScopes'
|
||||
import { logFeatureUsage } from '$lib/utils/featureUsage'
|
||||
import {
|
||||
useOperatingUser,
|
||||
@@ -436,7 +436,7 @@
|
||||
tooltip="Each viewer approves these scopes before the app runs. The app's code, or an XSS bug in it, can use them as that viewer."
|
||||
>
|
||||
{#snippet badge()}
|
||||
{#if policy.frontend_sdk_scopes?.length}
|
||||
{#if sdkScopesToConfirm(policy.frontend_sdk_scopes ?? []).length}
|
||||
<div class="flex grow min-w-0 flex-wrap gap-1 ps-2">
|
||||
{#each FRONTEND_SDK_SCOPES.filter( (s) => policy.frontend_sdk_scopes.includes(s.value) ) as scope (scope.value)}
|
||||
<Badge twBgColor="bg-surface-sunken" twTextColor="text-primary"
|
||||
@@ -464,7 +464,9 @@
|
||||
? [...current, scope.value]
|
||||
: current.filter((s) => s !== scope.value)
|
||||
// Keep the curated order so the consent banner and the stored
|
||||
// consent compare stably across deploys.
|
||||
// consent compare stably across deploys. A leftover implicit scope is
|
||||
// not in the list, so it drops here rather than keep minting a token
|
||||
// for an app whose toggles all read off.
|
||||
const ordered = FRONTEND_SDK_SCOPES.map((s) => s.value).filter((s) =>
|
||||
next.includes(s)
|
||||
)
|
||||
@@ -481,7 +483,7 @@
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{#if policy.frontend_sdk_scopes?.length}
|
||||
{#if sdkScopesToConfirm(policy.frontend_sdk_scopes ?? []).length}
|
||||
<div class="mt-3">
|
||||
<Alert type="info" title="Redeploy to use the SDK from a sandboxed app" size="xs">
|
||||
A sandboxed app calls the API cross-origin, which older <code>windmill-client</code>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
import type { Item } from '$lib/utils'
|
||||
import { Button } from '$lib/components/common'
|
||||
import { AppService, OpenAPI } from '$lib/gen'
|
||||
import { userStore, type UserExt } from '$lib/stores'
|
||||
import { userStore, workspaceStore, type UserExt } from '$lib/stores'
|
||||
import { getUserExt } from '$lib/user'
|
||||
import { ExternalLink, Pen } from 'lucide-svelte'
|
||||
import { page } from '$app/state'
|
||||
@@ -254,7 +254,7 @@
|
||||
<PublicApp
|
||||
{app}
|
||||
{workspace}
|
||||
user={appUser ?? $userStore}
|
||||
user={appUser ?? (workspace === $workspaceStore ? $userStore : undefined)}
|
||||
{notExists}
|
||||
{noPermission}
|
||||
jwtError={false}
|
||||
|
||||
@@ -211,7 +211,7 @@
|
||||
<!-- The icon slot itself: the kind icon until the row is hovered (or
|
||||
selection mode is on), the checkbox from then on. Both are stacked in a
|
||||
fixed 16px box and swapped with visibility so nothing shifts. -->
|
||||
<div class="shrink relative w-4 h-4">
|
||||
<div class="shrink-0 relative w-4 h-4">
|
||||
<div
|
||||
class={twMerge(
|
||||
'absolute inset-0',
|
||||
@@ -261,11 +261,11 @@
|
||||
{/if}
|
||||
|
||||
{#if canFavorite && (kind == 'app' || kind == 'raw_app' || kind == 'script' || kind == 'flow' || kind == 'agent')}
|
||||
<div class="center-center h-full text-xs font-semibold text-secondary w-9">
|
||||
<div class="center-center h-full text-xs font-semibold text-secondary w-9 shrink-0">
|
||||
<Star {kind} {path} {workspaceId} {summary} />
|
||||
</div>
|
||||
{:else}
|
||||
<div class="w-9"></div>
|
||||
<div class="w-9 shrink-0"></div>
|
||||
{/if}
|
||||
|
||||
<div data-row-actions class="flex gap-1 items-center justify-end pr-2">
|
||||
@@ -275,25 +275,26 @@
|
||||
|
||||
{#snippet rowContent(withIcon: boolean)}
|
||||
{#if withIcon}
|
||||
<div class="shrink">
|
||||
<div class="shrink-0">
|
||||
<RowIcon {kind} {triggerKind} />
|
||||
</div>
|
||||
{/if}
|
||||
<div class="grow min-w-0">
|
||||
<div
|
||||
class={twMerge(
|
||||
'text-emphasis flex-wrap text-left text-xs font-semibold',
|
||||
titleBadge ? 'inline-flex items-center gap-2' : ''
|
||||
)}
|
||||
>
|
||||
<div class="text-emphasis flex items-center gap-2 text-left text-xs font-semibold">
|
||||
{#if customSummary}
|
||||
{@render customSummary?.()}
|
||||
{:else if marked}
|
||||
{@html marked}
|
||||
<div class="min-w-0">{@render customSummary()}</div>
|
||||
{:else}
|
||||
{!summary || summary.length == 0 ? displayPath : summary}
|
||||
<span class="truncate" title={summary || displayPath}>
|
||||
{#if marked}
|
||||
{@html marked}
|
||||
{:else}
|
||||
{!summary || summary.length == 0 ? displayPath : summary}
|
||||
{/if}
|
||||
</span>
|
||||
{/if}
|
||||
{#if titleBadge}
|
||||
<span class="shrink-0">{@render titleBadge()}</span>
|
||||
{/if}
|
||||
{@render titleBadge?.()}
|
||||
</div>
|
||||
<div class="text-hint text-3xs truncate text-left font-normal" title={path}>
|
||||
{#if pathDisplay}
|
||||
|
||||
@@ -98,6 +98,7 @@
|
||||
})
|
||||
|
||||
const candidatePaths = $derived(extractCandidatePaths(message.content))
|
||||
const reasoningPlugins = [gfmPlugin(), { renderer: { a: LinkRenderer } }]
|
||||
const rendererPlugin = {
|
||||
renderer: {
|
||||
pre: CodeDisplay,
|
||||
@@ -158,7 +159,7 @@
|
||||
labelClass="truncate"
|
||||
contentClass="font-main text-secondary {markdownProse.xs}"
|
||||
>
|
||||
<Markdown md={reasoning} plugins={[gfmPlugin()]} />
|
||||
<Markdown md={reasoning} plugins={reasoningPlugins} />
|
||||
</ChatCollapsibleCard>
|
||||
{/if}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user