agl 43.2.0 → 43.3.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 (213) hide show
  1. package/changelog.md +29 -0
  2. package/dist_serve/bundle.js +2845 -2638
  3. package/dist_serve/bundle.js.map +2 -2
  4. package/dist_serve/bundle.js.third-party-notices.json +1 -1
  5. package/dist_serve/bundle.js.third-party-notices.txt +1 -1
  6. package/dist_ts/00_commitinfo_data.js +1 -1
  7. package/dist_ts/aglapi/aglapisurface.document.js +197 -17
  8. package/dist_ts/classes.accountsactions.d.ts +3 -1
  9. package/dist_ts/classes.accountsactions.js +21 -3
  10. package/dist_ts/classes.authstore.d.ts +7 -0
  11. package/dist_ts/classes.authstore.js +9 -1
  12. package/dist_ts/classes.claudeharness.d.ts +29 -2
  13. package/dist_ts/classes.claudeharness.js +35 -6
  14. package/dist_ts/classes.codexclientadapter.d.ts +11 -0
  15. package/dist_ts/classes.codexclientadapter.js +14 -2
  16. package/dist_ts/classes.controller.d.ts +187 -12
  17. package/dist_ts/classes.controller.js +1208 -186
  18. package/dist_ts/classes.controllerdevices.d.ts +2 -0
  19. package/dist_ts/classes.controllerdevices.js +6 -1
  20. package/dist_ts/classes.inbox.d.ts +72 -0
  21. package/dist_ts/classes.inbox.js +231 -0
  22. package/dist_ts/classes.inferencerouter.d.ts +10 -0
  23. package/dist_ts/classes.inferencerouter.js +5 -3
  24. package/dist_ts/classes.inferenceservice.js +2 -2
  25. package/dist_ts/classes.mcpclient.d.ts +1 -1
  26. package/dist_ts/classes.mcpclient.js +24 -6
  27. package/dist_ts/classes.mcpcontrollerhost.js +6 -1
  28. package/dist_ts/classes.mcptools.js +18 -8
  29. package/dist_ts/classes.mcpvalidation.d.ts +5 -0
  30. package/dist_ts/classes.mcpvalidation.js +32 -2
  31. package/dist_ts/classes.nativesessions.d.ts +29 -4
  32. package/dist_ts/classes.nativesessions.js +41 -9
  33. package/dist_ts/classes.opencodeclient.d.ts +23 -2
  34. package/dist_ts/classes.opencodeclient.js +47 -3
  35. package/dist_ts/classes.publishedset.d.ts +38 -0
  36. package/dist_ts/classes.publishedset.js +50 -0
  37. package/dist_ts/classes.sessionfeed.d.ts +3 -3
  38. package/dist_ts/classes.sessionfeed.js +18 -26
  39. package/dist_ts/classes.systemmetricssampler.d.ts +6 -0
  40. package/dist_ts/classes.systemmetricssampler.js +15 -3
  41. package/dist_ts/classes.ticketstore.d.ts +50 -3
  42. package/dist_ts/classes.ticketstore.js +45 -8
  43. package/dist_ts/classes.workercallers.js +4 -2
  44. package/dist_ts/driver/classes.directreports.d.ts +14 -4
  45. package/dist_ts/driver/classes.directreports.js +42 -23
  46. package/dist_ts/driver/classes.directreportstore.d.ts +8 -1
  47. package/dist_ts/driver/classes.directreportstore.js +20 -10
  48. package/dist_ts/driver/classes.driverservice.d.ts +44 -3
  49. package/dist_ts/driver/classes.driverservice.js +50 -16
  50. package/dist_ts/fleet/classes.claudeworkers.d.ts +21 -5
  51. package/dist_ts/fleet/classes.claudeworkers.js +142 -46
  52. package/dist_ts/fleet/classes.codexworkers.d.ts +16 -4
  53. package/dist_ts/fleet/classes.codexworkers.js +22 -5
  54. package/dist_ts/fleet/classes.workercommand.d.ts +6 -1
  55. package/dist_ts/fleet/classes.workercommand.js +15 -4
  56. package/dist_ts/fleet/classes.workers.d.ts +21 -1
  57. package/dist_ts/fleet/classes.workers.js +80 -40
  58. package/dist_ts/fleet/classes.workerstore.js +14 -8
  59. package/dist_ts/fleet/functions.unbounddrivers.js +2 -2
  60. package/dist_ts/fleet/functions.workervalidation.js +11 -4
  61. package/dist_ts/fleet/interfaces.workers.d.ts +27 -5
  62. package/dist_ts/fleet/interfaces.workers.js +8 -4
  63. package/dist_ts/functions.agentmessage.d.ts +3 -0
  64. package/dist_ts/functions.agentmessage.js +4 -1
  65. package/dist_ts/functions.deviceapi.d.ts +198 -4
  66. package/dist_ts/functions.deviceapi.js +1060 -38
  67. package/dist_ts/functions.exactpersistence.d.ts +3 -0
  68. package/dist_ts/functions.exactpersistence.js +4 -0
  69. package/dist_ts/functions.fleetworkercli.d.ts +1 -1
  70. package/dist_ts/functions.fleetworkercli.js +11 -8
  71. package/dist_ts/functions.inferencecli.js +3 -1
  72. package/dist_ts/functions.mcpfleetworkertools.js +3 -3
  73. package/dist_ts/functions.ticketactor.d.ts +17 -1
  74. package/dist_ts/functions.ticketactor.js +55 -15
  75. package/dist_ts/functions.ticketvalidation.js +11 -2
  76. package/dist_ts/interfaces.auth.d.ts +1 -1
  77. package/dist_ts/interfaces.auth.js +9 -1
  78. package/dist_ts/plugins.d.ts +3 -1
  79. package/dist_ts/plugins.js +7 -2
  80. package/dist_ts_authswitch/authority-contract.d.ts +25 -0
  81. package/dist_ts_authswitch/authority-contract.js +1 -1
  82. package/dist_ts_authswitch/authority-overview.d.ts +8 -0
  83. package/dist_ts_authswitch/authority-overview.js +17 -6
  84. package/dist_ts_authswitch/authority-placement.d.ts +20 -16
  85. package/dist_ts_authswitch/authority-placement.js +17 -10
  86. package/dist_ts_authswitch/authority-renewal.d.ts +34 -0
  87. package/dist_ts_authswitch/authority-renewal.js +56 -0
  88. package/dist_ts_authswitch/classes.authoritybroker.d.ts +8 -0
  89. package/dist_ts_authswitch/classes.authoritybroker.js +35 -2
  90. package/dist_ts_authswitch/classes.authoritycli.d.ts +1 -0
  91. package/dist_ts_authswitch/classes.authoritycli.js +44 -3
  92. package/dist_ts_authswitch/classes.authorityclient.d.ts +6 -1
  93. package/dist_ts_authswitch/classes.authorityclient.js +12 -4
  94. package/dist_ts_authswitch/classes.authoritydaemon.js +8 -1
  95. package/dist_ts_authswitch/classes.authoritydatabase.js +6 -2
  96. package/dist_ts_authswitch/classes.authoritymodels.d.ts +7 -0
  97. package/dist_ts_authswitch/classes.authoritymodels.js +21 -5
  98. package/dist_ts_interfaces/devices.d.ts +1027 -7
  99. package/dist_ts_interfaces/devices.js +68 -2
  100. package/dist_ts_interfaces/fleetworkers.d.ts +37 -10
  101. package/dist_ts_interfaces/fleetworkers.js +19 -8
  102. package/dist_ts_interfaces/inbox.d.ts +234 -0
  103. package/dist_ts_interfaces/inbox.js +101 -0
  104. package/dist_ts_interfaces/index.d.ts +1 -0
  105. package/dist_ts_interfaces/index.js +2 -1
  106. package/dist_ts_interfaces/interfaces.d.ts +10 -3
  107. package/dist_ts_interfaces/interfaces.js +4 -2
  108. package/dist_ts_interfaces/mcprequests.d.ts +34 -4
  109. package/dist_ts_interfaces/mcprequests.js +11 -1
  110. package/dist_ts_interfaces/mcpworkspacerequests.d.ts +4 -1
  111. package/dist_ts_interfaces/mcpworkspacerequests.js +1 -1
  112. package/dist_ts_interfaces/nativesessions.d.ts +16 -3
  113. package/dist_ts_interfaces/plugins.d.ts +2 -1
  114. package/dist_ts_interfaces/plugins.js +4 -2
  115. package/dist_ts_interfaces/requests.accounts.d.ts +21 -0
  116. package/dist_ts_interfaces/requests.accounts.js +3 -1
  117. package/dist_ts_interfaces/requests.d.ts +3 -2
  118. package/dist_ts_interfaces/requests.js +1 -1
  119. package/dist_ts_interfaces/workercallers.d.ts +2 -0
  120. package/dist_ts_migration/classes.documentmigrationrunner.d.ts +14 -0
  121. package/dist_ts_migration/classes.documentmigrationrunner.js +20 -1
  122. package/dist_ts_migration/index.d.ts +1 -0
  123. package/dist_ts_migration/index.js +2 -1
  124. package/dist_ts_migration/v43_ticketactornames.d.ts +32 -0
  125. package/dist_ts_migration/v43_ticketactornames.js +236 -0
  126. package/docs/authswitch.md +20 -1
  127. package/package.json +3 -3
  128. package/readme.md +144 -27
  129. package/ts/00_commitinfo_data.ts +1 -1
  130. package/ts/aglapi/aglapisurface.document.ts +196 -16
  131. package/ts/classes.accountsactions.ts +30 -3
  132. package/ts/classes.authstore.ts +10 -0
  133. package/ts/classes.claudeharness.ts +45 -5
  134. package/ts/classes.codexclientadapter.ts +14 -1
  135. package/ts/classes.controller.ts +1412 -262
  136. package/ts/classes.controllerdevices.ts +6 -0
  137. package/ts/classes.inbox.ts +239 -0
  138. package/ts/classes.inferencerouter.ts +15 -2
  139. package/ts/classes.inferenceservice.ts +1 -1
  140. package/ts/classes.mcpclient.ts +24 -3
  141. package/ts/classes.mcpcontrollerhost.ts +5 -0
  142. package/ts/classes.mcptools.ts +17 -7
  143. package/ts/classes.mcpvalidation.ts +27 -1
  144. package/ts/classes.nativesessions.ts +63 -12
  145. package/ts/classes.opencodeclient.ts +55 -4
  146. package/ts/classes.publishedset.ts +56 -0
  147. package/ts/classes.sessionfeed.ts +17 -20
  148. package/ts/classes.systemmetricssampler.ts +13 -2
  149. package/ts/classes.ticketstore.ts +73 -12
  150. package/ts/classes.workercallers.ts +3 -1
  151. package/ts/driver/classes.directreports.ts +42 -23
  152. package/ts/driver/classes.directreportstore.ts +20 -9
  153. package/ts/driver/classes.driverservice.ts +75 -14
  154. package/ts/fleet/classes.claudeworkers.ts +112 -39
  155. package/ts/fleet/classes.codexworkers.ts +21 -6
  156. package/ts/fleet/classes.workercommand.ts +14 -4
  157. package/ts/fleet/classes.workers.ts +75 -41
  158. package/ts/fleet/classes.workerstore.ts +11 -7
  159. package/ts/fleet/functions.unbounddrivers.ts +1 -1
  160. package/ts/fleet/functions.workervalidation.ts +8 -3
  161. package/ts/fleet/interfaces.workers.ts +26 -7
  162. package/ts/functions.agentmessage.ts +3 -0
  163. package/ts/functions.deviceapi.ts +1292 -34
  164. package/ts/functions.exactpersistence.ts +5 -0
  165. package/ts/functions.fleetworkercli.ts +10 -7
  166. package/ts/functions.inferencecli.ts +2 -0
  167. package/ts/functions.mcpfleetworkertools.ts +2 -2
  168. package/ts/functions.ticketactor.ts +58 -14
  169. package/ts/functions.ticketvalidation.ts +11 -1
  170. package/ts/interfaces.auth.ts +8 -0
  171. package/ts/plugins.ts +7 -0
  172. package/ts_authswitch/authority-contract.ts +20 -0
  173. package/ts_authswitch/authority-overview.ts +28 -6
  174. package/ts_authswitch/authority-placement.ts +25 -17
  175. package/ts_authswitch/authority-renewal.ts +64 -0
  176. package/ts_authswitch/classes.authoritybroker.ts +34 -1
  177. package/ts_authswitch/classes.authoritycli.ts +49 -2
  178. package/ts_authswitch/classes.authorityclient.ts +14 -4
  179. package/ts_authswitch/classes.authoritydaemon.ts +9 -1
  180. package/ts_authswitch/classes.authoritydatabase.ts +5 -1
  181. package/ts_authswitch/classes.authoritymodels.ts +23 -3
  182. package/ts_authswitch/native-contracts.md +21 -0
  183. package/ts_authswitch/readme.md +1 -1
  184. package/ts_interfaces/devices.schema.json +3576 -603
  185. package/ts_interfaces/devices.ts +1111 -6
  186. package/ts_interfaces/fleetworkers.ts +38 -10
  187. package/ts_interfaces/inbox.ts +287 -0
  188. package/ts_interfaces/index.ts +1 -0
  189. package/ts_interfaces/interfaces.ts +9 -2
  190. package/ts_interfaces/mcprequests.ts +43 -4
  191. package/ts_interfaces/mcpworkspacerequests.ts +4 -2
  192. package/ts_interfaces/nativesessions.ts +17 -3
  193. package/ts_interfaces/plugins.ts +3 -1
  194. package/ts_interfaces/requests.accounts.ts +20 -0
  195. package/ts_interfaces/requests.ts +4 -0
  196. package/ts_interfaces/workercallers.ts +2 -0
  197. package/ts_migration/classes.documentmigrationrunner.ts +21 -0
  198. package/ts_migration/index.ts +1 -0
  199. package/ts_migration/v43_ticketactornames.ts +225 -0
  200. package/ts_web/00_commitinfo_data.ts +1 -1
  201. package/ts_web/accounts.plugins.ts +4 -2
  202. package/ts_web/classes.accountsreadmodel.ts +33 -0
  203. package/ts_web/classes.browserpresentation.ts +10 -5
  204. package/ts_web/classes.inboxfeed.ts +329 -0
  205. package/ts_web/classes.nativesessionstate.ts +9 -23
  206. package/ts_web/elements.accounts.ts +81 -0
  207. package/ts_web/elements.deployments.ts +66 -2
  208. package/ts_web/elements.fleetworker.ts +4 -2
  209. package/ts_web/elements.harnesscontrollerapp.ts +107 -37
  210. package/ts_web/elements.inbox.ts +808 -0
  211. package/ts_web/functions.inbox.ts +95 -0
  212. package/ts_web/functions.sessioncards.ts +40 -0
  213. package/ts_web/plugins.ts +2 -0
@@ -3,9 +3,11 @@ import type { IFleetWorker } from '../ts_interfaces/fleetworkers.js';
3
3
  import type {
4
4
  IControllerNativeSession,
5
5
  IControllerNativeSessionRef,
6
+ TControllerNativeJobDelivery,
6
7
  TControllerNativeSessionReadOnlyReason,
7
8
  } from '../ts_interfaces/index.js';
8
9
  import type { IFleetNativeAgent, IFleetNativeSession, IFleetNativeThread } from './fleet/interfaces.workers.js';
10
+ import type { TClaudeDispatchRefusal } from './classes.claudeharness.js';
9
11
 
10
12
  /** Where the resolver finds native sessions: exactly the sources the session feed lists, never a path a caller names. */
11
13
  export interface INativeSessionSources {
@@ -26,6 +28,18 @@ export interface INativeSessionSources {
26
28
  directoryExists(path: string): Promise<boolean>;
27
29
  }
28
30
 
31
+ /**
32
+ * The data of a failed native session operation (`native_session_failed`), which says what it did: `refused`, nothing
33
+ * reached the session (an operation that sends it nothing, such as a read, or a send or answer refused before it went
34
+ * out, with `refusal` when a busy conversation or host refused it); `unknown`, the send or answer went out, or may have,
35
+ * and its effect is unknown.
36
+ */
37
+ export interface INativeSessionFailedErrorData {
38
+ code: 'native_session_failed';
39
+ outcome: 'refused' | 'unknown';
40
+ refusal?: TClaudeDispatchRefusal;
41
+ }
42
+
29
43
  /** A native session as the resolver found it in one of its sources. */
30
44
  export interface IResolvedNativeSession {
31
45
  session: IControllerNativeSession;
@@ -34,14 +48,21 @@ export interface IResolvedNativeSession {
34
48
  scope: { profileId: string | null };
35
49
  worker?: IFleetWorker;
36
50
  /**
37
- * A Claude Code background job holds the session: a send wakes the job through Claude Code itself, never AGL's own
38
- * Claude Code, so the job stays its owner.
51
+ * A Claude Code background job holds the session: a send reaches the job through Claude Code itself, never AGL's own
52
+ * Claude Code, so the job stays its owner. It wakes a settled job, and goes into a running job's inbox.
39
53
  */
40
- claudeJob?: true;
54
+ claudeJob?: TControllerNativeJobDelivery;
55
+ /**
56
+ * For a running job's inbox: the fleet profile homes apart from the host's own, whose running sessions SendMessage
57
+ * reaches by name too; the send checks the job's name against them again at dispatch (`IFleetNativeSession.peerHomes`).
58
+ */
59
+ peerHomes?: string[];
41
60
  }
42
61
 
43
- const readOnlyMessages: Record<TControllerNativeSessionReadOnlyReason, string> = {
62
+ export const nativeSessionReadOnlyMessages: Record<TControllerNativeSessionReadOnlyReason, string> = {
44
63
  running: 'Another Claude Code process runs this session. AGL never becomes its second writer; the composer unlocks once it settles.',
64
+ unaddressable: 'This Claude Code background job runs, and Claude Code\'s SendMessage reaches a running job only by a session name no other running session shares; this one has no name or shares it. The composer unlocks once it settles.',
65
+ notBackgroundJob: 'This Claude Code session is no background job (`claude --bg`): agents reach only background jobs. The owner sends to it from its native session view in AGL.',
45
66
  profileHome: 'This session lives in a fleet profile\'s Claude Code home, which AGL\'s own Claude Code does not resume. It stays read-only here.',
46
67
  directoryMissing: 'The session\'s directory is missing, so nothing can resume it. It stays read-only.',
47
68
  projectConversation: 'An AGL project conversation holds this Claude Code session. Send to it from its project.',
@@ -124,11 +145,16 @@ export class NativeSessions {
124
145
  const cwd = agent?.cwd ?? boundWorker!.cwd;
125
146
  const own = home === undefined || samePath(home, this.sources.ownClaudeHome());
126
147
  const held = this.sources.claudeHeld(refArg.nativeId);
127
- const running = held === undefined && agent !== undefined
128
- && (agent.pid !== undefined || agent.state === 'working' || agent.status === 'busy');
129
148
  const job = agent?.kind === 'background';
130
- // A failed job is not woken unverified; one AGL's own Claude Code holds would be woken as a copy.
131
- const jobReason = !job ? undefined : agent.state === 'failed' ? 'jobFailed' as const : held ? 'jobHeld' as const : undefined;
149
+ // A running background job takes a message in its inbox, through Claude Code's own SendMessage: no second writer.
150
+ const inbox = job && held === undefined && agent.pid !== undefined && agent.status !== undefined
151
+ && agent.state !== 'failed' && agent.state !== 'stopped';
152
+ const running = held === undefined && agent !== undefined && !inbox
153
+ && (agent.pid !== undefined || agent.state === 'working' || agent.status === 'busy');
154
+ // A failed job is not woken unverified; one AGL's own Claude Code holds would be woken as a copy; SendMessage
155
+ // addresses a running job by a name no other running session of any listed home shares, never by a guess.
156
+ const jobReason = !job ? undefined : agent.state === 'failed' ? 'jobFailed' as const : held ? 'jobHeld' as const
157
+ : inbox && !await this.uniquelyNamed(agent, profiles) ? 'unaddressable' as const : undefined;
132
158
  const reason = await this.readOnlyReason(cwd, boundWorker, !own, running,
133
159
  own && await this.sources.claudeProjectConversation(refArg.nativeId), jobReason);
134
160
  const status: IControllerNativeSession['status'] = held
@@ -146,15 +172,40 @@ export class NativeSessions {
146
172
  status,
147
173
  ...(agent?.startedAt === undefined ? {} : { updatedAt: agent.startedAt }),
148
174
  ...this.workerFields(boundWorker),
149
- ...(reason === undefined ? {} : { readOnly: { reason, message: readOnlyMessages[reason] } }),
175
+ ...(reason === undefined ? {} : { readOnly: { reason, message: nativeSessionReadOnlyMessages[reason] } }),
176
+ ...(job && reason === undefined ? { jobDelivery: inbox ? 'inbox' as const : 'wake' as const } : {}),
150
177
  },
151
178
  native: { nativeId: refArg.nativeId, cwd, ...(own ? {} : { home }) },
152
179
  scope: { profileId: own ? null : scopeProfile ?? null },
153
180
  ...(boundWorker ? { worker: boundWorker } : {}),
154
- ...(job ? { claudeJob: true as const } : {}),
181
+ ...(job ? { claudeJob: inbox ? 'inbox' as const : 'wake' as const } : {}),
182
+ // A profile home's job is read-only (`profileHome`), so only an inbox of the host's own home is ever addressed.
183
+ ...(own && inbox ? { peerHomes: this.peerHomes(profiles) } : {}),
155
184
  };
156
185
  }
157
186
 
187
+ /**
188
+ * Whether the running session `agentArg` is the only running session of that name in the host's inventory and every
189
+ * fleet profile home's: Claude Code's SendMessage resolves a recipient by its name among the sessions it can reach.
190
+ */
191
+ private async uniquelyNamed(agentArg: IFleetNativeAgent, profilesArg: Array<{ profileId: string; home: string }>): Promise<boolean> {
192
+ if (!agentArg.name) return false;
193
+ let named = 0;
194
+ for (const home of [undefined, ...this.peerHomes(profilesArg)]) {
195
+ named += (await this.sources.claudeAgents(home)).filter((entry) => entry.pid !== undefined && entry.name === agentArg.name).length;
196
+ }
197
+ return named === 1;
198
+ }
199
+
200
+ /** The fleet profile homes apart from the host's own, each once. */
201
+ private peerHomes(profilesArg: Array<{ profileId: string; home: string }>): string[] {
202
+ const own = this.sources.ownClaudeHome(), homes: string[] = [];
203
+ for (const { home } of profilesArg) {
204
+ if (!samePath(home, own) && !homes.some((entry) => samePath(entry, home))) homes.push(home);
205
+ }
206
+ return homes;
207
+ }
208
+
158
209
  private async resolveCodex(refArg: IControllerNativeSessionRef): Promise<IResolvedNativeSession> {
159
210
  if (refArg.profileId !== undefined) throw nativeSessionNotFound();
160
211
  const [threads, worker] = await Promise.all([
@@ -174,7 +225,7 @@ export class NativeSessions {
174
225
  status: thread === undefined ? 'idle' : thread.status === 'busy' || thread.status === 'waiting' ? 'busy' : thread.status,
175
226
  ...(thread === undefined ? {} : { updatedAt: thread.updatedAt }),
176
227
  ...this.workerFields(worker),
177
- ...(reason === undefined ? {} : { readOnly: { reason, message: readOnlyMessages[reason] } }),
228
+ ...(reason === undefined ? {} : { readOnly: { reason, message: nativeSessionReadOnlyMessages[reason] } }),
178
229
  },
179
230
  native: { nativeId: refArg.nativeId, cwd },
180
231
  scope: { profileId: null },
@@ -193,7 +244,7 @@ export class NativeSessions {
193
244
  profileHomeArg: boolean,
194
245
  runningArg: boolean,
195
246
  projectConversationArg: boolean,
196
- jobArg?: 'jobFailed' | 'jobHeld',
247
+ jobArg?: 'jobFailed' | 'jobHeld' | 'unaddressable',
197
248
  ): Promise<TControllerNativeSessionReadOnlyReason | undefined> {
198
249
  if (!await this.sources.directoryExists(cwdArg)) return 'directoryMissing';
199
250
  if (projectConversationArg) return 'projectConversation';
@@ -1286,7 +1286,11 @@ export const createBoundedOpenCodeSelectedMessageSlice = (
1286
1286
  throw new Error('Selected OpenCode message shells exceeded the aggregate output budget.');
1287
1287
  };
1288
1288
 
1289
- export const normalizeOpenCodePermissions = (value: unknown): IControllerPermission[] => {
1289
+ /** A pending request as OpenCode lists it, which carries no time: the adapter adds when it entered (`createdAt`). */
1290
+ export type TOpenCodePendingPermission = Omit<IControllerPermission, 'createdAt'>;
1291
+ export type TOpenCodePendingQuestion = Omit<IControllerQuestion, 'createdAt'>;
1292
+
1293
+ export const normalizeOpenCodePermissions = (value: unknown): TOpenCodePendingPermission[] => {
1290
1294
  if (!Array.isArray(value) || value.length > maxCollectionEntries) {
1291
1295
  throw new Error('OpenCode returned an invalid permission list.');
1292
1296
  }
@@ -1337,7 +1341,7 @@ export const normalizeOpenCodePermissions = (value: unknown): IControllerPermiss
1337
1341
  return result;
1338
1342
  };
1339
1343
 
1340
- export const normalizeOpenCodeQuestions = (value: unknown): IControllerQuestion[] => {
1344
+ export const normalizeOpenCodeQuestions = (value: unknown): TOpenCodePendingQuestion[] => {
1341
1345
  if (!Array.isArray(value) || value.length > maxCollectionEntries) {
1342
1346
  throw new Error('OpenCode returned an invalid question list.');
1343
1347
  }
@@ -1626,6 +1630,20 @@ const openCodeTurnRefusalText = (errorArg: unknown): string | undefined => {
1626
1630
  return Buffer.byteLength(text, 'utf8') <= maxTurnRefusalBytes ? text : `${truncateUtf8(text, maxTurnRefusalBytes)}…`;
1627
1631
  };
1628
1632
 
1633
+ /** At most this many pending requests keep the time they entered. */
1634
+ const maxPendingSinceEntries = 4096;
1635
+
1636
+ /** The permission or question an `asked` event announces: the time it entered OpenCode's pending requests is now. */
1637
+ export const openCodeAskedRequest = (valueArg: unknown): { directory: string; kind: 'permission' | 'question'; id: string } | undefined => {
1638
+ if (!isRecord(valueArg) || typeof valueArg.directory !== 'string' || !isRecord(valueArg.payload)) return undefined;
1639
+ const { type, properties } = valueArg.payload;
1640
+ const kind = type === 'permission.asked' || type === 'permission.v2.asked' ? 'permission'
1641
+ : type === 'question.asked' || type === 'question.v2.asked' ? 'question' : undefined;
1642
+ if (!kind || !isRecord(properties) || typeof properties.id !== 'string' || properties.id.length === 0
1643
+ || Buffer.byteLength(properties.id, 'utf8') > maxIdentifierBytes) return undefined;
1644
+ return { directory: valueArg.directory, kind, id: properties.id };
1645
+ };
1646
+
1629
1647
  const normalizeEvent = (
1630
1648
  value: unknown,
1631
1649
  ): TNormalizedOpenCodeEvent | undefined => {
@@ -1863,6 +1881,11 @@ export class OpenCodeClientAdapter implements IOpenCodeSessionIdentitySnapshotCa
1863
1881
  private eventTask?: Promise<void>;
1864
1882
  private readonly runtimeRequestAbortController = new AbortController();
1865
1883
  private readonly temporarySessionIds = new Set<string>();
1884
+ /**
1885
+ * When each pending permission and question entered OpenCode's pending requests, as this adapter first heard of it
1886
+ * (its `asked` event, or the first list that held it): OpenCode's requests carry no time of their own.
1887
+ */
1888
+ private readonly pendingSince = new Map<string, { at: number; directory: string }>();
1866
1889
  /** The message AGL last sent each session, by session ID: a refusal that follows is that message's. */
1867
1890
  private readonly lastSentMessageIds = new Map<string, string>();
1868
1891
  /** Why OpenCode refused a message AGL sent, by session ID and message ID (`openCodeTurnRefusalText`). */
@@ -3192,6 +3215,32 @@ export class OpenCodeClientAdapter implements IOpenCodeSessionIdentitySnapshotCa
3192
3215
  }
3193
3216
  }
3194
3217
 
3218
+ /** Records that the request `idArg` of `kindArg` entered OpenCode's pending requests now, unless it was seen before. */
3219
+ private notePendingRequest(directoryArg: string, kindArg: 'permission' | 'question', idArg: string): number {
3220
+ const key = `${kindArg}:${idArg}`;
3221
+ const seen = this.pendingSince.get(key);
3222
+ if (seen) return seen.at;
3223
+ const at = Date.now();
3224
+ rememberNewest(this.pendingSince, key, { at, directory: directoryArg }, maxPendingSinceEntries);
3225
+ return at;
3226
+ }
3227
+
3228
+ /**
3229
+ * The directory's whole pending list of `kindArg` with the time each request entered it. The requests of the
3230
+ * directory that the list no longer holds are forgotten.
3231
+ */
3232
+ private withPendingSince<TRequest extends { id: IControllerRuntimeId }>(
3233
+ directoryArg: string,
3234
+ kindArg: 'permission' | 'question',
3235
+ requestsArg: TRequest[],
3236
+ ): Array<TRequest & { createdAt: number }> {
3237
+ const listed = new Set(requestsArg.map((requestArg) => `${kindArg}:${requestArg.id.nativeId}`));
3238
+ for (const [key, entry] of this.pendingSince) {
3239
+ if (entry.directory === directoryArg && key.startsWith(`${kindArg}:`) && !listed.has(key)) this.pendingSince.delete(key);
3240
+ }
3241
+ return requestsArg.map((requestArg) => ({ ...requestArg, createdAt: this.notePendingRequest(directoryArg, kindArg, requestArg.id.nativeId) }));
3242
+ }
3243
+
3195
3244
  public async listPermissions(
3196
3245
  directoryArg: string,
3197
3246
  sessionId?: string,
@@ -3208,7 +3257,7 @@ export class OpenCodeClientAdapter implements IOpenCodeSessionIdentitySnapshotCa
3208
3257
  { signal: requestSignal }
3209
3258
  )
3210
3259
  );
3211
- const permissions = normalizeOpenCodePermissions(response);
3260
+ const permissions = this.withPendingSince(directory, 'permission', normalizeOpenCodePermissions(response));
3212
3261
  return validatedSessionId
3213
3262
  ? permissions.filter((permission) => permission.sessionId.nativeId === validatedSessionId)
3214
3263
  : permissions;
@@ -3230,7 +3279,7 @@ export class OpenCodeClientAdapter implements IOpenCodeSessionIdentitySnapshotCa
3230
3279
  { signal: requestSignal }
3231
3280
  )
3232
3281
  );
3233
- const questions = normalizeOpenCodeQuestions(response);
3282
+ const questions = this.withPendingSince(directory, 'question', normalizeOpenCodeQuestions(response));
3234
3283
  return validatedSessionId
3235
3284
  ? questions.filter((question) => question.sessionId.nativeId === validatedSessionId)
3236
3285
  : questions;
@@ -4356,6 +4405,8 @@ export class OpenCodeClientAdapter implements IOpenCodeSessionIdentitySnapshotCa
4356
4405
  }
4357
4406
  }
4358
4407
 
4408
+ const asked = openCodeAskedRequest(event);
4409
+ if (asked) this.notePendingRequest(asked.directory, asked.kind, asked.id);
4359
4410
  const normalized = normalizeEvent(event);
4360
4411
  if (!normalized) continue;
4361
4412
  if ('toolStreamGap' in normalized) {
@@ -0,0 +1,56 @@
1
+ import * as plugins from './plugins.js';
2
+
3
+ /**
4
+ * One published change of a `PublishedSet`: the values that are new or changed and the ids that left, or `reset` when
5
+ * more changed than a delta carries, after which a client lists the set again.
6
+ */
7
+ export type TPublishedSetDelta<TValue> = { epoch: string; revision: number } & (
8
+ | { upserts: TValue[]; removed: string[] }
9
+ | { reset: true }
10
+ );
11
+
12
+ /**
13
+ * What a read model last published, by id, in its order, and the deltas between two publications: the one diff the
14
+ * session feed and the Inbox publish their changes with. `epoch` names this process's set, `revision` counts its
15
+ * publications; a client applies a delta only on its epoch at the next revision.
16
+ */
17
+ export class PublishedSet<TValue extends { id: string }> {
18
+ public readonly epoch = plugins.crypto.randomUUID();
19
+ private revisionValue = 0;
20
+ private entries = new Map<string, { value: TValue; json: string }>();
21
+
22
+ /** A change of more than `deltaLimitArg` values publishes a reset. */
23
+ constructor(private readonly deltaLimitArg: number) {}
24
+
25
+ public get revision(): number {
26
+ return this.revisionValue;
27
+ }
28
+
29
+ /** The published values, in the order they were published. */
30
+ public values(): TValue[] {
31
+ return [...this.entries.values()].map((entryArg) => entryArg.value);
32
+ }
33
+
34
+ public get(idArg: string): TValue | undefined {
35
+ return this.entries.get(idArg)?.value;
36
+ }
37
+
38
+ /**
39
+ * Publishes `valuesArg` in their order and answers the delta from the previous publication, or `undefined` when no
40
+ * value changed, came or left and `changedArg` (a change beside the values, such as a count) is not set. A read
41
+ * model whose order follows from its values' fields never reorders without a changed value.
42
+ */
43
+ public publish(valuesArg: readonly TValue[], changedArg = false): TPublishedSetDelta<TValue> | undefined {
44
+ const next = new Map(valuesArg.map((valueArg) => [valueArg.id, { value: valueArg, json: JSON.stringify(valueArg) }]));
45
+ const upserts: TValue[] = [];
46
+ const removed: string[] = [];
47
+ for (const [id, entry] of next) if (this.entries.get(id)?.json !== entry.json) upserts.push(entry.value);
48
+ for (const id of this.entries.keys()) if (!next.has(id)) removed.push(id);
49
+ // Insertion order is the order `values()` returns.
50
+ this.entries = next;
51
+ if (upserts.length === 0 && removed.length === 0 && !changedArg) return undefined;
52
+ this.revisionValue += 1;
53
+ const base = { epoch: this.epoch, revision: this.revisionValue };
54
+ return upserts.length + removed.length > this.deltaLimitArg ? { ...base, reset: true } : { ...base, upserts, removed };
55
+ }
56
+ }
@@ -1,6 +1,7 @@
1
1
  import * as plugins from './plugins.js';
2
2
  import { resolveControllerTerminalAgentTranscript } from './functions.terminalagents.js';
3
3
  import { codexQualifiedIdentity } from './functions.codexidentity.js';
4
+ import { PublishedSet } from './classes.publishedset.js';
4
5
  import { fleetClaudeNativeWait, type IFleetNativeAgent, type IFleetNativeThread } from './fleet/interfaces.workers.js';
5
6
  import {
6
7
  controllerSessionFeedExcerpt,
@@ -218,9 +219,7 @@ interface IRowDraft {
218
219
  */
219
220
  export class SessionFeed {
220
221
  private readonly abort = new AbortController();
221
- private readonly epoch = plugins.crypto.randomUUID();
222
- private revision = 0;
223
- private published = new Map<string, { row: IControllerSessionFeedRow; json: string }>();
222
+ private readonly published = new PublishedSet<IControllerSessionFeedRow>(controllerSessionFeedLimits.deltaRows);
224
223
  private readonly options: Required<Omit<ISessionFeedOptions, 'maxAgeMs'>> & { maxAgeMs: Record<TSessionFeedSource, number> };
225
224
 
226
225
  private conversations: ISessionFeedConversation[] = [];
@@ -295,19 +294,24 @@ export class SessionFeed {
295
294
  public async list(): Promise<IReq_ControllerSessionFeedList['response']> {
296
295
  this.abort.signal.throwIfAborted();
297
296
  await this.flush(true);
298
- return { epoch: this.epoch, revision: this.revision, rows: [...this.published.values()].map((entry) => entry.row) };
297
+ return { epoch: this.published.epoch, revision: this.published.revision, rows: this.published.values() };
298
+ }
299
+
300
+ /** The rows as the feed published them last, newest first, without reading anything. */
301
+ public publishedRows(): IControllerSessionFeedRow[] {
302
+ return this.published.values();
299
303
  }
300
304
 
301
305
  /** A row as the feed published it last, without reading anything: what events about the session may name. */
302
306
  public publishedRow(rowIdArg: string): IControllerSessionFeedRow | undefined {
303
- return this.published.get(rowIdArg)?.row;
307
+ return this.published.get(rowIdArg);
304
308
  }
305
309
 
306
310
  /** A row after reading every stale source, as `list()` reads; undefined while the feed does not list it. */
307
311
  public async find(rowIdArg: string): Promise<IControllerSessionFeedRow | undefined> {
308
312
  this.abort.signal.throwIfAborted();
309
313
  await this.flush(true);
310
- return this.published.get(rowIdArg)?.row;
314
+ return this.published.get(rowIdArg);
311
315
  }
312
316
 
313
317
  /**
@@ -321,7 +325,7 @@ export class SessionFeed {
321
325
  const run = this.acknowledging.catch(() => undefined).then(async () => {
322
326
  const acknowledged = await this.readAcknowledgements();
323
327
  if (acknowledged.get(rowIdArg) === updatedAtArg) return;
324
- const row = this.published.get(rowIdArg)?.row;
328
+ const row = this.published.get(rowIdArg);
325
329
  if (!row) throw new SessionFeedAcknowledgementError('sessionfeed_row_not_found', 'The session feed lists no such row; list the feed again.');
326
330
  if (row.state !== 'failed') throw new SessionFeedAcknowledgementError('sessionfeed_row_not_failed', 'Only a failed row can be acknowledged.');
327
331
  if (row.updatedAt !== updatedAtArg) {
@@ -371,6 +375,10 @@ export class SessionFeed {
371
375
  }
372
376
  return;
373
377
  }
378
+ // A permission, question or MCP form a harness holds came or went: the conversation may need input, or no longer.
379
+ case 'permissions.changed':
380
+ this.markStale('conversations', 'projects');
381
+ return;
374
382
  case 'fleet.workers.changed':
375
383
  this.markStale('fleet');
376
384
  return;
@@ -732,19 +740,8 @@ export class SessionFeed {
732
740
  }
733
741
 
734
742
  private publish(rowsArg: IControllerSessionFeedRow[]): void {
735
- const next = new Map(rowsArg.map((row) => [row.id, { row, json: JSON.stringify(row) }]));
736
- const upserts: IControllerSessionFeedRow[] = [];
737
- const removed: string[] = [];
738
- for (const [id, entry] of next) if (this.published.get(id)?.json !== entry.json) upserts.push(entry.row);
739
- for (const id of this.published.keys()) if (!next.has(id)) removed.push(id);
740
- // Insertion order is the list order `list()` returns.
741
- this.published = next;
742
- if (upserts.length === 0 && removed.length === 0) return;
743
- this.revision += 1;
744
- const base = { epoch: this.epoch, revision: this.revision };
745
- this.sources.publish(upserts.length + removed.length > controllerSessionFeedLimits.deltaRows
746
- ? { ...base, reset: true }
747
- : { ...base, upserts, removed });
743
+ const delta = this.published.publish(rowsArg);
744
+ if (delta) this.sources.publish(delta);
748
745
  }
749
746
 
750
747
  private report(sourceArg: string, errorArg: unknown): void {
@@ -521,6 +521,12 @@ export class SystemMetricsSampler {
521
521
  }
522
522
  }
523
523
 
524
+ /**
525
+ * Retires the sampler and drains its source. The source's own stop lets every probe in flight finish
526
+ * (smartsystem ≥ 4.0.2: up to its request deadline) and rejects naming the probe workers that are hung or
527
+ * failed; that rejection reaches the caller unchanged. A rejected stop is not kept: the next call asks the
528
+ * source again, which no longer names a hung worker that has exited since.
529
+ */
524
530
  public stop(): Promise<void> {
525
531
  if (this.stopPromise) return this.stopPromise;
526
532
  this.stopped = true;
@@ -528,12 +534,17 @@ export class SystemMetricsSampler {
528
534
  this.recordingTimer = undefined;
529
535
  this.recorder = undefined;
530
536
  this.cachedSample = undefined;
531
- this.stopPromise = (async () => {
537
+ const stopping = (async () => {
532
538
  await this.recordingPromise?.catch(() => undefined);
533
539
  await this.inFlightSample?.catch(() => undefined);
534
540
  await this.source.stop?.();
535
541
  })();
536
- return this.stopPromise;
542
+ this.stopPromise = stopping;
543
+ // Every caller receives `stopping` itself and owns its rejection; this handler only forgets it.
544
+ void stopping.catch(() => {
545
+ if (this.stopPromise === stopping) this.stopPromise = undefined;
546
+ });
547
+ return stopping;
537
548
  }
538
549
 
539
550
  private async readFreshSample(): Promise<IControllerSystemMetrics> {
@@ -3,7 +3,7 @@ import {
3
3
  isTicketAutoLabel, ticketColumns, ticketDoneColumns, ticketErrorMessages, type ITicket, type ITicketActor, type ITicketActivity, type ITicketBoard,
4
4
  type ITicketChanges, type ITicketCreate, type ITicketFilters, type ITicketMove, type ITicketPerson, type ITicketQuestion,
5
5
  type TTicketLink, type TTicketOperation, type TTicketRequest, type TTicketResponse,
6
- type TTicketFleetEvent, type ITicketFleetEventResult, type ITicketComment, type TTicketData, type ITicketOpenQuestion,
6
+ type TTicketFleetEvent, type ITicketFleetEventResult, type ITicketComment, type TTicketData, type ITicketOpenQuestion, type TTicketAutoLabel,
7
7
  type ITicketDetail, type ITicketGet, type ITicketAsk, type ITicketMaintenanceWindow, ticketHistoryPage,
8
8
  } from '../ts_interfaces/tickets.js';
9
9
  import {
@@ -57,8 +57,16 @@ interface ITicketTrack {
57
57
  refusal?: ITicketChange;
58
58
  }
59
59
 
60
+ /**
61
+ * Every code a `TicketError` carries: a refusal `ticketErrorMessages` explains, a concurrent change the transaction
62
+ * lost (`concurrent_change`, nothing written), a transaction whose commit outcome is unknown (`outcome_unknown`), a
63
+ * fleet event key that names another request, and an owner capability the controller could not verify.
64
+ */
65
+ export type TTicketErrorCode = keyof typeof ticketErrorMessages | 'concurrent_change' | 'outcome_unknown'
66
+ | 'ticket_fleet_event_conflict' | 'unauthorized';
67
+
60
68
  export class TicketError extends Error {
61
- constructor(public readonly code: string, messageArg: string, public readonly currentRevision?: number) {
69
+ constructor(public readonly code: TTicketErrorCode, messageArg: string, public readonly currentRevision?: number) {
62
70
  super(messageArg);
63
71
  this.name = 'TicketError';
64
72
  }
@@ -69,6 +77,55 @@ export const ticketAssignedTo = (ticketArg: TTicketData, actorArg: ITicketActor)
69
77
  ? actorArg.sessionId !== undefined && (ticketArg.assignee?.sessionId ?? ticketArg.assignee?.id) === actorArg.sessionId
70
78
  : ticketArg.assignee?.id === actorArg.id
71
79
  );
80
+
81
+ /**
82
+ * The filters of a listing (`list`, `board`, `search`) as one predicate over the tickets `visible` shows (AutoLabels
83
+ * computed): mine (assigned to `actorArg`), a project, a column, a hand label or an AutoLabel, and text in the key,
84
+ * title, description or source words, ignoring case.
85
+ */
86
+ export const ticketFilter = (filtersArg: ITicketFilters, actorArg: ITicketActor | undefined): (ticketArg: ITicket) => boolean => {
87
+ const text = filtersArg.text?.toLocaleLowerCase();
88
+ return (ticketArg) => (
89
+ (!filtersArg.mine || (actorArg !== undefined && ticketAssignedTo(ticketArg, actorArg)))
90
+ && (!filtersArg.project || ticketArg.project === filtersArg.project)
91
+ && (!filtersArg.status || ticketArg.columnId === filtersArg.status)
92
+ && (!filtersArg.label || ticketArg.labels.includes(filtersArg.label) || (ticketArg.autoLabels ?? []).some((labelArg) => labelArg === filtersArg.label))
93
+ && (!text || [ticketArg.key, ticketArg.title, ticketArg.description, ticketArg.source.text].some((valueArg) => valueArg.toLocaleLowerCase().includes(text)))
94
+ );
95
+ };
96
+
97
+ /**
98
+ * Whose tickets a board shows, as the browser's board (dees-kanban) narrows by assignee: a person by `id` (the owner by
99
+ * the owner's principal id, as the board's "Assigned to me" does), nobody, or the session a person's `sessionId` names.
100
+ */
101
+ export type TTicketAssigneeFilter = { kind: 'person'; id: string } | { kind: 'unassigned' } | { kind: 'session'; sessionId: string };
102
+
103
+ /** What a board narrows by beyond a listing's own filters (`ITicketFilters`, `ticketFilter`). */
104
+ export interface ITicketBoardNarrowing {
105
+ /** An epic's key: its own tasks, the tickets whose parent it is, as the board's epic filter matches them. */
106
+ epic?: string;
107
+ assignee?: TTicketAssigneeFilter;
108
+ /** An AutoLabel the ticket carries; unlike the listing's `label`, never a hand label of that name. */
109
+ autoLabel?: TTicketAutoLabel;
110
+ }
111
+
112
+ /**
113
+ * Whether a ticket stays on a board narrowed by an epic, an assignee and an AutoLabel, beside `ticketFilter`, as the
114
+ * browser's board (dees-kanban `visibleTasks`) narrows: the epic filter matches `ticket.parentId === epic`, the epic's
115
+ * direct children and never their subtasks; the AutoLabel filter the ticket's AutoLabels alone.
116
+ */
117
+ export const ticketBoardNarrows = (ticketArg: ITicket, narrowingArg: ITicketBoardNarrowing): boolean => {
118
+ if (narrowingArg.epic !== undefined && ticketArg.parentId !== narrowingArg.epic) return false;
119
+ if (narrowingArg.autoLabel !== undefined && !(ticketArg.autoLabels ?? []).includes(narrowingArg.autoLabel)) return false;
120
+ const filter = narrowingArg.assignee;
121
+ if (filter === undefined) return true;
122
+ switch (filter.kind) {
123
+ case 'person': return ticketArg.assignee?.id === filter.id;
124
+ case 'unassigned': return ticketArg.assignee === undefined;
125
+ case 'session': return ticketArg.assignee?.sessionId === filter.sessionId;
126
+ }
127
+ };
128
+
72
129
  export const ticketCanEdit = (ticketArg: TTicketData, actorArg: ITicketActor): boolean => (
73
130
  actorArg.role !== 'worker' || (ticketAssignedTo(ticketArg, actorArg) && workerColumns.has(ticketArg.columnId))
74
131
  );
@@ -332,6 +389,15 @@ export class TicketStore {
332
389
  * out: a done ticket asks nobody.
333
390
  */
334
391
  public async openQuestions(signalArg?: AbortSignal): Promise<ITicketOpenQuestion[]> {
392
+ return (await this.openQuestionTickets(signalArg))
393
+ .map(({ ticket, question }) => ({ ticketKey: ticket.key, project: ticket.project, question }));
394
+ }
395
+
396
+ /**
397
+ * Every open question with its whole ticket, oldest first, as `openQuestions` reads them: a question whose ticket is
398
+ * gone or done is left out. The Inbox reads a deploy plan's and a maintenance window's question from its ticket.
399
+ */
400
+ public async openQuestionTickets(signalArg?: AbortSignal): Promise<Array<{ ticket: TTicketData; question: ITicketQuestion }>> {
335
401
  const questions: ITicketQuestion[] = [];
336
402
  let after: string | undefined;
337
403
  while (true) {
@@ -352,7 +418,7 @@ export class TicketStore {
352
418
  }
353
419
  return structuredClone(questions.flatMap((questionArg) => {
354
420
  const ticket = tickets.get(questionArg.ticketId);
355
- return ticket && !ticketDoneColumns.includes(ticket.columnId) ? [{ ticketKey: ticket.key, project: ticket.project, question: questionArg }] : [];
421
+ return ticket && !ticketDoneColumns.includes(ticket.columnId) ? [{ ticket, question: questionArg }] : [];
356
422
  })).sort((leftArg, rightArg) => leftArg.question.createdAt.localeCompare(rightArg.question.createdAt));
357
423
  }
358
424
 
@@ -738,17 +804,12 @@ export class TicketStore {
738
804
  const filters: ITicketFilters = methodArg === 'search'
739
805
  ? { text: (requestArg as TTicketRequest<'search'>).query, label: (requestArg as TTicketRequest<'search'>).label }
740
806
  : requestArg as ITicketFilters;
741
- const text = filters.text?.toLocaleLowerCase();
742
807
  const all = await this.allTickets(sessionArg);
743
808
  await this.countOpenQuestions(trackArg, sessionArg);
744
- const tickets = all.map((recordArg) => this.visible(recordArg.ticket, actorArg, trackArg)).filter((ticketArg) => (
745
- (!filters.mine || (actorArg !== undefined && ticketAssignedTo(ticketArg, actorArg)))
746
- && (!filters.project || ticketArg.project === filters.project)
747
- && (!filters.status || ticketArg.columnId === filters.status)
748
- && (!filters.label || ticketArg.labels.includes(filters.label) || ticketArg.autoLabels!.some((labelArg) => labelArg === filters.label))
749
- && (!text || [ticketArg.key, ticketArg.title, ticketArg.description, ticketArg.source.text].some((valueArg) => valueArg.toLocaleLowerCase().includes(text)))
750
- )).sort((leftArg, rightArg) => ticketColumns.indexOf(leftArg.columnId) - ticketColumns.indexOf(rightArg.columnId)
751
- || leftArg.order - rightArg.order);
809
+ const matches = ticketFilter(filters, actorArg);
810
+ const tickets = all.map((recordArg) => this.visible(recordArg.ticket, actorArg, trackArg)).filter(matches)
811
+ .sort((leftArg, rightArg) => ticketColumns.indexOf(leftArg.columnId) - ticketColumns.indexOf(rightArg.columnId)
812
+ || leftArg.order - rightArg.order);
752
813
  if (methodArg !== 'board') return { tickets };
753
814
  if (!actorArg) throw new TicketError('ticket_identity_required', ticketErrorMessages.ticket_identity_required);
754
815
  const { role: _role, ...viewer } = actorArg;
@@ -629,7 +629,9 @@ export class ControllerWorkerCallers implements IFleetWorkerCallerHooks {
629
629
  controllerGeneration: this.options.controllerGeneration, bindingRevision: revision,
630
630
  projectId: recordArg.launch.projectId, harnessId: recordArg.launch.harnessId,
631
631
  nativeSessionId: recordArg.binding.nativeSessionId, ticketSessionId: recordArg.ticketSessionId!,
632
- sessionIdentityId: plugins.crypto.createHash('sha256').update(recordArg.ticketSessionId!).digest('base64url') });
632
+ sessionIdentityId: plugins.crypto.createHash('sha256').update(recordArg.ticketSessionId!).digest('base64url'),
633
+ // A worker id is `${projectId}:${name}`: prepared and kept launches are refused otherwise.
634
+ workerName: recordArg.launch.workerId.slice(recordArg.launch.projectId.length + 1) });
633
635
  recordArg.credentials.set(bridgePidArg, { credential, bridge, bindingRevision: revision });
634
636
  return { ...this.getWorkerCallerStatus(recordArg.launch.launchId), credential };
635
637
  });