@markusylisiurunen/tau 0.3.47 → 0.3.49

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 (82) hide show
  1. package/README.md +14 -13
  2. package/dist/code_mode/command.js +3 -1
  3. package/dist/code_mode/command.js.map +1 -1
  4. package/dist/code_mode/files.d.ts +47 -0
  5. package/dist/code_mode/files.js +296 -0
  6. package/dist/code_mode/files.js.map +1 -0
  7. package/dist/code_mode/index.d.ts +2 -0
  8. package/dist/code_mode/index.js +1 -0
  9. package/dist/code_mode/index.js.map +1 -1
  10. package/dist/code_mode/runtime.d.ts +4 -0
  11. package/dist/code_mode/runtime.js +58 -14
  12. package/dist/code_mode/runtime.js.map +1 -1
  13. package/dist/core/agent/agent_runtime.js +0 -10
  14. package/dist/core/agent/agent_runtime.js.map +1 -1
  15. package/dist/{tui → core/client_tools}/command_client_tools.js +19 -69
  16. package/dist/core/client_tools/command_client_tools.js.map +1 -0
  17. package/dist/core/config/schema.js.map +1 -1
  18. package/dist/core/runtime/chat_runtime.js +5 -8
  19. package/dist/core/runtime/chat_runtime.js.map +1 -1
  20. package/dist/core/session/direct_bash.js +6 -1
  21. package/dist/core/session/direct_bash.js.map +1 -1
  22. package/dist/core/static/code_mode/nook/documentation.md +1 -1
  23. package/dist/core/static/code_mode/sandbox_runner.mjs +27 -22
  24. package/dist/core/telegram/config.js +34 -11
  25. package/dist/core/telegram/config.js.map +1 -1
  26. package/dist/core/telegram/index.js +1 -0
  27. package/dist/core/telegram/index.js.map +1 -1
  28. package/dist/core/telegram/local_session_client.js +19 -0
  29. package/dist/core/telegram/local_session_client.js.map +1 -0
  30. package/dist/core/telegram/session_manager.js +48 -14
  31. package/dist/core/telegram/session_manager.js.map +1 -1
  32. package/dist/core/telegram/workspace.js +24 -0
  33. package/dist/core/telegram/workspace.js.map +1 -1
  34. package/dist/core/tools/bash.js.map +1 -1
  35. package/dist/core/tools/code_mode.js +11 -0
  36. package/dist/core/tools/code_mode.js.map +1 -1
  37. package/dist/core/tools/history.js +2 -1
  38. package/dist/core/tools/history.js.map +1 -1
  39. package/dist/core/tools/nook.js +3 -2
  40. package/dist/core/tools/nook.js.map +1 -1
  41. package/dist/core/tools/presentation.js +36 -20
  42. package/dist/core/tools/presentation.js.map +1 -1
  43. package/dist/core/tools/send_input_to_agent.js +1 -1
  44. package/dist/core/tools/send_input_to_agent.js.map +1 -1
  45. package/dist/core/tools/spawn_agent.js +1 -1
  46. package/dist/core/tools/spawn_agent.js.map +1 -1
  47. package/dist/core/tools/subagent_ui.js +1 -1
  48. package/dist/core/tools/subagent_ui.js.map +1 -1
  49. package/dist/core/tools/web.js +4 -3
  50. package/dist/core/tools/web.js.map +1 -1
  51. package/dist/core/tools/write.js +6 -2
  52. package/dist/core/tools/write.js.map +1 -1
  53. package/dist/core/utils/spawn_capture.js +15 -16
  54. package/dist/core/utils/spawn_capture.js.map +1 -1
  55. package/dist/core/version.js +1 -1
  56. package/dist/host/client_tool_broker.js +9 -1
  57. package/dist/host/client_tool_broker.js.map +1 -1
  58. package/dist/host/local_session_host.js +3 -17
  59. package/dist/host/local_session_host.js.map +1 -1
  60. package/dist/main.js +6 -2
  61. package/dist/main.js.map +1 -1
  62. package/dist/nook/README.md +1 -1
  63. package/dist/protocol/session_protocol.d.ts +2 -1
  64. package/dist/protocol/session_protocol.js +2 -1
  65. package/dist/protocol/session_protocol.js.map +1 -1
  66. package/dist/sdk/client_tool_command.d.ts +24 -7
  67. package/dist/sdk/client_tool_command.js +142 -7
  68. package/dist/sdk/client_tool_command.js.map +1 -1
  69. package/dist/sdk/code_mode.js +3 -1
  70. package/dist/sdk/code_mode.js.map +1 -1
  71. package/dist/sdk/session.js +1 -0
  72. package/dist/sdk/session.js.map +1 -1
  73. package/dist/sdk/types.d.ts +1 -0
  74. package/dist/store/file_session_store.js +0 -8
  75. package/dist/store/file_session_store.js.map +1 -1
  76. package/dist/store/memory_session_store.js +0 -4
  77. package/dist/store/memory_session_store.js.map +1 -1
  78. package/dist/store/session_store.js.map +1 -1
  79. package/dist/tui/session_chat_app.js +1 -1
  80. package/dist/tui/session_chat_app.js.map +1 -1
  81. package/package.json +1 -1
  82. package/dist/tui/command_client_tools.js.map +0 -1
package/README.md CHANGED
@@ -147,7 +147,7 @@ Session attach renders the authoritative session snapshot, streams recoverable `
147
147
 
148
148
  The host owns the active transcript as one ordered timeline of messages, tool calls, notices, and maintenance operations. Durable items retain their exact position across reattach; ephemeral transcript notices use the same ordering while attached but are not recovered. Successful compaction starts a new numeric timeline epoch containing the summary and future activity, while rewind removes every item after its selected boundary.
149
149
 
150
- The TUI advertises client tools for diff review, input prefill, and the effective command-backed tools selected from global definitions. `prefill_input` fills only an empty editor and leaves existing draft text unchanged. Pass `--no-client-tools` to `tau` or `tau attach` to advertise no TUI client tools, for example when another TUI attached to the same session already owns them.
150
+ The TUI advertises client tools for diff review, input prefill, and the effective command-backed tools selected from global definitions. The Telegram runner advertises the effective command-backed tools for each session workspace without exposing TUI-only tools. `prefill_input` fills only an empty editor and leaves existing draft text unchanged. Pass `--no-client-tools` to `tau` or `tau attach` to advertise no TUI client tools, for example when another TUI attached to the same session already owns them.
151
151
 
152
152
  Model `bash` tool calls, `!`/`!!`, `session.exec`, and Tau-controlled command helpers each run in a fresh, non-interactive login Bash belonging to the session execution environment. Tau sets `HOME` to the execution environment home, so Bash reads `/etc/profile` and then the first available user login file (`~/.bash_profile`, `~/.bash_login`, or `~/.profile`). Bash also reads inherited `BASH_ENV` when set; otherwise `.bashrc` is loaded only when the login configuration sources it. Login startup files must be automation-safe: they must not write to stdout or stderr, read stdin, require a TTY, or terminate the shell unexpectedly. Tau does not filter or frame startup output. Commands start from the backend's target-side environment and apply explicit execution-environment overrides; the local backend filters sensitive variables inherited from the Tau host. Node, Git, and other helper executables resolve from the same login-configured `PATH` as model commands. Shell state such as `cd`, exports, aliases, functions, and `nvm use` does not persist between calls.
153
153
 
@@ -174,7 +174,7 @@ The runner keeps tool and lifecycle progress quiet: Telegram receives command ac
174
174
 
175
175
  Telegram DM input supports plain text, voice/audio transcription with the transcript echoed back for verification, and attachment queueing (`image/*`, PDF, `.txt`, `.md`, `.json`, `.csv`, `.yaml`, `.yml`). allowed groups are opt-in via `allowedChatIds`; non-triggering group text/captions, attachments, audio transcripts, and processing errors are buffered as sender-attributed context and the most recent 50 messages since the previous bot-triggering turn are included when a bot mention triggers a turn. group commands accept explicit bot mentions on or around the command, such as `/status@botusername`, `/status @botusername`, or `@botusername /status`.
176
176
 
177
- Telegram config defines `bots`, `projects`, `workspaceRoot`, optional `systemMessage`, and optional `maxSessions`. Projects may describe one repository or compose several repository projects under a generated multi-repo root. Repositories use persistent bare caches at `<workspaceRoot>-repo-cache/<projectId>.git`; active and failed session records and per-chat project preferences are persisted, workspaces survive runner restarts, and unreferenced workspace entries are removed on startup. Tau reconnects preserved active sessions to their corresponding snapshots and reconciles unresolved Telegram requests through the durable turn ledger. Accepted running turns remain interruptible after a lost response, while failed, blocked, or confirmed-unaccepted request notifications remain persisted until Telegram delivery succeeds. Terminal failed records retain the initiating submission diagnostic until the session is closed. When creating or reconstructing a workspace, Telegram starts an optional executable `.tau/scripts/provision` repository hook through the Tau session without blocking chat access; failures are reported while the session remains available. Preserved workspaces skip provisioning on restart. for config details, see [docs/telegram.md](docs/telegram.md).
177
+ Telegram config defines `bots`, `projects`, `workspaceRoot`, optional `systemMessage`, and optional `maxSessions`. Projects may describe one repository, reuse one existing persistent directory across sessions, or compose several repository projects under a generated multi-repo root. Persistent directories must already exist and are never created, provisioned, or removed by Tau. Repositories use persistent bare caches at `<workspaceRoot>-repo-cache/<projectId>.git`; active and failed session records and per-chat project preferences are persisted, workspaces survive runner restarts, and unreferenced managed workspace entries are removed on startup. Tau reconnects preserved active sessions to their corresponding snapshots and reconciles unresolved Telegram requests through the durable turn ledger. Accepted running turns remain interruptible after a lost response, while failed, blocked, or confirmed-unaccepted request notifications remain persisted until Telegram delivery succeeds. Terminal failed records retain the initiating submission diagnostic until the session is closed. When creating or reconstructing a repository workspace, Telegram starts an optional executable `.tau/scripts/provision` hook through the Tau session without blocking chat access; failures are reported while the session remains available. Preserved workspaces skip provisioning on restart. for config details, see [docs/telegram.md](docs/telegram.md).
178
178
 
179
179
  ## built-in tool commands
180
180
 
@@ -559,7 +559,7 @@ model definitions can be extended and overridden through `~/.config/tau/models.j
559
559
  {
560
560
  "name": "notify",
561
561
  "defaultEnabled": true,
562
- "description": "Show a desktop notification on the TUI machine.",
562
+ "description": "Show a desktop notification on the owning client machine.",
563
563
  "parameters": {
564
564
  "type": "object",
565
565
  "properties": { "message": { "type": "string" } },
@@ -635,7 +635,7 @@ tau ships a built-in browser diff review tool as `tau diff-tool`. `/diff` launch
635
635
 
636
636
  supported built-in diff tool code themes are: `andromeeda`, `aurora-x`, `ayu-dark`, `ayu-mirage`, `catppuccin-frappe`, `catppuccin-macchiato`, `catppuccin-mocha`, `dark-plus`, `dracula`, `dracula-soft`, `everforest-dark`, `github-dark`, `github-dark-default`, `github-dark-dimmed`, `github-dark-high-contrast`, `gruvbox-dark-hard`, `gruvbox-dark-medium`, `gruvbox-dark-soft`, `horizon`, `horizon-bright`, `houston`, `kanagawa-dragon`, `kanagawa-wave`, `laserwave`, `material-theme`, `material-theme-darker`, `material-theme-ocean`, `material-theme-palenight`, `min-dark`, `monokai`, `night-owl`, `nord`, `one-dark-pro`, `plastic`, `poimandres`, `red`, `rose-pine`, `rose-pine-moon`, `slack-dark`, `solarized-dark`, `synthwave-84`, `tokyo-night`, `vesper`, `vitesse-black`, `vitesse-dark`.
637
637
 
638
- `clientTools` defines command-backed model tools that execute on the TUI machine. Because these tools execute local commands when selected by the model, they are accepted only in `~/.config/tau/config.json`; project `.tau/config.json` files cannot define them. Each entry requires `name`, `defaultEnabled`, `description`, an object JSON Schema in `parameters`, and `command`, with optional `args` and positive `executionTimeoutMs`. Relative command paths resolve from home. When no project config selects tools, entries with `defaultEnabled: true` are advertised. A project `.tau/config.json` can set `enabledClientTools` to an exact allowlist of globally defined names; unknown names are ignored, an empty list disables all configured tools, and the most specific project value wins. Configured tools are available in both local `tau` and `tau attach`, and `--no-client-tools` disables them together with the built-in TUI client tools.
638
+ `clientTools` defines command-backed model tools that execute on the owning client machine. Because these tools execute local commands when selected by the model, they are accepted only in `~/.config/tau/config.json`; project `.tau/config.json` files cannot define them. Each entry requires `name`, `defaultEnabled`, `description`, an object JSON Schema in `parameters`, and `command`, with optional `args` and positive `executionTimeoutMs`. Relative command paths resolve from home. When no project config selects tools, entries with `defaultEnabled: true` are advertised. A project `.tau/config.json` can set `enabledClientTools` to an exact allowlist of globally defined names; unknown names are ignored, an empty list disables all configured tools, and the most specific project value wins. Configured tools are available in local `tau`, `tau attach`, and Telegram sessions. `--no-client-tools` disables configured and built-in client tools for TUI clients; Telegram workspaces can disable configured tools with `enabledClientTools: []`.
639
639
 
640
640
  the `subagents.defaultLaunchModels` field configures allowed `spawn_agent` launch overrides for the built-in `default` sub-agent. values must use `<provider>/<model>:<effort>`.
641
641
 
@@ -657,7 +657,7 @@ see [docs/telegram.md](docs/telegram.md) for the config schema, project selectio
657
657
 
658
658
  ### command client tools
659
659
 
660
- Command client tools extend the standard TUI without modifying Tau. Define them only in `~/.config/tau/config.json`; Tau requires each parameter schema to be an object with root `type: "object"`, trusts the remaining schema contents, advertises the effective tools to the session host, and runs their commands on the machine where `tau` or `tau attach` is running. Every definition must set `defaultEnabled`. Without a workspace selection, only default-enabled tools are advertised.
660
+ Command client tools extend Tau clients without modifying the session host. Define them only in `~/.config/tau/config.json`; Tau requires each parameter schema to be an object with root `type: "object"`, trusts the remaining schema contents, advertises the effective tools to the session host, and runs their commands on the owning TUI or Telegram runner machine. Every definition must set `defaultEnabled`. Without a workspace selection, only default-enabled tools are advertised.
661
661
 
662
662
  A project or nested directory can select a different exact set without defining executable behavior:
663
663
 
@@ -669,13 +669,14 @@ A project or nested directory can select a different exact set without defining
669
669
 
670
670
  The most specific `.tau/config.json` selection wins. Unknown names are skipped, and `enabledClientTools: []` disables every configured command client tool for that workspace.
671
671
 
672
- For every call, Tau validates the arguments against the configured schema, starts the command directly without a shell, and speaks a version 2 newline-delimited JSON protocol over stdin and stdout. The initial stdin frame contains the invocation:
672
+ For every call, Tau validates the arguments against the configured schema, starts the command directly without a shell, and speaks a version 3 newline-delimited JSON protocol over stdin and stdout. The initial stdin frame contains the invocation:
673
673
 
674
674
  ```json
675
675
  {
676
- "version": 2,
676
+ "version": 3,
677
677
  "type": "invoke",
678
678
  "sessionId": "session-id",
679
+ "agentId": "agent-id",
679
680
  "callId": "call-id",
680
681
  "arguments": { "message": "Build finished" }
681
682
  }
@@ -684,12 +685,12 @@ For every call, Tau validates the arguments against the configured schema, start
684
685
  Commands may send `exec` frames to run commands in the session execution environment. Tau returns the ordinary `session.exec` result in a matching `exec.result` stdin frame. The command finishes with one stdout result frame:
685
686
 
686
687
  ```json
687
- { "version": 2, "type": "result", "content": "Notification shown." }
688
+ { "version": 3, "type": "result", "content": "Notification shown." }
688
689
  ```
689
690
 
690
- Use `runTauClientToolCommand()` from `@markusylisiurunen/tau/sdk` or `@markusylisiurunen/tau/code-mode` to handle this framing and receive the same `{ sessionId, callId, signal, executionEnvironment }` context as an in-process SDK client tool. The command itself still runs on the TUI machine; only `context.executionEnvironment.exec()` runs through `session.exec` in the session execution environment.
691
+ Use `runTauClientToolCommand()` from `@markusylisiurunen/tau/sdk` or `@markusylisiurunen/tau/code-mode` to handle this framing and receive the same `{ sessionId, agentId, callId, signal, executionEnvironment }` context as an in-process SDK client tool. The command itself runs on the owning TUI or Telegram runner machine; only `context.executionEnvironment.exec()` runs through `session.exec` in the session execution environment.
691
692
 
692
- The result `content` becomes model-visible. A nonzero exit fails the tool using stderr, falling back to stdout when stderr is empty. Tau runs the command from the TUI's current working directory with the TUI process environment unchanged, limits each command-to-TUI protocol frame and total stdout and stderr to 1 MiB, allows at most eight execution requests to remain active while their responses are delivered with stdin backpressure, and terminates the command's process group on cancellation, terminal transport failure, timeout, or excess output. Closing protocol stdin aborts the command helper and its pending execution requests. Process-group termination escalates to `SIGKILL` after two seconds even if the command leader exits first. `executionTimeoutMs` defaults to 60 seconds.
693
+ The result `content` becomes model-visible. A nonzero exit fails the tool using stderr. Tau runs the command from the owning client's current working directory with that client's process environment unchanged. Command stdout is decoded as a bounded NDJSON protocol stream with at most 512 frames and 192 MiB total per invocation; each frame is capped at 24 MiB, `exec` stdin retains the session protocol's 16 MiB decoded limit, and final result content plus stderr are each capped at 1 MiB. Tau allows at most eight execution requests to remain active while their responses are delivered with stdin backpressure, and terminates the command's process group on cancellation, terminal transport failure, timeout, or excess output. Closing protocol stdin aborts the command helper and its pending execution requests. Process-group termination escalates to `SIGKILL` after two seconds even if the command leader exits first. `executionTimeoutMs` defaults to 60 seconds.
693
694
 
694
695
  ```ts
695
696
  #!/usr/bin/env node
@@ -718,7 +719,7 @@ Tau's `@markusylisiurunen/tau/code-mode` export implements this command framing
718
719
  }
719
720
  ```
720
721
 
721
- The executable owns authenticated clients and explicitly exposes trusted handlers. Handler arguments and results cross a JSON boundary; generated code receives only the declared namespace plus `docs`, `console`, `Date`, and `Math`:
722
+ The executable owns authenticated clients and explicitly exposes trusted handlers. Handler arguments and results cross a JSON boundary; generated code receives the declared namespace, agent-scoped `files`, `docs`, `console`, `Date`, and `Math`:
722
723
 
723
724
  ```ts
724
725
  #!/usr/bin/env node
@@ -736,9 +737,9 @@ await runTauCodeModeCommand({
736
737
  });
737
738
  ```
738
739
 
739
- Trusted code-mode API handlers receive the command's execution-environment facade in their context and may intentionally expose narrower workspace operations through the declared API. Generated code does not receive an undeclared shell namespace. Tau prepends canonical runtime guidance to the executable's API documentation. The installed runtime therefore documents its actual capabilities, 60-second default timeout, 8,192-token output projection, 128-call total limit, and eight-call concurrency limit without duplicating those details in `config.json`. The optional `buildTauCodeModeToolDescription()` helper produces the recommended progressive-disclosure description, but descriptions are otherwise passed through unchanged.
740
+ Trusted code-mode API handlers receive the command's execution-environment facade in their context and may intentionally expose narrower workspace operations through the declared API. Generated code does not receive an undeclared shell namespace. Its `files.read()`, `files.write()`, `files.list()`, and `files.remove()` methods operate on UTF-8 files in an agent-scoped execution-environment temporary directory. The files are shared across code-mode tools and later calls for that agent, and returned absolute paths are usable by Bash. Names are basenames rather than paths; `files.write()` rejects changes above 128 regular files or 64 MiB total, while Bash-created over-limit contents remain visible and removable. The execution environment's temporary filesystem controls the lifetime, and no scratch metadata enters the session snapshot. Tau prepends canonical runtime guidance to the executable's API documentation. The installed runtime therefore documents its actual capabilities, 60-second default timeout, 8,192-token output projection, 128-call total limit, and eight-call concurrency limit without duplicating those details in `config.json`. The optional `buildTauCodeModeToolDescription()` helper produces the recommended progressive-disclosure description, but descriptions are otherwise passed through unchanged.
740
741
 
741
- Configured names must be unique and cannot replace built-in TUI or host tools. Only one observing client may advertise a given name for a session. `--no-client-tools` disables command client tools together with `diff_review` and `prefill_input`.
742
+ Configured names must be unique and cannot replace host tools or built-ins advertised by the same client. Only one observing client may advertise a given name for a session. `--no-client-tools` disables command client tools together with `diff_review` and `prefill_input` for TUI clients; Telegram workspaces use `enabledClientTools: []` to disable configured tools.
742
743
 
743
744
  ### diff review tool
744
745
 
@@ -1,5 +1,5 @@
1
1
  import { runTauClientToolCommand } from "../sdk/client_tool_command.js";
2
- import { executeTauCodeMode, validateTauCodeModeDefinition, } from "./runtime.js";
2
+ import { createTauCodeModeExecutionEnvironmentFiles, executeTauCodeMode, validateTauCodeModeDefinition, } from "./runtime.js";
3
3
  export async function runTauCodeModeCommand(definition) {
4
4
  validateTauCodeModeDefinition(definition);
5
5
  await runTauClientToolCommand(async (args, context) => {
@@ -10,9 +10,11 @@ export async function runTauCodeModeCommand(definition) {
10
10
  signal: context.signal,
11
11
  invocation: {
12
12
  sessionId: context.sessionId,
13
+ agentId: context.agentId,
13
14
  callId: context.callId,
14
15
  },
15
16
  executionEnvironment: context.executionEnvironment,
17
+ files: createTauCodeModeExecutionEnvironmentFiles(context.agentId, context.executionEnvironment),
16
18
  });
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AAG,EAAE,EAAE,CAAC,GAAG,KAAK,MAAM,CAAC,EAC/C,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAC;IAClG,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC"}
@@ -0,0 +1,47 @@
1
+ export declare const TAU_CODE_MODE_MAX_FILES = 128;
2
+ export declare const TAU_CODE_MODE_MAX_TOTAL_FILE_BYTES: number;
3
+ export type TauCodeModeFileAdapterResult = {
4
+ stdout: string;
5
+ stderr: string;
6
+ exitCode: number | null;
7
+ };
8
+ export type TauCodeModeFileAdapter = {
9
+ runNodeScript(script: string, options: {
10
+ input: string;
11
+ signal: AbortSignal;
12
+ maxCaptureBytes: number;
13
+ }): Promise<TauCodeModeFileAdapterResult>;
14
+ };
15
+ export type TauCodeModeFilesOptions = {
16
+ agentId: string;
17
+ adapter: TauCodeModeFileAdapter;
18
+ };
19
+ export type TauCodeModeFileMetadata = {
20
+ name: string;
21
+ path: string;
22
+ bytes: number;
23
+ };
24
+ export type TauCodeModeFileList = {
25
+ files: TauCodeModeFileMetadata[];
26
+ totalFiles: number;
27
+ totalBytes: number;
28
+ };
29
+ export declare function createTauCodeModeFilesApi(options: TauCodeModeFilesOptions): {
30
+ read: (args: unknown[], context: {
31
+ signal: AbortSignal;
32
+ }) => Promise<string>;
33
+ write: (args: unknown[], context: {
34
+ signal: AbortSignal;
35
+ }) => Promise<{
36
+ path: string;
37
+ bytes: number;
38
+ }>;
39
+ list: (args: unknown[], context: {
40
+ signal: AbortSignal;
41
+ }) => Promise<TauCodeModeFileList>;
42
+ remove: (args: unknown[], context: {
43
+ signal: AbortSignal;
44
+ }) => Promise<{
45
+ path: string;
46
+ }>;
47
+ };
@@ -0,0 +1,296 @@
1
+ import { CODE_MODE_MAX_BRIDGE_PAYLOAD_BYTES } from "../core/tools/code_mode_worker.js";
2
+ export const TAU_CODE_MODE_MAX_FILES = 128;
3
+ export const TAU_CODE_MODE_MAX_TOTAL_FILE_BYTES = 64 * 1024 * 1024;
4
+ const FILE_COMMAND_MAX_CAPTURE_BYTES = 8 * 1024 * 1024;
5
+ export function createTauCodeModeFilesApi(options) {
6
+ if (!options.agentId)
7
+ throw new Error("code-mode files agentId must not be empty");
8
+ let operationQueue = Promise.resolve();
9
+ const execute = (request, signal) => {
10
+ const operation = operationQueue.then(() => executeScratchFileRequest(options.adapter, request, signal));
11
+ operationQueue = operation.then(() => undefined, () => undefined);
12
+ return operation;
13
+ };
14
+ return {
15
+ read: async (args, context) => {
16
+ const [name] = parseArguments(args, ["string"], "files.read");
17
+ return await execute({ operation: "read", agentId: options.agentId, name }, context.signal);
18
+ },
19
+ write: async (args, context) => {
20
+ const [name, content] = parseArguments(args, ["string", "string"], "files.write");
21
+ return await execute({
22
+ operation: "write",
23
+ agentId: options.agentId,
24
+ name,
25
+ content,
26
+ }, context.signal);
27
+ },
28
+ list: async (args, context) => {
29
+ parseArguments(args, [], "files.list");
30
+ return await execute({ operation: "list", agentId: options.agentId }, context.signal);
31
+ },
32
+ remove: async (args, context) => {
33
+ const [name] = parseArguments(args, ["string"], "files.remove");
34
+ return await execute({
35
+ operation: "remove",
36
+ agentId: options.agentId,
37
+ name,
38
+ }, context.signal);
39
+ },
40
+ };
41
+ }
42
+ function parseArguments(args, types, method) {
43
+ if (args.length !== types.length || args.some((value) => typeof value !== "string")) {
44
+ const signature = types.map((type, index) => `${index === 0 ? "name" : "content"}: ${type}`);
45
+ throw new TypeError(`${method} expects (${signature.join(", ")})`);
46
+ }
47
+ return args;
48
+ }
49
+ async function executeScratchFileRequest(adapter, request, signal) {
50
+ const result = await adapter.runNodeScript(SCRATCH_FILE_SCRIPT, {
51
+ input: JSON.stringify(request),
52
+ signal,
53
+ maxCaptureBytes: FILE_COMMAND_MAX_CAPTURE_BYTES,
54
+ });
55
+ if (result.exitCode !== 0) {
56
+ throw new Error(result.stderr.trim() || "code-mode scratch file operation failed");
57
+ }
58
+ let response;
59
+ try {
60
+ response = JSON.parse(result.stdout);
61
+ }
62
+ catch {
63
+ throw new Error("code-mode scratch file operation returned invalid JSON");
64
+ }
65
+ if (!isScratchFileResponse(response)) {
66
+ throw new Error("code-mode scratch file operation returned an invalid response");
67
+ }
68
+ if (!response.ok) {
69
+ const error = new Error(response.error.message);
70
+ error.name = response.error.name;
71
+ throw error;
72
+ }
73
+ return response.value;
74
+ }
75
+ function isScratchFileResponse(value) {
76
+ if (typeof value !== "object" || value === null || !("ok" in value))
77
+ return false;
78
+ const response = value;
79
+ if (response.ok === true)
80
+ return "value" in response;
81
+ if (response.ok !== false || typeof response.error !== "object" || response.error === null) {
82
+ return false;
83
+ }
84
+ const error = response.error;
85
+ return typeof error.name === "string" && typeof error.message === "string";
86
+ }
87
+ const SCRATCH_FILE_SCRIPT = String.raw `
88
+ const {
89
+ closeSync,
90
+ constants,
91
+ fstatSync,
92
+ fsyncSync,
93
+ lstatSync,
94
+ mkdirSync,
95
+ openSync,
96
+ readFileSync,
97
+ readdirSync,
98
+ renameSync,
99
+ unlinkSync,
100
+ writeFileSync,
101
+ } = require("node:fs");
102
+ const { createHash, randomUUID } = require("node:crypto");
103
+ const { tmpdir } = require("node:os");
104
+ const { join } = require("node:path");
105
+ const { TextDecoder } = require("node:util");
106
+
107
+ const MAX_NAME_BYTES = 255;
108
+ const MAX_OPERATION_BYTES = ${CODE_MODE_MAX_BRIDGE_PAYLOAD_BYTES};
109
+ const MAX_FILES = ${TAU_CODE_MODE_MAX_FILES};
110
+ const MAX_TOTAL_BYTES = ${TAU_CODE_MODE_MAX_TOTAL_FILE_BYTES};
111
+
112
+ function fail(message) {
113
+ throw new Error(message);
114
+ }
115
+
116
+ function validateName(name) {
117
+ const bytes = Buffer.byteLength(name, "utf8");
118
+ if (
119
+ bytes === 0 ||
120
+ bytes > MAX_NAME_BYTES ||
121
+ name === "." ||
122
+ name === ".." ||
123
+ name.includes("/") ||
124
+ name.includes("\\") ||
125
+ name.includes("\0")
126
+ ) {
127
+ fail("scratch file name must be a UTF-8 basename between 1 and 255 bytes");
128
+ }
129
+ }
130
+
131
+ function ensureOwnedDirectory(path, label) {
132
+ try {
133
+ mkdirSync(path, { mode: 0o700 });
134
+ } catch (error) {
135
+ if (error?.code !== "EEXIST") throw error;
136
+ }
137
+ const stats = lstatSync(path);
138
+ if (stats.isSymbolicLink() || !stats.isDirectory()) {
139
+ fail(label + " path is not a directory");
140
+ }
141
+ if (typeof process.getuid !== "function" || stats.uid !== process.getuid()) {
142
+ fail(label + " directory is not owned by the current user");
143
+ }
144
+ if ((stats.mode & 0o077) !== 0) {
145
+ fail(label + " directory permissions must not allow group or other access");
146
+ }
147
+ return path;
148
+ }
149
+
150
+ function getRoot(agentId) {
151
+ if (typeof agentId !== "string" || agentId.length === 0) fail("agentId must not be empty");
152
+ const scope = createHash("sha256").update(agentId).digest("hex").slice(0, 32);
153
+ return ensureOwnedDirectory(join(tmpdir(), "tau-code-mode-files-" + scope), "code-mode scratch");
154
+ }
155
+
156
+ function getStagingRoot(root) {
157
+ return ensureOwnedDirectory(root + "-staging", "code-mode scratch staging");
158
+ }
159
+
160
+ function getFilePath(root, name) {
161
+ validateName(name);
162
+ return join(root, name);
163
+ }
164
+
165
+ function getExistingFile(path) {
166
+ let stats;
167
+ try {
168
+ stats = lstatSync(path);
169
+ } catch (error) {
170
+ if (error?.code === "ENOENT") return undefined;
171
+ throw error;
172
+ }
173
+ if (stats.isSymbolicLink() || !stats.isFile()) fail("scratch path is not a regular file");
174
+ return stats;
175
+ }
176
+
177
+ function listFiles(root) {
178
+ const files = [];
179
+ for (const name of readdirSync(root)) {
180
+ const path = join(root, name);
181
+ const stats = lstatSync(path);
182
+ if (stats.isSymbolicLink() || !stats.isFile()) continue;
183
+ files.push({ name, path, bytes: stats.size });
184
+ }
185
+ files.sort((left, right) => left.name.localeCompare(right.name));
186
+ return files;
187
+ }
188
+
189
+ function read(root, name) {
190
+ const path = getFilePath(root, name);
191
+ const descriptor = openSync(
192
+ path,
193
+ constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK,
194
+ );
195
+ try {
196
+ const stats = fstatSync(descriptor);
197
+ if (!stats.isFile()) fail("scratch path is not a regular file");
198
+ if (stats.size > MAX_OPERATION_BYTES) {
199
+ fail("scratch file exceeds the 1 MiB read limit");
200
+ }
201
+ const content = readFileSync(descriptor);
202
+ return new TextDecoder("utf-8", { fatal: true }).decode(content);
203
+ } finally {
204
+ closeSync(descriptor);
205
+ }
206
+ }
207
+
208
+ function write(root, name, content) {
209
+ if (typeof content !== "string") fail("scratch file content must be a string");
210
+ const bytes = Buffer.byteLength(content, "utf8");
211
+ if (bytes > MAX_OPERATION_BYTES) fail("scratch file exceeds the 1 MiB write limit");
212
+
213
+ const path = getFilePath(root, name);
214
+ const existing = getExistingFile(path);
215
+ const files = listFiles(root);
216
+ const totalBytes = files.reduce((total, file) => total + file.bytes, 0);
217
+ const resultingFiles = files.length + (existing ? 0 : 1);
218
+ const resultingBytes = totalBytes - (existing?.size ?? 0) + bytes;
219
+ if (resultingFiles > MAX_FILES) fail("scratch directory exceeds the 128-file limit");
220
+ if (resultingBytes > MAX_TOTAL_BYTES) fail("scratch directory exceeds the 64 MiB total limit");
221
+
222
+ const temporaryPath = join(getStagingRoot(root), ".tau-write-" + randomUUID());
223
+ let descriptor;
224
+ try {
225
+ descriptor = openSync(
226
+ temporaryPath,
227
+ constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW,
228
+ 0o600,
229
+ );
230
+ writeFileSync(descriptor, content, "utf8");
231
+ fsyncSync(descriptor);
232
+ closeSync(descriptor);
233
+ descriptor = undefined;
234
+ renameSync(temporaryPath, path);
235
+ } finally {
236
+ if (descriptor !== undefined) closeSync(descriptor);
237
+ try {
238
+ unlinkSync(temporaryPath);
239
+ } catch (error) {
240
+ if (error?.code !== "ENOENT") throw error;
241
+ }
242
+ }
243
+ return { path, bytes };
244
+ }
245
+
246
+ function list(root) {
247
+ const allFiles = listFiles(root);
248
+ return {
249
+ files: allFiles,
250
+ totalFiles: allFiles.length,
251
+ totalBytes: allFiles.reduce((total, file) => total + file.bytes, 0),
252
+ };
253
+ }
254
+
255
+ function remove(root, name) {
256
+ const path = getFilePath(root, name);
257
+ if (!getExistingFile(path)) fail("scratch file does not exist");
258
+ unlinkSync(path);
259
+ return { path };
260
+ }
261
+
262
+ function execute(request) {
263
+ if (typeof request !== "object" || request === null || typeof request.operation !== "string") {
264
+ fail("invalid scratch file request");
265
+ }
266
+ const root = getRoot(request.agentId);
267
+ switch (request.operation) {
268
+ case "read":
269
+ return read(root, request.name);
270
+ case "write":
271
+ return write(root, request.name, request.content);
272
+ case "list":
273
+ return list(root);
274
+ case "remove":
275
+ return remove(root, request.name);
276
+ default:
277
+ fail("unsupported scratch file operation");
278
+ }
279
+ }
280
+
281
+ try {
282
+ const request = JSON.parse(readFileSync(0, "utf8"));
283
+ process.stdout.write(JSON.stringify({ ok: true, value: execute(request) }));
284
+ } catch (error) {
285
+ process.stdout.write(
286
+ JSON.stringify({
287
+ ok: false,
288
+ error: {
289
+ name: error instanceof Error ? error.name : "Error",
290
+ message: error instanceof Error ? error.message : String(error),
291
+ },
292
+ }),
293
+ );
294
+ }
295
+ `;
296
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/code_mode/files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kCAAkC,EAAE,MAAM,mCAAmC,CAAC;AAEvF,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,CAAC,MAAM,kCAAkC,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAEnE,MAAM,8BAA8B,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AA8CvD,MAAM,UAAU,yBAAyB,CAAC,OAAgC;IACxE,IAAI,CAAC,OAAO,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;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C;QAC3F,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAgC,CAAC;IACxD,OAAO,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAC;AAC7E,CAAC;AAED,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;8BAqBR,kCAAkC;oBAC5C,uBAAuB;0BACjB,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyL3D,CAAC"}
@@ -1,4 +1,6 @@
1
1
  export { runTauClientToolCommand, TAU_CLIENT_TOOL_COMMAND_PROTOCOL_VERSION, type TauClientToolCommandHandler, } from "../sdk/client_tool_command.js";
2
2
  export { runTauCodeModeCommand } from "./command.js";
3
+ export type { TauCodeModeFileAdapter, TauCodeModeFileAdapterResult, TauCodeModeFileList, TauCodeModeFileMetadata, TauCodeModeFilesOptions, } from "./files.js";
4
+ export { TAU_CODE_MODE_MAX_FILES, TAU_CODE_MODE_MAX_TOTAL_FILE_BYTES, } from "./files.js";
3
5
  export type { BuildTauCodeModeToolDescriptionOptions, ExecuteTauCodeModeOptions, TauCodeModeApi, TauCodeModeDefinition, TauCodeModeExecutionStatus, TauCodeModeHandler, TauCodeModeHandlerContext, TauCodeModeInvocation, TauCodeModeJsonValue, TauCodeModePersistOutput, TauCodeModeResult, } from "./runtime.js";
4
6
  export { buildTauCodeModeToolDescription, executeTauCodeMode, TAU_CODE_MODE_DEFAULT_TIMEOUT_MS, TAU_CODE_MODE_MAX_OUTPUT_TOKENS, } from "./runtime.js";
@@ -1,4 +1,5 @@
1
1
  export { runTauClientToolCommand, TAU_CLIENT_TOOL_COMMAND_PROTOCOL_VERSION, } from "../sdk/client_tool_command.js";
2
2
  export { runTauCodeModeCommand } from "./command.js";
3
+ export { TAU_CODE_MODE_MAX_FILES, TAU_CODE_MODE_MAX_TOTAL_FILE_BYTES, } from "./files.js";
3
4
  export { buildTauCodeModeToolDescription, executeTauCodeMode, TAU_CODE_MODE_DEFAULT_TIMEOUT_MS, TAU_CODE_MODE_MAX_OUTPUT_TOKENS, } from "./runtime.js";
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/code_mode/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,wCAAwC,GAEzC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAcrD,OAAO,EACL,+BAA+B,EAC/B,kBAAkB,EAClB,gCAAgC,EAChC,+BAA+B,GAChC,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/code_mode/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,wCAAwC,GAEzC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAQrD,OAAO,EACL,uBAAuB,EACvB,kCAAkC,GACnC,MAAM,YAAY,CAAC;AAcpB,OAAO,EACL,+BAA+B,EAC/B,kBAAkB,EAClB,gCAAgC,EAChC,+BAA+B,GAChC,MAAM,cAAc,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import type { TauSdkClientToolExecutionEnvironment } from "../sdk/types.js";
2
+ import { type TauCodeModeFilesOptions } from "./files.js";
2
3
  export declare const TAU_CODE_MODE_DEFAULT_TIMEOUT_MS = 60000;
3
4
  export declare const TAU_CODE_MODE_MAX_OUTPUT_TOKENS = 8192;
4
5
  export type TauCodeModeJsonValue = null | boolean | number | string | TauCodeModeJsonValue[] | {
@@ -6,6 +7,7 @@ export type TauCodeModeJsonValue = null | boolean | number | string | TauCodeMod
6
7
  };
7
8
  export type TauCodeModeInvocation = {
8
9
  sessionId: string;
10
+ agentId: string;
9
11
  callId: string;
10
12
  };
11
13
  export type TauCodeModeHandlerContext = {
@@ -59,6 +61,7 @@ export type ExecuteTauCodeModeOptions = TauCodeModeDefinition & {
59
61
  signal?: AbortSignal;
60
62
  invocation?: TauCodeModeInvocation | null;
61
63
  executionEnvironment?: TauSdkClientToolExecutionEnvironment | null;
64
+ files?: TauCodeModeFilesOptions;
62
65
  };
63
66
  export type TauCodeModeResult = {
64
67
  content: string;
@@ -67,6 +70,7 @@ export type BuildTauCodeModeToolDescriptionOptions = {
67
70
  name: string;
68
71
  description: string;
69
72
  };
73
+ export declare function createTauCodeModeExecutionEnvironmentFiles(agentId: string, executionEnvironment: TauSdkClientToolExecutionEnvironment): TauCodeModeFilesOptions;
70
74
  export type TauCodeModeRuntimeResult = {
71
75
  result: TauCodeModeResult;
72
76
  status: TauCodeModeExecutionStatus;