wicked-crew 0.18.16 → 0.18.18
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.
- package/README.md +11 -5
- package/dist/api/capture.d.ts.map +1 -1
- package/dist/api/capture.js +5 -0
- package/dist/api/capture.js.map +1 -1
- package/dist/api/chat-jobs.d.ts +28 -0
- package/dist/api/chat-jobs.d.ts.map +1 -1
- package/dist/api/chat-jobs.js +74 -7
- package/dist/api/chat-jobs.js.map +1 -1
- package/dist/api/chat-proposals.d.ts +39 -3
- package/dist/api/chat-proposals.d.ts.map +1 -1
- package/dist/api/chat-proposals.js +122 -17
- package/dist/api/chat-proposals.js.map +1 -1
- package/dist/api/chat-scope.d.ts.map +1 -1
- package/dist/api/chat-scope.js +2 -0
- package/dist/api/chat-scope.js.map +1 -1
- package/dist/api/post-hoc-deliver.d.ts +9 -0
- package/dist/api/post-hoc-deliver.d.ts.map +1 -1
- package/dist/api/post-hoc-deliver.js +32 -3
- package/dist/api/post-hoc-deliver.js.map +1 -1
- package/dist/api/roster-standing.d.ts +7 -0
- package/dist/api/roster-standing.d.ts.map +1 -1
- package/dist/api/roster-standing.js +32 -2
- package/dist/api/roster-standing.js.map +1 -1
- package/dist/api/routes.d.ts +6 -6
- package/dist/api/routes.d.ts.map +1 -1
- package/dist/api/routes.js +526 -182
- package/dist/api/routes.js.map +1 -1
- package/dist/api/run-files.d.ts.map +1 -1
- package/dist/api/run-files.js +41 -2
- package/dist/api/run-files.js.map +1 -1
- package/dist/api/seat-agents.d.ts +3 -1
- package/dist/api/seat-agents.d.ts.map +1 -1
- package/dist/api/seat-agents.js +8 -2
- package/dist/api/seat-agents.js.map +1 -1
- package/dist/api/seat-images.d.ts +54 -0
- package/dist/api/seat-images.d.ts.map +1 -1
- package/dist/api/seat-images.js +132 -8
- package/dist/api/seat-images.js.map +1 -1
- package/dist/api/seat-standing.d.ts +3 -0
- package/dist/api/seat-standing.d.ts.map +1 -1
- package/dist/api/seat-standing.js +5 -0
- package/dist/api/seat-standing.js.map +1 -1
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +3 -1
- package/dist/api/server.js.map +1 -1
- package/dist/api/system-snapshot.d.ts.map +1 -1
- package/dist/api/system-snapshot.js +1 -0
- package/dist/api/system-snapshot.js.map +1 -1
- package/dist/api/ui-text.d.ts +2 -0
- package/dist/api/ui-text.d.ts.map +1 -1
- package/dist/api/ui-text.js +2 -0
- package/dist/api/ui-text.js.map +1 -1
- package/dist/apps-server/server/lib/bundle/server.mjs +123 -0
- package/dist/core/adapter.d.ts +38 -2
- package/dist/core/adapter.d.ts.map +1 -1
- package/dist/core/adapter.js +102 -7
- package/dist/core/adapter.js.map +1 -1
- package/dist/core/deliver-exclusions.d.ts +29 -0
- package/dist/core/deliver-exclusions.d.ts.map +1 -1
- package/dist/core/deliver-exclusions.js +44 -0
- package/dist/core/deliver-exclusions.js.map +1 -1
- package/dist/core/deliver-text.d.ts.map +1 -1
- package/dist/core/deliver-text.js +11 -2
- package/dist/core/deliver-text.js.map +1 -1
- package/dist/core/deliver.d.ts +30 -1
- package/dist/core/deliver.d.ts.map +1 -1
- package/dist/core/deliver.js +167 -17
- package/dist/core/deliver.js.map +1 -1
- package/dist/core/job-seats.d.ts +23 -0
- package/dist/core/job-seats.d.ts.map +1 -0
- package/dist/core/job-seats.js +38 -0
- package/dist/core/job-seats.js.map +1 -0
- package/dist/core/launch-posture.d.ts +75 -0
- package/dist/core/launch-posture.d.ts.map +1 -0
- package/dist/core/launch-posture.js +88 -0
- package/dist/core/launch-posture.js.map +1 -0
- package/dist/core/pr-checks-helper.d.ts +51 -0
- package/dist/core/pr-checks-helper.d.ts.map +1 -0
- package/dist/core/pr-checks-helper.js +172 -0
- package/dist/core/pr-checks-helper.js.map +1 -0
- package/dist/insights/review-service.d.ts +10 -0
- package/dist/insights/review-service.d.ts.map +1 -1
- package/dist/insights/review-service.js +27 -3
- package/dist/insights/review-service.js.map +1 -1
- package/dist/learnings/recall.d.ts +11 -1
- package/dist/learnings/recall.d.ts.map +1 -1
- package/dist/learnings/recall.js +20 -4
- package/dist/learnings/recall.js.map +1 -1
- package/dist/learnings/replacement-lineage.d.ts +22 -0
- package/dist/learnings/replacement-lineage.d.ts.map +1 -0
- package/dist/learnings/replacement-lineage.js +41 -0
- package/dist/learnings/replacement-lineage.js.map +1 -0
- package/dist/qe/acceptance.d.ts +5 -1
- package/dist/qe/acceptance.d.ts.map +1 -1
- package/dist/qe/acceptance.js +13 -1
- package/dist/qe/acceptance.js.map +1 -1
- package/dist/qe/ledger.d.ts +34 -0
- package/dist/qe/ledger.d.ts.map +1 -1
- package/dist/qe/ledger.js +107 -1
- package/dist/qe/ledger.js.map +1 -1
- package/dist/schedules/routes.d.ts.map +1 -1
- package/dist/schedules/routes.js +5 -0
- package/dist/schedules/routes.js.map +1 -1
- package/dist/setup/delivery-readiness.d.ts +117 -0
- package/dist/setup/delivery-readiness.d.ts.map +1 -0
- package/dist/setup/delivery-readiness.js +262 -0
- package/dist/setup/delivery-readiness.js.map +1 -0
- package/dist/setup/known.d.ts +27 -0
- package/dist/setup/known.d.ts.map +1 -1
- package/dist/setup/known.js +47 -0
- package/dist/setup/known.js.map +1 -1
- package/dist/setup/routes.d.ts +5 -3
- package/dist/setup/routes.d.ts.map +1 -1
- package/dist/setup/routes.js +9 -3
- package/dist/setup/routes.js.map +1 -1
- package/dist/studio/apps-standalone/fixture.js +3 -3
- package/dist/studio/assets/{KnowledgeGraph-Bgo9MFqp.js → KnowledgeGraph-JfsMExo3.js} +1 -1
- package/dist/studio/assets/{index-DNAGbMFA.js → index-pq0QeOmo.js} +301 -301
- package/dist/studio/editors/wicked-apps/editor.json +1 -1
- package/dist/studio/editors/wicked-apps/index.html +1 -1
- package/dist/studio/editors/wicked-deck/editor.json +1 -1
- package/dist/studio/editors/wicked-deck/index.html +1 -1
- package/dist/studio/editors/wicked-doc/editor.json +1 -1
- package/dist/studio/editors/wicked-doc/index.html +1 -1
- package/dist/studio/editors/wicked-insights/editor.json +1 -1
- package/dist/studio/editors/wicked-insights/index.html +1 -1
- package/dist/studio/editors/wicked-page/editor.json +1 -1
- package/dist/studio/editors/wicked-page/index.html +1 -1
- package/dist/studio/editors/wicked-video/editor.json +1 -1
- package/dist/studio/editors/wicked-video/index.html +1 -1
- package/dist/studio/index.html +1 -1
- package/dist/studio/testid-inventory.json +52 -4
- package/endpoint-manifest.json +11 -1
- package/package.json +5 -5
|
@@ -36,11 +36,12 @@
|
|
|
36
36
|
import { createHash } from 'node:crypto';
|
|
37
37
|
import { appendFileSync, chmodSync, existsSync, mkdirSync, readFileSync } from 'node:fs';
|
|
38
38
|
import { dirname } from 'node:path';
|
|
39
|
+
import { NEW_WORK_SEATS_FIX, NewWorkSeatsRefusal, jobSeatPool } from '../core/job-seats.js';
|
|
39
40
|
import { z } from '../zod.js';
|
|
40
41
|
import { parseCommand, resolveOption } from '../workflow-catalog/build-v2.js';
|
|
41
42
|
import { CATALOG_V2_CARDS } from '../workflow-catalog/catalog-data-v2.js';
|
|
42
43
|
import { REVIEW_CHANGE_WORKFLOW } from './review-change.js';
|
|
43
|
-
import { checksLabel, ownWords, factsOf, JobRefusal, mergeRevision, nounOf, optionFor, personAskedSkip, personPid, proposalKindOf, qeSkipBound, requestDigest, repoOf, resolveJob, SEAT_WORDS, seatProtections, briefOf, inputLines, SELF_SEATED, } from './chat-jobs.js';
|
|
44
|
+
import { checksLabel, ownWords, factsOf, JobRefusal, mergeRevision, nounOf, optionFor, personAskedSkip, personPid, proposalKindOf, qeSkipBound, requestDigest, repoOf, resolveJob, SEAT_WORDS, seatProtections, seatRemovalNote, briefOf, inputLines, SELF_SEATED, } from './chat-jobs.js';
|
|
44
45
|
import { artifactExists, artifactHead, chatMount, parseArtifactRef, UNFILED_MOUNT } from './chat-context.js';
|
|
45
46
|
import { ATTACHMENT_MAX_FILE_BYTES } from './chat-attachments.js';
|
|
46
47
|
import { documentPathPlan } from '../interactive/source-packet.js';
|
|
@@ -637,6 +638,8 @@ class EditRefusal extends Error {
|
|
|
637
638
|
}
|
|
638
639
|
/** The one block a person can lift from the card (Change something → two helpers); every other block is the record's. */
|
|
639
640
|
const NEEDS_HELPER = 'Needs a second helper to check it';
|
|
641
|
+
/** (F1/F2) The proposal kinds whose seats or helpers come from `newWorkSeats` (a theme and an onboard start no seat). */
|
|
642
|
+
const SEATED_KINDS = new Set(['job', 'create', 'refine', 'demo']);
|
|
640
643
|
/** A reshape's immutable context (the held run it replaces, its envelope, inherited reduced assurance) survives every
|
|
641
644
|
* re-resolution of its proposal: a revision, a catalog refresh (codex r1). */
|
|
642
645
|
function keepReshape(next, from) {
|
|
@@ -653,6 +656,8 @@ function keepReshape(next, from) {
|
|
|
653
656
|
export class ChatProposals {
|
|
654
657
|
deps;
|
|
655
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;
|
|
656
661
|
/** Per chat: resolutions publish in the order their replies were folded (a slow one never lands after a newer one). */
|
|
657
662
|
order = new KeyedLock();
|
|
658
663
|
pending = new Set();
|
|
@@ -806,7 +811,10 @@ export class ChatProposals {
|
|
|
806
811
|
return false;
|
|
807
812
|
}
|
|
808
813
|
const projectId = this.deps.projectOf(chatId);
|
|
809
|
-
|
|
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 } : {}) };
|
|
810
818
|
this.deps.broadcast(frame);
|
|
811
819
|
return true;
|
|
812
820
|
}
|
|
@@ -898,9 +906,9 @@ export class ChatProposals {
|
|
|
898
906
|
// A5: a change works from the document and the person's words; extra sources do not reach its run yet, so the
|
|
899
907
|
// card says so instead of showing them as used (codex A5 r1).
|
|
900
908
|
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);
|
|
901
|
-
const helpers = this.
|
|
902
|
-
if (
|
|
903
|
-
blocked.push(
|
|
909
|
+
const { helpers, block: helperBlock } = await this.docHelpers(chat);
|
|
910
|
+
if (helperBlock !== null)
|
|
911
|
+
blocked.push(helperBlock);
|
|
904
912
|
const title = target?.title ?? (ref !== null ? humanDoc(ref.doc) : block.refine);
|
|
905
913
|
return {
|
|
906
914
|
pid, chatId, turnId, kind: 'refine', seat,
|
|
@@ -970,9 +978,9 @@ export class ChatProposals {
|
|
|
970
978
|
demo = { url, audience: block.audience ?? null, show: block.show ?? null };
|
|
971
979
|
}
|
|
972
980
|
const sources = kind === 'create' ? await this.resolveSources(block.sources, { chatId, turnId, records, binding, turnHas, chat, words, personNamed: false }) : [];
|
|
973
|
-
const helpers = this.
|
|
974
|
-
if (
|
|
975
|
-
blocked.push(
|
|
981
|
+
const { helpers, block: helperBlock } = await this.docHelpers(chat);
|
|
982
|
+
if (helperBlock !== null)
|
|
983
|
+
blocked.push(helperBlock);
|
|
976
984
|
return {
|
|
977
985
|
pid, chatId, turnId, kind, seat,
|
|
978
986
|
what: {
|
|
@@ -999,7 +1007,7 @@ export class ChatProposals {
|
|
|
999
1007
|
return null;
|
|
1000
1008
|
}
|
|
1001
1009
|
/** The two helpers (DES §4.2): the lead seat, then another of the chat's seats, else the roster's next. */
|
|
1002
|
-
helpers(chat, chosen) {
|
|
1010
|
+
helpers(chat, chosen, pool) {
|
|
1003
1011
|
const roster = this.deps.rosterEligible();
|
|
1004
1012
|
const can = new Set(roster.map((s) => s.key));
|
|
1005
1013
|
const name = (k) => roster.find((s) => s.key === k)?.name ?? k;
|
|
@@ -1010,7 +1018,9 @@ export class ChatProposals {
|
|
|
1010
1018
|
return null;
|
|
1011
1019
|
}
|
|
1012
1020
|
else {
|
|
1013
|
-
|
|
1021
|
+
// The chat's lead and seats that are in the pool new work is drawn from, then the rest of it (F1/F2).
|
|
1022
|
+
const drawn = (pool ?? roster).map((s) => s.key);
|
|
1023
|
+
const order = [...[chat.lead, ...chat.seats].filter((k) => k !== null && drawn.includes(k)), ...drawn].filter((k) => k !== null && can.has(k));
|
|
1014
1024
|
seats = [...new Set(order)].slice(0, 2);
|
|
1015
1025
|
if (seats.length < 2)
|
|
1016
1026
|
return null;
|
|
@@ -1256,7 +1266,7 @@ export class ChatProposals {
|
|
|
1256
1266
|
decide(chatId, pid, body, actor, instance) {
|
|
1257
1267
|
// Keyed by the pid alone (it is unique: `<chat>:<turn uuid>`), so the same proposal answered through an ended chat's
|
|
1258
1268
|
// archived alias still waits for an in-flight answer through its first name.
|
|
1259
|
-
return this.lock.run(`pid\u0000${pid}`, () => this.decideLocked(chatId, pid, body, actor, instance));
|
|
1269
|
+
return this.lock.run(`pid\u0000${pid}`, () => this.decideLocked(chatId, pid, body, actor, instance)).then((r) => this.served(r));
|
|
1260
1270
|
}
|
|
1261
1271
|
gone(chatId) {
|
|
1262
1272
|
return { code: 409, body: { code: 'chat_gone', error: `chat ${chatId} ended and its id was reused; this proposal can no longer be answered here` } };
|
|
@@ -1377,6 +1387,11 @@ export class ChatProposals {
|
|
|
1377
1387
|
return this.refusalOf(err);
|
|
1378
1388
|
throw err;
|
|
1379
1389
|
}
|
|
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;
|
|
1380
1395
|
if (effective.blocked !== null) {
|
|
1381
1396
|
return { code: 409, body: { code: 'proposal_blocked', error: effective.blocked, view: viewOf(folded) } };
|
|
1382
1397
|
}
|
|
@@ -1410,6 +1425,11 @@ export class ChatProposals {
|
|
|
1410
1425
|
if (!flags.proposals || !(kind === 'job' ? this.jobsOn() : flags[kind]) || !this.deps.registry.has(kind)) {
|
|
1411
1426
|
return { code: 409, body: { code: 'operation_unavailable', error: `studio cannot start a ${kind === 'create' ? 'document' : kind} from a chat on this daemon yet`, view: viewOf(folded) } };
|
|
1412
1427
|
}
|
|
1428
|
+
// (F1/F2) Every launch path (a fresh Go, Go again, a reshape) re-reads `newWorkSeats` before anything is answered or
|
|
1429
|
+
// 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);
|
|
1431
|
+
if (seatsRefused !== null)
|
|
1432
|
+
return seatsRefused;
|
|
1413
1433
|
// The helpers can still work (one may have signed out since the card was drawn).
|
|
1414
1434
|
if (resolution.helpers !== null) {
|
|
1415
1435
|
const can = new Set(this.deps.rosterEligible().map((s) => s.key));
|
|
@@ -1722,10 +1742,13 @@ export class ChatProposals {
|
|
|
1722
1742
|
}
|
|
1723
1743
|
if (edits.helpers !== undefined) {
|
|
1724
1744
|
const chat = this.deps.chat(chatId) ?? { projectId: p.filedIn.projectId, repos: [], lead: null, seats: [], analysis: false };
|
|
1725
|
-
const
|
|
1745
|
+
const { pool, refusal } = await this.seatPool();
|
|
1746
|
+
if (refusal !== undefined)
|
|
1747
|
+
throw new JobRefusal(refusal.code, refusal.message, 409);
|
|
1748
|
+
const helpers = this.helpers(chat, edits.helpers, pool);
|
|
1726
1749
|
if (helpers === null)
|
|
1727
1750
|
throw new EditRefusal('pick two different helpers that can work now');
|
|
1728
|
-
// Two helpers lift the
|
|
1751
|
+
// Two helpers lift the block a person can lift: a missing second helper, or none drawn while the setting was bad.
|
|
1729
1752
|
next = { ...next, helpers, blocked: next.blocked === NEEDS_HELPER ? null : next.blocked };
|
|
1730
1753
|
}
|
|
1731
1754
|
// A3 (§4.2 Change something, create): the project — only in a chat filed in no project. Every source, repository
|
|
@@ -2185,6 +2208,78 @@ export class ChatProposals {
|
|
|
2185
2208
|
const c = this.deps.chat(chatId);
|
|
2186
2209
|
return c === null ? null : { projectId: c.projectId, repos: c.repos, lead: c.lead, seats: c.seats };
|
|
2187
2210
|
}
|
|
2211
|
+
/**
|
|
2212
|
+
* (F1/F2) The seats new work may name, and the pool it is drawn from (`core/job-seats.ts`). Not set at all is the
|
|
2213
|
+
* default launch rule over the eligible seats (`defaultLaunchRoster`): every eligible seat but the opt-in ones
|
|
2214
|
+
* (OpenCode), which are kept only when no other seat can work (crew#1590). A setting that is set but can't be read,
|
|
2215
|
+
* or is invalid, is a LIVE state, never a stored one: `refusal`, and the card is drawn as if nothing were picked,
|
|
2216
|
+
* 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.
|
|
2219
|
+
*/
|
|
2220
|
+
async seatPool() {
|
|
2221
|
+
if (this.deps.newWorkSeats === undefined)
|
|
2222
|
+
return jobSeatPool(this.deps.rosterEligible(), null);
|
|
2223
|
+
try {
|
|
2224
|
+
const pool = jobSeatPool(this.deps.rosterEligible(), await this.deps.newWorkSeats());
|
|
2225
|
+
this.seatsRefusal = null;
|
|
2226
|
+
return pool;
|
|
2227
|
+
}
|
|
2228
|
+
catch (err) {
|
|
2229
|
+
const refusal = err instanceof NewWorkSeatsRefusal
|
|
2230
|
+
? { code: err.code, message: err.message }
|
|
2231
|
+
: { 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
|
+
return { ...jobSeatPool(this.deps.rosterEligible(), null), refusal };
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
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) {
|
|
2239
|
+
if (!SEATED_KINDS.has(p.kind))
|
|
2240
|
+
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) } };
|
|
2243
|
+
}
|
|
2244
|
+
/** (F1/F2) A proposal view as it is served: an open job or document reads blocked while `newWorkSeats` can't be
|
|
2245
|
+
* honored (read now), exactly as `withSeatsSetting` serves its record. */
|
|
2246
|
+
async servedView(v) {
|
|
2247
|
+
if (!SEATED_KINDS.has(v.proposal.kind) || !(v.state === 'open' || v.state === 'revising'))
|
|
2248
|
+
return v;
|
|
2249
|
+
const { refusal } = await this.seatPool();
|
|
2250
|
+
return refusal === undefined ? v : { ...v, proposal: { ...v.proposal, blocked: refusal.message } };
|
|
2251
|
+
}
|
|
2252
|
+
/** A response as it is served: its `view`, when it has one, through `servedView`. */
|
|
2253
|
+
async served(r) {
|
|
2254
|
+
const v = r.body['view'];
|
|
2255
|
+
return v === undefined || v === null || typeof v !== 'object' || !('proposal' in v) ? r : { ...r, body: { ...r.body, view: await this.servedView(v) } };
|
|
2256
|
+
}
|
|
2257
|
+
/** A proposal record as it is served: a seated proposal still open reads blocked by `refusal` (the live setting state). */
|
|
2258
|
+
seatsBlocked(r, refusal, open) {
|
|
2259
|
+
if (refusal === null || r.kind !== 'proposal' || !SEATED_KINDS.has(r.proposal.kind) || !open(r.proposal.pid))
|
|
2260
|
+
return r;
|
|
2261
|
+
return { ...r, proposal: { ...r.proposal, blocked: refusal.message } };
|
|
2262
|
+
}
|
|
2263
|
+
/**
|
|
2264
|
+
* (F1/F2) A chat's records as they are served (`GET /chats/:id/messages`): every open job or document reads blocked
|
|
2265
|
+
* while `newWorkSeats` is set but unreadable or invalid, and unblocked again as soon as it reads. Read fresh here.
|
|
2266
|
+
*/
|
|
2267
|
+
async withSeatsSetting(records) {
|
|
2268
|
+
if (this.deps.newWorkSeats === undefined)
|
|
2269
|
+
return [...records];
|
|
2270
|
+
const { refusal } = await this.seatPool();
|
|
2271
|
+
if (refusal === undefined)
|
|
2272
|
+
return [...records];
|
|
2273
|
+
const folded = foldProposals(records);
|
|
2274
|
+
const open = (pid) => ['open', 'revising'].includes(folded.get(pid)?.state ?? '');
|
|
2275
|
+
return records.map((r) => this.seatsBlocked(r, refusal, open));
|
|
2276
|
+
}
|
|
2277
|
+
/** A document's two default helpers from the pool, and the line that blocks it when there are none. */
|
|
2278
|
+
async docHelpers(chat) {
|
|
2279
|
+
const { pool } = await this.seatPool();
|
|
2280
|
+
const helpers = this.helpers(chat, undefined, pool);
|
|
2281
|
+
return { helpers, block: helpers === null ? NEEDS_HELPER : null };
|
|
2282
|
+
}
|
|
2188
2283
|
async jobContext(chatId, pid, turnId, seat, chat, extra) {
|
|
2189
2284
|
if (this.deps.served === undefined)
|
|
2190
2285
|
throw new JobRefusal('operation_unavailable', 'this daemon cannot read its catalog for a job', 409);
|
|
@@ -2198,7 +2293,8 @@ export class ChatProposals {
|
|
|
2198
2293
|
const projectLabel = chat.projectId === null ? 'Not in a project · this chat' : ((await this.deps.projectName(chat.projectId)) ?? chat.projectId);
|
|
2199
2294
|
const qeOff = (await this.deps.qeOff?.().catch(() => false)) === true;
|
|
2200
2295
|
const powerPresets = (await this.deps.powerPresets?.(chat.projectId).catch(() => null)) ?? null;
|
|
2201
|
-
|
|
2296
|
+
const { eligible: roster, pool } = await this.seatPool();
|
|
2297
|
+
return { chatId, pid, turnId, seat, chat, served, roster, pool, projectLabel, qeOff, powerPresets, ...extra };
|
|
2202
2298
|
}
|
|
2203
2299
|
/** Source availability matters only to a card that shows this input. Keep a failed read a named refusal. */
|
|
2204
2300
|
async loadJobSources(facts, ctx) {
|
|
@@ -2252,7 +2348,9 @@ export class ChatProposals {
|
|
|
2252
2348
|
this.reviewAuthorsSeen.set(key, authors);
|
|
2253
2349
|
}
|
|
2254
2350
|
const roster = ctx.roster.filter((s) => !authors.authors.includes(s.key));
|
|
2255
|
-
|
|
2351
|
+
if (roster.length === 0 || roster.length === ctx.roster.length)
|
|
2352
|
+
return ctx;
|
|
2353
|
+
return { ...ctx, roster, ...(ctx.pool !== undefined ? { pool: ctx.pool.filter((s) => !authors.authors.includes(s.key)) } : {}) };
|
|
2256
2354
|
}
|
|
2257
2355
|
/** Resolve the revision's shape first, then load only the choices that its input checks need. */
|
|
2258
2356
|
async mergeJobRevision(parent, edits, ctx) {
|
|
@@ -2396,6 +2494,9 @@ export class ChatProposals {
|
|
|
2396
2494
|
* runs. A repeated `requestId` answers the same proposal; another body under it is refused.
|
|
2397
2495
|
*/
|
|
2398
2496
|
propose(chatId, body, actor, instance) {
|
|
2497
|
+
return this.proposeLocked(chatId, body, actor, instance).then((r) => this.served(r));
|
|
2498
|
+
}
|
|
2499
|
+
proposeLocked(chatId, body, actor, instance) {
|
|
2399
2500
|
return this.lock.run(`chat\u0000${instance ?? chatId}`, async () => {
|
|
2400
2501
|
if (this.deps.instanceOf(chatId) !== instance)
|
|
2401
2502
|
return this.gone(chatId);
|
|
@@ -2675,7 +2776,11 @@ export class ChatProposals {
|
|
|
2675
2776
|
return { code: 200, body: { view: viewOf(parent) } };
|
|
2676
2777
|
if (candidate === null)
|
|
2677
2778
|
throw candidateErr;
|
|
2678
|
-
|
|
2779
|
+
// (F1/F2) What a removal did, from the card as published (never from the merge, which a loss question can hold).
|
|
2780
|
+
// A document's workers are its helpers (a revision can make a job a document; codex r2).
|
|
2781
|
+
const workers = candidate.seats !== undefined ? candidate.seats.keys : (candidate.helpers?.seats ?? []);
|
|
2782
|
+
const removal = seatRemovalNote(edits.removeSeats, parent.proposal.seats?.keys ?? [], workers, (k) => ctx.roster.find((s) => s.key === k)?.name ?? k, candidate.seats !== undefined);
|
|
2783
|
+
const proposal = removal.length === 0 || candidate.sentence === undefined ? candidate : { ...candidate, sentence: { ...candidate.sentence, notes: [...candidate.sentence.notes, ...removal] } };
|
|
2679
2784
|
if (!this.write(chatId, { at: this.now(), turnId: src.turnId ?? `person:${src.pid.slice(src.pid.lastIndexOf(':') + 1)}`, kind: 'proposal', proposal }, instance))
|
|
2680
2785
|
return this.gone(chatId);
|
|
2681
2786
|
const view = foldProposals(this.deps.records(chatId)).get(src.pid);
|
|
@@ -3045,7 +3150,7 @@ export class ChatProposals {
|
|
|
3045
3150
|
const current = folded.state === 'accepting' && folded.accepting !== undefined ? folded.accepting.resolution : folded.proposal;
|
|
3046
3151
|
const identity = folded.accepting?.identity ?? this.identityOf(current);
|
|
3047
3152
|
return this.goLocked(chatId, folded, current, null, identity, actor, instance);
|
|
3048
|
-
}));
|
|
3153
|
+
})).then((r) => this.served(r));
|
|
3049
3154
|
}
|
|
3050
3155
|
/** A proposal of this chat, folded, or `null`. */
|
|
3051
3156
|
viewOfPid(chatId, pid) {
|