wicked-crew 0.18.18 → 0.18.19

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 (142) hide show
  1. package/dist/api/chat-jobs.d.ts +2 -0
  2. package/dist/api/chat-jobs.d.ts.map +1 -1
  3. package/dist/api/chat-jobs.js.map +1 -1
  4. package/dist/api/chat-proposals.d.ts +6 -7
  5. package/dist/api/chat-proposals.d.ts.map +1 -1
  6. package/dist/api/chat-proposals.js +69 -33
  7. package/dist/api/chat-proposals.js.map +1 -1
  8. package/dist/api/chat-scope.d.ts +9 -0
  9. package/dist/api/chat-scope.d.ts.map +1 -1
  10. package/dist/api/chat-scope.js +33 -4
  11. package/dist/api/chat-scope.js.map +1 -1
  12. package/dist/api/delivery-index.d.ts.map +1 -1
  13. package/dist/api/delivery-index.js +13 -0
  14. package/dist/api/delivery-index.js.map +1 -1
  15. package/dist/api/mcp.js +1 -1
  16. package/dist/api/mcp.js.map +1 -1
  17. package/dist/api/needs.js +1 -1
  18. package/dist/api/needs.js.map +1 -1
  19. package/dist/api/redeliver.d.ts +48 -0
  20. package/dist/api/redeliver.d.ts.map +1 -0
  21. package/dist/api/redeliver.js +178 -0
  22. package/dist/api/redeliver.js.map +1 -0
  23. package/dist/api/roster-standing.d.ts +3 -1
  24. package/dist/api/roster-standing.d.ts.map +1 -1
  25. package/dist/api/roster-standing.js +2 -2
  26. package/dist/api/roster-standing.js.map +1 -1
  27. package/dist/api/routes.d.ts +8 -0
  28. package/dist/api/routes.d.ts.map +1 -1
  29. package/dist/api/routes.js +71 -28
  30. package/dist/api/routes.js.map +1 -1
  31. package/dist/api/run-base-notice.d.ts +5 -0
  32. package/dist/api/run-base-notice.d.ts.map +1 -0
  33. package/dist/api/run-base-notice.js +15 -0
  34. package/dist/api/run-base-notice.js.map +1 -0
  35. package/dist/api/seat-probe.d.ts +6 -5
  36. package/dist/api/seat-probe.d.ts.map +1 -1
  37. package/dist/api/seat-probe.js +11 -7
  38. package/dist/api/seat-probe.js.map +1 -1
  39. package/dist/api/seat-standing.js +4 -4
  40. package/dist/api/seat-standing.js.map +1 -1
  41. package/dist/api/server.d.ts.map +1 -1
  42. package/dist/api/server.js +13 -5
  43. package/dist/api/server.js.map +1 -1
  44. package/dist/api/system-snapshot.d.ts.map +1 -1
  45. package/dist/api/system-snapshot.js +3 -2
  46. package/dist/api/system-snapshot.js.map +1 -1
  47. package/dist/apps-server/server/lib/bundle/server.mjs +105 -1
  48. package/dist/cli/index.d.ts +1 -0
  49. package/dist/cli/index.d.ts.map +1 -1
  50. package/dist/cli/index.js +2 -0
  51. package/dist/cli/index.js.map +1 -1
  52. package/dist/cli/service.d.ts +2 -0
  53. package/dist/cli/service.d.ts.map +1 -1
  54. package/dist/cli/service.js +14 -0
  55. package/dist/cli/service.js.map +1 -1
  56. package/dist/core/adapter.d.ts +6 -2
  57. package/dist/core/adapter.d.ts.map +1 -1
  58. package/dist/core/adapter.js +3 -3
  59. package/dist/core/adapter.js.map +1 -1
  60. package/dist/core/bridge-reaper.d.ts +4 -3
  61. package/dist/core/bridge-reaper.d.ts.map +1 -1
  62. package/dist/core/bridge-reaper.js +24 -8
  63. package/dist/core/bridge-reaper.js.map +1 -1
  64. package/dist/core/deliver-exclusions.d.ts +5 -2
  65. package/dist/core/deliver-exclusions.d.ts.map +1 -1
  66. package/dist/core/deliver-exclusions.js +5 -2
  67. package/dist/core/deliver-exclusions.js.map +1 -1
  68. package/dist/core/deliver.d.ts +4 -0
  69. package/dist/core/deliver.d.ts.map +1 -1
  70. package/dist/core/deliver.js +110 -32
  71. package/dist/core/deliver.js.map +1 -1
  72. package/dist/core/redeliver.d.ts +16 -0
  73. package/dist/core/redeliver.d.ts.map +1 -0
  74. package/dist/core/redeliver.js +64 -0
  75. package/dist/core/redeliver.js.map +1 -0
  76. package/dist/core/threadpool.d.ts +3 -0
  77. package/dist/core/threadpool.d.ts.map +1 -0
  78. package/dist/core/threadpool.js +14 -0
  79. package/dist/core/threadpool.js.map +1 -0
  80. package/dist/interactive/council-outcome.js +1 -1
  81. package/dist/interactive/council-outcome.js.map +1 -1
  82. package/dist/learnings/extract.d.ts +7 -12
  83. package/dist/learnings/extract.d.ts.map +1 -1
  84. package/dist/learnings/extract.js +9 -40
  85. package/dist/learnings/extract.js.map +1 -1
  86. package/dist/learnings/service.d.ts +12 -15
  87. package/dist/learnings/service.d.ts.map +1 -1
  88. package/dist/learnings/service.js +23 -43
  89. package/dist/learnings/service.js.map +1 -1
  90. package/dist/mcp/env.js +3 -3
  91. package/dist/mcp/env.js.map +1 -1
  92. package/dist/mcp/registry.js +3 -3
  93. package/dist/mcp/registry.js.map +1 -1
  94. package/dist/projects/auto-refresh.d.ts +21 -0
  95. package/dist/projects/auto-refresh.d.ts.map +1 -1
  96. package/dist/projects/auto-refresh.js +55 -1
  97. package/dist/projects/auto-refresh.js.map +1 -1
  98. package/dist/projects/graph.d.ts +39 -0
  99. package/dist/projects/graph.d.ts.map +1 -1
  100. package/dist/projects/graph.js +144 -13
  101. package/dist/projects/graph.js.map +1 -1
  102. package/dist/schedules/scheduler.d.ts +40 -1
  103. package/dist/schedules/scheduler.d.ts.map +1 -1
  104. package/dist/schedules/scheduler.js +175 -13
  105. package/dist/schedules/scheduler.js.map +1 -1
  106. package/dist/schedules/store.d.ts +20 -0
  107. package/dist/schedules/store.d.ts.map +1 -1
  108. package/dist/schedules/store.js +17 -0
  109. package/dist/schedules/store.js.map +1 -1
  110. package/dist/sources/routes.js +1 -1
  111. package/dist/sources/routes.js.map +1 -1
  112. package/dist/standing-orders/parse.js +1 -1
  113. package/dist/standing-orders/parse.js.map +1 -1
  114. package/dist/studio/apps-standalone/runtime.js +1 -1
  115. package/dist/studio/assets/{KnowledgeGraph-JfsMExo3.js → KnowledgeGraph-DWw0I8RJ.js} +1 -1
  116. package/dist/studio/assets/index-C4Xj-zxa.css +32 -0
  117. package/dist/studio/assets/{index-pq0QeOmo.js → index-CrNY3d06.js} +305 -305
  118. package/dist/studio/editors/wicked-apps/editor.json +1 -1
  119. package/dist/studio/editors/wicked-apps/index.html +2 -2
  120. package/dist/studio/editors/wicked-deck/editor.json +1 -1
  121. package/dist/studio/editors/wicked-deck/index.html +13 -13
  122. package/dist/studio/editors/wicked-doc/editor.json +1 -1
  123. package/dist/studio/editors/wicked-doc/index.html +12 -12
  124. package/dist/studio/editors/wicked-insights/editor.json +1 -1
  125. package/dist/studio/editors/wicked-insights/index.html +2 -2
  126. package/dist/studio/editors/wicked-page/editor.json +1 -1
  127. package/dist/studio/editors/wicked-page/index.html +12 -12
  128. package/dist/studio/editors/wicked-video/editor.json +1 -1
  129. package/dist/studio/editors/wicked-video/index.html +10 -10
  130. package/dist/studio/index.html +2 -2
  131. package/dist/studio/testid-inventory.json +33 -3
  132. package/dist/working-doc/event-lines.d.ts +4 -0
  133. package/dist/working-doc/event-lines.d.ts.map +1 -1
  134. package/dist/working-doc/event-lines.js +8 -2
  135. package/dist/working-doc/event-lines.js.map +1 -1
  136. package/dist/working-doc/notes-index.d.ts.map +1 -1
  137. package/dist/working-doc/notes-index.js +2 -2
  138. package/dist/working-doc/notes-index.js.map +1 -1
  139. package/endpoint-manifest.json +26 -1
  140. package/package.json +4 -4
  141. package/workflows/distill-learnings.json +2 -2
  142. package/dist/studio/assets/index-CkosDNYp.css +0 -32
@@ -656,8 +656,8 @@ function keepReshape(next, from) {
656
656
  export class ChatProposals {
657
657
  deps;
658
658
  lock = new KeyedLock();
659
- /** (F1/F2) The last `newWorkSeats` read's refusal (`null` = it read): what a proposal broadcast reads blocked by. */
660
- seatsRefusal = null;
659
+ /** Frames publish in append order after reading the live seat setting. */
660
+ publishing = Promise.resolve();
661
661
  /** Per chat: resolutions publish in the order their replies were folded (a slow one never lands after a newer one). */
662
662
  order = new KeyedLock();
663
663
  pending = new Set();
@@ -709,6 +709,7 @@ export class ChatProposals {
709
709
  async settled() {
710
710
  while (this.pending.size > 0)
711
711
  await Promise.all([...this.pending]);
712
+ await this.publishing;
712
713
  }
713
714
  /**
714
715
  * A seat's reply was folded with the `wicked-make` bodies cut from it. Resolution reads crew's records (it awaits),
@@ -811,11 +812,14 @@ export class ChatProposals {
811
812
  return false;
812
813
  }
813
814
  const projectId = this.deps.projectOf(chatId);
814
- // A new proposal record reads as served: blocked while `newWorkSeats` can't be honored (the last read, made while
815
- // drawing it). The transcript keeps the card as drawn.
816
- const served = record.kind === 'proposal' ? this.seatsBlocked(record, this.seatsRefusal, () => true) : record;
817
- const frame = { type: 'chatProposal', chat: chatId, turn_id: record.turnId, record: served, ...(projectId !== null ? { project_id: projectId } : {}) };
818
- this.deps.broadcast(frame);
815
+ this.publishing = this.publishing.then(async () => {
816
+ const { refusal } = await this.seatPool();
817
+ if (this.deps.instanceOf(chatId) !== instance)
818
+ return;
819
+ const served = this.seatsBlocked(record, refusal ?? null, () => true);
820
+ const frame = { type: 'chatProposal', chat: chatId, turn_id: record.turnId, record: served, ...(projectId !== null ? { project_id: projectId } : {}) };
821
+ this.deps.broadcast(frame);
822
+ }).catch((err) => this.log(`[proposals] chat ${chatId}: ${record.kind} broadcast failed: ${err instanceof Error ? err.message : String(err)}`));
819
823
  return true;
820
824
  }
821
825
  /**
@@ -906,7 +910,7 @@ export class ChatProposals {
906
910
  // A5: a change works from the document and the person's words; extra sources do not reach its run yet, so the
907
911
  // card says so instead of showing them as used (codex A5 r1).
908
912
  const sources = (await this.resolveSources(block.sources, { chatId, turnId, records, binding, turnHas, chat, words, personNamed: false })).map((src) => src.status === 'ok' ? { ...src, status: 'struck', reason: 'a change works from the document and your words; make a new document to use this source' } : src);
909
- const { helpers, block: helperBlock } = await this.docHelpers(chat);
913
+ const { helpers, block: helperBlock, seatsUnread } = await this.docHelpers(chat);
910
914
  if (helperBlock !== null)
911
915
  blocked.push(helperBlock);
912
916
  const title = target?.title ?? (ref !== null ? humanDoc(ref.doc) : block.refine);
@@ -918,6 +922,7 @@ export class ChatProposals {
918
922
  sources,
919
923
  repos: [],
920
924
  helpers,
925
+ ...(seatsUnread ? { seatsUnread: true } : {}),
921
926
  time: await this.timeOf('refine', null, projectId),
922
927
  stops: STOPS.refine,
923
928
  filedIn: await filedIn(projectId),
@@ -978,7 +983,7 @@ export class ChatProposals {
978
983
  demo = { url, audience: block.audience ?? null, show: block.show ?? null };
979
984
  }
980
985
  const sources = kind === 'create' ? await this.resolveSources(block.sources, { chatId, turnId, records, binding, turnHas, chat, words, personNamed: false }) : [];
981
- const { helpers, block: helperBlock } = await this.docHelpers(chat);
986
+ const { helpers, block: helperBlock, seatsUnread } = await this.docHelpers(chat);
982
987
  if (helperBlock !== null)
983
988
  blocked.push(helperBlock);
984
989
  return {
@@ -995,6 +1000,7 @@ export class ChatProposals {
995
1000
  repos,
996
1001
  ...(repoRefs.length > 0 ? { repoRefs } : {}),
997
1002
  helpers,
1003
+ ...(seatsUnread ? { seatsUnread: true } : {}),
998
1004
  time: await this.timeOf(kind, seed ?? null, chat.projectId),
999
1005
  stops: STOPS[kind],
1000
1006
  filedIn: await filedIn(chat.projectId),
@@ -1368,6 +1374,10 @@ export class ChatProposals {
1368
1374
  if (stale !== null)
1369
1375
  return stale;
1370
1376
  }
1377
+ // Check the setting and redraw a card drawn during a refusal before edits or old-seat checks.
1378
+ const seatsRefused = await this.lock.run(`chat\u0000${instance ?? chatId}`, () => this.seatsSettingRefusal(chatId, folded.proposal, folded, instance));
1379
+ if (seatsRefused !== null)
1380
+ return seatsRefused;
1371
1381
  if (kind === 'job') {
1372
1382
  // A reshape starts only through its own transition (the held plan answered Reject first; codex r3).
1373
1383
  // The seats the proposal names can still work, before any edit re-resolves them (codex r3).
@@ -1387,11 +1397,6 @@ export class ChatProposals {
1387
1397
  return this.refusalOf(err);
1388
1398
  throw err;
1389
1399
  }
1390
- // (F1/F2) A job's seats and a document's helpers come from `newWorkSeats`: checked here before the card's own block (the
1391
- // setting is the cause to fix first), and again in `goLocked` for every launch path.
1392
- const seatsRefused = await this.seatsSettingRefusal(effective, folded);
1393
- if (seatsRefused !== null)
1394
- return seatsRefused;
1395
1400
  if (effective.blocked !== null) {
1396
1401
  return { code: 409, body: { code: 'proposal_blocked', error: effective.blocked, view: viewOf(folded) } };
1397
1402
  }
@@ -1427,7 +1432,7 @@ export class ChatProposals {
1427
1432
  }
1428
1433
  // (F1/F2) Every launch path (a fresh Go, Go again, a reshape) re-reads `newWorkSeats` before anything is answered or
1429
1434
  // recorded: set but unreadable or invalid refuses with its code, never starting the seats drawn without the pick.
1430
- const seatsRefused = await this.seatsSettingRefusal(resolution, folded);
1435
+ const seatsRefused = await this.seatsSettingRefusal(chatId, resolution, folded, instance);
1431
1436
  if (seatsRefused !== null)
1432
1437
  return seatsRefused;
1433
1438
  // The helpers can still work (one may have signed out since the card was drawn).
@@ -2214,32 +2219,62 @@ export class ChatProposals {
2214
2219
  * (OpenCode), which are kept only when no other seat can work (crew#1590). A setting that is set but can't be read,
2215
2220
  * or is invalid, is a LIVE state, never a stored one: `refusal`, and the card is drawn as if nothing were picked,
2216
2221
  * but it reads blocked with the reason wherever it is served (`withSeatsSetting`) and Start refuses it
2217
- * (`seatsSettingRefusal`) until the setting reads again. Fixing the setting lifts the block everywhere at once;
2218
- * nothing on the transcript has to change.
2222
+ * (`seatsSettingRefusal`) until the setting reads again. Cards drawn during the refusal are marked so Start
2223
+ * redraws their seats after repair, before the person can launch them.
2219
2224
  */
2220
2225
  async seatPool() {
2221
2226
  if (this.deps.newWorkSeats === undefined)
2222
2227
  return jobSeatPool(this.deps.rosterEligible(), null);
2223
2228
  try {
2224
- const pool = jobSeatPool(this.deps.rosterEligible(), await this.deps.newWorkSeats());
2225
- this.seatsRefusal = null;
2226
- return pool;
2229
+ return jobSeatPool(this.deps.rosterEligible(), await this.deps.newWorkSeats());
2227
2230
  }
2228
2231
  catch (err) {
2229
2232
  const refusal = err instanceof NewWorkSeatsRefusal
2230
2233
  ? { code: err.code, message: err.message }
2231
2234
  : { code: 'settings_unavailable', message: `crew can't read which seats new work may use (newWorkSeats): ${err instanceof Error ? err.message : String(err)}; it won't start new work on every seat instead. ${NEW_WORK_SEATS_FIX[0].toUpperCase()}${NEW_WORK_SEATS_FIX.slice(1)}` };
2232
- this.seatsRefusal = refusal;
2233
2235
  return { ...jobSeatPool(this.deps.rosterEligible(), null), refusal };
2234
2236
  }
2235
2237
  }
2236
- /** (F1/F2) A seated proposal refused at Start, fresh or again, while `newWorkSeats` is set but unreadable or invalid;
2237
- * `null` when it starts no seat or the setting reads. */
2238
- async seatsSettingRefusal(p, folded) {
2238
+ /** Refuse an unreadable setting, or redraw a card that was drawn without it. Called under the chat lock. */
2239
+ async seatsSettingRefusal(chatId, p, folded, instance) {
2239
2240
  if (!SEATED_KINDS.has(p.kind))
2240
2241
  return null;
2241
- const { refusal } = await this.seatPool();
2242
- return refusal === undefined ? null : { code: 409, body: { code: refusal.code, error: refusal.message, view: viewOf(folded) } };
2242
+ const { pool, refusal } = await this.seatPool();
2243
+ if (refusal !== undefined)
2244
+ return { code: 409, body: { code: refusal.code, error: refusal.message, view: viewOf(folded) } };
2245
+ if (!p.seatsUnread && !folded.proposal.seatsUnread)
2246
+ return null;
2247
+ const current = foldProposals(this.deps.records(chatId)).get(p.pid);
2248
+ if (current === undefined || current.state !== folded.state) {
2249
+ return { code: 409, body: { code: 'proposal_stale', error: 'this proposal changed; check the card again', ...(current !== undefined ? { view: viewOf(current) } : {}) } };
2250
+ }
2251
+ const recorded = current.accepting?.resolution ?? current.proposal;
2252
+ if (recorded.seatsUnread) {
2253
+ const base = { ...recorded };
2254
+ delete base.seatsUnread;
2255
+ let fresh;
2256
+ if (recorded.shape !== undefined) {
2257
+ const chat = this.jobChat(chatId) ?? {
2258
+ projectId: recorded.filedIn.projectId,
2259
+ repos: (recorded.repoRefs ?? []).map((id, i) => ({ id, name: recorded.repos[i] ?? id })),
2260
+ lead: null, seats: [],
2261
+ };
2262
+ const ctx = await this.jobContext(chatId, recorded.pid, recorded.turnId, recorded.seat, chat, {
2263
+ revises: recorded.revises ?? null, lineage: recorded.lineage ?? recorded.pid, notes: [],
2264
+ ...(recorded.request !== undefined ? { request: recorded.request } : {}),
2265
+ ...(recorded.answers !== undefined ? { answers: recorded.answers } : {}),
2266
+ });
2267
+ fresh = { ...base, ...keepReshape(await this.proposalOf(chatId, recorded.pid, { ...factsOf(recorded), lead: null, seats: null }, ctx, this.deps.records(chatId), true, recorded), recorded) };
2268
+ }
2269
+ else {
2270
+ const helpers = this.helpers({ lead: null, seats: [] }, undefined, pool);
2271
+ fresh = { ...base, helpers, blocked: helpers === null ? NEEDS_HELPER : recorded.blocked === NEEDS_HELPER ? null : recorded.blocked };
2272
+ }
2273
+ if (!this.write(chatId, { at: this.now(), turnId: current.turnId, kind: 'proposal', proposal: fresh }, instance))
2274
+ return this.gone(chatId);
2275
+ }
2276
+ const after = foldProposals(this.deps.records(chatId)).get(p.pid);
2277
+ return { code: 409, body: { code: 'seats_redrawn', error: 'the seats setting reads again; check the redrawn card and press Start', view: viewOf(after) } };
2243
2278
  }
2244
2279
  /** (F1/F2) A proposal view as it is served: an open job or document reads blocked while `newWorkSeats` can't be
2245
2280
  * honored (read now), exactly as `withSeatsSetting` serves its record. */
@@ -2276,9 +2311,9 @@ export class ChatProposals {
2276
2311
  }
2277
2312
  /** A document's two default helpers from the pool, and the line that blocks it when there are none. */
2278
2313
  async docHelpers(chat) {
2279
- const { pool } = await this.seatPool();
2314
+ const { pool, refusal } = await this.seatPool();
2280
2315
  const helpers = this.helpers(chat, undefined, pool);
2281
- return { helpers, block: helpers === null ? NEEDS_HELPER : null };
2316
+ return { helpers, block: helpers === null ? NEEDS_HELPER : null, ...(refusal !== undefined ? { seatsUnread: true } : {}) };
2282
2317
  }
2283
2318
  async jobContext(chatId, pid, turnId, seat, chat, extra) {
2284
2319
  if (this.deps.served === undefined)
@@ -2293,8 +2328,8 @@ export class ChatProposals {
2293
2328
  const projectLabel = chat.projectId === null ? 'Not in a project · this chat' : ((await this.deps.projectName(chat.projectId)) ?? chat.projectId);
2294
2329
  const qeOff = (await this.deps.qeOff?.().catch(() => false)) === true;
2295
2330
  const powerPresets = (await this.deps.powerPresets?.(chat.projectId).catch(() => null)) ?? null;
2296
- const { eligible: roster, pool } = await this.seatPool();
2297
- return { chatId, pid, turnId, seat, chat, served, roster, pool, projectLabel, qeOff, powerPresets, ...extra };
2331
+ const { eligible: roster, pool, refusal } = await this.seatPool();
2332
+ return { chatId, pid, turnId, seat, chat, served, roster, pool, projectLabel, qeOff, powerPresets, ...extra, ...(refusal !== undefined ? { seatsUnread: true } : {}) };
2298
2333
  }
2299
2334
  /** Source availability matters only to a card that shows this input. Keep a failed read a named refusal. */
2300
2335
  async loadJobSources(facts, ctx) {
@@ -2466,9 +2501,10 @@ export class ChatProposals {
2466
2501
  ctx = { ...ctx, documents: await this.authorizeDocumentsAt(chatId, input?.kind === 'documents' ? input.tokens : [], records, ctx.turnId ?? '\u0000', r !== null && proposalKindOf(r) === 'create', true) };
2467
2502
  }
2468
2503
  // An unsure reading holds no Start wherever the proposal is rebuilt (a Go's edits, a refresh; codex r4).
2469
- if (r !== null && proposalKindOf(r) === 'create')
2470
- return withAskOverlay(await this.documentProposal(chatId, pid, facts, ctx, records));
2471
- return withAskOverlay(resolveJob(facts, ctx, { allowHidden }));
2504
+ const proposal = r !== null && proposalKindOf(r) === 'create'
2505
+ ? await this.documentProposal(chatId, pid, facts, ctx, records)
2506
+ : resolveJob(facts, ctx, { allowHidden });
2507
+ return withAskOverlay({ ...proposal, ...(ctx.seatsUnread ? { seatsUnread: true } : {}) });
2472
2508
  }
2473
2509
  refusalOf(err) {
2474
2510
  if (err instanceof JobRefusal)