@cortex-agent/server 2026.9.14 → 2026.9.21

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 (259) hide show
  1. package/README.md +3 -2
  2. package/defaults/config/hooks/08-agents-md-injector-post-tool.json +10 -0
  3. package/defaults/config/hooks/{10-cortex-md-injector-session-start.json → 10-agents-md-injector-session-start.json} +3 -3
  4. package/defaults/config/hooks/{CORTEX.md → AGENTS.md} +2 -2
  5. package/defaults/hooks/{CORTEX.md → AGENTS.md} +1 -1
  6. package/defaults/hooks/{cortex-md-injector.mjs → agents-md-injector.mjs} +117 -26
  7. package/defaults/hooks/cortex-hook-api.mjs +2 -2
  8. package/defaults/hooks/new-session-hook.mjs +2 -2
  9. package/defaults/hooks/rules-loader.mjs +2 -2
  10. package/defaults/hooks/status-md-guard.mjs +8 -8
  11. package/defaults/hooks/task-status-check.mjs +18 -76
  12. package/defaults/hooks/tasks-yaml-guard.mjs +2 -2
  13. package/defaults/plugins/cortex-commission/.claude-plugin/plugin.json +2 -2
  14. package/defaults/plugins/cortex-commission/plugin.json +2 -2
  15. package/defaults/plugins/cortex-commission/skills/commission/SKILL.md +3 -3
  16. package/defaults/plugins/cortex-feishu/skills/feishu-doc/SKILL.md +1 -1
  17. package/defaults/plugins/cortex-system/skills/client-manage/SKILL.md +2 -2
  18. package/defaults/plugins/cortex-system/skills/project-init/SKILL.md +4 -4
  19. package/defaults/plugins/cortex-system/skills/task/SKILL.md +1 -1
  20. package/defaults/rules/{cortex-md.md → agents-md.md} +4 -4
  21. package/defaults/rules/decision-records.md +1 -1
  22. package/defaults/rules/meta-conventions.md +4 -4
  23. package/defaults/rules/mission-md.md +1 -1
  24. package/dist/agent-adapter/claude/adapter.d.ts +0 -6
  25. package/dist/agent-adapter/claude/adapter.js +0 -8
  26. package/dist/agent-adapter/claude/defaults.d.ts +10 -7
  27. package/dist/agent-adapter/claude/defaults.js +18 -16
  28. package/dist/agent-adapter/claude/hooks-builder.js +2 -2
  29. package/dist/agent-adapter/claude/spawn-args.d.ts +0 -3
  30. package/dist/agent-adapter/claude/spawn-args.js +20 -16
  31. package/dist/agent-adapter/claude/turn-machine.d.ts +11 -0
  32. package/dist/agent-adapter/claude/turn-machine.js +46 -5
  33. package/dist/agent-adapter/normalize/prompt-builder.d.ts +16 -1
  34. package/dist/agent-adapter/normalize/prompt-builder.js +24 -6
  35. package/dist/agent-adapter/pi/mcp-bridge-logic.d.ts +11 -2
  36. package/dist/agent-adapter/pi/mcp-bridge-logic.js +32 -1
  37. package/dist/agent-adapter/pi/mcp-bridge.js +16 -15
  38. package/dist/agent-adapter/pi/session-options.d.ts +0 -6
  39. package/dist/agent-adapter/pi/session-options.js +1 -8
  40. package/dist/agent-adapter/types.d.ts +1 -1
  41. package/dist/core/mcp-tool-gate.d.ts +3 -17
  42. package/dist/core/mcp-tool-gate.js +4 -19
  43. package/dist/core/media-types.d.ts +10 -0
  44. package/dist/core/media-types.js +34 -0
  45. package/dist/core/platform-settings-spec.js +1 -1
  46. package/dist/core/settings-spec.d.ts +22 -1
  47. package/dist/core/settings-spec.js +33 -2
  48. package/dist/core/types/agent-types.d.ts +3 -1
  49. package/dist/core/utils.d.ts +1 -1
  50. package/dist/core/utils.js +1 -1
  51. package/dist/domain/agents/config.d.ts +1 -1
  52. package/dist/domain/agents/config.js +1 -1
  53. package/dist/domain/agents/profile-switch.d.ts +1 -1
  54. package/dist/domain/agents/profile-switch.js +3 -5
  55. package/dist/domain/agents/subagent/runner.js +0 -1
  56. package/dist/domain/commissions/commission-draft.d.ts +58 -0
  57. package/dist/domain/commissions/commission-draft.js +87 -4
  58. package/dist/domain/commissions/commission-finalize.d.ts +8 -3
  59. package/dist/domain/commissions/commission-finalize.js +14 -0
  60. package/dist/domain/executions/registry.d.ts +1 -2
  61. package/dist/domain/executions/registry.js +0 -3
  62. package/dist/domain/mcp/bundled-server.js +4 -3
  63. package/dist/domain/mcp/feishu/file.js +37 -18
  64. package/dist/domain/mcp/feishu/types.d.ts +3 -0
  65. package/dist/domain/mcp/feishu-server.js +1 -1
  66. package/dist/domain/mcp/tools/{cortex-md.d.ts → agents-md.d.ts} +6 -6
  67. package/dist/domain/mcp/tools/{cortex-md.js → agents-md.js} +6 -6
  68. package/dist/domain/mcp/tools/commission-tools.d.ts +12 -1
  69. package/dist/domain/mcp/tools/commission-tools.js +68 -14
  70. package/dist/domain/mcp/tools/remote-file.d.ts +20 -0
  71. package/dist/domain/mcp/tools/remote-file.js +44 -0
  72. package/dist/domain/mcp/tools/slack.d.ts +2 -0
  73. package/dist/domain/mcp/tools/slack.js +22 -7
  74. package/dist/domain/mcp/tools/task-ops.js +5 -13
  75. package/dist/domain/mcp/tools/ui-file.js +23 -10
  76. package/dist/domain/mcp/tools/waitpoint.d.ts +3 -0
  77. package/dist/domain/mcp/tools/waitpoint.js +122 -0
  78. package/dist/domain/memory/agents-md-injector.d.ts +24 -0
  79. package/dist/domain/memory/{cortex-md-injector.js → agents-md-injector.js} +10 -7
  80. package/dist/domain/projects/project-store.d.ts +1 -1
  81. package/dist/domain/projects/project-store.js +3 -3
  82. package/dist/domain/remote/client-hot-reload.js +3 -1
  83. package/dist/domain/remote/client-manager.js +105 -126
  84. package/dist/domain/remote/client-ssh-tunnel.d.ts +16 -5
  85. package/dist/domain/remote/client-ssh-tunnel.js +12 -5
  86. package/dist/domain/remote/cortex-client-config.d.ts +1 -1
  87. package/dist/domain/remote/cortex-client-config.js +1 -1
  88. package/dist/domain/remote/device-file.d.ts +51 -0
  89. package/dist/domain/remote/device-file.js +193 -0
  90. package/dist/domain/remote/device-port.js +3 -0
  91. package/dist/domain/remote/reverse-stream.d.ts +18 -7
  92. package/dist/domain/remote/reverse-stream.js +19 -6
  93. package/dist/domain/runs/builders.js +0 -1
  94. package/dist/domain/runs/compact.js +0 -1
  95. package/dist/domain/runs/engine-spec.d.ts +11 -4
  96. package/dist/domain/runs/engine-spec.js +7 -4
  97. package/dist/domain/runs/prompt.js +16 -10
  98. package/dist/domain/runs/request.d.ts +0 -1
  99. package/dist/domain/sessions/session-hooks.d.ts +5 -12
  100. package/dist/domain/sessions/session-hooks.js +6 -13
  101. package/dist/domain/sessions/session-lifecycle.d.ts +4 -4
  102. package/dist/domain/sessions/session-lifecycle.js +5 -6
  103. package/dist/domain/sessions/session-retention.d.ts +1 -3
  104. package/dist/domain/sessions/session-retention.js +9 -26
  105. package/dist/domain/sessions/session-use.d.ts +32 -0
  106. package/dist/domain/sessions/session-use.js +63 -0
  107. package/dist/domain/sessions/session.js +6 -5
  108. package/dist/domain/system/server-update-check.js +29 -1
  109. package/dist/domain/system/update-ui-state.d.ts +32 -0
  110. package/dist/domain/system/update-ui-state.js +63 -0
  111. package/dist/domain/tasks/claim-recovery.js +2 -2
  112. package/dist/domain/tasks/dispatch-utils.d.ts +10 -1
  113. package/dist/domain/tasks/dispatch-utils.js +46 -1
  114. package/dist/domain/tasks/dispatcher.js +4 -5
  115. package/dist/domain/tasks/mutator.d.ts +2 -2
  116. package/dist/domain/tasks/mutator.js +2 -2
  117. package/dist/domain/tasks/system/task-cli.js +2 -2
  118. package/dist/domain/tasks/system/task-state.js +1 -1
  119. package/dist/domain/threads/runner.js +3 -2
  120. package/dist/domain/ui-service/app-router.d.ts +54 -3
  121. package/dist/domain/ui-service/app-router.js +12 -14
  122. package/dist/domain/ui-service/input-schemas.d.ts +49 -5
  123. package/dist/domain/ui-service/input-schemas.js +35 -9
  124. package/dist/domain/ui-service/mutate/platform-settings.js +1 -1
  125. package/dist/domain/ui-service/mutate/sessions.d.ts +17 -1
  126. package/dist/domain/ui-service/mutate/sessions.js +83 -3
  127. package/dist/domain/ui-service/mutate/system.d.ts +3 -1
  128. package/dist/domain/ui-service/mutate/system.js +13 -0
  129. package/dist/domain/ui-service/mutate/waitpoints.d.ts +2 -0
  130. package/dist/domain/ui-service/mutate/waitpoints.js +20 -0
  131. package/dist/domain/ui-service/platform-settings.js +1 -1
  132. package/dist/domain/ui-service/plugins-shared.js +1 -1
  133. package/dist/domain/ui-service/query/config.js +1 -1
  134. package/dist/domain/ui-service/query/executions.js +0 -2
  135. package/dist/domain/ui-service/query/machine-detail.js +3 -8
  136. package/dist/domain/ui-service/query/memory.js +1 -1
  137. package/dist/domain/ui-service/query/sessions.js +7 -0
  138. package/dist/domain/ui-service/query/system.d.ts +2 -1
  139. package/dist/domain/ui-service/query/system.js +4 -0
  140. package/dist/domain/ui-service/query/threads.js +1 -54
  141. package/dist/domain/ui-service/query/waitpoints.d.ts +30 -0
  142. package/dist/domain/ui-service/query/waitpoints.js +117 -0
  143. package/dist/domain/ui-service/query-input-schemas.d.ts +3 -0
  144. package/dist/domain/ui-service/query-input-schemas.js +3 -0
  145. package/dist/domain/ui-service/trpc.js +1 -1
  146. package/dist/domain/ui-service/types.d.ts +175 -50
  147. package/dist/domain/ui-service/types.js +1 -1
  148. package/dist/domain/ui-service/ui-service.js +13 -33
  149. package/dist/domain/waitpoints/notices.d.ts +21 -0
  150. package/dist/domain/waitpoints/notices.js +115 -0
  151. package/dist/domain/waitpoints/service.d.ts +91 -0
  152. package/dist/domain/waitpoints/service.js +243 -0
  153. package/dist/entry/app.js +39 -29
  154. package/dist/entry/auth-login-cli.js +1 -1
  155. package/dist/entry/auth-login-terminal.js +1 -1
  156. package/dist/entry/init-auth.js +1 -1
  157. package/dist/entry/init.js +6 -6
  158. package/dist/entry/signal-cli.d.ts +30 -0
  159. package/dist/entry/signal-cli.js +207 -0
  160. package/dist/entry/start-ui-http.d.ts +1 -1
  161. package/dist/entry/start-ui-http.js +5 -3
  162. package/dist/events/event-types.d.ts +5 -7
  163. package/dist/hooks/{cortex-md-injector.mjs → agents-md-injector.mjs} +117 -26
  164. package/dist/hooks/cortex-hook-api.mjs +2 -2
  165. package/dist/hooks/new-session-hook.mjs +2 -2
  166. package/dist/hooks/rules-loader.mjs +2 -2
  167. package/dist/hooks/status-md-guard.mjs +8 -8
  168. package/dist/hooks/task-status-check.mjs +18 -76
  169. package/dist/hooks/tasks-yaml-guard.mjs +2 -2
  170. package/dist/orchestration/agent-file-send.d.ts +9 -0
  171. package/dist/orchestration/agent-file-send.js +21 -2
  172. package/dist/orchestration/agent-runner.d.ts +4 -3
  173. package/dist/orchestration/agent-runner.js +25 -23
  174. package/dist/orchestration/attachments-store.d.ts +31 -0
  175. package/dist/orchestration/attachments-store.js +184 -0
  176. package/dist/orchestration/conversation-request.d.ts +30 -8
  177. package/dist/orchestration/conversation-request.js +62 -26
  178. package/dist/orchestration/edit-retry.js +2 -1
  179. package/dist/orchestration/interactions/ask-user-resume.js +2 -1
  180. package/dist/orchestration/interactions/plan-approvals.js +1 -1
  181. package/dist/orchestration/interactions/ui-update-prompt.d.ts +8 -0
  182. package/dist/orchestration/interactions/ui-update-prompt.js +47 -0
  183. package/dist/orchestration/outputs-store.d.ts +11 -0
  184. package/dist/orchestration/outputs-store.js +32 -6
  185. package/dist/orchestration/resume-dispatcher.js +2 -2
  186. package/dist/orchestration/routing/file-handler.d.ts +23 -2
  187. package/dist/orchestration/routing/file-handler.js +22 -5
  188. package/dist/orchestration/routing/webhook.js +240 -39
  189. package/dist/orchestration/session-compact.d.ts +3 -0
  190. package/dist/orchestration/session-compact.js +3 -2
  191. package/dist/orchestration/session-events.d.ts +6 -0
  192. package/dist/orchestration/session-events.js +5 -0
  193. package/dist/orchestration/session-gateway.d.ts +1 -1
  194. package/dist/orchestration/session-gateway.js +1 -0
  195. package/dist/orchestration/thread-executor.d.ts +2 -0
  196. package/dist/orchestration/thread-executor.js +11 -1
  197. package/dist/orchestration/thread-input.d.ts +3 -2
  198. package/dist/orchestration/thread-input.js +8 -9
  199. package/dist/orchestration/turn/turn-prep.d.ts +15 -1
  200. package/dist/orchestration/turn/turn-prep.js +21 -9
  201. package/dist/orchestration/waitpoint-ingress.d.ts +41 -0
  202. package/dist/orchestration/waitpoint-ingress.js +172 -0
  203. package/dist/orchestration/waitpoint-notifier.d.ts +21 -0
  204. package/dist/orchestration/waitpoint-notifier.js +119 -0
  205. package/dist/orchestration/waitpoint-remote-drain.d.ts +20 -0
  206. package/dist/orchestration/waitpoint-remote-drain.js +147 -0
  207. package/dist/orchestration/waitpoint-sweep.d.ts +42 -0
  208. package/dist/orchestration/waitpoint-sweep.js +87 -0
  209. package/dist/platform/adapters/feishu-image.d.ts +19 -0
  210. package/dist/platform/adapters/feishu-image.js +71 -0
  211. package/dist/platform/adapters/feishu.d.ts +2 -0
  212. package/dist/platform/adapters/feishu.js +26 -16
  213. package/dist/platform/ui-http/app-update.d.ts +11 -0
  214. package/dist/platform/ui-http/app-update.js +3 -0
  215. package/dist/platform/ui-http/listening-ports.d.ts +1 -1
  216. package/dist/platform/ui-http/listening-ports.js +1 -1
  217. package/dist/platform/ui-http/ui-session.js +1 -1
  218. package/dist/store/conversation-ledger-repo.d.ts +10 -19
  219. package/dist/store/conversation-ledger-repo.js +143 -152
  220. package/dist/store/execution-repo.d.ts +1 -19
  221. package/dist/store/execution-repo.js +1 -18
  222. package/dist/store/project-notes-repo.js +11 -2
  223. package/dist/store/prompt-migration-replacements.js +1 -1
  224. package/dist/store/session-registry-import.d.ts +34 -0
  225. package/dist/store/session-registry-import.js +182 -0
  226. package/dist/store/session-registry-journal.d.ts +107 -0
  227. package/dist/store/session-registry-journal.js +308 -19
  228. package/dist/store/session-registry-repo.d.ts +113 -28
  229. package/dist/store/session-registry-repo.js +288 -105
  230. package/dist/store/version-migrations.d.ts +29 -3
  231. package/dist/store/version-migrations.js +288 -24
  232. package/dist/store/waitpoint-repo.d.ts +108 -0
  233. package/dist/store/waitpoint-repo.js +94 -0
  234. package/package.json +2 -2
  235. package/web/dist/assets/index-CwwQNMpP.css +1 -0
  236. package/web/dist/assets/index-DLSfgq3o.js +444 -0
  237. package/web/dist/assets/{index-aHbOZSP6.js → index-DZTuqUO4.js} +1 -1
  238. package/web/dist/index.html +2 -2
  239. package/defaults/config/hooks/08-cortex-md-injector-post-tool.json +0 -10
  240. package/dist/domain/executions/log-tailer.d.ts +0 -71
  241. package/dist/domain/executions/log-tailer.js +0 -194
  242. package/dist/domain/memory/cortex-md-injector.d.ts +0 -24
  243. package/dist/domain/memory/cortex-md-scanner.d.ts +0 -10
  244. package/dist/domain/memory/cortex-md-scanner.js +0 -66
  245. package/dist/domain/remote/cortex-client.d.ts +0 -1
  246. package/dist/domain/remote/cortex-client.js +0 -662
  247. package/dist/domain/tasks/system/cortex-run.d.ts +0 -25
  248. package/dist/domain/tasks/system/cortex-run.js +0 -360
  249. package/dist/store/session-repo.d.ts +0 -65
  250. package/dist/store/session-repo.js +0 -184
  251. package/web/dist/assets/index-BuXbCsuz.js +0 -444
  252. package/web/dist/assets/index-CCPxQ94C.css +0 -1
  253. /package/defaults/{CORTEX.md → AGENTS.md} +0 -0
  254. /package/defaults/config/{CORTEX.md → AGENTS.md} +0 -0
  255. /package/defaults/context/{CORTEX.md → AGENTS.md} +0 -0
  256. /package/defaults/context/ideas/{CORTEX.md → AGENTS.md} +0 -0
  257. /package/defaults/context/projects/{CORTEX.md → AGENTS.md} +0 -0
  258. /package/defaults/context/scans/{CORTEX.md → AGENTS.md} +0 -0
  259. /package/defaults/context/user/{CORTEX.md → AGENTS.md} +0 -0
@@ -137,6 +137,21 @@ export declare function createAppRouter(service: UiService): import("@trpc/serve
137
137
  output: import("./types.js").SessionsSetSelectionReturn;
138
138
  meta: object;
139
139
  }>;
140
+ setCommission: import("@trpc/server").TRPCMutationProcedure<{
141
+ input: {
142
+ sessionId: string;
143
+ commission?: {
144
+ mode: "off";
145
+ } | {
146
+ mode: "new";
147
+ } | {
148
+ mode: "join";
149
+ commissionId: string;
150
+ };
151
+ };
152
+ output: import("./types.js").SessionsSetCommissionReturn;
153
+ meta: object;
154
+ }>;
140
155
  createAndSend: import("@trpc/server").TRPCMutationProcedure<{
141
156
  input: {
142
157
  projectId: string;
@@ -176,6 +191,13 @@ export declare function createAppRouter(service: UiService): import("@trpc/serve
176
191
  output: void;
177
192
  meta: object;
178
193
  }>;
194
+ markManyRead: import("@trpc/server").TRPCMutationProcedure<{
195
+ input: {
196
+ sessionIds: string[];
197
+ };
198
+ output: import("./types.js").SessionsMarkManyReadReturn;
199
+ meta: object;
200
+ }>;
179
201
  answerQuestion: import("@trpc/server").TRPCMutationProcedure<{
180
202
  input: {
181
203
  requestId: string;
@@ -457,11 +479,25 @@ export declare function createAppRouter(service: UiService): import("@trpc/serve
457
479
  output: import("./types.js").ExecutionsCancelReturn;
458
480
  meta: object;
459
481
  }>;
460
- log: import("@trpc/server").TRPCSubscriptionProcedure<{
482
+ }>>;
483
+ waitpoints: import("@trpc/server").TRPCBuiltRouter<{
484
+ ctx: object;
485
+ meta: object;
486
+ errorShape: import("@trpc/server").TRPCDefaultErrorShape;
487
+ transformer: false;
488
+ }, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
489
+ list: import("@trpc/server").TRPCQueryProcedure<{
461
490
  input: {
462
- executionId: string;
491
+ sessionId: string;
492
+ };
493
+ output: import("./types.js").WaitpointInfo[];
494
+ meta: object;
495
+ }>;
496
+ cancel: import("@trpc/server").TRPCMutationProcedure<{
497
+ input: {
498
+ waitpointId: string;
463
499
  };
464
- output: AsyncIterable<import("./types.js").UiEvent, void, any>;
500
+ output: import("./types.js").WaitpointsCancelReturn;
465
501
  meta: object;
466
502
  }>;
467
503
  }>>;
@@ -1163,6 +1199,21 @@ export declare function createAppRouter(service: UiService): import("@trpc/serve
1163
1199
  output: import("./types.js").SystemRefreshUsageReturn;
1164
1200
  meta: object;
1165
1201
  }>;
1202
+ updateStatus: import("@trpc/server").TRPCQueryProcedure<{
1203
+ input: Record<string, never>;
1204
+ output: import("./types.js").ServerUpdateStatus;
1205
+ meta: object;
1206
+ }>;
1207
+ applyUpdate: import("@trpc/server").TRPCMutationProcedure<{
1208
+ input: Record<string, never>;
1209
+ output: import("./types.js").SystemUpdateDecisionReturn;
1210
+ meta: object;
1211
+ }>;
1212
+ skipUpdate: import("@trpc/server").TRPCMutationProcedure<{
1213
+ input: Record<string, never>;
1214
+ output: import("./types.js").SystemUpdateDecisionReturn;
1215
+ meta: object;
1216
+ }>;
1166
1217
  }>>;
1167
1218
  subscribe: import("@trpc/server").TRPCSubscriptionProcedure<{
1168
1219
  input: {
@@ -1,12 +1,12 @@
1
1
  // input: UI service, operation schemas and tRPC
2
2
  // output: typed UI router including platform configuration
3
3
  // pos: Typed tRPC mirror of UI operations
4
- // >>> Once updated, update this header and parent CORTEX.md <<<
4
+ // >>> Once updated, update this header and parent AGENTS.md <<<
5
5
  import { platformSettingsInput } from '../../core/platform-settings-spec.js';
6
6
  import { TRPCError } from '@trpc/server';
7
7
  import { z } from 'zod';
8
8
  import { router, publicProcedure } from './trpc.js';
9
- import { projectsListInput, projectsCreateInput, sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsCreateInput, sessionsSendInput, sessionsCancelInput, sessionsCompactInput, sessionsSetProfileInput, sessionsSetSelectionInput, sessionsCreateAndSendInput, sessionsMarkReadInput, sessionsAnswerQuestionInput, sessionsRespondPlanInput, sessionsRespondDecisionInput, sessionsCancelResumeInput, sessionsRewindInput, sessionsPendingInteractionInput, threadsListInput, threadsGetInput, tasksListInput, taskVerificationInput, schedulesListInput, commissionsListInput, commissionsGetInput, commissionsDecisionsInput, commissionCloseInput, executionsListInput, executionsGetInput, memoryTreeInput, memoryFileInput, approvalsListInput, approvalsApproveInput, approvalsRejectInput, approvalsRequestInput, issuesListInput, issueActionInput, notesListInput, noteAddInput, noteUpdateInput, noteSetCompletedInput, noteActionInput, notesClearCompletedInput, costSummaryInput, threadsCancelInput, executionsCancelInput, scheduleActionInput, scheduleAddInput, scheduleUpdateInput, taskActionInput, taskCompleteInput, taskBlockInput, executionsLogInput, configGetInput, configSetInput, configSetProviderRateLimitPolicyInput, authStatusInput, authFlowStateInput, authStartLoginInput, authRespondPromptInput, authCancelFlowInput, authLogoutInput, authSyncGatewayInput, authCustomProvidersInput, authUpsertCustomProviderInput, authRemoveCustomProviderInput, hooksListInput, hooksCreateInput, hooksUpdateInput, hooksSetEnabledInput, hooksRemoveInput, hooksTestInput, profilesCreateInput, profilesUpdateInput, profilesRemoveInput, modelsCatalogInput, machinesListInput, machineDetailInput, skillsListInput, pluginsListInput, pluginsAssignInput, pluginsSkillFileInput, pluginsSkillWriteInput, pluginsSkillCreateInput, pluginsSkillMoveInput, pluginsSkillRemoveInput, pluginsCreateInput, pluginsRemoveInput, pluginsConvertInput, pluginsMcpReadInput, pluginsMcpWriteInput, threadTemplatesGetInput, threadTemplatesDetailInput, threadTemplatesValidateInput, threadTemplatesSaveInput, threadTemplatesRemoveInput, systemDaemonStatusInput, systemRateLimitStatusInput, systemUsageStatusInput, systemNoticesInput, systemRestartInput, systemClearRateLimitInput, systemRefreshUsageInput, } from './input-schemas.js';
9
+ import { projectsListInput, projectsCreateInput, sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsCreateInput, sessionsSendInput, sessionsCancelInput, sessionsCompactInput, sessionsSetProfileInput, sessionsSetSelectionInput, sessionsSetCommissionInput, sessionsCreateAndSendInput, sessionsMarkReadInput, sessionsMarkManyReadInput, sessionsAnswerQuestionInput, sessionsRespondPlanInput, sessionsRespondDecisionInput, sessionsCancelResumeInput, sessionsRewindInput, sessionsPendingInteractionInput, threadsListInput, threadsGetInput, tasksListInput, taskVerificationInput, schedulesListInput, commissionsListInput, commissionsGetInput, commissionsDecisionsInput, commissionCloseInput, executionsListInput, waitpointsListInput, executionsGetInput, memoryTreeInput, memoryFileInput, approvalsListInput, approvalsApproveInput, approvalsRejectInput, approvalsRequestInput, issuesListInput, issueActionInput, notesListInput, noteAddInput, noteUpdateInput, noteSetCompletedInput, noteActionInput, notesClearCompletedInput, costSummaryInput, threadsCancelInput, executionsCancelInput, waitpointsCancelInput, scheduleActionInput, scheduleAddInput, scheduleUpdateInput, taskActionInput, taskCompleteInput, taskBlockInput, configGetInput, configSetInput, configSetProviderRateLimitPolicyInput, authStatusInput, authFlowStateInput, authStartLoginInput, authRespondPromptInput, authCancelFlowInput, authLogoutInput, authSyncGatewayInput, authCustomProvidersInput, authUpsertCustomProviderInput, authRemoveCustomProviderInput, hooksListInput, hooksCreateInput, hooksUpdateInput, hooksSetEnabledInput, hooksRemoveInput, hooksTestInput, profilesCreateInput, profilesUpdateInput, profilesRemoveInput, modelsCatalogInput, machinesListInput, machineDetailInput, skillsListInput, pluginsListInput, pluginsAssignInput, pluginsSkillFileInput, pluginsSkillWriteInput, pluginsSkillCreateInput, pluginsSkillMoveInput, pluginsSkillRemoveInput, pluginsCreateInput, pluginsRemoveInput, pluginsConvertInput, pluginsMcpReadInput, pluginsMcpWriteInput, threadTemplatesGetInput, threadTemplatesDetailInput, threadTemplatesValidateInput, threadTemplatesSaveInput, threadTemplatesRemoveInput, systemDaemonStatusInput, systemRateLimitStatusInput, systemUsageStatusInput, systemNoticesInput, systemRestartInput, systemClearRateLimitInput, systemRefreshUsageInput, systemUpdateStatusInput, systemApplyUpdateInput, systemSkipUpdateInput, } from './input-schemas.js';
10
10
  // ── Subscribe filter input (no keyed schema for subscribe; router-local) ──
11
11
  const subscribeFilterInput = z.object({
12
12
  events: z.array(z.string()),
@@ -84,8 +84,10 @@ function sessionsRouter(service) {
84
84
  compact: makeMutation(service, 'sessions.compact', sessionsCompactInput),
85
85
  setProfile: makeMutation(service, 'sessions.setProfile', sessionsSetProfileInput),
86
86
  setSelection: makeMutation(service, 'sessions.setSelection', sessionsSetSelectionInput),
87
+ setCommission: makeMutation(service, 'sessions.setCommission', sessionsSetCommissionInput),
87
88
  createAndSend: makeMutation(service, 'sessions.createAndSend', sessionsCreateAndSendInput),
88
89
  markRead: makeMutation(service, 'sessions.markRead', sessionsMarkReadInput),
90
+ markManyRead: makeMutation(service, 'sessions.markManyRead', sessionsMarkManyReadInput),
89
91
  answerQuestion: makeMutation(service, 'sessions.answerQuestion', sessionsAnswerQuestionInput),
90
92
  respondPlan: makeMutation(service, 'sessions.respondPlan', sessionsRespondPlanInput),
91
93
  respondDecision: makeMutation(service, 'sessions.respondDecision', sessionsRespondDecisionInput),
@@ -129,17 +131,10 @@ function commissionsRouter(service) {
129
131
  close: makeMutation(service, 'commissions.close', commissionCloseInput),
130
132
  });
131
133
  }
132
- function executionLogProcedure(service) {
133
- return publicProcedure.input(executionsLogInput).subscription(async function* ({ input, signal }) {
134
- const sub = service.subscribeExecutionLog(input.executionId);
135
- signal?.addEventListener('abort', () => sub.close());
136
- try {
137
- for await (const event of sub)
138
- yield event;
139
- }
140
- finally {
141
- sub.close();
142
- }
134
+ function waitpointsRouter(service) {
135
+ return router({
136
+ list: makeQuery(service, 'waitpoints.list', waitpointsListInput),
137
+ cancel: makeMutation(service, 'waitpoints.cancel', waitpointsCancelInput),
143
138
  });
144
139
  }
145
140
  function executionsRouter(service) {
@@ -147,7 +142,6 @@ function executionsRouter(service) {
147
142
  list: makeQuery(service, 'executions.list', executionsListInput),
148
143
  get: makeQuery(service, 'executions.get', executionsGetInput),
149
144
  cancel: makeMutation(service, 'executions.cancel', executionsCancelInput),
150
- log: executionLogProcedure(service),
151
145
  });
152
146
  }
153
147
  function memoryRouter(service) {
@@ -231,6 +225,9 @@ function systemRouter(service) {
231
225
  restart: makeMutation(service, 'system.restart', systemRestartInput),
232
226
  clearRateLimit: makeMutation(service, 'system.clearRateLimit', systemClearRateLimitInput),
233
227
  refreshUsage: makeMutation(service, 'system.refreshUsage', systemRefreshUsageInput),
228
+ updateStatus: makeQuery(service, 'system.updateStatus', systemUpdateStatusInput),
229
+ applyUpdate: makeMutation(service, 'system.applyUpdate', systemApplyUpdateInput),
230
+ skipUpdate: makeMutation(service, 'system.skipUpdate', systemSkipUpdateInput),
234
231
  });
235
232
  }
236
233
  function costRouter(service) {
@@ -300,6 +297,7 @@ export function createAppRouter(service) {
300
297
  schedules: schedulesRouter(service),
301
298
  commissions: commissionsRouter(service),
302
299
  executions: executionsRouter(service),
300
+ waitpoints: waitpointsRouter(service),
303
301
  memory: memoryRouter(service),
304
302
  approvals: approvalsRouter(service),
305
303
  issues: issuesRouter(service),
@@ -1,7 +1,7 @@
1
1
  export { platformSettingsInput } from '../../core/platform-settings-spec.js';
2
2
  import { z } from 'zod';
3
- import { sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsPendingInteractionInput, threadsListInput, threadsGetInput, tasksListInput, taskVerificationInput, schedulesListInput, commissionsListInput, commissionsGetInput, commissionsDecisionsInput, executionsListInput, executionsGetInput, memoryTreeInput, memoryFileInput, approvalsListInput, issuesListInput, notesListInput } from './query-input-schemas.js';
4
- export { sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsPendingInteractionInput, threadsListInput, threadsGetInput, tasksListInput, taskVerificationInput, schedulesListInput, commissionsListInput, commissionsGetInput, commissionsDecisionsInput, executionsListInput, executionsGetInput, memoryTreeInput, memoryFileInput, approvalsListInput, issuesListInput, notesListInput, };
3
+ import { sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsPendingInteractionInput, threadsListInput, threadsGetInput, tasksListInput, taskVerificationInput, schedulesListInput, commissionsListInput, commissionsGetInput, commissionsDecisionsInput, executionsListInput, executionsGetInput, waitpointsListInput, memoryTreeInput, memoryFileInput, approvalsListInput, issuesListInput, notesListInput } from './query-input-schemas.js';
4
+ export { sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsPendingInteractionInput, threadsListInput, threadsGetInput, tasksListInput, taskVerificationInput, schedulesListInput, commissionsListInput, commissionsGetInput, commissionsDecisionsInput, executionsListInput, executionsGetInput, waitpointsListInput, memoryTreeInput, memoryFileInput, approvalsListInput, issuesListInput, notesListInput, };
5
5
  export declare const projectsListInput: z.ZodObject<{}, z.core.$strip>;
6
6
  export declare const costSummaryInput: z.ZodObject<{
7
7
  projectId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -26,9 +26,7 @@ export declare const systemUsageStatusInput: z.ZodObject<{}, z.core.$strip>;
26
26
  export declare const systemNoticesInput: z.ZodObject<{
27
27
  limit: z.ZodOptional<z.ZodNumber>;
28
28
  }, z.core.$strip>;
29
- export declare const executionsLogInput: z.ZodObject<{
30
- executionId: z.ZodString;
31
- }, z.core.$strip>;
29
+ export declare const systemUpdateStatusInput: z.ZodObject<{}, z.core.$strip>;
32
30
  export declare const authStartLoginInput: z.ZodObject<{
33
31
  backend: z.ZodEnum<{
34
32
  claude: "claude";
@@ -103,6 +101,21 @@ export declare const sessionCommissionInput: z.ZodDiscriminatedUnion<[z.ZodObjec
103
101
  mode: z.ZodLiteral<"join">;
104
102
  commissionId: z.ZodString;
105
103
  }, z.core.$strip>], "mode">;
104
+ /** Switching a LIVE session's commission mode (DR-0037 v4). The create-time choices plus `off`,
105
+ * which creation had no need for. Spelled as a third union member rather than a nullable field so
106
+ * the emitted client type keeps it: this package compiles with `strict: false`, where `X | null`
107
+ * erases to `X` and a null the server accepts becomes unspellable in the strict-mode web client. */
108
+ export declare const sessionsSetCommissionInput: z.ZodObject<{
109
+ sessionId: z.ZodString;
110
+ commission: z.ZodDiscriminatedUnion<[z.ZodObject<{
111
+ mode: z.ZodLiteral<"off">;
112
+ }, z.core.$strip>, z.ZodObject<{
113
+ mode: z.ZodLiteral<"new">;
114
+ }, z.core.$strip>, z.ZodObject<{
115
+ mode: z.ZodLiteral<"join">;
116
+ commissionId: z.ZodString;
117
+ }, z.core.$strip>], "mode">;
118
+ }, z.core.$strip>;
106
119
  export declare const sessionsCreateInput: z.ZodObject<{
107
120
  projectId: z.ZodOptional<z.ZodString>;
108
121
  browser: z.ZodOptional<z.ZodNullable<z.ZodObject<{
@@ -140,6 +153,9 @@ export declare const sessionsCompactInput: z.ZodObject<{
140
153
  export declare const sessionsMarkReadInput: z.ZodObject<{
141
154
  sessionId: z.ZodString;
142
155
  }, z.core.$strip>;
156
+ export declare const sessionsMarkManyReadInput: z.ZodObject<{
157
+ sessionIds: z.ZodArray<z.ZodString>;
158
+ }, z.core.$strip>;
143
159
  export declare const sessionsSetProfileInput: z.ZodObject<{
144
160
  sessionId: z.ZodString;
145
161
  profileName: z.ZodString;
@@ -216,6 +232,9 @@ export declare const sessionsCreateAndSendInput: z.ZodObject<{
216
232
  export declare const threadsCancelInput: z.ZodObject<{
217
233
  threadId: z.ZodString;
218
234
  }, z.core.$strip>;
235
+ export declare const waitpointsCancelInput: z.ZodObject<{
236
+ waitpointId: z.ZodString;
237
+ }, z.core.$strip>;
219
238
  export declare const executionsCancelInput: z.ZodObject<{
220
239
  executionId: z.ZodString;
221
240
  }, z.core.$strip>;
@@ -564,6 +583,8 @@ export declare const systemClearRateLimitInput: z.ZodObject<{
564
583
  provider: z.ZodOptional<z.ZodString>;
565
584
  }, z.core.$strip>;
566
585
  export declare const systemRefreshUsageInput: z.ZodObject<{}, z.core.$strip>;
586
+ export declare const systemApplyUpdateInput: z.ZodObject<{}, z.core.$strip>;
587
+ export declare const systemSkipUpdateInput: z.ZodObject<{}, z.core.$strip>;
567
588
  export declare const approvalsRequestInput: z.ZodObject<{
568
589
  kind: z.ZodEnum<{
569
590
  "reconnect-platform": "reconnect-platform";
@@ -644,6 +665,9 @@ export declare const queryInputSchemas: {
644
665
  status: z.ZodOptional<z.ZodArray<z.ZodString>>;
645
666
  limit: z.ZodOptional<z.ZodNumber>;
646
667
  }, z.core.$strip>;
668
+ 'waitpoints.list': z.ZodObject<{
669
+ sessionId: z.ZodString;
670
+ }, z.core.$strip>;
647
671
  'executions.get': z.ZodObject<{
648
672
  executionId: z.ZodString;
649
673
  }, z.core.$strip>;
@@ -707,6 +731,7 @@ export declare const queryInputSchemas: {
707
731
  'system.notices': z.ZodObject<{
708
732
  limit: z.ZodOptional<z.ZodNumber>;
709
733
  }, z.core.$strip>;
734
+ 'system.updateStatus': z.ZodObject<{}, z.core.$strip>;
710
735
  };
711
736
  export declare const mutateInputSchemas: {
712
737
  'projects.create': z.ZodObject<{
@@ -760,6 +785,17 @@ export declare const mutateInputSchemas: {
760
785
  mode: z.ZodOptional<z.ZodString>;
761
786
  }, z.core.$strip>>;
762
787
  }, z.core.$strip>;
788
+ 'sessions.setCommission': z.ZodObject<{
789
+ sessionId: z.ZodString;
790
+ commission: z.ZodDiscriminatedUnion<[z.ZodObject<{
791
+ mode: z.ZodLiteral<"off">;
792
+ }, z.core.$strip>, z.ZodObject<{
793
+ mode: z.ZodLiteral<"new">;
794
+ }, z.core.$strip>, z.ZodObject<{
795
+ mode: z.ZodLiteral<"join">;
796
+ commissionId: z.ZodString;
797
+ }, z.core.$strip>], "mode">;
798
+ }, z.core.$strip>;
763
799
  'sessions.createAndSend': z.ZodObject<{
764
800
  projectId: z.ZodString;
765
801
  profileName: z.ZodOptional<z.ZodString>;
@@ -795,6 +831,9 @@ export declare const mutateInputSchemas: {
795
831
  'sessions.markRead': z.ZodObject<{
796
832
  sessionId: z.ZodString;
797
833
  }, z.core.$strip>;
834
+ 'sessions.markManyRead': z.ZodObject<{
835
+ sessionIds: z.ZodArray<z.ZodString>;
836
+ }, z.core.$strip>;
798
837
  'sessions.answerQuestion': z.ZodObject<{
799
838
  requestId: z.ZodString;
800
839
  answers: z.ZodRecord<z.ZodString, z.ZodString>;
@@ -828,6 +867,9 @@ export declare const mutateInputSchemas: {
828
867
  'executions.cancel': z.ZodObject<{
829
868
  executionId: z.ZodString;
830
869
  }, z.core.$strip>;
870
+ 'waitpoints.cancel': z.ZodObject<{
871
+ waitpointId: z.ZodString;
872
+ }, z.core.$strip>;
831
873
  'schedules.pause': z.ZodObject<{
832
874
  scheduleId: z.ZodString;
833
875
  }, z.core.$strip>;
@@ -1264,4 +1306,6 @@ export declare const mutateInputSchemas: {
1264
1306
  provider: z.ZodOptional<z.ZodString>;
1265
1307
  }, z.core.$strip>;
1266
1308
  'system.refreshUsage': z.ZodObject<{}, z.core.$strip>;
1309
+ 'system.applyUpdate': z.ZodObject<{}, z.core.$strip>;
1310
+ 'system.skipUpdate': z.ZodObject<{}, z.core.$strip>;
1267
1311
  };
@@ -1,7 +1,7 @@
1
1
  // input: Zod, settings specs and UI operation unions
2
2
  // output: UI input validation schemas and operation maps
3
3
  // pos: Runtime validation source for UI contract
4
- // >>> Once updated, update this header and parent CORTEX.md <<<
4
+ // >>> Once updated, update this header and parent AGENTS.md <<<
5
5
  import { platformSettingsInput } from '../../core/platform-settings-spec.js';
6
6
  export { platformSettingsInput } from '../../core/platform-settings-spec.js';
7
7
  import { z } from 'zod';
@@ -9,8 +9,8 @@ import { SETTINGS_SPEC } from '../../core/settings-spec.js';
9
9
  // Import the leaf model module, not the pi-providers barrel: this file is bundled for the browser
10
10
  // through @cortex-agent/ui-contract, and that module is pure data with no imports of its own.
11
11
  import { CUSTOM_PROVIDER_APIS, CUSTOM_PROVIDER_NAME_RE, } from '../pi-providers/custom-provider-model.js';
12
- import { sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsPendingInteractionInput, threadsListInput, threadsGetInput, tasksListInput, taskVerificationInput, schedulesListInput, commissionsListInput, commissionsGetInput, commissionsDecisionsInput, executionsListInput, executionsGetInput, memoryTreeInput, memoryFileInput, approvalsListInput, issuesListInput, notesListInput, } from './query-input-schemas.js';
13
- export { sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsPendingInteractionInput, threadsListInput, threadsGetInput, tasksListInput, taskVerificationInput, schedulesListInput, commissionsListInput, commissionsGetInput, commissionsDecisionsInput, executionsListInput, executionsGetInput, memoryTreeInput, memoryFileInput, approvalsListInput, issuesListInput, notesListInput, };
12
+ import { sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsPendingInteractionInput, threadsListInput, threadsGetInput, tasksListInput, taskVerificationInput, schedulesListInput, commissionsListInput, commissionsGetInput, commissionsDecisionsInput, executionsListInput, executionsGetInput, waitpointsListInput, memoryTreeInput, memoryFileInput, approvalsListInput, issuesListInput, notesListInput, } from './query-input-schemas.js';
13
+ export { sessionsListInput, sessionsTranscriptInput, sessionsSubagentTranscriptInput, sessionsDebugDetailsInput, sessionsPendingInteractionInput, threadsListInput, threadsGetInput, tasksListInput, taskVerificationInput, schedulesListInput, commissionsListInput, commissionsGetInput, commissionsDecisionsInput, executionsListInput, executionsGetInput, waitpointsListInput, memoryTreeInput, memoryFileInput, approvalsListInput, issuesListInput, notesListInput, };
14
14
  // ── Query input schemas ───────────────────────────────────────────
15
15
  export const projectsListInput = z.object({});
16
16
  export const costSummaryInput = z.object({
@@ -34,12 +34,7 @@ export const systemDaemonStatusInput = z.object({});
34
34
  export const systemRateLimitStatusInput = z.object({});
35
35
  export const systemUsageStatusInput = z.object({});
36
36
  export const systemNoticesInput = z.object({ limit: z.number().int().positive().max(50).optional() });
37
- // ── Subscription input schemas ────────────────────────────────────
38
- // Subscriptions are not part of the query/mutate keyed maps; their input schemas live here too so
39
- // the AppRouter and the browser (@cortex-agent/ui-contract) share one source of truth (B2-C).
40
- export const executionsLogInput = z.object({
41
- executionId: z.string(),
42
- });
37
+ export const systemUpdateStatusInput = z.object({});
43
38
  // ── Mutate input schemas ──────────────────────────────────────────
44
39
  export const authStartLoginInput = z.object({
45
40
  backend: z.enum(['claude', 'pi']),
@@ -101,6 +96,18 @@ export const sessionCommissionInput = z.discriminatedUnion('mode', [
101
96
  z.object({ mode: z.literal('new') }),
102
97
  z.object({ mode: z.literal('join'), commissionId: z.string() }),
103
98
  ]);
99
+ /** Switching a LIVE session's commission mode (DR-0037 v4). The create-time choices plus `off`,
100
+ * which creation had no need for. Spelled as a third union member rather than a nullable field so
101
+ * the emitted client type keeps it: this package compiles with `strict: false`, where `X | null`
102
+ * erases to `X` and a null the server accepts becomes unspellable in the strict-mode web client. */
103
+ export const sessionsSetCommissionInput = z.object({
104
+ sessionId: z.string(),
105
+ commission: z.discriminatedUnion('mode', [
106
+ z.object({ mode: z.literal('off') }),
107
+ z.object({ mode: z.literal('new') }),
108
+ z.object({ mode: z.literal('join'), commissionId: z.string() }),
109
+ ]),
110
+ });
104
111
  export const sessionsCreateInput = z.object({
105
112
  projectId: z.string().optional(),
106
113
  browser: sessionBrowserInput.nullish(),
@@ -126,6 +133,10 @@ export const sessionsCompactInput = z.object({
126
133
  export const sessionsMarkReadInput = z.object({
127
134
  sessionId: z.string(),
128
135
  });
136
+ // Bounded batch: the run list of one schedule, never "every session on the box".
137
+ export const sessionsMarkManyReadInput = z.object({
138
+ sessionIds: z.array(z.string()).min(1).max(500),
139
+ });
129
140
  export const sessionsSetProfileInput = z.object({
130
141
  sessionId: z.string(),
131
142
  profileName: z.string().min(1),
@@ -193,6 +204,9 @@ export const sessionsCreateAndSendInput = z.object({
193
204
  export const threadsCancelInput = z.object({
194
205
  threadId: z.string(),
195
206
  });
207
+ export const waitpointsCancelInput = z.object({
208
+ waitpointId: z.string().min(1),
209
+ });
196
210
  export const executionsCancelInput = z.object({
197
211
  executionId: z.string(),
198
212
  });
@@ -635,6 +649,11 @@ export const systemClearRateLimitInput = z.object({
635
649
  provider: z.string().optional(),
636
650
  });
637
651
  export const systemRefreshUsageInput = z.object({});
652
+ // The pending prompt is process-global (one server, one npm self-update), so neither decision
653
+ // carries a version: answering a prompt that is no longer pending returns accepted:false rather
654
+ // than applying a stale choice.
655
+ export const systemApplyUpdateInput = z.object({});
656
+ export const systemSkipUpdateInput = z.object({});
638
657
  export const approvalsRequestInput = z
639
658
  .object({
640
659
  kind: z.enum(['reconnect-platform', 'add-machine']),
@@ -666,6 +685,7 @@ export const queryInputSchemas = {
666
685
  'commissions.get': commissionsGetInput,
667
686
  'commissions.decisions': commissionsDecisionsInput,
668
687
  'executions.list': executionsListInput,
688
+ 'waitpoints.list': waitpointsListInput,
669
689
  'executions.get': executionsGetInput,
670
690
  'memory.tree': memoryTreeInput,
671
691
  'memory.file': memoryFileInput,
@@ -691,6 +711,7 @@ export const queryInputSchemas = {
691
711
  'system.rateLimitStatus': systemRateLimitStatusInput,
692
712
  'system.usageStatus': systemUsageStatusInput,
693
713
  'system.notices': systemNoticesInput,
714
+ 'system.updateStatus': systemUpdateStatusInput,
694
715
  };
695
716
  export const mutateInputSchemas = {
696
717
  'projects.create': projectsCreateInput,
@@ -700,8 +721,10 @@ export const mutateInputSchemas = {
700
721
  'sessions.compact': sessionsCompactInput,
701
722
  'sessions.setProfile': sessionsSetProfileInput,
702
723
  'sessions.setSelection': sessionsSetSelectionInput,
724
+ 'sessions.setCommission': sessionsSetCommissionInput,
703
725
  'sessions.createAndSend': sessionsCreateAndSendInput,
704
726
  'sessions.markRead': sessionsMarkReadInput,
727
+ 'sessions.markManyRead': sessionsMarkManyReadInput,
705
728
  'sessions.answerQuestion': sessionsAnswerQuestionInput,
706
729
  'sessions.respondPlan': sessionsRespondPlanInput,
707
730
  'sessions.respondDecision': sessionsRespondDecisionInput,
@@ -709,6 +732,7 @@ export const mutateInputSchemas = {
709
732
  'sessions.rewind': sessionsRewindInput,
710
733
  'threads.cancel': threadsCancelInput,
711
734
  'executions.cancel': executionsCancelInput,
735
+ 'waitpoints.cancel': waitpointsCancelInput,
712
736
  'schedules.pause': scheduleActionInput,
713
737
  'schedules.resume': scheduleActionInput,
714
738
  'schedules.remove': scheduleActionInput,
@@ -763,4 +787,6 @@ export const mutateInputSchemas = {
763
787
  'system.restart': systemRestartInput,
764
788
  'system.clearRateLimit': systemClearRateLimitInput,
765
789
  'system.refreshUsage': systemRefreshUsageInput,
790
+ 'system.applyUpdate': systemApplyUpdateInput,
791
+ 'system.skipUpdate': systemSkipUpdateInput,
766
792
  };
@@ -1,7 +1,7 @@
1
1
  // input: platform patch schema, config path and credential writer
2
2
  // output: validated platform writes with secret-free errors
3
3
  // pos: Platform settings mutation boundary
4
- // >>> Once updated, update this header and parent CORTEX.md <<<
4
+ // >>> Once updated, update this header and parent AGENTS.md <<<
5
5
  import path from 'node:path';
6
6
  import { CONFIG_DIR } from '../../../core/paths.js';
7
7
  import { platformSettingsInput } from '../../../core/platform-settings-spec.js';
@@ -1,9 +1,25 @@
1
- import type { UiServiceDeps, Result, SessionsCreateArgs, SessionsCreateReturn, SessionsSendArgs, SessionsSendReturn, SessionsCancelArgs, SessionsCompactArgs, SessionsCompactReturn, SessionsMarkReadArgs, SessionsCancelReturn, SessionsSetProfileArgs, SessionsSetProfileReturn, SessionsSetSelectionArgs, SessionsSetSelectionReturn, SessionsCreateAndSendArgs, SessionsCreateAndSendReturn, SessionsAnswerQuestionArgs, SessionsRespondPlanArgs, SessionsRespondDecisionArgs, SessionsRespondDecisionReturn, SessionsInteractionMutateReturn, SessionsRewindArgs, SessionsRewindReturn, SessionsCancelResumeArgs, SessionsCancelResumeReturn } from '../types.js';
1
+ import type { UiServiceDeps, Result, SessionsCreateArgs, SessionsCreateReturn, SessionsSendArgs, SessionsSendReturn, SessionsCancelArgs, SessionsCompactArgs, SessionsCompactReturn, SessionsMarkReadArgs, SessionsMarkManyReadArgs, SessionsMarkManyReadReturn, SessionsCancelReturn, SessionsSetProfileArgs, SessionsSetProfileReturn, SessionsSetSelectionArgs, SessionsSetSelectionReturn, SessionsSetCommissionArgs, SessionsSetCommissionReturn, SessionsCreateAndSendArgs, SessionsCreateAndSendReturn, SessionsAnswerQuestionArgs, SessionsRespondPlanArgs, SessionsRespondDecisionArgs, SessionsRespondDecisionReturn, SessionsInteractionMutateReturn, SessionsRewindArgs, SessionsRewindReturn, SessionsCancelResumeArgs, SessionsCancelResumeReturn } from '../types.js';
2
2
  export declare function handleCreateSession(deps: UiServiceDeps, args: SessionsCreateArgs): Promise<Result<SessionsCreateReturn>>;
3
+ /**
4
+ * Switch a LIVE session in or out of commission mode (DR-0037 v4).
5
+ *
6
+ * The user's half of "either side may start a commission": the agent calls
7
+ * `cortex_commission_start`, the user flips the composer's capsule, and both land in the same
8
+ * `enterCommissionDraft`. It exists for a session already in flight — creation could only ever say
9
+ * yes at birth, which meant a conversation that turned into a long task had no way in.
10
+ *
11
+ * `bound` is terminal: a second contract would orphan the first, so a bound session refuses every
12
+ * transition (open a new session and join instead).
13
+ */
14
+ export declare function handleSetCommission(deps: UiServiceDeps, args: SessionsSetCommissionArgs): Promise<Result<SessionsSetCommissionReturn>>;
3
15
  export declare function handleSendSession(deps: UiServiceDeps, args: SessionsSendArgs): Promise<Result<SessionsSendReturn>>;
4
16
  export declare function handleCancelSession(deps: UiServiceDeps, args: SessionsCancelArgs): Promise<Result<SessionsCancelReturn>>;
5
17
  export declare function handleCompactSession(deps: UiServiceDeps, args: SessionsCompactArgs): Promise<Result<SessionsCompactReturn>>;
6
18
  export declare function handleMarkReadSession(deps: UiServiceDeps, args: SessionsMarkReadArgs): Promise<Result<void>>;
19
+ /** Batch mark-read behind the run list's「mark all read」. Deliberately forgiving: a session that
20
+ * no longer resolves (purged run, stale client list) is skipped instead of failing the batch —
21
+ * the user asked to clear what they see, and a half-stale list must still clear. */
22
+ export declare function handleMarkManyReadSessions(deps: UiServiceDeps, args: SessionsMarkManyReadArgs): Promise<Result<SessionsMarkManyReadReturn>>;
7
23
  export declare function handleCreateAndSend(deps: UiServiceDeps, args: SessionsCreateAndSendArgs): Promise<Result<SessionsCreateAndSendReturn>>;
8
24
  export declare function handleSetProfile(deps: UiServiceDeps, args: SessionsSetProfileArgs): Promise<Result<SessionsSetProfileReturn>>;
9
25
  export declare function handleSetSelection(deps: UiServiceDeps, args: SessionsSetSelectionArgs): Promise<Result<SessionsSetSelectionReturn>>;
@@ -4,13 +4,16 @@
4
4
  // assistant reply returns over the `session.message` stream event, NOT this return.
5
5
  import { removeDirectResume } from '../../costs/resume-registry.js';
6
6
  import { projectCommissionDecisionAction } from '../../commissions/decision-projection.js';
7
+ import { enterCommissionDraft, leaveCommissionDraft } from '../../commissions/commission-draft.js';
8
+ import { commissionRepo } from '../../../store/commission-repo.js';
9
+ import { sessionStore } from '../../../store/session-registry-repo.js';
7
10
  import { getSettings } from '../../../core/settings.js';
8
11
  // Create a fresh, live direct session for the workbench "+ New session" control. Resolves the target
9
12
  // project (falling back to the default project when omitted), delegates the real creation to the
10
13
  // injected `createDirectSession` dep (domain primitive wired in entry/app.ts), and returns the new
11
14
  // session's id.
12
- /** Commission mode ships behind `settings.commissionEnabled` (off by default while the feature is
13
- * under test). The composer hides the opt-in when it is off, so reaching this is either a stale
15
+ /** Commission mode ships behind `settings.commissionEnabled`, its kill switch (on by default since
16
+ * DR-0037 v4). The composer hides the opt-in when it is off, so reaching this is either a stale
14
17
  * client or a direct API call; answer with a 400 rather than letting createDirectSession throw. */
15
18
  function commissionDisabled(commission) {
16
19
  if (!commission || getSettings().commissionEnabled)
@@ -31,11 +34,74 @@ export async function handleCreateSession(deps, args) {
31
34
  });
32
35
  return { ok: true, data: { sessionId } };
33
36
  }
37
+ /**
38
+ * Switch a LIVE session in or out of commission mode (DR-0037 v4).
39
+ *
40
+ * The user's half of "either side may start a commission": the agent calls
41
+ * `cortex_commission_start`, the user flips the composer's capsule, and both land in the same
42
+ * `enterCommissionDraft`. It exists for a session already in flight — creation could only ever say
43
+ * yes at birth, which meant a conversation that turned into a long task had no way in.
44
+ *
45
+ * `bound` is terminal: a second contract would orphan the first, so a bound session refuses every
46
+ * transition (open a new session and join instead).
47
+ */
48
+ export async function handleSetCommission(deps, args) {
49
+ // `off` stays allowed with the feature switched off: a session left drafting when the switch
50
+ // flipped must still be able to get out.
51
+ const disabled = commissionDisabled(args.commission.mode === 'off' ? null : args.commission);
52
+ if (disabled)
53
+ return disabled;
54
+ const session = await deps.sessionStore.getById(args.sessionId);
55
+ if (!session)
56
+ return { ok: false, code: 'not-found', message: `Session not found: ${args.sessionId}` };
57
+ if (session.commissionId) {
58
+ return {
59
+ ok: false,
60
+ code: 'invalid-args',
61
+ message: 'This session is already bound to a commission — open a new session to work on another one',
62
+ };
63
+ }
64
+ const settled = (removedDraftDir) => ({
65
+ ok: true,
66
+ data: {
67
+ phase: 'none', commissionId: null, commissionDraft: null,
68
+ ...(removedDraftDir === undefined ? {} : { removedDraftDir }),
69
+ },
70
+ });
71
+ if (args.commission.mode === 'off') {
72
+ const left = await leaveCommissionDraft(args.sessionId);
73
+ if (left.ok === false)
74
+ return { ok: false, code: 'invalid-args', message: left.error };
75
+ deps.bus.publish({ type: 'session.commission', sessionId: args.sessionId, channel: session.channel });
76
+ return settled(left.removed);
77
+ }
78
+ if (args.commission.mode === 'join') {
79
+ const commission = await (deps.commissionStore ?? commissionRepo).find(args.commission.commissionId);
80
+ if (!commission) {
81
+ return { ok: false, code: 'not-found', message: `Commission not found: ${args.commission.commissionId}` };
82
+ }
83
+ if (commission.status !== 'active') {
84
+ return { ok: false, code: 'invalid-args', message: `Commission is ${commission.status}; only an active one accepts new sessions` };
85
+ }
86
+ // Joining mid-conversation is safe because the [Commission] block follows the binding rather
87
+ // than the session's first turn: the next turn carries the contract index (DR-0037 v4).
88
+ await sessionStore.bindCommission(args.sessionId, commission.id);
89
+ deps.bus.publish({ type: 'commission.updated', commissionId: commission.id, projectId: commission.projectId });
90
+ return { ok: true, data: { phase: 'active', commissionId: commission.id, commissionDraft: null } };
91
+ }
92
+ const entered = await enterCommissionDraft(args.sessionId);
93
+ if (entered.ok === false)
94
+ return { ok: false, code: 'invalid-args', message: entered.error };
95
+ if (!entered.alreadyDrafting) {
96
+ deps.bus.publish({ type: 'session.commission', sessionId: args.sessionId, channel: session.channel });
97
+ }
98
+ return { ok: true, data: { phase: 'draft', commissionId: null, commissionDraft: entered.draftDir } };
99
+ }
34
100
  export async function handleSendSession(deps, args) {
35
101
  if (!args.text.trim() && (!args.attachments || args.attachments.length === 0)) {
36
102
  return { ok: false, code: 'invalid-args', message: 'Either text or attachments required' };
37
103
  }
38
- if (deps.sessionStore.touchForUse && !(await deps.sessionStore.touchForUse(args.sessionId))) {
104
+ if (deps.sessionStore.touchSessionUse && !(await deps.sessionStore.touchSessionUse(args.sessionId))) {
39
105
  return { ok: false, code: 'not-found', message: `Session not found: ${args.sessionId}` };
40
106
  }
41
107
  const session = await deps.sessionStore.getById(args.sessionId);
@@ -111,6 +177,20 @@ export async function handleMarkReadSession(deps, args) {
111
177
  await deps.sessionStore.markRead?.(args.sessionId);
112
178
  return { ok: true, data: undefined };
113
179
  }
180
+ /** Batch mark-read behind the run list's「mark all read」. Deliberately forgiving: a session that
181
+ * no longer resolves (purged run, stale client list) is skipped instead of failing the batch —
182
+ * the user asked to clear what they see, and a half-stale list must still clear. */
183
+ export async function handleMarkManyReadSessions(deps, args) {
184
+ let marked = 0;
185
+ for (const sessionId of new Set(args.sessionIds)) {
186
+ const session = await deps.sessionStore.getById(sessionId);
187
+ if (!session)
188
+ continue;
189
+ await deps.sessionStore.markRead?.(sessionId);
190
+ marked += 1;
191
+ }
192
+ return { ok: true, data: { marked } };
193
+ }
114
194
  // Create a fresh session AND send the first message in one atomic operation. Used by the workbench
115
195
  // "New Conversation" draft flow (task 15b): the session is created only when the user sends their
116
196
  // first message, at which point the profile is already known and the backend is resolved correctly.
@@ -1,4 +1,6 @@
1
- import type { Result, SystemClearRateLimitArgs, SystemClearRateLimitReturn, SystemRefreshUsageArgs, SystemRefreshUsageReturn, SystemRestartArgs, SystemRestartReturn } from '../types.js';
1
+ import type { Result, SystemClearRateLimitArgs, SystemClearRateLimitReturn, SystemRefreshUsageArgs, SystemRefreshUsageReturn, SystemRestartArgs, SystemRestartReturn, SystemApplyUpdateArgs, SystemSkipUpdateArgs, SystemUpdateDecisionReturn } from '../types.js';
2
2
  export declare function handleSystemClearRateLimit(args: SystemClearRateLimitArgs): Promise<Result<SystemClearRateLimitReturn>>;
3
3
  export declare function handleSystemRefreshUsage(_args: SystemRefreshUsageArgs): Promise<Result<SystemRefreshUsageReturn>>;
4
4
  export declare function handleSystemRestart(args: SystemRestartArgs): Promise<Result<SystemRestartReturn>>;
5
+ export declare function handleSystemApplyUpdate(_args: SystemApplyUpdateArgs): Promise<Result<SystemUpdateDecisionReturn>>;
6
+ export declare function handleSystemSkipUpdate(_args: SystemSkipUpdateArgs): Promise<Result<SystemUpdateDecisionReturn>>;
@@ -4,6 +4,7 @@ import * as path from 'node:path';
4
4
  import { STORE_DIR } from '../../../core/paths.js';
5
5
  import { clearThrottle } from '../../costs/rate-limit-throttle.js';
6
6
  import { usageService } from '../../costs/usage-service.js';
7
+ import { answerServerUpdatePrompt, getServerUpdateStatus, } from '../../system/update-ui-state.js';
7
8
  function readChildPid() {
8
9
  const childPidFile = path.join(STORE_DIR, 'daemon-child.pid');
9
10
  try {
@@ -115,3 +116,15 @@ export async function handleSystemRestart(args) {
115
116
  };
116
117
  }
117
118
  }
119
+ // ── server self-update decisions ────────────────────────────────
120
+ // Both resolve the `ask()` the dialog is waiting on (domain/system/update-ui-state.ts). The
121
+ // install itself, and the skipped-version bookkeeping, stay in checkServerUpdate — these
122
+ // handlers only deliver the answer.
123
+ export async function handleSystemApplyUpdate(_args) {
124
+ const accepted = answerServerUpdatePrompt('apply');
125
+ return { ok: true, data: { accepted, status: getServerUpdateStatus() } };
126
+ }
127
+ export async function handleSystemSkipUpdate(_args) {
128
+ const accepted = answerServerUpdatePrompt('skip');
129
+ return { ok: true, data: { accepted, status: getServerUpdateStatus() } };
130
+ }
@@ -0,0 +1,2 @@
1
+ import type { Result, UiServiceDeps, WaitpointsCancelArgs, WaitpointsCancelReturn } from '../types.js';
2
+ export declare function handleCancelWaitpoint(deps: UiServiceDeps, args: WaitpointsCancelArgs): Promise<Result<WaitpointsCancelReturn>>;
@@ -0,0 +1,20 @@
1
+ // input: UiServiceDeps + WaitpointsCancelArgs
2
+ // output: handleCancelWaitpoint → Result<WaitpointsCancelReturn>
3
+ // pos: mutate handler for 'waitpoints.cancel' — the human escape hatch for a waitpoint whose
4
+ // signal is never coming. The state guard lives in the waitpoint service (a non-armed
5
+ // waitpoint refuses), so this handler only translates the outcome.
6
+ export async function handleCancelWaitpoint(deps, args) {
7
+ if (!deps.waitpointRegistry) {
8
+ return { ok: false, code: 'not-available', message: 'Waitpoints are not available on this server' };
9
+ }
10
+ try {
11
+ const outcome = await deps.waitpointRegistry.cancel(args.waitpointId);
12
+ if (!outcome.cancelled && !outcome.state) {
13
+ return { ok: false, code: 'not-found', message: `Waitpoint not found: ${args.waitpointId}` };
14
+ }
15
+ return { ok: true, data: { cancelled: outcome.cancelled, state: outcome.state ?? null } };
16
+ }
17
+ catch (err) {
18
+ return { ok: false, code: 'internal', message: err?.message || String(err) };
19
+ }
20
+ }