@treenity/mods 3.0.3 → 3.0.5

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 (116) hide show
  1. package/dist/agent/client.d.ts +3 -0
  2. package/dist/agent/client.d.ts.map +1 -0
  3. package/dist/agent/client.js +3 -0
  4. package/dist/agent/client.js.map +1 -0
  5. package/dist/agent/guardian.d.ts +47 -0
  6. package/dist/agent/guardian.d.ts.map +1 -0
  7. package/dist/agent/guardian.js +452 -0
  8. package/dist/agent/guardian.js.map +1 -0
  9. package/dist/agent/seed.d.ts +2 -0
  10. package/dist/agent/seed.d.ts.map +1 -0
  11. package/dist/agent/seed.js +68 -0
  12. package/dist/agent/seed.js.map +1 -0
  13. package/dist/agent/server.d.ts +5 -0
  14. package/dist/agent/server.d.ts.map +1 -0
  15. package/dist/agent/server.js +5 -0
  16. package/dist/agent/server.js.map +1 -0
  17. package/dist/agent/service.d.ts +2 -0
  18. package/dist/agent/service.d.ts.map +1 -0
  19. package/dist/agent/service.js +556 -0
  20. package/dist/agent/service.js.map +1 -0
  21. package/dist/agent/types.d.ts +115 -0
  22. package/dist/agent/types.d.ts.map +1 -0
  23. package/dist/agent/types.js +168 -0
  24. package/dist/agent/types.js.map +1 -0
  25. package/dist/agent/view.d.ts +2 -0
  26. package/dist/agent/view.d.ts.map +1 -0
  27. package/dist/agent/view.js +137 -0
  28. package/dist/agent/view.js.map +1 -0
  29. package/dist/mcp/mcp-server.d.ts +16 -0
  30. package/dist/mcp/mcp-server.d.ts.map +1 -0
  31. package/dist/mcp/mcp-server.js +344 -0
  32. package/dist/mcp/mcp-server.js.map +1 -0
  33. package/dist/mcp/server.d.ts +3 -0
  34. package/dist/mcp/server.d.ts.map +1 -0
  35. package/dist/mcp/server.js +3 -0
  36. package/dist/mcp/server.js.map +1 -0
  37. package/dist/mcp/service.d.ts +2 -0
  38. package/dist/mcp/service.d.ts.map +1 -0
  39. package/dist/mcp/service.js +16 -0
  40. package/dist/mcp/service.js.map +1 -0
  41. package/dist/mcp/types.d.ts +4 -0
  42. package/dist/mcp/types.d.ts.map +1 -0
  43. package/dist/mcp/types.js +6 -0
  44. package/dist/mcp/types.js.map +1 -0
  45. package/dist/metatron/claude.d.ts +30 -0
  46. package/dist/metatron/claude.d.ts.map +1 -0
  47. package/dist/metatron/claude.js +201 -0
  48. package/dist/metatron/claude.js.map +1 -0
  49. package/dist/metatron/client.d.ts +3 -0
  50. package/dist/metatron/client.d.ts.map +1 -0
  51. package/dist/metatron/client.js +3 -0
  52. package/dist/metatron/client.js.map +1 -0
  53. package/dist/metatron/mentions.d.ts +9 -0
  54. package/dist/metatron/mentions.d.ts.map +1 -0
  55. package/dist/metatron/mentions.js +21 -0
  56. package/dist/metatron/mentions.js.map +1 -0
  57. package/dist/metatron/permissions.d.ts +16 -0
  58. package/dist/metatron/permissions.d.ts.map +1 -0
  59. package/dist/metatron/permissions.js +52 -0
  60. package/dist/metatron/permissions.js.map +1 -0
  61. package/dist/metatron/seed.d.ts +2 -0
  62. package/dist/metatron/seed.d.ts.map +1 -0
  63. package/dist/metatron/seed.js +41 -0
  64. package/dist/metatron/seed.js.map +1 -0
  65. package/dist/metatron/server.d.ts +4 -0
  66. package/dist/metatron/server.d.ts.map +1 -0
  67. package/dist/metatron/server.js +4 -0
  68. package/dist/metatron/server.js.map +1 -0
  69. package/dist/metatron/service.d.ts +2 -0
  70. package/dist/metatron/service.d.ts.map +1 -0
  71. package/dist/metatron/service.js +329 -0
  72. package/dist/metatron/service.js.map +1 -0
  73. package/dist/metatron/types.d.ts +76 -0
  74. package/dist/metatron/types.d.ts.map +1 -0
  75. package/dist/metatron/types.js +112 -0
  76. package/dist/metatron/types.js.map +1 -0
  77. package/dist/metatron/view.d.ts +4 -0
  78. package/dist/metatron/view.d.ts.map +1 -0
  79. package/dist/metatron/view.js +5 -0
  80. package/dist/metatron/view.js.map +1 -0
  81. package/dist/metatron/views/config.d.ts +2 -0
  82. package/dist/metatron/views/config.d.ts.map +1 -0
  83. package/dist/metatron/views/config.js +116 -0
  84. package/dist/metatron/views/config.js.map +1 -0
  85. package/dist/metatron/views/log.d.ts +18 -0
  86. package/dist/metatron/views/log.d.ts.map +1 -0
  87. package/dist/metatron/views/log.js +224 -0
  88. package/dist/metatron/views/log.js.map +1 -0
  89. package/dist/metatron/views/shared.d.ts +13 -0
  90. package/dist/metatron/views/shared.d.ts.map +1 -0
  91. package/dist/metatron/views/shared.js +33 -0
  92. package/dist/metatron/views/shared.js.map +1 -0
  93. package/dist/metatron/views/task.d.ts +4 -0
  94. package/dist/metatron/views/task.d.ts.map +1 -0
  95. package/dist/metatron/views/task.js +106 -0
  96. package/dist/metatron/views/task.js.map +1 -0
  97. package/dist/metatron/views/workspace.d.ts +2 -0
  98. package/dist/metatron/views/workspace.d.ts.map +1 -0
  99. package/dist/metatron/views/workspace.js +138 -0
  100. package/dist/metatron/views/workspace.js.map +1 -0
  101. package/metatron/CLAUDE.md +22 -0
  102. package/metatron/claude.ts +258 -0
  103. package/metatron/client.ts +2 -0
  104. package/metatron/mentions.ts +31 -0
  105. package/metatron/permissions.ts +76 -0
  106. package/metatron/seed.ts +50 -0
  107. package/metatron/server.ts +3 -0
  108. package/metatron/service.ts +368 -0
  109. package/metatron/types.ts +120 -0
  110. package/metatron/view.tsx +4 -0
  111. package/metatron/views/config.tsx +408 -0
  112. package/metatron/views/log.tsx +412 -0
  113. package/metatron/views/shared.tsx +40 -0
  114. package/metatron/views/task.tsx +255 -0
  115. package/metatron/views/workspace.tsx +418 -0
  116. package/package.json +6 -1
@@ -0,0 +1,115 @@
1
+ export type AgentStatus = 'idle' | 'working' | 'blocked' | 'error' | 'offline';
2
+ /** AI Agent — autonomous worker node at /agents/{name}
3
+ * LLM config (model, systemPrompt, sessionId) lives in named metatron.config component.
4
+ * Work creates metatron.task nodes under /agents/{name}/tasks/. */
5
+ export declare class AiAgent {
6
+ /** Open-ended role string. Guardian policies keyed by role. */
7
+ role: string;
8
+ status: AgentStatus;
9
+ /** Path to current board.task being worked on */
10
+ currentTask: string;
11
+ /** Path to current metatron.task (live log) */
12
+ taskRef: string;
13
+ lastRunAt: number;
14
+ /** Total tokens used across all tasks */
15
+ totalTokens: number;
16
+ /** @description Bring agent online */
17
+ online(): void;
18
+ /** @description Take agent offline */
19
+ offline(): void;
20
+ /** @description Assign a board task to this agent */
21
+ assign(data: {
22
+ task: string;
23
+ }): void;
24
+ /** @description Agent finished current task */
25
+ complete(): void;
26
+ /** @description Agent is blocked */
27
+ block(data?: {
28
+ reason?: string;
29
+ }): void;
30
+ /** @description Agent hit an error */
31
+ fail(data?: {
32
+ error?: string;
33
+ }): void;
34
+ }
35
+ /** Concurrency pool — lives on /agents node */
36
+ export declare class AiPool {
37
+ maxConcurrent: number;
38
+ /** Paths of currently active agent nodes */
39
+ active: string[];
40
+ /** Paths of agents waiting for a slot */
41
+ queue: string[];
42
+ }
43
+ /** AI workflow on a board.task — routing + discussion cursor */
44
+ export declare class AiAssignment {
45
+ /** Who created the task */
46
+ origin: string;
47
+ /** Roles to wake for discussion (empty = no discussion pending) */
48
+ nextRoles: string[];
49
+ /** agentPath → last read message index (don't re-send old messages) */
50
+ cursors: Record<string, number>;
51
+ }
52
+ /** Discussion thread on a task — lightweight multi-agent chat */
53
+ export declare class AiThread {
54
+ messages: ThreadMessage[];
55
+ /** @description Post a message to the discussion */
56
+ post(data: {
57
+ role: string;
58
+ from: string;
59
+ text: string;
60
+ }): void;
61
+ }
62
+ export type ThreadMessage = {
63
+ role: string;
64
+ from: string;
65
+ text: string;
66
+ ts: number;
67
+ };
68
+ /** AI execution plan — lives as named component on board.task node.
69
+ * Agent writes plan first, human reviews + approves before execution. */
70
+ export declare class AiPlan {
71
+ /** @format textarea */
72
+ text: string;
73
+ approved: boolean;
74
+ /** @format textarea */
75
+ feedback: string;
76
+ createdAt: number;
77
+ /** @description Approve the plan — agent will proceed to execute */
78
+ approvePlan(data?: {
79
+ feedback?: string;
80
+ }): void;
81
+ /** @description Reject the plan — agent will re-plan with feedback */
82
+ rejectPlan(data?: {
83
+ feedback?: string;
84
+ }): void;
85
+ }
86
+ /** Persistent tool policy — lives on agent (per-agent) or /agents/guardian (global) */
87
+ export declare class AiPolicy {
88
+ allow: string[];
89
+ deny: string[];
90
+ escalate: string[];
91
+ /** @description Add a tool to allow list */
92
+ addAllow(data: {
93
+ pattern: string;
94
+ }): void;
95
+ /** @description Add a tool to deny list */
96
+ addDeny(data: {
97
+ pattern: string;
98
+ }): void;
99
+ /** @description Add a tool to escalate list (requires human approval) */
100
+ addEscalate(data: {
101
+ pattern: string;
102
+ }): void;
103
+ /** @description Remove a rule from all lists */
104
+ removeRule(data: {
105
+ pattern: string;
106
+ }): void;
107
+ }
108
+ /** Approval inbox — field-level ref points to the approvals dir */
109
+ export declare class AiApprovals {
110
+ source: {
111
+ $type: 'ref';
112
+ $ref: string;
113
+ };
114
+ }
115
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../agent/types.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAE/E;;mEAEmE;AACnE,qBAAa,OAAO;IAClB,+DAA+D;IAC/D,IAAI,SAAQ;IACZ,MAAM,EAAE,WAAW,CAAa;IAChC,iDAAiD;IACjD,WAAW,SAAM;IACjB,+CAA+C;IAC/C,OAAO,SAAM;IACb,SAAS,SAAK;IACd,yCAAyC;IACzC,WAAW,SAAK;IAEhB,sCAAsC;IACtC,MAAM;IAKN,sCAAsC;IACtC,OAAO;IAMP,qDAAqD;IACrD,MAAM,CAAC,IAAI,EAAE;QAA4B,IAAI,EAAE,MAAM,CAAA;KAAE;IAQvD,+CAA+C;IAC/C,QAAQ;IAQR,oCAAoC;IACpC,KAAK,CAAC,IAAI,CAAC,EAAE;QAAgB,MAAM,CAAC,EAAE,MAAM,CAAA;K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,EAAE,CAAM;IACrB,IAAI,EAAE,MAAM,EAAE,CAAM;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAM;IACxB,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE;QAAmC,OAAO,EAAE,MAAM,CAAA;KAAE;IAQnE,2CAA2C;IAC3C,OAAO,CAAC,IAAI,EAAE;QAAmC,OAAO,EAAE,MAAM,CAAA;KAAE;IAQlE,yEAAyE;IACzE,WAAW,CAAC,IAAI,EAAE;QAAmC,OAAO,EAAE,MAAM,CAAA;KAAE;IAQtE,gDAAgD;IAChD,UAAU,CAAC,IAAI,EAAE;QAA2B,OAAO,EAAE,MAAM,CAAA;KAAE;CAO9D;AAED,mEAAmE;AACnE,qBAAa,WAAW;IACtB,MAAM,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAA8B;CACrE"}
@@ -0,0 +1,168 @@
1
+ // AI Agent — autonomous worker in the tree.
2
+ // Role determines prompt + tool policy. Uses metatron's invokeClaude for LLM.
3
+ // Agent = node, tree = protocol.
4
+ import { registerType } from '@treenity/core/comp';
5
+ /** AI Agent — autonomous worker node at /agents/{name}
6
+ * LLM config (model, systemPrompt, sessionId) lives in named metatron.config component.
7
+ * Work creates metatron.task nodes under /agents/{name}/tasks/. */
8
+ export class AiAgent {
9
+ /** Open-ended role string. Guardian policies keyed by role. */
10
+ role = 'qa';
11
+ status = 'offline';
12
+ /** Path to current board.task being worked on */
13
+ currentTask = '';
14
+ /** Path to current metatron.task (live log) */
15
+ taskRef = '';
16
+ lastRunAt = 0;
17
+ /** Total tokens used across all tasks */
18
+ totalTokens = 0;
19
+ /** @description Bring agent online */
20
+ online() {
21
+ this.status = 'idle';
22
+ this.currentTask = '';
23
+ }
24
+ /** @description Take agent offline */
25
+ offline() {
26
+ if (this.status === 'working')
27
+ throw new Error('cannot go offline while working');
28
+ this.status = 'offline';
29
+ }
30
+ /** @description Assign a board task to this agent */
31
+ assign(data) {
32
+ if (this.status !== 'idle')
33
+ throw new Error(`cannot assign: agent is ${this.status}`);
34
+ if (!data.task?.trim())
35
+ throw new Error('task path required');
36
+ this.currentTask = data.task.trim();
37
+ this.status = 'working';
38
+ }
39
+ /** @description Agent finished current task */
40
+ complete() {
41
+ if (this.status !== 'working')
42
+ throw new Error(`cannot complete: agent is ${this.status}`);
43
+ this.currentTask = '';
44
+ this.status = 'idle';
45
+ this.lastRunAt = Date.now();
46
+ }
47
+ /** @description Agent is blocked */
48
+ block(data) {
49
+ this.status = 'blocked';
50
+ }
51
+ /** @description Agent hit an error */
52
+ fail(data) {
53
+ this.status = 'error';
54
+ this.currentTask = '';
55
+ }
56
+ }
57
+ /** Concurrency pool — lives on /agents node */
58
+ export class AiPool {
59
+ maxConcurrent = 2;
60
+ /** Paths of currently active agent nodes */
61
+ active = [];
62
+ /** Paths of agents waiting for a slot */
63
+ queue = [];
64
+ }
65
+ /** AI workflow on a board.task — routing + discussion cursor */
66
+ export class AiAssignment {
67
+ /** Who created the task */
68
+ origin = '';
69
+ /** Roles to wake for discussion (empty = no discussion pending) */
70
+ nextRoles = [];
71
+ /** agentPath → last read message index (don't re-send old messages) */
72
+ cursors = {};
73
+ }
74
+ /** Discussion thread on a task — lightweight multi-agent chat */
75
+ export class AiThread {
76
+ messages = [];
77
+ /** @description Post a message to the discussion */
78
+ post(data) {
79
+ if (!data.text?.trim())
80
+ throw new Error('empty message');
81
+ this.messages.push({ role: data.role, from: data.from, text: data.text, ts: Date.now() });
82
+ }
83
+ }
84
+ /** AI execution plan — lives as named component on board.task node.
85
+ * Agent writes plan first, human reviews + approves before execution. */
86
+ export class AiPlan {
87
+ /** @format textarea */
88
+ text = '';
89
+ approved = false;
90
+ /** @format textarea */
91
+ feedback = '';
92
+ createdAt = 0;
93
+ /** @description Approve the plan — agent will proceed to execute */
94
+ approvePlan(data) {
95
+ if (this.approved)
96
+ throw new Error('plan already approved');
97
+ if (!this.text)
98
+ throw new Error('no plan to approve');
99
+ this.approved = true;
100
+ if (data?.feedback)
101
+ this.feedback = data.feedback;
102
+ }
103
+ /** @description Reject the plan — agent will re-plan with feedback */
104
+ rejectPlan(data) {
105
+ if (!this.text)
106
+ throw new Error('no plan to reject');
107
+ this.approved = false;
108
+ if (data?.feedback)
109
+ this.feedback = data.feedback;
110
+ }
111
+ }
112
+ registerType('ai.plan', AiPlan);
113
+ /** Persistent tool policy — lives on agent (per-agent) or /agents/guardian (global) */
114
+ export class AiPolicy {
115
+ allow = [];
116
+ deny = [];
117
+ escalate = [];
118
+ /** @description Add a tool to allow list */
119
+ addAllow(data) {
120
+ if (!data.pattern?.trim())
121
+ throw new Error('pattern required');
122
+ const p = data.pattern.trim();
123
+ if (!this.allow.includes(p))
124
+ this.allow.push(p);
125
+ this.deny = this.deny.filter(d => d !== p);
126
+ this.escalate = this.escalate.filter(e => e !== p);
127
+ }
128
+ /** @description Add a tool to deny list */
129
+ addDeny(data) {
130
+ if (!data.pattern?.trim())
131
+ throw new Error('pattern required');
132
+ const p = data.pattern.trim();
133
+ if (!this.deny.includes(p))
134
+ this.deny.push(p);
135
+ this.allow = this.allow.filter(a => a !== p);
136
+ this.escalate = this.escalate.filter(e => e !== p);
137
+ }
138
+ /** @description Add a tool to escalate list (requires human approval) */
139
+ addEscalate(data) {
140
+ if (!data.pattern?.trim())
141
+ throw new Error('pattern required');
142
+ const p = data.pattern.trim();
143
+ if (!this.escalate.includes(p))
144
+ this.escalate.push(p);
145
+ this.allow = this.allow.filter(a => a !== p);
146
+ this.deny = this.deny.filter(d => d !== p);
147
+ }
148
+ /** @description Remove a rule from all lists */
149
+ removeRule(data) {
150
+ if (!data.pattern?.trim())
151
+ throw new Error('pattern required');
152
+ const p = data.pattern.trim();
153
+ this.allow = this.allow.filter(a => a !== p);
154
+ this.deny = this.deny.filter(d => d !== p);
155
+ this.escalate = this.escalate.filter(e => e !== p);
156
+ }
157
+ }
158
+ /** Approval inbox — field-level ref points to the approvals dir */
159
+ export class AiApprovals {
160
+ source = { $type: 'ref', $ref: '' };
161
+ }
162
+ registerType('ai.approvals', AiApprovals);
163
+ registerType('ai.policy', AiPolicy);
164
+ registerType('ai.agent', AiAgent);
165
+ registerType('ai.pool', AiPool);
166
+ registerType('ai.assignment', AiAssignment);
167
+ registerType('ai.thread', AiThread);
168
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../agent/types.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,8EAA8E;AAC9E,iCAAiC;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAInD;;mEAEmE;AACnE,MAAM,OAAO,OAAO;IAClB,+DAA+D;IAC/D,IAAI,GAAG,IAAI,CAAC;IACZ,MAAM,GAAgB,SAAS,CAAC;IAChC,iDAAiD;IACjD,WAAW,GAAG,EAAE,CAAC;IACjB,+CAA+C;IAC/C,OAAO,GAAG,EAAE,CAAC;IACb,SAAS,GAAG,CAAC,CAAC;IACd,yCAAyC;IACzC,WAAW,GAAG,CAAC,CAAC;IAEhB,sCAAsC;IACtC,MAAM;QACJ,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IAED,sCAAsC;IACtC,OAAO;QACL,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;YAC3B,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACrD,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC1B,CAAC;IAED,qDAAqD;IACrD,MAAM,CAAC,IAAgD;QACrD,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM;YACxB,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QAC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E,EAAE,EAAE,CAAC;CACrE;AAED,YAAY,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;AAC1C,YAAY,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;AACpC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAClC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AAChC,YAAY,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC;AAC5C,YAAY,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../agent/view.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,137 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // Agent Office — views for ai.pool, ai.agent, ai.approval, ai.thread
3
+ import { MetatronConfig } from '#metatron/types';
4
+ import { getComponent, register } from '@treenity/core';
5
+ import { Render, RenderContext } from '@treenity/react/context';
6
+ import { execute, useChildren, useNavigate, usePath } from '@treenity/react/hooks';
7
+ import { minimd } from '@treenity/react/lib/minimd';
8
+ import { cn } from '@treenity/react/lib/utils';
9
+ import { useMemo, useState } from 'react';
10
+ import { AiApproval } from './guardian';
11
+ import { AiAgent, AiApprovals, AiPlan, AiPool, AiThread } from './types';
12
+ const AGENT_STATUS = {
13
+ idle: { bg: 'bg-emerald-500/10', text: 'text-emerald-400', dot: 'bg-emerald-400', label: 'idle' },
14
+ working: { bg: 'bg-sky-500/10', text: 'text-sky-400', dot: 'bg-sky-400 animate-pulse', label: 'working' },
15
+ blocked: { bg: 'bg-amber-500/10', text: 'text-amber-400', dot: 'bg-amber-400', label: 'blocked' },
16
+ error: { bg: 'bg-red-500/10', text: 'text-red-400', dot: 'bg-red-400', label: 'error' },
17
+ offline: { bg: 'bg-zinc-700/20', text: 'text-zinc-500', dot: 'bg-zinc-600', label: 'offline' },
18
+ };
19
+ const APPROVAL_STATUS = {
20
+ pending: { bg: 'bg-amber-500/10', text: 'text-amber-400', border: 'border-amber-500/30' },
21
+ approved: { bg: 'bg-emerald-500/10', text: 'text-emerald-400', border: 'border-emerald-500/30' },
22
+ denied: { bg: 'bg-red-500/10', text: 'text-red-400', border: 'border-red-500/30' },
23
+ };
24
+ function timeAgo(ts) {
25
+ if (!ts)
26
+ return '';
27
+ const d = Date.now() - ts;
28
+ if (d < 60_000)
29
+ return 'just now';
30
+ if (d < 3600_000)
31
+ return `${Math.floor(d / 60_000)}m ago`;
32
+ if (d < 86400_000)
33
+ return `${Math.floor(d / 3600_000)}h ago`;
34
+ return new Date(ts).toLocaleDateString('en', { month: 'short', day: 'numeric' });
35
+ }
36
+ function statusStyle(status) {
37
+ return AGENT_STATUS[status] ?? AGENT_STATUS.offline;
38
+ }
39
+ function StatusDot({ status }) {
40
+ return _jsx("span", { className: cn('inline-block w-2 h-2 rounded-full', statusStyle(status).dot) });
41
+ }
42
+ // ── PoolView (ai.pool — dashboard) ──
43
+ const PoolView = ({ value, ctx }) => {
44
+ const path = ctx.node.$path;
45
+ const agents = useChildren(path);
46
+ const approvals = useChildren(path + '/approvals');
47
+ const agentNodes = (agents ?? []).filter(n => n.$type === 'ai.agent');
48
+ const approvalNodes = (approvals ?? []).filter(n => n.$type === 'ai.approval');
49
+ const pendingApprovals = approvalNodes.filter(n => n.status === 'pending');
50
+ const activeCount = value.active?.length ?? 0;
51
+ const queueCount = value.queue?.length ?? 0;
52
+ const maxC = value.maxConcurrent ?? 2;
53
+ return (_jsxs("div", { className: "flex flex-col gap-6 p-5 max-w-3xl", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { children: [_jsx("h2", { className: "text-lg font-semibold text-zinc-100 tracking-tight", children: "Agent Office" }), _jsxs("p", { className: "text-xs text-zinc-500 mt-0.5 font-mono", children: [activeCount, "/", maxC, " active \u00B7 ", queueCount, " queued"] })] }), _jsx("div", { className: "flex gap-1", children: Array.from({ length: maxC }, (_, i) => (_jsx("div", { className: cn('w-3 h-8 rounded-sm transition-colors duration-300', i < activeCount ? 'bg-sky-500/60' : 'bg-zinc-800') }, i))) })] }), pendingApprovals.length > 0 && (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsxs("h3", { className: "text-[11px] font-medium text-amber-400 uppercase tracking-wider", children: ["Pending Approvals (", pendingApprovals.length, ")"] }), pendingApprovals.map((a) => (_jsx(Render, { value: a }, a.$path)))] })), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsxs("h3", { className: "text-[11px] font-medium text-zinc-500 uppercase tracking-wider", children: ["Agents (", agentNodes.length, ")"] }), _jsx(RenderContext, { name: "react:list", children: agentNodes.map((agent) => (_jsx(Render, { value: agent }, agent.$path))) }), agentNodes.length === 0 && (_jsx("p", { className: "text-sm text-zinc-600 italic", children: "No agents registered" }))] })] }));
54
+ };
55
+ // ── AgentRow (compact card — react:list context) ──
56
+ const AgentRow = ({ value, ctx }) => {
57
+ const nav = useNavigate();
58
+ const status = value.status || 'offline';
59
+ const s = statusStyle(status);
60
+ return (_jsxs("button", { onClick: () => nav(ctx.node.$path), className: cn('flex items-center gap-3 px-3.5 py-2.5 rounded-lg border transition-all duration-150', 'border-zinc-800/60 hover:border-zinc-700 hover:bg-zinc-800/30', 'text-left w-full group'), children: [_jsx(StatusDot, { status: status }), _jsxs("div", { className: "flex-1 min-w-0", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-sm font-medium text-zinc-200 truncate", children: ctx.node.$path.split('/').at(-1) }), _jsx("span", { className: cn('text-[10px] font-mono px-1.5 py-0.5 rounded', s.bg, s.text), children: value.role })] }), status === 'working' && value.currentTask && (_jsxs("p", { className: "text-[11px] text-zinc-500 truncate mt-0.5 font-mono", children: ["\u2192 ", value.currentTask] }))] }), _jsxs("div", { className: "flex items-center gap-3 text-[11px] text-zinc-600", children: [value.totalTokens > 0 && (_jsxs("span", { className: "font-mono", children: [(value.totalTokens / 100000).toFixed(2), "$"] })), value.lastRunAt > 0 && _jsx("span", { children: timeAgo(value.lastRunAt) })] }), _jsx("span", { className: "text-zinc-700 group-hover:text-zinc-500 transition-colors", children: "\u203A" })] }));
61
+ };
62
+ // ── AgentView (ai.agent detail) ──
63
+ const AgentView = ({ value, ctx }) => {
64
+ const path = ctx.node.$path;
65
+ const status = value.status || 'offline';
66
+ const s = statusStyle(status);
67
+ const config = getComponent(ctx.node, MetatronConfig);
68
+ const mtTask = usePath(value.taskRef || null);
69
+ return (_jsxs("div", { className: "flex flex-col gap-5 p-5 max-w-2xl", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(StatusDot, { status: status }), _jsx("h2", { className: "text-lg font-semibold text-zinc-100", children: path.split('/').at(-1) }), _jsx("span", { className: cn('text-xs font-mono px-2 py-0.5 rounded', s.bg, s.text), children: s.label })] }), _jsxs("div", { className: "grid grid-cols-2 gap-3", children: [_jsx(InfoCell, { label: "Role", value: value.role }), _jsx(InfoCell, { label: "Model", value: config?.model || '—', mono: true }), _jsx(InfoCell, { label: "Last Run", value: value.lastRunAt ? timeAgo(value.lastRunAt) : 'never' }), _jsx(InfoCell, { label: "Tokens", value: value.totalTokens > 0 ? `$${(value.totalTokens / 100000).toFixed(3)}` : '—', mono: true }), value.currentTask && _jsx(InfoCell, { label: "Current Task", value: value.currentTask, mono: true, span2: true })] }), config?.systemPrompt && (_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("span", { className: "text-[11px] font-medium text-zinc-500 uppercase tracking-wider", children: "System Prompt" }), _jsx("pre", { className: "text-xs text-zinc-400 bg-zinc-900/50 border border-zinc-800 rounded-lg p-3 whitespace-pre-wrap leading-relaxed max-h-48 overflow-y-auto", children: config.systemPrompt })] })), mtTask && (_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("span", { className: "text-[11px] font-medium text-sky-400 uppercase tracking-wider", children: "Live Task" }), _jsx(Render, { value: mtTask })] })), _jsxs("div", { className: "flex gap-2 pt-2", children: [status === 'offline' && (_jsx(ActionBtn, { label: "Bring Online", color: "emerald", onClick: () => execute(path, 'online') })), status === 'idle' && (_jsx(ActionBtn, { label: "Take Offline", color: "zinc", onClick: () => execute(path, 'offline') })), status === 'error' && (_jsx(ActionBtn, { label: "Bring Online", color: "emerald", onClick: () => execute(path, 'online') }))] })] }));
70
+ };
71
+ function InfoCell({ label, value, mono, span2 }) {
72
+ return (_jsxs("div", { className: cn('bg-zinc-900/40 border border-zinc-800/50 rounded-lg px-3 py-2', span2 && 'col-span-2'), children: [_jsx("span", { className: "text-[10px] text-zinc-600 uppercase tracking-wider block", children: label }), _jsx("span", { className: cn('text-sm text-zinc-300 mt-0.5 block truncate', mono && 'font-mono text-xs'), children: value })] }));
73
+ }
74
+ function ActionBtn({ label, color, onClick }) {
75
+ const colors = {
76
+ emerald: 'bg-emerald-600/20 text-emerald-400 hover:bg-emerald-600/30 border-emerald-500/20',
77
+ zinc: 'bg-zinc-700/30 text-zinc-400 hover:bg-zinc-700/50 border-zinc-600/20',
78
+ red: 'bg-red-600/20 text-red-400 hover:bg-red-600/30 border-red-500/20',
79
+ };
80
+ return (_jsx("button", { onClick: onClick, className: cn('px-3 py-1.5 rounded-lg text-xs font-medium border transition-colors', colors[color] ?? colors.zinc), children: label }));
81
+ }
82
+ // ── ApprovalsView (ai.approvals — container) ──
83
+ const ApprovalsView = ({ value, ctx }) => {
84
+ const children = useChildren(ctx.node.$path, { watch: true, watchNew: true });
85
+ const pending = children.filter(n => n.$type === 'ai.approval' && n.status === 'pending');
86
+ const resolved = children.filter(n => n.$type === 'ai.approval' && n.status !== 'pending');
87
+ return (_jsxs("div", { className: "flex flex-col gap-5 p-5 max-w-3xl", children: [_jsx("h2", { className: "text-lg font-semibold text-zinc-100 tracking-tight", children: "Approvals" }), pending.length > 0 && (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsxs("h3", { className: "text-[11px] font-medium text-amber-400 uppercase tracking-wider", children: ["Pending (", pending.length, ")"] }), pending.map(a => _jsx(Render, { value: a }, a.$path))] })), pending.length === 0 && (_jsx("p", { className: "text-sm text-zinc-600 italic", children: "No pending approvals" })), resolved.length > 0 && (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsxs("h3", { className: "text-[11px] font-medium text-zinc-600 uppercase tracking-wider", children: ["History (", resolved.length, ")"] }), resolved.slice(0, 20).map(a => _jsx(Render, { value: a }, a.$path))] }))] }));
88
+ };
89
+ // ── ApprovalView (ai.approval) ──
90
+ const ApprovalView = ({ value, ctx }) => {
91
+ const path = ctx.node.$path;
92
+ const status = value.status || 'pending';
93
+ const s = APPROVAL_STATUS[status] ?? APPROVAL_STATUS.pending;
94
+ const isPending = status === 'pending';
95
+ return (_jsxs("div", { className: cn('border rounded-lg px-4 py-3 flex flex-col gap-2', s.border, s.bg), children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: cn('text-xs font-medium', s.text), children: status }), _jsx("span", { className: "text-[11px] text-zinc-500 font-mono", children: value.agentRole }), _jsx("span", { className: "text-[11px] text-zinc-600", children: "\u2192" }), _jsx("span", { className: "text-[11px] text-zinc-400 font-mono", children: value.tool })] }), _jsx("span", { className: "text-[10px] text-zinc-600", children: timeAgo(value.createdAt) })] }), value.input && (_jsx("pre", { className: "text-[11px] text-zinc-500 bg-black/20 rounded px-2 py-1 max-h-20 overflow-y-auto whitespace-pre-wrap", children: value.input })), value.reason && _jsx("p", { className: "text-[11px] text-zinc-500 italic", children: value.reason }), isPending && (_jsxs("div", { className: "flex items-center gap-2 pt-1 flex-wrap", children: [_jsx(ActionBtn, { label: "Approve", color: "emerald", onClick: () => execute(path, 'approve') }), _jsx(ActionBtn, { label: "Deny", color: "red", onClick: () => execute(path, 'deny') }), _jsx("span", { className: "text-[10px] text-zinc-700 mx-1", children: "|" }), _jsx(ActionBtn, { label: "Approve + remember (agent)", color: "emerald", onClick: () => execute(path, 'approve', { remember: 'agent' }) }), _jsx(ActionBtn, { label: "Approve + remember (global)", color: "emerald", onClick: () => execute(path, 'approve', { remember: 'global' }) })] }))] }));
96
+ };
97
+ // ── ThreadView (ai.thread — message list) ──
98
+ const ThreadView = ({ value }) => {
99
+ const messages = value?.messages ?? [];
100
+ if (!messages.length) {
101
+ return _jsx("p", { className: "text-sm text-zinc-600 italic p-4", children: "No messages yet" });
102
+ }
103
+ return (_jsx("div", { className: "flex flex-col gap-1 p-4", children: messages.map((msg, i) => (_jsxs("div", { className: "flex gap-2 py-1.5 group", children: [_jsx("span", { className: "text-[11px] font-mono text-sky-500/70 w-16 shrink-0 text-right pt-0.5", children: msg.role }), _jsxs("div", { className: "flex-1 min-w-0", children: [_jsx("p", { className: "text-sm text-zinc-300 leading-relaxed whitespace-pre-wrap", children: msg.text }), _jsxs("span", { className: "text-[10px] text-zinc-700 opacity-0 group-hover:opacity-100 transition-opacity", children: [msg.from, " \u00B7 ", timeAgo(msg.ts)] })] })] }, i))) }));
104
+ };
105
+ // ── PlanView (ai.plan — approve/reject) ──
106
+ const PlanView = ({ value, ctx }) => {
107
+ const [feedback, setFeedback] = useState('');
108
+ const [busy, setBusy] = useState(false);
109
+ const html = useMemo(() => value.text ? minimd(value.text) : '', [value.text]);
110
+ if (!value.text && !value.feedback)
111
+ return null;
112
+ const doAction = async (action) => {
113
+ if (!ctx)
114
+ return;
115
+ setBusy(true);
116
+ try {
117
+ await ctx.execute(action, feedback.trim() ? { feedback: feedback.trim() } : undefined);
118
+ setFeedback('');
119
+ }
120
+ finally {
121
+ setBusy(false);
122
+ }
123
+ };
124
+ if (value.approved) {
125
+ return (_jsxs("div", { className: "rounded-lg border border-emerald-500/30 bg-emerald-500/5 p-3", children: [_jsx("div", { className: "mb-1 text-[11px] font-medium text-emerald-400 uppercase tracking-wider", children: "Plan approved" }), _jsx("div", { className: "minimd max-h-40 overflow-y-auto text-sm text-zinc-300", dangerouslySetInnerHTML: { __html: html } }), value.feedback && (_jsxs("div", { className: "mt-2 border-t border-emerald-500/20 pt-2 text-xs text-zinc-500", children: ["Feedback: ", value.feedback] }))] }));
126
+ }
127
+ return (_jsxs("div", { className: "rounded-lg border border-amber-500/30 bg-amber-500/5 p-3", children: [_jsxs("div", { className: "mb-2 flex items-center justify-between", children: [_jsx("span", { className: "text-[11px] font-medium text-amber-400 uppercase tracking-wider", children: "Plan awaiting approval" }), _jsx("span", { className: "text-[10px] text-zinc-600", children: value.createdAt ? new Date(value.createdAt).toLocaleString() : '' })] }), _jsx("div", { className: "minimd mb-3 max-h-60 overflow-y-auto rounded border border-zinc-800 bg-zinc-900/50 p-2 text-sm text-zinc-300", dangerouslySetInnerHTML: { __html: html } }), value.feedback && (_jsxs("div", { className: "mb-2 rounded border border-red-500/20 bg-red-500/5 px-3 py-2 text-xs text-red-300", children: [_jsx("span", { className: "font-medium text-red-400", children: "Rejection feedback:" }), " ", value.feedback] })), _jsx("textarea", { value: feedback, onChange: e => setFeedback(e.target.value), placeholder: "Feedback / comments (optional)...", className: "mb-2 w-full min-h-16 max-h-32 resize-none rounded border border-zinc-800 bg-zinc-900/50 p-2 text-sm text-zinc-300 placeholder:text-zinc-600 focus:outline-none focus:border-zinc-700" }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(ActionBtn, { label: "Approve Plan", color: "emerald", onClick: () => doAction('approvePlan') }), _jsx(ActionBtn, { label: "Reject", color: "red", onClick: () => doAction('rejectPlan') }), busy && _jsx("span", { className: "text-[10px] text-zinc-600", children: "sending..." })] })] }));
128
+ };
129
+ // ── Register views ──
130
+ register(AiPool, 'react', PoolView);
131
+ register(AiAgent, 'react', AgentView);
132
+ register(AiAgent, 'react:list', AgentRow);
133
+ register(AiApproval, 'react', ApprovalView);
134
+ register(AiApprovals, 'react', ApprovalsView);
135
+ register(AiThread, 'react', ThreadView);
136
+ register(AiPlan, 'react', PlanView);
137
+ //# sourceMappingURL=view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.js","sourceRoot":"","sources":["../../agent/view.tsx"],"names":[],"mappings":";A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+ import { type Server } from 'node:http';
5
+ export type McpGuardianResult = {
6
+ allowed: true;
7
+ } | {
8
+ allowed: false;
9
+ reason: string;
10
+ };
11
+ export declare function checkMcpGuardian(store: Tree, toolName: string, input?: string): Promise<McpGuardianResult>;
12
+ export declare function buildMcpServer(store: Tree, session: Session, claims?: string[]): Promise<McpServer>;
13
+ export declare function extractToken(req: import('node:http').IncomingMessage): string | null;
14
+ /** Create MCP HTTP server. Returns server handle for lifecycle management. */
15
+ export declare function createMcpHttpServer(store: Tree, port: number): Server;
16
+ //# sourceMappingURL=mcp-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../../mcp/mcp-server.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMpE,OAAO,EAA6B,KAAK,OAAO,EAAW,MAAM,4BAA4B,CAAC;AAE9F,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAgBtD,MAAM,MAAM,iBAAiB,GAAG;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAGvF,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAmChH;AAgDD,wBAAsB,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,sBAsNpF;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,WAAW,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,CAUpF;AAED,8EAA8E;AAC9E,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CA6CrE"}