@rubytech/create-maxy-code 0.1.458 → 0.1.460

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 (218) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/lib/storage-broker/dist/__tests__/cf-exec.test.js +298 -3
  3. package/payload/platform/lib/storage-broker/dist/__tests__/cf-exec.test.js.map +1 -1
  4. package/payload/platform/lib/storage-broker/dist/__tests__/object-limits.test.d.ts +2 -0
  5. package/payload/platform/lib/storage-broker/dist/__tests__/object-limits.test.d.ts.map +1 -0
  6. package/payload/platform/lib/storage-broker/dist/__tests__/object-limits.test.js +79 -0
  7. package/payload/platform/lib/storage-broker/dist/__tests__/object-limits.test.js.map +1 -0
  8. package/payload/platform/lib/storage-broker/dist/__tests__/resource-limits.test.d.ts +2 -0
  9. package/payload/platform/lib/storage-broker/dist/__tests__/resource-limits.test.d.ts.map +1 -0
  10. package/payload/platform/lib/storage-broker/dist/__tests__/resource-limits.test.js +41 -0
  11. package/payload/platform/lib/storage-broker/dist/__tests__/resource-limits.test.js.map +1 -0
  12. package/payload/platform/lib/storage-broker/dist/cf-exec.d.ts +13 -1
  13. package/payload/platform/lib/storage-broker/dist/cf-exec.d.ts.map +1 -1
  14. package/payload/platform/lib/storage-broker/dist/cf-exec.js +165 -0
  15. package/payload/platform/lib/storage-broker/dist/cf-exec.js.map +1 -1
  16. package/payload/platform/lib/storage-broker/dist/house-credential.d.ts.map +1 -1
  17. package/payload/platform/lib/storage-broker/dist/house-credential.js +4 -2
  18. package/payload/platform/lib/storage-broker/dist/house-credential.js.map +1 -1
  19. package/payload/platform/lib/storage-broker/dist/index.d.ts +2 -0
  20. package/payload/platform/lib/storage-broker/dist/index.d.ts.map +1 -1
  21. package/payload/platform/lib/storage-broker/dist/index.js +2 -0
  22. package/payload/platform/lib/storage-broker/dist/index.js.map +1 -1
  23. package/payload/platform/lib/storage-broker/dist/object-limits.d.ts +80 -0
  24. package/payload/platform/lib/storage-broker/dist/object-limits.d.ts.map +1 -0
  25. package/payload/platform/lib/storage-broker/dist/object-limits.js +92 -0
  26. package/payload/platform/lib/storage-broker/dist/object-limits.js.map +1 -0
  27. package/payload/platform/lib/storage-broker/dist/resource-limits.d.ts +102 -0
  28. package/payload/platform/lib/storage-broker/dist/resource-limits.d.ts.map +1 -0
  29. package/payload/platform/lib/storage-broker/dist/resource-limits.js +105 -0
  30. package/payload/platform/lib/storage-broker/dist/resource-limits.js.map +1 -0
  31. package/payload/platform/lib/storage-broker/src/__tests__/cf-exec.test.ts +334 -5
  32. package/payload/platform/lib/storage-broker/src/__tests__/object-limits.test.ts +106 -0
  33. package/payload/platform/lib/storage-broker/src/__tests__/resource-limits.test.ts +49 -0
  34. package/payload/platform/lib/storage-broker/src/cf-exec.ts +221 -6
  35. package/payload/platform/lib/storage-broker/src/house-credential.ts +4 -2
  36. package/payload/platform/lib/storage-broker/src/index.ts +2 -0
  37. package/payload/platform/lib/storage-broker/src/object-limits.ts +95 -0
  38. package/payload/platform/lib/storage-broker/src/resource-limits.ts +105 -0
  39. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +7 -6
  40. package/payload/platform/plugins/cloudflare/PLUGIN.md +3 -1
  41. package/payload/platform/plugins/cloudflare/bin/cf-token.sh +4 -3
  42. package/payload/platform/plugins/cloudflare/mcp/__tests__/auth-route.test.ts +206 -0
  43. package/payload/platform/plugins/cloudflare/mcp/__tests__/authorize.test.ts +201 -0
  44. package/payload/platform/plugins/cloudflare/mcp/__tests__/file-routes.test.ts +178 -0
  45. package/payload/platform/plugins/cloudflare/mcp/__tests__/harness.test.ts +32 -0
  46. package/payload/platform/plugins/cloudflare/mcp/__tests__/passcode.test.ts +74 -0
  47. package/payload/platform/plugins/cloudflare/mcp/__tests__/ratelimit.test.ts +77 -0
  48. package/payload/platform/plugins/cloudflare/mcp/__tests__/skill-contract.test.ts +46 -0
  49. package/payload/platform/plugins/cloudflare/mcp/__tests__/template-config.test.ts +55 -0
  50. package/payload/platform/plugins/cloudflare/mcp/__tests__/upload-route.test.ts +255 -0
  51. package/payload/platform/plugins/cloudflare/mcp/package.json +5 -2
  52. package/payload/platform/plugins/cloudflare/references/api.md +1 -1
  53. package/payload/platform/plugins/cloudflare/references/r2-object-storage.md +46 -0
  54. package/payload/platform/plugins/cloudflare/skills/data-portal/SKILL.md +123 -0
  55. package/payload/platform/plugins/cloudflare/skills/data-portal/template/functions/api/_lib/authorize.ts +32 -0
  56. package/payload/platform/plugins/cloudflare/skills/data-portal/template/functions/api/_lib/log.ts +12 -0
  57. package/payload/platform/plugins/cloudflare/skills/data-portal/template/functions/api/_lib/passcode.ts +73 -0
  58. package/payload/platform/plugins/cloudflare/skills/data-portal/template/functions/api/_lib/ratelimit.ts +55 -0
  59. package/payload/platform/plugins/cloudflare/skills/data-portal/template/functions/api/_lib/session.ts +85 -0
  60. package/payload/platform/plugins/cloudflare/skills/data-portal/template/functions/api/_lib/types.ts +44 -0
  61. package/payload/platform/plugins/cloudflare/skills/data-portal/template/functions/api/auth.ts +113 -0
  62. package/payload/platform/plugins/cloudflare/skills/data-portal/template/functions/api/delete.ts +89 -0
  63. package/payload/platform/plugins/cloudflare/skills/data-portal/template/functions/api/download.ts +70 -0
  64. package/payload/platform/plugins/cloudflare/skills/data-portal/template/functions/api/files.ts +41 -0
  65. package/payload/platform/plugins/cloudflare/skills/data-portal/template/functions/api/upload.ts +151 -0
  66. package/payload/platform/plugins/cloudflare/skills/data-portal/template/public/index.html +42 -0
  67. package/payload/platform/plugins/cloudflare/skills/data-portal/template/public/portal.css +113 -0
  68. package/payload/platform/plugins/cloudflare/skills/data-portal/template/public/portal.js +155 -0
  69. package/payload/platform/plugins/cloudflare/skills/data-portal/template/schema.sql +64 -0
  70. package/payload/platform/plugins/cloudflare/skills/data-portal/template/wrangler.toml +21 -0
  71. package/payload/platform/plugins/cloudflare/skills/site-deploy/SKILL.md +8 -0
  72. package/payload/platform/plugins/docs/references/outlook-guide.md +5 -5
  73. package/payload/platform/plugins/docs/references/voice-mirror-guide.md +1 -0
  74. package/payload/platform/plugins/filesystem/PLUGIN.md +0 -1
  75. package/payload/platform/plugins/filesystem/mcp/dist/lib/scope.d.ts +14 -10
  76. package/payload/platform/plugins/filesystem/mcp/dist/lib/scope.d.ts.map +1 -1
  77. package/payload/platform/plugins/filesystem/mcp/dist/lib/scope.js +14 -10
  78. package/payload/platform/plugins/filesystem/mcp/dist/lib/scope.js.map +1 -1
  79. package/payload/platform/plugins/outlook/.claude-plugin/plugin.json +1 -1
  80. package/payload/platform/plugins/outlook/PLUGIN.md +3 -5
  81. package/payload/platform/plugins/outlook/mcp/dist/__tests__/attach.test.d.ts +2 -0
  82. package/payload/platform/plugins/outlook/mcp/dist/__tests__/attach.test.d.ts.map +1 -0
  83. package/payload/platform/plugins/outlook/mcp/dist/__tests__/attach.test.js +138 -0
  84. package/payload/platform/plugins/outlook/mcp/dist/__tests__/attach.test.js.map +1 -0
  85. package/payload/platform/plugins/outlook/mcp/dist/__tests__/detach.test.d.ts +2 -0
  86. package/payload/platform/plugins/outlook/mcp/dist/__tests__/detach.test.d.ts.map +1 -0
  87. package/payload/platform/plugins/outlook/mcp/dist/__tests__/detach.test.js +75 -0
  88. package/payload/platform/plugins/outlook/mcp/dist/__tests__/detach.test.js.map +1 -0
  89. package/payload/platform/plugins/outlook/mcp/dist/__tests__/draft-attachments.test.d.ts +2 -0
  90. package/payload/platform/plugins/outlook/mcp/dist/__tests__/draft-attachments.test.d.ts.map +1 -0
  91. package/payload/platform/plugins/outlook/mcp/dist/__tests__/draft-attachments.test.js +121 -0
  92. package/payload/platform/plugins/outlook/mcp/dist/__tests__/draft-attachments.test.js.map +1 -0
  93. package/payload/platform/plugins/outlook/mcp/dist/__tests__/draft-edit-attachments.test.d.ts +2 -0
  94. package/payload/platform/plugins/outlook/mcp/dist/__tests__/draft-edit-attachments.test.d.ts.map +1 -0
  95. package/payload/platform/plugins/outlook/mcp/dist/__tests__/draft-edit-attachments.test.js +102 -0
  96. package/payload/platform/plugins/outlook/mcp/dist/__tests__/draft-edit-attachments.test.js.map +1 -0
  97. package/payload/platform/plugins/outlook/mcp/dist/__tests__/draft-edit-removal.test.d.ts +2 -0
  98. package/payload/platform/plugins/outlook/mcp/dist/__tests__/draft-edit-removal.test.d.ts.map +1 -0
  99. package/payload/platform/plugins/outlook/mcp/dist/__tests__/draft-edit-removal.test.js +187 -0
  100. package/payload/platform/plugins/outlook/mcp/dist/__tests__/draft-edit-removal.test.js.map +1 -0
  101. package/payload/platform/plugins/outlook/mcp/dist/__tests__/draft-edit.test.js +1 -1
  102. package/payload/platform/plugins/outlook/mcp/dist/__tests__/draft-edit.test.js.map +1 -1
  103. package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-send-attachments.test.d.ts +2 -0
  104. package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-send-attachments.test.d.ts.map +1 -0
  105. package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-send-attachments.test.js +209 -0
  106. package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-send-attachments.test.js.map +1 -0
  107. package/payload/platform/plugins/outlook/mcp/dist/index.js +12 -8
  108. package/payload/platform/plugins/outlook/mcp/dist/index.js.map +1 -1
  109. package/payload/platform/plugins/outlook/mcp/dist/lib/attach.d.ts +37 -0
  110. package/payload/platform/plugins/outlook/mcp/dist/lib/attach.d.ts.map +1 -0
  111. package/payload/platform/plugins/outlook/mcp/dist/lib/attach.js +79 -0
  112. package/payload/platform/plugins/outlook/mcp/dist/lib/attach.js.map +1 -0
  113. package/payload/platform/plugins/outlook/mcp/dist/lib/attachment-list.d.ts +43 -0
  114. package/payload/platform/plugins/outlook/mcp/dist/lib/attachment-list.d.ts.map +1 -0
  115. package/payload/platform/plugins/outlook/mcp/dist/lib/attachment-list.js +65 -0
  116. package/payload/platform/plugins/outlook/mcp/dist/lib/attachment-list.js.map +1 -0
  117. package/payload/platform/plugins/outlook/mcp/dist/lib/detach.d.ts +65 -0
  118. package/payload/platform/plugins/outlook/mcp/dist/lib/detach.d.ts.map +1 -0
  119. package/payload/platform/plugins/outlook/mcp/dist/lib/detach.js +99 -0
  120. package/payload/platform/plugins/outlook/mcp/dist/lib/detach.js.map +1 -0
  121. package/payload/platform/plugins/outlook/mcp/dist/lib/message.d.ts +8 -0
  122. package/payload/platform/plugins/outlook/mcp/dist/lib/message.d.ts.map +1 -1
  123. package/payload/platform/plugins/outlook/mcp/dist/lib/message.js +4 -0
  124. package/payload/platform/plugins/outlook/mcp/dist/lib/message.js.map +1 -1
  125. package/payload/platform/plugins/outlook/mcp/dist/lib/outbound-attachments.d.ts +36 -8
  126. package/payload/platform/plugins/outlook/mcp/dist/lib/outbound-attachments.d.ts.map +1 -1
  127. package/payload/platform/plugins/outlook/mcp/dist/lib/outbound-attachments.js +40 -13
  128. package/payload/platform/plugins/outlook/mcp/dist/lib/outbound-attachments.js.map +1 -1
  129. package/payload/platform/plugins/outlook/mcp/dist/lib/upload-session.d.ts +9 -5
  130. package/payload/platform/plugins/outlook/mcp/dist/lib/upload-session.d.ts.map +1 -1
  131. package/payload/platform/plugins/outlook/mcp/dist/lib/upload-session.js +12 -8
  132. package/payload/platform/plugins/outlook/mcp/dist/lib/upload-session.js.map +1 -1
  133. package/payload/platform/plugins/outlook/mcp/dist/tools/draft-edit.d.ts +49 -4
  134. package/payload/platform/plugins/outlook/mcp/dist/tools/draft-edit.d.ts.map +1 -1
  135. package/payload/platform/plugins/outlook/mcp/dist/tools/draft-edit.js +82 -13
  136. package/payload/platform/plugins/outlook/mcp/dist/tools/draft-edit.js.map +1 -1
  137. package/payload/platform/plugins/outlook/mcp/dist/tools/draft.d.ts +8 -2
  138. package/payload/platform/plugins/outlook/mcp/dist/tools/draft.d.ts.map +1 -1
  139. package/payload/platform/plugins/outlook/mcp/dist/tools/draft.js +13 -4
  140. package/payload/platform/plugins/outlook/mcp/dist/tools/draft.js.map +1 -1
  141. package/payload/platform/plugins/outlook/mcp/dist/tools/mail-attachment.d.ts +15 -16
  142. package/payload/platform/plugins/outlook/mcp/dist/tools/mail-attachment.d.ts.map +1 -1
  143. package/payload/platform/plugins/outlook/mcp/dist/tools/mail-attachment.js +8 -41
  144. package/payload/platform/plugins/outlook/mcp/dist/tools/mail-attachment.js.map +1 -1
  145. package/payload/platform/plugins/outlook/mcp/dist/tools/mail-reply.d.ts.map +1 -1
  146. package/payload/platform/plugins/outlook/mcp/dist/tools/mail-reply.js +3 -20
  147. package/payload/platform/plugins/outlook/mcp/dist/tools/mail-reply.js.map +1 -1
  148. package/payload/platform/plugins/outlook/mcp/dist/tools/mail-send.d.ts +27 -3
  149. package/payload/platform/plugins/outlook/mcp/dist/tools/mail-send.d.ts.map +1 -1
  150. package/payload/platform/plugins/outlook/mcp/dist/tools/mail-send.js +53 -8
  151. package/payload/platform/plugins/outlook/mcp/dist/tools/mail-send.js.map +1 -1
  152. package/payload/platform/plugins/outlook/references/auth.md +1 -1
  153. package/payload/platform/plugins/outlook/references/graph-surfaces.md +33 -6
  154. package/payload/platform/plugins/outlook/skills/outlook/SKILL.md +22 -5
  155. package/payload/platform/plugins/storage-broker/PLUGIN.md +41 -2
  156. package/payload/platform/plugins/storage-broker/mcp/dist/__tests__/confine-path.test.d.ts +2 -0
  157. package/payload/platform/plugins/storage-broker/mcp/dist/__tests__/confine-path.test.d.ts.map +1 -0
  158. package/payload/platform/plugins/storage-broker/mcp/dist/__tests__/confine-path.test.js +85 -0
  159. package/payload/platform/plugins/storage-broker/mcp/dist/__tests__/confine-path.test.js.map +1 -0
  160. package/payload/platform/plugins/storage-broker/mcp/dist/__tests__/put-source.test.d.ts +2 -0
  161. package/payload/platform/plugins/storage-broker/mcp/dist/__tests__/put-source.test.d.ts.map +1 -0
  162. package/payload/platform/plugins/storage-broker/mcp/dist/__tests__/put-source.test.js +77 -0
  163. package/payload/platform/plugins/storage-broker/mcp/dist/__tests__/put-source.test.js.map +1 -0
  164. package/payload/platform/plugins/storage-broker/mcp/dist/confine-path.d.ts +12 -0
  165. package/payload/platform/plugins/storage-broker/mcp/dist/confine-path.d.ts.map +1 -0
  166. package/payload/platform/plugins/storage-broker/mcp/dist/confine-path.js +107 -0
  167. package/payload/platform/plugins/storage-broker/mcp/dist/confine-path.js.map +1 -0
  168. package/payload/platform/plugins/storage-broker/mcp/dist/index.js +86 -0
  169. package/payload/platform/plugins/storage-broker/mcp/dist/index.js.map +1 -1
  170. package/payload/platform/plugins/storage-broker/mcp/dist/put-source.d.ts +11 -0
  171. package/payload/platform/plugins/storage-broker/mcp/dist/put-source.d.ts.map +1 -0
  172. package/payload/platform/plugins/storage-broker/mcp/dist/put-source.js +35 -0
  173. package/payload/platform/plugins/storage-broker/mcp/dist/put-source.js.map +1 -0
  174. package/payload/platform/plugins/voice-mirror/PLUGIN.md +19 -7
  175. package/payload/platform/plugins/voice-mirror/mcp/dist/index.d.ts.map +1 -1
  176. package/payload/platform/plugins/voice-mirror/mcp/dist/index.js +35 -16
  177. package/payload/platform/plugins/voice-mirror/mcp/dist/index.js.map +1 -1
  178. package/payload/platform/plugins/voice-mirror/mcp/dist/lib/admin-user.d.ts +31 -0
  179. package/payload/platform/plugins/voice-mirror/mcp/dist/lib/admin-user.d.ts.map +1 -0
  180. package/payload/platform/plugins/voice-mirror/mcp/dist/lib/admin-user.js +87 -0
  181. package/payload/platform/plugins/voice-mirror/mcp/dist/lib/admin-user.js.map +1 -0
  182. package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-distil-profile.d.ts.map +1 -1
  183. package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-distil-profile.js +13 -3
  184. package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-distil-profile.js.map +1 -1
  185. package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-ingest-session-text.d.ts.map +1 -1
  186. package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-ingest-session-text.js +2 -1
  187. package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-ingest-session-text.js.map +1 -1
  188. package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-record-feedback.d.ts.map +1 -1
  189. package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-record-feedback.js +2 -1
  190. package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-record-feedback.js.map +1 -1
  191. package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-tag-content.d.ts +2 -2
  192. package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-tag-content.d.ts.map +1 -1
  193. package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-tag-content.js +12 -3
  194. package/payload/platform/plugins/voice-mirror/mcp/dist/tools/voice-tag-content.js.map +1 -1
  195. package/payload/platform/plugins/voice-mirror/mcp/scripts/smoke.mjs +334 -0
  196. package/payload/platform/plugins/voice-mirror/skills/voice-mirror/SKILL.md +13 -0
  197. package/payload/platform/scripts/logs-read-jsonl.test.sh +118 -0
  198. package/payload/platform/scripts/logs-read.sh +63 -9
  199. package/payload/platform/scripts/voice-author-key-audit.sh +155 -0
  200. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.d.ts.map +1 -1
  201. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js +4 -0
  202. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js.map +1 -1
  203. package/payload/platform/services/claude-session-manager/dist/mcp-descriptor-resolve.d.ts +17 -0
  204. package/payload/platform/services/claude-session-manager/dist/mcp-descriptor-resolve.d.ts.map +1 -0
  205. package/payload/platform/services/claude-session-manager/dist/mcp-descriptor-resolve.js +88 -0
  206. package/payload/platform/services/claude-session-manager/dist/mcp-descriptor-resolve.js.map +1 -0
  207. package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts +0 -1
  208. package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts.map +1 -1
  209. package/payload/platform/services/claude-session-manager/dist/pty-spawner.js +34 -23
  210. package/payload/platform/services/claude-session-manager/dist/pty-spawner.js.map +1 -1
  211. package/payload/server/{chunk-64FGYKNZ.js → chunk-JXWFVE5X.js} +148 -0
  212. package/payload/server/{chunk-F4D35LKL.js → chunk-POBXIHOF.js} +34 -0
  213. package/payload/server/maxy-edge.js +1 -1
  214. package/payload/server/server.js +412 -37
  215. package/payload/server/{src-S7C4P6TT.js → src-4F37OHLK.js} +19 -1
  216. package/payload/platform/plugins/outlook/mcp/dist/__tests__/pkce-flow.test.d.ts +0 -2
  217. package/payload/platform/plugins/outlook/mcp/dist/__tests__/pkce-flow.test.js +0 -215
  218. package/payload/platform/plugins/outlook/mcp/dist/__tests__/pkce-flow.test.js.map +0 -1
@@ -1,9 +1,16 @@
1
1
  import type { GraphClientConfig } from "../lib/graph-client.js";
2
+ import type { AttachmentListItem } from "../lib/attachment-list.js";
2
3
  /**
3
- * Inbound attachment retrieval for Outlook mailboxes.
4
+ * Attachment retrieval for Outlook mailboxes.
4
5
  *
5
6
  * `runMailAttachmentList` enumerates a message's attachments (metadata only, no
6
- * bytes). `runMailAttachmentDownload` fetches one file attachment's bytes and
7
+ * bytes). It is not inbound-only: a draft is a message in the same collection,
8
+ * so passing a draftId lists what that draft carries, and the id/name it returns
9
+ * is the handle outlook-draft-edit's `removeAttachments` resolves against.
10
+ * Downloading bytes is inbound in practice, since a draft's own attachments came
11
+ * from the account directory to begin with.
12
+ *
13
+ * `runMailAttachmentDownload` fetches one file attachment's bytes and
7
14
  * writes them to the account's uploads directory so the agent can Read the
8
15
  * file, forward it, or attach it to a reply.
9
16
  *
@@ -12,24 +19,16 @@ import type { GraphClientConfig } from "../lib/graph-client.js";
12
19
  * listed with their kind but refused for download, so a caller never writes a
13
20
  * zero-byte or malformed file.
14
21
  */
15
- /** Graph attachment @odata.type → a short kind the agent reads. */
16
- export type AttachmentKind = "file" | "item" | "reference" | "unknown";
17
- export interface AttachmentListItem {
18
- id: string;
19
- name: string | null;
20
- contentType: string | null;
21
- size: number;
22
- isInline: boolean;
23
- kind: AttachmentKind;
24
- }
25
22
  export interface AttachmentListResult {
26
23
  items: AttachmentListItem[];
27
24
  }
28
- export declare function attachmentKind(odataType: string | undefined): AttachmentKind;
29
25
  /**
30
- * List a message's attachments by id. Metadata only — `$select` omits
31
- * `contentBytes`, so no file bytes are downloaded. Get `messageId` from
32
- * outlook-mail-list / outlook-mail-search (both now report `hasAttachments`).
26
+ * List a message's attachments by id. Metadata only — no file bytes are
27
+ * downloaded. Get `messageId` from outlook-mail-list / outlook-mail-search
28
+ * (both now report `hasAttachments`).
29
+ *
30
+ * The GET itself lives in lib/attachment-list.ts because outlook-draft-edit
31
+ * resolves attachment removals against the same call.
33
32
  */
34
33
  export declare function runMailAttachmentList(config: GraphClientConfig, args: {
35
34
  messageId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"mail-attachment.d.ts","sourceRoot":"","sources":["../../src/tools/mail-attachment.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAKhE;;;;;;;;;;;;GAYG;AAEH,mEAAmE;AACnE,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;AAEvE,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,kBAAkB,EAAE,CAAC;CAC7B;AAWD,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,cAAc,CAW5E;AAID;;;;GAIG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,iBAAiB,EACzB,IAAI,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GAC1B,OAAO,CAAC,oBAAoB,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 -2,52 +2,19 @@ import { createHash } from "node:crypto";
2
2
  import { mkdirSync, statSync, unlinkSync, writeFileSync } from "node:fs";
3
3
  import { basename, join } from "node:path";
4
4
  import { callGraph } from "../lib/graph-client.js";
5
+ import { attachmentKind, listMessageAttachments } from "../lib/attachment-list.js";
5
6
  import { resolveAccountDir, OUTLOOK_ATTACHMENT_MAX_BYTES } from "../lib/outbound-attachments.js";
6
7
  import { log } from "../lib/log.js";
7
- export function attachmentKind(odataType) {
8
- switch (odataType) {
9
- case "#microsoft.graph.fileAttachment":
10
- return "file";
11
- case "#microsoft.graph.itemAttachment":
12
- return "item";
13
- case "#microsoft.graph.referenceAttachment":
14
- return "reference";
15
- default:
16
- return "unknown";
17
- }
18
- }
19
- const LIST_SELECT = "id,name,contentType,size,isInline";
20
8
  /**
21
- * List a message's attachments by id. Metadata only — `$select` omits
22
- * `contentBytes`, so no file bytes are downloaded. Get `messageId` from
23
- * outlook-mail-list / outlook-mail-search (both now report `hasAttachments`).
9
+ * List a message's attachments by id. Metadata only — no file bytes are
10
+ * downloaded. Get `messageId` from outlook-mail-list / outlook-mail-search
11
+ * (both now report `hasAttachments`).
12
+ *
13
+ * The GET itself lives in lib/attachment-list.ts because outlook-draft-edit
14
+ * resolves attachment removals against the same call.
24
15
  */
25
16
  export async function runMailAttachmentList(config, args) {
26
- // Follow @odata.nextLink to completion so a message with more attachments
27
- // than one Graph page is never silently truncated (matching mail-list /
28
- // mail-search, which paginate). The first request builds the path + $select;
29
- // each nextLink is a full URL that already encodes the select and skiptoken.
30
- const raws = [];
31
- let next;
32
- let pages = 0;
33
- do {
34
- const firstPath = `/me/messages/${encodeURIComponent(args.messageId)}/attachments`;
35
- const page = await callGraph(config, async (client) => {
36
- const req = next ? client.api(next) : client.api(firstPath).select(LIST_SELECT);
37
- return (await req.get());
38
- }, { tool: "mail-attachment", target: next ?? firstPath });
39
- raws.push(...(page.value ?? []));
40
- next = page["@odata.nextLink"];
41
- pages += 1;
42
- } while (next);
43
- const items = raws.map((a) => ({
44
- id: a.id,
45
- name: a.name ?? null,
46
- contentType: a.contentType ?? null,
47
- size: a.size ?? 0,
48
- isInline: a.isInline ?? false,
49
- kind: attachmentKind(a["@odata.type"]),
50
- }));
17
+ const { items, pages } = await listMessageAttachments(config, args.messageId, "mail-attachment");
51
18
  log({
52
19
  event: "mail-attachment",
53
20
  op: "list",
@@ -1 +1 @@
1
- {"version":3,"file":"mail-attachment.js","sourceRoot":"","sources":["../../src/tools/mail-attachment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAG3C,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AACjG,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAyCpC,MAAM,UAAU,cAAc,CAAC,SAA6B;IAC1D,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,iCAAiC;YACpC,OAAO,MAAM,CAAC;QAChB,KAAK,iCAAiC;YACpC,OAAO,MAAM,CAAC;QAChB,KAAK,sCAAsC;YACzC,OAAO,WAAW,CAAC;QACrB;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAED,MAAM,WAAW,GAAG,mCAAmC,CAAC;AAExD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,MAAyB,EACzB,IAA2B;IAE3B,0EAA0E;IAC1E,wEAAwE;IACxE,6EAA6E;IAC7E,6EAA6E;IAC7E,MAAM,IAAI,GAAoB,EAAE,CAAC;IACjC,IAAI,IAAwB,CAAC;IAC7B,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,GAAG,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AAE,CAAC;AAChF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"mail-reply.d.ts","sourceRoot":"","sources":["../../src/tools/mail-reply.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAMhE,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,EAAE,EAAE,MAAM,EAAE,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAmBD;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,iBAAiB,EACzB,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,WAAW,CAAC,CAkEtB"}
1
+ {"version":3,"file":"mail-reply.d.ts","sourceRoot":"","sources":["../../src/tools/mail-reply.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAKhE,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,EAAE,EAAE,MAAM,EAAE,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAmBD;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,iBAAiB,EACzB,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,WAAW,CAAC,CA8CtB"}
@@ -1,6 +1,5 @@
1
1
  import { postGraph, patchGraph } from "../lib/graph-client.js";
2
- import { resolveOutboundAttachments, toInlineAttachment } from "../lib/outbound-attachments.js";
3
- import { uploadAttachmentSession } from "../lib/upload-session.js";
2
+ import { attachFilesToDraft, resolveAttachmentsOrRefuse } from "../lib/attach.js";
4
3
  import { log } from "../lib/log.js";
5
4
  function addrs(list) {
6
5
  return (list ?? []).map((r) => r.emailAddress?.address).filter((a) => !!a);
@@ -20,7 +19,7 @@ function recip(list) {
20
19
  */
21
20
  export async function runMailReply(config, args) {
22
21
  const replyAll = args.replyAll ?? false;
23
- const files = resolveOutboundAttachments(config.accountId, args.attachments);
22
+ const files = resolveAttachmentsOrRefuse(config.accountId, args.attachments, "mail-reply");
24
23
  const action = replyAll ? "createReplyAll" : "createReply";
25
24
  const { json } = await postGraph(config, `/me/messages/${encodeURIComponent(args.messageId)}/${action}`, { comment: args.body }, { tool: "mail-reply" });
26
25
  const draft = json;
@@ -38,23 +37,7 @@ export async function runMailReply(config, args) {
38
37
  patch.bccRecipients = recip(bcc);
39
38
  await patchGraph(config, `/me/messages/${encodeURIComponent(draft.id)}`, patch, { tool: "mail-reply" });
40
39
  }
41
- for (const f of files) {
42
- let chunks = 0;
43
- if (f.mode === "session") {
44
- chunks = await uploadAttachmentSession(config, draft.id, f);
45
- }
46
- else {
47
- await postGraph(config, `/me/messages/${encodeURIComponent(draft.id)}/attachments`, toInlineAttachment(f), { tool: "mail-reply" });
48
- }
49
- log({
50
- event: "mail-reply",
51
- op: "attach",
52
- id: f.name,
53
- bytes: f.size,
54
- path: f.mode,
55
- chunks,
56
- });
57
- }
40
+ await attachFilesToDraft(config, draft.id, files, "mail-reply");
58
41
  await postGraph(config, `/me/messages/${encodeURIComponent(draft.id)}/send`, undefined, { tool: "mail-reply" });
59
42
  log({
60
43
  event: "mail-reply",
@@ -1 +1 @@
1
- {"version":3,"file":"mail-reply.js","sourceRoot":"","sources":["../../src/tools/mail-reply.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAChG,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AA4BpC,SAAS,KAAK,CAAC,IAAgC;IAC7C,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1F,CAAC;AACD,SAAS,KAAK,CAAC,IAAc;IAC3B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAyB,EACzB,IAAe;IAEf,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC;IACxC,MAAM,KAAK,GAAG,0BAA0B,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAE7E,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,aAAa,CAAC;IAC3D,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,SA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QAClB,MAAM,EAAE,KAAK,CAAC,cAAc,IAAI,IAAI;QACpC,QAAQ;QACR,WAAW,EAAE,KAAK,CAAC,MAAM;KAC1B,CAAC,CAAC;IAEH,OAAO;QACL,cAAc,EAAE,KAAK,CAAC,cAAc,IAAI,IAAI;QAC5C,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC;QAC7B,QAAQ;QACR,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;KACtC,CAAC;AACJ,CAAC"}
@@ -4,11 +4,35 @@ export interface MailSendResult {
4
4
  status: "sent";
5
5
  httpStatus: number;
6
6
  messageId: string | null;
7
+ attachments: string[];
7
8
  }
8
9
  /**
9
- * Send a message via Graph `POST /me/sendMail`. Graph returns 202 with no body,
10
- * so `messageId` is null unless a body is ever returned. Success is asserted on
11
- * the 202 status, not on the absence of a throw.
10
+ * Send a message via Microsoft Graph.
11
+ *
12
+ * Two transports, chosen by whether the message carries a file:
13
+ *
14
+ * - no attachments → `POST /me/sendMail`. One call, atomic.
15
+ * - attachments → `POST /me/messages` (draft) → per-file attach →
16
+ * `POST /me/messages/{id}/send`, reusing mail-reply's
17
+ * proven order.
18
+ *
19
+ * The switch is forced, not stylistic: `/me/sendMail` carries attachments inline
20
+ * in the request body and is bounded well below the plugin's 25 MB per-file cap,
21
+ * so a large file can only reach the wire through a draft's upload session.
22
+ * The `op: "transport"` line names the route actually taken — a `route=sendMail`
23
+ * line with `attachments>0` is the mis-wire signature and must never appear.
24
+ *
25
+ * `messageId` is null on BOTH routes. `/me/sendMail` returns 202 with no body,
26
+ * and on the draft route the draft id is consumed by `/send` — returning it
27
+ * would hand back a handle that 404s on the next call (Task 1688). Success is
28
+ * asserted on the Graph status, which `writeGraph` already enforces by throwing
29
+ * on any non-2xx; the literal status is logged rather than an assumed 202.
30
+ *
31
+ * The draft route is NOT atomic: an attach or send failing Graph-side leaves a
32
+ * draft in the Drafts folder, the same exposure mail-reply carries. It is
33
+ * operator-visible there, and greppable as an `op:"transport" route=draft-send`
34
+ * line with no terminal `sent` line. Paths validate before any Graph write, so
35
+ * the common failure — a bad path — still orphans nothing.
12
36
  */
13
37
  export declare function runMailSend(config: GraphClientConfig, input: MessageInput): Promise<MailSendResult>;
14
38
  //# sourceMappingURL=mail-send.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mail-send.d.ts","sourceRoot":"","sources":["../../src/tools/mail-send.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGpE,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,cAAc,CAAC,CAoBzB"}
1
+ {"version":3,"file":"mail-send.d.ts","sourceRoot":"","sources":["../../src/tools/mail-send.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIpE,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,cAAc,CAAC,CAmDzB"}
@@ -1,25 +1,70 @@
1
1
  import { postGraph } from "../lib/graph-client.js";
2
2
  import { buildMessage } from "../lib/message.js";
3
+ import { attachFilesToDraft, resolveAttachmentsOrRefuse } from "../lib/attach.js";
3
4
  import { log } from "../lib/log.js";
4
5
  /**
5
- * Send a message via Graph `POST /me/sendMail`. Graph returns 202 with no body,
6
- * so `messageId` is null unless a body is ever returned. Success is asserted on
7
- * the 202 status, not on the absence of a throw.
6
+ * Send a message via Microsoft Graph.
7
+ *
8
+ * Two transports, chosen by whether the message carries a file:
9
+ *
10
+ * - no attachments → `POST /me/sendMail`. One call, atomic.
11
+ * - attachments → `POST /me/messages` (draft) → per-file attach →
12
+ * `POST /me/messages/{id}/send`, reusing mail-reply's
13
+ * proven order.
14
+ *
15
+ * The switch is forced, not stylistic: `/me/sendMail` carries attachments inline
16
+ * in the request body and is bounded well below the plugin's 25 MB per-file cap,
17
+ * so a large file can only reach the wire through a draft's upload session.
18
+ * The `op: "transport"` line names the route actually taken — a `route=sendMail`
19
+ * line with `attachments>0` is the mis-wire signature and must never appear.
20
+ *
21
+ * `messageId` is null on BOTH routes. `/me/sendMail` returns 202 with no body,
22
+ * and on the draft route the draft id is consumed by `/send` — returning it
23
+ * would hand back a handle that 404s on the next call (Task 1688). Success is
24
+ * asserted on the Graph status, which `writeGraph` already enforces by throwing
25
+ * on any non-2xx; the literal status is logged rather than an assumed 202.
26
+ *
27
+ * The draft route is NOT atomic: an attach or send failing Graph-side leaves a
28
+ * draft in the Drafts folder, the same exposure mail-reply carries. It is
29
+ * operator-visible there, and greppable as an `op:"transport" route=draft-send`
30
+ * line with no terminal `sent` line. Paths validate before any Graph write, so
31
+ * the common failure — a bad path — still orphans nothing.
8
32
  */
9
33
  export async function runMailSend(config, input) {
10
34
  const account = config.accountId;
11
35
  log({ event: "send-request", account, to: input.to.length, subjLen: input.subject.length });
36
+ // Before any Graph write: a bad path must leave nothing behind.
37
+ const files = resolveAttachmentsOrRefuse(account, input.attachments, "mail-send");
12
38
  const message = buildMessage(input);
13
39
  const recipients = input.to.length + (input.cc?.length ?? 0) + (input.bcc?.length ?? 0);
14
40
  log({ event: "send-args", account, recipients, hasBody: input.body.length > 0 });
41
+ const route = files.length > 0 ? "draft-send" : "sendMail";
42
+ log({ event: "mail-send", op: "transport", route, attachments: files.length });
15
43
  try {
16
- const { status, json } = await postGraph(config, "/me/sendMail", { message, saveToSentItems: true }, { tool: "mail-send" });
17
- const messageId = json?.id ?? null;
18
- log({ event: "sent", account, status, messageId });
19
- return { status: "sent", httpStatus: status, messageId };
44
+ if (files.length === 0) {
45
+ const { status, json } = await postGraph(config, "/me/sendMail", { message, saveToSentItems: true }, { tool: "mail-send" });
46
+ const messageId = json?.id ?? null;
47
+ log({ event: "sent", account, status, messageId, route });
48
+ return { status: "sent", httpStatus: status, messageId, attachments: [] };
49
+ }
50
+ const { json } = await postGraph(config, "/me/messages", message, { tool: "mail-send" });
51
+ const draftId = json?.id;
52
+ if (!draftId) {
53
+ throw new Error("outlook-mail-send: Graph created the draft but returned no id.");
54
+ }
55
+ // The orphan diagnostic, mirroring draft.ts's `draft-created` / draft-send.ts's
56
+ // `draft-sent` pairing. Emitted the moment a draft exists, because from here on
57
+ // a failure strands it: this id is the only handle the operator has to find it.
58
+ // Its absence also proves the CREATE itself failed, which strands nothing —
59
+ // without it, those two outcomes are indistinguishable in the log.
60
+ log({ event: "mail-send", op: "draft-created", account, id: draftId, route });
61
+ await attachFilesToDraft(config, draftId, files, "mail-send");
62
+ const { status } = await postGraph(config, `/me/messages/${encodeURIComponent(draftId)}/send`, undefined, { tool: "mail-send" });
63
+ log({ event: "sent", account, status, messageId: null, route });
64
+ return { status: "sent", httpStatus: status, messageId: null, attachments: files.map((f) => f.name) };
20
65
  }
21
66
  catch (err) {
22
- log({ event: "send-failed", account, error: err.message });
67
+ log({ event: "send-failed", account, route, error: err.message });
23
68
  throw err;
24
69
  }
25
70
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mail-send.js","sourceRoot":"","sources":["../../src/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F;QAChF,4EAA4E;QAC5E,mEAAmE;QACnE,GAAG,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,eAAe,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAC9E,MAAM,kBAAkB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;QAC9D,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAChC,MAAM,EACN,gBAAgB,kBAAkB,CAAC,OAAO,CAAC,OAAO,EAClD,SAAS,EACT,EAAE,IAAI,EAAE,WAAW,EAAE,CACtB,CAAC;QACF,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAChE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;IACxG,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,GAAG,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAG,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;QAC7E,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC"}
@@ -14,7 +14,7 @@ The **encrypted token store** (`token-store.ts`) is still adapted from [`nsakki5
14
14
 
15
15
  End users never register an Azure app. The `OUTLOOK_CLIENT_ID` is a **public, non-secret** value (a PKCE public-client app has no client secret), and the app is **multi-tenant** (`/common`), so **one vendor-owned Entra app per brand** serves every install and every mailbox on that brand. End users only complete the OAuth consent screen; per-mailbox tokens stay per-account and encrypted, so a shared client ID does not weaken isolation.
16
16
 
17
- The value ships as the brand default: `brands/<brand>/brand.json#outlookClientId`. The installer stamps it onto the `-claude-session-manager` unit env as `OUTLOOK_CLIENT_ID` (+ `OUTLOOK_TENANT_ID=common`), and the plugin resolves it through the PLUGIN.md `mcp.env` passthrough. A brand that ships the field empty has the plugin inert (register refuses) until its vendor app exists — no operator action makes it work.
17
+ The value ships as the brand default: `brands/<brand>/brand.json#outlookClientId`. The installer stamps it onto the `-claude-session-manager` unit env as `OUTLOOK_CLIENT_ID` (+ `OUTLOOK_TENANT_ID=common`), and the plugin's MCP server reads it from `process.env` — it arrives by inheritance down the spawn chain (manager unit env → PTY → MCP child), not through any PLUGIN.md declaration. Outlook is `mcp-manifest: auto`, whose generator branch discards the declared `mcp.env` block entirely and emits only `MCP_SPAWN_TEE_NAME` (the manifest contract). The plugin's inert `OUTLOOK_CLIENT_ID: ${OUTLOOK_CLIENT_ID}` declaration has been deleted; it reached no path. A brand that ships the field empty has the plugin inert (register refuses) until its vendor app exists — no operator action makes it work.
18
18
 
19
19
  **Per-install override (escape hatch, not required):** setting `OUTLOOK_CLIENT_ID` in the install's env overrides the brand default. This is only for a vendor testing a replacement app; normal installs need nothing.
20
20
 
@@ -132,13 +132,25 @@ Recoverable — moves to Deleted Items, never hard-deletes or expunges. An id al
132
132
 
133
133
  ## outlook-draft-edit
134
134
 
135
- **Endpoint:** `PATCH /me/messages/{draftId}` (`ResponseType.RAW`; success asserted on HTTP 200) with only the supplied fields (`subject`, `body` → `{ contentType, content }`, `toRecipients`, `ccRecipients`, `bccRecipients`). Graph drafts are mutable, so no delete-and-reappend. At least one field is required; a PATCH on a sent (non-draft) message returns a Graph error surfaced unchanged.
135
+ **Endpoints (in order):**
136
+ 1. `PATCH /me/messages/{draftId}` (`ResponseType.RAW`; success asserted on HTTP 200) with only the supplied fields (`subject`, `body` → `{ contentType, content }`, `toRecipients`, `ccRecipients`, `bccRecipients`). Graph drafts are mutable, so no delete-and-reappend. **Skipped entirely** when the call supplies attachments and no patchable field. A PATCH on a sent (non-draft) message returns a Graph error surfaced unchanged.
137
+ 2. Per file, by size — identical to `outlook-mail-reply` step 3 (shared helper). Attachments edit in place: `attachments` adds files to what the draft already carries, `removeAttachments` takes files off via `DELETE /me/messages/{draftId}/attachments/{attachmentId}`, and the two together replace a file.
138
+
139
+ **Removal resolution.** Each `removeAttachments` entry is matched against `GET /me/messages/{draftId}/attachments` (the same paginated call `outlook-mail-attachment` uses — shared as `lib/attachment-list.ts`): an exact attachment-id match wins, otherwise an exact name match. Zero matches refuses `not-on-draft` and names what the draft carries; two or more name matches refuses `ambiguous-name` and names the ids that disambiguate. Both fire before the PATCH — the listing is a GET — so a bad removal leaves the draft untouched. Resolution completing before any write is what makes a same-name swap unambiguous: the old file's id is pinned before the new file exists. Two distinct targets addressing the same attachment (an id and a name for one file) are collapsed to one removal rather than refused, so each attachment is deleted at most once. The DELETEs and attaches target the id the PATCH reported, while the listing is necessarily read from the caller's id; see [Item id contract](#item-id-contract).
140
+
141
+ **Removal observability.** `op=resolve requested=<n> resolved=<m>` is emitted once every target has resolved (`m` below `n` means targets were deduped), then one `op=detach id=<name> attachmentId=<id>` per file **after** its DELETE returns. A detach count below `resolved` together with a terminal failure is the partial-removal signature: `draft-edit` is non-atomic across PATCH, DELETE and attach, so a DELETE failing on file 2 of 3 leaves the draft matching neither the before nor the requested after while the caller is told the edit failed.
136
142
 
137
- **Returned shape:** `{ draftId: string; updated: true }` `draftId` is the id Graph reported for the updated draft, which is authoritative over the id passed in. The tool refuses rather than report `updated: true` for an id it has not read back.
143
+ At least one patchable field, **one attachment or one removal** is required. Attachment paths are validated, and removals resolved, before step 1 so a bad path or an unresolvable removal leaves the draft untouched rather than half-edited.
144
+
145
+ Step 2 targets the id step 1 **reported**, not the caller's `draftId`. Ids are immutable plugin-wide so the two normally match, but a rotated id means the caller's handle no longer addresses the draft — see [Item id contract](#item-id-contract).
146
+
147
+ **Returned shape:** `{ draftId: string; updated: true; attachments: string[]; removed: string[] }` — `attachments` names the files added, `removed` the files taken off. `draftId` is the id Graph reported for the updated draft, which is authoritative over the id passed in. The tool refuses rather than report `updated: true` for an id it has not read back. An attachments-only or removal-only edit issues no PATCH, so it reports the caller's id.
138
148
 
139
149
  ## outlook-mail-send
140
150
 
141
- **Endpoint:** `POST /me/sendMail`
151
+ Two transports, chosen by whether the message carries a file. The `op: "transport"` log line names the route actually taken.
152
+
153
+ **Route A — no attachments. Endpoint:** `POST /me/sendMail`
142
154
 
143
155
  **Request body:**
144
156
  ```json
@@ -156,13 +168,28 @@ Recoverable — moves to Deleted Items, never hard-deletes or expunges. An id al
156
168
 
157
169
  **Success:** HTTP `202 Accepted`, empty body. No message id is returned. The tool asserts on the 202 — an empty body is not proof of send.
158
170
 
171
+ **Route B — with attachments. Endpoints (in order):**
172
+ 1. `POST /me/messages` with the `message` object above (no `saveToSentItems` wrapper) → 201 with the created draft; `id` is used for steps 2-3 only.
173
+ 2. Per file, by size — identical to `outlook-mail-reply` step 3 (shared helper).
174
+ 3. `POST /me/messages/{draftId}/send` → 202. Graph consumes the draft and saves to Sent Items.
175
+
176
+ The switch is forced, not stylistic: `/me/sendMail` carries attachments inline in the request body and is bounded well below the plugin's 25 MB per-file cap, so a large file can only reach the wire through a draft's upload session. A `route=sendMail` line with `attachments>0` is the mis-wire signature and must never appear.
177
+
178
+ Route B is **not atomic**, unlike route A: an attach or send failing Graph-side leaves a draft in the Drafts folder — the same exposure `outlook-mail-reply` carries, and not cleaned up here either. Attachment paths are validated before step 1, so the common failure (a bad path) leaves nothing behind.
179
+
180
+ **Finding an orphan.** Step 1 emits `op:"draft-created" id=<draftId>` the moment a draft exists, mirroring `outlook-draft`'s `draft-created` / `outlook-draft-send`'s `draft-sent` pairing. The orphan signature is a `draft-created` line with **no** terminal `sent` line, and the `id` on it is the handle needed to go delete the draft. The `op:"transport"` line alone is not the signature: it is emitted before the create, so a transport line with no `draft-created` means the create itself failed and stranded nothing.
181
+
182
+ **Returned shape:** `{ status: "sent"; httpStatus: number; messageId: string | null; attachments: string[] }` — `messageId` is `null` on **both** routes. Route A returns no body; on route B the draft id is consumed by `/send` and would 404 if handed back — see [Item id contract](#item-id-contract).
183
+
159
184
  ## outlook-draft
160
185
 
161
- **Endpoint:** `POST /me/messages`
186
+ **Endpoints (in order):**
187
+ 1. `POST /me/messages` with the `message` object above (no `saveToSentItems` wrapper).
188
+ 2. Per file, by size — identical to `outlook-mail-reply` step 3 (shared helper). Attachment paths are validated before step 1, so a bad path leaves no orphan draft.
162
189
 
163
- **Request body:** the `message` object above (no `saveToSentItems` wrapper).
190
+ **Success:** HTTP `201 Created` with the created message JSON; `id` is the handle passed to `outlook-draft-send`, and the returned draft already carries the files. It is durable only because the plugin opts into immutable ids — see [Item id contract](#item-id-contract).
164
191
 
165
- **Success:** HTTP `201 Created` with the created message JSON; `id` is the handle passed to `outlook-draft-send`. It is durable only because the plugin opts into immutable ids — see [Item id contract](#item-id-contract).
192
+ **Returned shape:** `{ draftId: string; attachments: string[] }`.
166
193
 
167
194
  ## outlook-draft-send
168
195
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: outlook
3
- description: "Microsoft 365 / Outlook.com via Microsoft Graph. Mail is read (list, search, full-body), reply, delete, and compose (draft, draft-edit, send); contacts are read-only; the calendar is read plus control. Use when the user asks about their Outlook mail, calendar, or contacts, wants to read a full message, reply, delete, send or draft a message, or asks to book, move, cancel, or accept a calendar event. First-time use requires outlook-account-register plus outlook-account-register-poll; subsequent use is transparent. Tools: outlook-mail-list / outlook-mail-search (inbox triage, ~255-char preview, date window + nextCursor paging), outlook-mail-fetch-body (full body of one message), outlook-mail-reply (in-thread reply with attachments), outlook-mail-delete (move to Deleted Items), outlook-mail-otp-extract (poll for a one-time code), outlook-mail-send / outlook-draft / outlook-draft-edit / outlook-draft-send (compose, edit, send), outlook-calendar-list / outlook-calendar-event (read calendar), outlook-calendar-create / outlook-calendar-update / outlook-calendar-cancel / outlook-calendar-respond / outlook-calendar-freebusy (control calendar), outlook-contacts-list (contacts), outlook-mailbox-info (health), outlook-account-register / outlook-account-register-poll (device-code register)."
3
+ description: "Microsoft 365 / Outlook.com via Microsoft Graph. Mail is read (list, search, full-body), reply, delete, and compose (draft, draft-edit, send); contacts are read-only; the calendar is read plus control. Use when the user asks about their Outlook mail, calendar, or contacts, wants to read a full message, reply, delete, send or draft a message, or asks to book, move, cancel, or accept a calendar event. First-time use requires outlook-account-register plus outlook-account-register-poll; subsequent use is transparent. Tools: outlook-mail-list / outlook-mail-search (inbox triage, ~255-char preview, date window + nextCursor paging), outlook-mail-fetch-body (full body of one message), outlook-mail-reply (in-thread reply with attachments), outlook-mail-delete (move to Deleted Items), outlook-mail-otp-extract (poll for a one-time code), outlook-mail-send / outlook-draft / outlook-draft-edit / outlook-draft-send (compose, edit, send, with attachments), outlook-calendar-list / outlook-calendar-event (read calendar), outlook-calendar-create / outlook-calendar-update / outlook-calendar-cancel / outlook-calendar-respond / outlook-calendar-freebusy (control calendar), outlook-contacts-list (contacts), outlook-mailbox-info (health), outlook-account-register / outlook-account-register-poll (device-code register)."
4
4
  ---
5
5
 
6
6
  # Outlook (Microsoft Graph)
@@ -50,7 +50,7 @@ The revoke path below is scoped to one specific, visible failure. It is not a ge
50
50
  ## Reading mail
51
51
 
52
52
  - `outlook-mail-list` — mail newest-first, default top=25, folder=Inbox. Returns Microsoft's short `bodyPreview` (~255 chars) for cheap triage. Add `since`/`before` (ISO date-times) for a date window. To reach mail older than the newest page, pass the response's `nextCursor` back as `cursor` — repeat until `nextCursor` is null. Filter by sender or subject via `outlook-mail-search`.
53
- - `outlook-mail-search query=<keyword>` — Microsoft Graph `$search` (KQL) over the mailbox; same preview-only shape as the list. Put filters in the query: `from:addr`, `to:addr`, `subject:text`, `received>=2024-01-01`, or free text. Page with `nextCursor` → `cursor` like the list. (Graph forbids `$search`+date-`$filter`, so a strict date window is on `outlook-mail-list`.)
53
+ - `outlook-mail-search query=<keyword>` — Microsoft Graph `$search` (KQL) over the mailbox; same preview-only shape as the list. Filters go **inside the `query` string** as KQL text, not as tool parameters: `query="from:sam@example.com"`, `query="subject:invoice received>=2024-01-01"`, or free text. The bare `from:`/`to:` form is KQL syntax that lives inside that one string; it is not how recipients are written anywhere else in this plugin (see Sending and drafting, where `to` is a JSON array of quoted strings). Page with `nextCursor` → `cursor` like the list. (Graph forbids `$search`+date-`$filter`, so a strict date window is on `outlook-mail-list`.)
54
54
  - `outlook-mail-fetch-body messageId=<id>` — the COMPLETE body of one message (HTML decoded to text, no preview cap). This is the full-read path: `outlook-mail-list` / `outlook-mail-search` return previews only, so when you must read or act on a message's actual content, fetch the body by its id. Also returns the envelope (from, to, cc, subject, date, conversationId).
55
55
  - `outlook-mail-attachment messageId=<id>` — LIST a message's attachments (`id`, `name`, `contentType`, `size`, `isInline`, `kind`). `outlook-mail-list` / `outlook-mail-search` / `outlook-mail-fetch-body` all report `hasAttachments`; when it is true, call this to see what is attached.
56
56
  - `outlook-mail-attachment messageId=<id> attachmentId=<id>` — DOWNLOAD one file attachment. The bytes are saved under the account's `uploads/outlook` folder and the absolute path is returned, ready for the Read tool, `SendUserFile`, or an `outlook-mail-reply` attachment. Only file attachments download: `item` and `reference` kinds are refused, as are empty payloads and anything over 25 MB. Needs `Mail.Read`.
@@ -66,9 +66,26 @@ The revoke path below is scoped to one specific, visible failure. It is not a ge
66
66
 
67
67
  ## Sending and drafting
68
68
 
69
- - `outlook-mail-send` — send a message. `to` is an array of addresses (at least one); `cc`/`bcc` optional arrays; `subject`; `body`; `isHtml` true for an HTML body, otherwise plain text. A copy is saved to Sent Items. Success is confirmed on Graph's 202 response.
70
- - `outlook-draft` — create a draft in the Drafts folder (same fields as send). Returns the draft's id.
71
- - `outlook-draft-edit draftId=<id>` update an existing draft in place (Graph drafts are mutable, so no delete-and-reappend). Pass the draftId plus only the fields to change: `to`, `cc`, `bcc`, `subject`, `body`, `isHtml`. At least one field is required; a sent message cannot be edited.
69
+ - `outlook-mail-send` — send a message. `to` is an array of addresses (at least one); `cc`/`bcc` optional arrays; `subject`; `body`; `isHtml` true for an HTML body, otherwise plain text; `attachments` an array of file paths inside the account directory, up to 25 MB each. A copy is saved to Sent Items. Success is confirmed on Graph's 202 response.
70
+
71
+ Every address is a **quoted string inside an array**, even when there is only one recipient, and `mailbox` is a plain quoted string. `attachments` takes the same shape: an array of quoted absolute paths.
72
+
73
+ ```json
74
+ {
75
+ "mailbox": "rob@example.com",
76
+ "to": ["rob@example.com"],
77
+ "cc": ["tom@example.com"],
78
+ "subject": "Pricing schedule",
79
+ "body": "Schedule attached.",
80
+ "isHtml": false,
81
+ "attachments": ["/path/to/account/uploads/outlook/schedule.pdf"]
82
+ }
83
+ ```
84
+
85
+ `"to": rob@example.com` (unquoted) and `"to": "rob@example.com"` (quoted but not an array) are both rejected before the call reaches Outlook. A rejection here means the arguments were malformed; it is not evidence that sending is broken. Check `outlook-mailbox-info` before reporting a send fault.
86
+
87
+ - `outlook-draft` — create a draft in the Drafts folder (same fields, same array-of-quoted-strings shape as send, including `attachments`). Returns the draft's id, and the files are already on the draft, so it can be sent as-is.
88
+ - `outlook-draft-edit draftId=<id>` — update an existing draft in place (Graph drafts are mutable, so no delete-and-reappend). Pass the draftId plus only the fields to change: `to`, `cc`, `bcc`, `subject`, `body`, `isHtml`, `attachments`, `removeAttachments` (recipients and attachments take the same array-of-quoted-strings shape as send). `attachments` adds files to the draft. `removeAttachments` takes files off it, each entry either an attachment name or an attachment id. Pass both to replace a file in one call. To see what a draft carries, call `outlook-mail-attachment` with the draftId as its messageId. Removing a file the draft does not carry, or a name it carries twice, is refused and changes nothing. At least one field, attachment or removal is required; a sent message cannot be edited.
72
89
  - `outlook-draft-send draftId=<id>` — send a draft created earlier. Graph consumes the draft on send.
73
90
 
74
91
  If the mailbox was registered before send was available, the first send returns "re-register to grant send" — run `outlook-account-register` again and consent to the send scopes.
@@ -17,6 +17,18 @@ tools:
17
17
  - name: storage-r2-bucket-create
18
18
  publicAllowlist: false
19
19
  adminAllowlist: true
20
+ - name: storage-r2-object-list
21
+ publicAllowlist: false
22
+ adminAllowlist: true
23
+ - name: storage-r2-object-get
24
+ publicAllowlist: false
25
+ adminAllowlist: true
26
+ - name: storage-r2-object-put
27
+ publicAllowlist: false
28
+ adminAllowlist: true
29
+ - name: storage-r2-object-delete
30
+ publicAllowlist: false
31
+ adminAllowlist: true
20
32
  metadata: {"platform":{"embed":["admin"]}}
21
33
  mcp:
22
34
  command: node
@@ -35,7 +47,7 @@ mcp-manifest: auto
35
47
 
36
48
  # storage-broker
37
49
 
38
- The isolation boundary for per-account Cloudflare D1 and R2 on a multi-tenant install. A sub-account agent is issued no Cloudflare credential: its `cloudflare.env` carries no account-wide token, and `cf-token.sh` refuses to mint one for a non-house caller. The broker is therefore the only *sanctioned* route to D1 and R2, and it denies cross-account access before calling Cloudflare. It is not an OS-enforced boundary: all accounts share one unix user, so an agent holding `Bash` can read the house credential and reach `wrangler` outside the broker. Closing that requires OS user separation, tracked separately. Every D1 and R2 operation goes through these tools, which forward the caller's account as the platform-stamped `x-maxy-caller-account` header (never a tool argument) to the house-level broker service. The service holds the sole account-wide credential in `config/cloudflare-house.env`, resolves each resource's recorded owner, and denies any cross-account access before it ever calls Cloudflare.
50
+ The isolation boundary for per-account Cloudflare D1 and R2 on a multi-tenant install. A sub-account agent is issued no Cloudflare credential: its `cloudflare.env` carries no account-wide token, and `cf-token.sh` refuses to mint one for a non-house caller. The broker is therefore the only *sanctioned* route to D1 and R2, and it denies cross-account access before calling Cloudflare. It is not an OS-enforced boundary: all accounts share one unix user, so an agent holding `Bash` can read the house credential and reach `wrangler` outside the broker. Closing that requires OS user separation, which was costed and declined as disproportionate — so this stays a sanctioned-path boundary permanently, and nothing tracks closing it. Every D1 and R2 operation goes through these tools, which forward the caller's account as the platform-stamped `x-maxy-caller-account` header (never a tool argument) to the house-level broker service. The service holds the sole account-wide credential in `config/cloudflare-house.env`, resolves each resource's recorded owner, and denies any cross-account access before it ever calls Cloudflare.
39
51
 
40
52
  ## Tools
41
53
 
@@ -44,9 +56,36 @@ The isolation boundary for per-account Cloudflare D1 and R2 on a multi-tenant in
44
56
  - `storage-d1-query` — run SQL against a database the caller owns.
45
57
  - `storage-r2-bucket-list` — the caller account's R2 buckets.
46
58
  - `storage-r2-bucket-create` — create an R2 bucket, registered to the caller.
59
+ - `storage-r2-object-list` — the objects in a bucket the caller owns.
60
+ - `storage-r2-object-get` — download an object to a file in the caller's account directory. Objects over 100 MiB are rejected.
61
+ - `storage-r2-object-put` — upload a file from the caller's account directory. Files over 100 MiB are rejected.
62
+ - `storage-r2-object-delete` — delete an object from a bucket the caller owns.
47
63
 
48
64
  A request against a database or bucket the caller does not own returns an authorization error, not another account's data.
49
65
 
66
+ ## Where the object tools do their file I/O, and why
67
+
68
+ `storage-r2-object-get` writes to a file and `storage-r2-object-put` reads from one, rather than passing bytes through the tool result, because these objects are photos and scans and base64 in a result would push megabytes into the agent's context window.
69
+
70
+ That file I/O happens in this MCP process, under the caller's own account, and never in the house-level broker service. The service holds the account-wide credential, so a caller-supplied path resolved there would be a house-privileged arbitrary read and write reachable from any sub-account — a `put` sourced from `config/cloudflare-house.env` would copy the house master into the caller's own bucket, to be read back legitimately afterwards. Keeping the service free of any filesystem access removes that class entirely, and it needs no `Bash`, so OS user separation would not have closed it.
71
+
72
+ The paths are confined to the caller's account directory by realpath, which a symlink cannot escape. That is a correctness guardrail rather than a boundary: all accounts share one unix user, so an agent holding `Bash` can already read whatever this process can.
73
+
74
+ ## The 100 MiB object cap
75
+
76
+ `storage-r2-object-get` and `storage-r2-object-put` refuse any object over 100 MiB. The number lives once, in `platform/lib/storage-broker/src/object-limits.ts`, and both the tools and the broker routes read it from there.
77
+
78
+ It is set independently of the email plugin's 25 MiB attachment cap. Both bound the same class of payload, but for different reasons, and so they move for different reasons: email's tracks an SMTP-side rejection threshold, this one tracks memory in the house process. R2 does not bind either — a single-part upload may be up to 5 GiB — so this cap is the only bound on either transfer.
79
+
80
+ Both directions are checked before anything is buffered, in two places that are not redundant:
81
+
82
+ - `put` is size-checked in this MCP process with `statSync` before the file is read. That is what produces the error naming the file and the limit.
83
+ - The house routes enforce independently, because they are plain loopback HTTP and every agent holds `Bash`: a cap enforced only here is bypassed by one `curl`, and the house process is the one holding the account-wide credential. Every object route rejects an over-cap body at Hono's `bodyLimit`, before the body is buffered — `/r2/object/put` against a base64 object ceiling, and `list`, `get` and `delete` against a 64 KiB metadata envelope, since those three carry a bucket and a key or prefix and nothing else. `get` is additionally sized from `r2ObjectFind`'s recorded `size` before any bytes move, which stops at the page carrying the exact key rather than listing every object sharing it as a prefix.
84
+
85
+ A `get` whose key has no recorded size in the listing is refused, not attempted. No recorded size means no bound, and a stale or lagging listing would otherwise transfer an unbounded object. The cost is that a genuinely missing object reports "no recorded size" rather than Cloudflare's 404.
86
+
87
+ The cap bounds the spike; it does not make it small. At 100 MiB a `get` still leaves the house process holding the object and its base64 form, roughly 2.4x. Streaming and multipart transfer are the real fix for large objects and are deliberately not implemented; the cap stands in for them.
88
+
50
89
  ## Wrangler resolution
51
90
 
52
- The broker service shells wrangler through `npx wrangler`, never bare `wrangler`, for every D1 operation and R2 bucket creation. The brand server PATH carries no global wrangler install; only `npx wrangler` resolves, so a bare `wrangler` call ENOENTs those operations on a real install. R2 bucket listing is exempt: it reads the Cloudflare R2 API directly, not wrangler.
91
+ The broker service shells wrangler through `npx wrangler`, never bare `wrangler`, for every D1 operation and R2 bucket creation. The brand server PATH carries no global wrangler install; only `npx wrangler` resolves, so a bare `wrangler` call ENOENTs those operations on a real install. R2 bucket listing and every R2 object operation are exempt: they read the Cloudflare REST API directly, not wrangler.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=confine-path.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confine-path.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/confine-path.test.ts"],"names":[],"mappings":""}