@mcpmesh/sdk 1.4.1 → 2.0.0-beta.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 (242) hide show
  1. package/dist/__tests__/a2a/a2a-bearer.spec.d.ts +2 -0
  2. package/dist/__tests__/a2a/a2a-bearer.spec.d.ts.map +1 -0
  3. package/dist/__tests__/a2a/a2a-bearer.spec.js +58 -0
  4. package/dist/__tests__/a2a/a2a-bearer.spec.js.map +1 -0
  5. package/dist/__tests__/a2a/a2a-client.spec.d.ts +2 -0
  6. package/dist/__tests__/a2a/a2a-client.spec.d.ts.map +1 -0
  7. package/dist/__tests__/a2a/a2a-client.spec.js +334 -0
  8. package/dist/__tests__/a2a/a2a-client.spec.js.map +1 -0
  9. package/dist/__tests__/a2a/a2a-job.spec.d.ts +2 -0
  10. package/dist/__tests__/a2a/a2a-job.spec.d.ts.map +1 -0
  11. package/dist/__tests__/a2a/a2a-job.spec.js +255 -0
  12. package/dist/__tests__/a2a/a2a-job.spec.js.map +1 -0
  13. package/dist/__tests__/a2a/a2a-stream.spec.d.ts +2 -0
  14. package/dist/__tests__/a2a/a2a-stream.spec.d.ts.map +1 -0
  15. package/dist/__tests__/a2a/a2a-stream.spec.js +278 -0
  16. package/dist/__tests__/a2a/a2a-stream.spec.js.map +1 -0
  17. package/dist/__tests__/a2a/agent-a2a-config.spec.d.ts +2 -0
  18. package/dist/__tests__/a2a/agent-a2a-config.spec.d.ts.map +1 -0
  19. package/dist/__tests__/a2a/agent-a2a-config.spec.js +262 -0
  20. package/dist/__tests__/a2a/agent-a2a-config.spec.js.map +1 -0
  21. package/dist/__tests__/a2a/producer/auth-filter.spec.d.ts +2 -0
  22. package/dist/__tests__/a2a/producer/auth-filter.spec.d.ts.map +1 -0
  23. package/dist/__tests__/a2a/producer/auth-filter.spec.js +127 -0
  24. package/dist/__tests__/a2a/producer/auth-filter.spec.js.map +1 -0
  25. package/dist/__tests__/a2a/producer/card-builder.spec.d.ts +2 -0
  26. package/dist/__tests__/a2a/producer/card-builder.spec.d.ts.map +1 -0
  27. package/dist/__tests__/a2a/producer/card-builder.spec.js +113 -0
  28. package/dist/__tests__/a2a/producer/card-builder.spec.js.map +1 -0
  29. package/dist/__tests__/a2a/producer/dispatcher.spec.d.ts +2 -0
  30. package/dist/__tests__/a2a/producer/dispatcher.spec.d.ts.map +1 -0
  31. package/dist/__tests__/a2a/producer/dispatcher.spec.js +850 -0
  32. package/dist/__tests__/a2a/producer/dispatcher.spec.js.map +1 -0
  33. package/dist/__tests__/a2a/producer/mount-surface-push.spec.d.ts +2 -0
  34. package/dist/__tests__/a2a/producer/mount-surface-push.spec.d.ts.map +1 -0
  35. package/dist/__tests__/a2a/producer/mount-surface-push.spec.js +164 -0
  36. package/dist/__tests__/a2a/producer/mount-surface-push.spec.js.map +1 -0
  37. package/dist/__tests__/a2a/producer/mount.spec.d.ts +2 -0
  38. package/dist/__tests__/a2a/producer/mount.spec.d.ts.map +1 -0
  39. package/dist/__tests__/a2a/producer/mount.spec.js +433 -0
  40. package/dist/__tests__/a2a/producer/mount.spec.js.map +1 -0
  41. package/dist/__tests__/a2a/producer/public-url-cache.spec.d.ts +2 -0
  42. package/dist/__tests__/a2a/producer/public-url-cache.spec.d.ts.map +1 -0
  43. package/dist/__tests__/a2a/producer/public-url-cache.spec.js +116 -0
  44. package/dist/__tests__/a2a/producer/public-url-cache.spec.js.map +1 -0
  45. package/dist/__tests__/a2a/producer/sse-emitter.spec.d.ts +2 -0
  46. package/dist/__tests__/a2a/producer/sse-emitter.spec.d.ts.map +1 -0
  47. package/dist/__tests__/a2a/producer/sse-emitter.spec.js +754 -0
  48. package/dist/__tests__/a2a/producer/sse-emitter.spec.js.map +1 -0
  49. package/dist/__tests__/a2a/producer/state-translator.spec.d.ts +2 -0
  50. package/dist/__tests__/a2a/producer/state-translator.spec.d.ts.map +1 -0
  51. package/dist/__tests__/a2a/producer/state-translator.spec.js +124 -0
  52. package/dist/__tests__/a2a/producer/state-translator.spec.js.map +1 -0
  53. package/dist/__tests__/a2a/producer/task-store.spec.d.ts +2 -0
  54. package/dist/__tests__/a2a/producer/task-store.spec.d.ts.map +1 -0
  55. package/dist/__tests__/a2a/producer/task-store.spec.js +180 -0
  56. package/dist/__tests__/a2a/producer/task-store.spec.js.map +1 -0
  57. package/dist/__tests__/agent-add-tool.spec.d.ts +2 -0
  58. package/dist/__tests__/agent-add-tool.spec.d.ts.map +1 -0
  59. package/dist/__tests__/agent-add-tool.spec.js +483 -0
  60. package/dist/__tests__/agent-add-tool.spec.js.map +1 -0
  61. package/dist/__tests__/api-runtime-race.spec.d.ts +2 -0
  62. package/dist/__tests__/api-runtime-race.spec.d.ts.map +1 -0
  63. package/dist/__tests__/api-runtime-race.spec.js +193 -0
  64. package/dist/__tests__/api-runtime-race.spec.js.map +1 -0
  65. package/dist/__tests__/claim-dispatcher.spec.d.ts +2 -0
  66. package/dist/__tests__/claim-dispatcher.spec.d.ts.map +1 -0
  67. package/dist/__tests__/claim-dispatcher.spec.js +408 -0
  68. package/dist/__tests__/claim-dispatcher.spec.js.map +1 -0
  69. package/dist/__tests__/inbound-job-dispatch.spec.d.ts +2 -0
  70. package/dist/__tests__/inbound-job-dispatch.spec.d.ts.map +1 -0
  71. package/dist/__tests__/inbound-job-dispatch.spec.js +185 -0
  72. package/dist/__tests__/inbound-job-dispatch.spec.js.map +1 -0
  73. package/dist/__tests__/job-controller-progress.spec.d.ts +2 -0
  74. package/dist/__tests__/job-controller-progress.spec.d.ts.map +1 -0
  75. package/dist/__tests__/job-controller-progress.spec.js +85 -0
  76. package/dist/__tests__/job-controller-progress.spec.js.map +1 -0
  77. package/dist/__tests__/jobs-cancel-route.spec.d.ts +2 -0
  78. package/dist/__tests__/jobs-cancel-route.spec.d.ts.map +1 -0
  79. package/dist/__tests__/jobs-cancel-route.spec.js +88 -0
  80. package/dist/__tests__/jobs-cancel-route.spec.js.map +1 -0
  81. package/dist/__tests__/llm-agent-stream.test.d.ts +14 -0
  82. package/dist/__tests__/llm-agent-stream.test.d.ts.map +1 -0
  83. package/dist/__tests__/llm-agent-stream.test.js +341 -0
  84. package/dist/__tests__/llm-agent-stream.test.js.map +1 -0
  85. package/dist/__tests__/mesh-job-submitter.spec.d.ts +2 -0
  86. package/dist/__tests__/mesh-job-submitter.spec.d.ts.map +1 -0
  87. package/dist/__tests__/mesh-job-submitter.spec.js +110 -0
  88. package/dist/__tests__/mesh-job-submitter.spec.js.map +1 -0
  89. package/dist/__tests__/proxy-stream.test.d.ts +9 -0
  90. package/dist/__tests__/proxy-stream.test.d.ts.map +1 -0
  91. package/dist/__tests__/proxy-stream.test.js +347 -0
  92. package/dist/__tests__/proxy-stream.test.js.map +1 -0
  93. package/dist/__tests__/resolver-meshjob.spec.d.ts +26 -0
  94. package/dist/__tests__/resolver-meshjob.spec.d.ts.map +1 -0
  95. package/dist/__tests__/resolver-meshjob.spec.js +201 -0
  96. package/dist/__tests__/resolver-meshjob.spec.js.map +1 -0
  97. package/dist/__tests__/schema-verdict-policy.test.d.ts +6 -0
  98. package/dist/__tests__/schema-verdict-policy.test.d.ts.map +1 -0
  99. package/dist/__tests__/schema-verdict-policy.test.js +126 -0
  100. package/dist/__tests__/schema-verdict-policy.test.js.map +1 -0
  101. package/dist/__tests__/sse-stream.test.d.ts +12 -0
  102. package/dist/__tests__/sse-stream.test.d.ts.map +1 -0
  103. package/dist/__tests__/sse-stream.test.js +170 -0
  104. package/dist/__tests__/sse-stream.test.js.map +1 -0
  105. package/dist/a2a/a2a-bearer.d.ts +27 -0
  106. package/dist/a2a/a2a-bearer.d.ts.map +1 -0
  107. package/dist/a2a/a2a-bearer.js +63 -0
  108. package/dist/a2a/a2a-bearer.js.map +1 -0
  109. package/dist/a2a/a2a-client.d.ts +114 -0
  110. package/dist/a2a/a2a-client.d.ts.map +1 -0
  111. package/dist/a2a/a2a-client.js +405 -0
  112. package/dist/a2a/a2a-client.js.map +1 -0
  113. package/dist/a2a/a2a-event.d.ts +25 -0
  114. package/dist/a2a/a2a-event.d.ts.map +1 -0
  115. package/dist/a2a/a2a-event.js +9 -0
  116. package/dist/a2a/a2a-event.js.map +1 -0
  117. package/dist/a2a/a2a-job.d.ts +58 -0
  118. package/dist/a2a/a2a-job.d.ts.map +1 -0
  119. package/dist/a2a/a2a-job.js +264 -0
  120. package/dist/a2a/a2a-job.js.map +1 -0
  121. package/dist/a2a/a2a-stream.d.ts +39 -0
  122. package/dist/a2a/a2a-stream.d.ts.map +1 -0
  123. package/dist/a2a/a2a-stream.js +290 -0
  124. package/dist/a2a/a2a-stream.js.map +1 -0
  125. package/dist/a2a/errors.d.ts +29 -0
  126. package/dist/a2a/errors.d.ts.map +1 -0
  127. package/dist/a2a/errors.js +48 -0
  128. package/dist/a2a/errors.js.map +1 -0
  129. package/dist/a2a/index.d.ts +12 -0
  130. package/dist/a2a/index.d.ts.map +1 -0
  131. package/dist/a2a/index.js +11 -0
  132. package/dist/a2a/index.js.map +1 -0
  133. package/dist/a2a/producer/auth-filter.d.ts +34 -0
  134. package/dist/a2a/producer/auth-filter.d.ts.map +1 -0
  135. package/dist/a2a/producer/auth-filter.js +39 -0
  136. package/dist/a2a/producer/auth-filter.js.map +1 -0
  137. package/dist/a2a/producer/card-builder.d.ts +59 -0
  138. package/dist/a2a/producer/card-builder.d.ts.map +1 -0
  139. package/dist/a2a/producer/card-builder.js +59 -0
  140. package/dist/a2a/producer/card-builder.js.map +1 -0
  141. package/dist/a2a/producer/dispatcher.d.ts +276 -0
  142. package/dist/a2a/producer/dispatcher.d.ts.map +1 -0
  143. package/dist/a2a/producer/dispatcher.js +896 -0
  144. package/dist/a2a/producer/dispatcher.js.map +1 -0
  145. package/dist/a2a/producer/index.d.ts +26 -0
  146. package/dist/a2a/producer/index.d.ts.map +1 -0
  147. package/dist/a2a/producer/index.js +23 -0
  148. package/dist/a2a/producer/index.js.map +1 -0
  149. package/dist/a2a/producer/mount.d.ts +75 -0
  150. package/dist/a2a/producer/mount.d.ts.map +1 -0
  151. package/dist/a2a/producer/mount.js +422 -0
  152. package/dist/a2a/producer/mount.js.map +1 -0
  153. package/dist/a2a/producer/public-url-cache.d.ts +73 -0
  154. package/dist/a2a/producer/public-url-cache.d.ts.map +1 -0
  155. package/dist/a2a/producer/public-url-cache.js +0 -0
  156. package/dist/a2a/producer/public-url-cache.js.map +1 -0
  157. package/dist/a2a/producer/registry.d.ts +138 -0
  158. package/dist/a2a/producer/registry.d.ts.map +1 -0
  159. package/dist/a2a/producer/registry.js +117 -0
  160. package/dist/a2a/producer/registry.js.map +1 -0
  161. package/dist/a2a/producer/sse-emitter.d.ts +85 -0
  162. package/dist/a2a/producer/sse-emitter.d.ts.map +1 -0
  163. package/dist/a2a/producer/sse-emitter.js +405 -0
  164. package/dist/a2a/producer/sse-emitter.js.map +1 -0
  165. package/dist/a2a/producer/state-translator.d.ts +63 -0
  166. package/dist/a2a/producer/state-translator.d.ts.map +1 -0
  167. package/dist/a2a/producer/state-translator.js +108 -0
  168. package/dist/a2a/producer/state-translator.js.map +1 -0
  169. package/dist/a2a/producer/task-store.d.ts +128 -0
  170. package/dist/a2a/producer/task-store.d.ts.map +1 -0
  171. package/dist/a2a/producer/task-store.js +128 -0
  172. package/dist/a2a/producer/task-store.js.map +1 -0
  173. package/dist/agent.d.ts +72 -0
  174. package/dist/agent.d.ts.map +1 -1
  175. package/dist/agent.js +618 -13
  176. package/dist/agent.js.map +1 -1
  177. package/dist/api-runtime.d.ts +25 -0
  178. package/dist/api-runtime.d.ts.map +1 -1
  179. package/dist/api-runtime.js +75 -2
  180. package/dist/api-runtime.js.map +1 -1
  181. package/dist/claim-dispatcher.d.ts +126 -0
  182. package/dist/claim-dispatcher.d.ts.map +1 -0
  183. package/dist/claim-dispatcher.js +478 -0
  184. package/dist/claim-dispatcher.js.map +1 -0
  185. package/dist/express.d.ts.map +1 -1
  186. package/dist/express.js +33 -6
  187. package/dist/express.js.map +1 -1
  188. package/dist/inbound-job-dispatch.d.ts +105 -0
  189. package/dist/inbound-job-dispatch.d.ts.map +1 -0
  190. package/dist/inbound-job-dispatch.js +335 -0
  191. package/dist/inbound-job-dispatch.js.map +1 -0
  192. package/dist/index.d.ts +37 -4
  193. package/dist/index.d.ts.map +1 -1
  194. package/dist/index.js +29 -3
  195. package/dist/index.js.map +1 -1
  196. package/dist/job-context.d.ts +107 -0
  197. package/dist/job-context.d.ts.map +1 -0
  198. package/dist/job-context.js +95 -0
  199. package/dist/job-context.js.map +1 -0
  200. package/dist/jobs-cancel-route.d.ts +36 -0
  201. package/dist/jobs-cancel-route.d.ts.map +1 -0
  202. package/dist/jobs-cancel-route.js +60 -0
  203. package/dist/jobs-cancel-route.js.map +1 -0
  204. package/dist/jobs-helper-tools.d.ts +48 -0
  205. package/dist/jobs-helper-tools.d.ts.map +1 -0
  206. package/dist/jobs-helper-tools.js +133 -0
  207. package/dist/jobs-helper-tools.js.map +1 -0
  208. package/dist/llm-agent.d.ts +62 -53
  209. package/dist/llm-agent.d.ts.map +1 -1
  210. package/dist/llm-agent.js +211 -292
  211. package/dist/llm-agent.js.map +1 -1
  212. package/dist/llm-provider.d.ts +4 -4
  213. package/dist/llm.d.ts +4 -1
  214. package/dist/llm.d.ts.map +1 -1
  215. package/dist/llm.js +7 -17
  216. package/dist/llm.js.map +1 -1
  217. package/dist/mesh-job-submitter.d.ts +83 -0
  218. package/dist/mesh-job-submitter.d.ts.map +1 -0
  219. package/dist/mesh-job-submitter.js +143 -0
  220. package/dist/mesh-job-submitter.js.map +1 -0
  221. package/dist/proxy.d.ts +30 -0
  222. package/dist/proxy.d.ts.map +1 -1
  223. package/dist/proxy.js +351 -1
  224. package/dist/proxy.js.map +1 -1
  225. package/dist/resolver-meshjob.d.ts +170 -0
  226. package/dist/resolver-meshjob.d.ts.map +1 -0
  227. package/dist/resolver-meshjob.js +159 -0
  228. package/dist/resolver-meshjob.js.map +1 -0
  229. package/dist/route.d.ts +4 -0
  230. package/dist/route.d.ts.map +1 -1
  231. package/dist/route.js.map +1 -1
  232. package/dist/schema-normalize.d.ts +62 -0
  233. package/dist/schema-normalize.d.ts.map +1 -0
  234. package/dist/schema-normalize.js +128 -0
  235. package/dist/schema-normalize.js.map +1 -0
  236. package/dist/sse-stream.d.ts +44 -0
  237. package/dist/sse-stream.d.ts.map +1 -0
  238. package/dist/sse-stream.js +173 -0
  239. package/dist/sse-stream.js.map +1 -0
  240. package/dist/types.d.ts +351 -9
  241. package/dist/types.d.ts.map +1 -1
  242. package/package.json +4 -3
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAehD;;;;;;;;GAQG;AACH,MAAM,IAAI,GAAkB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;IAChD,KAAK;IACL,eAAe;IACf,IAAI,EAAE,aAAa;IACnB,GAAG;IACH,WAAW;CACZ,CAAC,CAAC;AAEH,WAAW;AACX,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAE3B,0EAA0E;AAC1E,0EAA0E;AAC1E,2EAA2E;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,qEAAqE;AACrE,kEAAkE;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,uEAAuE;AACvE,wEAAwE;AACxE,8BAA8B;AAC9B,OAAO,EAAE,mBAAmB,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AY,EACZ,cAAc,EACd,yBAAyB,EACzB,kBAAkB,EAClB,yBAAyB,EACzB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,mBAAmB,IAAI,uBAAuB,EAC9C,oBAAoB,IAAI,wBAAwB,EAChD,kBAAkB,IAAI,sBAAsB,EAC5C,mBAAmB,IAAI,uBAAuB,EAC9C,uBAAuB,IAAI,2BAA2B,EACtD,wBAAwB,IAAI,4BAA4B,EACxD,sBAAsB,IAAI,0BAA0B,GAOrD,MAAM,yBAAyB,CAAC;AAqDjC,iCAAiC;AACjC,eAAe,IAAI,CAAC"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * AsyncLocalStorage mirror of the Rust core's `JobContext` (Phase 1 —
3
+ * MeshJob substrate).
4
+ *
5
+ * The Rust core (`mcp_mesh_core::job_context`) holds the source of truth
6
+ * for the active job context — set via `with_job` / `run_as_job` from
7
+ * the inbound HTTP tool wrapper or the claim worker. The Rust outbound
8
+ * paths read it via `injectJobHeaders` to attach
9
+ * `X-Mesh-Job-Id` / `X-Mesh-Timeout` headers to downstream calls.
10
+ *
11
+ * JS user code can also need to read the active job context (e.g. to
12
+ * log the current job id or branch on whether a tool is running under a
13
+ * job). Crossing the FFI boundary on every read is wasteful, AND the
14
+ * Rust task-local does not propagate into the Node event loop across
15
+ * the FFI boundary — so this module exposes an `AsyncLocalStorage`
16
+ * mirror that the inbound wrapper (next dispatch) sets alongside the
17
+ * Rust call.
18
+ *
19
+ * For the current dispatch only the JS surface is defined; the inbound
20
+ * wrapper that populates it lands in the next dispatch. Until then
21
+ * `currentJob()` returns `null` (no active job) — which is the correct
22
+ * answer for any tool invoked via a regular `tools/call` rather than a
23
+ * job-dispatch path.
24
+ *
25
+ * See `MESHJOB_DESIGN.org` → "Timeout & Cancellation" → "Async-local
26
+ * primitives" for the cross-runtime parity (Python `contextvars` ≡
27
+ * TypeScript `AsyncLocalStorage` ≡ Java `ThreadLocal`).
28
+ */
29
+ import { AsyncLocalStorage } from "node:async_hooks";
30
+ /**
31
+ * Read-only snapshot of the active job context for the current async
32
+ * scope. Mirrors the fields of the Rust core's `JobContext` that JS
33
+ * user code can usefully observe. The cancel token itself stays in the
34
+ * Rust core — JS observes its effects via FFI (e.g. an awaited Rust
35
+ * future rejecting with "cancelled") rather than polling it directly.
36
+ */
37
+ export interface JobContextSnapshot {
38
+ /** Server-assigned job UUID this scope is executing for. */
39
+ jobId: string;
40
+ /**
41
+ * Seconds left until the per-attempt deadline expires, or `null` if
42
+ * no deadline is set (unlimited per design-doc default).
43
+ *
44
+ * NB: this snapshot value is captured at the time `withJobAsync`
45
+ * binds the context. It does NOT auto-decrement as wall-clock time
46
+ * passes. For an always-fresh remaining-seconds value, query the
47
+ * Rust core via `currentJob()` from `@mcpmesh/core` instead.
48
+ */
49
+ deadlineSecsRemaining: number | null;
50
+ }
51
+ /**
52
+ * Active `JobContextSnapshot` on the current async scope, or `null`.
53
+ *
54
+ * The inbound HTTP tool wrapper (next dispatch) sets this alongside
55
+ * the Rust core's `withJobAsync` so JS user code can read either side
56
+ * without crossing FFI. When neither side is active, the value is
57
+ * `null`.
58
+ *
59
+ * Exported so the dispatch wrapper (and tests) can call `.run()` /
60
+ * `.exit()` / `.getStore()` directly when finer control than
61
+ * `withJobAsync` is required.
62
+ */
63
+ export declare const CURRENT_JOB: AsyncLocalStorage<JobContextSnapshot | null>;
64
+ /**
65
+ * Return the active job snapshot for the current async scope, or
66
+ * `null`.
67
+ *
68
+ * Safe to call from any context — never throws. Returns `null` outside
69
+ * any active job (e.g. for tools invoked via a regular `tools/call` or
70
+ * in unit tests with no job-dispatch path).
71
+ *
72
+ * Note: The source of truth is the Rust core. This function reads the
73
+ * JS-side mirror for fast in-process access; for cross-FFI parity (and
74
+ * always-fresh `deadlineSecsRemaining`) use `currentJob()` from
75
+ * `@mcpmesh/core`.
76
+ */
77
+ export declare function currentJob(): JobContextSnapshot | null;
78
+ /**
79
+ * Seconds remaining on the active job's deadline, or `null`.
80
+ *
81
+ * Returns `null` if no job is active, or if the active job has no
82
+ * deadline set (unlimited). Returns `0` once the deadline has passed —
83
+ * caller should treat that as "no time left" and abort outbound work.
84
+ *
85
+ * Snapshot semantics (see {@link JobContextSnapshot.deadlineSecsRemaining}):
86
+ * this returns the value captured when the scope was bound, not a
87
+ * live wall-clock countdown.
88
+ */
89
+ export declare function remainingSeconds(): number | null;
90
+ /**
91
+ * Run `fn` inside an `AsyncLocalStorage` scope with `snap` as the
92
+ * active job context.
93
+ *
94
+ * This is the JS-side analogue of the Rust `with_job` task-local
95
+ * binding. The inbound dispatch wrapper (next dispatch) calls BOTH
96
+ * this AND the Rust `withJobAsync` so:
97
+ *
98
+ * - JS user code reading via `currentJob()` sees the snapshot;
99
+ * - Rust-originated work (e.g. `call_tool`, `submit_job`) within
100
+ * the scope sees the Rust task-local for header injection and
101
+ * cancel-registry binding.
102
+ *
103
+ * The two contexts are deliberately set in parallel because the Rust
104
+ * task-local does not cross the FFI boundary into the Node event loop.
105
+ */
106
+ export declare function withJobAsync<T>(snap: JobContextSnapshot, fn: () => Promise<T>): Promise<T>;
107
+ //# sourceMappingURL=job-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job-context.d.ts","sourceRoot":"","sources":["../src/job-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;;;OAQG;IACH,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,WAAW,8CAAqD,CAAC;AAE9E;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,IAAI,kBAAkB,GAAG,IAAI,CAEtD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,IAAI,CAIhD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAClC,IAAI,EAAE,kBAAkB,EACxB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAEZ"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * AsyncLocalStorage mirror of the Rust core's `JobContext` (Phase 1 —
3
+ * MeshJob substrate).
4
+ *
5
+ * The Rust core (`mcp_mesh_core::job_context`) holds the source of truth
6
+ * for the active job context — set via `with_job` / `run_as_job` from
7
+ * the inbound HTTP tool wrapper or the claim worker. The Rust outbound
8
+ * paths read it via `injectJobHeaders` to attach
9
+ * `X-Mesh-Job-Id` / `X-Mesh-Timeout` headers to downstream calls.
10
+ *
11
+ * JS user code can also need to read the active job context (e.g. to
12
+ * log the current job id or branch on whether a tool is running under a
13
+ * job). Crossing the FFI boundary on every read is wasteful, AND the
14
+ * Rust task-local does not propagate into the Node event loop across
15
+ * the FFI boundary — so this module exposes an `AsyncLocalStorage`
16
+ * mirror that the inbound wrapper (next dispatch) sets alongside the
17
+ * Rust call.
18
+ *
19
+ * For the current dispatch only the JS surface is defined; the inbound
20
+ * wrapper that populates it lands in the next dispatch. Until then
21
+ * `currentJob()` returns `null` (no active job) — which is the correct
22
+ * answer for any tool invoked via a regular `tools/call` rather than a
23
+ * job-dispatch path.
24
+ *
25
+ * See `MESHJOB_DESIGN.org` → "Timeout & Cancellation" → "Async-local
26
+ * primitives" for the cross-runtime parity (Python `contextvars` ≡
27
+ * TypeScript `AsyncLocalStorage` ≡ Java `ThreadLocal`).
28
+ */
29
+ import { AsyncLocalStorage } from "node:async_hooks";
30
+ /**
31
+ * Active `JobContextSnapshot` on the current async scope, or `null`.
32
+ *
33
+ * The inbound HTTP tool wrapper (next dispatch) sets this alongside
34
+ * the Rust core's `withJobAsync` so JS user code can read either side
35
+ * without crossing FFI. When neither side is active, the value is
36
+ * `null`.
37
+ *
38
+ * Exported so the dispatch wrapper (and tests) can call `.run()` /
39
+ * `.exit()` / `.getStore()` directly when finer control than
40
+ * `withJobAsync` is required.
41
+ */
42
+ export const CURRENT_JOB = new AsyncLocalStorage();
43
+ /**
44
+ * Return the active job snapshot for the current async scope, or
45
+ * `null`.
46
+ *
47
+ * Safe to call from any context — never throws. Returns `null` outside
48
+ * any active job (e.g. for tools invoked via a regular `tools/call` or
49
+ * in unit tests with no job-dispatch path).
50
+ *
51
+ * Note: The source of truth is the Rust core. This function reads the
52
+ * JS-side mirror for fast in-process access; for cross-FFI parity (and
53
+ * always-fresh `deadlineSecsRemaining`) use `currentJob()` from
54
+ * `@mcpmesh/core`.
55
+ */
56
+ export function currentJob() {
57
+ return CURRENT_JOB.getStore() ?? null;
58
+ }
59
+ /**
60
+ * Seconds remaining on the active job's deadline, or `null`.
61
+ *
62
+ * Returns `null` if no job is active, or if the active job has no
63
+ * deadline set (unlimited). Returns `0` once the deadline has passed —
64
+ * caller should treat that as "no time left" and abort outbound work.
65
+ *
66
+ * Snapshot semantics (see {@link JobContextSnapshot.deadlineSecsRemaining}):
67
+ * this returns the value captured when the scope was bound, not a
68
+ * live wall-clock countdown.
69
+ */
70
+ export function remainingSeconds() {
71
+ const snap = CURRENT_JOB.getStore();
72
+ if (!snap)
73
+ return null;
74
+ return snap.deadlineSecsRemaining;
75
+ }
76
+ /**
77
+ * Run `fn` inside an `AsyncLocalStorage` scope with `snap` as the
78
+ * active job context.
79
+ *
80
+ * This is the JS-side analogue of the Rust `with_job` task-local
81
+ * binding. The inbound dispatch wrapper (next dispatch) calls BOTH
82
+ * this AND the Rust `withJobAsync` so:
83
+ *
84
+ * - JS user code reading via `currentJob()` sees the snapshot;
85
+ * - Rust-originated work (e.g. `call_tool`, `submit_job`) within
86
+ * the scope sees the Rust task-local for header injection and
87
+ * cancel-registry binding.
88
+ *
89
+ * The two contexts are deliberately set in parallel because the Rust
90
+ * task-local does not cross the FFI boundary into the Node event loop.
91
+ */
92
+ export async function withJobAsync(snap, fn) {
93
+ return CURRENT_JOB.run(snap, fn);
94
+ }
95
+ //# sourceMappingURL=job-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job-context.js","sourceRoot":"","sources":["../src/job-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAwBrD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,iBAAiB,EAA6B,CAAC;AAE9E;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,WAAW,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC;AACxC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,IAAI,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAC;IACpC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,OAAO,IAAI,CAAC,qBAAqB,CAAC;AACpC,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAwB,EACxB,EAAoB;IAEpB,OAAO,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Mount the cancel HTTP route on the agent's HTTP server (Phase 1 —
3
+ * MeshJob substrate).
4
+ *
5
+ * Mirrors Python's
6
+ * `_mcp_mesh.pipeline.mcp_startup.jobs_cancel_route.JobsCancelRouteStep`.
7
+ *
8
+ * Per `MESHJOB_DESIGN.org` "Wire Protocol / New endpoints" /
9
+ * "Cancellation": when the registry receives a cancel request for a
10
+ * job whose owner is alive, it forwards the call to the owner
11
+ * replica's `POST /jobs/{job_id}/cancel` HTTP route. That route fires
12
+ * the in-process cancel token registered by the inbound tool wrapper
13
+ * (or the claim worker) so any outbound HTTP calls under the active
14
+ * `with_job_async` scope abort.
15
+ *
16
+ * The route is registered on FastMCP's underlying Hono app. FastMCP
17
+ * exposes the Hono instance via `server.getApp()` after the server has
18
+ * started; calling that BEFORE start would throw. We register at the
19
+ * front of the routes table so the explicit `/jobs/:job_id/cancel`
20
+ * matches before any catch-all FastMCP routes (Hono matches routes in
21
+ * registration order by default, so calling `app.post(...)` after the
22
+ * server starts is sufficient — Hono inserts at the end, but the
23
+ * FastMCP catch-alls only match the configured `endpoint` path which
24
+ * defaults to `/mcp` — there's no overlap).
25
+ */
26
+ import type { FastMCP } from "fastmcp";
27
+ /**
28
+ * Register `POST /jobs/:job_id/cancel` on the FastMCP server's Hono
29
+ * app. Returns `true` iff the route was registered (i.e. the FastMCP
30
+ * server exposes a Hono instance). Logs a warning and returns `false`
31
+ * on any failure — cancel is a best-effort signal; missing the route
32
+ * just means the registry's forward attempt 404s and the cancel
33
+ * falls back to lease-expiry.
34
+ */
35
+ export declare function registerCancelRoute(server: FastMCP): boolean;
36
+ //# sourceMappingURL=jobs-cancel-route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobs-cancel-route.d.ts","sourceRoot":"","sources":["../src/jobs-cancel-route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGvC;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CA0D5D"}
@@ -0,0 +1,60 @@
1
+ import { cancelActiveJob } from "@mcpmesh/core";
2
+ /**
3
+ * Register `POST /jobs/:job_id/cancel` on the FastMCP server's Hono
4
+ * app. Returns `true` iff the route was registered (i.e. the FastMCP
5
+ * server exposes a Hono instance). Logs a warning and returns `false`
6
+ * on any failure — cancel is a best-effort signal; missing the route
7
+ * just means the registry's forward attempt 404s and the cancel
8
+ * falls back to lease-expiry.
9
+ */
10
+ export function registerCancelRoute(server) {
11
+ // Visibility: cancel-mid-flight is a primary control-plane signal for
12
+ // long-running jobs. When registration fails the agent silently
13
+ // degrades to lease-expiry — operators who only watch ERROR-level
14
+ // logs would never see the regression. Emit at console.error and
15
+ // include the underlying reason so the failure mode is debuggable
16
+ // from logs alone.
17
+ let app = null;
18
+ try {
19
+ app = server.getApp();
20
+ }
21
+ catch (err) {
22
+ const reason = err instanceof Error ? err.message : String(err);
23
+ console.error(`[mesh-jobs] cancel route NOT registered — FastMCP.getApp() ` +
24
+ `unavailable: ${reason}. Cancel-mid-flight will silently degrade ` +
25
+ `to lease expiry for any task: true tools on this agent.`);
26
+ return false;
27
+ }
28
+ if (!app) {
29
+ console.error(`[mesh-jobs] cancel route NOT registered — FastMCP.getApp() ` +
30
+ `returned null. Cancel-mid-flight will silently degrade to lease ` +
31
+ `expiry for any task: true tools on this agent.`);
32
+ return false;
33
+ }
34
+ try {
35
+ app.post("/jobs/:job_id/cancel", async (c) => {
36
+ const jobId = c.req.param("job_id");
37
+ let cancelled = false;
38
+ try {
39
+ cancelled = Boolean(cancelActiveJob(jobId));
40
+ }
41
+ catch (err) {
42
+ // The napi binding shouldn't throw under normal conditions;
43
+ // log + report cancelled=false so the registry's forwarder
44
+ // gets a deterministic answer.
45
+ console.warn(`[mesh-jobs] cancelActiveJob napi raised for job=${jobId}:`, err);
46
+ }
47
+ console.log(`[mesh-jobs] cancel route: job_id=${jobId} cancelled=${cancelled}`);
48
+ return c.json({ cancelled, job_id: jobId });
49
+ });
50
+ return true;
51
+ }
52
+ catch (err) {
53
+ const reason = err instanceof Error ? err.message : String(err);
54
+ console.error(`[mesh-jobs] cancel route NOT registered — app.post() raised: ` +
55
+ `${reason}. Cancel-mid-flight will silently degrade to lease ` +
56
+ `expiry for any task: true tools on this agent.`);
57
+ return false;
58
+ }
59
+ }
60
+ //# sourceMappingURL=jobs-cancel-route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job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G,EAC3D,GAAG,CACJ,CAAC;YACJ,CAAC;YACD,OAAO,CAAC,GAAG,CACT,oCAAoC,KAAK,cAAc,SAAS,EAAE,CACnE,CAAC;YACF,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,MAAM,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChE,OAAO,CAAC,KAAK,CACX,+DAA+D;YAC7D,GAAG,MAAM,qDAAqD;YAC9D,gDAAgD,CACnD,CAAC;QACF,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Auto-register the three MeshJob helper tools on every TS mesh agent
3
+ * (Phase 1 — MeshJob substrate).
4
+ *
5
+ * Mirrors Python's
6
+ * `_mcp_mesh.pipeline.mcp_startup.jobs_helper_tools.JobsHelperToolsStep`.
7
+ *
8
+ * Per `MESHJOB_DESIGN.org` "Helper tool placement: auto-registered on
9
+ * every mesh agent": `__mesh_job_status` / `__mesh_job_result` /
10
+ * `__mesh_job_cancel` are framework primitives, exposed on every agent
11
+ * that initialises the mesh runtime — independent of whether that
12
+ * agent owns any `task: true` tools. External MCP clients can call any
13
+ * agent to poll job status; the call lands at the registry, not at any
14
+ * specific owner replica.
15
+ *
16
+ * The helpers are thin wrappers around `JobProxy` from `@mcpmesh/core`
17
+ * (which terminates at the registry's `GET /jobs/{id}` /
18
+ * `POST /jobs/{id}/cancel`). No replica-side caching, no owner-bound
19
+ * routing for reads (per "Status read path" decision in design doc).
20
+ */
21
+ import type { FastMCP } from "fastmcp";
22
+ /**
23
+ * Metadata stamp for the three helper tools — same shape `MeshAgent`
24
+ * builds for user tools, so the Rust core ships them to the registry
25
+ * as regular capabilities under the framework_internal=true tag.
26
+ */
27
+ export interface HelperToolMeta {
28
+ capability: string;
29
+ version: string;
30
+ tags: string[];
31
+ description: string;
32
+ inputSchema: string;
33
+ task: boolean;
34
+ }
35
+ /**
36
+ * Register `__mesh_job_status` / `__mesh_job_result` /
37
+ * `__mesh_job_cancel` on the FastMCP server and return their mesh
38
+ * metadata so the agent can ship them in the heartbeat tool catalog.
39
+ *
40
+ * Skipped if `registryUrl` is empty — without a registry there's
41
+ * nothing for the helpers to read from. Returns an empty metadata map
42
+ * in that case so the caller can still proceed with startup.
43
+ *
44
+ * Idempotent w.r.t. an already-registered tool name (FastMCP throws on
45
+ * duplicate names; we catch + log so a hot-reload doesn't crash).
46
+ */
47
+ export declare function registerJobHelperTools(server: FastMCP, registryUrl: string): Map<string, HelperToolMeta>;
48
+ //# sourceMappingURL=jobs-helper-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobs-helper-tools.d.ts","sourceRoot":"","sources":["../src/jobs-helper-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAoBvC;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,OAAO,EACf,WAAW,EAAE,MAAM,GAClB,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CA6G7B"}
@@ -0,0 +1,133 @@
1
+ import { z } from "zod";
2
+ import { JobProxy } from "@mcpmesh/core";
3
+ const TOOL_NAME_STATUS = "__mesh_job_status";
4
+ const TOOL_NAME_RESULT = "__mesh_job_result";
5
+ const TOOL_NAME_CANCEL = "__mesh_job_cancel";
6
+ const DESCRIPTIONS = {
7
+ [TOOL_NAME_STATUS]: "[Framework] Return the latest mesh-registry state for a job_id. " +
8
+ "Reads terminate at the registry; safe to call from any agent.",
9
+ [TOOL_NAME_RESULT]: "[Framework] Return the terminal result/status/error for a job_id " +
10
+ "via a single registry read.",
11
+ [TOOL_NAME_CANCEL]: "[Framework] Request cancellation for a job_id. The registry " +
12
+ "forwards the signal to the owner replica when alive.",
13
+ };
14
+ /**
15
+ * Register `__mesh_job_status` / `__mesh_job_result` /
16
+ * `__mesh_job_cancel` on the FastMCP server and return their mesh
17
+ * metadata so the agent can ship them in the heartbeat tool catalog.
18
+ *
19
+ * Skipped if `registryUrl` is empty — without a registry there's
20
+ * nothing for the helpers to read from. Returns an empty metadata map
21
+ * in that case so the caller can still proceed with startup.
22
+ *
23
+ * Idempotent w.r.t. an already-registered tool name (FastMCP throws on
24
+ * duplicate names; we catch + log so a hot-reload doesn't crash).
25
+ */
26
+ export function registerJobHelperTools(server, registryUrl) {
27
+ const meta = new Map();
28
+ if (!registryUrl) {
29
+ return meta;
30
+ }
31
+ const inputParams = z.object({
32
+ jobId: z.string().describe("Job UUID returned by submit_job"),
33
+ });
34
+ const cancelParams = z.object({
35
+ jobId: z.string().describe("Job UUID returned by submit_job"),
36
+ reason: z.string().optional().describe("Optional reason string"),
37
+ });
38
+ // We pass JSON-stringified inputSchema downstream just like the user
39
+ // tools do (see agent.ts addTool path).
40
+ const inputSchemaJson = JSON.stringify({
41
+ type: "object",
42
+ properties: {
43
+ jobId: { type: "string", description: "Job UUID returned by submit_job" },
44
+ },
45
+ required: ["jobId"],
46
+ });
47
+ const cancelSchemaJson = JSON.stringify({
48
+ type: "object",
49
+ properties: {
50
+ jobId: { type: "string", description: "Job UUID returned by submit_job" },
51
+ reason: { type: "string", description: "Optional reason string" },
52
+ },
53
+ required: ["jobId"],
54
+ });
55
+ // Status: GET /jobs/{id} via JobProxy.status()
56
+ try {
57
+ server.addTool({
58
+ name: TOOL_NAME_STATUS,
59
+ description: DESCRIPTIONS[TOOL_NAME_STATUS],
60
+ parameters: inputParams,
61
+ execute: async (args) => {
62
+ const proxy = new JobProxy(args.jobId, registryUrl);
63
+ const snapshot = await proxy.status();
64
+ return JSON.stringify(snapshot);
65
+ },
66
+ });
67
+ meta.set(TOOL_NAME_STATUS, {
68
+ capability: TOOL_NAME_STATUS,
69
+ version: "1.0.0",
70
+ tags: ["mesh-jobs", "framework"],
71
+ description: DESCRIPTIONS[TOOL_NAME_STATUS],
72
+ inputSchema: inputSchemaJson,
73
+ task: false,
74
+ });
75
+ }
76
+ catch (err) {
77
+ console.warn(`[mesh-jobs] could not register ${TOOL_NAME_STATUS}:`, err);
78
+ }
79
+ // Result: same wire as status; helper unwraps just the terminal bits.
80
+ try {
81
+ server.addTool({
82
+ name: TOOL_NAME_RESULT,
83
+ description: DESCRIPTIONS[TOOL_NAME_RESULT],
84
+ parameters: inputParams,
85
+ execute: async (args) => {
86
+ const proxy = new JobProxy(args.jobId, registryUrl);
87
+ const snapshot = (await proxy.status());
88
+ return JSON.stringify({
89
+ status: snapshot.status,
90
+ result: snapshot.result,
91
+ error: snapshot.error,
92
+ });
93
+ },
94
+ });
95
+ meta.set(TOOL_NAME_RESULT, {
96
+ capability: TOOL_NAME_RESULT,
97
+ version: "1.0.0",
98
+ tags: ["mesh-jobs", "framework"],
99
+ description: DESCRIPTIONS[TOOL_NAME_RESULT],
100
+ inputSchema: inputSchemaJson,
101
+ task: false,
102
+ });
103
+ }
104
+ catch (err) {
105
+ console.warn(`[mesh-jobs] could not register ${TOOL_NAME_RESULT}:`, err);
106
+ }
107
+ // Cancel: POST /jobs/{id}/cancel via JobProxy.cancel()
108
+ try {
109
+ server.addTool({
110
+ name: TOOL_NAME_CANCEL,
111
+ description: DESCRIPTIONS[TOOL_NAME_CANCEL],
112
+ parameters: cancelParams,
113
+ execute: async (args) => {
114
+ const proxy = new JobProxy(args.jobId, registryUrl);
115
+ await proxy.cancel(args.reason ?? null);
116
+ return JSON.stringify({ ok: true, jobId: args.jobId });
117
+ },
118
+ });
119
+ meta.set(TOOL_NAME_CANCEL, {
120
+ capability: TOOL_NAME_CANCEL,
121
+ version: "1.0.0",
122
+ tags: ["mesh-jobs", "framework"],
123
+ description: DESCRIPTIONS[TOOL_NAME_CANCEL],
124
+ inputSchema: cancelSchemaJson,
125
+ task: false,
126
+ });
127
+ }
128
+ catch (err) {
129
+ console.warn(`[mesh-jobs] could not register ${TOOL_NAME_CANCEL}:`, err);
130
+ }
131
+ return meta;
132
+ }
133
+ //# sourceMappingURL=jobs-helper-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobs-helper-tools.js","sourceRoot":"","sources":["../src/jobs-helper-tools.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AAC7C,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AAC7C,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AAE7C,MAAM,YAAY,GAA2B;IAC3C,CAAC,gBAAgB,CAAC,EAChB,kEAAkE;QAClE,+DAA+D;IACjE,CAAC,gBAAgB,CAAC,EAChB,mEAAmE;QACnE,6BAA6B;IAC/B,CAAC,gBAAgB,CAAC,EAChB,8DAA8D;QAC9D,sDAAsD;CACzD,CAAC;AAgBF;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAe,EACf,WAAmB;IAEnB,MAAM,IAAI,GAAG,IAAI,GAAG,EAA0B,CAAC;IAC/C,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;QAC3B,KAAK,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