@introspection-ai/recipes 0.51.0 → 0.52.1

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 (235) hide show
  1. package/README.md +3 -3
  2. package/dist/api/api-bindings.d.ts +3 -0
  3. package/dist/api/api-bindings.d.ts.map +1 -0
  4. package/dist/api/api-bindings.js +2 -0
  5. package/dist/api/api-bindings.js.map +1 -0
  6. package/dist/api/session.d.ts +1 -0
  7. package/dist/api/session.d.ts.map +1 -1
  8. package/dist/api-bindings.d.ts +101 -0
  9. package/dist/api-bindings.d.ts.map +1 -0
  10. package/dist/api-bindings.js +406 -0
  11. package/dist/api-bindings.js.map +1 -0
  12. package/dist/channels/arguments.d.ts +116 -0
  13. package/dist/channels/arguments.d.ts.map +1 -0
  14. package/dist/channels/arguments.generated.d.ts +15 -0
  15. package/dist/channels/arguments.generated.d.ts.map +1 -0
  16. package/dist/channels/arguments.generated.js +181 -0
  17. package/dist/channels/arguments.generated.js.map +1 -0
  18. package/dist/channels/arguments.js +8 -0
  19. package/dist/channels/arguments.js.map +1 -0
  20. package/dist/channels/module.d.ts +5 -0
  21. package/dist/channels/module.d.ts.map +1 -1
  22. package/dist/channels/module.js +10 -5
  23. package/dist/channels/module.js.map +1 -1
  24. package/dist/channels/tools.d.ts.map +1 -1
  25. package/dist/channels/tools.js +22 -59
  26. package/dist/channels/tools.js.map +1 -1
  27. package/dist/channels/types.d.ts +5 -0
  28. package/dist/channels/types.d.ts.map +1 -1
  29. package/dist/child/session.d.ts +5 -0
  30. package/dist/child/session.d.ts.map +1 -1
  31. package/dist/child/session.js +2 -0
  32. package/dist/child/session.js.map +1 -1
  33. package/dist/clock.d.ts +80 -0
  34. package/dist/clock.d.ts.map +1 -0
  35. package/dist/clock.js +169 -0
  36. package/dist/clock.js.map +1 -0
  37. package/dist/command-parameters.d.ts +37 -5
  38. package/dist/command-parameters.d.ts.map +1 -1
  39. package/dist/command-parameters.js +73 -11
  40. package/dist/command-parameters.js.map +1 -1
  41. package/dist/connector-tools.d.ts +18 -0
  42. package/dist/connector-tools.d.ts.map +1 -1
  43. package/dist/connector-tools.js +48 -2
  44. package/dist/connector-tools.js.map +1 -1
  45. package/dist/documents/tools.d.ts.map +1 -1
  46. package/dist/documents/tools.js +3 -3
  47. package/dist/documents/tools.js.map +1 -1
  48. package/dist/introspection-open.d.ts +2 -1
  49. package/dist/introspection-open.d.ts.map +1 -1
  50. package/dist/introspection-open.js +14 -6
  51. package/dist/introspection-open.js.map +1 -1
  52. package/dist/issues/index.d.ts +7 -0
  53. package/dist/issues/index.d.ts.map +1 -0
  54. package/dist/issues/index.js +4 -0
  55. package/dist/issues/index.js.map +1 -0
  56. package/dist/issues/module.d.ts +38 -0
  57. package/dist/issues/module.d.ts.map +1 -0
  58. package/dist/issues/module.js +114 -0
  59. package/dist/issues/module.js.map +1 -0
  60. package/dist/issues/tool.d.ts +95 -0
  61. package/dist/issues/tool.d.ts.map +1 -0
  62. package/dist/issues/tool.js +479 -0
  63. package/dist/issues/tool.js.map +1 -0
  64. package/dist/issues/types.d.ts +280 -0
  65. package/dist/issues/types.d.ts.map +1 -0
  66. package/dist/issues/types.js +79 -0
  67. package/dist/issues/types.js.map +1 -0
  68. package/dist/mcp/cli/command-context.d.ts +20 -1
  69. package/dist/mcp/cli/command-context.d.ts.map +1 -1
  70. package/dist/mcp/cli/command-context.js.map +1 -1
  71. package/dist/mcp/cli/core.d.ts +0 -2
  72. package/dist/mcp/cli/core.d.ts.map +1 -1
  73. package/dist/mcp/cli/core.js +9 -33
  74. package/dist/mcp/cli/core.js.map +1 -1
  75. package/dist/mcp/cli/handshake-retry.d.ts +5 -0
  76. package/dist/mcp/cli/handshake-retry.d.ts.map +1 -0
  77. package/dist/mcp/cli/handshake-retry.js +32 -0
  78. package/dist/mcp/cli/handshake-retry.js.map +1 -0
  79. package/dist/mcp/daemon/index.js +3 -4
  80. package/dist/mcp/daemon/index.js.map +1 -1
  81. package/dist/mcp/pi-client.d.ts +2 -0
  82. package/dist/mcp/pi-client.d.ts.map +1 -1
  83. package/dist/mcp/pi-client.js +5 -1
  84. package/dist/mcp/pi-client.js.map +1 -1
  85. package/dist/mcp/pi-mcp-runtime.d.ts +25 -0
  86. package/dist/mcp/pi-mcp-runtime.d.ts.map +1 -0
  87. package/dist/mcp/pi-mcp-runtime.js +215 -0
  88. package/dist/mcp/pi-mcp-runtime.js.map +1 -0
  89. package/dist/mcp/pi-runtime.d.ts +7 -0
  90. package/dist/mcp/pi-runtime.d.ts.map +1 -0
  91. package/dist/mcp/pi-runtime.js +26 -0
  92. package/dist/mcp/pi-runtime.js.map +1 -0
  93. package/dist/mcp-chunks/chunk-3UVHZECT.js +31 -0
  94. package/dist/mcp-chunks/{chunk-PO2SOBEN.js → chunk-CGJ2XOSF.js} +43 -35
  95. package/dist/mcp-chunks/{chunk-GTETFUPQ.js → chunk-IMG2JMBS.js} +8 -8
  96. package/dist/mcp-chunks/{chunk-UFV6SVQG.js → chunk-LQKMNWDE.js} +2 -2
  97. package/dist/mcp-chunks/{chunk-S2F7DDP5.js → chunk-QUDOU7MQ.js} +1 -1
  98. package/dist/mcp-chunks/{cli-IYD7Y7MO.js → cli-BM23ZXPJ.js} +54 -54
  99. package/dist/mcp-chunks/{client-5MNBV3Z7.js → client-RKTAKDAY.js} +7 -7
  100. package/dist/mcp-chunks/{daemon-command-V3B3EMXD.js → daemon-command-VU6WTFCJ.js} +8 -8
  101. package/dist/mcp-chunks/{generate-cli-runner-PW5WJ7KI.js → generate-cli-runner-JAAPSWGX.js} +12 -12
  102. package/dist/mcp-chunks/{generated-daemon-runtime-3C4NWGAU.js → generated-daemon-runtime-LX4L2X7Z.js} +8 -8
  103. package/dist/mcp-chunks/pi-mcp-runtime-GHDEPXUL.js +1231 -0
  104. package/dist/mcp-chunks/{runtime-RMI3XCYJ.js → runtime-T63YI7TC.js} +6 -6
  105. package/dist/mcp-chunks/{serve-command-UF5SVREV.js → serve-command-75P4VBJ6.js} +7 -7
  106. package/dist/mcp-daemon.js +21 -19
  107. package/dist/mcp-run-worker.js +11 -10
  108. package/dist/open.d.ts +6 -0
  109. package/dist/open.d.ts.map +1 -1
  110. package/dist/open.js +9 -1
  111. package/dist/open.js.map +1 -1
  112. package/dist/pi-extension.d.ts +3 -0
  113. package/dist/pi-extension.d.ts.map +1 -1
  114. package/dist/pi-extension.js +82 -18
  115. package/dist/pi-extension.js.map +1 -1
  116. package/dist/productivity/arguments.d.ts +298 -0
  117. package/dist/productivity/arguments.d.ts.map +1 -0
  118. package/dist/productivity/arguments.generated.d.ts +28 -0
  119. package/dist/productivity/arguments.generated.d.ts.map +1 -0
  120. package/dist/productivity/arguments.generated.js +489 -0
  121. package/dist/productivity/arguments.generated.js.map +1 -0
  122. package/dist/productivity/arguments.js +10 -0
  123. package/dist/productivity/arguments.js.map +1 -0
  124. package/dist/productivity/http.d.ts.map +1 -1
  125. package/dist/productivity/http.js +4 -1
  126. package/dist/productivity/http.js.map +1 -1
  127. package/dist/productivity/index.d.ts +1 -1
  128. package/dist/productivity/index.d.ts.map +1 -1
  129. package/dist/productivity/index.js +1 -1
  130. package/dist/productivity/index.js.map +1 -1
  131. package/dist/productivity/module.d.ts +15 -2
  132. package/dist/productivity/module.d.ts.map +1 -1
  133. package/dist/productivity/module.js +24 -19
  134. package/dist/productivity/module.js.map +1 -1
  135. package/dist/productivity/tools.d.ts +6 -0
  136. package/dist/productivity/tools.d.ts.map +1 -1
  137. package/dist/productivity/tools.js +64 -224
  138. package/dist/productivity/tools.js.map +1 -1
  139. package/dist/productivity/types.d.ts +2 -0
  140. package/dist/productivity/types.d.ts.map +1 -1
  141. package/dist/productivity/types.js.map +1 -1
  142. package/dist/recipe/agent.d.ts +40 -10
  143. package/dist/recipe/agent.d.ts.map +1 -1
  144. package/dist/recipe/agent.js +209 -30
  145. package/dist/recipe/agent.js.map +1 -1
  146. package/dist/recipe/companions.js +1 -1
  147. package/dist/recipe/manifest.generated.d.ts +3 -1
  148. package/dist/recipe/manifest.generated.d.ts.map +1 -1
  149. package/dist/recipe/manifest.generated.js +3 -1
  150. package/dist/recipe/manifest.generated.js.map +1 -1
  151. package/dist/recipe/package.d.ts +28 -3
  152. package/dist/recipe/package.d.ts.map +1 -1
  153. package/dist/recipe/package.js +155 -1
  154. package/dist/recipe/package.js.map +1 -1
  155. package/dist/recipe/providers.d.ts +62 -0
  156. package/dist/recipe/providers.d.ts.map +1 -0
  157. package/dist/recipe/providers.js +95 -0
  158. package/dist/recipe/providers.js.map +1 -0
  159. package/dist/recipe/resolve.d.ts +7 -3
  160. package/dist/recipe/resolve.d.ts.map +1 -1
  161. package/dist/recipe/resolve.js +7 -2
  162. package/dist/recipe/resolve.js.map +1 -1
  163. package/dist/run-controller.d.ts +6 -0
  164. package/dist/run-controller.d.ts.map +1 -1
  165. package/dist/run-controller.js +2 -0
  166. package/dist/run-controller.js.map +1 -1
  167. package/dist/search/index.d.ts +2 -1
  168. package/dist/search/index.d.ts.map +1 -1
  169. package/dist/search/index.js +1 -1
  170. package/dist/search/index.js.map +1 -1
  171. package/dist/search/module.d.ts +19 -7
  172. package/dist/search/module.d.ts.map +1 -1
  173. package/dist/search/module.js +38 -16
  174. package/dist/search/module.js.map +1 -1
  175. package/dist/search/tool.d.ts +6 -1
  176. package/dist/search/tool.d.ts.map +1 -1
  177. package/dist/search/tool.js +22 -9
  178. package/dist/search/tool.js.map +1 -1
  179. package/dist/search/types.d.ts +13 -3
  180. package/dist/search/types.d.ts.map +1 -1
  181. package/dist/search/types.js +4 -1
  182. package/dist/search/types.js.map +1 -1
  183. package/dist/session.d.ts +21 -1
  184. package/dist/session.d.ts.map +1 -1
  185. package/dist/session.js +132 -43
  186. package/dist/session.js.map +1 -1
  187. package/dist/test-utils.d.ts +2 -0
  188. package/dist/test-utils.d.ts.map +1 -1
  189. package/dist/test-utils.js +3 -1
  190. package/dist/test-utils.js.map +1 -1
  191. package/dist/tool-search.d.ts +9 -0
  192. package/dist/tool-search.d.ts.map +1 -1
  193. package/dist/tool-search.js +23 -0
  194. package/dist/tool-search.js.map +1 -1
  195. package/dist/tools/bridge.d.ts +44 -0
  196. package/dist/tools/bridge.d.ts.map +1 -0
  197. package/dist/tools/bridge.js +106 -0
  198. package/dist/tools/bridge.js.map +1 -0
  199. package/dist/tools/cli.d.ts +20 -0
  200. package/dist/tools/cli.d.ts.map +1 -0
  201. package/dist/tools/cli.js +246 -0
  202. package/dist/tools/cli.js.map +1 -0
  203. package/dist/tools/entry.d.ts +2 -0
  204. package/dist/tools/entry.d.ts.map +1 -0
  205. package/dist/tools/entry.js +3 -0
  206. package/dist/tools/entry.js.map +1 -0
  207. package/dist/tools/shell.d.ts +12 -0
  208. package/dist/tools/shell.d.ts.map +1 -0
  209. package/dist/tools/shell.js +50 -0
  210. package/dist/tools/shell.js.map +1 -0
  211. package/dist/tuning/tpe.d.ts +112 -0
  212. package/dist/tuning/tpe.d.ts.map +1 -0
  213. package/dist/tuning/tpe.js +286 -0
  214. package/dist/tuning/tpe.js.map +1 -0
  215. package/docs/README.md +3 -1
  216. package/docs/channels/README.md +10 -0
  217. package/docs/documents/README.md +20 -19
  218. package/docs/host-api.md +10 -0
  219. package/docs/interactions.md +6 -6
  220. package/docs/issues/README.md +183 -0
  221. package/docs/mcp-configuration.md +65 -1
  222. package/docs/pi-extension.md +5 -0
  223. package/docs/productivity/README.md +8 -3
  224. package/docs/providers.md +321 -0
  225. package/docs/recipe-format.md +103 -32
  226. package/docs/search/README.md +37 -20
  227. package/package.json +28 -10
  228. package/skills/documents/SKILL.md +2 -1
  229. package/dist/mcp-chunks/{auth-command-M7TQE3AL.js → auth-command-UYFOGGQR.js} +6 -6
  230. package/dist/mcp-chunks/{call-command-7LD7UEFK.js → call-command-6U5BNDR7.js} +17 -17
  231. package/dist/mcp-chunks/{chunk-PSE442BC.js → chunk-36D4FILJ.js} +26 -26
  232. package/dist/mcp-chunks/{config-command-6DXILFNO.js → config-command-ZSPJI34E.js} +10 -10
  233. package/dist/mcp-chunks/{emit-ts-command-NDCDFDRM.js → emit-ts-command-SY4LQE4S.js} +3 -3
  234. package/dist/mcp-chunks/{inspect-cli-command-4MGF5CPP.js → inspect-cli-command-JPX4ON6N.js} +4 -4
  235. package/dist/mcp-chunks/{resource-command-SRFQQROJ.js → resource-command-DUY4SVE5.js} +4 -4
@@ -0,0 +1,183 @@
1
+ # Issues tool
2
+
3
+ **Status: built** (`@introspection-ai/recipes/issues` and
4
+ `@introspection-ai/recipe-issues`). The Linear and Jira adapters are written
5
+ against tool names and arguments from vendor documentation, not yet against a
6
+ captured tool list; see [Tool maps](#tool-maps).
7
+
8
+ One `issues` tool tracks work in whichever tracker a Recipe's members use:
9
+ Linear, Jira, or Introspection's own issues when neither is connected. It is
10
+ the `issues` family of [provider modules](../providers.md).
11
+
12
+ ## Declare it
13
+
14
+ ```json
15
+ {
16
+ "pi": {
17
+ "issues": [
18
+ { "provider": "linear", "options": { "team": "ENG" } },
19
+ {
20
+ "provider": "jira",
21
+ "options": { "project": "OPS", "issueType": "Task" }
22
+ }
23
+ ]
24
+ }
25
+ }
26
+ ```
27
+
28
+ and select the tool in the agent file:
29
+
30
+ ```yaml
31
+ tools: [issues]
32
+ mcp:
33
+ servers:
34
+ linear:
35
+ include: ["*"]
36
+ behind: [issues]
37
+ atlassian:
38
+ include: ["*"]
39
+ behind: [issues]
40
+ ```
41
+
42
+ Nothing about issues loads, and no `issues` tool is offered, unless a Recipe
43
+ declares `pi.issues` and its agent selects `issues`.
44
+
45
+ A declaration takes only these fields:
46
+
47
+ | Field | Applies to | Meaning |
48
+ | ---------- | --------------- | ----------------------------------------------------------------------------------------- |
49
+ | `provider` | all | `linear`, `jira`, `introspection`, or a Recipe's own id |
50
+ | `package` | a Recipe's own | the installed package that serves it ([providers](../providers.md#2-declaring-providers)) |
51
+ | `options` | all | the provider's own settings, below |
52
+ | `enabled` | `introspection` | `false` leaves out the fallback |
53
+
54
+ | Option | Provider | Meaning |
55
+ | ---------------------- | ---------------- | ------------------------------------------------------------------ |
56
+ | `team` | `linear` | the team `create` files into |
57
+ | `project`, `issueType` | `jira` | the project and issue type `create` files into |
58
+ | `server` | `linear`, `jira` | the Recipe's MCP server id, when it is not `linear` or `atlassian` |
59
+
60
+ Validation (`pi.issues_invalid`) reports any other field, an option a
61
+ first-party provider does not take or of the wrong type, an unknown
62
+ first-party id, a duplicate, and a bad source. A Recipe's own provider
63
+ declares its options in `capabilities.options` (`{ queue: "string" }`), and
64
+ loading it fails on an option it does not declare.
65
+
66
+ ## Providers
67
+
68
+ | Provider | Transport | Server | Credential |
69
+ | --------------- | --------- | -------------------------------------------------- | ---------------------------------- |
70
+ | `linear` | MCP | `https://mcp.linear.app/mcp` | the member's MCP connector binding |
71
+ | `jira` | MCP | `https://mcp.atlassian.com/v2/mcp`, its Jira tools | the member's MCP connector binding |
72
+ | `introspection` | REST | the data plane's `/v1/issues` | the task's own session |
73
+
74
+ **`introspection` is the fallback.** It is included whenever `pi.issues` is
75
+ declared, unless declared with `"enabled": false`, and is offered only while
76
+ no other declared provider has a working credential path. Once a member
77
+ connects Linear or Jira, `search` and `create` go there; an issue already
78
+ filed on Introspection stays readable by its handle.
79
+
80
+ **Choosing a provider.** A provider is on offer when it has a working
81
+ credential path: an MCP provider when its bound server offers one of its
82
+ adapter's tools, `introspection` when the runtime holds a data plane URL and
83
+ the task's token. `search` and `create` name a provider when several are on
84
+ offer; every other command takes a handle, which names its provider. The
85
+ tool's `provider` parameter lists the declared providers, since an MCP
86
+ server's tools are known only once it has connected; a call naming one that
87
+ is not on offer fails with `not_connected`.
88
+
89
+ **Connecting Linear or Jira.** Both are OAuth MCP servers, connected per
90
+ member through an MCP connector binding. When none is connected the tool
91
+ answers `not_connected`, and the agent asks the member to connect one with
92
+ `introspection_open`.
93
+
94
+ **Introspection's session.** The provider uses the JavaScript SDK
95
+ (`@introspection-sdk/introspection-node`): a `DataPlaneClient` on
96
+ `INTROSPECTION_DP_URL` (else `INTROSPECTION_BASE_API_URL`) with
97
+ `INTROSPECTION_TOKEN`, all of which the runtime injects into the task's
98
+ sandbox. `create` files the issue on the calling task
99
+ (`INTROSPECTION_TASK_ID`), in the Recipe's project.
100
+
101
+ ## Commands
102
+
103
+ | Command | Takes | Does |
104
+ | ------------ | ----------------------------------------------------------------------------------- | --------------------------- |
105
+ | `search` | `query`, `status`, `assignee`, `container`, `label`, `limit` | find issues |
106
+ | `get` | `handle` | one issue with its comments |
107
+ | `create` | `title`, `description`, `priority`, `labels`, `assignee`, `container`, `issue_type` | a new issue |
108
+ | `update` | `handle`, `title`, `description`, `priority`, `labels`, `assignee` | change fields |
109
+ | `comment` | `handle`, `body` | add a comment |
110
+ | `transition` | `handle`, `status` (a name or a category) | move to another status |
111
+
112
+ ## The shape
113
+
114
+ Every issue comes back in one shape, with a handle every later command takes:
115
+
116
+ | Field | Linear | Jira | Introspection |
117
+ | ------------------------ | ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
118
+ | `handle` | `linear:ENG-123` | `jira:PROJ-45` | `introspection:<display index>` |
119
+ | `title` | title | summary | title |
120
+ | `description` (markdown) | description | description, from Atlassian Document Format (best-effort) | description |
121
+ | `status.name` | workflow state | status | status |
122
+ | `status.category` | backlog, unstarted, triage → open; started → in_progress; completed → done; canceled → cancelled | To Do → open, In Progress → in_progress, Done → done; a done status named like cancelled, won't do or rejected → cancelled | open → open, waiting → in_progress, closed → done, cancelled → cancelled |
123
+ | `priority` | 0 none, 1 urgent, 2 high, 3 medium, 4 low | Highest → urgent, High → high, Medium → medium, Low and Lowest → low | low to urgent, no `none` |
124
+ | `assignee` | assignee | assignee | none |
125
+ | `labels` | labels | labels | tags |
126
+ | `container` | team | project, with the issue type | the project |
127
+ | `url` | ✓ | the site's `/browse/<key>` | not yet |
128
+ | `comments` (on `get`) | ✓ | ✓ | from the issue's events |
129
+
130
+ ## What each provider supports
131
+
132
+ | | `linear` | `jira` | `introspection` |
133
+ | ------------ | -------------------------------------------------------------- | ------------------------------------------------------- | -------------------------------------------------------------- |
134
+ | `search` | ✓ | ✓ (JQL) | ✓; text matches the 200 most recent issues; no assignee filter |
135
+ | `get` | ✓ | ✓ | ✓ |
136
+ | `create` | ✓, needs a team | ✓, needs a project and issue type | ✓, on the calling task |
137
+ | `update` | ✓ | ✓ | ✓, no assignee |
138
+ | `comment` | ✓ | ✓ | not yet |
139
+ | `transition` | sets the state; a category picks the team's state of that type | applies the workflow transition that reaches the status | sets `status` |
140
+
141
+ An Introspection comment is an event attached to the issue. The provider reads
142
+ comments from `GET /v1/events?event_name=introspection.issue&issue_id=…`
143
+ (`payload.comment`), and reads none from a data plane that does not record
144
+ that family yet. It does not offer `comment` until the platform accepts one
145
+ on `PATCH /v1/issues/{id}`.
146
+
147
+ ## Tool maps
148
+
149
+ Each MCP adapter calls its server through one tool map
150
+ (`LINEAR_MCP_TOOLS`, `JIRA_MCP_TOOLS`), every entry with `verified: false`
151
+ until it is checked against the server's live tool list
152
+ (`introspection bindings mcp capture`). The adapters' tests run against
153
+ captured-tool-list fixtures in `test/fixtures/issues/`, authored from vendor
154
+ documentation; replace them with captured lists, fix the maps, and set
155
+ `verified: true`.
156
+
157
+ | Provider | Use | Tool | Arguments sent |
158
+ | -------- | -------------------------- | ------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
159
+ | `linear` | search | `list_issues` | `query`, `state`, `assignee`, `team`, `label`, `limit` |
160
+ | `linear` | get | `get_issue`, `list_comments` | `id`; `issueId` |
161
+ | `linear` | create, update, transition | `save_issue` (else `create_issue`, `update_issue`) | `id`, `team`, `title`, `description`, `priority` (0–4), `labels`, `assignee`, `state` |
162
+ | `linear` | comment | `create_comment` | `issueId`, `body` |
163
+ | `linear` | transition by category | `list_issue_statuses` | `team` |
164
+ | `jira` | every call | `getAccessibleAtlassianResources` | none; the first site with Jira scopes gives `cloudId` |
165
+ | `jira` | assignee by name | `lookupJiraAccountId` | `cloudId`, `searchString` |
166
+ | `jira` | search | `searchJiraIssuesUsingJql` | `cloudId`, `jql`, `maxResults`, `fields` |
167
+ | `jira` | get | `getJiraIssue`, `listJiraIssueComments` | `cloudId`, `issueIdOrKey`, `fields` |
168
+ | `jira` | create | `createJiraIssue` | `cloudId`, `projectKey`, `issueTypeName`, `summary`, `description`, `assignee_account_id`, `additional_fields` |
169
+ | `jira` | update | `editJiraIssue` | `cloudId`, `issueIdOrKey`, `fields` |
170
+ | `jira` | comment | `addOrEditJiraIssueComment` (else `addCommentToJiraIssue`) | `cloudId`, `issueIdOrKey`, `commentBody` |
171
+ | `jira` | transition | `listJiraIssueTransitions` (else `getTransitionsForJiraIssue`), `transitionJiraIssue` | `cloudId`, `issueIdOrKey`, `transition: { id }` |
172
+
173
+ ## A provider of your own
174
+
175
+ A provider module is `{ kind: "issues", apiVersion: 1, id, capabilities,
176
+ mcp?, available?, createSession }` (`RecipeIssuesProviderModule`), importing
177
+ only types from `@introspection-ai/recipes/issues`. `capabilities` lists the
178
+ commands it serves, the fields it fills, every host it calls, and the options
179
+ it takes. Its session receives the declaration's options as `config.options`.
180
+ `createSession` returns one method per command; each receives the provider's
181
+ own reference (the handle without its prefix) and, for an MCP provider, a
182
+ caller bound to its server. A failure the model should read throws an
183
+ `Error` carrying `issues: { code, message }`.
@@ -239,6 +239,59 @@ When the local file is absent, manifest-supplied endpoints remain usable.
239
239
  Required servers that need environment-specific bindings fail closed until the
240
240
  local Pi environment or embedding host supplies them.
241
241
 
242
+ ### Bind a provider's API host
243
+
244
+ The vendor APIs a Recipe's own code calls (productivity, search and issues
245
+ providers, channel adapters) are bound by host in `.pi/api.local.json`, the
246
+ counterpart of `.pi/mcp.local.json`: an evaluation sends a host to a fake, and
247
+ a developer to a local or staging server.
248
+
249
+ ```json
250
+ {
251
+ "apis": [
252
+ { "host": "graph.microsoft.com", "url": "http://localhost:7353/microsoft" },
253
+ {
254
+ "host": "www.googleapis.com",
255
+ "url": "https://staging.example.com",
256
+ "headers": { "Authorization": "Bearer ${STAGING_TOKEN}" }
257
+ }
258
+ ]
259
+ }
260
+ ```
261
+
262
+ - **Entry.** `host` is a bare hostname, once per file. `url` is an absolute
263
+ `http(s)` URL, optionally with a path prefix. `headers` are set on every
264
+ request to the host. `${VAR}` in `url` and `headers` is resolved from the
265
+ environment.
266
+ - **Lookup.** An inline `apiBindings` option (`createAgentSession`), then the
267
+ file `PI_RECIPES_API_LOCAL_CONFIG` names, then `<cwd>/.pi/api.local.json`,
268
+ then `<recipeDir>/.pi/api.local.json`. An empty file binds nothing.
269
+ - **Declared hosts only.** A host must be one the session's loaded providers
270
+ and adapters declare: `capabilities.hosts` of the productivity and issues
271
+ providers and the channel adapters (Slack: `slack.com`, `files.slack.com`),
272
+ and `host`/`hosts` of the search providers when the Recipe declares
273
+ `pi.search`. An undeclared host, a host bound twice, a malformed file or a
274
+ `url` that is not absolute fails the session at start.
275
+
276
+ A request to a bound host goes to `url` plus its own path and query:
277
+ `GET https://graph.microsoft.com/v1.0/me` is sent as
278
+ `GET http://localhost:7353/microsoft/v1.0/me`. It carries
279
+ `x-forwarded-host: <host>`, `x-forwarded-proto: https` and, when `url` has a
280
+ path, `x-forwarded-prefix: <that path>`, so a server that builds absolute links
281
+ (a next-page link, an upload session's `Location`) replaces its own scheme,
282
+ host and prefix with `https://<host>` and answers with the vendor's URLs. Its
283
+ `Authorization`, `Proxy-Authorization`, API-key headers and session carriers
284
+ are removed before the entry's headers are set. A bound host needs no egress
285
+ credential lane, so productivity, search and Slack tools run under a local
286
+ Pi against what the file binds.
287
+
288
+ The binding sits in front of `globalThis.fetch` in the Pi process, outside a
289
+ host's managed proxy fetch, so the proxy sees the rewritten URL. Traffic
290
+ outside the Pi process (a Python subprocess, `curl`) is not covered. A session
291
+ created with `createAgentSession` reports what it bound as `apiBindings`
292
+ (`declaredHosts`, and `bound` with each host's `url`). Do not commit a file
293
+ that holds a real endpoint or credential.
294
+
242
295
  ## Use capabilities from an agent
243
296
 
244
297
  In CLI mode, Recipes creates a session-local `mcp` command containing only the
@@ -253,7 +306,18 @@ mcp call contacts.search_contacts --json '{"query":"Ada Lovelace"}'
253
306
  ```
254
307
 
255
308
  The command is headless and cannot add servers, mutate configuration, or start
256
- browser authentication. See [MCP authentication](mcp-auth.md) for OAuth and
309
+ browser authentication.
310
+
311
+ The command's connections run on `@earendil-works/pi-mcp`.
312
+ `PI_RECIPES_MCP_CLIENT=mcporter` keeps them on mcporter's runtime instead, for
313
+ a release or two; so does a session whose config binds a server with an OAuth
314
+ flow, which pi-mcp does not run, or a command run without a session config. The
315
+ command, its arguments, output and exit codes, and `mcp run` scripts are the
316
+ same on either. It keeps one connection per server for
317
+ the daemon's life, sends a request again only when the server never ran it (a
318
+ refused connect answered with a transient status, or an expired MCP session),
319
+ retries reads after a transient failure, never sends a `tools/call` twice, and
320
+ cancels a call on the server when the command is interrupted. See [MCP authentication](mcp-auth.md) for OAuth and
257
321
  hosted binding details, and [Recipes extension](pi-extension.md) for the
258
322
  full session contract.
259
323
 
@@ -251,6 +251,11 @@ A host may synthesize the same bindings in memory.
251
251
  Bindings are resolved fail-closed for required servers. Optional servers may
252
252
  remain unavailable. See [MCP configuration](mcp-configuration.md).
253
253
 
254
+ The vendor API hosts the Recipe's providers and channel adapters call are bound
255
+ the same way, by host, in `.pi/api.local.json` (or the file
256
+ `PI_RECIPES_API_LOCAL_CONFIG` names), at session start before any extension
257
+ loads (see [Bind a provider's API host](mcp-configuration.md#bind-a-providers-api-host)).
258
+
254
259
  ## Recipe-owned extensions
255
260
 
256
261
  TypeScript extension sources declared by `package.json#pi.extensions` are
@@ -54,6 +54,10 @@ tools: [mail, calendar, drive]
54
54
  `@introspection-ai/recipe-productivity-<provider>`. The first two are
55
55
  `microsoft` (Outlook mail, Outlook calendar, OneDrive and SharePoint) and
56
56
  `google` (Gmail, Google Calendar, Google Drive).
57
+ - A provider of the Recipe's own adds `package` (an installed package listed
58
+ in `dependencies`), and any id:
59
+ `{ "provider": "acme-mail", "package": "@acme/recipe-productivity-mail" }`.
60
+ See [providers.md](../providers.md).
57
61
  - `tools` is an optional allowlist per tool, like the channels `commands`
58
62
  list. Omitting a tool exposes all of its supported commands; an empty list
59
63
  exposes none of that tool. Unknown or unsupported commands fail at
@@ -251,7 +255,8 @@ channels:
251
255
  class (which must equal `PRODUCTIVITY_COMMAND_EFFECTS`), its backend
252
256
  (`mcp` or `rest`) and an optional one-sentence `note` the host appends to
253
257
  the command's description. `mail` also says what `label` and `move` act on
254
- (`labels: "labels" | "categories"`, `folders: "folders" | "labels"`);
258
+ (`labels: "labels" | "categories"`, `folders: "folders" | "labels"`), and
259
+ `hosts` lists every host the provider sends to;
255
260
  - `createSession({ config, env, cwd, http })`: returns (or resolves to) a
256
261
  `ProductivitySession` for one person's connection, with a `mail`,
257
262
  `calendar` and `drive` object whose methods serve the enabled commands
@@ -356,5 +361,5 @@ Recipes that call Pipedream's per-app tools (`gmail-find-email`,
356
361
  neutral commands. Most map one to one (`*-find-email` to `mail search`,
357
362
  `*-create-draft*` to `mail draft`, `*-send-email` to a draft plus `mail
358
363
  send`); Pipedream's triggers have no equivalent until triggers are designed.
359
- Recipes that wrap those tools in their own adapters, as Ark's `mail.js`,
360
- `calendar.js` and `drive.js` do, replace each adapter call with one command.
364
+ Recipes that wrap those tools in their own adapters (a `mail.js`,
365
+ `calendar.js` and `drive.js`, say) replace each adapter call with one command.
@@ -0,0 +1,321 @@
1
+ # Provider modules
2
+
3
+ **Status: proposed.** One way for every provider-neutral tool family (search,
4
+ productivity, issues) to take its providers: first-party ones by id, and a
5
+ Recipe's own by package. Adds the `issues` family, served by Linear's
6
+ and Atlassian's MCP servers, or by Introspection's own issues when neither is
7
+ connected.
8
+
9
+ ## 1. Families and providers
10
+
11
+ A **family** is a set of provider-neutral tools that Recipes owns, with one
12
+ versioned contract for the providers behind them:
13
+
14
+ | Family | Tools | First-party providers |
15
+ | --- | --- | --- |
16
+ | `search` | `web_search` | tavily, exa, brave, keenable, parallel, perplexity |
17
+ | `productivity` | `mail`, `calendar`, `drive` | google, microsoft |
18
+ | `issues` | `issues` | linear, jira, introspection |
19
+
20
+ A **provider module** implements one family's contract: `{ kind, apiVersion,
21
+ id, capabilities, … }` plus the family's calls (`search` for search,
22
+ `createSession` for productivity and issues). It imports only types from
23
+ `@introspection-ai/recipes`; the host holds credentials, transports, spans and
24
+ usage. Documents are not a family here: a format is a package and a profile is
25
+ guidance, not a provider.
26
+
27
+ ## 2. Declaring providers
28
+
29
+ Every family is declared the same way, in `package.json#pi`:
30
+
31
+ ```json
32
+ {
33
+ "pi": {
34
+ "issues": [
35
+ { "provider": "linear" },
36
+ { "provider": "acme-tracker", "package": "@acme/recipe-issues-tracker", "options": { "queue": "support" } }
37
+ ],
38
+ "search": [
39
+ { "provider": "brave" },
40
+ { "provider": "acme", "package": "@acme/recipe-search" }
41
+ ],
42
+ "productivity": [
43
+ { "provider": "acme-mail", "package": "@acme/recipe-productivity-mail" }
44
+ ]
45
+ }
46
+ }
47
+ ```
48
+
49
+ A declaration names one provider id and at most one source. A provider is
50
+ always a compiled package resolved from `node_modules`, like any other
51
+ dependency; nothing is loaded from a file in the Recipe at run time.
52
+
53
+ | Source | Resolves to |
54
+ | --- | --- |
55
+ | none | the first-party package: `@introspection-ai/recipe-<family>-<id>`, or the family's bundle (`@introspection-ai/recipe-search`, `@introspection-ai/recipe-issues`) |
56
+ | `package` | an installed package by name, such as `@acme/recipe-search`, which the Recipe lists in `dependencies` with a version, never only as a peer |
57
+
58
+ A provider kept with the Recipe's own code is a local package inside the
59
+ Recipe that it depends on (`"@acme/recipe-search": "file:./providers/search"`,
60
+ or a workspace package), built like any other. Loading or checking fails when the package does not
61
+ resolve from the Recipe's `node_modules`; there is no fallback to a path.
62
+
63
+ Ids are open: any slug, unique within the family, because a handle such as
64
+ `jira:PROJ-45` must route to exactly one provider. A first-party id with a
65
+ `package` replaces the first-party provider. Productivity takes one provider
66
+ per Recipe; search and issues take several.
67
+
68
+ The top level of a declaration holds only what the platform reads: `provider`,
69
+ `package`, a fallback's `enabled` (6) and productivity's `tools` allowlist,
70
+ which the host enforces before any call; any other field is an error. Anything
71
+ the provider itself reads goes in `options`, passed to the provider unchanged
72
+ when it creates a session. Each provider declares the options it takes, by
73
+ name and type, in `capabilities.options`, and a declaration may set only
74
+ those: `introspection check` holds the first-party providers' schemas, and
75
+ loading a Recipe's own provider fails on an option it does not declare.
76
+
77
+ `pi.search` is new. Without it, a Recipe keeps today's behaviour: the providers
78
+ the runtime binds, from `@introspection-ai/recipe-search`.
79
+
80
+ ## 3. Loading and checking
81
+
82
+ One loader serves every family, `loadProviderModules(family, declarations, {
83
+ recipeDir })`, replacing `loadSearchProviders` and the productivity loader. For
84
+ each declaration it imports the module and refuses one whose `kind` is not the
85
+ family, whose `apiVersion` differs from the host's, or whose `id` differs from
86
+ the declaration's. There is no fixed list of ids.
87
+
88
+ `introspection check` loads every declared provider and reports one that does
89
+ not load, a duplicate id, a `package` not in `dependencies`, and an MCP-backed provider (5) whose server the Recipe does not
90
+ bind.
91
+
92
+ ## 4. Credentials
93
+
94
+ A provider module never holds a credential. It sends a placeholder, and the
95
+ egress attaches the real one for the hosts it calls. Each module declares those
96
+ hosts in `capabilities.hosts`, so a provider the platform does not know is still
97
+ explicit about where it sends a member's data:
98
+
99
+ | Provider | Credential |
100
+ | --- | --- |
101
+ | First-party SaaS (Google, Microsoft, Linear, Atlassian) | the platform's integrations and members' own connections |
102
+ | A Recipe's own (`package`) | a project endpoint or connector for its declared hosts |
103
+ | `introspection` | the task's own session against the Introspection API; no third-party key |
104
+
105
+ ## 5. Transports: REST and MCP
106
+
107
+ A provider calls its service over REST, through an MCP server, or both. An
108
+ MCP-backed provider carries an **adapter**: it names the server it adapts (by
109
+ URL) and maps each of the family's commands to one call to that server's tools,
110
+ then parses the result into the family's shape. `web_search` already works this
111
+ way for providers with a hosted MCP server (`SearchMcpAdapter`); the adapter
112
+ becomes part of every family's contract. When the server is bound to the
113
+ runtime, the call goes through it; otherwise through REST if the provider has
114
+ it, else the provider is not offered.
115
+
116
+ ## 6. Choosing a provider at run time
117
+
118
+ The providers a call may name are the declared ones with a working credential
119
+ path: a bound MCP server, a connection, or an endpoint. MCP servers connect
120
+ after the tool is registered, so availability is checked on each call: the
121
+ tool's schema lists every declared provider, and a call to one that is not
122
+ connected fails with `not_connected`, naming `introspection_open` as the way to
123
+ connect it. A call names a provider when several are on offer; a command on an
124
+ existing issue goes to the provider its handle names.
125
+
126
+ A family may have a **fallback**: a provider offered only when no other
127
+ provider of the family is. For issues it is `introspection`, included whenever
128
+ a Recipe declares `pi.issues` without being listed, so a Recipe always has
129
+ somewhere to track work, and the same commands reach Linear or Jira once
130
+ someone connects one. A Recipe excludes it with `{ "provider":
131
+ "introspection", "enabled": false }`.
132
+
133
+ ## 7. The `issues` family
134
+
135
+ One `issues` tool with these commands:
136
+
137
+ | Command | Does |
138
+ | --- | --- |
139
+ | `search` | find issues by text, status, assignee, project or label |
140
+ | `get` | one issue with its comments |
141
+ | `create` | a new issue |
142
+ | `update` | title, description, assignee, labels, priority |
143
+ | `comment` | add a comment |
144
+ | `transition` | move to another status |
145
+
146
+ An Introspection issue is like a task: a row the issues API changes (title,
147
+ status, priority, tags), with immutable values attached to it, its conversation
148
+ (the issue's worker task chat) and its events (history, requests, comments).
149
+ The issues API writes the events for every change through one command writer;
150
+ a comment is one more, never a change to the row, and not a message in the
151
+ issue's chat, which its worker agent would answer.
152
+
153
+ Every issue is returned in one shape, with a provider-scoped handle that every
154
+ later command takes:
155
+
156
+ | Field | Linear | Jira | Introspection (`/v1/issues`) |
157
+ | --- | --- | --- | --- |
158
+ | `handle` | `linear:ENG-123` (identifier) | `jira:PROJ-45` (key) | `introspection:<display index>` |
159
+ | `title` | title | summary | title |
160
+ | `description` (markdown) | description | description, from Atlassian Document Format | description |
161
+ | `status.name` | workflow state | status | status |
162
+ | `status.category` (`open`, `in_progress`, `done`, `cancelled`) | state type: backlog and unstarted → open, started → in_progress, completed → done, canceled → cancelled | status category: To Do → open, In Progress → in_progress, Done → done | open → open, waiting → in_progress, closed → done, cancelled → cancelled |
163
+ | `priority` (`none`, `low`, `medium`, `high`, `urgent`) | 0–4 | Highest → urgent … Lowest → low | the same scale, without `none` |
164
+ | `assignee` | assignee | assignee | none |
165
+ | `labels` | labels | labels | tags |
166
+ | `container` | team | project and issue type | the Recipe's project |
167
+ | `url`, `created_at`, `updated_at` | ✓ | ✓ | ✓ |
168
+
169
+ The providers differ, so each declares the commands and fields it supports in
170
+ `capabilities`, as productivity providers do:
171
+
172
+ - **Comments:** Linear and Jira have them. An Introspection comment is an
173
+ attached event, written like every other change to an issue: `PATCH
174
+ /v1/issues/{id}` with a nested `comment`, which the issue command writer
175
+ records as an `introspection.issue.comment` event.
176
+ The issues API stays CRUD on Postgres and never returns comments; the
177
+ provider reads them straight from the event log
178
+ (`GET /v1/events?event_name=introspection.issue&issue_id=…`, `payload.comment`)
179
+ through the SDK's events client, with no helper of its own. Until the
180
+ platform accepts `comment`, the provider does not offer it. `open_requests`
181
+ are questions put to a person, not comments.
182
+ - **Assignee:** Introspection's issues have an owner (`member_id`), not an
183
+ assignee, so `update` takes no assignee there.
184
+ - **Moving an issue:** `transition` takes a status name or category. Linear
185
+ sets the state, Jira applies the workflow transition that reaches it, and
186
+ Introspection sets `status`.
187
+ - **Where to create:** Linear needs a team and Jira a project and issue type,
188
+ from the declaration's options (`{ "provider": "jira", "options": {
189
+ "project": "OPS", "issueType": "Task" } }`) or the call. Introspection creates in the Recipe's project, on the
190
+ calling task.
191
+
192
+ Introspection issues have no `url` yet, and `/v1/issues` has no text filter, so
193
+ the `introspection` provider's `search` matches text against the most recent
194
+ issues it lists. The `introspection` provider uses the JavaScript SDK
195
+ (`@introspection-sdk/introspection-node`) on the task's own session, not the
196
+ CLI: its issues client for the row and its events client for comments and
197
+ history. It runs in the agent's process, with typed responses and no CLI to
198
+ install.
199
+
200
+ All three ship in one package, `@introspection-ai/recipe-issues`, a companion of
201
+ Recipes like `@introspection-ai/recipe-search`. Nothing about issues loads, and
202
+ no `issues` tool is offered, unless a Recipe declares `pi.issues`; most Recipes
203
+ don't, and the Operator does.
204
+
205
+ | Provider | Transport | Server |
206
+ | --- | --- | --- |
207
+ | `linear` | MCP adapter | Linear's remote MCP server (`mcp.linear.app`) |
208
+ | `jira` | MCP adapter | Atlassian's Rovo MCP server (`mcp.atlassian.com`), its Jira tools |
209
+ | `introspection` | REST | the data plane's `/v1/issues` |
210
+
211
+ Linear and Atlassian are OAuth MCP servers. A declaration names the Recipe's
212
+ MCP server for its provider with the `server` option (default `linear`,
213
+ `atlassian`), since
214
+ a Recipe names its servers freely. An agent asks a person to connect with
215
+ `introspection_open`.
216
+ Each adapter maps commands to the server's tools as its live tool list names
217
+ them (`introspection bindings mcp capture`), not as its documentation does, and
218
+ the adapter's tests run against a captured tool list.
219
+
220
+ ## 8. What changes per family
221
+
222
+ | Family | Change |
223
+ | --- | --- |
224
+ | `search` | the fixed `SEARCH_PROVIDER_IDS` filter goes; `pi.search` is added; `recipe-search` serves the first-party providers through the shared loader |
225
+ | `productivity` | gains the `package` source; loads through the shared loader |
226
+ | `issues` | new: the contract and the tool in Recipes, and `@introspection-ai/recipe-issues` with `linear`, `jira` and `introspection` |
227
+
228
+ The contract version of each family stays separate, so a breaking change to one
229
+ family's contract does not bump another's.
230
+
231
+ ## 9. Decisions
232
+
233
+ - **Providers are compiled packages.** There is no source for a file in the
234
+ Recipe: everything a Recipe uses is built and resolved from `node_modules`,
235
+ and nothing is loaded dynamically.
236
+ - **One declaration per id.** A Recipe does not declare the same id twice.
237
+ Several Jira sites do not need it: Atlassian's server reaches every site the
238
+ person's account can, and the adapter chooses one per call (`container`, or a
239
+ `site` option). If two separate servers or accounts are ever needed, an `id`
240
+ alias on the declaration (`{ "provider": "jira", "id": "jira-eu", "options":
241
+ { "server": "atlassian-eu" } }`, handles `jira-eu:PROJ-1`) adds it
242
+ without changing anything here.
243
+
244
+ ## 10. Wiring a provider
245
+
246
+ What wiring Linear and Jira taught, in the order to do it. Each step names the
247
+ code that does it.
248
+
249
+ 1. **Capture the server's tool list before writing the adapter**
250
+ (`introspection bindings mcp capture <id>`) and commit the tools it calls as
251
+ its fixture ([`linear-tools.json`](../test/fixtures/issues/linear-tools.json)).
252
+ A map written from the vendor's docs named a comment tool Linear does not have.
253
+ 2. **Map each command to the captured names and arguments**, and mark the map
254
+ `verified` only against a capture
255
+ ([`LINEAR_MCP_TOOLS`](../packages/issues/src/linear.ts)). Translate the
256
+ family's words into the vendor's before the call: a status category becomes
257
+ the state types it spans, not a filter applied afterwards.
258
+ 3. **Page by the rules below**, with the package's own helper
259
+ ([`common.ts`](../packages/issues/src/common.ts)).
260
+ 4. **Declare every host and option in `capabilities`** (sections 2 and 4).
261
+ 5. **Test against a fake built from the capture** that refuses an argument the
262
+ schema lacks or a value of the wrong type, including one that pages
263
+ (`fakeServer` and "pages and status categories" in
264
+ [`issues-providers.test.ts`](../test/issues-providers.test.ts)).
265
+ 6. **Record once against real, dummy data** with Polly
266
+ ([`linear.recording.test.ts`](../packages/issues/test/linear.recording.test.ts),
267
+ [`polly.ts`](../test/helpers/polly.ts)). Scope every request to the dummy
268
+ items (a label, a separate calendar, a named folder), let the helper
269
+ anonymize, read the cassette before committing it, and replay it in CI.
270
+
271
+ ### Paging
272
+
273
+ A result that silently stops at the first page is the bug reviews kept finding.
274
+
275
+ - **A read the model treats as complete follows every page:** an issue's
276
+ comments, a thread's messages. Bound it with a page cap; never return the
277
+ first page alone.
278
+ - **A search or list returns up to `limit`** and, when more were available,
279
+ the vendor's cursor as the family's `cursor`, so the model can ask again.
280
+ - **The server's metadata ends a list:** `isLast`, a reported `total`,
281
+ `hasNextPage`. A page shorter than asked ends it only when the server
282
+ reports none of these, since servers cap a page below what was asked.
283
+ - **An offset advances by the rows the server returned,** not by how many
284
+ survived conversion or filtering.
285
+ - **Filtering after the fetch keeps paging** until `limit` matches or the
286
+ pages run out, then cuts to `limit`.
287
+ - **Guard every loop:** stop on an empty page, on a cursor or token equal to
288
+ the last one, and at the page cap.
289
+ - **Each package pages its vendor's way once** (`packages/issues/src/common.ts`,
290
+ Google's `collectPages`, Microsoft's `@odata.nextLink`): use that package's
291
+ helper rather than a new loop, and test each rule above against a fake that
292
+ pages.
293
+
294
+ ### Tool arguments
295
+
296
+ The arguments of a first-party command tool (`mail`, `calendar`, `drive`,
297
+ `channels`) are TypeScript types, and their JSON Schemas are generated from
298
+ them by [ts-json-schema-generator](https://github.com/vega/ts-json-schema-generator).
299
+
300
+ - **One type per command,** `<Tool><Command>Arguments` in the family's
301
+ `arguments.ts` ([`src/productivity/arguments.ts`](../src/productivity/arguments.ts),
302
+ [`src/channels/arguments.ts`](../src/channels/arguments.ts)): `MailDraftArguments`
303
+ is `mail draft`. A field shared by several commands is one type alias, so it
304
+ reaches the model once.
305
+ - **A field's doc comment is its description, and its tags are its limits:**
306
+ `@minLength`, `@maxLength`, `@minimum`, `@maximum`, `@minItems`, `@maxItems`,
307
+ `@default`, and `@asType integer` for a whole number. Every field has a
308
+ description; `test/tool-arguments.test.ts` fails on one without. A word that
309
+ varies by provider is a `{word}` placeholder the tool fills at registration
310
+ (`{folder}`, `{labels}`).
311
+ - **Regenerate with `pnpm schemas`** and commit the `arguments.generated.ts`
312
+ beside the source. CI runs `pnpm schemas:check`, which fails when a
313
+ generated file is stale. Never edit the generated file, and never hand-write
314
+ a TypeBox schema for a tool's arguments.
315
+ - **The tool merges the commands with `commandParameters`**
316
+ ([`src/command-parameters.ts`](../src/command-parameters.ts)): one flat
317
+ object with each field once, and the commands as its `anyOf` for validators
318
+ that read it. Some providers send the model only the flat properties, so
319
+ each command's line in the tool's description starts with a signature
320
+ `commandSignature` derives from its schema, `?` marking an optional field:
321
+ `draft { body, to?, cc?, subject?, reply_to? }: Write a draft…`.