pilotswarm-sdk 0.5.11 → 0.5.13

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 (113) hide show
  1. package/dist/agent-loader.d.ts +2 -0
  2. package/dist/agent-loader.d.ts.map +1 -1
  3. package/dist/agent-loader.js +20 -5
  4. package/dist/agent-loader.js.map +1 -1
  5. package/dist/artifact-tools.d.ts +22 -16
  6. package/dist/artifact-tools.d.ts.map +1 -1
  7. package/dist/artifact-tools.js +252 -100
  8. package/dist/artifact-tools.js.map +1 -1
  9. package/dist/blob-store.d.ts +50 -8
  10. package/dist/blob-store.d.ts.map +1 -1
  11. package/dist/blob-store.js +128 -16
  12. package/dist/blob-store.js.map +1 -1
  13. package/dist/client.d.ts +1 -0
  14. package/dist/client.d.ts.map +1 -1
  15. package/dist/client.js +24 -0
  16. package/dist/client.js.map +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +1 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/managed-session.d.ts +2 -0
  22. package/dist/managed-session.d.ts.map +1 -1
  23. package/dist/managed-session.js +61 -10
  24. package/dist/managed-session.js.map +1 -1
  25. package/dist/orchestration/agents.js +2 -2
  26. package/dist/orchestration/agents.js.map +1 -1
  27. package/dist/orchestration/index.d.ts +2 -2
  28. package/dist/orchestration/index.js +1 -1
  29. package/dist/orchestration/lifecycle.d.ts.map +1 -1
  30. package/dist/orchestration/lifecycle.js +1 -0
  31. package/dist/orchestration/lifecycle.js.map +1 -1
  32. package/dist/orchestration/queue.d.ts.map +1 -1
  33. package/dist/orchestration/queue.js +22 -1
  34. package/dist/orchestration/queue.js.map +1 -1
  35. package/dist/orchestration/runtime.d.ts +1 -1
  36. package/dist/orchestration/state.d.ts +4 -0
  37. package/dist/orchestration/state.d.ts.map +1 -1
  38. package/dist/orchestration/state.js +1 -0
  39. package/dist/orchestration/state.js.map +1 -1
  40. package/dist/orchestration/turn.d.ts +2 -0
  41. package/dist/orchestration/turn.d.ts.map +1 -1
  42. package/dist/orchestration/turn.js +18 -7
  43. package/dist/orchestration/turn.js.map +1 -1
  44. package/dist/orchestration-registry.d.ts.map +1 -1
  45. package/dist/orchestration-registry.js +4 -2
  46. package/dist/orchestration-registry.js.map +1 -1
  47. package/dist/orchestration-version.d.ts +1 -1
  48. package/dist/orchestration-version.js +1 -1
  49. package/dist/orchestration.d.ts +2 -2
  50. package/dist/orchestration.js +1 -1
  51. package/dist/orchestration_1_0_46.d.ts +1 -1
  52. package/dist/orchestration_1_0_47.d.ts +1 -1
  53. package/dist/orchestration_1_0_48.d.ts +1 -1
  54. package/dist/orchestration_1_0_49.d.ts +1 -1
  55. package/dist/orchestration_1_0_50.d.ts +1 -1
  56. package/dist/orchestration_1_0_59/agents.d.ts +41 -0
  57. package/dist/orchestration_1_0_59/agents.d.ts.map +1 -0
  58. package/dist/orchestration_1_0_59/agents.js +773 -0
  59. package/dist/orchestration_1_0_59/agents.js.map +1 -0
  60. package/dist/orchestration_1_0_59/index.d.ts +24 -0
  61. package/dist/orchestration_1_0_59/index.d.ts.map +1 -0
  62. package/dist/orchestration_1_0_59/index.js +13 -0
  63. package/dist/orchestration_1_0_59/index.js.map +1 -0
  64. package/dist/orchestration_1_0_59/lifecycle.d.ts +48 -0
  65. package/dist/orchestration_1_0_59/lifecycle.d.ts.map +1 -0
  66. package/dist/orchestration_1_0_59/lifecycle.js +556 -0
  67. package/dist/orchestration_1_0_59/lifecycle.js.map +1 -0
  68. package/dist/orchestration_1_0_59/queue.d.ts +7 -0
  69. package/dist/orchestration_1_0_59/queue.d.ts.map +1 -0
  70. package/dist/orchestration_1_0_59/queue.js +644 -0
  71. package/dist/orchestration_1_0_59/queue.js.map +1 -0
  72. package/dist/orchestration_1_0_59/runtime.d.ts +29 -0
  73. package/dist/orchestration_1_0_59/runtime.d.ts.map +1 -0
  74. package/dist/orchestration_1_0_59/runtime.js +197 -0
  75. package/dist/orchestration_1_0_59/runtime.js.map +1 -0
  76. package/dist/orchestration_1_0_59/state.d.ts +130 -0
  77. package/dist/orchestration_1_0_59/state.d.ts.map +1 -0
  78. package/dist/orchestration_1_0_59/state.js +115 -0
  79. package/dist/orchestration_1_0_59/state.js.map +1 -0
  80. package/dist/orchestration_1_0_59/turn.d.ts +30 -0
  81. package/dist/orchestration_1_0_59/turn.d.ts.map +1 -0
  82. package/dist/orchestration_1_0_59/turn.js +1143 -0
  83. package/dist/orchestration_1_0_59/turn.js.map +1 -0
  84. package/dist/orchestration_1_0_59/utils.d.ts +22 -0
  85. package/dist/orchestration_1_0_59/utils.d.ts.map +1 -0
  86. package/dist/orchestration_1_0_59/utils.js +226 -0
  87. package/dist/orchestration_1_0_59/utils.js.map +1 -0
  88. package/dist/session-manager.d.ts +1 -0
  89. package/dist/session-manager.d.ts.map +1 -1
  90. package/dist/session-proxy.d.ts +8 -0
  91. package/dist/session-proxy.d.ts.map +1 -1
  92. package/dist/session-proxy.js +39 -14
  93. package/dist/session-proxy.js.map +1 -1
  94. package/dist/session-store.d.ts +28 -1
  95. package/dist/session-store.d.ts.map +1 -1
  96. package/dist/session-store.js +110 -0
  97. package/dist/session-store.js.map +1 -1
  98. package/dist/skills.d.ts +5 -0
  99. package/dist/skills.d.ts.map +1 -1
  100. package/dist/skills.js +18 -1
  101. package/dist/skills.js.map +1 -1
  102. package/dist/types.d.ts +7 -1
  103. package/dist/types.d.ts.map +1 -1
  104. package/dist/types.js.map +1 -1
  105. package/dist/web/web-client.d.ts.map +1 -1
  106. package/dist/web/web-client.js +21 -4
  107. package/dist/web/web-client.js.map +1 -1
  108. package/dist/worker.d.ts +4 -0
  109. package/dist/worker.d.ts.map +1 -1
  110. package/dist/worker.js +27 -2
  111. package/dist/worker.js.map +1 -1
  112. package/package.json +4 -3
  113. package/plugins/system/agents/default.agent.md +19 -16
@@ -34,6 +34,8 @@ export interface AgentConfig {
34
34
  description?: string;
35
35
  prompt: string;
36
36
  tools?: string[] | null;
37
+ /** Skill names to preload from the session's configured skill directories. */
38
+ skills?: string[];
37
39
  /** If true, this is a system agent started automatically by workers. */
38
40
  system?: boolean;
39
41
  /** Deterministic ID slug for system agents (e.g. "sweeper"). Used to derive a fixed session UUID. */
@@ -1 +1 @@
1
- {"version":3,"file":"agent-loader.d.ts","sourceRoot":"","sources":["../src/agent-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAQH;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAYpD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAclF;AAID,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACxB,wEAAwE;IACxE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,qGAAqG;IACrG,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,qHAAqH;IACrH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6FAA6F;IAC7F,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qFAAqF;IACrF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oIAAoI;IACpI,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uGAAuG;IACvG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,eAAe,CAAC,EAAE,WAAW,GAAG,kBAAkB,GAAG,yBAAyB,CAAC;IAC/E;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0EAA0E;IAC1E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;I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IAC/E;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0EAA0E;IAC1E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAmID;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,EAAE,CAkE/D"}
@@ -62,7 +62,7 @@ export function systemChildAgentUUID(parentSessionId, slug) {
62
62
  // ─── Frontmatter Parser ─────────────────────────────────────────
63
63
  /**
64
64
  * Parse YAML frontmatter from an .agent.md file.
65
- * Handles simple `key: value` pairs and YAML list syntax for `tools`.
65
+ * Handles simple `key: value` pairs and YAML list syntax for `tools` and `skills`.
66
66
  */
67
67
  function parseAgentFrontmatter(content) {
68
68
  const meta = {};
@@ -109,10 +109,18 @@ function parseAgentFrontmatter(content) {
109
109
  }
110
110
  }
111
111
  // YAML list item (e.g. " - view")
112
- if (trimmed.startsWith("- ") && currentKey === "tools") {
113
- if (!meta.tools)
114
- meta.tools = [];
115
- meta.tools.push(trimmed.slice(2).trim());
112
+ if (trimmed.startsWith("- ") && (currentKey === "tools" || currentKey === "skills")) {
113
+ const item = trimmed.slice(2).trim();
114
+ if (currentKey === "tools") {
115
+ if (!meta.tools)
116
+ meta.tools = [];
117
+ meta.tools.push(item);
118
+ }
119
+ else {
120
+ if (!meta.skills)
121
+ meta.skills = [];
122
+ meta.skills.push(item);
123
+ }
116
124
  continue;
117
125
  }
118
126
  // Key-value pair
@@ -158,6 +166,12 @@ function parseAgentFrontmatter(content) {
158
166
  // Will be followed by list items
159
167
  meta.tools = [];
160
168
  }
169
+ else if (key === "skills" && value) {
170
+ meta.skills = value.replace(/[\[\]]/g, "").split(",").map(s => s.trim()).filter(Boolean);
171
+ }
172
+ else if (key === "skills" && !value) {
173
+ meta.skills = [];
174
+ }
161
175
  else if ((key === "splash" || key === "splashMobile" || key === "initialPrompt") && (value === "|" || value === ">")) {
162
176
  // YAML block scalar (| literal, > folded)
163
177
  currentBlockStyle = value;
@@ -216,6 +230,7 @@ export function loadAgentFiles(agentsDir) {
216
230
  description: meta.description,
217
231
  prompt: body,
218
232
  tools: meta.tools && meta.tools.length > 0 ? meta.tools : null,
233
+ skills: meta.skills && meta.skills.length > 0 ? meta.skills : undefined,
219
234
  system: meta.system,
220
235
  id: meta.id,
221
236
  title: meta.title,
@@ -1 +1 @@
1
- {"version":3,"file":"agent-loader.js","sourceRoot":"","sources":["../src/agent-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,mEAAmE;AAEnE;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IACxC,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC;SACnC,MAAM,CAAC,0BAA0B,CAAC;SAClC,MAAM,CAAC,IAAI,CAAC;SACZ,MAAM,CAAC,KAAK,CAAC,CAAC;IACnB,OAAO;QACH,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;QAChB,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;QACjB,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC;QAClB,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC;QAClB,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC;KACrB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,eAAuB,EAAE,IAAY;IACtE,MAAM,IAAI,GAAG,M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AAC,MAAM;gBACnB,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,OAAO;gBACP,SAAS,EAAE,OAAO;gBAClB,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,UAAU,EAAE,QAAQ;aACvB,CAAC,CAAC;YACH,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;gBACnC,OAAO,CAAC,IAAI,CAAC,kBAAkB,KAAK,CAAC,IAAI,yGAAyG,CAAC,CAAC;YACxJ,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAChB,OAAO,CAAC,IAAI,CAAC,kBAAkB,KAAK,CAAC,IAAI,+GAA+G,CAAC,CAAC;YAC9J,CAAC;QACL,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAChB,OAAO,CAAC,IAAI,CAAC,kCAAkC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACjF,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
@@ -1,18 +1,26 @@
1
1
  /**
2
- * Artifact Tools — allow agents to read/write markdown files via Azure Blob Storage.
2
+ * Artifact Tools — agent-facing surface over the artifact store.
3
3
  *
4
- * Three tools:
5
- * - `write_artifact` upload a file to blob storage
6
- * - `read_artifact` — read a file from another session's artifacts
7
- * - `export_artifact` — return an artifact:// URI for TUI on-demand download
4
+ * Three tools, consolidated along the source/destination axis so the model's
5
+ * mental picture stays "read and write":
8
6
  *
9
- * Plus a discovery tool:
10
- * - `list_artifacts` list files in a session's artifact folder
7
+ * - `write_artifact` store bytes from exactly one of three sources:
8
+ * content (inline, model-authoredthe only path where bytes
9
+ * transit the context window)
10
+ * fromFile (worker-local path → streamed; zero payload tokens)
11
+ * fromArtifact (server-side copy from another session, with optional
12
+ * SHA-256 precondition)
13
+ * - `read_artifact` — fetch metadata (`metaOnly`), stream to a worker-local
14
+ * file (`toFile`), or return content inline (utf-8 or base64, bounded).
15
+ * - `list_artifacts` — discovery, with full provenance metadata.
11
16
  *
12
- * Agents communicate via artifacts: Agent A writes, Agent B reads.
13
- * For TUI download, the agent calls `export_artifact` which returns an
14
- * `artifact://sessionId/filename` URI. The TUI detects these URIs and
15
- * lets the user download on demand from blob storage directly.
17
+ * Every result carries { sha256, sizeBytes, contentType, isBinary,
18
+ * artifactLink, } so provenance verification never requires a transfer.
19
+ *
20
+ * DESIGN RULE (born from the 2026-07-12 Diagon Alley incident): the model is
21
+ * a control plane, not a wire. Payloads that already exist as bytes must move
22
+ * via `fromFile` / `fromArtifact` / `toFile`, never by being reproduced as
23
+ * model tokens. Inline reads are size-guarded for the same reason.
16
24
  *
17
25
  * @module
18
26
  * @internal
@@ -20,11 +28,9 @@
20
28
  import type { Tool } from "@github/copilot-sdk";
21
29
  import type { ArtifactStore } from "./session-store.js";
22
30
  /**
23
- * Create artifact tools bound to the given artifact store.
24
- *
25
- * The store can be Azure Blob (SessionBlobStore) or local filesystem
26
- * (FilesystemArtifactStore). The `sessionId` for write/export operations
27
- * is injected by the tool handler via the session context.
31
+ * Create the artifact tools bound to the given store. The store can be Azure
32
+ * Blob (SessionBlobStore) or local filesystem (FilesystemArtifactStore); the
33
+ * `sessionId` for writes is injected via the session context.
28
34
  */
29
35
  export declare function createArtifactTools(opts: {
30
36
  blobStore: ArtifactStore;
@@ -1 +1 @@
1
- {"version":3,"file":"artifact-tools.d.ts","sourceRoot":"","sources":["../src/artifact-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACtC,SAAS,EAAE,aAAa,CAAC;CAC5B,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAgNd"}
1
+ {"version":3,"file":"artifact-tools.d.ts","sourceRoot":"","sources":["../src/artifact-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAOH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AA6DxD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACtC,SAAS,EAAE,aAAa,CAAC;CAC5B,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAoUd"}
@@ -1,132 +1,327 @@
1
1
  /**
2
- * Artifact Tools — allow agents to read/write markdown files via Azure Blob Storage.
2
+ * Artifact Tools — agent-facing surface over the artifact store.
3
3
  *
4
- * Three tools:
5
- * - `write_artifact` upload a file to blob storage
6
- * - `read_artifact` — read a file from another session's artifacts
7
- * - `export_artifact` — return an artifact:// URI for TUI on-demand download
4
+ * Three tools, consolidated along the source/destination axis so the model's
5
+ * mental picture stays "read and write":
8
6
  *
9
- * Plus a discovery tool:
10
- * - `list_artifacts` list files in a session's artifact folder
7
+ * - `write_artifact` store bytes from exactly one of three sources:
8
+ * content (inline, model-authoredthe only path where bytes
9
+ * transit the context window)
10
+ * fromFile (worker-local path → streamed; zero payload tokens)
11
+ * fromArtifact (server-side copy from another session, with optional
12
+ * SHA-256 precondition)
13
+ * - `read_artifact` — fetch metadata (`metaOnly`), stream to a worker-local
14
+ * file (`toFile`), or return content inline (utf-8 or base64, bounded).
15
+ * - `list_artifacts` — discovery, with full provenance metadata.
11
16
  *
12
- * Agents communicate via artifacts: Agent A writes, Agent B reads.
13
- * For TUI download, the agent calls `export_artifact` which returns an
14
- * `artifact://sessionId/filename` URI. The TUI detects these URIs and
15
- * lets the user download on demand from blob storage directly.
17
+ * Every result carries { sha256, sizeBytes, contentType, isBinary,
18
+ * artifactLink, } so provenance verification never requires a transfer.
19
+ *
20
+ * DESIGN RULE (born from the 2026-07-12 Diagon Alley incident): the model is
21
+ * a control plane, not a wire. Payloads that already exist as bytes must move
22
+ * via `fromFile` / `fromArtifact` / `toFile`, never by being reproduced as
23
+ * model tokens. Inline reads are size-guarded for the same reason.
16
24
  *
17
25
  * @module
18
26
  * @internal
19
27
  */
28
+ import crypto from "node:crypto";
29
+ import fs from "node:fs";
30
+ import os from "node:os";
31
+ import path from "node:path";
20
32
  import { defineTool } from "@github/copilot-sdk";
33
+ const INLINE_READ_DEFAULT_BYTES = 65_536;
34
+ const INLINE_READ_MAX_BYTES = 262_144;
35
+ function artifactLink(sessionId, filename) {
36
+ return `artifact://${sessionId}/${filename}`;
37
+ }
38
+ function toolError(code, message, hint) {
39
+ return JSON.stringify({ error: code, message, ...(hint ? { hint } : {}) });
40
+ }
21
41
  /**
22
- * Create artifact tools bound to the given artifact store.
23
- *
24
- * The store can be Azure Blob (SessionBlobStore) or local filesystem
25
- * (FilesystemArtifactStore). The `sessionId` for write/export operations
26
- * is injected by the tool handler via the session context.
42
+ * Worker-local paths handed to fromFile/toFile are jailed to a set of allowed
43
+ * roots (default: the process working directory and the OS temp dir, where
44
+ * session `bash` work lands). Symlink escapes are rejected via realpath.
45
+ */
46
+ function allowedFileRoots() {
47
+ const configured = (process.env.PILOTSWARM_ARTIFACT_FILE_ROOTS || "")
48
+ .split(path.delimiter)
49
+ .map((entry) => entry.trim())
50
+ .filter(Boolean);
51
+ const roots = configured.length > 0 ? configured : [process.cwd(), os.tmpdir()];
52
+ return roots.map((root) => {
53
+ const resolved = path.resolve(root);
54
+ try {
55
+ return fs.realpathSync(resolved);
56
+ }
57
+ catch {
58
+ return resolved;
59
+ }
60
+ });
61
+ }
62
+ function resolveJailedPath(candidate, mustExist) {
63
+ const resolved = path.resolve(String(candidate || ""));
64
+ // realpath the deepest existing ancestor so symlinks can't tunnel out.
65
+ let probe = mustExist ? resolved : path.dirname(resolved);
66
+ while (!fs.existsSync(probe)) {
67
+ const parent = path.dirname(probe);
68
+ if (parent === probe)
69
+ break;
70
+ probe = parent;
71
+ }
72
+ let real;
73
+ try {
74
+ real = fs.realpathSync(probe);
75
+ }
76
+ catch {
77
+ return { error: `Path is not accessible: ${candidate}` };
78
+ }
79
+ const effective = mustExist ? real : path.join(real, path.relative(probe, resolved));
80
+ const roots = allowedFileRoots();
81
+ const inJail = roots.some((root) => effective === root || effective.startsWith(root + path.sep));
82
+ if (!inJail) {
83
+ return { error: `Path is outside the allowed roots (${roots.join(", ")}): ${candidate}` };
84
+ }
85
+ if (mustExist && !fs.existsSync(effective)) {
86
+ return { error: `File not found: ${candidate}` };
87
+ }
88
+ return { path: effective };
89
+ }
90
+ /**
91
+ * Create the artifact tools bound to the given store. The store can be Azure
92
+ * Blob (SessionBlobStore) or local filesystem (FilesystemArtifactStore); the
93
+ * `sessionId` for writes is injected via the session context.
27
94
  */
28
95
  export function createArtifactTools(opts) {
29
96
  const { blobStore } = opts;
30
97
  // ── write_artifact ─────────────────────────────────────────
31
98
  const writeTool = defineTool("write_artifact", {
32
- description: "Write a file (typically markdown) to shared blob storage. " +
33
- "Other agents can read it via `read_artifact`. " +
34
- "To make it downloadable by the TUI user, call `export_artifact` afterwards.\n\n" +
35
- "The file is stored under the current session's artifact folder. " +
36
- "Maximum file size: 1MB.",
99
+ description: "Write an artifact from EXACTLY ONE of three sources: inline `content` (text you are authoring), " +
100
+ "`fromFile` (a worker-local file path streamed server-side, use this for anything that already " +
101
+ "exists as a file, especially binaries and archives), or `fromArtifact` (server-side copy from " +
102
+ "another session's artifact, optionally verified against an expected SHA-256). " +
103
+ "Returns full metadata including sha256 and an artifact:// link — include the link in your " +
104
+ "response when the user should see it. Never read a file just to re-send its bytes as `content`; " +
105
+ "pass the path via `fromFile` instead.",
37
106
  parameters: {
38
107
  type: "object",
39
108
  properties: {
40
109
  filename: {
41
110
  type: "string",
42
- description: "Filename including extension, e.g. 'report.md' or 'analysis.json'. " +
43
- "No path separators allowed.",
111
+ description: "Destination filename, e.g. 'report.md'. No path separators. " +
112
+ "Optional for fromFile/fromArtifact (defaults to the source basename).",
44
113
  },
45
114
  content: {
46
115
  type: "string",
47
- description: "The full file content to write.",
116
+ description: "Inline content to write (source 1 of 3). Max 1MB.",
117
+ },
118
+ encoding: {
119
+ type: "string",
120
+ enum: ["utf-8", "base64"],
121
+ description: "Encoding of `content`. Default 'utf-8'; 'base64' for small binary payloads.",
122
+ },
123
+ fromFile: {
124
+ type: "string",
125
+ description: "Worker-local file path to upload (source 2 of 3). Streamed — bytes never enter " +
126
+ "the conversation. Preferred for files created with bash/tar/build steps.",
127
+ },
128
+ fromArtifact: {
129
+ type: "object",
130
+ description: "Copy another session's artifact server-side (source 3 of 3). " +
131
+ "Bytes move store-to-store.",
132
+ properties: {
133
+ sessionId: { type: "string", description: "Session that owns the source artifact." },
134
+ filename: { type: "string", description: "Source artifact filename." },
135
+ expectedSha256: {
136
+ type: "string",
137
+ description: "Optional precondition: fail with SHA_MISMATCH if the copied bytes hash differently.",
138
+ },
139
+ },
140
+ required: ["sessionId", "filename"],
48
141
  },
49
142
  contentType: {
50
143
  type: "string",
51
- description: "MIME type. Default: 'text/markdown'. Use 'application/json' for JSON, etc.",
144
+ description: "MIME type. Default: 'text/markdown' for inline text; sniffed for fromFile.",
52
145
  },
53
146
  content_type: {
54
147
  type: "string",
55
148
  description: "Alias for contentType. Supported for compatibility; contentType is preferred.",
56
149
  },
57
- encoding: {
58
- type: "string",
59
- enum: ["utf-8", "base64"],
60
- description: "Encoding for the content field. Default: 'utf-8'. Use 'base64' for binary artifacts.",
150
+ pin: {
151
+ type: "boolean",
152
+ description: "Pin the artifact so it survives session cleanup (deliverables).",
61
153
  },
62
154
  },
63
- required: ["filename", "content"],
155
+ required: [],
64
156
  },
65
157
  handler: async (params, context) => {
66
158
  const sessionId = context?.durableSessionId;
67
159
  if (!sessionId) {
68
- return JSON.stringify({ error: "No session context — cannot determine artifact path." });
160
+ return toolError("NO_SESSION_CONTEXT", "No session context — cannot determine artifact path.");
161
+ }
162
+ const sources = [params.content !== undefined, !!params.fromFile, !!params.fromArtifact]
163
+ .filter(Boolean).length;
164
+ if (sources !== 1) {
165
+ return toolError("EXCLUSIVE_SOURCE", `write_artifact needs exactly one byte source; you provided ${sources}.`, "Pass exactly one of: content (inline text), fromFile (worker-local path), fromArtifact ({sessionId, filename}).");
69
166
  }
167
+ const contentType = params.contentType ?? params.content_type;
168
+ const pinned = params.pin === true;
70
169
  try {
71
- const metadata = await blobStore.uploadArtifact(sessionId, params.filename, params.content, params.contentType ?? params.content_type, { encoding: params.encoding });
170
+ if (params.fromFile) {
171
+ const jailed = resolveJailedPath(params.fromFile, true);
172
+ if (jailed.error)
173
+ return toolError("PATH_OUTSIDE_WORKDIR", jailed.error);
174
+ const filename = params.filename || path.basename(jailed.path);
175
+ const metadata = await blobStore.uploadArtifactFromFile(sessionId, filename, jailed.path, contentType, { pinned });
176
+ return JSON.stringify({
177
+ success: true,
178
+ sessionId,
179
+ ...metadata,
180
+ artifactLink: artifactLink(sessionId, metadata.filename),
181
+ });
182
+ }
183
+ if (params.fromArtifact) {
184
+ const from = params.fromArtifact;
185
+ const filename = params.filename || path.basename(from.filename);
186
+ const metadata = await blobStore.copyArtifact(from.sessionId, from.filename, sessionId, filename, { pinned });
187
+ if (from.expectedSha256 && metadata.sha256 !== from.expectedSha256) {
188
+ await blobStore.deleteArtifact(sessionId, metadata.filename);
189
+ return toolError("SHA_MISMATCH", `Copied bytes hash ${metadata.sha256}, expected ${from.expectedSha256}. The copy was deleted.`, "The source artifact is not the bytes you believed. Re-verify the source with read_artifact({metaOnly: true}).");
190
+ }
191
+ return JSON.stringify({
192
+ success: true,
193
+ sessionId,
194
+ ...metadata,
195
+ artifactLink: artifactLink(sessionId, metadata.filename),
196
+ });
197
+ }
198
+ if (!params.filename) {
199
+ return toolError("FILENAME_REQUIRED", "filename is required when writing inline content.");
200
+ }
201
+ const metadata = await blobStore.uploadArtifact(sessionId, params.filename, params.content, contentType, { encoding: params.encoding, pinned });
72
202
  return JSON.stringify({
73
203
  success: true,
74
204
  sessionId,
75
205
  ...metadata,
206
+ artifactLink: artifactLink(sessionId, metadata.filename),
76
207
  });
77
208
  }
78
209
  catch (err) {
79
- return JSON.stringify({ error: err.message });
210
+ return toolError(err?.code || "ARTIFACT_WRITE_FAILED", err.message);
80
211
  }
81
212
  },
82
213
  });
83
214
  // ── read_artifact ──────────────────────────────────────────
84
215
  const readTool = defineTool("read_artifact", {
85
- description: "Read a file from any session's artifact storage. " +
86
- "Use this to read files written by other agents via `write_artifact`. " +
87
- "You need the session ID and filename.",
216
+ description: "Read a session artifact (yours or another session's). Three modes: default returns text content " +
217
+ "inline (bounded by maxBytes, use offset to page); `toFile` streams the artifact to a worker-local " +
218
+ "path without the bytes entering the conversation (REQUIRED for large or binary artifacts you want " +
219
+ "to process with bash); `metaOnly` returns just metadata (size, sha256, contentType) — use it to " +
220
+ "verify provenance cheaply. Small binary artifacts can be read inline with encoding='base64'.",
88
221
  parameters: {
89
222
  type: "object",
90
223
  properties: {
91
224
  sessionId: {
92
225
  type: "string",
93
- description: "The session ID that owns the artifact. Use your own session ID for your own files, " +
94
- "or another agent's session ID to read their files.",
226
+ description: "The session that owns the artifact (your own session ID for your files).",
95
227
  },
96
- filename: {
228
+ filename: { type: "string", description: "The artifact filename, e.g. 'report.md'." },
229
+ metaOnly: {
230
+ type: "boolean",
231
+ description: "Return metadata only — no content transfer.",
232
+ },
233
+ toFile: {
97
234
  type: "string",
98
- description: "The filename to read, e.g. 'report.md'.",
235
+ description: "Write the artifact to this worker-local path instead of returning content. " +
236
+ "Zero context cost; works for any size and any content type.",
237
+ },
238
+ encoding: {
239
+ type: "string",
240
+ enum: ["utf-8", "base64"],
241
+ description: "Inline content encoding. 'base64' permits reading small binary artifacts inline.",
242
+ },
243
+ maxBytes: {
244
+ type: "number",
245
+ description: `Max bytes returned inline (default ${INLINE_READ_DEFAULT_BYTES}, hard cap ${INLINE_READ_MAX_BYTES}). Result sets truncated=true when the artifact is larger.`,
246
+ },
247
+ offset: {
248
+ type: "number",
249
+ description: "Byte offset for inline reads — page through large text artifacts.",
99
250
  },
100
251
  },
101
252
  required: ["sessionId", "filename"],
102
253
  },
103
254
  handler: async (params) => {
255
+ if (params.metaOnly && params.toFile) {
256
+ return toolError("EXCLUSIVE_MODE", "metaOnly and toFile are mutually exclusive.", "Use metaOnly for metadata, toFile to materialize bytes, or neither for inline content.");
257
+ }
104
258
  try {
105
- const content = await blobStore.downloadArtifactText(params.sessionId, params.filename);
259
+ if (params.metaOnly) {
260
+ const metadata = await blobStore.statArtifact(params.sessionId, params.filename);
261
+ if (!metadata) {
262
+ return toolError("ARTIFACT_NOT_FOUND", `Artifact not found: ${params.filename} in session ${params.sessionId}`);
263
+ }
264
+ return JSON.stringify({
265
+ success: true,
266
+ sessionId: params.sessionId,
267
+ ...metadata,
268
+ artifactLink: artifactLink(params.sessionId, metadata.filename),
269
+ });
270
+ }
271
+ if (params.toFile) {
272
+ const jailed = resolveJailedPath(params.toFile, false);
273
+ if (jailed.error)
274
+ return toolError("PATH_OUTSIDE_WORKDIR", jailed.error);
275
+ const result = await blobStore.downloadArtifact(params.sessionId, params.filename);
276
+ fs.mkdirSync(path.dirname(jailed.path), { recursive: true });
277
+ fs.writeFileSync(jailed.path, result.body);
278
+ const { body: _body, ...metadata } = result;
279
+ return JSON.stringify({
280
+ success: true,
281
+ sessionId: params.sessionId,
282
+ path: jailed.path,
283
+ ...metadata,
284
+ sha256: metadata.sha256 || crypto.createHash("sha256").update(result.body).digest("hex"),
285
+ artifactLink: artifactLink(params.sessionId, metadata.filename),
286
+ });
287
+ }
288
+ const result = await blobStore.downloadArtifact(params.sessionId, params.filename);
289
+ const encoding = params.encoding || "utf-8";
290
+ if (result.isBinary && encoding !== "base64") {
291
+ return JSON.stringify({
292
+ error: "ARTIFACT_IS_BINARY",
293
+ message: `Artifact '${params.filename}' is binary (${result.contentType}, ${result.sizeBytes} bytes) and cannot be returned as text.`,
294
+ hint: "Use toFile to materialize it on the worker filesystem, or encoding='base64' if it is small enough to inspect inline.",
295
+ contentType: result.contentType,
296
+ sizeBytes: result.sizeBytes,
297
+ });
298
+ }
299
+ const maxBytes = Math.min(Math.max(1, Math.floor(params.maxBytes ?? INLINE_READ_DEFAULT_BYTES)), INLINE_READ_MAX_BYTES);
300
+ const offset = Math.max(0, Math.floor(params.offset ?? 0));
301
+ const slice = result.body.subarray(offset, offset + maxBytes);
302
+ const truncated = offset > 0 || offset + slice.length < result.body.length;
303
+ const { body: _body, ...metadata } = result;
106
304
  return JSON.stringify({
107
305
  success: true,
108
306
  sessionId: params.sessionId,
109
- filename: params.filename,
110
- content,
111
- sizeBytes: content.length,
307
+ ...metadata,
308
+ sha256: metadata.sha256 || crypto.createHash("sha256").update(result.body).digest("hex"),
309
+ content: slice.toString(encoding === "base64" ? "base64" : "utf8"),
310
+ truncated,
311
+ ...(truncated ? { range: { offset, length: slice.length } } : {}),
312
+ artifactLink: artifactLink(params.sessionId, metadata.filename),
112
313
  });
113
314
  }
114
315
  catch (err) {
115
- if (err?.code === "ARTIFACT_IS_BINARY") {
116
- return JSON.stringify({
117
- error: "ARTIFACT_IS_BINARY",
118
- contentType: err.contentType,
119
- sizeBytes: err.sizeBytes,
120
- });
121
- }
122
- return JSON.stringify({ error: err.message });
316
+ return toolError(err?.code || "ARTIFACT_READ_FAILED", err.message);
123
317
  }
124
318
  },
125
319
  });
126
320
  // ── list_artifacts ─────────────────────────────────────────
127
321
  const listTool = defineTool("list_artifacts", {
128
- description: "List all artifact files in a session's storage folder. " +
129
- "Returns filenames that can be read with `read_artifact`.",
322
+ description: "List all artifact files in a session's storage folder, with full metadata " +
323
+ "(sizeBytes, contentType, sha256, pinned). Returns filenames that can be read " +
324
+ "with `read_artifact`.",
130
325
  parameters: {
131
326
  type: "object",
132
327
  properties: {
@@ -141,7 +336,7 @@ export function createArtifactTools(opts) {
141
336
  handler: async (params, context) => {
142
337
  const targetId = params.sessionId || context?.durableSessionId;
143
338
  if (!targetId) {
144
- return JSON.stringify({ error: "No session ID provided or available from context." });
339
+ return toolError("NO_SESSION_CONTEXT", "No session ID provided or available from context.");
145
340
  }
146
341
  try {
147
342
  const files = await blobStore.listArtifacts(targetId);
@@ -154,53 +349,10 @@ export function createArtifactTools(opts) {
154
349
  });
155
350
  }
156
351
  catch (err) {
157
- return JSON.stringify({ error: err.message });
158
- }
159
- },
160
- });
161
- // ── export_artifact ────────────────────────────────────────
162
- const exportTool = defineTool("export_artifact", {
163
- description: "Make a file available for the TUI user to download. " +
164
- "Returns an artifact:// link that the TUI renders as a clickable download. " +
165
- "You MUST include the returned artifact:// link in your response text " +
166
- "so the user can see and download it.\n\n" +
167
- "You must have written the file with `write_artifact` first.",
168
- parameters: {
169
- type: "object",
170
- properties: {
171
- filename: {
172
- type: "string",
173
- description: "The filename to export, e.g. 'report.md'.",
174
- },
175
- },
176
- required: ["filename"],
177
- },
178
- handler: async (params, context) => {
179
- const sessionId = context?.durableSessionId;
180
- if (!sessionId) {
181
- return JSON.stringify({ error: "No session context — cannot determine artifact path." });
182
- }
183
- try {
184
- // Verify the file exists
185
- const exists = await blobStore.artifactExists(sessionId, params.filename);
186
- if (!exists) {
187
- return JSON.stringify({
188
- error: `Artifact '${params.filename}' not found. Write it first with write_artifact.`,
189
- });
190
- }
191
- const artifactUri = `artifact://${sessionId}/${params.filename}`;
192
- return JSON.stringify({
193
- success: true,
194
- filename: params.filename,
195
- artifactLink: artifactUri,
196
- message: "Include the artifactLink in your response. The TUI will render it as a downloadable link.",
197
- });
198
- }
199
- catch (err) {
200
- return JSON.stringify({ error: err.message });
352
+ return toolError(err?.code || "ARTIFACT_LIST_FAILED", err.message);
201
353
  }
202
354
  },
203
355
  });
204
- return [writeTool, readTool, listTool, exportTool];
356
+ return [writeTool, readTool, listTool];
205
357
  }
206
358
  //# sourceMappingURL=artifact-tools.js.map