@tacitai/mcp-server 0.6.27 → 0.6.29

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/dist/client.d.ts CHANGED
@@ -112,4 +112,14 @@ export declare class TokenExpiredError extends Error {
112
112
  /** HTTPS mode: bind the caller's token/apiUrl/principal to everything run inside fn. */
113
113
  export declare function runWithRequestContext<T>(token: string, apiUrl: string, fn: () => Promise<T>, principal?: string): Promise<T>;
114
114
  export declare function getRequestPrincipal(): string | null;
115
+ export type AutonomyLevel = 'GUEST' | 'SCRIBE' | 'MENTAT' | 'TWIN';
116
+ export declare function parseAutonomyLevel(raw: unknown): AutonomyLevel;
117
+ export declare function autonomyAtLeast(current: AutonomyLevel, required: AutonomyLevel): boolean;
118
+ export declare function getRequestAutonomy(principal: string): Promise<AutonomyLevel | {
119
+ error: 'token_expired';
120
+ }>;
121
+ export declare function ensureAutonomy(principal: string): Promise<AutonomyLevel | {
122
+ error: 'token_expired';
123
+ }>;
124
+ export declare function getCachedAutonomy(principal: string): AutonomyLevel | null;
115
125
  export declare function getClient(): TacitClient;
package/dist/client.js CHANGED
@@ -434,6 +434,77 @@ export function runWithRequestContext(token, apiUrl, fn, principal) {
434
434
  export function getRequestPrincipal() {
435
435
  return requestStore.getStore()?.principal ?? null;
436
436
  }
437
+ const AUTONOMY_ORDINAL = { GUEST: 0, SCRIBE: 1, MENTAT: 2, TWIN: 3 };
438
+ export function parseAutonomyLevel(raw) {
439
+ if (typeof raw !== 'string' || !raw)
440
+ return 'SCRIBE';
441
+ const upper = raw.toUpperCase();
442
+ if (upper === 'OWNER')
443
+ return 'TWIN';
444
+ if (upper === 'GUEST' || upper === 'SCRIBE' || upper === 'MENTAT' || upper === 'TWIN')
445
+ return upper;
446
+ return 'SCRIBE';
447
+ }
448
+ export function autonomyAtLeast(current, required) {
449
+ return AUTONOMY_ORDINAL[current] >= AUTONOMY_ORDINAL[required];
450
+ }
451
+ const autonomyCache = new Map();
452
+ function envFallbackAutonomy() {
453
+ return parseAutonomyLevel(process.env['TACIT_AUTONOMY_LEVEL']);
454
+ }
455
+ export async function getRequestAutonomy(principal) {
456
+ const cached = autonomyCache.get(principal);
457
+ if (cached)
458
+ return cached;
459
+ const token = process.env['TACIT_TOKEN'] ?? '';
460
+ if (!token) {
461
+ const level = envFallbackAutonomy();
462
+ autonomyCache.set(principal, level);
463
+ return level;
464
+ }
465
+ const apiUrl = (process.env['TACIT_API_URL'] ?? 'http://localhost:7473').replace(/\/$/, '');
466
+ try {
467
+ const resp = await globalThis.fetch(`${apiUrl}/api/v1/people/myself`, {
468
+ headers: { Authorization: `Bearer ${token}`, Accept: 'application/json' },
469
+ signal: AbortSignal.timeout(5000),
470
+ });
471
+ if (resp.status === 401) {
472
+ return { error: 'token_expired' };
473
+ }
474
+ if (resp.status === 403) {
475
+ const body = await resp.text().catch(() => '');
476
+ if (body.includes('people.read')) {
477
+ autonomyCache.set(principal, 'GUEST');
478
+ return 'GUEST';
479
+ }
480
+ const level = envFallbackAutonomy();
481
+ autonomyCache.set(principal, level);
482
+ return level;
483
+ }
484
+ if (resp.status === 404) {
485
+ const level = envFallbackAutonomy();
486
+ autonomyCache.set(principal, level);
487
+ return level;
488
+ }
489
+ if (!resp.ok) {
490
+ const level = envFallbackAutonomy();
491
+ return level; // don't cache non-2xx
492
+ }
493
+ const data = (await resp.json());
494
+ const level = parseAutonomyLevel(data['autonomy_level']);
495
+ autonomyCache.set(principal, level);
496
+ return level;
497
+ }
498
+ catch {
499
+ return envFallbackAutonomy(); // network error — don't cache
500
+ }
501
+ }
502
+ export async function ensureAutonomy(principal) {
503
+ return getRequestAutonomy(principal);
504
+ }
505
+ export function getCachedAutonomy(principal) {
506
+ return autonomyCache.get(principal) ?? null;
507
+ }
437
508
  /** Shared singleton client (initialized lazily on first use). */
438
509
  let _defaultClient = null;
439
510
  export function getClient() {
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Feature flag resolution for workflow types (MV-1539 W2 Step 6).
3
+ *
4
+ * Each workflow type maps to a feature flag env var. Flag OFF blocks
5
+ * creation (startWorkflow returns type_not_active) but does NOT block
6
+ * lifecycle operations on existing instances (flag gates creation, not
7
+ * lifecycle — persisted instances whose flag is now OFF are completable).
8
+ */
9
+ export declare function isWorkflowTypeActive(typeName: string): boolean;
10
+ export declare function getWorkflowTypeFlag(typeName: string): string | undefined;
11
+ export declare function isUserWorkflowTypesActive(): boolean;
package/dist/flags.js ADDED
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Feature flag resolution for workflow types (MV-1539 W2 Step 6).
3
+ *
4
+ * Each workflow type maps to a feature flag env var. Flag OFF blocks
5
+ * creation (startWorkflow returns type_not_active) but does NOT block
6
+ * lifecycle operations on existing instances (flag gates creation, not
7
+ * lifecycle — persisted instances whose flag is now OFF are completable).
8
+ */
9
+ const WORKFLOW_TYPE_FLAGS = {
10
+ cos_coordination: 'FEATURE_WORKFLOW_COS',
11
+ pyr_exec: 'FEATURE_WORKFLOW_PYR_EXEC',
12
+ coo_operations: 'FEATURE_WORKFLOW_COO',
13
+ cmo_marketing_pipeline: 'FEATURE_WORKFLOW_CMO',
14
+ sales_full_pipeline: 'FEATURE_WORKFLOW_SALES',
15
+ research_exec: 'FEATURE_WORKFLOW_RESEARCH',
16
+ wiki_authoring: 'FEATURE_WORKFLOW_WIKI',
17
+ kb_management: 'FEATURE_WORKFLOW_KB',
18
+ lake_operations: 'FEATURE_WORKFLOW_LAKE',
19
+ };
20
+ export function isWorkflowTypeActive(typeName) {
21
+ const envVar = WORKFLOW_TYPE_FLAGS[typeName];
22
+ if (!envVar)
23
+ return true; // GM and unknown types are always active
24
+ const val = process.env[envVar];
25
+ return val === 'true' || val === '1';
26
+ }
27
+ export function getWorkflowTypeFlag(typeName) {
28
+ return WORKFLOW_TYPE_FLAGS[typeName];
29
+ }
30
+ export function isUserWorkflowTypesActive() {
31
+ const val = process.env['FEATURE_WORKFLOW_USER_TYPES'];
32
+ return val === 'true' || val === '1';
33
+ }
package/dist/index.js CHANGED
@@ -60,15 +60,77 @@ import { registerSkillTools } from './tools/skills.js';
60
60
  import { registerWikiTools } from './tools/wiki.js';
61
61
  import { registerVoiceTools } from './tools/voice.js';
62
62
  import { registerOnboardingTools } from './tools/onboarding.js';
63
+ import { registerWorkflowTools } from './tools/workflow.js';
64
+ import { registerWorkflowTypeTools } from './tools/workflow-types.js';
65
+ import { registerWorkflowPrereqsTool } from './tools/workflow-prereqs.js';
66
+ import { registerCmoTools } from './tools/cmo.js';
63
67
  import { registerPrompts } from './prompts.js';
64
- import { getRequestPrincipal } from './client.js';
68
+ import { getRequestPrincipal, ensureAutonomy } from './client.js';
65
69
  // Setup wizard (MV-1057h / W5)
66
70
  import { setup, profileToEnvVar } from './setup.js';
67
71
  import { WorkflowGate } from './workflow-gate.js';
68
- // FEAT-249: one WorkflowGate per server process — GM placement workflow state keyed
72
+ import { WorkflowPersistence } from './workflow-persistence.js';
73
+ import { createDefaultRegistry } from './workflow-registry.js';
74
+ // FEAT-249 / MV-1539: one WorkflowGate per server process — workflow state keyed
69
75
  // by request principal (stdio shares the single '__stdio__' slot). Never store gate
70
76
  // state inside the per-request AsyncLocalStorage context; see workflow-gate.ts.
71
- const gate = new WorkflowGate();
77
+ const gate = new WorkflowGate({
78
+ registry: createDefaultRegistry(),
79
+ persistence: new WorkflowPersistence(async () => getModuleClient()),
80
+ onEvent: async (event) => {
81
+ try {
82
+ const client = await getModuleClient();
83
+ await client.request('POST', '/api/v1/events', {
84
+ event_type: event.eventType,
85
+ raw_payload: JSON.stringify(event),
86
+ title: `${event.eventType} [${event.typeName}] ${event.instanceId.slice(0, 8)}`,
87
+ metadata: event.metadata,
88
+ });
89
+ }
90
+ catch (err) {
91
+ process.stderr.write(`[workflow-chronicle] event emit failed: ${err instanceof Error ? err.message : String(err)}\n`);
92
+ }
93
+ },
94
+ });
95
+ // MV-1539 W1 Step 3: preCall hook — wraps every tool handler to record calls centrally.
96
+ const PRECALL_EXEMPT = new Set(['tacit_cmo_lint']);
97
+ function installPreCallHook(server) {
98
+ const originalTool = server.tool.bind(server);
99
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
100
+ server.tool = function (...registerArgs) {
101
+ const toolName = registerArgs[0];
102
+ if (PRECALL_EXEMPT.has(toolName)) {
103
+ return originalTool(...registerArgs);
104
+ }
105
+ const handlerIdx = registerArgs.length - 1;
106
+ const originalHandler = registerArgs[handlerIdx];
107
+ registerArgs[handlerIdx] = async (...callArgs) => {
108
+ const principal = getRequestPrincipal();
109
+ const principalKey = principal ?? '__stdio__';
110
+ const autonomyResult = await ensureAutonomy(principalKey);
111
+ if (typeof autonomyResult === 'object' && 'error' in autonomyResult) {
112
+ return { content: [{ type: 'text', text: JSON.stringify(autonomyResult) }], isError: true };
113
+ }
114
+ const autonomyBlock = gate.checkToolAutonomy(principal, toolName);
115
+ if (autonomyBlock) {
116
+ return { content: [{ type: 'text', text: JSON.stringify(autonomyBlock) }], isError: true };
117
+ }
118
+ gate.recordCallForAll(principal, toolName);
119
+ const block = gate.checkToolBlock(principal, toolName);
120
+ if (block) {
121
+ return { content: [{ type: 'text', text: JSON.stringify(block) }], isError: true };
122
+ }
123
+ if (!gate.routeToolCall(principal, toolName)) {
124
+ const coldBlock = gate.checkColdToolBlock(toolName);
125
+ if (coldBlock) {
126
+ return { content: [{ type: 'text', text: JSON.stringify(coldBlock) }], isError: true };
127
+ }
128
+ }
129
+ return originalHandler(...callArgs);
130
+ };
131
+ return originalTool(...registerArgs);
132
+ };
133
+ }
72
134
  // ─── ESM __dirname replacement ───────────────────────────────────────────────
73
135
  const __filename = fileURLToPath(import.meta.url);
74
136
  const __dirname = path.dirname(__filename);
@@ -145,7 +207,10 @@ async function run() {
145
207
  }
146
208
  checkProfileExpiry(profile);
147
209
  checkCompatibility();
148
- const server = new McpServer({ name: '@tacitai/mcp-server', version: '0.3.0' }, { capabilities: { tools: {}, prompts: {} } });
210
+ const server = new McpServer({ name: '@tacitai/mcp-server', version: '0.3.0' }, {
211
+ capabilities: { tools: {}, prompts: {} },
212
+ instructions: 'This MCP server manages a workspace executive team with workflow-enforced operations. Use tacit_agent_list to see the team. Use tacit_workflow_prereqs to discover prerequisite chains before calling gated tools. Workflows enforce ordered phases — complete prerequisites before attempting write operations.',
213
+ });
149
214
  const isHttpMode = process.env['MCP_TRANSPORT'] === 'http';
150
215
  let clientInstance = null;
151
216
  const getClient = async () => {
@@ -159,6 +224,8 @@ async function run() {
159
224
  }
160
225
  return clientInstance;
161
226
  };
227
+ // MV-1539: install preCall hook before tool registration
228
+ installPreCallHook(server);
162
229
  // Register all tool modules
163
230
  registerSearchTools(server, getClient);
164
231
  registerSynthesizeTools(server, getClient);
@@ -190,6 +257,10 @@ async function run() {
190
257
  registerWikiTools(server, getClient);
191
258
  registerVoiceTools(server, getClient);
192
259
  registerOnboardingTools(server, getClient);
260
+ registerWorkflowTools(server, gate);
261
+ registerWorkflowTypeTools(server, getClient, gate.getRegistry());
262
+ registerWorkflowPrereqsTool(server, gate.getRegistry());
263
+ registerCmoTools(server);
193
264
  registerPrompts(server, getClient);
194
265
  if (process.env['MCP_TRANSPORT'] === 'http') {
195
266
  await startHttpTransport(server);
package/dist/prompts.d.ts CHANGED
@@ -58,6 +58,61 @@ export declare const GM_WORKFLOW: {
58
58
  readonly signal: "User sees a clear, plain-language confirmation.";
59
59
  }];
60
60
  };
61
+ export declare const COS_SUB_WORKFLOWS: readonly [{
62
+ readonly id: "delegate_gm";
63
+ readonly target: "gm_content_placement";
64
+ readonly trigger: "Content ingestion, placement, or filing requests";
65
+ }, {
66
+ readonly id: "delegate_coo";
67
+ readonly target: "coo_operations";
68
+ readonly trigger: "Operational tasks, team coordination, process execution";
69
+ }, {
70
+ readonly id: "delegate_research";
71
+ readonly target: "research_exec";
72
+ readonly trigger: "Research requests, SOTA surveys, evidence gathering";
73
+ }, {
74
+ readonly id: "delegate_cmo";
75
+ readonly target: "cmo_marketing_pipeline";
76
+ readonly trigger: "Marketing content production, brand compliance";
77
+ }];
78
+ export declare const COO_SUB_WORKFLOWS: readonly [{
79
+ readonly id: "delegate_sales";
80
+ readonly target: "sales_full_pipeline";
81
+ readonly trigger: "Sales pipeline, proposals, discovery, quotes";
82
+ }, {
83
+ readonly id: "delegate_gm";
84
+ readonly target: "gm_content_placement";
85
+ readonly trigger: "Content placement via GM workflow";
86
+ }, {
87
+ readonly id: "delegate_pyr";
88
+ readonly target: "pyr_exec";
89
+ readonly trigger: "Pyramid structure operations (portfolio, program, dossier management)";
90
+ }, {
91
+ readonly id: "delegate_research";
92
+ readonly target: "research_exec";
93
+ readonly trigger: "Research dispatch for operational decisions";
94
+ }, {
95
+ readonly id: "delegate_cmo";
96
+ readonly target: "cmo_marketing_pipeline";
97
+ readonly trigger: "Marketing content requests from operations";
98
+ }];
99
+ export declare const PYR_EXEC_SUB_WORKFLOWS: readonly [{
100
+ readonly id: "list_portfolios";
101
+ readonly tool: "tacit_pyramid_list_portfolios";
102
+ readonly trigger: "Show all portfolios";
103
+ }, {
104
+ readonly id: "list_value_streams";
105
+ readonly tool: "tacit_pyramid_list_value_streams";
106
+ readonly trigger: "Show value streams";
107
+ }, {
108
+ readonly id: "list_programs";
109
+ readonly tool: "tacit_pyramid_list_programs";
110
+ readonly trigger: "Show programs under a portfolio";
111
+ }, {
112
+ readonly id: "list_dossiers";
113
+ readonly tool: "tacit_pyramid_list_dossiers";
114
+ readonly trigger: "Show dossiers under a program";
115
+ }];
61
116
  export declare const EXPERIENCES: readonly [{
62
117
  readonly id: "explore_workspace";
63
118
  readonly num: 1;
@@ -100,9 +155,9 @@ export declare const EXPERIENCES: readonly [{
100
155
  readonly name: "Build Your Map";
101
156
  readonly tier: 1;
102
157
  readonly tierName: "Orient & Equip";
103
- readonly action: "Show the user their current Pyramid structure by calling tacit_pyramid_list_portfolios, then tacit_pyramid_list_programs for each portfolio. Present a clear map of what exists. Then invite the user to make ONE change to prove they can reshape it — suggest something concrete like: \"Want to create a new program, rename something, or move content around? Pick one and I will walk you through it.\" WAIT for the user to try something. Do NOT mark this experience complete until the user has either (a) made a structural change (create, rename, move) or (b) explicitly said they are satisfied with the current structure and want to move on. Showing the map alone is not completion — the user must interact with the structure.";
104
- readonly signal: "User has explored their workspace map AND either made a change or confirmed they are satisfied with the current structure";
105
- readonly tip: "You can always reorganize later. Say \"Move this to [collection]\" or \"Create a new program for [topic]\" anytime. Your General Manager proposes, you approve.";
158
+ readonly action: "Show the user their current Pyramid structure by calling tacit_pyramid_list_portfolios, tacit_pyramid_list_value_streams, and tacit_pyramid_list_programs. Present a clear map. Then walk the user through building a SAMPLE pyramid chain to teach each tier. Explain: (1) PORTFOLIO = investment segment — \"where we play\" — passes the board-slide test (would a board split investment across these?). (2) VALUE STREAM = what customers or employees receive end-to-end — passes the customer-receipt test. Internal VS use experience qualities not function names (e.g. \"Operational Excellence\" not \"Operations\"). (3) PROGRAM = a bounded push with an end state — passes the end-date test. If it can never end, it belongs as a stream not a program. (4) DOSSIER = a folder for artifacts (the actual work products). Suggest building this sample chain together: Portfolio: \"Employee Experience\" (INTERNAL pillar — what employees receive). Value Stream: \"Operational Excellence\" (the experience quality of running things well). Program: \"AI Transformation\" or \"TACIT Implementation\" (bounded: getting the company onto TACIT). Dossier: \"Onboarding Artifacts\" (a place to collect onboarding materials for all employees). Walk through creating each one step by step using tacit_pyramid_create_portfolio, tacit_pyramid_create_value_stream, tacit_pyramid_assign_program_to_value_stream, tacit_pyramid_create_program, tacit_pyramid_create_dossier. IMPORTANT: Tell the user these are SAMPLE entities to learn the system — they can delete or keep them after onboarding. They will not pollute the workspace. After creating the chain, show the updated map. WAIT for the user to confirm they understand the four tiers before marking complete.";
159
+ readonly signal: "User has built a sample pyramid chain (portfolio → value stream → program → dossier) and understands what each tier represents";
160
+ readonly tip: "Portfolios = investment segments (board-level). Value Streams = what people receive. Programs = bounded initiatives with end dates. Dossiers = artifact folders. You can always reorganize later.";
106
161
  }, {
107
162
  readonly id: "connect_your_tools";
108
163
  readonly num: 6;
@@ -127,7 +182,7 @@ export declare const EXPERIENCES: readonly [{
127
182
  readonly name: "Run Sales";
128
183
  readonly tier: 2;
129
184
  readonly tierName: "The Operating System";
130
- readonly action: "Part 1 — Discovery Brief: Say \"Prepare a discovery brief for a potential client.\" TACIT uses workspace knowledge to build a discovery framework. The brief should be a STYLED HTML REPORT using /artifact-design — same flow as Experience 7: invoke artifact-design, build the HTML, publish as a Claude artifact, save the file to disk, then ingest the HTML file via tacit_gm_ingest for placement. Part 2 — Voice Composition: After the brief, draft an intro email using the TACIT Voice Resonance system. MANDATORY: (1) Call tacit_voice_list_profiles to find the user's voice profile. A profile MUST exist — voice samples were pre-loaded during workspace setup. (2) Call tacit_compose_in_voice with the email request and the user's profile. This uses TACIT's actual voice fingerprinting system, NOT LLM approximation. NEVER draft the email yourself and claim it matches the user's voice — that is fake voice matching. NEVER offer to \"paste a sample email\" or \"upload writing samples\" — voice profiles are already loaded. If tacit_voice_list_profiles returns no profiles, say \"I expected to find your voice profile but it is not set up yet — let me check with the team\" and move on. Do NOT fall back to LLM-generated voice mimicry.";
185
+ readonly action: "Part 1 — Discovery Brief: Say \"Prepare a discovery brief for a potential client.\" TACIT uses workspace knowledge to build a discovery framework. The brief should be a STYLED HTML REPORT using /artifact-design — same flow as Experience 7: invoke artifact-design, build the HTML, publish as a Claude artifact, save the file to disk, then ingest the HTML file via tacit_gm_ingest for placement. Part 2 — Voice Composition: After the brief, draft an intro email using the TACIT Voice Resonance system. MANDATORY TWO-STEP FLOW: (1) GROUND FIRST — assemble the key facts from the discovery brief (prospect name, pain points, value proposition, relevant capabilities) into a structured plain-text brief. This is the content the voice system will work with. (2) COMPOSE IN VOICE — call tacit_voice_list_profiles to find the user's voice profile (it MUST exist — voice samples were pre-loaded). Then call tacit_compose_in_voice, passing the grounded-facts brief as the content to voice-ify. This ensures the voice system has concrete facts instead of re-retrieving from workspace docs. This uses TACIT's actual voice fingerprinting system, NOT LLM approximation. NEVER draft the email yourself and claim it matches the user's voice. NEVER offer to \"paste a sample email\" or \"upload writing samples\" — voice profiles are already loaded. If tacit_voice_list_profiles returns no profiles, say \"I expected to find your voice profile but it is not set up yet — let me check with the team\" and move on.";
131
186
  readonly signal: "First sales deliverable as HTML report, then first voice-matched composition using TACIT Voice Resonance (not LLM approximation)";
132
187
  readonly tip: "Voice Resonance is a real system — it analyzes your writing samples to capture your cadence, vocabulary, and patterns. Every \"in my voice\" request routes through this system.";
133
188
  }, {
@@ -136,18 +191,18 @@ export declare const EXPERIENCES: readonly [{
136
191
  readonly name: "Morning Brief";
137
192
  readonly tier: 2;
138
193
  readonly tierName: "The Operating System";
139
- readonly action: "IMPORTANT — CONNECTOR DETECTION: Before running the brief, CHECK your available MCP tool list to determine what is connected. Gmail IS connected if you have mcp__claude_ai_Gmail__* tools available. Slack IS connected if you have mcp__plugin_*_slack__* tools. Calendar IS connected if you have mcp__claude_ai_Google_Calendar__* tools. Do NOT say \"Gmail not connected\" if you can see Gmail MCP tools — that is a false negative. Run the COS daily brief: gather workspace state (programs, deadlines, proposals, KB freshness), and for each connected tool, pull real data — Gmail threads, Slack channels, Calendar events. Present the full operating picture. If a connector genuinely has no MCP tools available, say \"not yet connected\" and explain how to connect via claude.ai Integrations. After the brief, offer to draft a team message using tacit_compose_in_voice (same voice system as Experience 8 — NEVER LLM approximation).";
194
+ readonly action: "IMPORTANT — CONNECTOR DETECTION: Before running the brief, CHECK your available MCP tool list to determine what is connected. Gmail IS connected if you have mcp__claude_ai_Gmail__* tools available. Slack IS connected if you have mcp__plugin_*_slack__* tools. Calendar IS connected if you have mcp__claude_ai_Google_Calendar__* tools. Do NOT say \"Gmail not connected\" if you can see Gmail MCP tools — that is a false negative. Run the COS daily brief: gather workspace state (programs, deadlines, proposals, KB freshness), and for each connected tool, pull real data — Gmail threads, Slack channels, Calendar events. Present the full operating picture. If a connector genuinely has no MCP tools available, say \"not yet connected\" and explain how to connect via claude.ai Integrations. After the brief, offer to draft a team message in the user's voice. TWO-STEP VOICE FLOW (mandatory): (1) GROUND FIRST — assemble a structured brief of the key facts, numbers, and updates you gathered from the morning brief (programs, deadlines, email highlights, meeting items). Write this as plain text with concrete data points. (2) COMPOSE IN VOICE — call tacit_compose_in_voice, passing the grounded-facts brief as the content to voice-ify. This ensures the voice system has verified facts to work with instead of re-retrieving from workspace documents (which cannot see the live MCP query results you just gathered). NEVER skip step 1 and call tacit_compose_in_voice with just \"draft a team update\" — the voice system cannot access the live data you collected.";
140
195
  readonly signal: "First daily operating picture with accurate connector status and real data from connected tools";
141
196
  readonly tip: "Meet your executive team. COS (Chief of Staff — daily ops, email, meetings), COO (Chief Operating Officer — business ops, sales, audits), GM (General Manager — content ingestion, classification, pyramid placement). Address them by name to route through their workflow.";
142
197
  }, {
143
- readonly id: "audit_business";
198
+ readonly id: "business_pulse";
144
199
  readonly num: 10;
145
- readonly name: "Audit Your Business";
200
+ readonly name: "Your Business Pulse";
146
201
  readonly tier: 2;
147
202
  readonly tierName: "The Operating System";
148
- readonly action: "Run a business health audit. Ask the user \"How healthy is our business?\" or suggest a pulse audit across their workspace. Then: (1) Gather data — call tacit_pyramid_list_portfolios, tacit_pyramid_list_programs, tacit_pyramid_list_value_streams to assess structure completeness. Call tacit_kb_freshness to check knowledge currency. Call tacit_lake_browse_catalog to gauge content volume. Check connector status from the MCP tool list. (2) Score each dimension (structure, knowledge freshness, content depth, tool connectivity, voice readiness) and produce a STYLED HTML REPORT using /artifact-design — same flow as Experience 7: invoke artifact-design, build the HTML, publish as a Claude artifact, save the file to disk. The report should include dimension scores, a summary health grade, and concrete next steps. (3) After the artifact is saved, ingest the HTML file via tacit_gm_ingest for placement. The user approves where it goes.";
149
- readonly signal: "First scored business health audit published as a Claude artifact, then filed via GM workflow";
150
- readonly tip: "You can also say \"Have COO review our operational health\" — COO coordinates cross-team status and health checks.";
203
+ readonly action: "Show the user what TACIT can see about their business right now. Ask \"Want to see your business pulse?\" Then: (1) Gather workspace data — call tacit_pyramid_list_portfolios, tacit_pyramid_list_programs, tacit_pyramid_list_value_streams to assess structure completeness. Call tacit_kb_freshness to check knowledge currency. Call tacit_lake_browse_catalog to gauge content volume. Check connector status from the MCP tool list (Gmail, Slack, Calendar, Drive, GitHub). Call tacit_voice_list_profiles to check voice readiness. (2) Score each dimension (structure completeness, knowledge freshness, content depth, tool connectivity, voice readiness) and produce a STYLED HTML REPORT using /artifact-design — same flow as Experience 7: invoke artifact-design, build the HTML, publish as a Claude artifact, save the file to disk. The report should include dimension scores, a summary health grade, and concrete recommendations for what to build next. Frame it as a health snapshot, not a formal audit. (3) After the artifact is saved, ingest the HTML file via tacit_gm_ingest for placement. The user approves where it goes.";
204
+ readonly signal: "First business pulse report published as a Claude artifact showing workspace health scores, then filed via GM workflow";
205
+ readonly tip: "This is your quick health snapshot. When you want the deep version, say \"Have COO audit our business\" — COO runs the formal operational review with remediation tracking.";
151
206
  }, {
152
207
  readonly id: "operating_rhythm";
153
208
  readonly num: 11;
package/dist/prompts.js CHANGED
@@ -63,6 +63,12 @@ function buildAssistantSystemPrompt(state) {
63
63
  lines.push('');
64
64
  lines.push('During onboarding experiences, minimize what you ask from the user. Each experience should require at most one short sentence from the user — you do the heavy lifting. Never ask the user to provide details, pick topics, or name entities before you start working. Use what is already in the workspace, make reasonable defaults, and let the user correct you if needed. The goal is delight through effortless demonstration, not a task list.');
65
65
  lines.push('');
66
+ lines.push('## Workflow enforcement');
67
+ lines.push('');
68
+ lines.push('- Some tools are gated by phased workflows: required tools must be called, in order, before gated tools succeed. A rejection lists the prerequisite chain, what is completed, and the next step — follow it rather than retrying.');
69
+ lines.push('- Before calling a write or dispatch tool you have not used, call `tacit_workflow_prereqs` with its name to see the prerequisite chain.');
70
+ lines.push('- Call `tacit_agent_list` to see the executive team and address them by name.');
71
+ lines.push('');
66
72
  lines.push('## Safety');
67
73
  lines.push('');
68
74
  lines.push('- Never modify or delete content without explicit approval.');
@@ -190,17 +196,37 @@ export const GM_WORKFLOW = {
190
196
  },
191
197
  ],
192
198
  };
199
+ // ─── Sub-Workflow Guidance Constants (MV-1539 W2) ────────────────────────────
200
+ export const COS_SUB_WORKFLOWS = [
201
+ { id: 'delegate_gm', target: 'gm_content_placement', trigger: 'Content ingestion, placement, or filing requests' },
202
+ { id: 'delegate_coo', target: 'coo_operations', trigger: 'Operational tasks, team coordination, process execution' },
203
+ { id: 'delegate_research', target: 'research_exec', trigger: 'Research requests, SOTA surveys, evidence gathering' },
204
+ { id: 'delegate_cmo', target: 'cmo_marketing_pipeline', trigger: 'Marketing content production, brand compliance' },
205
+ ];
206
+ export const COO_SUB_WORKFLOWS = [
207
+ { id: 'delegate_sales', target: 'sales_full_pipeline', trigger: 'Sales pipeline, proposals, discovery, quotes' },
208
+ { id: 'delegate_gm', target: 'gm_content_placement', trigger: 'Content placement via GM workflow' },
209
+ { id: 'delegate_pyr', target: 'pyr_exec', trigger: 'Pyramid structure operations (portfolio, program, dossier management)' },
210
+ { id: 'delegate_research', target: 'research_exec', trigger: 'Research dispatch for operational decisions' },
211
+ { id: 'delegate_cmo', target: 'cmo_marketing_pipeline', trigger: 'Marketing content requests from operations' },
212
+ ];
213
+ export const PYR_EXEC_SUB_WORKFLOWS = [
214
+ { id: 'list_portfolios', tool: 'tacit_pyramid_list_portfolios', trigger: 'Show all portfolios' },
215
+ { id: 'list_value_streams', tool: 'tacit_pyramid_list_value_streams', trigger: 'Show value streams' },
216
+ { id: 'list_programs', tool: 'tacit_pyramid_list_programs', trigger: 'Show programs under a portfolio' },
217
+ { id: 'list_dossiers', tool: 'tacit_pyramid_list_dossiers', trigger: 'Show dossiers under a program' },
218
+ ];
193
219
  export const EXPERIENCES = [
194
220
  { id: 'explore_workspace', num: 1, name: 'Explore Your Workspace', tier: 1, tierName: 'Orient & Equip', action: 'Type: "What is in my workspace?" — see what knowledge, collections, and structure are already here.', signal: 'You can describe what is in your workspace', tip: '' },
195
221
  { id: 'see_capabilities', num: 2, name: 'See What\'s Possible', tier: 1, tierName: 'Orient & Equip', action: 'Type: "What can TACIT do for me?" — discover the full range of capabilities available to you.', signal: 'You know what TACIT can do and are ready to try it', tip: '' },
196
222
  { id: 'first_light', num: 3, name: 'First Light', tier: 1, tierName: 'Orient & Equip', action: 'Ask a question about your business — try "What do we know about [topic]?"', signal: 'First grounded answer drawn from your workspace knowledge', tip: '' },
197
223
  { id: 'feed_it', num: 4, name: 'Feed It', tier: 1, tierName: 'Orient & Equip', action: 'Turn your first answer into a workspace document. Say: "Take what you just told me and add it to the workspace." TACIT will use the synthesis from your last question as the document body and route it through your General Manager. The GM will classify it, then propose where it should live in your workspace. You approve before anything moves. If you already know where you want it, say so — otherwise say "you decide" and the GM will recommend a spot.', signal: 'First content ingested and placed via GM propose-then-approve', tip: 'Your General Manager handles content routing and placement. Everything goes through a propose-then-approve flow — the GM recommends where content belongs, and nothing moves without your say-so.' },
198
- { id: 'build_your_map', num: 5, name: 'Build Your Map', tier: 1, tierName: 'Orient & Equip', action: 'Show the user their current Pyramid structure by calling tacit_pyramid_list_portfolios, then tacit_pyramid_list_programs for each portfolio. Present a clear map of what exists. Then invite the user to make ONE change to prove they can reshape it — suggest something concrete like: "Want to create a new program, rename something, or move content around? Pick one and I will walk you through it." WAIT for the user to try something. Do NOT mark this experience complete until the user has either (a) made a structural change (create, rename, move) or (b) explicitly said they are satisfied with the current structure and want to move on. Showing the map alone is not completion — the user must interact with the structure.', signal: 'User has explored their workspace map AND either made a change or confirmed they are satisfied with the current structure', tip: 'You can always reorganize later. Say "Move this to [collection]" or "Create a new program for [topic]" anytime. Your General Manager proposes, you approve.' },
224
+ { id: 'build_your_map', num: 5, name: 'Build Your Map', tier: 1, tierName: 'Orient & Equip', action: 'Show the user their current Pyramid structure by calling tacit_pyramid_list_portfolios, tacit_pyramid_list_value_streams, and tacit_pyramid_list_programs. Present a clear map. Then walk the user through building a SAMPLE pyramid chain to teach each tier. Explain: (1) PORTFOLIO = investment segment — "where we play" — passes the board-slide test (would a board split investment across these?). (2) VALUE STREAM = what customers or employees receive end-to-end — passes the customer-receipt test. Internal VS use experience qualities not function names (e.g. "Operational Excellence" not "Operations"). (3) PROGRAM = a bounded push with an end state — passes the end-date test. If it can never end, it belongs as a stream not a program. (4) DOSSIER = a folder for artifacts (the actual work products). Suggest building this sample chain together: Portfolio: "Employee Experience" (INTERNAL pillar — what employees receive). Value Stream: "Operational Excellence" (the experience quality of running things well). Program: "AI Transformation" or "TACIT Implementation" (bounded: getting the company onto TACIT). Dossier: "Onboarding Artifacts" (a place to collect onboarding materials for all employees). Walk through creating each one step by step using tacit_pyramid_create_portfolio, tacit_pyramid_create_value_stream, tacit_pyramid_assign_program_to_value_stream, tacit_pyramid_create_program, tacit_pyramid_create_dossier. IMPORTANT: Tell the user these are SAMPLE entities to learn the system — they can delete or keep them after onboarding. They will not pollute the workspace. After creating the chain, show the updated map. WAIT for the user to confirm they understand the four tiers before marking complete.', signal: 'User has built a sample pyramid chain (portfolio → value stream → program → dossier) and understands what each tier represents', tip: 'Portfolios = investment segments (board-level). Value Streams = what people receive. Programs = bounded initiatives with end dates. Dossiers = artifact folders. You can always reorganize later.' },
199
225
  { id: 'connect_your_tools', num: 6, name: 'Connect Your Tools', tier: 1, tierName: 'Orient & Equip', action: 'First, CHECK what is already connected before telling the user anything: (1) Call tacit_github_list_connections to see GitHub repo connections. (2) Check your available MCP tool list — if you have Gmail tools (mcp__claude_ai_Gmail__*), Gmail IS connected. If you have Slack tools (mcp__plugin_*_slack__*), Slack IS connected. If you have Google Calendar tools, Calendar IS connected. If you have Google Drive tools, Drive IS connected. Present a CONNECTION STATUS showing what is already active and what is not. For anything already connected, say "Already connected — ready to use." For anything not connected, explain how to connect it via claude.ai Settings → Integrations. Also show GitHub workspace connections from step 1. Do NOT say a tool is disconnected if you can see its MCP tools in your available tool list. WAIT for the user to either connect something new or confirm they want to move on.', signal: 'User knows their connection status and has either connected new tools or confirmed they are ready to proceed', tip: 'GitHub connections sync your repos into the workspace. Gmail and Slack power the Morning Brief. Google Drive lets you pull in documents directly.' },
200
226
  { id: 'research_publish', num: 7, name: 'Research & Publish', tier: 2, tierName: 'The Operating System', action: 'Research a topic and publish a report. Ask the user what they want to research, or suggest a topic relevant to their business. Then: (1) Search workspace knowledge via tacit_search or tacit_synthesize. (2) Search the web for current information. (3) Combine findings into a STYLED HTML REPORT using /artifact-design — invoke the artifact-design skill to get the design system, then build a proper HTML artifact with title, date, executive summary, sections with findings, citations, and a professional layout. Publish it as a Claude artifact so the user sees it in their browser. Save the HTML file to disk. (4) After the artifact is saved, ingest the HTML FILE into TACIT via tacit_gm_ingest — pass the file path, not the content. The GM classifies and proposes placement. The user approves before anything moves. IMPORTANT: Do NOT copy-paste the report content into tacit_artifact_create. The correct flow is: create the HTML file → publish as Claude artifact → ingest the file via GM. This preserves provenance and goes through the lake-first pipeline.', signal: 'First research artifact published as a Claude artifact in the browser, then the HTML file ingested and placed via GM workflow', tip: 'After publishing, your General Manager will propose where to place the report in your knowledge structure — you approve the placement.' },
201
- { id: 'run_sales', num: 8, name: 'Run Sales', tier: 2, tierName: 'The Operating System', action: 'Part 1 — Discovery Brief: Say "Prepare a discovery brief for a potential client." TACIT uses workspace knowledge to build a discovery framework. The brief should be a STYLED HTML REPORT using /artifact-design — same flow as Experience 7: invoke artifact-design, build the HTML, publish as a Claude artifact, save the file to disk, then ingest the HTML file via tacit_gm_ingest for placement. Part 2 — Voice Composition: After the brief, draft an intro email using the TACIT Voice Resonance system. MANDATORY: (1) Call tacit_voice_list_profiles to find the user\'s voice profile. A profile MUST exist — voice samples were pre-loaded during workspace setup. (2) Call tacit_compose_in_voice with the email request and the user\'s profile. This uses TACIT\'s actual voice fingerprinting system, NOT LLM approximation. NEVER draft the email yourself and claim it matches the user\'s voice — that is fake voice matching. NEVER offer to "paste a sample email" or "upload writing samples" — voice profiles are already loaded. If tacit_voice_list_profiles returns no profiles, say "I expected to find your voice profile but it is not set up yet — let me check with the team" and move on. Do NOT fall back to LLM-generated voice mimicry.', signal: 'First sales deliverable as HTML report, then first voice-matched composition using TACIT Voice Resonance (not LLM approximation)', tip: 'Voice Resonance is a real system — it analyzes your writing samples to capture your cadence, vocabulary, and patterns. Every "in my voice" request routes through this system.' },
202
- { id: 'morning_brief', num: 9, name: 'Morning Brief', tier: 2, tierName: 'The Operating System', action: 'IMPORTANT — CONNECTOR DETECTION: Before running the brief, CHECK your available MCP tool list to determine what is connected. Gmail IS connected if you have mcp__claude_ai_Gmail__* tools available. Slack IS connected if you have mcp__plugin_*_slack__* tools. Calendar IS connected if you have mcp__claude_ai_Google_Calendar__* tools. Do NOT say "Gmail not connected" if you can see Gmail MCP tools — that is a false negative. Run the COS daily brief: gather workspace state (programs, deadlines, proposals, KB freshness), and for each connected tool, pull real data — Gmail threads, Slack channels, Calendar events. Present the full operating picture. If a connector genuinely has no MCP tools available, say "not yet connected" and explain how to connect via claude.ai Integrations. After the brief, offer to draft a team message using tacit_compose_in_voice (same voice system as Experience 8 — NEVER LLM approximation).', signal: 'First daily operating picture with accurate connector status and real data from connected tools', tip: 'Meet your executive team. COS (Chief of Staff — daily ops, email, meetings), COO (Chief Operating Officer — business ops, sales, audits), GM (General Manager — content ingestion, classification, pyramid placement). Address them by name to route through their workflow.' },
203
- { id: 'audit_business', num: 10, name: 'Audit Your Business', tier: 2, tierName: 'The Operating System', action: 'Run a business health audit. Ask the user "How healthy is our business?" or suggest a pulse audit across their workspace. Then: (1) Gather data — call tacit_pyramid_list_portfolios, tacit_pyramid_list_programs, tacit_pyramid_list_value_streams to assess structure completeness. Call tacit_kb_freshness to check knowledge currency. Call tacit_lake_browse_catalog to gauge content volume. Check connector status from the MCP tool list. (2) Score each dimension (structure, knowledge freshness, content depth, tool connectivity, voice readiness) and produce a STYLED HTML REPORT using /artifact-design — same flow as Experience 7: invoke artifact-design, build the HTML, publish as a Claude artifact, save the file to disk. The report should include dimension scores, a summary health grade, and concrete next steps. (3) After the artifact is saved, ingest the HTML file via tacit_gm_ingest for placement. The user approves where it goes.', signal: 'First scored business health audit published as a Claude artifact, then filed via GM workflow', tip: 'You can also say "Have COO review our operational health" — COO coordinates cross-team status and health checks.' },
227
+ { id: 'run_sales', num: 8, name: 'Run Sales', tier: 2, tierName: 'The Operating System', action: 'Part 1 — Discovery Brief: Say "Prepare a discovery brief for a potential client." TACIT uses workspace knowledge to build a discovery framework. The brief should be a STYLED HTML REPORT using /artifact-design — same flow as Experience 7: invoke artifact-design, build the HTML, publish as a Claude artifact, save the file to disk, then ingest the HTML file via tacit_gm_ingest for placement. Part 2 — Voice Composition: After the brief, draft an intro email using the TACIT Voice Resonance system. MANDATORY TWO-STEP FLOW: (1) GROUND FIRST — assemble the key facts from the discovery brief (prospect name, pain points, value proposition, relevant capabilities) into a structured plain-text brief. This is the content the voice system will work with. (2) COMPOSE IN VOICE — call tacit_voice_list_profiles to find the user\'s voice profile (it MUST exist — voice samples were pre-loaded). Then call tacit_compose_in_voice, passing the grounded-facts brief as the content to voice-ify. This ensures the voice system has concrete facts instead of re-retrieving from workspace docs. This uses TACIT\'s actual voice fingerprinting system, NOT LLM approximation. NEVER draft the email yourself and claim it matches the user\'s voice. NEVER offer to "paste a sample email" or "upload writing samples" — voice profiles are already loaded. If tacit_voice_list_profiles returns no profiles, say "I expected to find your voice profile but it is not set up yet — let me check with the team" and move on.', signal: 'First sales deliverable as HTML report, then first voice-matched composition using TACIT Voice Resonance (not LLM approximation)', tip: 'Voice Resonance is a real system — it analyzes your writing samples to capture your cadence, vocabulary, and patterns. Every "in my voice" request routes through this system.' },
228
+ { id: 'morning_brief', num: 9, name: 'Morning Brief', tier: 2, tierName: 'The Operating System', action: 'IMPORTANT — CONNECTOR DETECTION: Before running the brief, CHECK your available MCP tool list to determine what is connected. Gmail IS connected if you have mcp__claude_ai_Gmail__* tools available. Slack IS connected if you have mcp__plugin_*_slack__* tools. Calendar IS connected if you have mcp__claude_ai_Google_Calendar__* tools. Do NOT say "Gmail not connected" if you can see Gmail MCP tools — that is a false negative. Run the COS daily brief: gather workspace state (programs, deadlines, proposals, KB freshness), and for each connected tool, pull real data — Gmail threads, Slack channels, Calendar events. Present the full operating picture. If a connector genuinely has no MCP tools available, say "not yet connected" and explain how to connect via claude.ai Integrations. After the brief, offer to draft a team message in the user\'s voice. TWO-STEP VOICE FLOW (mandatory): (1) GROUND FIRST — assemble a structured brief of the key facts, numbers, and updates you gathered from the morning brief (programs, deadlines, email highlights, meeting items). Write this as plain text with concrete data points. (2) COMPOSE IN VOICE — call tacit_compose_in_voice, passing the grounded-facts brief as the content to voice-ify. This ensures the voice system has verified facts to work with instead of re-retrieving from workspace documents (which cannot see the live MCP query results you just gathered). NEVER skip step 1 and call tacit_compose_in_voice with just "draft a team update" — the voice system cannot access the live data you collected.', signal: 'First daily operating picture with accurate connector status and real data from connected tools', tip: 'Meet your executive team. COS (Chief of Staff — daily ops, email, meetings), COO (Chief Operating Officer — business ops, sales, audits), GM (General Manager — content ingestion, classification, pyramid placement). Address them by name to route through their workflow.' },
229
+ { id: 'business_pulse', num: 10, name: 'Your Business Pulse', tier: 2, tierName: 'The Operating System', action: 'Show the user what TACIT can see about their business right now. Ask "Want to see your business pulse?" Then: (1) Gather workspace data — call tacit_pyramid_list_portfolios, tacit_pyramid_list_programs, tacit_pyramid_list_value_streams to assess structure completeness. Call tacit_kb_freshness to check knowledge currency. Call tacit_lake_browse_catalog to gauge content volume. Check connector status from the MCP tool list (Gmail, Slack, Calendar, Drive, GitHub). Call tacit_voice_list_profiles to check voice readiness. (2) Score each dimension (structure completeness, knowledge freshness, content depth, tool connectivity, voice readiness) and produce a STYLED HTML REPORT using /artifact-design — same flow as Experience 7: invoke artifact-design, build the HTML, publish as a Claude artifact, save the file to disk. The report should include dimension scores, a summary health grade, and concrete recommendations for what to build next. Frame it as a health snapshot, not a formal audit. (3) After the artifact is saved, ingest the HTML file via tacit_gm_ingest for placement. The user approves where it goes.', signal: 'First business pulse report published as a Claude artifact showing workspace health scores, then filed via GM workflow', tip: 'This is your quick health snapshot. When you want the deep version, say "Have COO audit our business" — COO runs the formal operational review with remediation tracking.' },
204
230
  { id: 'operating_rhythm', num: 11, name: 'Your Operating Rhythm', tier: 3, tierName: 'Agentic Mastery', action: 'Summarize what the user has accomplished across the onboarding and suggest their operating rhythm. CONNECTOR STATUS: Check your available MCP tool list — if you have Gmail/Slack/Calendar/Drive MCP tools, those ARE connected. Do NOT say they are disconnected. VOICE: Call tacit_voice_list_profiles — if profiles exist, voice is ready. Do NOT ask the user to upload samples if profiles already exist. Focus on: (1) Daily rhythm — morning brief via COS, email triage, meeting prep. (2) Weekly rhythm — COO business review, GM content organization. (3) Delegation — crew dispatch for complex deliverables. (4) What to explore next based on what they have connected and used.', signal: 'User has a clear picture of their operating rhythm and next steps', tip: 'By now you know the team: COS for daily ops, COO for business operations, GM for content. Address them directly anytime.' },
205
231
  ];
206
232
  export function registerPrompts(server, getClientFn) {
@@ -0,0 +1,9 @@
1
+ export interface RoleTemplate {
2
+ slug: string;
3
+ display_name: string;
4
+ description: string;
5
+ icon: string;
6
+ default_capabilities: string[];
7
+ workflow_types: string[];
8
+ }
9
+ export declare function loadRoleTemplates(): RoleTemplate[];
@@ -0,0 +1,93 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ const __filename = fileURLToPath(import.meta.url);
5
+ const __dirname = join(__filename, '..');
6
+ let cachedTemplates = null;
7
+ export function loadRoleTemplates() {
8
+ if (cachedTemplates)
9
+ return cachedTemplates;
10
+ const candidates = [
11
+ join(__dirname, '..', '..', '..', '..', 'config', 'exec-roles.yaml'),
12
+ join(__dirname, '..', '..', 'config', 'exec-roles.yaml'),
13
+ ];
14
+ for (const p of candidates) {
15
+ try {
16
+ const raw = readFileSync(p, 'utf-8');
17
+ const parsed = parseYaml(raw);
18
+ if (parsed?.roles && Array.isArray(parsed.roles)) {
19
+ cachedTemplates = parsed.roles;
20
+ return cachedTemplates;
21
+ }
22
+ }
23
+ catch {
24
+ // try next candidate
25
+ }
26
+ }
27
+ cachedTemplates = FALLBACK_TEMPLATES;
28
+ return cachedTemplates;
29
+ }
30
+ function parseYaml(raw) {
31
+ // Minimal YAML parser for the flat roles structure; avoids a YAML dependency.
32
+ const roles = [];
33
+ let current = null;
34
+ let arrayField = null;
35
+ for (const line of raw.split('\n')) {
36
+ const trimmed = line.trimEnd();
37
+ if (trimmed.trimStart().startsWith('#') || trimmed === '')
38
+ continue;
39
+ const indent = line.length - line.trimStart().length;
40
+ if (indent === 2 && trimmed.trimStart().startsWith('- slug:')) {
41
+ if (current?.slug)
42
+ roles.push(current);
43
+ current = {
44
+ slug: trimmed.split(':').slice(1).join(':').trim(),
45
+ default_capabilities: [],
46
+ workflow_types: [],
47
+ };
48
+ arrayField = null;
49
+ continue;
50
+ }
51
+ if (!current)
52
+ continue;
53
+ if (indent === 4 && trimmed.includes(':') && !trimmed.trimStart().startsWith('-')) {
54
+ arrayField = null;
55
+ const [key, ...rest] = trimmed.split(':');
56
+ const val = rest.join(':').trim();
57
+ const k = key.trim();
58
+ if (k === 'display_name')
59
+ current.display_name = val;
60
+ else if (k === 'description')
61
+ current.description = val;
62
+ else if (k === 'icon')
63
+ current.icon = val;
64
+ else if (k === 'default_capabilities' || k === 'workflow_types') {
65
+ arrayField = k;
66
+ }
67
+ continue;
68
+ }
69
+ if (indent === 6 && trimmed.trimStart().startsWith('- ') && arrayField) {
70
+ const val = trimmed.trimStart().slice(2).trim();
71
+ if (arrayField === 'default_capabilities') {
72
+ (current.default_capabilities ??= []).push(val);
73
+ }
74
+ else if (arrayField === 'workflow_types') {
75
+ (current.workflow_types ??= []).push(val);
76
+ }
77
+ }
78
+ }
79
+ if (current?.slug)
80
+ roles.push(current);
81
+ return roles.length > 0 ? { roles } : null;
82
+ }
83
+ const FALLBACK_TEMPLATES = [
84
+ { slug: 'general_manager', display_name: 'General Manager', description: 'Oversees content placement and coordination.', icon: 'briefcase', default_capabilities: ['content_placement', 'artifact_management'], workflow_types: ['gm_content_placement'] },
85
+ { slug: 'chief_of_staff', display_name: 'Chief of Staff', description: 'Coordinates cross-functional workflows.', icon: 'clipboard', default_capabilities: ['coordination', 'approval_management'], workflow_types: ['cos_coordination'] },
86
+ { slug: 'pyramid_executor', display_name: 'Pyramid Executor', description: 'Manages strategic pyramid operations.', icon: 'layers', default_capabilities: ['portfolio_management', 'program_management'], workflow_types: ['pyr_exec'] },
87
+ { slug: 'coo_operator', display_name: 'COO Operator', description: 'Handles operational workflows.', icon: 'settings', default_capabilities: ['operations_management'], workflow_types: ['coo_operations'] },
88
+ { slug: 'cmo_marketer', display_name: 'CMO Marketer', description: 'Manages marketing pipeline.', icon: 'megaphone', default_capabilities: ['marketing_pipeline'], workflow_types: ['cmo_marketing_pipeline'] },
89
+ { slug: 'sales_executor', display_name: 'Sales Executor', description: 'Manages sales pipeline.', icon: 'trending_up', default_capabilities: ['pipeline_management'], workflow_types: ['sales_full_pipeline'] },
90
+ { slug: 'wiki_editor', display_name: 'Wiki Editor', description: 'Authors and maintains wiki content with structured classification and validation workflows.', icon: 'book', default_capabilities: ['wiki_authoring', 'content_classification', 'content_validation'], workflow_types: ['wiki_authoring'] },
91
+ { slug: 'kb_curator', display_name: 'KB Curator', description: 'Curates knowledge base articles, collections, and source integrations.', icon: 'library', default_capabilities: ['kb_management', 'article_curation', 'source_administration'], workflow_types: ['kb_management'] },
92
+ { slug: 'lake_operator', display_name: 'Lake Operator', description: 'Manages data lake ingestion, classification, taxonomy, and structure proposals.', icon: 'database', default_capabilities: ['lake_ingestion', 'classification', 'taxonomy_management', 'structure_proposals'], workflow_types: ['lake_operations'] },
93
+ ];