@productbrain/mcp 0.0.1-beta.14839 → 0.0.1-beta.14848

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.
@@ -8,6 +8,7 @@ import {
8
8
  QUESTION_SEAT_WORDS,
9
9
  QUESTION_TEAM_NEXT,
10
10
  SPINE_RUNG_SEQUENCE,
11
+ START_DOORS,
11
12
  START_NOTES_NOT_LOADED_LINE,
12
13
  WORKSPACE_CLOSED,
13
14
  acceptCall,
@@ -20,6 +21,7 @@ import {
20
21
  formatGatewaySeamSummary,
21
22
  formatInviteSentence,
22
23
  formatSeatSentence,
24
+ formatSessionStartLines,
23
25
  getAgentSessionId,
24
26
  getApiKeyId,
25
27
  getApiKeyScope,
@@ -51,7 +53,7 @@ import {
51
53
  startAgentSession,
52
54
  startTimingLine,
53
55
  withAcceptPrompt
54
- } from "./chunk-TMS4QINE.js";
56
+ } from "./chunk-B4FRHJNW.js";
55
57
 
56
58
  // src/server.ts
57
59
  import { McpServer as McpServer2 } from "@modelcontextprotocol/server";
@@ -5759,58 +5761,6 @@ function formatTimeAgo(ms) {
5759
5761
  // src/tools/collections.ts
5760
5762
  import { z as z22 } from "zod/v3";
5761
5763
 
5762
- // src/lib/scopedCache.ts
5763
- var ScopedCache = class {
5764
- constructor(ttlMs, maxScopes = 100) {
5765
- this.ttlMs = ttlMs;
5766
- this.maxScopes = maxScopes;
5767
- }
5768
- store = /* @__PURE__ */ new Map();
5769
- get(scope) {
5770
- const e = this.store.get(scope);
5771
- if (!e) return void 0;
5772
- if (Date.now() > e.expiresAt) {
5773
- this.store.delete(scope);
5774
- return void 0;
5775
- }
5776
- return e.value;
5777
- }
5778
- set(scope, value) {
5779
- this.store.set(scope, { value, expiresAt: Date.now() + this.ttlMs });
5780
- if (this.store.size > this.maxScopes) this.evict();
5781
- }
5782
- delete(scope) {
5783
- this.store.delete(scope);
5784
- }
5785
- clear() {
5786
- this.store.clear();
5787
- }
5788
- size() {
5789
- return this.store.size;
5790
- }
5791
- /** Drop expired entries first; if still over budget, drop the oldest-expiring. */
5792
- evict() {
5793
- const now = Date.now();
5794
- for (const [k, e] of this.store) {
5795
- if (now > e.expiresAt) this.store.delete(k);
5796
- }
5797
- if (this.store.size > this.maxScopes) {
5798
- const sorted = [...this.store.entries()].sort((a, b) => a[1].expiresAt - b[1].expiresAt);
5799
- const overBy = sorted.length - this.maxScopes;
5800
- for (let i = 0; i < overBy; i++) {
5801
- this.store.delete(sorted[i][0]);
5802
- }
5803
- }
5804
- }
5805
- };
5806
- var COLLECTION_CACHE_TTL_MS = 6e4;
5807
-
5808
- // src/lib/collectionCache.ts
5809
- var collectionCache = new ScopedCache(COLLECTION_CACHE_TTL_MS);
5810
- function invalidateCollectionCacheForScope() {
5811
- collectionCache.delete(cacheScope());
5812
- }
5813
-
5814
5764
  // src/lib/bodyTemplate.ts
5815
5765
  function readBodyTemplateGuidance(bodyTemplate) {
5816
5766
  if (!bodyTemplate || bodyTemplate.length === 0) return void 0;
@@ -6276,7 +6226,6 @@ async function handleUpdate(slug, name, description, purpose, icon, navGroup, fi
6276
6226
  ...fields !== void 0 && { fields },
6277
6227
  ...metaFields(meta)
6278
6228
  });
6279
- invalidateCollectionCacheForScope();
6280
6229
  const changes = [name && "name", description && "description", purpose && "purpose", icon && "icon", navGroup && "navGroup", fields && "fields", meta.axis !== void 0 && "axis", meta.stageLabelMap !== void 0 && "stageLabelMap", meta.defaultCanonicalKey !== void 0 && "defaultCanonicalKey", meta.defaultWorkflowStatus !== void 0 && "defaultWorkflowStatus", meta.validWorkflowStatuses !== void 0 && "validWorkflowStatuses", meta.classificationCheck !== void 0 && "classificationCheck", meta.classificationPriority !== void 0 && "classificationPriority", meta.qualityCriteria !== void 0 && "qualityCriteria", meta.statusList !== void 0 && "statusList"].filter(Boolean).join(", ");
6281
6230
  return {
6282
6231
  content: [{
@@ -10465,7 +10414,7 @@ function formatNoticeLines(notices) {
10465
10414
  }
10466
10415
 
10467
10416
  // src/tools/session.ts
10468
- var START_PREFLIGHT_NEXT = 'Next: context action=preflight collection=<kind> links=[{"type":"part_of","entryId":"<PARENT-ID>"}]';
10417
+ var START_PREFLIGHT_NEXT = START_DOORS.mcp.preflight;
10469
10418
  var SESSION_ACTIONS = ["start", "close", "status", "wrapup-review", "resume"];
10470
10419
  var TEAM_PARAM_DESCRIPTION = "For 'start': the team the role is held in, by its 'TEAM-<n>' id \u2014 only needed with role, when you hold that role in more than one team; a refusal that names the way in prints it.";
10471
10420
  var previewParams = {
@@ -10564,32 +10513,28 @@ async function readAllowanceLine() {
10564
10513
  const usage = await kernelQuery("usage.getWorkspaceSummary", { periodDays: 1 }).catch(() => null);
10565
10514
  return usage?.allowanceLine;
10566
10515
  }
10567
- async function handleStart2(data, clientName) {
10568
- const result2 = await startAgentSession(data?.role, data?.team, clientName, previewFields(data?.preview));
10569
- const lines = [];
10570
- lines.push(
10571
- `Session ${result2.sessionId} active. Pass sessionId="${result2.sessionId}" on every write: the connection does not remember your session between calls. Initiated by ${result2.initiatedBy}. Workspace ${result2.workspaceName}. Scope: ${result2.toolsScope}. Orient with a task before substantive work: it is advice for captures, relations, accepts, ticks and questions; workflow checkpoints and organisation-structure writes still require it.`
10572
- );
10573
- lines.push(startTimingLine(result2.seatMs, result2.notesMs), ...result2.startNotesLoaded ? [] : [START_NOTES_NOT_LOADED_LINE]);
10574
- const methodServed = Boolean(result2.briefing?.methods?.method);
10575
- if (!methodServed) lines.push(FEEDBACK_SUBMIT_HINT);
10576
- const allowanceLine = await readAllowanceLine();
10577
- if (allowanceLine) lines.push(allowanceLine);
10516
+ function formatStartText(result2, allowanceLine) {
10578
10517
  const questionNotice = result2.notices?.find((n) => n.source === QUESTION_ACK_GATE_SOURCE_ID);
10579
10518
  const noticeLines = formatNoticeLines(result2.notices?.filter((n) => n !== questionNotice));
10580
- if (noticeLines.length > 0) lines.push("", "Notices:", ...noticeLines);
10581
- const openQuestions = (questionNotice?.payload?.questions ?? []).map((q) => ({ entryId: q.sourcePointer, title: q.name, ageDays: q.ageDays }));
10582
- lines.push("");
10583
- for (const line of formatBriefingLines({
10584
- workspaceName: result2.workspaceName,
10519
+ return formatSessionStartLines({
10520
+ surface: "mcp",
10585
10521
  facts: result2.briefing,
10586
10522
  ruleLists: result2.ruleLists,
10587
- openQuestions,
10588
- openQuestionsTruncated: questionNotice?.payload?.truncated === true,
10589
- surface: "mcp",
10590
- sessionStart: true
10591
- })) lines.push(line);
10592
- if (!methodServed) lines.push("", START_PREFLIGHT_NEXT);
10523
+ workspaceName: result2.workspaceName,
10524
+ sessionLines: [
10525
+ `Session ${result2.sessionId} active. Pass sessionId="${result2.sessionId}" on every write: the connection does not remember your session between calls. Initiated by ${result2.initiatedBy}. Workspace ${result2.workspaceName}. Scope: ${result2.toolsScope}. Orient with a task before substantive work: it is advice for captures, relations, accepts, ticks and questions; workflow checkpoints and organisation-structure writes still require it.`
10526
+ ],
10527
+ feedbackLine: FEEDBACK_SUBMIT_HINT,
10528
+ allowanceLine,
10529
+ // TASK-1014 (DEC-2195): the same line the CLI shows at start
10530
+ openQuestions: { count: questionNotice?.payload?.questions.length ?? 0, atLeast: questionNotice?.payload?.truncated === true },
10531
+ noticeLines: noticeLines.length > 0 ? ["", "Notices:", ...noticeLines] : []
10532
+ });
10533
+ }
10534
+ async function handleStart2(data, clientName) {
10535
+ const result2 = await startAgentSession(data?.role, data?.team, clientName, previewFields(data?.preview));
10536
+ const allowanceLine = await readAllowanceLine();
10537
+ const lines = [...formatStartText(result2, allowanceLine), ...result2.startNotesLoaded ? [] : [START_NOTES_NOT_LOADED_LINE], startTimingLine(result2.seatMs, result2.notesMs)];
10593
10538
  const summary = `Session ${result2.sessionId} active. Workspace ${result2.workspaceName}. Pass sessionId="${result2.sessionId}" on every write. Orient with a task first; workflow checkpoints and organisation-structure writes still require it.`;
10594
10539
  return {
10595
10540
  content: [{ type: "text", text: lines.join("\n") }],
@@ -12364,7 +12309,7 @@ var INSTRUCTIONS = [
12364
12309
  "Call `session action=start` first. The reply names:",
12365
12310
  "- the workspace and the role you act as;",
12366
12311
  "- notices, including open questions routed to you;",
12367
- "- the rule lists that bind you, each rule as one sentence with its why, its owner role and, when it has one, its date.",
12312
+ "- the rule lists that bind you, each rule as one sentence with its why.",
12368
12313
  "",
12369
12314
  "Read those rules before you propose or build. If the work conflicts with one, stop, name the rule and ask the user before going on. Never design around a rule.",
12370
12315
  "",
@@ -12463,4 +12408,4 @@ export {
12463
12408
  SERVER_VERSION,
12464
12409
  createProductBrainServer
12465
12410
  };
12466
- //# sourceMappingURL=chunk-5LQBJEH4.js.map
12411
+ //# sourceMappingURL=chunk-VOHLFDOD.js.map