mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-15 16:03:02 +00:00
* feat: guide the AI when no resource type fits a service Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: report a failed resource type search and model a synced instance in evals Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: keep named resource types first and list only related names on search failure Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: point the sync note at the hub sync button only Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor: list the instance's resource types when the search finds nothing Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: let the user create a resource type instead of syncing the hub Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: make the linked-variable resource the default, not the only option Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: add a cli eval for a service without a hub resource type Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: keep the resource type search fresh and serve it without embeddings Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: let the global chat create a resource type after the user confirms it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: simulate create_resource_type in global evals and fix the in-house API checklists Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: reuse unchanged custom resource type vectors and match names case-insensitively Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: add the unsynced note whatever the resource type search returns Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: carry the no-type rule into flow inputs and script parameters, and ask the chat to relay the sync Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: tell script chat to hand the user the schema it cannot create Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: skip the resource type fingerprint query when no index is loaded Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: index resource types locally when the hub's embeddings cannot be fetched Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: match short service names in the resource type text fallback Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: name custom resource types with the c_ prefix the Resources page uses Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: require the c_ prefix in in-house API evals and a real sync mention Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: cover workspace scoping of the resource type text search Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: say the form adds the c_ prefix unless an admin turns it off Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: refresh resource type names and the resources tab after the chat creates a type Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * perf: fingerprint resource types without sorting every schema Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: tell the global chat in each message when the hub's types are not synced Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: send users who cannot deploy to an admin for a resource type, and have the cli list types first Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015YR13nJWziUSWktZwhC7dx * refactor: move the resource type search index changes to their own pull request Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015YR13nJWziUSWktZwhC7dx --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
3.5 KiB
Markdown
29 lines
3.5 KiB
Markdown
# Windmill Script Writing Guide
|
|
|
|
## General Principles
|
|
|
|
- A script's inputs are its parameters. Credentials and configuration come in as resource-typed parameters, never hard-coded or read from the environment; the language section below shows how that language declares parameters
|
|
- When no resource type exists for a service, still take its connection as one resource-typed parameter, of a custom type holding the connection fields (base URL, account identifiers, credentials), its secret in a variable the resource references. A custom type is named `c_<name>`, which keeps it apart from a hub type synced later: the parameter takes `RT.C<Name>` in TypeScript, a `c_<name>` TypedDict in Python. A plain string parameter or a variable read inside the code only when the user asks for it: the resource keeps a connection's fields together, lets whoever runs the script pick an existing connection, and keeps the secret out of the arguments a run records. If the instance is reported as not having synced the Windmill Hub's resource types, mention that a superadmin can sync them, since the hub has types for most services. Otherwise, or when the user prefers it to syncing, propose the resource type and ask before creating it
|
|
- A Windmill Hub script takes a resource type the hub publishes, so on an instance that has not synced the hub's types that type is missing: say so, and that a superadmin can sync them, before asking for a resource of it. Hub scripts often declare the type inline (`type Stripe = { token: string }`), which is still the `stripe` resource type; in code you write, name it the way the language section shows (`RT.Stripe` in TypeScript) rather than copying the inline declaration
|
|
<!-- cli-only -->
|
|
- Before relying on a resource type, a hub script's included, run `wmill resource-type list`: it shows whether the workspace has the type, and warns when the instance has not synced the hub's types
|
|
<!-- /cli-only -->
|
|
- Libraries are installed automatically - do not show installation instructions
|
|
- In a language with an entrypoint function (TypeScript, Python, Go, Rust, PHP, R, …), name it `main` (`Main` in C#) and do not call it; in TypeScript it must be async. SQL, GraphQL, Bash, PowerShell and Ansible scripts have no `main`: their language section shows how they take arguments
|
|
- Where the language has a Windmill client (`wmill`), use it to interact with the platform
|
|
- A script's input schema may carry a top-level `prompt_for_ai` string: its author's instructions to an AI choosing the inputs. Follow it when you pick arguments to run that script, and keep it when you rewrite the schema
|
|
|
|
## Return Values
|
|
|
|
- A script can return any JSON-serializable value; a SQL script returns the rows its query produces
|
|
- Return values become available to subsequent flow steps via `results.step_id`
|
|
|
|
## Preprocessor Scripts
|
|
|
|
Preprocessor scripts process raw trigger data from various sources (webhook, custom HTTP route, SQS, WebSocket, Kafka, NATS, MQTT, AMQP, Postgres, GCP Pub/Sub, Azure, or email) before passing it to the flow. This separates the trigger logic from the flow logic and keeps the auto-generated UI clean.
|
|
|
|
A preprocessor is written in TypeScript or Python: its function is named `preprocessor` instead of `main`, and it receives a single parameter called `event` (the language section gives its type).
|
|
|
|
The returned object determines the parameter values passed to the flow.
|
|
e.g., `{ b: 1, a: 2 }` calls the flow with `a = 2` and `b = 1`, assuming the flow has two inputs called `a` and `b`.
|