windmill-cli 1.846.0 → 1.847.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/main.js +81 -15
- package/package.json +1 -1
package/esm/main.js
CHANGED
|
@@ -16766,7 +16766,7 @@ var init_OpenAPI = __esm(() => {
|
|
|
16766
16766
|
PASSWORD: undefined,
|
|
16767
16767
|
TOKEN: getEnv3("WM_TOKEN"),
|
|
16768
16768
|
USERNAME: undefined,
|
|
16769
|
-
VERSION: "1.
|
|
16769
|
+
VERSION: "1.847.0",
|
|
16770
16770
|
WITH_CREDENTIALS: true,
|
|
16771
16771
|
interceptors: {
|
|
16772
16772
|
request: new Interceptors,
|
|
@@ -20074,7 +20074,7 @@ var init_auth = __esm(async () => {
|
|
|
20074
20074
|
});
|
|
20075
20075
|
|
|
20076
20076
|
// src/core/constants.ts
|
|
20077
|
-
var WM_FORK_PREFIX = "wm-fork", VERSION = "1.
|
|
20077
|
+
var WM_FORK_PREFIX = "wm-fork", VERSION = "1.847.0";
|
|
20078
20078
|
|
|
20079
20079
|
// src/utils/resource_folders.ts
|
|
20080
20080
|
import { existsSync } from "node:fs";
|
|
@@ -58794,7 +58794,7 @@ var init_openflow = __esm(() => {
|
|
|
58794
58794
|
openflow_default = {
|
|
58795
58795
|
openapi: "3.0.3",
|
|
58796
58796
|
info: {
|
|
58797
|
-
version: "1.
|
|
58797
|
+
version: "1.847.0",
|
|
58798
58798
|
title: "OpenFlow Spec",
|
|
58799
58799
|
contact: {
|
|
58800
58800
|
name: "Ruben Fiszel",
|
|
@@ -72679,7 +72679,7 @@ async function loadRunnablesFromBackend(backendPath, defaultTs = "bun") {
|
|
|
72679
72679
|
...lock ? { lock } : {}
|
|
72680
72680
|
};
|
|
72681
72681
|
}
|
|
72682
|
-
} else if (runnable?.type === "script" || runnable?.type === "hubscript" || runnable?.type === "flow") {
|
|
72682
|
+
} else if (runnable?.type === "script" || runnable?.type === "hubscript" || runnable?.type === "flow" || runnable?.type === "agent") {
|
|
72683
72683
|
const { type, schema: _schema, ...rest } = runnable;
|
|
72684
72684
|
runnable.type = "path";
|
|
72685
72685
|
runnable.runType = type;
|
|
@@ -74701,6 +74701,38 @@ function buildWmillTs(runnables, inlineSchemaOverrides = {}, pathSchemaOverrides
|
|
|
74701
74701
|
}
|
|
74702
74702
|
return Z(runnables);
|
|
74703
74703
|
}
|
|
74704
|
+
function agentRunnableSchema(memory) {
|
|
74705
|
+
const managed = memory?.kind === "compaction" || (memory?.kind === "window" || memory?.kind === "auto") && Boolean(memory.context_length);
|
|
74706
|
+
const legacy = memory?.kind === "manual";
|
|
74707
|
+
const history = {};
|
|
74708
|
+
if (managed) {
|
|
74709
|
+
history.memory_id = {
|
|
74710
|
+
type: "string",
|
|
74711
|
+
description: "The conversation the message belongs to: reuse it to continue one, or omit it for a single run"
|
|
74712
|
+
};
|
|
74713
|
+
} else if (!legacy) {
|
|
74714
|
+
history.previous_messages = {
|
|
74715
|
+
type: "array",
|
|
74716
|
+
description: "The history to answer from, as chat messages: this agent keeps no memory",
|
|
74717
|
+
items: { type: "object" }
|
|
74718
|
+
};
|
|
74719
|
+
}
|
|
74720
|
+
return {
|
|
74721
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
74722
|
+
type: "object",
|
|
74723
|
+
properties: {
|
|
74724
|
+
user_message: { type: "string", description: "The message to answer" },
|
|
74725
|
+
...history,
|
|
74726
|
+
user_attachments: {
|
|
74727
|
+
type: "array",
|
|
74728
|
+
description: "Files the message carries, as object storage references",
|
|
74729
|
+
items: { type: "object", resourceType: "s3object" }
|
|
74730
|
+
}
|
|
74731
|
+
},
|
|
74732
|
+
required: ["user_message"],
|
|
74733
|
+
order: ["user_message", ...Object.keys(history), "user_attachments"]
|
|
74734
|
+
};
|
|
74735
|
+
}
|
|
74704
74736
|
async function fetchPathRunnableSchemas(workspaceId, runnables) {
|
|
74705
74737
|
const schemas = {};
|
|
74706
74738
|
for (const [runnableId, runnable] of Object.entries(runnables)) {
|
|
@@ -74718,6 +74750,12 @@ async function fetchPathRunnableSchemas(workspaceId, runnables) {
|
|
|
74718
74750
|
});
|
|
74719
74751
|
if (script.schema)
|
|
74720
74752
|
schemas[runnableId] = script.schema;
|
|
74753
|
+
} else if (runnable.runType === "agent") {
|
|
74754
|
+
const agent = await getResource({
|
|
74755
|
+
workspace: workspaceId,
|
|
74756
|
+
path: runnable.path
|
|
74757
|
+
});
|
|
74758
|
+
schemas[runnableId] = agentRunnableSchema(agent.value?.memory);
|
|
74721
74759
|
} else if (runnable.runType === "flow") {
|
|
74722
74760
|
const flow = await getFlowByPath({
|
|
74723
74761
|
workspace: workspaceId,
|
|
@@ -74735,7 +74773,7 @@ async function fetchPathRunnableSchemas(workspaceId, runnables) {
|
|
|
74735
74773
|
}
|
|
74736
74774
|
function convertRunnablesToApiFormat(runnables) {
|
|
74737
74775
|
for (const [runnableId, runnable] of Object.entries(runnables)) {
|
|
74738
|
-
if (runnable?.type === "script" || runnable?.type === "hubscript" || runnable?.type === "flow") {
|
|
74776
|
+
if (runnable?.type === "script" || runnable?.type === "hubscript" || runnable?.type === "flow" || runnable?.type === "agent") {
|
|
74739
74777
|
const originalType = runnable.type;
|
|
74740
74778
|
runnable.runType = originalType;
|
|
74741
74779
|
runnable.type = "path";
|
|
@@ -74896,8 +74934,8 @@ async function getJobStatus(workspace, jobId) {
|
|
|
74896
74934
|
id: jobId
|
|
74897
74935
|
});
|
|
74898
74936
|
}
|
|
74899
|
-
async function streamJobWithSSE(workspace, jobId, reqId, ws, baseUrl, token) {
|
|
74900
|
-
const sseUrl = `${baseUrl}api/w/${workspace}/jobs_u/getupdate_sse/${jobId}?fast=true
|
|
74937
|
+
async function streamJobWithSSE(workspace, jobId, reqId, ws, baseUrl, token, streamOffset) {
|
|
74938
|
+
const sseUrl = `${baseUrl}api/w/${workspace}/jobs_u/getupdate_sse/${jobId}?fast=true` + (streamOffset !== undefined ? `&stream_offset=${streamOffset}` : "");
|
|
74901
74939
|
const extraHeaders = getHeaders2();
|
|
74902
74940
|
const response = await fetch(sseUrl, {
|
|
74903
74941
|
headers: {
|
|
@@ -74916,6 +74954,7 @@ async function streamJobWithSSE(workspace, jobId, reqId, ws, baseUrl, token) {
|
|
|
74916
74954
|
}
|
|
74917
74955
|
const decoder = new TextDecoder;
|
|
74918
74956
|
let buffer = "";
|
|
74957
|
+
let lastOffset = streamOffset;
|
|
74919
74958
|
try {
|
|
74920
74959
|
while (true) {
|
|
74921
74960
|
const { done, value } = await reader.read();
|
|
@@ -74934,7 +74973,7 @@ async function streamJobWithSSE(workspace, jobId, reqId, ws, baseUrl, token) {
|
|
|
74934
74973
|
if (type === "ping" || type === "timeout") {
|
|
74935
74974
|
if (type === "timeout") {
|
|
74936
74975
|
reader.cancel();
|
|
74937
|
-
return;
|
|
74976
|
+
return streamJobWithSSE(workspace, jobId, reqId, ws, baseUrl, token, lastOffset);
|
|
74938
74977
|
}
|
|
74939
74978
|
continue;
|
|
74940
74979
|
}
|
|
@@ -74958,6 +74997,9 @@ async function streamJobWithSSE(workspace, jobId, reqId, ws, baseUrl, token) {
|
|
|
74958
74997
|
reader.cancel();
|
|
74959
74998
|
return;
|
|
74960
74999
|
}
|
|
75000
|
+
if (update.stream_offset !== undefined) {
|
|
75001
|
+
lastOffset = update.stream_offset;
|
|
75002
|
+
}
|
|
74961
75003
|
if (update.new_result_stream !== undefined) {
|
|
74962
75004
|
ws.send(JSON.stringify({
|
|
74963
75005
|
type: "streamJobUpdate",
|
|
@@ -77462,7 +77504,8 @@ async function pushNativeTrigger(workspace, filePath, _remoteTrigger, localTrigg
|
|
|
77462
77504
|
script_path: localTrigger.script_path,
|
|
77463
77505
|
is_flow: localTrigger.is_flow,
|
|
77464
77506
|
service_config: localTrigger.service_config,
|
|
77465
|
-
summary: localTrigger.summary
|
|
77507
|
+
summary: localTrigger.summary,
|
|
77508
|
+
connection_path: localTrigger.connection_path
|
|
77466
77509
|
};
|
|
77467
77510
|
if (remoteTrigger) {
|
|
77468
77511
|
const localCompare = {
|
|
@@ -87095,7 +87138,7 @@ An app can be demoed by recording a session: every interaction becomes a step ca
|
|
|
87095
87138
|
|
|
87096
87139
|
Apply it to customer data, internal notes and anything else a viewer of the demo should not see. It costs nothing when the app is never recorded.
|
|
87097
87140
|
|
|
87098
|
-
### Chat UIs over a flow in chat mode
|
|
87141
|
+
### Chat UIs over a flow in chat mode or a saved agent
|
|
87099
87142
|
|
|
87100
87143
|
A flow deployed with chat mode on is a chat backend (streaming answer, tool calls, memory, conversation history). Do not drive it through a runnable: add \`@windmill-labs/chat-sdk\` to \`package.json\` and use it directly, it detects the app's Windmill and credential.
|
|
87101
87144
|
|
|
@@ -87108,9 +87151,31 @@ const chat = useWindmillChat({ flowPath: 'f/support/assistant' })
|
|
|
87108
87151
|
|
|
87109
87152
|
\`@windmill-labs/chat-sdk/ai-sdk\` gives a \`ChatTransport\` for the Vercel AI SDK's \`useChat\`, \`@windmill-labs/chat-sdk/assistant-ui\` a runtime for assistant-ui. The flow must be deployed, not a draft. A sandboxed app needs \`jobs:run\` in its frontend SDK scopes, plus \`flow_conversations:write\` for the conversation sidebar; without them the chat keeps history in the browser.
|
|
87110
87153
|
|
|
87154
|
+
#### A saved agent: an \`agent\` runnable
|
|
87155
|
+
|
|
87156
|
+
Chat with a saved AI agent (an \`ai_agent\` resource) through an \`agent\` runnable, a path runnable whose \`path\` is the agent's. Each call runs one turn of the agent's chat as the app, so a sandboxed app declares no frontend SDK scope, viewers get no consent prompt and need no access to the agent. Prefer it in every app, sandboxed or not:
|
|
87157
|
+
|
|
87158
|
+
In \`raw_app.yaml\`:
|
|
87159
|
+
|
|
87160
|
+
\`\`\`yaml
|
|
87161
|
+
runnables:
|
|
87162
|
+
chat:
|
|
87163
|
+
type: agent
|
|
87164
|
+
path: f/support/agent
|
|
87165
|
+
\`\`\`
|
|
87166
|
+
|
|
87167
|
+
\`\`\`tsx
|
|
87168
|
+
import { useWindmillChat } from '@windmill-labs/chat-sdk/react'
|
|
87169
|
+
import * as wmill from './wmill'
|
|
87170
|
+
|
|
87171
|
+
const chat = useWindmillChat({ wmill, runnable: 'chat' })
|
|
87172
|
+
\`\`\`
|
|
87173
|
+
|
|
87174
|
+
\`runnable\` is the runnable's key; each runnable keeps its own conversations. The runnable takes \`user_message\` and \`memory_id\`, the conversation id, which the chat fills in: the agent remembers earlier turns of a conversation, and a signed-in viewer's conversations are theirs alone. Called directly as \`backend.<key>({ user_message })\` without \`memory_id\`, it is a single run with no conversation, for a one-off question. The chat needs an agent with managed memory. An agent whose memory is off keeps none: its runnable takes \`previous_messages\` (chat messages) instead of \`memory_id\`, and the app keeps the history itself. The chat keeps its transcript in the app's own storage. \`chat.stop()\` stops following without cancelling the turn, and a message sent while it still runs is refused with \`TurnRunningError\`. Attachments are not supported this way.
|
|
87175
|
+
|
|
87111
87176
|
## Backend runnables
|
|
87112
87177
|
|
|
87113
|
-
Each runnable has a unique key (used to call it from the frontend) and one of
|
|
87178
|
+
Each runnable has a unique key (used to call it from the frontend) and one of five types:
|
|
87114
87179
|
|
|
87115
87180
|
| Type | What it is |
|
|
87116
87181
|
|---|---|
|
|
@@ -87118,6 +87183,7 @@ Each runnable has a unique key (used to call it from the frontend) and one of fo
|
|
|
87118
87183
|
| \`script\` | Reference to an existing workspace script by path. |
|
|
87119
87184
|
| \`flow\` | Reference to an existing workspace flow by path. |
|
|
87120
87185
|
| \`hubscript\` | Reference to a hub script by path. |
|
|
87186
|
+
| \`agent\` | Reference to a saved AI agent by path. Each call is one turn of its chat (see the chat section above). |
|
|
87121
87187
|
|
|
87122
87188
|
### Inline runnables
|
|
87123
87189
|
|
|
@@ -87159,9 +87225,9 @@ An inline runnable runs as an ordinary Windmill job. \`import * as wmill from 'w
|
|
|
87159
87225
|
|
|
87160
87226
|
Use only \`wmill\` functions the SDK actually exports; for an endpoint none of them covers, the generated service classes (\`JobService\`, \`ScriptService\`, ...) are importable from \`windmill-client\`. What is not available is a name you guessed at: \`getBaseUrl\` and \`getWorkspaceToken\` are inventions, not API.
|
|
87161
87227
|
|
|
87162
|
-
### Path runnables (script / flow / hubscript)
|
|
87228
|
+
### Path runnables (script / flow / hubscript / agent)
|
|
87163
87229
|
|
|
87164
|
-
When \`type\` is \`script\`, \`flow\`, or \`
|
|
87230
|
+
When \`type\` is \`script\`, \`flow\`, \`hubscript\` or \`agent\`, the runnable just stores a \`path\` to an existing workspace or hub item — no inline code. The referenced item's input/output schema becomes the runnable's surface; an agent's is \`user_message\` and \`user_attachments\`, plus \`memory_id\` when the agent keeps managed memory or \`previous_messages\` when its memory is off.
|
|
87165
87231
|
|
|
87166
87232
|
Before writing an inline runnable, look for a workspace script or flow that already does the job, or a Hub script (a prebuilt integration at \`hub/<version>/<app>/<name>\`) for a third-party service, and reference it instead of copying its logic.
|
|
87167
87233
|
|
|
@@ -87170,7 +87236,7 @@ Before writing an inline runnable, look for a workspace script or flow that alre
|
|
|
87170
87236
|
This decides whether an app works before anything is deployed:
|
|
87171
87237
|
|
|
87172
87238
|
- **Inline runnables run the app's current code.** The editor sends the runnable's source with each request, so an inline runnable works in the preview with nothing deployed.
|
|
87173
|
-
- **Path runnables (\`script\` / \`flow\` / \`hubscript\`) run the DEPLOYED item at that path.** So do \`wmill.runFlow\`, \`wmill.runFlowAsync\` and \`wmill.runScriptByPath\` called from inside a runnable. A draft — including a draft you just created — does not exist for them.
|
|
87239
|
+
- **Path runnables (\`script\` / \`flow\` / \`hubscript\` / \`agent\`) run the DEPLOYED item at that path.** So do \`wmill.runFlow\`, \`wmill.runFlowAsync\` and \`wmill.runScriptByPath\` called from inside a runnable. A draft — including a draft you just created — does not exist for them.
|
|
87174
87240
|
|
|
87175
87241
|
So an app wired to a flow you just wrote does nothing until **that flow is deployed**. The app itself does NOT have to be deployed for this: the preview runs the app's draft, so the referenced flow is the only thing that has to exist deployed.
|
|
87176
87242
|
|
|
@@ -87280,7 +87346,7 @@ def main(user_id: str):
|
|
|
87280
87346
|
7. **Mark sensitive UI with \`data-wm-no-record\`** — it is what keeps that data out of a recorded demo; passwords are handled for you.
|
|
87281
87347
|
8. **Reach for \`backendAsync\` + \`waitJob\`** for long work — never a hand-written job-polling runnable.
|
|
87282
87348
|
9. **Deploy what a path runnable points at** — a path runnable aimed at a draft fails at runtime; tell the user what needs deploying.
|
|
87283
|
-
10. **Use \`@windmill-labs/chat-sdk\` for a chat over a chat-mode flow** — never a runnable that runs
|
|
87349
|
+
10. **Use \`@windmill-labs/chat-sdk\` for a chat over a chat-mode flow or a saved agent** — never hand-roll a runnable that runs it and polls its stream; a saved agent is an \`agent\` runnable passed as \`{ wmill, runnable }\`.
|
|
87284
87350
|
`,
|
|
87285
87351
|
triggers: `---
|
|
87286
87352
|
name: triggers
|