@desplega.ai/agent-swarm 2.4.0 → 2.4.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 (222) hide show
  1. package/README.md +1 -1
  2. package/dist/{acp-adapter-kedstxx6.js → acp-adapter-zvzr538d.js} +9 -9
  3. package/dist/{actions-vget6r1k.js → actions-jhtqdw69.js} +21 -21
  4. package/dist/{amp-adapter-xeb5mktv.js → amp-adapter-bd84rhs2.js} +4 -4
  5. package/dist/{app-mqap8t8m.js → app-kreq1gwg.js} +3 -3
  6. package/dist/{assistant-h0gv97mv.js → assistant-3k22sbsq.js} +22 -22
  7. package/dist/{boot-reembed-qr8a894z.js → boot-reembed-e53x6b9v.js} +1 -1
  8. package/dist/{boot-reembed-rj85jjhw.js → boot-reembed-f6z923ny.js} +1 -1
  9. package/dist/{boot-scrub-sweep-eyfvn6v9.js → boot-scrub-sweep-0538vsb7.js} +4 -4
  10. package/dist/{boot-seeds-xs9a8dx1.js → boot-seeds-6wxqkfk2.js} +4 -4
  11. package/dist/{claude-adapter-bm23cye7.js → claude-adapter-gfts5044.js} +9 -9
  12. package/dist/{claude-managed-adapter-1mwrsm9d.js → claude-managed-adapter-h2y889ge.js} +2 -2
  13. package/dist/{claude-managed-setup-gkfgks4j.js → claude-managed-setup-h00hsgtz.js} +2 -2
  14. package/dist/{claude-sdk-session-apb4ypz3.js → claude-sdk-session-56besmfz.js} +13 -13
  15. package/dist/{cli-nrrg0fvy.js → cli-0bh477zn.js} +18 -5
  16. package/dist/{cli-7gh7020n.js → cli-1dmcq2eh.js} +1 -1
  17. package/dist/{cli-7ayprxp7.js → cli-2dfbv8qr.js} +8 -0
  18. package/dist/{cli-1cevz46c.js → cli-3kh4kpqy.js} +6 -6
  19. package/dist/{cli-tg9ksbn8.js → cli-3p8fqcnh.js} +2 -2
  20. package/dist/{cli-x1p5dhq2.js → cli-3r448dqn.js} +3 -3
  21. package/dist/{cli-ecshf504.js → cli-3tnpj2bh.js} +7 -7
  22. package/dist/{cli-ffbrkh1r.js → cli-471qk6s2.js} +46 -38
  23. package/dist/{cli-a49vpbf3.js → cli-5kqnemen.js} +1 -1
  24. package/dist/{cli-zvze9rbm.js → cli-6ncjvx55.js} +3 -3
  25. package/dist/{cli-fb6t92v8.js → cli-6x9ma5w5.js} +1 -1
  26. package/dist/{cli-c8fwpgqb.js → cli-7225gwj7.js} +2 -2
  27. package/dist/{cli-bn26xbcs.js → cli-8nyhf7za.js} +1 -1
  28. package/dist/{cli-y83zk5sb.js → cli-a0kcty51.js} +4 -4
  29. package/dist/{cli-8b9wvjps.js → cli-a4gvwttf.js} +4 -4
  30. package/dist/{cli-jhp7w1fy.js → cli-a5ebc95n.js} +2 -2
  31. package/dist/{cli-mz1ezzzh.js → cli-ash6xxk7.js} +2 -2
  32. package/dist/{cli-rsd7ga7v.js → cli-axh29tyr.js} +11 -11
  33. package/dist/{cli-p22zdvnt.js → cli-bn0rewsy.js} +3 -3
  34. package/dist/{cli-6ftrrwm1.js → cli-bn5kevnf.js} +5 -5
  35. package/dist/{cli-p1m2b6gc.js → cli-d2mb5s8a.js} +7 -7
  36. package/dist/{cli-c5sbmw1v.js → cli-d82btycs.js} +94 -15
  37. package/dist/{cli-vjfpshn3.js → cli-ejs3m1sx.js} +1 -1
  38. package/dist/{cli-a1esmmee.js → cli-fpmsqq59.js} +7 -2
  39. package/dist/{cli-8cxkw1f5.js → cli-fz9kewbh.js} +2 -2
  40. package/dist/{cli-8rwvksbc.js → cli-g0hgtz4p.js} +5 -5
  41. package/dist/{cli-kz116kvw.js → cli-gf0kfg81.js} +7 -7
  42. package/dist/{cli-eqgfs202.js → cli-hqhzg1qq.js} +2 -2
  43. package/dist/{cli-3wjs22x3.js → cli-j4rqdf2n.js} +2 -2
  44. package/dist/{cli-ywyrffff.js → cli-jh0qcrga.js} +1 -1
  45. package/dist/{cli-ttaz6c7m.js → cli-k9z4zd4p.js} +6 -5
  46. package/dist/{cli-nme7wery.js → cli-kmqgmcnb.js} +46 -13
  47. package/dist/{cli-x719j3vs.js → cli-kr2pmfqx.js} +392 -168
  48. package/dist/{cli-wrv09v7q.js → cli-m2qgh5sv.js} +1 -1
  49. package/dist/{cli-xfe63zx3.js → cli-mfe7f7b5.js} +2 -2
  50. package/dist/{cli-x3en6ct3.js → cli-nwyw3zhg.js} +1 -1
  51. package/dist/{cli-5s5hx57y.js → cli-nx462e4v.js} +1 -1
  52. package/dist/{cli-bfc3k1x5.js → cli-p0rakbrk.js} +9 -9
  53. package/dist/{cli-avmqhatn.js → cli-p6argxh9.js} +8 -8
  54. package/dist/{cli-3avfh5az.js → cli-pemywhfq.js} +2 -2
  55. package/dist/{cli-sppc0cmw.js → cli-pnp2j5zg.js} +2 -2
  56. package/dist/{cli-wk8ccrz6.js → cli-pw7v69vp.js} +2 -2
  57. package/dist/{cli-bhwa8rzc.js → cli-rdq7tzwm.js} +13 -12
  58. package/dist/{cli-rg7ntypm.js → cli-rqqsfz30.js} +379 -87
  59. package/dist/{cli-kk2r80n5.js → cli-s48yvzb8.js} +4 -4
  60. package/dist/{cli-zv4vy2b0.js → cli-s95dknxh.js} +1 -1
  61. package/dist/{cli-b80a1100.js → cli-sjyetj21.js} +2 -2
  62. package/dist/{cli-rdr166ht.js → cli-smvcw9z5.js} +1 -1
  63. package/dist/{cli-2rwet3r7.js → cli-sv5gb0yb.js} +1 -1
  64. package/dist/{cli-5ff2sjyt.js → cli-syhq378v.js} +2 -2
  65. package/dist/{cli-tj4j2ts4.js → cli-tbhwrxpt.js} +8 -8
  66. package/dist/{cli-4fhyq711.js → cli-vy0fay6k.js} +13 -13
  67. package/dist/{cli-ptkpaqfy.js → cli-wt645v7q.js} +1 -1
  68. package/dist/{cli-f3nx1h8z.js → cli-wxbn3yfx.js} +2 -2
  69. package/dist/{cli-wyrr38xm.js → cli-x5mq1fyq.js} +1 -1
  70. package/dist/{cli-ccn0eybf.js → cli-xbzvet96.js} +6 -6
  71. package/dist/{cli-4mkvwgzr.js → cli-xf234ws8.js} +1 -1
  72. package/dist/{cli-tgvpmnwz.js → cli-xftrvxag.js} +5 -5
  73. package/dist/{cli-02vhhssk.js → cli-z071fb95.js} +5 -5
  74. package/dist/{cli-mvg2hf8p.js → cli-z1ew8vbq.js} +14 -7
  75. package/dist/{cli-dsgj3e7a.js → cli-zfg9enh9.js} +2 -2
  76. package/dist/{cli-yxqag76b.js → cli-zw88zjba.js} +1 -1
  77. package/dist/cli.js +19 -19
  78. package/dist/{codex-adapter-pp2gq8gr.js → codex-adapter-p6rmm7vv.js} +6 -6
  79. package/dist/{codex-hook-qwzccd64.js → codex-hook-x7nejyrr.js} +7 -4
  80. package/dist/{codex-login-35p4sk85.js → codex-login-m819c41r.js} +1 -1
  81. package/dist/{codex-session-runner-0vzn09t8.js → codex-session-runner-8vd5t9t0.js} +7 -7
  82. package/dist/{commands-psqhkttb.js → commands-7ems2p13.js} +2 -2
  83. package/dist/{controller-t20vz2k8.js → controller-m263fg43.js} +4 -4
  84. package/dist/{controllers-connect-gkxmqw9d.js → controllers-connect-bg33ae53.js} +23 -23
  85. package/dist/{cursor-adapter-3v542qe5.js → cursor-adapter-cz6nm6mj.js} +3 -3
  86. package/dist/{db-2xbyenjr.js → db-w505dwa8.js} +2 -2
  87. package/dist/{db-nc1rd869.js → db-ys2rbdft.js} +3 -3
  88. package/dist/{devin-adapter-7egzmt0k.js → devin-adapter-zgqadvnm.js} +1 -1
  89. package/dist/{dispatcher-ewceb8ts.js → dispatcher-0s0mckqr.js} +20 -20
  90. package/dist/{docker-njavd3fb.js → docker-fkgtr75t.js} +2 -2
  91. package/dist/{dsh-adapter-75xwh78t.js → dsh-adapter-3n3net33.js} +3 -3
  92. package/dist/{e2b-5r6a5jeb.js → e2b-7am6tmq6.js} +2 -2
  93. package/dist/{e2b-pw1nvtmh.js → e2b-thdcxtjd.js} +2 -2
  94. package/dist/{easter-egg-3d-xsc47jwf.js → easter-egg-3d-5cgynaja.js} +1 -1
  95. package/dist/{event-bus-101fenkh.js → event-bus-9vpk8gmq.js} +1 -1
  96. package/dist/{execute-gzmw1mnw.js → execute-t4e6m3rw.js} +1 -1
  97. package/dist/{external-channel-a5dsmxn4.js → external-channel-5b23fv8z.js} +2 -2
  98. package/dist/{grok-adapter-vj88xr23.js → grok-adapter-q9fghe5q.js} +10 -10
  99. package/dist/handlers-mqrym347.js +39 -0
  100. package/dist/{heartbeat-t2m9r3wa.js → heartbeat-tww6yx1w.js} +23 -23
  101. package/dist/{hook-xa677f8r.js → hook-dx0pkvar.js} +16 -9
  102. package/dist/{hook-8femx1bg.js → hook-pvmh9b6m.js} +6 -6
  103. package/dist/{http-xpmmq028.js → http-k2ejbt05.js} +199 -131
  104. package/dist/{index-s7ckdajq.js → index-2z710v4x.js} +10 -10
  105. package/dist/{index-dg2tmj99.js → index-dgz61nff.js} +20 -20
  106. package/dist/{index-syztqdt6.js → index-g6tbb6ve.js} +1 -1
  107. package/dist/index-h2ek08d6.js +40 -0
  108. package/dist/index-pqfwh9nn.js +41 -0
  109. package/dist/{index-cdzyfrsp.js → index-x5aktmp8.js} +1 -1
  110. package/dist/{keepalive-3nr4st3r.js → keepalive-nhvpw10z.js} +4 -4
  111. package/dist/lead-jb6sf69z.js +78 -0
  112. package/dist/{maintenance-verwpe2c.js → maintenance-agakc519.js} +1 -1
  113. package/dist/{oauth-refresh-sweep-9q2t0y3q.js → oauth-refresh-sweep-4dcbhtn0.js} +3 -3
  114. package/dist/{onboard-aytqedmq.js → onboard-4n2kwa4v.js} +3 -3
  115. package/dist/{opencode-adapter-f4hryjny.js → opencode-adapter-3s7ax02e.js} +7 -7
  116. package/dist/{otel-impl-hckw4wt1.js → otel-impl-tfa12080.js} +2 -2
  117. package/dist/{pi-mono-adapter-hxby0ce1.js → pi-mono-adapter-ytp7gz8b.js} +22 -11
  118. package/dist/{pricing-refresh-5nvme3sm.js → pricing-refresh-3cqx3f3x.js} +3 -3
  119. package/dist/{rbac-roles-pd8c26m1.js → rbac-roles-9fae5rnv.js} +1 -1
  120. package/dist/{rbac-roles-vbpy21mg.js → rbac-roles-y6zbfzve.js} +2 -2
  121. package/dist/{render-v2-7nqgvk2q.js → render-v2-emawjvc4.js} +3 -3
  122. package/dist/{resume-b6djcj3c.js → resume-zhgts7h7.js} +10 -8
  123. package/dist/{runtime-txrxc9za.js → runtime-xe3aqy4x.js} +1 -1
  124. package/dist/{session-access-fc3f9y12.js → session-access-cm823e06.js} +4 -4
  125. package/dist/{setup-n39szm6b.js → setup-tkp99w1e.js} +1 -1
  126. package/dist/{virtual-modules-wyp2k6z3.js → virtual-modules-4r3zkc20.js} +2 -2
  127. package/dist/{work-objects-jem2fre0.js → work-objects-f722h263.js} +23 -23
  128. package/dist/worker-p7f336rq.js +78 -0
  129. package/dist/{x-8ewt8gxn.js → x-y45mthwn.js} +2 -2
  130. package/openapi.json +99 -52
  131. package/package.json +2 -2
  132. package/src/apps/action-runner.ts +146 -0
  133. package/src/apps/row-store.ts +4 -2
  134. package/src/apps/script-types.ts +1 -1
  135. package/src/be/db.ts +14 -4
  136. package/src/be/fleet-benchmark-stats.ts +10 -5
  137. package/src/be/models-catalog.ts +4 -0
  138. package/src/be/onboarding.ts +6 -0
  139. package/src/be/scripts/typecheck.ts +13 -0
  140. package/src/be/swarm-config-guard.ts +10 -1
  141. package/src/be/telemetry-enable.ts +1 -1
  142. package/src/commands/provider-credentials.ts +12 -2
  143. package/src/commands/runner.ts +3 -0
  144. package/src/heartbeat/heartbeat.ts +2 -2
  145. package/src/hooks/codex-hook.ts +6 -2
  146. package/src/hooks/hook.ts +7 -0
  147. package/src/hooks/pr-body-guard.ts +38 -11
  148. package/src/hooks/pr-room-guard.ts +88 -0
  149. package/src/http/agents.ts +1 -0
  150. package/src/http/apps.ts +84 -181
  151. package/src/http/fleet-benchmark.ts +79 -30
  152. package/src/http/global-config.ts +7 -0
  153. package/src/http/ranking.ts +24 -40
  154. package/src/http/tasks.ts +2 -1
  155. package/src/http/telemetry-ui.ts +1 -1
  156. package/src/http/used-by.ts +55 -19
  157. package/src/http/users.ts +2 -2
  158. package/src/providers/amp-adapter.ts +1 -1
  159. package/src/providers/pi-mono-adapter.ts +15 -0
  160. package/src/providers/reasoning-effort.ts +2 -1
  161. package/src/providers/types.ts +2 -0
  162. package/src/ranking/telemetry-ranking.ts +5 -33
  163. package/src/scripts-runtime/sdk-allowlist.ts +7 -0
  164. package/src/scripts-runtime/types/stdlib.d.ts +31 -0
  165. package/src/scripts-runtime/types/swarm-sdk.d.ts +31 -0
  166. package/src/server.ts +4 -0
  167. package/src/telemetry-context.ts +19 -1
  168. package/src/telemetry-contract/EVENTS.md +42 -8
  169. package/src/telemetry-contract/SOURCE.json +6 -5
  170. package/src/telemetry-contract/catalog.json +225 -5
  171. package/src/telemetry-contract/ranking/fixtures/valid/no-claim.json +10 -0
  172. package/src/telemetry-contract/ranking/listing.v1.schema.json +2 -2
  173. package/src/telemetry-contract/types.gen.ts +225 -27
  174. package/src/telemetry-identity.ts +47 -9
  175. package/src/telemetry-snapshot.ts +9 -1
  176. package/src/telemetry-ui-events.ts +9 -2
  177. package/src/telemetry.ts +14 -3
  178. package/src/tests/app-action-run-tool.test.ts +178 -0
  179. package/src/tests/app-row-tools.test.ts +360 -0
  180. package/src/tests/check-pr-body.test.ts +0 -23
  181. package/src/tests/credential-check.test.ts +38 -0
  182. package/src/tests/fleet-benchmark.test.ts +122 -2
  183. package/src/tests/http-users.test.ts +62 -1
  184. package/src/tests/model-catalog-table.test.ts +63 -0
  185. package/src/tests/model-profiles-api.test.ts +19 -7
  186. package/src/tests/models-catalog.test.ts +50 -0
  187. package/src/tests/onboarding.test.ts +21 -0
  188. package/src/tests/org-website.test.ts +62 -0
  189. package/src/tests/pi-mono-adapter.test.ts +23 -0
  190. package/src/tests/pr-body-leaks.test.ts +4 -0
  191. package/src/tests/pr-room-guard.test.ts +242 -0
  192. package/src/tests/ranking-listing.test.ts +8 -23
  193. package/src/tests/ranking-route.test.ts +49 -47
  194. package/src/tests/reasoning-effort.test.ts +39 -3
  195. package/src/tests/runner-harness-telemetry-env.test.ts +56 -1
  196. package/src/tests/swarm-tool-result-gate.test.ts +2 -4
  197. package/src/tests/telemetry-context.test.ts +128 -2
  198. package/src/tests/telemetry-ui-route.test.ts +123 -0
  199. package/src/tests/tool-annotations.test.ts +3 -2
  200. package/src/tests/used-by-route.test.ts +144 -10
  201. package/src/tests/workflow-agent-task-retry.test.ts +130 -4
  202. package/src/tests/workflow-wait-recovery.test.ts +116 -4
  203. package/src/tools/app-action-run.ts +63 -0
  204. package/src/tools/app-rows.ts +234 -0
  205. package/src/tools/model-catalog/index.ts +1 -1
  206. package/src/tools/tool-config.ts +8 -0
  207. package/src/tools/utils.ts +1 -1
  208. package/src/tools/workflows/retry-workflow-run.ts +1 -1
  209. package/src/types.ts +17 -0
  210. package/src/utils/company-profile.ts +24 -0
  211. package/src/utils/org-website.ts +58 -21
  212. package/src/workflows/recovery.ts +10 -22
  213. package/src/workflows/resume.ts +16 -0
  214. package/src/workflows/task-step-routing.ts +47 -7
  215. package/templates/skills/apps/SKILL.md +41 -2
  216. package/templates/skills/apps/content.md +41 -2
  217. package/dist/handlers-zbs90bny.js +0 -39
  218. package/dist/index-8pwc1jc8.js +0 -40
  219. package/dist/index-nxa6me0q.js +0 -41
  220. package/dist/lead-td8h2sfn.js +0 -78
  221. package/dist/worker-wr6xgfr2.js +0 -78
  222. package/src/tests/check-ranking-entry.test.ts +0 -146
@@ -332,19 +332,19 @@ import {
332
332
  recordInlineScriptRun2,
333
333
  exports_db,
334
334
  init_db3
335
- } from "./cli-rg7ntypm.js";
335
+ } from "./cli-rqqsfz30.js";
336
336
  import {
337
337
  getUserGrant2,
338
338
  init_rbac_roles
339
- } from "./cli-5s5hx57y.js";
339
+ } from "./cli-nx462e4v.js";
340
340
  import {
341
341
  ensurePricingSeeded2,
342
342
  ensureRbacSeeded2,
343
343
  ensureModelProfilesSeeded2
344
- } from "./cli-kk2r80n5.js";
344
+ } from "./cli-s48yvzb8.js";
345
345
  import {
346
346
  loadModelsDevCache
347
- } from "./cli-tg9ksbn8.js";
347
+ } from "./cli-3p8fqcnh.js";
348
348
  import {
349
349
  buildCatalogEntries,
350
350
  listModelCatalog,
@@ -354,12 +354,12 @@ import {
354
354
  loadModelsCatalog,
355
355
  requestModelCatalogRefresh2,
356
356
  startPricingRefreshLoop2
357
- } from "./cli-ttaz6c7m.js";
357
+ } from "./cli-k9z4zd4p.js";
358
358
  import {
359
359
  ampPinProviderError,
360
360
  ampPinCatalogError,
361
361
  ampModelError
362
- } from "./cli-2rwet3r7.js";
362
+ } from "./cli-sv5gb0yb.js";
363
363
  import {
364
364
  notifyAutomationPreflightFailure,
365
365
  isNeedsSetupFailure,
@@ -397,6 +397,7 @@ import {
397
397
  cancelWorkflowRunRows2,
398
398
  cancelWorkflowRun2,
399
399
  resumeWaitState2,
400
+ recoverResolvedWaitState2,
400
401
  resumeFromChildRun2,
401
402
  initWaitBusSubscriptions2,
402
403
  TriggerSchemaError,
@@ -410,7 +411,7 @@ import {
410
411
  buildNodeInterpolationCtx,
411
412
  interpolateNodeConfig,
412
413
  scriptBodyInterpolationError
413
- } from "./cli-nme7wery.js";
414
+ } from "./cli-kmqgmcnb.js";
414
415
  import {
415
416
  require_dist2,
416
417
  publicEndpointSsrfOptions,
@@ -467,14 +468,14 @@ import {
467
468
  deleteApp,
468
469
  typecheckScript,
469
470
  parseSkillContent
470
- } from "./cli-nrrg0fvy.js";
471
+ } from "./cli-0bh477zn.js";
471
472
  import {
472
473
  buildAuthorizationUrl,
473
474
  onAuthorizationRefreshed,
474
475
  ensureAuthorizationTokenOrThrow,
475
476
  ensureToken,
476
477
  ensureTokenOrThrow
477
- } from "./cli-b80a1100.js";
478
+ } from "./cli-sjyetj21.js";
478
479
  import {
479
480
  detachedProcessGroup,
480
481
  registerProcessGroup,
@@ -504,14 +505,14 @@ import {
504
505
  getSlackApp2,
505
506
  startSlackApp2,
506
507
  stopSlackApp2
507
- } from "./cli-4fhyq711.js";
508
+ } from "./cli-vy0fay6k.js";
508
509
  import {
509
510
  slackCode,
510
511
  slackMissingScopeMessage,
511
512
  withAutoJoin,
512
513
  externalChannelToolError2,
513
514
  getChannelBlockReason2
514
- } from "./cli-xfe63zx3.js";
515
+ } from "./cli-mfe7f7b5.js";
515
516
  import {
516
517
  BaseExecutor,
517
518
  postApprovalCancellationUpdates,
@@ -528,11 +529,11 @@ import {
528
529
  definitionNodeIds,
529
530
  validateDefinition,
530
531
  applyDefinitionPatch
531
- } from "./cli-tj4j2ts4.js";
532
+ } from "./cli-tbhwrxpt.js";
532
533
  import {
533
534
  workflowEventBus2,
534
535
  init_event_bus
535
- } from "./cli-ptkpaqfy.js";
536
+ } from "./cli-wt645v7q.js";
536
537
  import {
537
538
  duplicateGuardedQueryKey,
538
539
  parseQueryParams,
@@ -557,7 +558,7 @@ import {
557
558
  isPublicRoute,
558
559
  findRoute,
559
560
  route
560
- } from "./cli-02vhhssk.js";
561
+ } from "./cli-z071fb95.js";
561
562
  import {
562
563
  isMultiRuntimeEnabled
563
564
  } from "./cli-7a91w22y.js";
@@ -569,7 +570,7 @@ import {
569
570
  import {
570
571
  getRuntimePool2,
571
572
  init_db
572
- } from "./cli-6ftrrwm1.js";
573
+ } from "./cli-bn5kevnf.js";
573
574
  import {
574
575
  getMemoryRaterNames,
575
576
  REFERENCES_SOURCE_MAX_LENGTH,
@@ -580,7 +581,7 @@ import {
580
581
  COMPOSIO_HTTP_METHODS,
581
582
  executeComposioRequest,
582
583
  composioArgsFromParts
583
- } from "./cli-rdr166ht.js";
584
+ } from "./cli-smvcw9z5.js";
584
585
  import {
585
586
  require_fast_deep_equal
586
587
  } from "./cli-bhp11egn.js";
@@ -594,7 +595,7 @@ import {
594
595
  import {
595
596
  canProvisionKind,
596
597
  init_runtime_providers
597
- } from "./cli-wk8ccrz6.js";
598
+ } from "./cli-pw7v69vp.js";
598
599
  import {
599
600
  findUserById,
600
601
  findUserByExternalId,
@@ -610,7 +611,7 @@ import {
610
611
  resolveSessionToken,
611
612
  fingerprintApiKey,
612
613
  init_users
613
- } from "./cli-8cxkw1f5.js";
614
+ } from "./cli-fz9kewbh.js";
614
615
  import {
615
616
  isRbacEnabled,
616
617
  decideAdmission,
@@ -679,7 +680,7 @@ import {
679
680
  KvNamespaceSchema,
680
681
  KvKeySchema,
681
682
  init_types
682
- } from "./cli-a1esmmee.js";
683
+ } from "./cli-fpmsqq59.js";
683
684
  import {
684
685
  generateDefaultClaudeMd2,
685
686
  generateDefaultSoulMd2,
@@ -688,7 +689,7 @@ import {
688
689
  taskAttachmentFetchCommand,
689
690
  taskAttachmentDisplayUrl,
690
691
  init_task_attachment_links
691
- } from "./cli-wyrr38xm.js";
692
+ } from "./cli-x5mq1fyq.js";
692
693
  import {
693
694
  getSlackConfiguration,
694
695
  init_config
@@ -750,7 +751,7 @@ import {
750
751
  import {
751
752
  init_package,
752
753
  package_default
753
- } from "./cli-mz1ezzzh.js";
754
+ } from "./cli-ash6xxk7.js";
754
755
  import {
755
756
  realtimeBus,
756
757
  init_bus
@@ -783,7 +784,7 @@ import {
783
784
  registerVolatileSecret,
784
785
  registerSensitiveKeyName,
785
786
  init_secret_scrubber
786
- } from "./cli-4mkvwgzr.js";
787
+ } from "./cli-xf234ws8.js";
787
788
  import {
788
789
  isAlias,
789
790
  parseAlias,
@@ -797,7 +798,7 @@ import {
797
798
  openAICompatibleProviderIds,
798
799
  claudeCatalogModelId,
799
800
  init_src2
800
- } from "./cli-x3en6ct3.js";
801
+ } from "./cli-nwyw3zhg.js";
801
802
  import {
802
803
  __toESM,
803
804
  __commonJS,
@@ -20252,17 +20253,12 @@ async function recoverWaitStates(registry) {
20252
20253
  let recovered = 0;
20253
20254
  for (const stuck of stuckRuns) {
20254
20255
  try {
20255
- let resumeStatus;
20256
- let payload;
20257
- if (stuck.waitStatus === "fired") {
20258
- resumeStatus = "fired";
20259
- payload = stuck.firedPayload != null ? safeJsonParse(stuck.firedPayload) : undefined;
20260
- } else if (stuck.waitStatus === "timeout") {
20261
- resumeStatus = "timeout";
20256
+ if (stuck.waitStatus === "pending") {
20257
+ const status = stuck.waitMode === "time" ? "fired" : "timeout";
20258
+ await resumeWaitState2(stuck.waitId, status, undefined, registry);
20262
20259
  } else {
20263
- resumeStatus = stuck.waitMode === "time" ? "fired" : "timeout";
20260
+ await recoverResolvedWaitState2(stuck.waitId, registry);
20264
20261
  }
20265
- await resumeWaitState2(stuck.waitId, resumeStatus, payload, registry);
20266
20262
  recovered++;
20267
20263
  } catch (err) {
20268
20264
  if (await failRunOnUnreadableReplay(stuck.runId, err))
@@ -20272,13 +20268,6 @@ async function recoverWaitStates(registry) {
20272
20268
  }
20273
20269
  return recovered;
20274
20270
  }
20275
- function safeJsonParse(s) {
20276
- try {
20277
- return JSON.parse(s);
20278
- } catch {
20279
- return s;
20280
- }
20281
- }
20282
20271
  async function getRunIdsByStatus(status) {
20283
20272
  const rows = await getDbClient2().query("SELECT id FROM workflow_runs WHERE status = ?", [status]);
20284
20273
  return rows.map((r) => r.id);
@@ -21154,7 +21143,7 @@ class NotifyExecutor extends BaseExecutor {
21154
21143
  }
21155
21144
  }
21156
21145
  case "slack": {
21157
- const { getSlackApp } = await import("./app-mqap8t8m.js");
21146
+ const { getSlackApp } = await import("./app-kreq1gwg.js");
21158
21147
  const app = getSlackApp();
21159
21148
  if (!app) {
21160
21149
  return {
@@ -23705,6 +23694,13 @@ var SDK_TOOL_NAME_MAP = {
23705
23694
  app_list: "app-list",
23706
23695
  app_patch: "app-patch",
23707
23696
  app_query: "app-query",
23697
+ app_rows_list: "app-rows-list",
23698
+ app_row_get: "app-row-get",
23699
+ app_row_create: "app-row-create",
23700
+ app_rows_create: "app-rows-create",
23701
+ app_row_patch: "app-row-patch",
23702
+ app_row_delete: "app-row-delete",
23703
+ app_rows_delete: "app-rows-delete",
23708
23704
  app_rollback: "app-rollback",
23709
23705
  app_sync: "app-sync",
23710
23706
  app_upsert: "app-upsert",
@@ -24161,7 +24157,7 @@ var NUDGES = {
24161
24157
  const definition = r.data?.app?.definition;
24162
24158
  const hasQueries = Object.keys(definition?.queries ?? {}).length > 0;
24163
24159
  const hasActions = Object.keys(definition?.actions ?? {}).length > 0;
24164
- return hasQueries || hasActions ? "This app's callable surface is `definition.queries` (run with `app-query`, passing any `$param` values) and `definition.actions` (invoke with `POST /api/apps/<id>/actions/<name>`; `sync` actions refresh sources)." : undefined;
24160
+ return hasQueries || hasActions ? "Run `definition.queries` with `app-query` and supply each `$param` value. Invoke `definition.actions` with `app-action-run` through MCP or `POST /api/apps/<id>/actions/<name>` through REST. Sync actions refresh sources." : undefined;
24165
24161
  },
24166
24162
  "kv-get": (r) => {
24167
24163
  if (!r.ok)
@@ -24509,7 +24505,7 @@ function setPreloadedTools(server, names) {
24509
24505
  async function applyPreToolCall(name, args, requestInfo, inputSchema) {
24510
24506
  if (requestInfo.callOrigin !== "mcp")
24511
24507
  return { args };
24512
- const dispatcher = await import("./dispatcher-ewceb8ts.js");
24508
+ const dispatcher = await import("./dispatcher-0s0mckqr.js");
24513
24509
  const result = await dispatcher.dispatchPre("pre.tool.call", { tool: name, args, requestInfo }, inputSchema ? {
24514
24510
  validateModify: async (data) => {
24515
24511
  const schema = normalizeObjectSchema(inputSchema) ?? inputSchema;
@@ -33822,7 +33818,7 @@ async function notifySlack(text) {
33822
33818
  return;
33823
33819
  }
33824
33820
  try {
33825
- const { getSlackApp } = await import("./app-mqap8t8m.js");
33821
+ const { getSlackApp } = await import("./app-kreq1gwg.js");
33826
33822
  const app = getSlackApp();
33827
33823
  if (!app) {
33828
33824
  console.warn("[Jira webhook keepalive] Slack not available, cannot send notification");
@@ -33893,7 +33889,7 @@ async function deleteJiraWebhook(webhookId) {
33893
33889
  console.log(`[Jira webhook keepalive] Deleted webhook id=${webhookId}`);
33894
33890
  }
33895
33891
  async function overwriteWebhookIds(next) {
33896
- const { getDbClient } = await import("./db-2xbyenjr.js");
33892
+ const { getDbClient } = await import("./db-w505dwa8.js");
33897
33893
  await getDbClient().transaction(async (tx) => {
33898
33894
  const row = await tx.get("SELECT metadata FROM oauth_apps WHERE provider = 'jira'");
33899
33895
  if (!row) {
@@ -107243,7 +107239,7 @@ async function reloadGlobalConfigsAndIntegrations() {
107243
107239
  return runWithoutRequestAuth(() => reloadGlobalConfigsAndIntegrationsInner());
107244
107240
  }
107245
107241
  async function reloadGlobalConfigsAndIntegrationsInner() {
107246
- const { getEmbeddingProvider, resetEmbeddingProvider } = await import("./index-cdzyfrsp.js");
107242
+ const { getEmbeddingProvider, resetEmbeddingProvider } = await import("./index-x5aktmp8.js");
107247
107243
  const wasEmbeddingsConfigured = getEmbeddingProvider().isConfigured();
107248
107244
  const updated = await loadGlobalConfigsIntoEnv(true);
107249
107245
  await syncTelemetryEnabled("settings").catch((err) => {
@@ -107259,10 +107255,10 @@ async function reloadGlobalConfigsAndIntegrationsInner() {
107259
107255
  integrations.push("embeddings");
107260
107256
  }
107261
107257
  if (!wasEmbeddingsConfigured && isEmbeddingsConfigured) {
107262
- import("./boot-reembed-qr8a894z.js").then(({ runBootReembed }) => runBootReembed()).catch((err) => {
107258
+ import("./boot-reembed-e53x6b9v.js").then(({ runBootReembed }) => runBootReembed()).catch((err) => {
107263
107259
  console.error("[config-reload] memory backfill failed (non-fatal):", err);
107264
107260
  });
107265
- import("./boot-reembed-rj85jjhw.js").then(({ runBootReembedScripts }) => runBootReembedScripts()).catch((err) => {
107261
+ import("./boot-reembed-f6z923ny.js").then(({ runBootReembedScripts }) => runBootReembedScripts()).catch((err) => {
107266
107262
  console.error("[config-reload] script backfill failed (non-fatal):", err);
107267
107263
  });
107268
107264
  }
@@ -107797,15 +107793,21 @@ var registerAcceptSteerTool = (server) => {
107797
107793
  }, async (args, info, _meta) => acceptSteerHandler(ownerCtx(info), args));
107798
107794
  };
107799
107795
 
107800
- // src/tools/app-diff.ts
107796
+ // src/tools/app-action-run.ts
107801
107797
  init_zod();
107802
107798
 
107803
- // src/apps/version.ts
107799
+ // src/apps/action-runner.ts
107800
+ init_key();
107804
107801
  init_db3();
107802
+ init_db2();
107803
+ init_resolver();
107804
+ init_secret_scrubber();
107805
107805
 
107806
- // src/apps/schema-migrate.ts
107806
+ // src/apps/sync.ts
107807
107807
  init_zod();
107808
107808
  init_db3();
107809
+ init_db2();
107810
+ init_types();
107809
107811
  init_secret_scrubber();
107810
107812
 
107811
107813
  // src/apps/row-store.ts
@@ -108145,14 +108147,14 @@ async function rebuildAppColumnIndexUnlocked(appId, model, columnName, column, r
108145
108147
  });
108146
108148
  }
108147
108149
  }
108148
- function deleteAppRow(appId, model, _definition, rowId) {
108150
+ function deleteAppRow(appId, model, _definition, rowId, matches) {
108149
108151
  return withMutationLock(appId, model, async () => {
108150
108152
  const currentDefinition = await currentModelDefinition(appId, model);
108151
108153
  if (!currentDefinition)
108152
108154
  return false;
108153
108155
  const namespace = appsNamespace(appId);
108154
108156
  const row = await getAppRow(appId, model, rowId);
108155
- if (!row)
108157
+ if (!row || matches && !matches(row))
108156
108158
  return false;
108157
108159
  for (const key of indexKeys(model, currentDefinition, row))
108158
108160
  await deleteKv2(namespace, key);
@@ -108187,11 +108189,6 @@ function purgeAppRows(appId, models, afterPurge) {
108187
108189
  }
108188
108190
 
108189
108191
  // src/apps/sync.ts
108190
- init_zod();
108191
- init_db3();
108192
- init_db2();
108193
- init_types();
108194
- init_secret_scrubber();
108195
108192
  var MAX_PULL_RECORDS = 500;
108196
108193
  var MAX_PASS_WARNINGS = 20;
108197
108194
  var MAX_TASK_LIMIT = 200;
@@ -108777,7 +108774,176 @@ async function runAppSync(input) {
108777
108774
  return { ok: passes.every((pass) => pass.error === undefined), passes };
108778
108775
  }
108779
108776
 
108777
+ // src/apps/action-runner.ts
108778
+ function syncPassError(sync) {
108779
+ const failed = sync.passes.filter((pass) => pass.error !== undefined);
108780
+ if (failed.length === 0)
108781
+ return;
108782
+ return failed.map((pass) => `${pass.model}.${pass.source}: ${pass.error}`).join("; ");
108783
+ }
108784
+ async function runAppAction({
108785
+ app,
108786
+ name,
108787
+ input = {},
108788
+ caller,
108789
+ actor
108790
+ }) {
108791
+ const actions = app.definition.actions;
108792
+ if (!actions || !Object.hasOwn(actions, name)) {
108793
+ return { status: 404, body: { error: "app action not found" } };
108794
+ }
108795
+ const action = actions[name];
108796
+ if (action.kind === "script") {
108797
+ const script = await getScriptById(action.scriptId);
108798
+ if (!script) {
108799
+ return {
108800
+ status: 400,
108801
+ body: {
108802
+ error: "invalid app action",
108803
+ issues: [
108804
+ {
108805
+ path: `actions.${name}.scriptId`,
108806
+ message: `script "${action.scriptId}" no longer exists`
108807
+ }
108808
+ ]
108809
+ }
108810
+ };
108811
+ }
108812
+ const runAsAgentId = getSavedScriptOwnerAgentId(script);
108813
+ if (!runAsAgentId) {
108814
+ return {
108815
+ status: 400,
108816
+ body: { error: "agentId is required: this script has no owning agent to run as" }
108817
+ };
108818
+ }
108819
+ const output = await runSavedScriptAsAgent({
108820
+ script,
108821
+ input: { ...action.args, ...input, app: { id: app.id }, caller },
108822
+ agentId: runAsAgentId
108823
+ });
108824
+ const ok = output.exitCode === 0 && !output.error && !output.runtimeError;
108825
+ const error = ok ? undefined : output.runtimeError ? `${output.runtimeError.name}: ${output.runtimeError.message}` : output.error ?? `Script exited with code ${output.exitCode}`;
108826
+ return {
108827
+ status: 200,
108828
+ body: scrubObject({
108829
+ ok,
108830
+ result: output.result,
108831
+ stdout: output.stdout,
108832
+ ...error === undefined ? {} : { error },
108833
+ durationMs: output.durationMs
108834
+ })
108835
+ };
108836
+ }
108837
+ if (action.kind === "sync") {
108838
+ const startedAt = Date.now();
108839
+ const sync = await runAppSync({
108840
+ appId: app.id,
108841
+ ...action.model === undefined ? {} : { model: action.model },
108842
+ ...action.source === undefined ? {} : { source: action.source },
108843
+ invokedBy: actor
108844
+ });
108845
+ const durationMs = Date.now() - startedAt;
108846
+ if (sync.issues && sync.issues.length > 0) {
108847
+ return { status: 400, body: { error: "invalid sync action", issues: sync.issues } };
108848
+ }
108849
+ const error = syncPassError(sync);
108850
+ return {
108851
+ status: 200,
108852
+ body: scrubObject({
108853
+ ok: sync.ok,
108854
+ result: { passes: sync.passes },
108855
+ ...error === undefined ? {} : { error },
108856
+ durationMs
108857
+ })
108858
+ };
108859
+ }
108860
+ const lead = action.agentId ? null : await getLeadAgent2();
108861
+ const taskPrompt = resolveTemplate("task.app.action", {
108862
+ prompt: action.prompt,
108863
+ app_id: app.id,
108864
+ action_name: name,
108865
+ input_json: JSON.stringify(input),
108866
+ caller_json: JSON.stringify(caller)
108867
+ });
108868
+ const task = await createTaskWithSiblingAwareness(taskPrompt.text, {
108869
+ source: "api",
108870
+ agentId: action.agentId ?? lead?.id,
108871
+ routingReason: action.agentId ? "human_pinned" : lead ? "skill" : undefined,
108872
+ routingSource: action.agentId || lead ? "engine_default" : undefined,
108873
+ key: normalizeAssetKey(`shared/app:${app.id}/action:${name}/`),
108874
+ ...actor.startsWith("user:") ? { requestedByUserId: actor.slice("user:".length) } : {}
108875
+ }, { origin: "app" });
108876
+ return {
108877
+ status: 200,
108878
+ body: { ok: true, taskId: task.id, status: task.status }
108879
+ };
108880
+ }
108881
+
108882
+ // src/tools/app-action-run.ts
108883
+ init_db3();
108884
+ init_rbac();
108885
+ function registerAppActionRunTool(server) {
108886
+ createToolRegistrar(server)("app-action-run", {
108887
+ title: "Run an app action",
108888
+ description: "Run a declared app action as an agent. Scripts and extensions cannot invoke this tool.",
108889
+ annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
108890
+ rbac: { permission: "app.use" },
108891
+ inputSchema: object2({
108892
+ appId: string2().min(1),
108893
+ action: AppNameSchema,
108894
+ input: record2(string2(), unknown()).optional()
108895
+ }),
108896
+ outputSchema: swarmToolOutputSchema({
108897
+ ok: boolean().optional(),
108898
+ result: unknown().optional(),
108899
+ stdout: string2().optional(),
108900
+ error: string2().optional(),
108901
+ durationMs: number2().optional(),
108902
+ taskId: string2().optional(),
108903
+ status: string2().optional()
108904
+ })
108905
+ }, async ({ appId, action, input }, info) => {
108906
+ if (info.callOrigin === "script-sdk" || info.callOrigin === "extension")
108907
+ return toolErr("Scripts and extensions cannot run app actions.");
108908
+ if (!info.agentId)
108909
+ return toolErr('Agent ID not found. Set the "X-Agent-ID" header.');
108910
+ const agent = await getAgentById2(info.agentId);
108911
+ const decision = can({
108912
+ principal: { kind: "agent", agentId: info.agentId, isLead: agent?.isLead ?? false },
108913
+ verb: "app.use",
108914
+ resource: { kind: "app", appId },
108915
+ source: "mcp"
108916
+ });
108917
+ if (!decision.allow)
108918
+ return toolErr(decision.reason);
108919
+ const app = await getApp(appId);
108920
+ if (!app)
108921
+ return toolErr("App not found.");
108922
+ if (appDefinitionNeedsRepair(app))
108923
+ return toolErr("App definition needs repair.", { data: { issues: app.definitionError } });
108924
+ const output = await runAppAction({
108925
+ app,
108926
+ name: action,
108927
+ input,
108928
+ actor: `agent:${info.agentId}`,
108929
+ caller: { kind: "agent", id: info.agentId, ...agent?.name ? { name: agent.name } : {} }
108930
+ });
108931
+ if (output.status !== 200)
108932
+ return toolErr(output.body.error ?? "Action failed.", { data: output.body });
108933
+ return toolOk("Action invoked.", { data: output.body });
108934
+ });
108935
+ }
108936
+
108937
+ // src/tools/app-diff.ts
108938
+ init_zod();
108939
+
108940
+ // src/apps/version.ts
108941
+ init_db3();
108942
+
108780
108943
  // src/apps/schema-migrate.ts
108944
+ init_zod();
108945
+ init_db3();
108946
+ init_secret_scrubber();
108781
108947
  var MigrationValueSchema = union2([string2(), number2(), boolean()]);
108782
108948
  var AppMigrationDirectiveSchema = union2([
108783
108949
  object2({ set: MigrationValueSchema }).strict(),
@@ -109873,10 +110039,7 @@ async function upsertAppUserConfigValues(appId, scope, values) {
109873
110039
  }
109874
110040
 
109875
110041
  // src/http/apps.ts
109876
- init_key();
109877
110042
  init_db3();
109878
- init_db2();
109879
- init_resolver();
109880
110043
  init_rbac();
109881
110044
  init_types();
109882
110045
  init_request_auth_context();
@@ -110419,12 +110582,6 @@ function definitionNeedsRepair(res, app) {
110419
110582
  json(res, { error: "definition needs repair", issues: app.definitionError }, 409);
110420
110583
  return true;
110421
110584
  }
110422
- function syncPassError(sync) {
110423
- const failed = sync.passes.filter((pass) => pass.error !== undefined);
110424
- if (failed.length === 0)
110425
- return;
110426
- return failed.map((pass) => `${pass.model}.${pass.source}: ${pass.error}`).join("; ");
110427
- }
110428
110585
  function snapshotFailure(res) {
110429
110586
  jsonError(res, "failed to snapshot app", 500);
110430
110587
  }
@@ -110595,6 +110752,9 @@ function compareValues(left, right, direction, dateValues = false) {
110595
110752
  function rowValue(row, column) {
110596
110753
  return Object.hasOwn(row, column) ? row[column] : undefined;
110597
110754
  }
110755
+ function rowMatchesFilters(row, filters) {
110756
+ return filters.every((filter) => rowValue(row, filter.column) === filter.value);
110757
+ }
110598
110758
  function applyQuery(rows, query, model, params = {}, queryName = "<unnamed>") {
110599
110759
  const filters = resolveQueryFilters(query, model, params, queryName);
110600
110760
  let selected = rows.filter((row) => filters.every(([column, value]) => rowValue(row, column) === value));
@@ -110607,6 +110767,23 @@ function applyQuery(rows, query, model, params = {}, queryName = "<unnamed>") {
110607
110767
  }
110608
110768
  return selected.slice(0, query.limit ?? 200);
110609
110769
  }
110770
+ async function selectAppRows(appId, modelName, model, filters, sortRaw, limit = 200, systemColumns = false) {
110771
+ const rows = (await listAppRows(appId, modelName, filters.flatMap((filter) => typeof filter.value === "string" || typeof filter.value === "number" || typeof filter.value === "boolean" ? [{ column: filter.column, value: filter.value }] : []))).filter((row) => rowMatchesFilters(row, filters));
110772
+ if (sortRaw) {
110773
+ const [column, dir, extra] = sortRaw.split(":");
110774
+ if (extra !== undefined || !column || dir !== "asc" && dir !== "desc" || !SORTABLE_SYSTEM_DATE_COLUMNS.has(column) && !(systemColumns && Object.hasOwn(SYSTEM_COLUMN_KINDS, column)) && (!Object.hasOwn(model.columns, column) || model.columns[column].hidden === true)) {
110775
+ throw new AppRowValidationError([
110776
+ { path: "sort", message: "must be <column>:<asc|desc> for a known column" }
110777
+ ]);
110778
+ }
110779
+ rows.sort((a, b) => {
110780
+ const result = compareValues(rowValue(a, column), rowValue(b, column), dir, SORTABLE_SYSTEM_DATE_COLUMNS.has(column) || Object.hasOwn(model.columns, column) && model.columns[column].kind === "date");
110781
+ return result;
110782
+ });
110783
+ }
110784
+ const total = rows.length;
110785
+ return { rows: rows.slice(0, limit), total };
110786
+ }
110610
110787
  async function handleApps(req, res, pathSegments, queryParams, myAgentId) {
110611
110788
  if (createAppRoute.match(req.method, pathSegments)) {
110612
110789
  if (enforceContentLengthCap(req, res, MAX_APP_BODY_BYTES) === BODY_TOO_LARGE)
@@ -110769,24 +110946,13 @@ async function handleApps(req, res, pathSegments, queryParams, myAgentId) {
110769
110946
  json(res, { error: "invalid row query", issues }, 400);
110770
110947
  return true;
110771
110948
  }
110772
- const rows = (await listAppRows(parsed.params.id, parsed.params.model, filters.flatMap((filter) => typeof filter.value === "string" || typeof filter.value === "number" || typeof filter.value === "boolean" ? [{ column: filter.column, value: filter.value }] : []))).filter((row) => filters.every((filter) => rowValue(row, filter.column) === filter.value));
110773
- const sortRaw = parsed.query.sort;
110774
- if (sortRaw) {
110775
- const [column, dir, extra] = sortRaw.split(":");
110776
- if (extra !== undefined || !column || dir !== "asc" && dir !== "desc" || !SORTABLE_SYSTEM_DATE_COLUMNS.has(column) && (!Object.hasOwn(resolved.model.columns, column) || resolved.model.columns[column].hidden === true)) {
110777
- json(res, {
110778
- error: "invalid sort",
110779
- issues: [{ path: "sort", message: "must be <column>:<asc|desc> for a known column" }]
110780
- }, 400);
110781
- return true;
110782
- }
110783
- rows.sort((a, b) => {
110784
- const result = compareValues(rowValue(a, column), rowValue(b, column), dir, SORTABLE_SYSTEM_DATE_COLUMNS.has(column) || Object.hasOwn(resolved.model.columns, column) && resolved.model.columns[column].kind === "date");
110785
- return result;
110786
- });
110949
+ try {
110950
+ listRowsRoute.respond(res, 200, await selectAppRows(parsed.params.id, parsed.params.model, resolved.model, filters, parsed.query.sort, parsed.query.limit));
110951
+ } catch (error) {
110952
+ if (!(error instanceof AppRowValidationError))
110953
+ throw error;
110954
+ json(res, { error: "invalid sort", issues: error.issues }, 400);
110787
110955
  }
110788
- const total = rows.length;
110789
- listRowsRoute.respond(res, 200, { rows: rows.slice(0, parsed.query.limit ?? 200), total });
110790
110956
  return true;
110791
110957
  }
110792
110958
  if (getRowRoute.match(req.method, pathSegments)) {
@@ -110897,87 +111063,17 @@ async function handleApps(req, res, pathSegments, queryParams, myAgentId) {
110897
111063
  }
110898
111064
  if (definitionNeedsRepair(res, app))
110899
111065
  return true;
110900
- const actions = app.definition.actions;
110901
- if (!actions || !Object.hasOwn(actions, parsed.params.name)) {
110902
- jsonError(res, "app action not found", 404);
110903
- return true;
110904
- }
110905
- const action = actions[parsed.params.name];
110906
- const input = parsed.body.input ?? {};
110907
- if (action.kind === "script") {
110908
- const script = await getScriptById(action.scriptId);
110909
- if (!script) {
110910
- json(res, {
110911
- error: "invalid app action",
110912
- issues: [
110913
- {
110914
- path: `actions.${parsed.params.name}.scriptId`,
110915
- message: `script "${action.scriptId}" no longer exists`
110916
- }
110917
- ]
110918
- }, 400);
110919
- return true;
110920
- }
110921
- const runAsAgentId = getSavedScriptOwnerAgentId(script);
110922
- if (!runAsAgentId) {
110923
- jsonError(res, "agentId is required: this script has no owning agent to run as", 400);
110924
- return true;
110925
- }
110926
- const output = await runSavedScriptAsAgent({
110927
- script,
110928
- input: { ...action.args, ...input, app: { id: app.id }, caller },
110929
- agentId: runAsAgentId
110930
- });
110931
- const ok = output.exitCode === 0 && !output.error && !output.runtimeError;
110932
- const error = ok ? undefined : output.runtimeError ? `${output.runtimeError.name}: ${output.runtimeError.message}` : output.error ?? `Script exited with code ${output.exitCode}`;
110933
- runActionRoute.respond(res, 200, scrubObject({
110934
- ok,
110935
- result: output.result,
110936
- stdout: output.stdout,
110937
- ...error === undefined ? {} : { error },
110938
- durationMs: output.durationMs
110939
- }));
110940
- return true;
110941
- }
110942
- if (action.kind === "sync") {
110943
- const startedAt = Date.now();
110944
- const sync = await runAppSync({
110945
- appId: app.id,
110946
- ...action.model === undefined ? {} : { model: action.model },
110947
- ...action.source === undefined ? {} : { source: action.source },
110948
- invokedBy: actor
110949
- });
110950
- const durationMs = Date.now() - startedAt;
110951
- if (sync.issues && sync.issues.length > 0) {
110952
- json(res, { error: "invalid sync action", issues: sync.issues }, 400);
110953
- return true;
110954
- }
110955
- const error = syncPassError(sync);
110956
- runActionRoute.respond(res, 200, scrubObject({
110957
- ok: sync.ok,
110958
- result: { passes: sync.passes },
110959
- ...error === undefined ? {} : { error },
110960
- durationMs
110961
- }));
110962
- return true;
110963
- }
110964
- const lead = action.agentId ? null : await getLeadAgent2();
110965
- const taskPrompt = resolveTemplate("task.app.action", {
110966
- prompt: action.prompt,
110967
- app_id: app.id,
110968
- action_name: parsed.params.name,
110969
- input_json: JSON.stringify(input),
110970
- caller_json: JSON.stringify(caller)
111066
+ const output = await runAppAction({
111067
+ app,
111068
+ name: parsed.params.name,
111069
+ input: parsed.body.input,
111070
+ caller,
111071
+ actor
110971
111072
  });
110972
- const task = await createTaskWithSiblingAwareness(taskPrompt.text, {
110973
- source: "api",
110974
- agentId: action.agentId ?? lead?.id,
110975
- routingReason: action.agentId ? "human_pinned" : lead ? "skill" : undefined,
110976
- routingSource: action.agentId || lead ? "engine_default" : undefined,
110977
- key: normalizeAssetKey(`shared/app:${app.id}/action:${parsed.params.name}/`),
110978
- ...actor.startsWith("user:") ? { requestedByUserId: actor.slice("user:".length) } : {}
110979
- }, { origin: "app" });
110980
- runActionRoute.respond(res, 200, { ok: true, taskId: task.id, status: task.status });
111073
+ if (output.status === 200)
111074
+ runActionRoute.respond(res, 200, output.body);
111075
+ else
111076
+ json(res, output.body, output.status);
110981
111077
  return true;
110982
111078
  }
110983
111079
  if (syncAppRoute.match(req.method, pathSegments)) {
@@ -111720,6 +111816,132 @@ var registerAppRollbackTool = (server) => {
111720
111816
  });
111721
111817
  };
111722
111818
 
111819
+ // src/tools/app-rows.ts
111820
+ init_zod();
111821
+ init_db3();
111822
+ init_rbac();
111823
+ var base = { appId: string2().min(1), model: AppNameSchema };
111824
+ var rowId = string2().min(1);
111825
+ var values = record2(string2(), unknown());
111826
+ var equals = record2(string2(), union2([string2(), number2(), boolean()]));
111827
+ var limit = number2().int().min(1).max(1000);
111828
+ var rowOutput = { row: looseObject({}).optional() };
111829
+ var rowsOutput = { rows: array2(looseObject({})).optional() };
111830
+ function checkSize(value, max) {
111831
+ if (Buffer.byteLength(JSON.stringify(value), "utf8") > max) {
111832
+ throw new AppRowValidationError([
111833
+ { path: "values", message: `Row input exceeds ${max} bytes.` }
111834
+ ]);
111835
+ }
111836
+ }
111837
+ function rowFilters(model, equals = {}) {
111838
+ return Object.entries(equals).map(([column, value]) => {
111839
+ const declared = Object.hasOwn(model.columns, column) ? model.columns[column] : undefined;
111840
+ if (!declared && !Object.hasOwn(SYSTEM_COLUMN_KINDS, column) || declared?.hidden) {
111841
+ throw new AppRowValidationError([
111842
+ { path: `equals.${column}`, message: "Unknown or hidden column." }
111843
+ ]);
111844
+ }
111845
+ if (!validValue(declared ?? { kind: SYSTEM_COLUMN_KINDS[column] }, value)) {
111846
+ throw new AppRowValidationError([
111847
+ { path: `equals.${column}`, message: "Filter value must match the column kind." }
111848
+ ]);
111849
+ }
111850
+ return { column, value };
111851
+ });
111852
+ }
111853
+ function registerAppRowTools(server) {
111854
+ function register(name, description, shape, output, operation, readOnly = false) {
111855
+ createToolRegistrar(server)(name, {
111856
+ title: description,
111857
+ description,
111858
+ annotations: { readOnlyHint: readOnly },
111859
+ rbac: { permission: "app.use" },
111860
+ inputSchema: object2({ ...base, ...shape }),
111861
+ outputSchema: swarmToolOutputSchema(output)
111862
+ }, async (args, info) => {
111863
+ if (!info.agentId)
111864
+ return toolErr('Agent ID not found. Set the "X-Agent-ID" header.');
111865
+ const { appId, model: modelName } = object2(base).parse(args);
111866
+ const agent = await getAgentById2(info.agentId);
111867
+ const decision = can({
111868
+ principal: { kind: "agent", agentId: info.agentId, isLead: agent?.isLead ?? false },
111869
+ verb: "app.use",
111870
+ resource: { kind: "app", appId },
111871
+ source: "mcp"
111872
+ });
111873
+ if (!decision.allow)
111874
+ return toolErr(decision.reason);
111875
+ const app = await getApp(appId);
111876
+ if (!app)
111877
+ return toolErr("App not found.");
111878
+ if (appDefinitionNeedsRepair(app))
111879
+ return toolErr("App definition needs repair.", { data: { issues: app.definitionError } });
111880
+ if (!Object.hasOwn(app.definition.models, modelName))
111881
+ return toolErr("Model not found.");
111882
+ try {
111883
+ return await operation(args, app.definition.models[modelName], `agent:${info.agentId}`);
111884
+ } catch (error) {
111885
+ if (error instanceof AppRowValidationError)
111886
+ return toolErr(error.message, { data: { issues: error.issues } });
111887
+ if (error instanceof AppRowAppNotFoundError)
111888
+ return toolErr(error.message);
111889
+ throw error;
111890
+ }
111891
+ });
111892
+ }
111893
+ register("app-rows-list", "List app rows with equality filters, sorting, and a limit.", {
111894
+ equals: equals.optional(),
111895
+ sort: string2().optional(),
111896
+ limit: limit.optional()
111897
+ }, { ...rowsOutput, total: number2().optional() }, async (args, model) => {
111898
+ const data = await selectAppRows(args.appId, args.model, model, rowFilters(model, args.equals), args.sort, args.limit, true);
111899
+ return toolOk(`Found ${data.total} row(s).`, { data });
111900
+ }, true);
111901
+ register("app-row-get", "Get an app row.", { rowId }, rowOutput, async (args) => {
111902
+ const row = await getAppRow(args.appId, args.model, args.rowId);
111903
+ return row ? toolOk("Row retrieved.", { data: { row } }) : toolErr("Row not found.");
111904
+ }, true);
111905
+ register("app-row-create", "Create an app row.", { values }, rowOutput, async (args, model, actor) => {
111906
+ checkSize({ values: args.values }, MAX_APP_ROW_BODY_BYTES);
111907
+ const row = await createAppRow(args.appId, args.model, model, args.values, { actor });
111908
+ return toolOk("Row created.", { data: { row } });
111909
+ });
111910
+ register("app-rows-create", "Create up to 500 app rows within 10 MiB.", {
111911
+ rows: array2(values).min(1).max(500)
111912
+ }, rowsOutput, async (args, model, actor) => {
111913
+ checkSize({ rows: args.rows }, MAX_APP_BULK_ROWS_BODY_BYTES);
111914
+ for (const values of args.rows)
111915
+ checkSize({ values }, MAX_APP_ROW_BODY_BYTES);
111916
+ const rows = await createAppRows(args.appId, args.model, model, args.rows, { actor });
111917
+ return toolOk(`Created ${rows.length} row(s).`, { data: { rows } });
111918
+ });
111919
+ register("app-row-patch", "Patch an app row.", { rowId, values }, rowOutput, async (args, model, actor) => {
111920
+ checkSize({ values: args.values }, MAX_APP_ROW_BODY_BYTES);
111921
+ const row = await patchAppRow(args.appId, args.model, model, args.rowId, args.values, {
111922
+ actor
111923
+ });
111924
+ return row ? toolOk("Row updated.", { data: { row } }) : toolErr("Row not found.");
111925
+ });
111926
+ register("app-row-delete", "Delete an app row.", { rowId }, { ok: boolean().optional() }, async (args, model) => {
111927
+ const deleted = await deleteAppRow(args.appId, args.model, model, args.rowId);
111928
+ return deleted ? toolOk("Row deleted.", { data: { ok: true } }) : toolErr("Row not found.");
111929
+ });
111930
+ register("app-rows-delete", "Delete matching app rows. Supply at least one equality filter.", {
111931
+ equals: equals.refine((value) => Object.keys(value).length > 0, "Supply at least one equality filter."),
111932
+ limit: limit.optional()
111933
+ }, { deleted: number2().optional() }, async (args, model) => {
111934
+ const filters = rowFilters(model, args.equals);
111935
+ const { rows } = await selectAppRows(args.appId, args.model, model, filters, undefined, args.limit ?? 1000, true);
111936
+ const matches = (row) => rowMatchesFilters(row, filters);
111937
+ let deleted = 0;
111938
+ for (const row of rows)
111939
+ if (await deleteAppRow(args.appId, args.model, model, row.id, matches))
111940
+ deleted++;
111941
+ return toolOk(`Deleted ${deleted} row(s).`, { data: { deleted } });
111942
+ });
111943
+ }
111944
+
111723
111945
  // src/tools/app-sync.ts
111724
111946
  init_zod();
111725
111947
  init_db3();
@@ -118952,7 +119174,7 @@ var registerModelCatalogOverlayUpsertTool = (server) => {
118952
119174
  description: "Add or update hand-verified facts for one model (e.g. a launch models.dev has not listed yet). Overlay fields win over models.dev; overlay prices fill pricing-table gaps so cost recompute prices the model. The row auto-expires once models.dev matches every fact you set.",
118953
119175
  annotations: { idempotentHint: true },
118954
119176
  inputSchema: object2({
118955
- provider: string2().min(1).describe(`models.dev provider id: anthropic, openai, openrouter, amazon-bedrock, opencode, ${openAICompatibleProviderIds().join(", ")}.`),
119177
+ provider: string2().min(1).describe(`models.dev provider id: anthropic, openai, openrouter, amazon-bedrock, opencode, opencode-go, ${openAICompatibleProviderIds().join(", ")}.`),
118956
119178
  modelId: string2().min(1).describe("Model id as models.dev keys it (e.g. claude-opus-5-5)."),
118957
119179
  name: string2().optional().describe("Display name."),
118958
119180
  releaseDate: string2().optional().describe("Release date, YYYY-MM-DD."),
@@ -121700,7 +121922,7 @@ var varStorage = _localStorage;
121700
121922
 
121701
121923
  // node_modules/lib0/trait/equality.js
121702
121924
  var EqualityTraitSymbol = Symbol("Equality");
121703
- var equals = (a, b) => a === b || !!a?.[EqualityTraitSymbol]?.(b) || false;
121925
+ var equals2 = (a, b) => a === b || !!a?.[EqualityTraitSymbol]?.(b) || false;
121704
121926
 
121705
121927
  // node_modules/lib0/object.js
121706
121928
  var assign = Object.assign;
@@ -121726,7 +121948,7 @@ var every = (obj, f) => {
121726
121948
  return true;
121727
121949
  };
121728
121950
  var hasProperty = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key);
121729
- var equalFlat = (a, b) => a === b || size(a) === size(b) && every(a, (val, key) => (val !== undefined || hasProperty(b, key)) && equals(b[key], val));
121951
+ var equalFlat = (a, b) => a === b || size(a) === size(b) && every(a, (val, key) => (val !== undefined || hasProperty(b, key)) && equals2(b[key], val));
121730
121952
  var freeze = Object.freeze;
121731
121953
  var deepFreeze = (o) => {
121732
121954
  for (const key in o) {
@@ -133789,7 +134011,7 @@ async function emitBudgetRefusalSideEffects(ctx, inserted) {
133789
134011
  console.warn(`[budget-refusal-notify] Failed to create follow-up task for budget refusal (task=${ctx.task.id.slice(0, 8)}): ${err}`);
133790
134012
  }
133791
134013
  }
133792
- import("./event-bus-101fenkh.js").then(({ workflowEventBus }) => {
134014
+ import("./event-bus-9vpk8gmq.js").then(({ workflowEventBus }) => {
133793
134015
  workflowEventBus.emit("task.budget_refused", {
133794
134016
  taskId: ctx.task.id,
133795
134017
  agentId: ctx.agentId,
@@ -135339,7 +135561,7 @@ var registerRetryWorkflowRunTool = (server) => {
135339
135561
  createToolRegistrar(server)("retry-workflow-run", {
135340
135562
  title: "Retry Workflow Run",
135341
135563
  annotations: { destructiveHint: false },
135342
- description: "Retry a failed workflow run from the beginning. The run must be in 'failed' status.",
135564
+ description: "Resume the same failed workflow run from its failed step(s); completed steps are not re-run. Retrying re-creates the failed node's side effects (e.g. an agent task), so check the target state first if that work was already done manually.",
135343
135565
  inputSchema: object2({
135344
135566
  runId: string2().uuid().describe("Workflow run ID to retry")
135345
135567
  }),
@@ -135803,6 +136025,8 @@ async function createServer(opts = {}) {
135803
136025
  }
135804
136026
  if (hasCapability("pages")) {
135805
136027
  registerAppGetTool(server);
136028
+ registerAppRowTools(server);
136029
+ registerAppActionRunTool(server);
135806
136030
  registerAppHistoryTool(server);
135807
136031
  registerAppDiffTool(server);
135808
136032
  registerAppListTool(server);