langflower 0.2.2 → 0.4.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.
Files changed (68) hide show
  1. package/README.md +34 -29
  2. package/dist/{chunk-KOS7BXAM.js → chunk-32BC3YXC.js} +1 -1
  3. package/dist/{chunk-26UB55E5.js → chunk-5B3555QF.js} +2 -0
  4. package/dist/{chunk-X3FU465E.js → chunk-P3QJHZO7.js} +1 -1
  5. package/dist/{chunk-3Z7Q6SQ5.js → chunk-VVJLF47H.js} +93 -10
  6. package/dist/index.js +5743 -2626
  7. package/docs/{public → assets/public}/README.md +8 -1
  8. package/docs/{public → assets/public}/configuration.md +7 -0
  9. package/docs/{public → assets/public}/extending.md +9 -2
  10. package/docs/{public → assets/public}/getting-started.md +11 -4
  11. package/docs/{public → assets/public}/how-it-works.md +7 -0
  12. package/docs/{public → assets/public}/launcher.md +11 -2
  13. package/docs/{public → assets/public}/product.md +17 -3
  14. package/docs/{public → assets/public}/using-the-editor.md +7 -0
  15. package/docs/{public → assets/public}/workflows.md +7 -0
  16. package/package.json +2 -2
  17. package/ui-dist/assets/langflower-mark.svg +33 -0
  18. package/ui-dist/{chunk-IASSR2ON.js → chunk-33CXNPF2.js} +1 -1
  19. package/ui-dist/chunk-SNO65Y6K.js +4 -0
  20. package/ui-dist/index.html +2 -2
  21. package/ui-dist/main-GN43PQD5.js +323 -0
  22. package/ui-dist/styles-DMRPMU4V.css +1 -0
  23. package/vendor/node-sdk/dist/node-factory/define-llm-node/default-llm-ports.d.ts +11 -1
  24. package/vendor/node-sdk/dist/node-factory/define-llm-node/define-llm-node.d.ts +3 -1
  25. package/vendor/node-sdk/dist/node-factory/define-llm-node/define-llm-node.js +1 -0
  26. package/vendor/node-sdk/dist/node-factory/define-llm-node/steer-control.d.ts +5 -2
  27. package/vendor/node-sdk/dist/node-factory/define-llm-node/steer-control.js +3 -2
  28. package/vendor/node-sdk/dist/node-factory/define-node/define-node.d.ts +2 -1
  29. package/vendor/node-sdk/dist/node-factory/define-reactive-node/capabilities.d.ts +32 -1
  30. package/vendor/node-sdk/dist/node-factory/define-reactive-node/define-reactive-node.d.ts +3 -1
  31. package/vendor/node-sdk/dist/node-factory/define-reactive-node/define-reactive-node.js +4 -1
  32. package/vendor/node-sdk/dist/node-factory/define-reactive-node/hitl-config.d.ts +14 -0
  33. package/vendor/node-sdk/dist/node-factory/define-reactive-node/hitl-config.js +24 -1
  34. package/vendor/node-sdk/dist/node-factory/define-reactive-node/io-helpers.d.ts +13 -4
  35. package/vendor/node-sdk/dist/node-factory/define-reactive-node/port-meta.d.ts +12 -2
  36. package/vendor/node-sdk/dist/node-factory/define-reactive-node/types.d.ts +8 -0
  37. package/vendor/node-sdk/dist/node-factory/define-reactive-node/ui-schema-inference.d.ts +18 -0
  38. package/vendor/node-sdk/dist/node-state.d.ts +28 -0
  39. package/vendor/node-sdk/dist/node-state.js +1 -0
  40. package/vendor/node-sdk/package.json +1 -1
  41. package/vendor/runtime/dist/feed-log-fold.d.ts +26 -0
  42. package/vendor/runtime/dist/feed-log-fold.js +113 -0
  43. package/vendor/runtime/dist/runtime-editor.d.ts +6 -0
  44. package/vendor/runtime/dist/runtime-editor.js +95 -2
  45. package/vendor/runtime/dist/runtime-runner.d.ts +28 -3
  46. package/vendor/runtime/dist/runtime-runner.js +101 -9
  47. package/vendor/runtime/dist/runtime.d.ts +5 -1
  48. package/vendor/runtime/dist/runtime.js +2 -0
  49. package/vendor/runtime/dist/types.d.ts +91 -5
  50. package/vendor/runtime/dist/wire-type.d.ts +12 -0
  51. package/vendor/runtime/dist/wire-type.js +18 -0
  52. package/vendor/server/skeleton/instructions.md +3 -1
  53. package/vendor/server/skeleton/nodes/hello-embed/README.md +1 -1
  54. package/vendor/server/skeleton/nodes/hello-embed/package.json +1 -1
  55. package/vendor/server/skeleton/nodes/my-nodes/README.md +12 -0
  56. package/vendor/server/skeleton/nodes/my-nodes/package.json +1 -1
  57. package/vendor/server/skeleton/nodes/my-nodes/review-gate.ts +5 -0
  58. package/vendor/server/skeleton/skills/langflower-helper/SKILL.md +196 -57
  59. package/vendor/server/skeleton/skills/langflower-helper/architecture.md +50 -8
  60. package/vendor/server/skeleton/skills/langflower-helper/layout.md +33 -13
  61. package/vendor/server/skeleton/skills/langflower-node-writer/SKILL.md +25 -4
  62. package/vendor/server/skeleton/skills/langflower-workflow-writer/SKILL.md +21 -2
  63. package/vendor/server/skeleton/workflows/agents-dialog.json +1 -1
  64. package/vendor/server/skeleton/workflows/kb-rag.json +1 -1
  65. package/vendor/server/skeleton/workflows/starter.json +3 -3
  66. package/ui-dist/chunk-HEF6F5HN.js +0 -4
  67. package/ui-dist/main-66PVIOBC.js +0 -323
  68. package/ui-dist/styles-Y56BLXVS.css +0 -1
package/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # Langflower
2
2
 
3
- > **Disclaimer:** Langflower is currently in internal testing. Anyone can download and try it, but some functions may not be stable.
4
-
5
3
  **AI workflows where the graph controls what happens next.**
6
4
 
7
5
  Langflower is a local visual workflow for a project folder: a node graph that runs agents, tools, checks, and human gates on your machine.
@@ -10,7 +8,7 @@ You build the workflow on a canvas in the browser you already have. The LLM is a
10
8
 
11
9
  > **Not another chat harness. A local node graph.**
12
10
 
13
- ![Ask feeds an Agent; Chat loop sends feedback back into the Agent](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/img/Hero.png)
11
+ ![Ask feeds an Agent; Chat loop sends feedback back into the Agent](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/assets/img/Hero.png)
14
12
 
15
13
  A chat loop is just a graph.
16
14
 
@@ -30,7 +28,7 @@ Agent-to-agent dialogue is just another graph pattern.
30
28
 
31
29
  Connect one agent's output to another agent's input. Add feedback paths when the second agent needs to challenge or refine the first.
32
30
 
33
- ![Planner and Red Team agents with a feedback path between them](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/img/plan-red-team.png)
31
+ ![Planner and Red Team agents with a feedback path between them](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/assets/img/plan-red-team.png)
34
32
 
35
33
  There is no special "multi-agent mode".
36
34
 
@@ -44,7 +42,7 @@ Start with an agent. Then add the capabilities your workflow needs.
44
42
 
45
43
  Skills, tools, and specialized sub-agents can become parts of the same graph.
46
44
 
47
- ![Crawl, Langflower, Memory, and MCP tools plus a sub-agent on one agent, with a chat loop and tool permissions open](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/img/capabilities.png)
45
+ ![Crawl, Langflower, Memory, and MCP tools plus a sub-agent on one agent, with a chat loop and tool permissions open](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/assets/img/capabilities.png)
48
46
 
49
47
  Tools live on the graph too. Wire a pack, an MCP server, or a sub-agent only to the agent that needs it.
50
48
 
@@ -58,7 +56,7 @@ Don't ask an agent to certify its own work.
58
56
 
59
57
  Put the check in the graph.
60
58
 
61
- ![Agent response routed through a review gate, with feedback returning to the agent](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/img/gate.png)
59
+ ![Agent response routed through a review gate, with feedback returning to the agent](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/assets/img/gate.png)
62
60
 
63
61
  A check can:
64
62
 
@@ -79,10 +77,12 @@ Graphs don't have to be linear.
79
77
 
80
78
  A workflow can fan out into several independent pieces of work and later merge their results.
81
79
 
82
- ![Question fanning out to Docs, Risks, and Alternatives, then merging through Concat](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/img/fan-out.png)
80
+ ![Question fanning out to Docs, Risks, and Alternatives, then merging through Concat](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/assets/img/fan-out.png)
83
81
 
84
82
  **Parallel work is a graph, too.**
85
83
 
84
+ That picture is three agent nodes on one question. They start together. `common-loop` is a different pattern: it paces one body, one item at a time ([research fan-out](docs/product/use-cases/research-fanout-merge.md)).
85
+
86
86
  ---
87
87
 
88
88
  ### Give each agent only the capabilities it needs
@@ -91,7 +91,7 @@ Don't give every agent every tool.
91
91
 
92
92
  Give each stage the capabilities it needs.
93
93
 
94
- ![Plan wired to RO tools, then after Review a Coder wired to Write tools](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/img/permission.png)
94
+ ![Plan wired to RO tools, then after Review a Coder wired to Write tools](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/assets/img/permission.png)
95
95
 
96
96
  A planning agent can inspect a project without being allowed to modify it.
97
97
 
@@ -116,7 +116,7 @@ The same primitives can be combined into a complete development workflow:
116
116
  - parallel work;
117
117
  - controlled capabilities.
118
118
 
119
- ![Coding workflow from a goal through Planner, Red Team, Coder, QA, review, and Finish](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/img/coding_agent.png)
119
+ ![Coding workflow from a goal through Planner, Red Team, Coder, QA, review, and Finish](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/assets/img/coding_agent.png)
120
120
 
121
121
  The graph remains the same abstraction whether the workflow has three nodes or thirty.
122
122
 
@@ -128,7 +128,7 @@ The graph is not just where you design the workflow.
128
128
 
129
129
  **It's where you watch it run.**
130
130
 
131
- ![Running Starter workflow: green and yellow edges beside the Work log](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/img/feed.png)
131
+ ![Running Starter workflow: green and yellow edges beside the Work log](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/assets/img/feed.png)
132
132
 
133
133
  ### See execution on the graph
134
134
 
@@ -158,7 +158,7 @@ Its output ports can represent different event streams:
158
158
 
159
159
  As the agent runs, those events can appear in the Work log as they happen.
160
160
 
161
- ![Helper streaming reasoning in the Work log, with reasoning, draftResponse, toolLog, and response on the node](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/img/events.png)
161
+ ![Helper streaming reasoning in the Work log, with reasoning, draftResponse, toolLog, and response on the node](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/assets/img/events.png)
162
162
 
163
163
  This makes intermediate work observable without turning it into a separate tracing system.
164
164
 
@@ -172,7 +172,7 @@ Inspect it.
172
172
 
173
173
  Any connection can be routed through a Preview node to see the payload of the event flowing through it.
174
174
 
175
- ![Preview node showing the Langflower Tools payload, with the same value in the Work log](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/img/inspect.png)
175
+ ![Preview node showing the Langflower Tools payload, with the same value in the Work log](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/assets/img/inspect.png)
176
176
 
177
177
  This is useful when building and debugging workflows:
178
178
 
@@ -190,7 +190,7 @@ The Work log is not just a text stream detached from the canvas.
190
190
 
191
191
  Hover an event in the Work log and Langflower highlights the node that produced the event.
192
192
 
193
- ![Work log research highlighted on the Fan-out branch that produced it](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/img/highlight.png)
193
+ ![Work log research highlighted on the Fan-out branch that produced it](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/assets/img/highlight.png)
194
194
 
195
195
  You can move from:
196
196
 
@@ -431,7 +431,7 @@ Langflower is developed using Langflower.
431
431
 
432
432
  The project itself uses a workflow to coordinate planning, coding, review, tests, tools, and human gates.
433
433
 
434
- ![Langflower development workflow](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/img/lf_dev.png)
434
+ ![Langflower development workflow](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/assets/img/lf_dev.png)
435
435
 
436
436
  The development workflow combines memory tools, MCP, custom Langflower development tools, review gates, and coding agents.
437
437
 
@@ -445,7 +445,7 @@ The point is simple:
445
445
 
446
446
  If you don't want to start Langflower from a terminal, use the desktop launcher.
447
447
 
448
- ![Langflower desktop launcher](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/img/launcher.png)
448
+ ![Langflower desktop launcher](https://raw.githubusercontent.com/earthdmitriy/langflower/master/docs/assets/img/launcher.png)
449
449
 
450
450
  Pick a project folder, start Langflower, and the editor opens in the browser you already have.
451
451
 
@@ -552,19 +552,24 @@ Simple nodes and the Fake LLM can be used without a model key.
552
552
 
553
553
  ---
554
554
 
555
- # What it lacks
555
+ # Pick up where you left off
556
556
 
557
- Langflower is intentionally still small, and some things are not implemented yet.
557
+ Close Langflower today, open it tomorrow, and your conversation is still there.
558
558
 
559
- ### Chat sessions
559
+ Every run is saved in a session tab next to the workflow name. Start Langflower again and the latest session opens, ready to continue.
560
560
 
561
- You cannot save a chat and reopen it tomorrow as a persistent conversation.
561
+ Want a clean slate? **Reset** clears the conversation and keeps your workflow.
562
562
 
563
- Agent state currently lives inside the node.
563
+ ---
564
+
565
+ # What it lacks
566
+
567
+ Langflower is intentionally still small, and some things are not implemented yet.
564
568
 
565
569
  ### Image and video
566
570
 
567
- There is no asset-management layer for multimodal models yet.
571
+ There is no asset gallery and no video. A chat turn can attach png,
572
+ jpeg, gif, webp, wav, mp3, or pdf. Other types are not uploaded.
568
573
 
569
574
  ### Built-in IDE or Git UI
570
575
 
@@ -576,14 +581,14 @@ Use the tools you already have for editing, reviewing, committing, and navigatin
576
581
 
577
582
  # Learn more
578
583
 
579
- - [Getting started](https://github.com/earthdmitriy/langflower/blob/master/docs/public/getting-started.md) — installation and first run
580
- - [Product overview](https://github.com/earthdmitriy/langflower/blob/master/docs/public/product.md) — the product model and core concepts
581
- - [Using the editor](https://github.com/earthdmitriy/langflower/blob/master/docs/public/using-the-editor.md) — canvas, workflows, and runs
582
- - [Workflow ideas](https://github.com/earthdmitriy/langflower/blob/master/docs/public/workflows.md) — examples of workflows you can build
583
- - [Configuration](https://github.com/earthdmitriy/langflower/blob/master/docs/public/configuration.md) — providers, keys, ports, and project configuration
584
- - [Extending Langflower](https://github.com/earthdmitriy/langflower/blob/master/docs/public/extending.md) — custom nodes, node packs, MCP, and skills
585
- - [How it works](https://github.com/earthdmitriy/langflower/blob/master/docs/public/how-it-works.md) — the builder/runtime architecture
586
- - [Desktop launcher](https://github.com/earthdmitriy/langflower/blob/master/docs/public/launcher.md) — running Langflower without the CLI
584
+ - [Getting started](https://github.com/earthdmitriy/langflower/blob/master/docs/assets/public/getting-started.md) — installation and first run
585
+ - [Product overview](https://github.com/earthdmitriy/langflower/blob/master/docs/assets/public/product.md) — the product model and core concepts
586
+ - [Using the editor](https://github.com/earthdmitriy/langflower/blob/master/docs/assets/public/using-the-editor.md) — canvas, workflows, and runs
587
+ - [Workflow ideas](https://github.com/earthdmitriy/langflower/blob/master/docs/assets/public/workflows.md) — examples of workflows you can build
588
+ - [Configuration](https://github.com/earthdmitriy/langflower/blob/master/docs/assets/public/configuration.md) — providers, keys, ports, and project configuration
589
+ - [Extending Langflower](https://github.com/earthdmitriy/langflower/blob/master/docs/assets/public/extending.md) — custom nodes, node packs, MCP, and skills
590
+ - [How it works](https://github.com/earthdmitriy/langflower/blob/master/docs/assets/public/how-it-works.md) — the builder/runtime architecture
591
+ - [Desktop launcher](https://github.com/earthdmitriy/langflower/blob/master/docs/assets/public/launcher.md) — running Langflower without the CLI
587
592
 
588
593
  ---
589
594
 
@@ -23,7 +23,7 @@ import {
23
23
  wipeCacheRoot,
24
24
  wipePathOrCacheRoot,
25
25
  writeCacheManifest
26
- } from "./chunk-26UB55E5.js";
26
+ } from "./chunk-5B3555QF.js";
27
27
  import "./chunk-GFESS7SA.js";
28
28
 
29
29
  // packages/compiler/dist/compile-project-nodes.js
@@ -572,6 +572,8 @@ var loadBundledDefault = async (outfile, entryPath, packageName, projectDir) =>
572
572
  }
573
573
  ], projectDir)
574
574
  };
575
+ } finally {
576
+ await fs5.rm(loadFile, { force: true });
575
577
  }
576
578
  };
577
579
  var loadPackFromCache = async (projectDir, pack) => {
@@ -4,7 +4,7 @@ const require = __lfCreateRequire(import.meta.url);
4
4
  import {
5
5
  DEFAULT_PERMISSION_CONFIG,
6
6
  createProjectHarness
7
- } from "./chunk-3Z7Q6SQ5.js";
7
+ } from "./chunk-VVJLF47H.js";
8
8
  import "./chunk-GFESS7SA.js";
9
9
 
10
10
  // packages/cli/dist/eval-command.js
@@ -304,7 +304,12 @@ var invoke = async (ctx, args) => {
304
304
  if (ctx.askUser === void 0) {
305
305
  throw new Error("ask_user requires a live HITL host. No askUser hook is bound on this harness.");
306
306
  }
307
- return invokeWithAbort(ctx.askUser(request), ctx.signal);
307
+ const answer = await invokeWithAbort(ctx.askUser(request), ctx.signal);
308
+ if (typeof answer === "string") {
309
+ return answer;
310
+ }
311
+ ctx.recordStagedFiles?.(answer.files);
312
+ return answer.text;
308
313
  };
309
314
  var askUserTool = {
310
315
  id: "ask_user",
@@ -662,7 +667,7 @@ import path5 from "node:path";
662
667
 
663
668
  // packages/tools/dist/post-process.js
664
669
  import vm from "node:vm";
665
- var DEFAULT_TIMEOUT_MS = 50;
670
+ var DEFAULT_TIMEOUT_MS = 500;
666
671
  var DEFAULT_MAX_OUTPUT_CHARS = 2e5;
667
672
  var runReadClassPostProcess = (source, input, options = {}) => {
668
673
  const trimmed = source.trim();
@@ -1428,7 +1433,29 @@ var moveTool = {
1428
1433
 
1429
1434
  // packages/tools/dist/builtins/read/tool.js
1430
1435
  import fs10 from "node:fs/promises";
1436
+ import path9 from "node:path";
1437
+ import { isSessionUploadMime, SESSION_UPLOAD_MAX_BYTES } from "@langflower/node-sdk";
1431
1438
  var MAX_READ_CHARS = 2e5;
1439
+ var isUnderSessionUploadCeiling = (size) => Number.isSafeInteger(size) && size >= 0 && size < SESSION_UPLOAD_MAX_BYTES;
1440
+ var MEDIA_MIME_BY_EXTENSION = {
1441
+ ".png": "image/png",
1442
+ ".jpg": "image/jpeg",
1443
+ ".jpeg": "image/jpeg",
1444
+ ".gif": "image/gif",
1445
+ ".webp": "image/webp",
1446
+ ".wav": "audio/wav",
1447
+ ".mp3": "audio/mpeg",
1448
+ ".pdf": "application/pdf"
1449
+ };
1450
+ var mediaMimeForPath = (userPath) => {
1451
+ const mimeType = MEDIA_MIME_BY_EXTENSION[path9.extname(userPath).toLowerCase()];
1452
+ if (mimeType === void 0 || !isSessionUploadMime(mimeType)) {
1453
+ return void 0;
1454
+ }
1455
+ return mimeType;
1456
+ };
1457
+ var readErrorCode = (error) => error !== null && typeof error === "object" && "code" in error ? String(error.code) : "";
1458
+ var mediaSummary = (userPath, mimeType, size) => `${userPath} (${mimeType}, ${size} bytes)`;
1432
1459
  var sliceLines = (content, args) => {
1433
1460
  const lines = content.split(/\r?\n/);
1434
1461
  const startLine = asNumber(args, "startLine");
@@ -1457,18 +1484,51 @@ var sliceLines = (content, args) => {
1457
1484
  }
1458
1485
  return truncated;
1459
1486
  };
1487
+ var readMedia = async (ctx, userPath, absolute, mimeType, args) => {
1488
+ let info;
1489
+ try {
1490
+ info = await fs10.stat(absolute);
1491
+ } catch (error) {
1492
+ if (readErrorCode(error) === "ENOENT") {
1493
+ throw new Error(await formatNotFound(absolute, userPath));
1494
+ }
1495
+ throw error;
1496
+ }
1497
+ if (!info.isFile()) {
1498
+ throw new Error(`read refuses "${userPath}": not a file.`);
1499
+ }
1500
+ if (!isUnderSessionUploadCeiling(info.size)) {
1501
+ throw new Error(`read refuses "${userPath}": file must be under ${SESSION_UPLOAD_MAX_BYTES} bytes.`);
1502
+ }
1503
+ if (ctx.stageSessionUpload === void 0) {
1504
+ throw new Error(`read cannot stage ${mimeType} for "${userPath}": no session upload hook is bound.`);
1505
+ }
1506
+ const bytes = await fs10.readFile(absolute);
1507
+ if (!isUnderSessionUploadCeiling(bytes.byteLength)) {
1508
+ throw new Error(`read refuses "${userPath}": file must be under ${SESSION_UPLOAD_MAX_BYTES} bytes.`);
1509
+ }
1510
+ const staged = await ctx.stageSessionUpload({
1511
+ name: path9.basename(userPath),
1512
+ mimeType,
1513
+ bytes
1514
+ });
1515
+ return applyPostProcess(args, mediaSummary(userPath, staged.mimeType, staged.size));
1516
+ };
1460
1517
  var invoke9 = async (ctx, args) => {
1461
1518
  const userPath = asString(args, "path");
1462
1519
  if (userPath === void 0) {
1463
1520
  throw new Error("read requires string argument \xABpath\xBB.");
1464
1521
  }
1465
1522
  const absolute = resolveProjectPath(ctx.projectRoot, userPath, fenceOptions(ctx));
1523
+ const mediaMime = mediaMimeForPath(userPath);
1524
+ if (mediaMime !== void 0) {
1525
+ return readMedia(ctx, userPath, absolute, mediaMime, args);
1526
+ }
1466
1527
  let content;
1467
1528
  try {
1468
1529
  content = await fs10.readFile(absolute, "utf8");
1469
1530
  } catch (error) {
1470
- const code = error !== null && typeof error === "object" && "code" in error ? String(error.code) : "";
1471
- if (code === "ENOENT") {
1531
+ if (readErrorCode(error) === "ENOENT") {
1472
1532
  throw new Error(await formatNotFound(absolute, userPath));
1473
1533
  }
1474
1534
  throw error;
@@ -1480,7 +1540,7 @@ var readTool = {
1480
1540
  registration: {
1481
1541
  toolId: "read",
1482
1542
  name: "read",
1483
- description: "Read a file under the project root. Optional startLine/endLine (1-based) or offset/limit (byte-ish line slices). Optional postProcess: source of (res: string) => string.",
1543
+ description: "Read a file under the project root. Optional startLine/endLine (1-based) or offset/limit (byte-ish line slices). Optional postProcess: source of (res: string) => string. png, jpg, jpeg, gif, webp, wav, mp3, and pdf are staged as session uploads; the result is one line with the path, MIME, and size. Other files, including video, stay UTF-8 text.",
1484
1544
  inputSchema: {
1485
1545
  type: "object",
1486
1546
  properties: {
@@ -1571,7 +1631,7 @@ var sleepTool = {
1571
1631
 
1572
1632
  // packages/tools/dist/builtins/write/tool.js
1573
1633
  import fs11 from "node:fs/promises";
1574
- import path9 from "node:path";
1634
+ import path10 from "node:path";
1575
1635
  var invoke11 = async (ctx, args) => {
1576
1636
  const userPath = asString(args, "path");
1577
1637
  const content = asString(args, "content");
@@ -1579,7 +1639,7 @@ var invoke11 = async (ctx, args) => {
1579
1639
  throw new Error("write requires string arguments \xABpath\xBB and \xABcontent\xBB.");
1580
1640
  }
1581
1641
  const absolute = resolveProjectPath(ctx.projectRoot, userPath, fenceOptions(ctx));
1582
- await fs11.mkdir(path9.dirname(absolute), { recursive: true });
1642
+ await fs11.mkdir(path10.dirname(absolute), { recursive: true });
1583
1643
  await fs11.writeFile(absolute, content, "utf8");
1584
1644
  return `Wrote \xAB${userPath}\xBB (${content.length} chars).`;
1585
1645
  };
@@ -1688,6 +1748,9 @@ var wrapBuiltinToolHandles = (harness, permission) => {
1688
1748
  if (!result.ok) {
1689
1749
  throw new Error(result.text);
1690
1750
  }
1751
+ if (result.stagedFiles !== void 0 && hostCtx?.stagedSessionUpload !== void 0) {
1752
+ hostCtx.stagedSessionUpload.files.push(...result.stagedFiles);
1753
+ }
1691
1754
  return result.text;
1692
1755
  }
1693
1756
  }));
@@ -1700,7 +1763,8 @@ var createProjectHarness = (options) => {
1700
1763
  denyPaths: options.denyPaths ?? [],
1701
1764
  allowedRoots: options.allowedRoots ?? [],
1702
1765
  bashEnabled: options.bashEnabled === true,
1703
- ...options.askUser !== void 0 ? { askUser: options.askUser } : {}
1766
+ ...options.askUser !== void 0 ? { askUser: options.askUser } : {},
1767
+ ...options.stageSessionUpload !== void 0 ? { stageSessionUpload: options.stageSessionUpload } : {}
1704
1768
  };
1705
1769
  const permission = {
1706
1770
  ...DEFAULT_PERMISSION_CONFIG,
@@ -1740,9 +1804,28 @@ var createProjectHarness = (options) => {
1740
1804
  return deniedToolResult(toolId, deniedDetail(toolId, details));
1741
1805
  }
1742
1806
  try {
1743
- const invokeCtx = call.signal === void 0 ? ctx : { ...ctx, signal: call.signal };
1807
+ const stagedFiles = [];
1808
+ const stage = ctx.stageSessionUpload;
1809
+ const invokeCtx = {
1810
+ ...ctx,
1811
+ ...call.signal !== void 0 ? { signal: call.signal } : {},
1812
+ ...stage !== void 0 ? {
1813
+ stageSessionUpload: async (input) => {
1814
+ const file = await stage(input);
1815
+ stagedFiles.push(file);
1816
+ return file;
1817
+ }
1818
+ } : {},
1819
+ recordStagedFiles: (files) => {
1820
+ stagedFiles.push(...files);
1821
+ }
1822
+ };
1744
1823
  const text = await invokeBuiltin(toolId, invokeCtx, call.args);
1745
- return { ok: true, text };
1824
+ return {
1825
+ ok: true,
1826
+ text,
1827
+ ...stagedFiles.length > 0 ? { stagedFiles } : {}
1828
+ };
1746
1829
  } catch (error) {
1747
1830
  const text = error instanceof Error ? error.message : String(error);
1748
1831
  return { ok: false, text };