@tacitai/mcp-server 0.6.28 → 0.6.30
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 +10 -0
- package/dist/client.js +71 -0
- package/dist/flags.d.ts +11 -0
- package/dist/flags.js +33 -0
- package/dist/index.js +75 -4
- package/dist/prompts.d.ts +55 -0
- package/dist/prompts.js +26 -0
- package/dist/templates/role-loader.d.ts +9 -0
- package/dist/templates/role-loader.js +93 -0
- package/dist/tools/agents.d.ts +45 -4
- package/dist/tools/agents.js +180 -12
- package/dist/tools/cmo.d.ts +14 -0
- package/dist/tools/cmo.js +125 -0
- package/dist/tools/errors.js +4 -2
- package/dist/tools/outbox.d.ts +2 -2
- package/dist/tools/registry.d.ts +1 -1
- package/dist/tools/registry.js +14 -3
- package/dist/tools/workflow-prereqs.d.ts +16 -0
- package/dist/tools/workflow-prereqs.js +29 -0
- package/dist/tools/workflow-types.d.ts +11 -0
- package/dist/tools/workflow-types.js +179 -0
- package/dist/tools/workflow.d.ts +9 -0
- package/dist/tools/workflow.js +134 -0
- package/dist/workflow-gate.d.ts +173 -78
- package/dist/workflow-gate.js +741 -156
- package/dist/workflow-persistence.d.ts +25 -0
- package/dist/workflow-persistence.js +127 -0
- package/dist/workflow-registry.d.ts +80 -0
- package/dist/workflow-registry.js +375 -0
- package/dist/workflow-type-schema.d.ts +11 -0
- package/dist/workflow-type-schema.js +92 -0
- package/package.json +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WorkflowPersistence — HTTP-backed persistence for workflow instances (MV-1539 W4 Step 15).
|
|
3
|
+
*
|
|
4
|
+
* Implements WorkflowPersistencePort via Rust endpoints at /api/v1/workflow-state.
|
|
5
|
+
* All operations are fire-and-forget from the gate's perspective — errors are caught
|
|
6
|
+
* and logged, never thrown. AR-4: two-tier debounce (recordCall 5s, phase advancement
|
|
7
|
+
* immediate). AR-7: piggyback TTL cleanup on restore. ST-3: Map serialization via
|
|
8
|
+
* replacer/reviver for callLog.
|
|
9
|
+
*/
|
|
10
|
+
import type { WorkflowPersistencePort, WorkflowInstance } from './workflow-gate.js';
|
|
11
|
+
import type { TacitClient } from './client.js';
|
|
12
|
+
export declare class WorkflowPersistence implements WorkflowPersistencePort {
|
|
13
|
+
private readonly getClient;
|
|
14
|
+
private readonly saveTimers;
|
|
15
|
+
private readonly debounceMs;
|
|
16
|
+
constructor(getClient: () => Promise<TacitClient>, opts?: {
|
|
17
|
+
debounceMs?: number;
|
|
18
|
+
});
|
|
19
|
+
save(principal: string, workspaceId: string, instance: WorkflowInstance): Promise<void>;
|
|
20
|
+
saveImmediate(principal: string, workspaceId: string, instance: WorkflowInstance): Promise<void>;
|
|
21
|
+
private doSave;
|
|
22
|
+
restore(principal: string, workspaceId: string): Promise<WorkflowInstance[]>;
|
|
23
|
+
remove(principal: string, instanceId: string): Promise<void>;
|
|
24
|
+
flush(): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WorkflowPersistence — HTTP-backed persistence for workflow instances (MV-1539 W4 Step 15).
|
|
3
|
+
*
|
|
4
|
+
* Implements WorkflowPersistencePort via Rust endpoints at /api/v1/workflow-state.
|
|
5
|
+
* All operations are fire-and-forget from the gate's perspective — errors are caught
|
|
6
|
+
* and logged, never thrown. AR-4: two-tier debounce (recordCall 5s, phase advancement
|
|
7
|
+
* immediate). AR-7: piggyback TTL cleanup on restore. ST-3: Map serialization via
|
|
8
|
+
* replacer/reviver for callLog.
|
|
9
|
+
*/
|
|
10
|
+
function serializeInstance(instance) {
|
|
11
|
+
return {
|
|
12
|
+
...instance,
|
|
13
|
+
callLog: Object.fromEntries(instance.callLog),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function deserializeInstance(raw) {
|
|
17
|
+
const inst = { ...raw };
|
|
18
|
+
if (raw['callLog'] && typeof raw['callLog'] === 'object' && !(raw['callLog'] instanceof Map)) {
|
|
19
|
+
inst.callLog = new Map(Object.entries(raw['callLog']));
|
|
20
|
+
}
|
|
21
|
+
if (!inst.callLog || !(inst.callLog instanceof Map)) {
|
|
22
|
+
inst.callLog = new Map();
|
|
23
|
+
}
|
|
24
|
+
if (typeof inst.lastActivityAt !== 'number') {
|
|
25
|
+
inst.lastActivityAt = inst.createdAt ?? Date.now();
|
|
26
|
+
}
|
|
27
|
+
return inst;
|
|
28
|
+
}
|
|
29
|
+
export class WorkflowPersistence {
|
|
30
|
+
getClient;
|
|
31
|
+
saveTimers = new Map();
|
|
32
|
+
debounceMs;
|
|
33
|
+
constructor(getClient, opts) {
|
|
34
|
+
this.getClient = getClient;
|
|
35
|
+
this.debounceMs = opts?.debounceMs ?? 5000;
|
|
36
|
+
}
|
|
37
|
+
async save(principal, workspaceId, instance) {
|
|
38
|
+
const key = instance.instanceId;
|
|
39
|
+
const existing = this.saveTimers.get(key);
|
|
40
|
+
if (existing)
|
|
41
|
+
clearTimeout(existing);
|
|
42
|
+
const isPhaseChange = !existing;
|
|
43
|
+
if (isPhaseChange) {
|
|
44
|
+
await this.doSave(principal, workspaceId, instance);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
await new Promise((resolve) => {
|
|
48
|
+
this.saveTimers.set(key, setTimeout(async () => {
|
|
49
|
+
this.saveTimers.delete(key);
|
|
50
|
+
await this.doSave(principal, workspaceId, instance).catch(() => { });
|
|
51
|
+
resolve();
|
|
52
|
+
}, this.debounceMs));
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async saveImmediate(principal, workspaceId, instance) {
|
|
57
|
+
const key = instance.instanceId;
|
|
58
|
+
const existing = this.saveTimers.get(key);
|
|
59
|
+
if (existing) {
|
|
60
|
+
clearTimeout(existing);
|
|
61
|
+
this.saveTimers.delete(key);
|
|
62
|
+
}
|
|
63
|
+
await this.doSave(principal, workspaceId, instance);
|
|
64
|
+
}
|
|
65
|
+
async doSave(principal, workspaceId, instance) {
|
|
66
|
+
try {
|
|
67
|
+
const client = await this.getClient();
|
|
68
|
+
const typeDef = instance.typeRef;
|
|
69
|
+
const ttlDays = 30;
|
|
70
|
+
const expiresAt = new Date(Date.now() + ttlDays * 86400000).toISOString();
|
|
71
|
+
await client.put(`/api/v1/workflow-state/${instance.instanceId}`, {
|
|
72
|
+
principal,
|
|
73
|
+
type_name: typeDef,
|
|
74
|
+
workspace_id: workspaceId,
|
|
75
|
+
state: serializeInstance(instance),
|
|
76
|
+
expires_at: expiresAt,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
process.stderr.write(`[workflow-persistence] save failed for ${instance.instanceId}: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
async restore(principal, workspaceId) {
|
|
84
|
+
try {
|
|
85
|
+
const client = await this.getClient();
|
|
86
|
+
const result = await client.get('/api/v1/workflow-state', {
|
|
87
|
+
principal,
|
|
88
|
+
workspace_id: workspaceId,
|
|
89
|
+
});
|
|
90
|
+
const now = Date.now();
|
|
91
|
+
const instances = [];
|
|
92
|
+
const expired = [];
|
|
93
|
+
for (const row of result.instances ?? []) {
|
|
94
|
+
if (row.expires_at && new Date(row.expires_at).getTime() < now) {
|
|
95
|
+
expired.push(row.instance_id);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
instances.push(deserializeInstance(row.state));
|
|
99
|
+
}
|
|
100
|
+
if (expired.length > 0) {
|
|
101
|
+
for (const id of expired) {
|
|
102
|
+
this.remove(principal, id).catch(() => { });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return instances;
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
process.stderr.write(`[workflow-persistence] restore failed for ${principal}: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async remove(principal, instanceId) {
|
|
113
|
+
try {
|
|
114
|
+
const client = await this.getClient();
|
|
115
|
+
await client.delete(`/api/v1/workflow-state/${instanceId}`);
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
process.stderr.write(`[workflow-persistence] remove failed for ${instanceId}: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
flush() {
|
|
122
|
+
for (const [key, timer] of this.saveTimers) {
|
|
123
|
+
clearTimeout(timer);
|
|
124
|
+
this.saveTimers.delete(key);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WorkflowRegistry — type storage, lookup, and inverted tool index (MV-1539 W1 Step 1).
|
|
3
|
+
*
|
|
4
|
+
* Maps type names to WorkflowTypeDef objects. Provides O(1) tool→type lookup via
|
|
5
|
+
* an inverted index rebuilt on each register() call. System types are pre-seeded
|
|
6
|
+
* via createDefaultRegistry(); user-authored types (W7) are loaded per-workspace.
|
|
7
|
+
*/
|
|
8
|
+
/** Drill-down tools required before `tacit_gm_approve` (pyramid surface). */
|
|
9
|
+
export declare const PYRAMID_PREREQ_TOOLS: readonly ["tacit_pyramid_list_portfolios", "tacit_pyramid_list_value_streams", "tacit_pyramid_list_programs", "tacit_pyramid_list_dossiers"];
|
|
10
|
+
/** Drill-down tool required before a GM-workflow KB promotion. */
|
|
11
|
+
export declare const KB_PREREQ_TOOL = "tacit_kb_list_collections";
|
|
12
|
+
export type PrereqModel = {
|
|
13
|
+
kind: 'flat';
|
|
14
|
+
tools: readonly string[];
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'phased';
|
|
17
|
+
phases: WorkflowPhase[];
|
|
18
|
+
};
|
|
19
|
+
export interface WorkflowPhase {
|
|
20
|
+
name: string;
|
|
21
|
+
requiredTools: readonly string[];
|
|
22
|
+
gatedTools: readonly string[];
|
|
23
|
+
approvalGate?: boolean;
|
|
24
|
+
guidance: string;
|
|
25
|
+
requiredMetadata?: Record<string, 'present' | 'present-and-distinct'>;
|
|
26
|
+
/** When set, requiredMetadata is enforced only if instance.metadata[metadataCondition] is truthy. */
|
|
27
|
+
metadataCondition?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface WorkflowTypeDef {
|
|
30
|
+
name: string;
|
|
31
|
+
entryTool: string | null;
|
|
32
|
+
prereqs: PrereqModel;
|
|
33
|
+
terminalAction?: {
|
|
34
|
+
tool: string;
|
|
35
|
+
budget: number | ((opts?: Record<string, unknown>) => number);
|
|
36
|
+
};
|
|
37
|
+
gatedChecks?: 'bespoke' | 'standard';
|
|
38
|
+
handoff?: {
|
|
39
|
+
targetTypes: string[];
|
|
40
|
+
preserveParent: boolean;
|
|
41
|
+
budgetPerPhase?: number;
|
|
42
|
+
};
|
|
43
|
+
persistent?: boolean;
|
|
44
|
+
ttlDays?: number;
|
|
45
|
+
failDirection: 'open' | 'closed';
|
|
46
|
+
sharedToolPolicy: 'passthrough';
|
|
47
|
+
resumeMode?: 'tool' | 'skill-preamble';
|
|
48
|
+
guidance?: string;
|
|
49
|
+
maxInstances?: number;
|
|
50
|
+
}
|
|
51
|
+
export declare const GM_TYPE_DEF: WorkflowTypeDef;
|
|
52
|
+
export declare class WorkflowRegistry {
|
|
53
|
+
private readonly types;
|
|
54
|
+
private readonly entryToolIndex;
|
|
55
|
+
private readonly toolToTypes;
|
|
56
|
+
private readonly workspaceTypes;
|
|
57
|
+
private readonly loadedWorkspaces;
|
|
58
|
+
register(def: WorkflowTypeDef): void;
|
|
59
|
+
get(typeName: string, workspaceId?: string): WorkflowTypeDef | undefined;
|
|
60
|
+
findByEntryTool(toolName: string): WorkflowTypeDef | undefined;
|
|
61
|
+
findByTool(toolName: string, workspaceId?: string): WorkflowTypeDef[];
|
|
62
|
+
list(workspaceId?: string): WorkflowTypeDef[];
|
|
63
|
+
has(typeName: string, workspaceId?: string): boolean;
|
|
64
|
+
registerUserType(def: WorkflowTypeDef, workspaceId: string): void;
|
|
65
|
+
removeUserType(typeName: string, workspaceId: string): boolean;
|
|
66
|
+
hasWorkspaceLoaded(workspaceId: string): boolean;
|
|
67
|
+
markWorkspaceLoaded(workspaceId: string): void;
|
|
68
|
+
private rebuildIndexes;
|
|
69
|
+
private collectTools;
|
|
70
|
+
}
|
|
71
|
+
export declare const COS_TYPE_DEF: WorkflowTypeDef;
|
|
72
|
+
export declare const PYR_EXEC_TYPE_DEF: WorkflowTypeDef;
|
|
73
|
+
export declare const COO_TYPE_DEF: WorkflowTypeDef;
|
|
74
|
+
export declare const CMO_TYPE_DEF: WorkflowTypeDef;
|
|
75
|
+
export declare const SALES_TYPE_DEF: WorkflowTypeDef;
|
|
76
|
+
export declare const RESEARCH_TYPE_DEF: WorkflowTypeDef;
|
|
77
|
+
export declare const WIKI_TYPE_DEF: WorkflowTypeDef;
|
|
78
|
+
export declare const KB_TYPE_DEF: WorkflowTypeDef;
|
|
79
|
+
export declare const LAKE_TYPE_DEF: WorkflowTypeDef;
|
|
80
|
+
export declare function createDefaultRegistry(): WorkflowRegistry;
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WorkflowRegistry — type storage, lookup, and inverted tool index (MV-1539 W1 Step 1).
|
|
3
|
+
*
|
|
4
|
+
* Maps type names to WorkflowTypeDef objects. Provides O(1) tool→type lookup via
|
|
5
|
+
* an inverted index rebuilt on each register() call. System types are pre-seeded
|
|
6
|
+
* via createDefaultRegistry(); user-authored types (W7) are loaded per-workspace.
|
|
7
|
+
*/
|
|
8
|
+
// ─── Shared constants (canonical source — re-exported by workflow-gate.ts) ──
|
|
9
|
+
/** Drill-down tools required before `tacit_gm_approve` (pyramid surface). */
|
|
10
|
+
export const PYRAMID_PREREQ_TOOLS = [
|
|
11
|
+
'tacit_pyramid_list_portfolios',
|
|
12
|
+
'tacit_pyramid_list_value_streams',
|
|
13
|
+
'tacit_pyramid_list_programs',
|
|
14
|
+
'tacit_pyramid_list_dossiers',
|
|
15
|
+
];
|
|
16
|
+
/** Drill-down tool required before a GM-workflow KB promotion. */
|
|
17
|
+
export const KB_PREREQ_TOOL = 'tacit_kb_list_collections';
|
|
18
|
+
// ─── GM type definition ─────────────────────────────────────────────────────
|
|
19
|
+
export const GM_TYPE_DEF = {
|
|
20
|
+
name: 'gm_content_placement',
|
|
21
|
+
entryTool: 'tacit_gm_ingest',
|
|
22
|
+
prereqs: {
|
|
23
|
+
kind: 'flat',
|
|
24
|
+
tools: [...PYRAMID_PREREQ_TOOLS, KB_PREREQ_TOOL],
|
|
25
|
+
},
|
|
26
|
+
gatedChecks: 'bespoke',
|
|
27
|
+
terminalAction: {
|
|
28
|
+
tool: 'tacit_gm_approve',
|
|
29
|
+
budget: (opts) => (opts?.['crossReference'] ? 2 : 1),
|
|
30
|
+
},
|
|
31
|
+
persistent: false,
|
|
32
|
+
failDirection: 'open',
|
|
33
|
+
sharedToolPolicy: 'passthrough',
|
|
34
|
+
guidance: 'GM_WORKFLOW',
|
|
35
|
+
maxInstances: 1,
|
|
36
|
+
};
|
|
37
|
+
// ─── Registry class ─────────────────────────────────────────────────────────
|
|
38
|
+
export class WorkflowRegistry {
|
|
39
|
+
types = new Map();
|
|
40
|
+
entryToolIndex = new Map();
|
|
41
|
+
toolToTypes = new Map();
|
|
42
|
+
// W7: workspace-scoped user types overlay system types
|
|
43
|
+
workspaceTypes = new Map();
|
|
44
|
+
loadedWorkspaces = new Set();
|
|
45
|
+
register(def) {
|
|
46
|
+
if (this.types.has(def.name)) {
|
|
47
|
+
throw new Error(`WorkflowRegistry: duplicate type name '${def.name}'`);
|
|
48
|
+
}
|
|
49
|
+
this.types.set(def.name, def);
|
|
50
|
+
this.rebuildIndexes(def);
|
|
51
|
+
}
|
|
52
|
+
get(typeName, workspaceId) {
|
|
53
|
+
if (workspaceId) {
|
|
54
|
+
const ws = this.workspaceTypes.get(workspaceId);
|
|
55
|
+
if (ws?.has(typeName))
|
|
56
|
+
return ws.get(typeName);
|
|
57
|
+
}
|
|
58
|
+
return this.types.get(typeName);
|
|
59
|
+
}
|
|
60
|
+
findByEntryTool(toolName) {
|
|
61
|
+
const typeName = this.entryToolIndex.get(toolName);
|
|
62
|
+
return typeName ? this.types.get(typeName) : undefined;
|
|
63
|
+
}
|
|
64
|
+
findByTool(toolName, workspaceId) {
|
|
65
|
+
const result = [];
|
|
66
|
+
const seen = new Set();
|
|
67
|
+
if (workspaceId) {
|
|
68
|
+
const ws = this.workspaceTypes.get(workspaceId);
|
|
69
|
+
if (ws) {
|
|
70
|
+
for (const def of ws.values()) {
|
|
71
|
+
const tools = this.collectTools(def);
|
|
72
|
+
if (tools.includes(toolName)) {
|
|
73
|
+
result.push(def);
|
|
74
|
+
seen.add(def.name);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const typeNames = this.toolToTypes.get(toolName);
|
|
80
|
+
if (typeNames) {
|
|
81
|
+
for (const name of typeNames) {
|
|
82
|
+
if (seen.has(name))
|
|
83
|
+
continue;
|
|
84
|
+
const def = this.types.get(name);
|
|
85
|
+
if (def)
|
|
86
|
+
result.push(def);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
list(workspaceId) {
|
|
92
|
+
const system = Array.from(this.types.values());
|
|
93
|
+
if (!workspaceId)
|
|
94
|
+
return system;
|
|
95
|
+
const ws = this.workspaceTypes.get(workspaceId);
|
|
96
|
+
if (!ws)
|
|
97
|
+
return system;
|
|
98
|
+
const merged = new Map();
|
|
99
|
+
for (const def of system)
|
|
100
|
+
merged.set(def.name, def);
|
|
101
|
+
for (const def of ws.values())
|
|
102
|
+
merged.set(def.name, def);
|
|
103
|
+
return Array.from(merged.values());
|
|
104
|
+
}
|
|
105
|
+
has(typeName, workspaceId) {
|
|
106
|
+
if (this.types.has(typeName))
|
|
107
|
+
return true;
|
|
108
|
+
if (workspaceId) {
|
|
109
|
+
const ws = this.workspaceTypes.get(workspaceId);
|
|
110
|
+
if (ws?.has(typeName))
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
// W7: register a user-authored type scoped to a workspace
|
|
116
|
+
registerUserType(def, workspaceId) {
|
|
117
|
+
let ws = this.workspaceTypes.get(workspaceId);
|
|
118
|
+
if (!ws) {
|
|
119
|
+
ws = new Map();
|
|
120
|
+
this.workspaceTypes.set(workspaceId, ws);
|
|
121
|
+
}
|
|
122
|
+
ws.set(def.name, def);
|
|
123
|
+
}
|
|
124
|
+
removeUserType(typeName, workspaceId) {
|
|
125
|
+
const ws = this.workspaceTypes.get(workspaceId);
|
|
126
|
+
if (!ws)
|
|
127
|
+
return false;
|
|
128
|
+
return ws.delete(typeName);
|
|
129
|
+
}
|
|
130
|
+
hasWorkspaceLoaded(workspaceId) {
|
|
131
|
+
return this.loadedWorkspaces.has(workspaceId);
|
|
132
|
+
}
|
|
133
|
+
markWorkspaceLoaded(workspaceId) {
|
|
134
|
+
this.loadedWorkspaces.add(workspaceId);
|
|
135
|
+
}
|
|
136
|
+
rebuildIndexes(def) {
|
|
137
|
+
if (def.entryTool !== null) {
|
|
138
|
+
this.entryToolIndex.set(def.entryTool, def.name);
|
|
139
|
+
}
|
|
140
|
+
const allTools = this.collectTools(def);
|
|
141
|
+
for (const tool of allTools) {
|
|
142
|
+
let set = this.toolToTypes.get(tool);
|
|
143
|
+
if (!set) {
|
|
144
|
+
set = new Set();
|
|
145
|
+
this.toolToTypes.set(tool, set);
|
|
146
|
+
}
|
|
147
|
+
set.add(def.name);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
collectTools(def) {
|
|
151
|
+
const tools = [];
|
|
152
|
+
if (def.entryTool !== null) {
|
|
153
|
+
tools.push(def.entryTool);
|
|
154
|
+
}
|
|
155
|
+
if (def.terminalAction) {
|
|
156
|
+
tools.push(def.terminalAction.tool);
|
|
157
|
+
}
|
|
158
|
+
if (def.prereqs.kind === 'flat') {
|
|
159
|
+
for (const t of def.prereqs.tools) {
|
|
160
|
+
if (!tools.includes(t))
|
|
161
|
+
tools.push(t);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
for (const phase of def.prereqs.phases) {
|
|
166
|
+
for (const t of phase.requiredTools) {
|
|
167
|
+
if (!tools.includes(t))
|
|
168
|
+
tools.push(t);
|
|
169
|
+
}
|
|
170
|
+
for (const t of phase.gatedTools) {
|
|
171
|
+
if (!tools.includes(t))
|
|
172
|
+
tools.push(t);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return tools;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// ─── COS type definition (W2 Step 6) ────────────────────────────────────────
|
|
180
|
+
export const COS_TYPE_DEF = {
|
|
181
|
+
name: 'cos_coordination',
|
|
182
|
+
entryTool: null,
|
|
183
|
+
prereqs: { kind: 'flat', tools: [] },
|
|
184
|
+
gatedChecks: 'standard',
|
|
185
|
+
handoff: {
|
|
186
|
+
targetTypes: ['gm_content_placement', 'coo_operations', 'research_exec', 'cmo_marketing_pipeline'],
|
|
187
|
+
preserveParent: true,
|
|
188
|
+
},
|
|
189
|
+
persistent: false,
|
|
190
|
+
failDirection: 'open',
|
|
191
|
+
sharedToolPolicy: 'passthrough',
|
|
192
|
+
guidance: 'COS_SUB_WORKFLOWS',
|
|
193
|
+
maxInstances: 1,
|
|
194
|
+
};
|
|
195
|
+
// ─── Pyr Exec type definition (W2 Step 7) ──────────────────────────────────
|
|
196
|
+
export const PYR_EXEC_TYPE_DEF = {
|
|
197
|
+
name: 'pyr_exec',
|
|
198
|
+
entryTool: null,
|
|
199
|
+
prereqs: {
|
|
200
|
+
kind: 'flat',
|
|
201
|
+
tools: [...PYRAMID_PREREQ_TOOLS],
|
|
202
|
+
},
|
|
203
|
+
gatedChecks: 'standard',
|
|
204
|
+
persistent: false,
|
|
205
|
+
failDirection: 'open',
|
|
206
|
+
sharedToolPolicy: 'passthrough',
|
|
207
|
+
guidance: 'PYR_EXEC_SUB_WORKFLOWS',
|
|
208
|
+
maxInstances: 1,
|
|
209
|
+
};
|
|
210
|
+
// ─── COO type definition (W2 Step 8) ───────────────────────────────────────
|
|
211
|
+
export const COO_TYPE_DEF = {
|
|
212
|
+
name: 'coo_operations',
|
|
213
|
+
entryTool: null,
|
|
214
|
+
prereqs: { kind: 'flat', tools: [] },
|
|
215
|
+
gatedChecks: 'standard',
|
|
216
|
+
handoff: {
|
|
217
|
+
targetTypes: ['sales_full_pipeline', 'gm_content_placement', 'pyr_exec', 'research_exec', 'cmo_marketing_pipeline'],
|
|
218
|
+
preserveParent: false,
|
|
219
|
+
},
|
|
220
|
+
persistent: false,
|
|
221
|
+
failDirection: 'open',
|
|
222
|
+
sharedToolPolicy: 'passthrough',
|
|
223
|
+
guidance: 'COO_SUB_WORKFLOWS',
|
|
224
|
+
maxInstances: 1,
|
|
225
|
+
};
|
|
226
|
+
// ─── CMO type definition (W3 Step 12) ──────────────────────────────────────
|
|
227
|
+
export const CMO_TYPE_DEF = {
|
|
228
|
+
name: 'cmo_marketing_pipeline',
|
|
229
|
+
entryTool: null,
|
|
230
|
+
prereqs: {
|
|
231
|
+
kind: 'phased',
|
|
232
|
+
phases: [
|
|
233
|
+
{ name: 'intake', requiredTools: [], gatedTools: [], approvalGate: false, guidance: 'CMO_INTAKE' },
|
|
234
|
+
{ name: 'brand-load', requiredTools: [], gatedTools: [], approvalGate: false, guidance: 'CMO_BRAND_LOAD' },
|
|
235
|
+
{ name: 'produce', requiredTools: [], gatedTools: [], approvalGate: false, guidance: 'CMO_PRODUCE' },
|
|
236
|
+
{ name: 'lint', requiredTools: ['tacit_cmo_lint'], gatedTools: [], approvalGate: false, guidance: 'CMO_LINT' },
|
|
237
|
+
{
|
|
238
|
+
name: 'judge/receipt',
|
|
239
|
+
requiredTools: [],
|
|
240
|
+
gatedTools: [],
|
|
241
|
+
approvalGate: false,
|
|
242
|
+
guidance: 'CMO_JUDGE_RECEIPT',
|
|
243
|
+
requiredMetadata: {
|
|
244
|
+
receiptSha256: 'present',
|
|
245
|
+
'receiptSha256:deliverableSha256': 'present-and-distinct',
|
|
246
|
+
},
|
|
247
|
+
metadataCondition: 'receiptRequired',
|
|
248
|
+
},
|
|
249
|
+
{ name: 'handoff', requiredTools: [], gatedTools: [], approvalGate: false, guidance: 'CMO_HANDOFF' },
|
|
250
|
+
],
|
|
251
|
+
},
|
|
252
|
+
handoff: {
|
|
253
|
+
targetTypes: ['gm_content_placement'],
|
|
254
|
+
preserveParent: true,
|
|
255
|
+
},
|
|
256
|
+
persistent: false,
|
|
257
|
+
failDirection: 'open',
|
|
258
|
+
sharedToolPolicy: 'passthrough',
|
|
259
|
+
guidance: 'CMO_MARKETING_PIPELINE',
|
|
260
|
+
maxInstances: 1,
|
|
261
|
+
};
|
|
262
|
+
// ─── Sales type definition (W4 Step 16) ───────────────────────────────────
|
|
263
|
+
export const SALES_TYPE_DEF = {
|
|
264
|
+
name: 'sales_full_pipeline',
|
|
265
|
+
entryTool: null,
|
|
266
|
+
prereqs: {
|
|
267
|
+
kind: 'phased',
|
|
268
|
+
phases: [
|
|
269
|
+
{ name: 'context', requiredTools: [], gatedTools: [], approvalGate: true, guidance: 'SALES_CONTEXT' },
|
|
270
|
+
{ name: 'discovery', requiredTools: [], gatedTools: [], approvalGate: true, guidance: 'SALES_DISCOVERY' },
|
|
271
|
+
{ name: 'proposal', requiredTools: [], gatedTools: [], approvalGate: true, guidance: 'SALES_PROPOSAL' },
|
|
272
|
+
{ name: 'review', requiredTools: [], gatedTools: [], approvalGate: true, guidance: 'SALES_REVIEW' },
|
|
273
|
+
{ name: 'quote', requiredTools: [], gatedTools: [], approvalGate: true, guidance: 'SALES_QUOTE' },
|
|
274
|
+
{ name: 'pilot', requiredTools: [], gatedTools: [], approvalGate: true, guidance: 'SALES_PILOT' },
|
|
275
|
+
{ name: 'pipeline', requiredTools: [], gatedTools: [], approvalGate: true, guidance: 'SALES_PIPELINE' },
|
|
276
|
+
],
|
|
277
|
+
},
|
|
278
|
+
handoff: {
|
|
279
|
+
targetTypes: ['gm_content_placement'],
|
|
280
|
+
preserveParent: true,
|
|
281
|
+
budgetPerPhase: 3,
|
|
282
|
+
},
|
|
283
|
+
persistent: true,
|
|
284
|
+
ttlDays: 30,
|
|
285
|
+
failDirection: 'open',
|
|
286
|
+
sharedToolPolicy: 'passthrough',
|
|
287
|
+
guidance: 'SALES_FULL_PIPELINE',
|
|
288
|
+
maxInstances: 1,
|
|
289
|
+
};
|
|
290
|
+
// ─── Research type definition (W5 Step 20) ────────────────────────────────
|
|
291
|
+
export const RESEARCH_TYPE_DEF = {
|
|
292
|
+
name: 'research_exec',
|
|
293
|
+
entryTool: null,
|
|
294
|
+
prereqs: {
|
|
295
|
+
kind: 'phased',
|
|
296
|
+
phases: [
|
|
297
|
+
{ name: 'prepare', requiredTools: ['tacit_research_prepare'], gatedTools: [], approvalGate: false, guidance: 'RESEARCH_PREPARE' },
|
|
298
|
+
{ name: 'plan_approval', requiredTools: [], gatedTools: ['tacit_research_launch'], approvalGate: true, guidance: 'RESEARCH_PLAN_APPROVAL' },
|
|
299
|
+
{ name: 'dispatch', requiredTools: ['tacit_research_launch'], gatedTools: [], approvalGate: false, guidance: 'RESEARCH_DISPATCH' },
|
|
300
|
+
{ name: 'synthesis', requiredTools: [], gatedTools: [], approvalGate: false, guidance: 'RESEARCH_SYNTHESIS' },
|
|
301
|
+
{ name: 'placement', requiredTools: ['tacit_research_place'], gatedTools: ['tacit_gm_ingest'], approvalGate: true, guidance: 'RESEARCH_PLACEMENT' },
|
|
302
|
+
],
|
|
303
|
+
},
|
|
304
|
+
persistent: true,
|
|
305
|
+
ttlDays: 7,
|
|
306
|
+
failDirection: 'open',
|
|
307
|
+
sharedToolPolicy: 'passthrough',
|
|
308
|
+
guidance: 'RESEARCH_EXEC',
|
|
309
|
+
maxInstances: 3,
|
|
310
|
+
};
|
|
311
|
+
export const WIKI_TYPE_DEF = {
|
|
312
|
+
name: 'wiki_authoring',
|
|
313
|
+
entryTool: null,
|
|
314
|
+
prereqs: {
|
|
315
|
+
kind: 'phased',
|
|
316
|
+
phases: [
|
|
317
|
+
{ name: 'classify', requiredTools: ['tacit_wiki_classify'], gatedTools: [], approvalGate: false, guidance: 'Classify the content type and target wiki section before authoring.' },
|
|
318
|
+
{ name: 'validate', requiredTools: ['tacit_wiki_validate'], gatedTools: [], approvalGate: false, guidance: 'Validate content structure and references before writing.' },
|
|
319
|
+
{ name: 'author', requiredTools: ['tacit_wiki_author'], gatedTools: ['tacit_wiki_write', 'tacit_wiki_override'], approvalGate: false, guidance: 'Author the content. Write and override tools unlock after this phase.' },
|
|
320
|
+
],
|
|
321
|
+
},
|
|
322
|
+
failDirection: 'open',
|
|
323
|
+
sharedToolPolicy: 'passthrough',
|
|
324
|
+
guidance: 'WIKI_AUTHORING',
|
|
325
|
+
maxInstances: 1,
|
|
326
|
+
};
|
|
327
|
+
export const KB_TYPE_DEF = {
|
|
328
|
+
name: 'kb_management',
|
|
329
|
+
entryTool: null,
|
|
330
|
+
prereqs: {
|
|
331
|
+
kind: 'phased',
|
|
332
|
+
phases: [
|
|
333
|
+
{ name: 'browse', requiredTools: ['tacit_kb_browse_tree', 'tacit_kb_list_collections', 'tacit_kb_list_categories'], gatedTools: [], approvalGate: false, guidance: 'Browse the knowledge base structure before making changes.' },
|
|
334
|
+
{ name: 'curate', requiredTools: [], gatedTools: ['tacit_kb_create_article', 'tacit_kb_update_article', 'tacit_kb_create_category', 'tacit_kb_create_collection', 'tacit_kb_update_collection', 'tacit_kb_delete_collection', 'tacit_kb_promote_from_artifact', 'tacit_kb_promote_from_catalog'], approvalGate: false, guidance: 'Create, update, or promote KB content. Browse phase must complete first.' },
|
|
335
|
+
{ name: 'source_admin', requiredTools: [], gatedTools: ['tacit_kb_pull_source'], approvalGate: true, guidance: 'Source administration requires approval. Note: tacit_kb_register_source is ADMIN_ONLY transport and bypasses this gate.' },
|
|
336
|
+
],
|
|
337
|
+
},
|
|
338
|
+
failDirection: 'open',
|
|
339
|
+
sharedToolPolicy: 'passthrough',
|
|
340
|
+
guidance: 'KB_MANAGEMENT',
|
|
341
|
+
maxInstances: 1,
|
|
342
|
+
};
|
|
343
|
+
export const LAKE_TYPE_DEF = {
|
|
344
|
+
name: 'lake_operations',
|
|
345
|
+
entryTool: null,
|
|
346
|
+
prereqs: {
|
|
347
|
+
kind: 'phased',
|
|
348
|
+
phases: [
|
|
349
|
+
{ name: 'explore', requiredTools: ['tacit_lake_browse_catalog', 'tacit_lake_folder_list', 'tacit_lake_taxonomy_browse'], gatedTools: [], approvalGate: false, guidance: 'Explore the data lake catalog and taxonomy before operations.' },
|
|
350
|
+
{ name: 'ingest', requiredTools: [], gatedTools: ['tacit_lake_ingest', 'tacit_lake_classify', 'tacit_lake_classify_subject', 'tacit_lake_reclassify', 'tacit_lake_reclassify_subjects', 'tacit_lake_folder_add', 'tacit_lake_folder_rename'], approvalGate: false, guidance: 'Ingest and classify content. Explore phase must complete first.' },
|
|
351
|
+
{ name: 'structure', requiredTools: [], gatedTools: ['tacit_lake_propose_structure', 'tacit_lake_confirm_proposal'], approvalGate: true, guidance: 'Structure proposals require approval before confirmation.' },
|
|
352
|
+
],
|
|
353
|
+
},
|
|
354
|
+
persistent: true,
|
|
355
|
+
ttlDays: 7,
|
|
356
|
+
failDirection: 'open',
|
|
357
|
+
sharedToolPolicy: 'passthrough',
|
|
358
|
+
guidance: 'LAKE_OPERATIONS',
|
|
359
|
+
maxInstances: 3,
|
|
360
|
+
};
|
|
361
|
+
// ─── Factory ────────────────────────────────────────────────────────────────
|
|
362
|
+
export function createDefaultRegistry() {
|
|
363
|
+
const registry = new WorkflowRegistry();
|
|
364
|
+
registry.register(GM_TYPE_DEF);
|
|
365
|
+
registry.register(COS_TYPE_DEF);
|
|
366
|
+
registry.register(PYR_EXEC_TYPE_DEF);
|
|
367
|
+
registry.register(COO_TYPE_DEF);
|
|
368
|
+
registry.register(CMO_TYPE_DEF);
|
|
369
|
+
registry.register(SALES_TYPE_DEF);
|
|
370
|
+
registry.register(RESEARCH_TYPE_DEF);
|
|
371
|
+
registry.register(WIKI_TYPE_DEF);
|
|
372
|
+
registry.register(KB_TYPE_DEF);
|
|
373
|
+
registry.register(LAKE_TYPE_DEF);
|
|
374
|
+
return registry;
|
|
375
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-written TS validation for user-authored workflow type definitions (MV-1539 W7 Step 29).
|
|
3
|
+
* No ajv dependency — validation is structural checks only.
|
|
4
|
+
*/
|
|
5
|
+
export declare const SYSTEM_RESERVED_TYPE_NAMES: readonly ["gm_content_placement", "cos_coordination", "pyr_exec", "coo_operations", "cmo_marketing_pipeline", "sales_full_pipeline", "research_exec", "wiki_authoring", "kb_management", "lake_operations"];
|
|
6
|
+
export declare const SYSTEM_RESERVED_TOOLS: readonly ["tacit_gm_ingest", "tacit_gm_approve", "tacit_gm_reset", "tacit_kb_promote_from_artifact", "tacit_kb_promote_from_catalog", "tacit_cmo_lint", "tacit_dispatch_crew", "tacit_research_launch", "tacit_research_prepare", "tacit_research_place"];
|
|
7
|
+
export interface UserTypeValidationResult {
|
|
8
|
+
valid: boolean;
|
|
9
|
+
errors: string[];
|
|
10
|
+
}
|
|
11
|
+
export declare function validateUserTypeDef(input: unknown): UserTypeValidationResult;
|