@gwdn/nexus-mcp 0.7.0

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.
Files changed (133) hide show
  1. package/.github/workflows/ci.yml +38 -0
  2. package/.github/workflows/release.yml +57 -0
  3. package/README.md +89 -0
  4. package/dist/auth.d.ts +39 -0
  5. package/dist/auth.d.ts.map +1 -0
  6. package/dist/auth.js +47 -0
  7. package/dist/auth.js.map +1 -0
  8. package/dist/nexus-api.d.ts +35 -0
  9. package/dist/nexus-api.d.ts.map +1 -0
  10. package/dist/nexus-api.js +90 -0
  11. package/dist/nexus-api.js.map +1 -0
  12. package/dist/server.d.ts +67 -0
  13. package/dist/server.d.ts.map +1 -0
  14. package/dist/server.js +189 -0
  15. package/dist/server.js.map +1 -0
  16. package/dist/tools/add-task-note.d.ts +34 -0
  17. package/dist/tools/add-task-note.d.ts.map +1 -0
  18. package/dist/tools/add-task-note.js +39 -0
  19. package/dist/tools/add-task-note.js.map +1 -0
  20. package/dist/tools/append-session-entry.d.ts +53 -0
  21. package/dist/tools/append-session-entry.d.ts.map +1 -0
  22. package/dist/tools/append-session-entry.js +68 -0
  23. package/dist/tools/append-session-entry.js.map +1 -0
  24. package/dist/tools/create-task.d.ts +52 -0
  25. package/dist/tools/create-task.d.ts.map +1 -0
  26. package/dist/tools/create-task.js +51 -0
  27. package/dist/tools/create-task.js.map +1 -0
  28. package/dist/tools/decision-comments.d.ts +54 -0
  29. package/dist/tools/decision-comments.d.ts.map +1 -0
  30. package/dist/tools/decision-comments.js +81 -0
  31. package/dist/tools/decision-comments.js.map +1 -0
  32. package/dist/tools/get-document.d.ts +47 -0
  33. package/dist/tools/get-document.d.ts.map +1 -0
  34. package/dist/tools/get-document.js +68 -0
  35. package/dist/tools/get-document.js.map +1 -0
  36. package/dist/tools/get-project-memory.d.ts +47 -0
  37. package/dist/tools/get-project-memory.d.ts.map +1 -0
  38. package/dist/tools/get-project-memory.js +53 -0
  39. package/dist/tools/get-project-memory.js.map +1 -0
  40. package/dist/tools/get-related-entities.d.ts +44 -0
  41. package/dist/tools/get-related-entities.d.ts.map +1 -0
  42. package/dist/tools/get-related-entities.js +60 -0
  43. package/dist/tools/get-related-entities.js.map +1 -0
  44. package/dist/tools/governance.d.ts +90 -0
  45. package/dist/tools/governance.d.ts.map +1 -0
  46. package/dist/tools/governance.js +127 -0
  47. package/dist/tools/governance.js.map +1 -0
  48. package/dist/tools/ingest-document.d.ts +40 -0
  49. package/dist/tools/ingest-document.d.ts.map +1 -0
  50. package/dist/tools/ingest-document.js +49 -0
  51. package/dist/tools/ingest-document.js.map +1 -0
  52. package/dist/tools/letter-inbox.d.ts +80 -0
  53. package/dist/tools/letter-inbox.d.ts.map +1 -0
  54. package/dist/tools/letter-inbox.js +118 -0
  55. package/dist/tools/letter-inbox.js.map +1 -0
  56. package/dist/tools/letters.d.ts +91 -0
  57. package/dist/tools/letters.d.ts.map +1 -0
  58. package/dist/tools/letters.js +112 -0
  59. package/dist/tools/letters.js.map +1 -0
  60. package/dist/tools/list-documents.d.ts +33 -0
  61. package/dist/tools/list-documents.d.ts.map +1 -0
  62. package/dist/tools/list-documents.js +47 -0
  63. package/dist/tools/list-documents.js.map +1 -0
  64. package/dist/tools/list-tasks.d.ts +39 -0
  65. package/dist/tools/list-tasks.d.ts.map +1 -0
  66. package/dist/tools/list-tasks.js +46 -0
  67. package/dist/tools/list-tasks.js.map +1 -0
  68. package/dist/tools/project-list.d.ts +28 -0
  69. package/dist/tools/project-list.d.ts.map +1 -0
  70. package/dist/tools/project-list.js +43 -0
  71. package/dist/tools/project-list.js.map +1 -0
  72. package/dist/tools/reviews.d.ts +145 -0
  73. package/dist/tools/reviews.d.ts.map +1 -0
  74. package/dist/tools/reviews.js +220 -0
  75. package/dist/tools/reviews.js.map +1 -0
  76. package/dist/tools/search-knowledge.d.ts +48 -0
  77. package/dist/tools/search-knowledge.d.ts.map +1 -0
  78. package/dist/tools/search-knowledge.js +54 -0
  79. package/dist/tools/search-knowledge.js.map +1 -0
  80. package/dist/tools/sessions.d.ts +81 -0
  81. package/dist/tools/sessions.d.ts.map +1 -0
  82. package/dist/tools/sessions.js +123 -0
  83. package/dist/tools/sessions.js.map +1 -0
  84. package/dist/tools/skill-assign.d.ts +77 -0
  85. package/dist/tools/skill-assign.d.ts.map +1 -0
  86. package/dist/tools/skill-assign.js +108 -0
  87. package/dist/tools/skill-assign.js.map +1 -0
  88. package/dist/tools/skills.d.ts +138 -0
  89. package/dist/tools/skills.d.ts.map +1 -0
  90. package/dist/tools/skills.js +195 -0
  91. package/dist/tools/skills.js.map +1 -0
  92. package/dist/tools/update-task-status.d.ts +48 -0
  93. package/dist/tools/update-task-status.d.ts.map +1 -0
  94. package/dist/tools/update-task-status.js +51 -0
  95. package/dist/tools/update-task-status.js.map +1 -0
  96. package/package.json +30 -0
  97. package/src/__tests__/auth.test.ts +162 -0
  98. package/src/__tests__/decision-comments.test.ts +173 -0
  99. package/src/__tests__/e2e-integration.test.ts +443 -0
  100. package/src/__tests__/helpers.ts +58 -0
  101. package/src/__tests__/layer1-knowledge.test.ts +302 -0
  102. package/src/__tests__/layer2-coordination.test.ts +842 -0
  103. package/src/__tests__/layer3-governance.test.ts +205 -0
  104. package/src/__tests__/project-list-and-skill-assign.test.ts +282 -0
  105. package/src/__tests__/reviews.test.ts +420 -0
  106. package/src/__tests__/server.test.ts +250 -0
  107. package/src/__tests__/setup.ts +15 -0
  108. package/src/__tests__/task-list-and-doc-list.test.ts +226 -0
  109. package/src/auth.ts +81 -0
  110. package/src/nexus-api.ts +127 -0
  111. package/src/server.ts +520 -0
  112. package/src/tools/add-task-note.ts +50 -0
  113. package/src/tools/append-session-entry.ts +84 -0
  114. package/src/tools/create-task.ts +66 -0
  115. package/src/tools/decision-comments.ts +103 -0
  116. package/src/tools/get-document.ts +80 -0
  117. package/src/tools/get-project-memory.ts +65 -0
  118. package/src/tools/get-related-entities.ts +73 -0
  119. package/src/tools/governance.ts +165 -0
  120. package/src/tools/ingest-document.ts +65 -0
  121. package/src/tools/letter-inbox.ts +157 -0
  122. package/src/tools/letters.ts +144 -0
  123. package/src/tools/list-documents.ts +58 -0
  124. package/src/tools/list-tasks.ts +57 -0
  125. package/src/tools/project-list.ts +52 -0
  126. package/src/tools/reviews.ts +281 -0
  127. package/src/tools/search-knowledge.ts +68 -0
  128. package/src/tools/sessions.ts +157 -0
  129. package/src/tools/skill-assign.ts +142 -0
  130. package/src/tools/skills.ts +255 -0
  131. package/src/tools/update-task-status.ts +64 -0
  132. package/tsconfig.json +20 -0
  133. package/vitest.config.ts +8 -0
@@ -0,0 +1,66 @@
1
+ /**
2
+ * task_create -- Layer 2 Coordination
3
+ *
4
+ * Creates a new task within a project scope.
5
+ * Delegates to POST /api/mcp/tasks (action: task_create).
6
+ */
7
+
8
+ import { z } from 'zod'
9
+ import { nexusPost } from '../nexus-api.js'
10
+
11
+ export const createTaskSchema = {
12
+ project_id: z.string().uuid().describe('Project UUID'),
13
+ title: z.string().max(500).describe('Task title'),
14
+ description: z.string().max(100_000).optional().describe('Task description'),
15
+ priority: z
16
+ .enum(['low', 'normal', 'high', 'urgent'])
17
+ .default('normal')
18
+ .describe('Task priority'),
19
+ assignee: z.string().uuid().optional().describe('UUID of the assigned user'),
20
+ status: z
21
+ .enum(['open', 'in_progress', 'blocked', 'done', 'cancelled'])
22
+ .default('open')
23
+ .describe('Initial task status'),
24
+ agent_id: z.string().max(200).optional().describe('Agent identifier if applicable'),
25
+ }
26
+
27
+ type CreateTaskArgs = {
28
+ project_id: string
29
+ title: string
30
+ description?: string
31
+ priority?: string
32
+ assignee?: string
33
+ status?: string
34
+ user_id: string
35
+ agent_id?: string
36
+ }
37
+
38
+ export async function createTask(args: CreateTaskArgs) {
39
+ const result = await nexusPost('/api/mcp/tasks', {
40
+ action: 'task_create',
41
+ project_id: args.project_id,
42
+ title: args.title,
43
+ description: args.description,
44
+ priority: args.priority ?? 'normal',
45
+ assignee: args.assignee,
46
+ status: args.status ?? 'open',
47
+ })
48
+
49
+ if (!result.ok) {
50
+ return {
51
+ content: [
52
+ {
53
+ type: 'text' as const,
54
+ text: JSON.stringify({ error: result.error }, null, 2),
55
+ },
56
+ ],
57
+ isError: true,
58
+ }
59
+ }
60
+
61
+ return {
62
+ content: [
63
+ { type: 'text' as const, text: JSON.stringify(result.data, null, 2) },
64
+ ],
65
+ }
66
+ }
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Decision comment tools -- Layer 2 Coordination
3
+ *
4
+ * Provides append-only comment threads for ADR decisions.
5
+ * Delegates to POST /api/mcp/governance (actions: dc_add, dc_list).
6
+ */
7
+
8
+ import { z } from 'zod'
9
+ import { nexusPost } from '../nexus-api.js'
10
+
11
+ // ---------------------------------------------------------------------------
12
+ // add_decision_comment -> dc_add
13
+ // ---------------------------------------------------------------------------
14
+
15
+ export const addDecisionCommentSchema = {
16
+ decision_id: z.string().uuid().describe('Decision UUID to comment on'),
17
+ body: z.string().max(100_000).describe('Comment body (markdown supported)'),
18
+ agent_id: z
19
+ .string()
20
+ .max(200)
21
+ .optional()
22
+ .describe('Agent identifier if comment is posted by an agent'),
23
+ }
24
+
25
+ type AddDecisionCommentArgs = {
26
+ decision_id: string
27
+ body: string
28
+ agent_id?: string
29
+ user_id: string
30
+ }
31
+
32
+ export async function addDecisionComment(args: AddDecisionCommentArgs) {
33
+ const result = await nexusPost('/api/mcp/governance', {
34
+ action: 'dc_add',
35
+ decision_id: args.decision_id,
36
+ body: args.body,
37
+ agent_id: args.agent_id,
38
+ })
39
+
40
+ if (!result.ok) {
41
+ return {
42
+ content: [
43
+ {
44
+ type: 'text' as const,
45
+ text: JSON.stringify({ error: result.error }, null, 2),
46
+ },
47
+ ],
48
+ isError: true,
49
+ }
50
+ }
51
+
52
+ return {
53
+ content: [
54
+ { type: 'text' as const, text: JSON.stringify(result.data, null, 2) },
55
+ ],
56
+ }
57
+ }
58
+
59
+ // ---------------------------------------------------------------------------
60
+ // list_decision_comments -> dc_list
61
+ // ---------------------------------------------------------------------------
62
+
63
+ export const listDecisionCommentsSchema = {
64
+ decision_id: z.string().uuid().describe('Decision UUID'),
65
+ limit: z
66
+ .number()
67
+ .int()
68
+ .min(1)
69
+ .max(100)
70
+ .default(50)
71
+ .describe('Maximum comments to return'),
72
+ }
73
+
74
+ type ListDecisionCommentsArgs = {
75
+ decision_id: string
76
+ limit?: number
77
+ }
78
+
79
+ export async function listDecisionComments(args: ListDecisionCommentsArgs) {
80
+ const result = await nexusPost('/api/mcp/governance', {
81
+ action: 'dc_list',
82
+ decision_id: args.decision_id,
83
+ limit: args.limit ?? 50,
84
+ })
85
+
86
+ if (!result.ok) {
87
+ return {
88
+ content: [
89
+ {
90
+ type: 'text' as const,
91
+ text: JSON.stringify({ error: result.error }, null, 2),
92
+ },
93
+ ],
94
+ isError: true,
95
+ }
96
+ }
97
+
98
+ return {
99
+ content: [
100
+ { type: 'text' as const, text: JSON.stringify(result.data, null, 2) },
101
+ ],
102
+ }
103
+ }
@@ -0,0 +1,80 @@
1
+ /**
2
+ * kb_get -- Layer 1 Knowledge Access
3
+ *
4
+ * Fetches a single knowledge object in canonical form.
5
+ * Returns metadata, current version, body, and linked references.
6
+ * Delegates to POST /api/mcp/documents (action: kb_get).
7
+ *
8
+ * ADR-0001 spec: kb_get(entity_type, entity_id, render_mode)
9
+ */
10
+
11
+ import { z } from 'zod'
12
+ import { nexusPost } from '../nexus-api.js'
13
+
14
+ export const getDocumentSchema = {
15
+ entity_type: z
16
+ .enum([
17
+ 'session',
18
+ 'decision',
19
+ 'letter',
20
+ 'task',
21
+ 'research_note',
22
+ 'planning_item',
23
+ 'ingest_item',
24
+ ])
25
+ .describe('Type of the knowledge object'),
26
+ entity_id: z.string().uuid().describe('UUID of the entity'),
27
+ render_mode: z
28
+ .enum(['structured', 'markdown', 'summary'])
29
+ .default('structured')
30
+ .describe('Output format: structured JSON, markdown, or summary'),
31
+ }
32
+
33
+ type GetDocumentArgs = {
34
+ entity_type: string
35
+ entity_id: string
36
+ render_mode?: string
37
+ }
38
+
39
+ export async function getDocument(args: GetDocumentArgs) {
40
+ const result = await nexusPost('/api/mcp/documents', {
41
+ action: 'kb_get',
42
+ entity_type: args.entity_type,
43
+ entity_id: args.entity_id,
44
+ render_mode: args.render_mode ?? 'structured',
45
+ })
46
+
47
+ if (!result.ok) {
48
+ return {
49
+ content: [
50
+ {
51
+ type: 'text' as const,
52
+ text: JSON.stringify({ error: result.error }, null, 2),
53
+ },
54
+ ],
55
+ isError: true,
56
+ }
57
+ }
58
+
59
+ // For markdown and summary modes, the API returns { content: "..." }
60
+ // For structured mode, the API returns the full object
61
+ const data = result.data as Record<string, unknown>
62
+ const renderMode = args.render_mode ?? 'structured'
63
+
64
+ if (renderMode === 'markdown' || renderMode === 'summary') {
65
+ return {
66
+ content: [
67
+ {
68
+ type: 'text' as const,
69
+ text: (data.content as string) ?? JSON.stringify(data, null, 2),
70
+ },
71
+ ],
72
+ }
73
+ }
74
+
75
+ return {
76
+ content: [
77
+ { type: 'text' as const, text: JSON.stringify(data, null, 2) },
78
+ ],
79
+ }
80
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * kb_memory -- Layer 1 Knowledge Access
3
+ *
4
+ * Returns curated project context for agent bootstrapping.
5
+ * Includes ADRs, active tasks, recent sessions, open letters, etc.
6
+ * Delegates to POST /api/mcp/memory.
7
+ *
8
+ * ADR-0001 spec: kb_memory(project_id, include[], depth)
9
+ */
10
+
11
+ import { z } from 'zod'
12
+ import { nexusPost } from '../nexus-api.js'
13
+
14
+ export const getProjectMemorySchema = {
15
+ project_id: z.string().uuid().describe('Project UUID'),
16
+ include: z
17
+ .array(
18
+ z.enum([
19
+ 'adrs',
20
+ 'rules',
21
+ 'active_tasks',
22
+ 'recent_sessions',
23
+ 'open_letters',
24
+ 'planning',
25
+ 'research',
26
+ ]),
27
+ )
28
+ .describe('Categories of knowledge to include'),
29
+ depth: z
30
+ .enum(['light', 'standard', 'deep'])
31
+ .default('standard')
32
+ .describe('Detail level: light (summaries), standard, deep (full bodies)'),
33
+ }
34
+
35
+ type GetProjectMemoryArgs = {
36
+ project_id: string
37
+ include: string[]
38
+ depth?: string
39
+ }
40
+
41
+ export async function getProjectMemory(args: GetProjectMemoryArgs) {
42
+ const result = await nexusPost('/api/mcp/memory', {
43
+ project_id: args.project_id,
44
+ include: args.include,
45
+ depth: args.depth ?? 'standard',
46
+ })
47
+
48
+ if (!result.ok) {
49
+ return {
50
+ content: [
51
+ {
52
+ type: 'text' as const,
53
+ text: JSON.stringify({ error: result.error }, null, 2),
54
+ },
55
+ ],
56
+ isError: true,
57
+ }
58
+ }
59
+
60
+ return {
61
+ content: [
62
+ { type: 'text' as const, text: JSON.stringify(result.data, null, 2) },
63
+ ],
64
+ }
65
+ }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * kb_related -- Layer 1 Knowledge Access
3
+ *
4
+ * Returns graph-neighbor entities related to a given entity.
5
+ * Delegates to POST /api/mcp/related.
6
+ *
7
+ * ADR-0001 spec: kb_related(entity_type, entity_id, relation_types[], limit)
8
+ */
9
+
10
+ import { z } from 'zod'
11
+ import { nexusPost } from '../nexus-api.js'
12
+
13
+ export const getRelatedEntitiesSchema = {
14
+ entity_type: z
15
+ .enum([
16
+ 'session',
17
+ 'decision',
18
+ 'letter',
19
+ 'task',
20
+ 'research_note',
21
+ 'planning_item',
22
+ 'ingest_item',
23
+ ])
24
+ .describe('Type of the source entity'),
25
+ entity_id: z.string().uuid().describe('UUID of the source entity'),
26
+ relation_types: z
27
+ .array(z.string().max(50))
28
+ .optional()
29
+ .describe(
30
+ 'Filter by specific relation types (e.g., "references", "created_in", "supersedes")',
31
+ ),
32
+ limit: z
33
+ .number()
34
+ .int()
35
+ .min(1)
36
+ .max(50)
37
+ .default(20)
38
+ .describe('Maximum related entities to return'),
39
+ }
40
+
41
+ type GetRelatedEntitiesArgs = {
42
+ entity_type: string
43
+ entity_id: string
44
+ relation_types?: string[]
45
+ limit?: number
46
+ }
47
+
48
+ export async function getRelatedEntities(args: GetRelatedEntitiesArgs) {
49
+ const result = await nexusPost('/api/mcp/related', {
50
+ entity_type: args.entity_type,
51
+ entity_id: args.entity_id,
52
+ relation_types: args.relation_types,
53
+ limit: args.limit ?? 20,
54
+ })
55
+
56
+ if (!result.ok) {
57
+ return {
58
+ content: [
59
+ {
60
+ type: 'text' as const,
61
+ text: JSON.stringify({ error: result.error }, null, 2),
62
+ },
63
+ ],
64
+ isError: true,
65
+ }
66
+ }
67
+
68
+ return {
69
+ content: [
70
+ { type: 'text' as const, text: JSON.stringify(result.data, null, 2) },
71
+ ],
72
+ }
73
+ }
@@ -0,0 +1,165 @@
1
+ /**
2
+ * ADR Governance tools -- Layer 3
3
+ *
4
+ * Manages the ADR lifecycle:
5
+ * draft -> under_review -> accepted | rejected -> superseded -> archived
6
+ *
7
+ * Delegates to POST /api/mcp/governance.
8
+ */
9
+
10
+ import { z } from 'zod'
11
+ import { nexusPost } from '../nexus-api.js'
12
+
13
+ // ---------------------------------------------------------------------------
14
+ // create_adr_draft -> adr_create
15
+ // ---------------------------------------------------------------------------
16
+
17
+ export const createAdrDraftSchema = {
18
+ project_id: z.string().uuid().describe('Project UUID'),
19
+ title: z.string().max(500).describe('ADR title'),
20
+ context: z
21
+ .string()
22
+ .max(100_000)
23
+ .describe('Context / motivation for the decision (markdown)'),
24
+ decision: z.string().max(100_000).describe('The decision content (markdown)'),
25
+ consequences: z
26
+ .string()
27
+ .max(100_000)
28
+ .optional()
29
+ .describe('Expected consequences of the decision (markdown)'),
30
+ supersedes: z
31
+ .string()
32
+ .uuid()
33
+ .optional()
34
+ .describe('UUID of the ADR this one supersedes'),
35
+ agent_id: z.string().max(200).optional().describe('Agent identifier if applicable'),
36
+ }
37
+
38
+ type CreateAdrDraftArgs = {
39
+ project_id: string
40
+ title: string
41
+ context: string
42
+ decision: string
43
+ consequences?: string
44
+ supersedes?: string
45
+ user_id: string
46
+ agent_id?: string
47
+ }
48
+
49
+ export async function createAdrDraft(args: CreateAdrDraftArgs) {
50
+ const result = await nexusPost('/api/mcp/governance', {
51
+ action: 'adr_create',
52
+ project_id: args.project_id,
53
+ title: args.title,
54
+ context: args.context,
55
+ decision: args.decision,
56
+ consequences: args.consequences,
57
+ supersedes: args.supersedes,
58
+ })
59
+
60
+ if (!result.ok) {
61
+ return {
62
+ content: [
63
+ {
64
+ type: 'text' as const,
65
+ text: JSON.stringify({ error: result.error }, null, 2),
66
+ },
67
+ ],
68
+ isError: true,
69
+ }
70
+ }
71
+
72
+ return {
73
+ content: [
74
+ { type: 'text' as const, text: JSON.stringify(result.data, null, 2) },
75
+ ],
76
+ }
77
+ }
78
+
79
+ // ---------------------------------------------------------------------------
80
+ // submit_adr_review -> adr_submit
81
+ // ---------------------------------------------------------------------------
82
+
83
+ export const submitAdrReviewSchema = {
84
+ adr_id: z.string().uuid().describe('ADR UUID to submit for review'),
85
+ }
86
+
87
+ type SubmitAdrReviewArgs = {
88
+ adr_id: string
89
+ user_id: string
90
+ }
91
+
92
+ export async function submitAdrReview(args: SubmitAdrReviewArgs) {
93
+ const result = await nexusPost('/api/mcp/governance', {
94
+ action: 'adr_submit',
95
+ adr_id: args.adr_id,
96
+ })
97
+
98
+ if (!result.ok) {
99
+ return {
100
+ content: [
101
+ {
102
+ type: 'text' as const,
103
+ text: JSON.stringify({ error: result.error }, null, 2),
104
+ },
105
+ ],
106
+ isError: true,
107
+ }
108
+ }
109
+
110
+ return {
111
+ content: [
112
+ { type: 'text' as const, text: JSON.stringify(result.data, null, 2) },
113
+ ],
114
+ }
115
+ }
116
+
117
+ // ---------------------------------------------------------------------------
118
+ // record_adr_decision -> adr_decide
119
+ // ---------------------------------------------------------------------------
120
+
121
+ export const recordAdrDecisionSchema = {
122
+ adr_id: z.string().uuid().describe('ADR UUID'),
123
+ decision: z
124
+ .enum(['accepted', 'rejected'])
125
+ .describe('Decision outcome: accept or reject'),
126
+ rationale: z
127
+ .string()
128
+ .max(10_000)
129
+ .optional()
130
+ .describe('Optional rationale for the decision'),
131
+ }
132
+
133
+ type RecordAdrDecisionArgs = {
134
+ adr_id: string
135
+ decision: string
136
+ rationale?: string
137
+ user_id: string
138
+ }
139
+
140
+ export async function recordAdrDecision(args: RecordAdrDecisionArgs) {
141
+ const result = await nexusPost('/api/mcp/governance', {
142
+ action: 'adr_decide',
143
+ adr_id: args.adr_id,
144
+ decision: args.decision,
145
+ rationale: args.rationale,
146
+ })
147
+
148
+ if (!result.ok) {
149
+ return {
150
+ content: [
151
+ {
152
+ type: 'text' as const,
153
+ text: JSON.stringify({ error: result.error }, null, 2),
154
+ },
155
+ ],
156
+ isError: true,
157
+ }
158
+ }
159
+
160
+ return {
161
+ content: [
162
+ { type: 'text' as const, text: JSON.stringify(result.data, null, 2) },
163
+ ],
164
+ }
165
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * doc_ingest -- Layer 2 Coordination
3
+ *
4
+ * Allows agents to push text/markdown content into a project's
5
+ * knowledge base via the ingest_items table.
6
+ * Delegates to POST /api/mcp/documents (action: doc_ingest).
7
+ */
8
+
9
+ import { z } from 'zod'
10
+ import { nexusPost } from '../nexus-api.js'
11
+
12
+ export const ingestDocumentSchema = {
13
+ project_id: z.string().uuid().describe('Project UUID'),
14
+ title: z.string().max(500).describe('Document title'),
15
+ body: z.string().max(100_000).describe('Document content (text or markdown)'),
16
+ source: z
17
+ .string()
18
+ .max(200)
19
+ .optional()
20
+ .describe(
21
+ 'Source identifier (e.g. "mcp-agent", "research", "session-extract")',
22
+ ),
23
+ source_url: z.string().url().optional().describe('Source URL if applicable'),
24
+ agent_id: z.string().max(200).optional().describe('Agent identifier if applicable'),
25
+ }
26
+
27
+ type IngestDocumentArgs = {
28
+ project_id: string
29
+ title: string
30
+ body: string
31
+ source?: string
32
+ source_url?: string
33
+ user_id: string
34
+ agent_id?: string
35
+ }
36
+
37
+ export async function ingestDocument(args: IngestDocumentArgs) {
38
+ const result = await nexusPost('/api/mcp/documents', {
39
+ action: 'doc_ingest',
40
+ project_id: args.project_id,
41
+ title: args.title,
42
+ body: args.body,
43
+ source: args.source,
44
+ source_url: args.source_url,
45
+ agent_id: args.agent_id,
46
+ })
47
+
48
+ if (!result.ok) {
49
+ return {
50
+ content: [
51
+ {
52
+ type: 'text' as const,
53
+ text: JSON.stringify({ error: result.error }, null, 2),
54
+ },
55
+ ],
56
+ isError: true,
57
+ }
58
+ }
59
+
60
+ return {
61
+ content: [
62
+ { type: 'text' as const, text: JSON.stringify(result.data, null, 2) },
63
+ ],
64
+ }
65
+ }