@unson/brainbase-mcp 0.51.10 → 0.51.11

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.
@@ -63,6 +63,21 @@ export function projectVocabularyTerms(records) {
63
63
  }
64
64
  return terms.sort((a, b) => a.id.localeCompare(b.id));
65
65
  }
66
+ /**
67
+ * What the world's display filter reads from a project record (story-world-agents-step1-v1): both status
68
+ * fields as recorded (the entity's `status` keeps only one of them), a test mark and a hidden mark.
69
+ */
70
+ function projectWorldFlags(payload) {
71
+ const operational = text(payload.operational_status);
72
+ const recorded = text(payload.status);
73
+ const visibility = text(payload.world_visibility);
74
+ return {
75
+ ...(operational ? { operational_status: operational } : {}),
76
+ ...(recorded ? { record_status: recorded } : {}),
77
+ ...(payload.is_test === true ? { is_test: true } : {}),
78
+ ...(visibility ? { world_visibility: visibility } : {})
79
+ };
80
+ }
66
81
  /** A project's code, parent and repositories as the organization Graph states them. */
67
82
  function projectPlacement(record, payload, catalogByCode) {
68
83
  const scope = text(record.project_code);
@@ -125,7 +140,8 @@ export function projectOrganizationGraph(records, owner) {
125
140
  ...(type === 'project' && status ? { status } : {}),
126
141
  ...(type === 'project' && text(payload.kind) ? { kind: text(payload.kind) } : {}),
127
142
  ...(type === 'decision' && text(payload.decided_at) ? { decided_at: text(payload.decided_at) } : {}),
128
- ...(type === 'project' ? projectPlacement(record, payload, catalogByCode) : {})
143
+ ...(type === 'project' ? projectPlacement(record, payload, catalogByCode) : {}),
144
+ ...(type === 'project' ? projectWorldFlags(payload) : {})
129
145
  }
130
146
  });
131
147
  ids.set(record.id, type);
@@ -1,6 +1,6 @@
1
1
  import { JudgmentValueProofJournalCache } from './judgment-value-proof-review.js';
2
2
  import { type GraphVocabularyTerm, type LocalWebExtension, type LocalWebModuleContext } from './local-web-host.js';
3
- import type { GraphFileV2 } from './types.js';
3
+ import type { CanonicalEntity, GraphFileV2 } from './types.js';
4
4
  export * from './world-work.js';
5
5
  /**
6
6
  * World view (ledger P17, adopted 2026-10-04): the home's upper layer.
@@ -104,7 +104,36 @@ export interface WorldBusinessProjection {
104
104
  readonly excluded: {
105
105
  readonly inactive: number;
106
106
  };
107
+ /**
108
+ * Projects kept off the map by the display filter (story-world-agents-step1-v1 AC-01/02): archived or
109
+ * finished businesses, projects marked as tests or hidden, and projects named like test leftovers.
110
+ * The Graph is never changed; only how many were kept off is said (P9: never dropped silently).
111
+ * Optional on this public type so consumers that build the earlier three-field shape keep compiling;
112
+ * `projectWorldFromGraph` and the businesses API always emit it. Read it as `filtered_out_count ?? 0`.
113
+ */
114
+ readonly filtered_out_count?: number;
107
115
  }
116
+ /** What `projectWorldFromGraph` returns: the projection with the display filter's count always present. */
117
+ export type WorldBusinessProjectionResult = WorldBusinessProjection & {
118
+ readonly filtered_out_count: number;
119
+ };
120
+ /** Options for the world's display filter; `includeTest` draws the filtered projects too (for checking only). */
121
+ export interface WorldProjectionOptions {
122
+ readonly includeTest?: boolean;
123
+ }
124
+ /**
125
+ * Names of the probes and acceptance runs that were left in Graphs as active projects. A project whose
126
+ * code or name matches one is kept off the map by default (layer 2; layer 1 is the record's own flags).
127
+ */
128
+ export declare const WORLD_TEST_PROJECT_PATTERNS: readonly RegExp[];
129
+ /**
130
+ * Why a project is kept off the world by default, or null when it is drawn. `top` is true for a
131
+ * business (a city): a finished business is kept off, while a finished engagement inside a city stays
132
+ * as its empty lot (story-world-size-and-activity-v1).
133
+ */
134
+ export declare function worldProjectFilterReason(entity: Pick<CanonicalEntity, 'name' | 'metadata'>, { top }?: {
135
+ readonly top?: boolean;
136
+ }): 'lifecycle' | 'archived' | 'test_flag' | 'hidden' | 'test_name' | null;
108
137
  export type WorldSource = {
109
138
  readonly authority: 'organization_graph';
110
139
  readonly server: string;
@@ -123,6 +152,63 @@ export type WorldBusinessesResponse = ({
123
152
  readonly version: typeof WORLD_EXTENSION_VERSION;
124
153
  readonly reason: string;
125
154
  };
155
+ /**
156
+ * The AI agents a host projects onto the world (story-world-agents-step1-v1, design item #707 §1.3).
157
+ * It is an execution-state projection (for example Orca run receipts), never Brainbase's judgment record:
158
+ * the plaza (判断) is not touched by it, and the world says where it came from. This package only draws
159
+ * it; the host computes the states on its server, with its own organization and member boundaries.
160
+ */
161
+ export declare const WORLD_AGENTS_CONTRACT_VERSION: "world-agents.v1";
162
+ /** Where an agent stands: the common headquarters (cross-business work) or a business it serves. */
163
+ export type WorldAgentZone = 'hq' | 'business';
164
+ /** What the agent is doing, decided by the host; `unconfirmed` when it could not be confirmed (never idle). */
165
+ export type WorldAgentState = 'idle' | 'working' | 'needs_you' | 'blocked' | 'unconfirmed';
166
+ /** How recent the observation is, against the host's `stale_threshold_sec`. */
167
+ export type WorldAgentFreshness = 'fresh' | 'stale' | 'unconfirmed';
168
+ export interface WorldAgent {
169
+ readonly agent_id: string;
170
+ readonly slug: string;
171
+ readonly display_name: string;
172
+ /** One line on what the agent is for. */
173
+ readonly role_summary: string | null;
174
+ readonly zone: WorldAgentZone;
175
+ /** The business code the agent belongs to (its city), or the organization's own code for `hq`. */
176
+ readonly home_project_code: string | null;
177
+ /** Where the agent works now (Step 2); null while only the home is known. */
178
+ readonly current_project_code: string | null;
179
+ readonly state: WorldAgentState;
180
+ readonly freshness: WorldAgentFreshness;
181
+ /** When the state was observed (ISO 8601), or null when never observed. */
182
+ readonly observed_at: string | null;
183
+ readonly age_sec: number | null;
184
+ /** A non-confidential line the host composes from fixed phrases (no item titles, no chat text). */
185
+ readonly summary_line: string | null;
186
+ readonly blocker_code: string | null;
187
+ readonly metrics: {
188
+ readonly active_workers: number | null;
189
+ readonly needs_you_count: number | null;
190
+ readonly open_items_count: number | null;
191
+ };
192
+ /** The one way down; `href` only when `available`, else why there is none (story-world-clickable-honesty-v1 AC-03). */
193
+ readonly drilldown: {
194
+ readonly available: boolean;
195
+ readonly href: string | null;
196
+ readonly unavailable_reason: string | null;
197
+ };
198
+ }
199
+ export interface WorldAgentsResponse {
200
+ readonly contract_version: typeof WORLD_AGENTS_CONTRACT_VERSION;
201
+ readonly organization_id: string;
202
+ readonly viewer_scope: 'owner' | 'member';
203
+ readonly source: string;
204
+ /** Always false: the projection is not Brainbase's judgment record. */
205
+ readonly is_canonical_judgment: false;
206
+ readonly snapshot_interval_sec: number;
207
+ readonly stale_threshold_sec: number;
208
+ readonly read_state: 'confirmed' | 'partial' | 'unavailable';
209
+ readonly checked_at: string;
210
+ readonly agents: readonly WorldAgent[];
211
+ }
126
212
  /**
127
213
  * The projects of a Graph v2 → cities (top-level projects) and their districts
128
214
  * (projects whose `metadata.parent_project_id` names another project). A
@@ -133,7 +219,7 @@ export type WorldBusinessesResponse = ({
133
219
  */
134
220
  export declare function projectWorldFromGraph(graph: Pick<GraphFileV2, 'entities'> & {
135
221
  readonly edges?: GraphFileV2['edges'];
136
- }, now?: Date): WorldBusinessProjection;
222
+ }, now?: Date, options?: WorldProjectionOptions): WorldBusinessProjectionResult;
137
223
  /**
138
224
  * The vocabulary the world draws with: the host's kinds in their order, then
139
225
  * kinds the Graph uses that the host did not name (under their own value),
@@ -151,7 +237,7 @@ export declare function readWorldVocabulary(path: string): Promise<WorldVocabula
151
237
  export declare function readWorldBusinesses(context: Pick<LocalWebModuleContext, 'dataDir'>, options?: {
152
238
  readonly vocabulary?: WorldVocabularyConfig;
153
239
  readonly now?: () => Date;
154
- }): Promise<WorldBusinessesResponse>;
240
+ } & WorldProjectionOptions): Promise<WorldBusinessesResponse>;
155
241
  /**
156
242
  * The world of an organization from the project and glossary-term records its Graph API returns, for an
157
243
  * organization web that hosts the same world screen (P16). Pure: the caller reads the records with the
@@ -165,7 +251,7 @@ export declare function projectOrganizationWorld(records: {
165
251
  readonly server: string;
166
252
  readonly vocabulary?: WorldVocabularyConfig;
167
253
  readonly now?: Date;
168
- }): WorldBusinessesResponse;
254
+ } & WorldProjectionOptions): WorldBusinessesResponse;
169
255
  export interface WorldJudgmentPlace {
170
256
  readonly decision_attempt_id: string;
171
257
  /** Repository the judgment Host recorded for the turn (`turn-input.json` project_code); null when unrecorded. */
@@ -41,6 +41,50 @@ const KIND_PALETTE = ['#1261ad', '#b07a1f', '#35684c', '#6b4fa0', '#a8433a', '#2
41
41
  const UNCLASSIFIED_COLOR = '#69746d';
42
42
  const HEX_COLOR = /^#[0-9a-f]{6}$/iu;
43
43
  const ACTIVITY_WINDOW_DAYS = 30;
44
+ /** Lifecycle states that are no longer a business on the map (as the organization Graph records them). */
45
+ const INACTIVE_LIFECYCLE = new Set(['retired', 'merged', 'inactive', 'superseded']);
46
+ /** Record statuses of a business that is over (the same words the project directory treats as archived). */
47
+ const ARCHIVED_STATUS = new Set(['archived', 'completed', 'closed']);
48
+ /**
49
+ * Names of the probes and acceptance runs that were left in Graphs as active projects. A project whose
50
+ * code or name matches one is kept off the map by default (layer 2; layer 1 is the record's own flags).
51
+ */
52
+ export const WORLD_TEST_PROJECT_PATTERNS = Object.freeze([
53
+ /^zz[\s_-]*probe/iu,
54
+ /^agent-live-acceptance-/iu,
55
+ /^codex-(crud|lock-probe)/iu,
56
+ /(^|[-_])(e2e|smoke|test)[-_]/iu,
57
+ ]);
58
+ function lowerText(value) {
59
+ return text(value)?.toLowerCase() ?? null;
60
+ }
61
+ /**
62
+ * Why a project is kept off the world by default, or null when it is drawn. `top` is true for a
63
+ * business (a city): a finished business is kept off, while a finished engagement inside a city stays
64
+ * as its empty lot (story-world-size-and-activity-v1).
65
+ */
66
+ export function worldProjectFilterReason(entity, { top = true } = {}) {
67
+ const metadata = entity.metadata ?? {};
68
+ if (INACTIVE_LIFECYCLE.has(lowerText(metadata.lifecycle_status) ?? ''))
69
+ return 'lifecycle';
70
+ if (metadata.is_test === true)
71
+ return 'test_flag';
72
+ if (lowerText(metadata.world_visibility) === 'hidden')
73
+ return 'hidden';
74
+ if (top && [metadata.status, metadata.operational_status, metadata.record_status].some((value) => ARCHIVED_STATUS.has(lowerText(value) ?? '')))
75
+ return 'archived';
76
+ const names = [text(metadata.code), text(entity.name)].filter((value) => value !== null);
77
+ if (names.some((value) => WORLD_TEST_PROJECT_PATTERNS.some((pattern) => pattern.test(value))))
78
+ return 'test_name';
79
+ return null;
80
+ }
81
+ /**
82
+ * The AI agents a host projects onto the world (story-world-agents-step1-v1, design item #707 §1.3).
83
+ * It is an execution-state projection (for example Orca run receipts), never Brainbase's judgment record:
84
+ * the plaza (判断) is not touched by it, and the world says where it came from. This package only draws
85
+ * it; the host computes the states on its server, with its own organization and member boundaries.
86
+ */
87
+ export const WORLD_AGENTS_CONTRACT_VERSION = 'world-agents.v1';
44
88
  function isRecord(value) {
45
89
  return value !== null && typeof value === 'object' && !Array.isArray(value);
46
90
  }
@@ -64,9 +108,34 @@ function engagementOf(entity) {
64
108
  * Nothing here knows any organization's words: kinds and statuses are the
65
109
  * Graph's own values.
66
110
  */
67
- export function projectWorldFromGraph(graph, now = new Date()) {
111
+ export function projectWorldFromGraph(graph, now = new Date(), options = {}) {
68
112
  const projects = graph.entities.filter((entity) => entity.type === 'project');
69
- const active = projects.filter((entity) => !entity.validTo || Date.parse(entity.validTo) > now.getTime());
113
+ const current = projects.filter((entity) => !entity.validTo || Date.parse(entity.validTo) > now.getTime());
114
+ // The display filter (two layers: the record's own flags, then test-like names). A project under a
115
+ // filtered one goes with it, so it is not miscounted as an engagement whose business is missing.
116
+ const filtered = new Set();
117
+ if (!options.includeTest) {
118
+ const currentById = new Map(current.map((entity) => [entity.id, entity]));
119
+ const isTop = (entity) => {
120
+ const parentId = text(entity.metadata?.parent_project_id);
121
+ return !parentId || parentId === entity.id || !currentById.has(parentId);
122
+ };
123
+ for (const entity of current) {
124
+ if (worldProjectFilterReason(entity, { top: isTop(entity) }))
125
+ filtered.add(entity.id);
126
+ }
127
+ for (let grew = filtered.size > 0; grew;) {
128
+ grew = false;
129
+ for (const entity of current) {
130
+ const parentId = text(entity.metadata?.parent_project_id);
131
+ if (!filtered.has(entity.id) && parentId && filtered.has(parentId)) {
132
+ filtered.add(entity.id);
133
+ grew = true;
134
+ }
135
+ }
136
+ }
137
+ }
138
+ const active = current.filter((entity) => !filtered.has(entity.id));
70
139
  const byId = new Map(active.map((entity) => [entity.id, entity]));
71
140
  // A district hangs on its top-level ancestor, so nested projects stay in one city.
72
141
  const topOf = (entity) => {
@@ -163,7 +232,8 @@ export function projectWorldFromGraph(graph, now = new Date()) {
163
232
  return {
164
233
  businesses: businesses.sort((a, b) => a.name.localeCompare(b.name, 'ja')),
165
234
  unplaced,
166
- excluded: { inactive: projects.length - active.length },
235
+ excluded: { inactive: projects.length - current.length },
236
+ filtered_out_count: filtered.size,
167
237
  };
168
238
  }
169
239
  /**
@@ -270,7 +340,7 @@ export async function readWorldBusinesses(context, options = {}) {
270
340
  catch (error) {
271
341
  return { status: 'unavailable', version: WORLD_EXTENSION_VERSION, reason: error instanceof Error ? error.message : 'graph_unreadable' };
272
342
  }
273
- const projection = projectWorldFromGraph(graph, now);
343
+ const projection = projectWorldFromGraph(graph, now, { includeTest: options.includeTest === true });
274
344
  return {
275
345
  status: 'ok',
276
346
  version: WORLD_EXTENSION_VERSION,
@@ -292,7 +362,7 @@ export function projectOrganizationWorld(records, options) {
292
362
  memberOf: [],
293
363
  assignedTo: [],
294
364
  });
295
- const projection = projectWorldFromGraph(graph, now);
365
+ const projection = projectWorldFromGraph(graph, now, { includeTest: options.includeTest === true });
296
366
  return {
297
367
  status: 'ok',
298
368
  version: WORLD_EXTENSION_VERSION,
@@ -342,10 +412,12 @@ function createWorldModule(context, read) {
342
412
  async handle(request, response) {
343
413
  if (request.method !== 'GET')
344
414
  return false;
345
- const path = requestUrl(request).pathname;
415
+ const url = requestUrl(request);
416
+ const path = url.pathname;
346
417
  if (path === `/api/extensions/${WORLD_EXTENSION_ID}/businesses`) {
347
418
  response.setHeader('Cache-Control', 'no-store');
348
- writeJson(response, 200, await read());
419
+ // The single owner may look at what the display filter keeps off the map (for checking only).
420
+ writeJson(response, 200, await read({ includeTest: url.searchParams.get('include_test') === '1' }));
349
421
  return true;
350
422
  }
351
423
  // This Mac keeps no Canonical Task store, so the work inside a city is not connected here
@@ -372,6 +444,6 @@ export function createWorldExtension(options = {}) {
372
444
  screenEntry: 'world-view.js',
373
445
  // P17: the world sits above the home and opens first.
374
446
  navPosition: 'first',
375
- createModule: (context) => createWorldModule(context, () => readWorldBusinesses(context, { vocabulary: options.vocabulary, now: context.now })),
447
+ createModule: (context) => createWorldModule(context, (read) => readWorldBusinesses(context, { vocabulary: options.vocabulary, now: context.now, ...read })),
376
448
  };
377
449
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unson/brainbase-mcp",
3
- "version": "0.51.10",
3
+ "version": "0.51.11",
4
4
  "description": "Local-first Brainbase judgment OS that lets supported AI agents reuse a user's approved goals, priorities, decisions, and judgment criteria.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -681,5 +681,5 @@
681
681
  "url": "https://github.com/Unson-LLC/brainbase/issues"
682
682
  },
683
683
  "homepage": "https://github.com/Unson-LLC/brainbase#readme",
684
- "gitHead": "4f0cd113a8fe2048bf5c2882f2c9e1402b32497a"
684
+ "gitHead": "560d58fe291180e921a11bb50aec595292dc5dd8"
685
685
  }
@@ -390,3 +390,27 @@
390
390
 
391
391
  /* A real record without a visible lot remains readable as detached details. */
392
392
  .bb-world-canvas-ui .bb-world-canvas-task.is-unanchored::after { display: none; }
393
+
394
+ /* Tier B (story-world-agents-step1-v1): the standing limits gathered behind one chip under the actionable
395
+ rows. Folded by default, never removed; it opens itself while a read has failed. */
396
+ .bb-world-canvas-ui .bb-world-canvas-constraints {
397
+ display: grid;
398
+ justify-items: start;
399
+ gap: 6px;
400
+ max-width: 100%;
401
+ pointer-events: auto;
402
+ }
403
+ .bb-world-canvas-ui .bb-world-canvas-constraints-toggle {
404
+ padding: 4px 10px;
405
+ border: 1px dashed rgb(255 255 255 / 55%);
406
+ border-radius: 999px;
407
+ background: rgb(13 25 46 / 62%);
408
+ color: #fff;
409
+ font: inherit;
410
+ font-size: 12px;
411
+ cursor: pointer;
412
+ }
413
+ .bb-world-canvas-ui .bb-world-canvas-constraints.has-incident .bb-world-canvas-constraints-toggle { border-style: solid; border-color: #f0b648; }
414
+ .bb-world-canvas-ui .bb-world-canvas-constraints-toggle:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
415
+ .bb-world-canvas-ui .bb-world-canvas-constraints-list { display: grid; justify-items: start; gap: 6px; max-width: 100%; }
416
+ .bb-world-canvas-ui .bb-world-canvas-constraints-list[hidden] { display: none; }
@@ -59,6 +59,13 @@ const nodeList = (nodes) => (Array.isArray(nodes) ? nodes : [nodes]).filter((nod
59
59
  * remains in help. No summary is inferred from a long or nonurgent notice.
60
60
  * A quest with a `link` or an `action` is pressable as a whole row; one without
61
61
  * is drawn flat and may say its `reason` (why nothing opens from it).
62
+ *
63
+ * Tiers (story-world-agents-step1-v1): a quest with `tier: 'constraint'` is a standing limit of what the
64
+ * screen is connected to (未接続, 一部だけ読めた); it is never hidden, but gathered behind one chip
65
+ * (`計器の制約 N件 ▾`) that opens every row in one press. Other quests are the actionable exceptions; at
66
+ * most `questLimit` of them stand at the top and the rest are counted on the same chip. A quest with
67
+ * `incident: true` (a read that failed now) opens the chip by itself until the viewer folds it.
68
+ * @param {number} [options.questLimit] At most this many actionable rows stand at the top (default: all).
62
69
  */
63
70
  export function createWorldCanvasUI({
64
71
  doc,
@@ -69,6 +76,7 @@ export function createWorldCanvasUI({
69
76
  onSky,
70
77
  onDismissTask,
71
78
  context = {},
79
+ questLimit = Number.POSITIVE_INFINITY,
72
80
  }) {
73
81
  const id = `bb-world-canvas-${++instanceId}`;
74
82
  const listeners = [];
@@ -174,6 +182,30 @@ export function createWorldCanvasUI({
174
182
  });
175
183
  contextRoot.append(contextNextAction);
176
184
  const quests = element('div', 'bb-world-canvas-quests', null, { 'aria-live': 'polite', 'aria-label': '確認が必要なこと' });
185
+ // Tier B: the standing limits (and the actionable rows past the limit) behind one chip, never hidden.
186
+ const constraints = element('div', 'bb-world-canvas-constraints');
187
+ const constraintsToggle = element('button', 'bb-world-canvas-constraints-toggle', '', { type: 'button', 'aria-expanded': 'false', 'aria-controls': `${id}-constraints` });
188
+ const constraintsList = element('div', 'bb-world-canvas-constraints-list', null, { id: `${id}-constraints` });
189
+ constraintsList.hidden = true;
190
+ constraints.append(constraintsToggle, constraintsList);
191
+ const tiers = { actionable: 0, constraint: 0, overflow: 0, incident: 0 };
192
+ let constraintsOpen = null;
193
+ function renderConstraints() {
194
+ const count = tiers.constraint + tiers.overflow;
195
+ if (count === 0) {
196
+ constraints.remove();
197
+ return;
198
+ }
199
+ const open = constraintsOpen ?? tiers.incident > 0;
200
+ const parts = [tiers.constraint ? `計器の制約 ${tiers.constraint}件` : null, tiers.overflow ? `ほかの確認 ${tiers.overflow}件` : null].filter(Boolean);
201
+ constraintsToggle.textContent = `${parts.join('・')} ${open ? '▴' : '▾'}`;
202
+ constraintsToggle.setAttribute('aria-expanded', String(open));
203
+ constraintsToggle.setAttribute('aria-label', `${parts.join('・')}(${open ? 'たたむ' : '理由を全部見る'})`);
204
+ constraints.classList.toggle('is-open', open);
205
+ constraints.classList.toggle('has-incident', tiers.incident > 0);
206
+ constraintsList.hidden = !open;
207
+ quests.append(constraints);
208
+ }
177
209
 
178
210
  const edge = button('bb-world-canvas-edge', '都市の詳細を開く', '');
179
211
  edge.setAttribute('aria-controls', `${id}-rail`);
@@ -376,7 +408,7 @@ export function createWorldCanvasUI({
376
408
  activate('help', help);
377
409
  focus(helpTitle);
378
410
  }
379
- function addNote({ label = '', text = '', tone = '', summary, link = null, action = null, reason = null } = {}) {
411
+ function addNote({ label = '', text = '', tone = '', summary, link = null, action = null, reason = null, tier = null, incident = false } = {}) {
380
412
  if (disposed) return;
381
413
  const note = element('section', 'bb-world-canvas-note');
382
414
  if (label) note.append(element('h3', '', label));
@@ -405,11 +437,25 @@ export function createWorldCanvasUI({
405
437
  // Why nothing opens from here (未接続 and the like), said in the row instead of only in help.
406
438
  quest.append(element('span', 'bb-world-canvas-quest-reason', reason.trim()));
407
439
  }
408
- quests.append(quest);
440
+ if (incident) tiers.incident += 1;
441
+ if (tier === 'constraint') {
442
+ tiers.constraint += 1;
443
+ quest.classList.add('is-constraint');
444
+ constraintsList.append(quest);
445
+ } else if (tiers.actionable >= questLimit) {
446
+ tiers.overflow += 1;
447
+ constraintsList.append(quest);
448
+ } else {
449
+ tiers.actionable += 1;
450
+ quests.append(quest);
451
+ }
452
+ renderConstraints();
409
453
  }
410
454
  function clearNotes() {
411
455
  if (disposed) return;
412
456
  quests.replaceChildren();
457
+ constraintsList.replaceChildren();
458
+ Object.assign(tiers, { actionable: 0, constraint: 0, overflow: 0, incident: 0 });
413
459
  notes.replaceChildren();
414
460
  }
415
461
  function dismissOverlay() {
@@ -448,6 +494,10 @@ export function createWorldCanvasUI({
448
494
  listen(railClose, 'click', closeRail);
449
495
  listen(taskClose, 'click', dismissTask);
450
496
  listen(helpButton, 'click', toggleHelp);
497
+ listen(constraintsToggle, 'click', () => {
498
+ constraintsOpen = !(constraintsOpen ?? tiers.incident > 0);
499
+ renderConstraints();
500
+ });
451
501
  listen(helpClose, 'click', closeHelp);
452
502
  listen(root, 'keydown', (event) => {
453
503
  if (event.key === 'Escape' && !event.defaultPrevented && dismissOverlay()) {
@@ -1093,3 +1093,60 @@ button.bb-world-pulse-crumb:hover { background: var(--bb-color-accent-soft); col
1093
1093
  .bb-world-actor-mark.is-running::after { animation: none; }
1094
1094
  .bb-world-pulse-row { transition: none; }
1095
1095
  }
1096
+
1097
+ /* --- AI agents (story-world-agents-step1-v1) -------------------------------------------------------
1098
+ The overview stays quiet: needs_you (amber, "?") is the strongest, blocked (vermilion, "!", another
1099
+ shape) the second, working a low teal, idle melts in. Unconfirmed is grey and dashed, never idle.
1100
+ Nothing here blinks or moves. */
1101
+ .bb-world-label.is-agent-hq {
1102
+ border-style: dashed;
1103
+ color: var(--bb-color-muted);
1104
+ font-size: 11px;
1105
+ }
1106
+ .bb-world-label.is-agent { font-size: 11px; color: var(--bb-color-muted); background: rgb(255 255 255 / 72%); }
1107
+ .bb-world-label.is-agent.is-needs_you { border: 2px solid #e8a10c; color: #7a4f00; background: #fff6df; font-weight: var(--bb-font-weight-medium); }
1108
+ .bb-world-label.is-agent.is-blocked { border: 2px solid #d2462b; border-radius: 2px; color: #8f2a17; background: #fff0ec; font-weight: var(--bb-font-weight-medium); }
1109
+ .bb-world-label.is-agent.is-working { border-color: #9cc9bd; }
1110
+ .bb-world-label.is-agent.is-unconfirmed,
1111
+ .bb-world-label.is-agent.is-stale { border-style: dashed; color: #7d8589; }
1112
+ .bb-world-label.is-agent.is-caution { outline: 1px dashed #6f6a60; outline-offset: 2px; }
1113
+
1114
+ .bb-world-pulse-agents { margin: 4px 0 6px; padding: 6px 8px; border-left: 3px solid #9cc9bd; background: rgb(255 255 255 / 60%); }
1115
+ .bb-world-pulse-agents.is-attention { border-left-color: #e8a10c; }
1116
+ .bb-world-pulse-agents.is-unconfirmed { border-left: 3px dashed #9aa3a6; }
1117
+ .bb-world-pulse-agents p { margin: 0; }
1118
+ .bb-world-pulse-agents-count { font-size: 12px; }
1119
+ .bb-world-pulse-agents-source { font-size: 10px; color: var(--bb-color-muted); }
1120
+
1121
+ .bb-world-agent-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
1122
+ .bb-world-agent-row {
1123
+ display: grid;
1124
+ grid-template-columns: 1.4em minmax(0, 1fr);
1125
+ gap: 2px 6px;
1126
+ width: 100%;
1127
+ padding: 6px 8px;
1128
+ border: 1px solid var(--bb-color-border);
1129
+ border-radius: 6px;
1130
+ background: var(--bb-color-surface, #fff);
1131
+ color: inherit;
1132
+ font: inherit;
1133
+ text-align: start;
1134
+ cursor: pointer;
1135
+ }
1136
+ .bb-world-agent-row .bb-world-agent-name { grid-column: 2; font-weight: var(--bb-font-weight-medium); }
1137
+ .bb-world-agent-row .bb-world-agent-row-state { grid-column: 2; font-size: 12px; color: var(--bb-color-muted); }
1138
+ .bb-world-agent-mark { grid-row: 1 / span 2; align-self: center; font-weight: 700; text-align: center; }
1139
+ .bb-world-agent-row.is-needs_you { border: 2px solid #e8a10c; }
1140
+ .bb-world-agent-row.is-needs_you .bb-world-agent-mark { color: #b07600; }
1141
+ .bb-world-agent-row.is-blocked { border: 2px solid #d2462b; border-radius: 2px; }
1142
+ .bb-world-agent-row.is-blocked .bb-world-agent-mark { color: #b3361f; }
1143
+ .bb-world-agent-row.is-unconfirmed,
1144
+ .bb-world-agent-row.is-stale { border-style: dashed; }
1145
+ .bb-world-agent-row:focus-visible { outline: 2px solid var(--bb-color-accent, #087d62); outline-offset: 2px; }
1146
+ .bb-world-agent-drilldown.is-unavailable { color: var(--bb-color-muted); cursor: not-allowed; }
1147
+ .bb-world-agent-source { margin: 8px 0 0; font-size: 11px; color: var(--bb-color-muted); }
1148
+ .bb-world-agent-state.is-needs_you dd:first-of-type { color: #7a4f00; font-weight: var(--bb-font-weight-medium); }
1149
+ .bb-world-agent-state.is-blocked dd:first-of-type { color: #8f2a17; font-weight: var(--bb-font-weight-medium); }
1150
+ .bb-world-agent-state.is-unconfirmed dd:first-of-type,
1151
+ .bb-world-agent-state.is-stale dd:first-of-type { color: #6b7377; }
1152
+ .bb-world-label.is-agent-hq.has-exception { border-style: solid; border-color: #e8a10c; color: var(--bb-color-ink); }