clementine-agent 1.0.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 (190) hide show
  1. package/.env.example +44 -0
  2. package/LICENSE +21 -0
  3. package/README.md +795 -0
  4. package/dist/agent/agent-manager.d.ts +69 -0
  5. package/dist/agent/agent-manager.js +441 -0
  6. package/dist/agent/assistant.d.ts +225 -0
  7. package/dist/agent/assistant.js +3888 -0
  8. package/dist/agent/auto-update.d.ts +32 -0
  9. package/dist/agent/auto-update.js +186 -0
  10. package/dist/agent/daily-planner.d.ts +24 -0
  11. package/dist/agent/daily-planner.js +379 -0
  12. package/dist/agent/execution-advisor.d.ts +10 -0
  13. package/dist/agent/execution-advisor.js +272 -0
  14. package/dist/agent/hooks.d.ts +45 -0
  15. package/dist/agent/hooks.js +564 -0
  16. package/dist/agent/insight-engine.d.ts +66 -0
  17. package/dist/agent/insight-engine.js +225 -0
  18. package/dist/agent/intent-classifier.d.ts +48 -0
  19. package/dist/agent/intent-classifier.js +214 -0
  20. package/dist/agent/link-extractor.d.ts +19 -0
  21. package/dist/agent/link-extractor.js +90 -0
  22. package/dist/agent/mcp-bridge.d.ts +62 -0
  23. package/dist/agent/mcp-bridge.js +435 -0
  24. package/dist/agent/metacognition.d.ts +66 -0
  25. package/dist/agent/metacognition.js +221 -0
  26. package/dist/agent/orchestrator.d.ts +81 -0
  27. package/dist/agent/orchestrator.js +790 -0
  28. package/dist/agent/profiles.d.ts +22 -0
  29. package/dist/agent/profiles.js +91 -0
  30. package/dist/agent/prompt-cache.d.ts +24 -0
  31. package/dist/agent/prompt-cache.js +68 -0
  32. package/dist/agent/prompt-evolver.d.ts +28 -0
  33. package/dist/agent/prompt-evolver.js +279 -0
  34. package/dist/agent/role-scaffolds.d.ts +28 -0
  35. package/dist/agent/role-scaffolds.js +433 -0
  36. package/dist/agent/safe-restart.d.ts +41 -0
  37. package/dist/agent/safe-restart.js +150 -0
  38. package/dist/agent/self-improve.d.ts +66 -0
  39. package/dist/agent/self-improve.js +1706 -0
  40. package/dist/agent/session-event-log.d.ts +114 -0
  41. package/dist/agent/session-event-log.js +233 -0
  42. package/dist/agent/skill-extractor.d.ts +72 -0
  43. package/dist/agent/skill-extractor.js +435 -0
  44. package/dist/agent/source-mods.d.ts +61 -0
  45. package/dist/agent/source-mods.js +230 -0
  46. package/dist/agent/source-preflight.d.ts +25 -0
  47. package/dist/agent/source-preflight.js +100 -0
  48. package/dist/agent/stall-guard.d.ts +62 -0
  49. package/dist/agent/stall-guard.js +109 -0
  50. package/dist/agent/strategic-planner.d.ts +60 -0
  51. package/dist/agent/strategic-planner.js +352 -0
  52. package/dist/agent/team-bus.d.ts +89 -0
  53. package/dist/agent/team-bus.js +556 -0
  54. package/dist/agent/team-router.d.ts +26 -0
  55. package/dist/agent/team-router.js +37 -0
  56. package/dist/agent/tool-loop-detector.d.ts +59 -0
  57. package/dist/agent/tool-loop-detector.js +242 -0
  58. package/dist/agent/workflow-runner.d.ts +36 -0
  59. package/dist/agent/workflow-runner.js +317 -0
  60. package/dist/agent/workflow-variables.d.ts +16 -0
  61. package/dist/agent/workflow-variables.js +62 -0
  62. package/dist/channels/discord-agent-bot.d.ts +101 -0
  63. package/dist/channels/discord-agent-bot.js +881 -0
  64. package/dist/channels/discord-bot-manager.d.ts +80 -0
  65. package/dist/channels/discord-bot-manager.js +262 -0
  66. package/dist/channels/discord-utils.d.ts +51 -0
  67. package/dist/channels/discord-utils.js +293 -0
  68. package/dist/channels/discord.d.ts +12 -0
  69. package/dist/channels/discord.js +1832 -0
  70. package/dist/channels/slack-agent-bot.d.ts +73 -0
  71. package/dist/channels/slack-agent-bot.js +320 -0
  72. package/dist/channels/slack-bot-manager.d.ts +66 -0
  73. package/dist/channels/slack-bot-manager.js +236 -0
  74. package/dist/channels/slack-utils.d.ts +39 -0
  75. package/dist/channels/slack-utils.js +189 -0
  76. package/dist/channels/slack.d.ts +11 -0
  77. package/dist/channels/slack.js +196 -0
  78. package/dist/channels/telegram.d.ts +10 -0
  79. package/dist/channels/telegram.js +235 -0
  80. package/dist/channels/webhook.d.ts +9 -0
  81. package/dist/channels/webhook.js +78 -0
  82. package/dist/channels/whatsapp.d.ts +11 -0
  83. package/dist/channels/whatsapp.js +181 -0
  84. package/dist/cli/chat.d.ts +14 -0
  85. package/dist/cli/chat.js +220 -0
  86. package/dist/cli/cron.d.ts +17 -0
  87. package/dist/cli/cron.js +552 -0
  88. package/dist/cli/dashboard.d.ts +15 -0
  89. package/dist/cli/dashboard.js +17677 -0
  90. package/dist/cli/index.d.ts +3 -0
  91. package/dist/cli/index.js +2474 -0
  92. package/dist/cli/routes/delegations.d.ts +19 -0
  93. package/dist/cli/routes/delegations.js +154 -0
  94. package/dist/cli/routes/digest.d.ts +17 -0
  95. package/dist/cli/routes/digest.js +375 -0
  96. package/dist/cli/routes/goals.d.ts +14 -0
  97. package/dist/cli/routes/goals.js +258 -0
  98. package/dist/cli/routes/workflows.d.ts +18 -0
  99. package/dist/cli/routes/workflows.js +97 -0
  100. package/dist/cli/setup.d.ts +8 -0
  101. package/dist/cli/setup.js +619 -0
  102. package/dist/cli/tunnel.d.ts +35 -0
  103. package/dist/cli/tunnel.js +141 -0
  104. package/dist/config.d.ts +145 -0
  105. package/dist/config.js +278 -0
  106. package/dist/events/bus.d.ts +43 -0
  107. package/dist/events/bus.js +136 -0
  108. package/dist/gateway/cron-scheduler.d.ts +166 -0
  109. package/dist/gateway/cron-scheduler.js +1767 -0
  110. package/dist/gateway/delivery-queue.d.ts +30 -0
  111. package/dist/gateway/delivery-queue.js +110 -0
  112. package/dist/gateway/heartbeat-scheduler.d.ts +99 -0
  113. package/dist/gateway/heartbeat-scheduler.js +1298 -0
  114. package/dist/gateway/heartbeat.d.ts +3 -0
  115. package/dist/gateway/heartbeat.js +3 -0
  116. package/dist/gateway/lanes.d.ts +24 -0
  117. package/dist/gateway/lanes.js +76 -0
  118. package/dist/gateway/notifications.d.ts +29 -0
  119. package/dist/gateway/notifications.js +75 -0
  120. package/dist/gateway/router.d.ts +210 -0
  121. package/dist/gateway/router.js +1330 -0
  122. package/dist/index.d.ts +12 -0
  123. package/dist/index.js +1015 -0
  124. package/dist/memory/chunker.d.ts +28 -0
  125. package/dist/memory/chunker.js +226 -0
  126. package/dist/memory/consolidation.d.ts +44 -0
  127. package/dist/memory/consolidation.js +171 -0
  128. package/dist/memory/context-assembler.d.ts +50 -0
  129. package/dist/memory/context-assembler.js +149 -0
  130. package/dist/memory/embeddings.d.ts +38 -0
  131. package/dist/memory/embeddings.js +180 -0
  132. package/dist/memory/graph-store.d.ts +66 -0
  133. package/dist/memory/graph-store.js +613 -0
  134. package/dist/memory/mmr.d.ts +21 -0
  135. package/dist/memory/mmr.js +75 -0
  136. package/dist/memory/search.d.ts +26 -0
  137. package/dist/memory/search.js +67 -0
  138. package/dist/memory/store.d.ts +530 -0
  139. package/dist/memory/store.js +2022 -0
  140. package/dist/security/integrity.d.ts +24 -0
  141. package/dist/security/integrity.js +58 -0
  142. package/dist/security/patterns.d.ts +34 -0
  143. package/dist/security/patterns.js +110 -0
  144. package/dist/security/scanner.d.ts +32 -0
  145. package/dist/security/scanner.js +263 -0
  146. package/dist/tools/admin-tools.d.ts +12 -0
  147. package/dist/tools/admin-tools.js +1278 -0
  148. package/dist/tools/external-tools.d.ts +11 -0
  149. package/dist/tools/external-tools.js +1327 -0
  150. package/dist/tools/goal-tools.d.ts +9 -0
  151. package/dist/tools/goal-tools.js +159 -0
  152. package/dist/tools/mcp-server.d.ts +13 -0
  153. package/dist/tools/mcp-server.js +141 -0
  154. package/dist/tools/memory-tools.d.ts +10 -0
  155. package/dist/tools/memory-tools.js +568 -0
  156. package/dist/tools/session-tools.d.ts +6 -0
  157. package/dist/tools/session-tools.js +146 -0
  158. package/dist/tools/shared.d.ts +216 -0
  159. package/dist/tools/shared.js +340 -0
  160. package/dist/tools/team-tools.d.ts +6 -0
  161. package/dist/tools/team-tools.js +447 -0
  162. package/dist/tools/tool-meta.d.ts +34 -0
  163. package/dist/tools/tool-meta.js +133 -0
  164. package/dist/tools/vault-tools.d.ts +8 -0
  165. package/dist/tools/vault-tools.js +457 -0
  166. package/dist/types.d.ts +716 -0
  167. package/dist/types.js +16 -0
  168. package/dist/vault-migrations/0001-add-execution-framework.d.ts +10 -0
  169. package/dist/vault-migrations/0001-add-execution-framework.js +47 -0
  170. package/dist/vault-migrations/0002-add-agentic-communication.d.ts +12 -0
  171. package/dist/vault-migrations/0002-add-agentic-communication.js +79 -0
  172. package/dist/vault-migrations/0003-update-execution-pipeline-narration.d.ts +11 -0
  173. package/dist/vault-migrations/0003-update-execution-pipeline-narration.js +73 -0
  174. package/dist/vault-migrations/helpers.d.ts +14 -0
  175. package/dist/vault-migrations/helpers.js +44 -0
  176. package/dist/vault-migrations/runner.d.ts +14 -0
  177. package/dist/vault-migrations/runner.js +139 -0
  178. package/dist/vault-migrations/types.d.ts +42 -0
  179. package/dist/vault-migrations/types.js +9 -0
  180. package/install.sh +320 -0
  181. package/package.json +84 -0
  182. package/scripts/postinstall.js +125 -0
  183. package/vault/00-System/AGENTS.md +66 -0
  184. package/vault/00-System/CRON.md +71 -0
  185. package/vault/00-System/HEARTBEAT.md +58 -0
  186. package/vault/00-System/MEMORY.md +16 -0
  187. package/vault/00-System/SOUL.md +96 -0
  188. package/vault/05-Tasks/TASKS.md +19 -0
  189. package/vault/06-Templates/_Daily-Template.md +28 -0
  190. package/vault/06-Templates/_People-Template.md +22 -0
@@ -0,0 +1,3 @@
1
+ export { HeartbeatScheduler } from './heartbeat-scheduler.js';
2
+ export { CronScheduler, CronRunLog, parseCronJobs, parseAgentCronJobs, validateCronYaml, classifyError, logToDailyNote } from './cron-scheduler.js';
3
+ //# sourceMappingURL=heartbeat.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { HeartbeatScheduler } from './heartbeat-scheduler.js';
2
+ export { CronScheduler, CronRunLog, parseCronJobs, parseAgentCronJobs, validateCronYaml, classifyError, logToDailyNote } from './cron-scheduler.js';
3
+ //# sourceMappingURL=heartbeat.js.map
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Clementine TypeScript — Lane-based concurrency control.
3
+ *
4
+ * Separates work into independent concurrency pools so cron jobs
5
+ * can't starve chat responses and vice versa.
6
+ */
7
+ export type Lane = 'chat' | 'cron' | 'heartbeat' | 'self-improve' | 'team';
8
+ declare class LaneController {
9
+ private limits;
10
+ private active;
11
+ private waiters;
12
+ /** Acquire a slot in a lane. Resolves when a slot is available. */
13
+ acquire(lane: Lane): Promise<() => void>;
14
+ /** Get current lane utilization for monitoring. */
15
+ status(): Record<Lane, {
16
+ active: number;
17
+ limit: number;
18
+ queued: number;
19
+ }>;
20
+ private createRelease;
21
+ }
22
+ export declare const lanes: LaneController;
23
+ export {};
24
+ //# sourceMappingURL=lanes.d.ts.map
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Clementine TypeScript — Lane-based concurrency control.
3
+ *
4
+ * Separates work into independent concurrency pools so cron jobs
5
+ * can't starve chat responses and vice versa.
6
+ */
7
+ import pino from 'pino';
8
+ const logger = pino({ name: 'clementine.lanes' });
9
+ class LaneController {
10
+ limits = {
11
+ chat: 3, // Up to 3 concurrent chat sessions
12
+ cron: 2, // Up to 2 concurrent cron jobs
13
+ heartbeat: 1, // Only 1 heartbeat at a time
14
+ 'self-improve': 1, // Only 1 self-improvement cycle at a time
15
+ team: 2, // Up to 2 concurrent inter-agent messages
16
+ };
17
+ active = {
18
+ chat: 0,
19
+ cron: 0,
20
+ heartbeat: 0,
21
+ 'self-improve': 0,
22
+ team: 0,
23
+ };
24
+ waiters = {
25
+ chat: [],
26
+ cron: [],
27
+ heartbeat: [],
28
+ 'self-improve': [],
29
+ team: [],
30
+ };
31
+ /** Acquire a slot in a lane. Resolves when a slot is available. */
32
+ async acquire(lane) {
33
+ if (this.active[lane] < this.limits[lane]) {
34
+ this.active[lane]++;
35
+ logger.debug({ lane, active: this.active[lane], limit: this.limits[lane] }, 'Lane slot acquired');
36
+ return this.createRelease(lane);
37
+ }
38
+ // Lane is full — queue a waiter
39
+ logger.info({ lane, active: this.active[lane], limit: this.limits[lane], queued: this.waiters[lane].length }, 'Lane full — queuing');
40
+ await new Promise((resolve) => {
41
+ this.waiters[lane].push(resolve);
42
+ });
43
+ // Slot was handed to us by a release — already incremented
44
+ return this.createRelease(lane);
45
+ }
46
+ /** Get current lane utilization for monitoring. */
47
+ status() {
48
+ return {
49
+ chat: { active: this.active.chat, limit: this.limits.chat, queued: this.waiters.chat.length },
50
+ cron: { active: this.active.cron, limit: this.limits.cron, queued: this.waiters.cron.length },
51
+ heartbeat: { active: this.active.heartbeat, limit: this.limits.heartbeat, queued: this.waiters.heartbeat.length },
52
+ 'self-improve': { active: this.active['self-improve'], limit: this.limits['self-improve'], queued: this.waiters['self-improve'].length },
53
+ team: { active: this.active.team, limit: this.limits.team, queued: this.waiters.team.length },
54
+ };
55
+ }
56
+ createRelease(lane) {
57
+ let released = false;
58
+ return () => {
59
+ if (released)
60
+ return; // guard against double-release
61
+ released = true;
62
+ const next = this.waiters[lane].shift();
63
+ if (next) {
64
+ // Hand the slot directly to the next waiter (active count stays the same)
65
+ logger.debug({ lane, queued: this.waiters[lane].length }, 'Lane slot handed to next waiter');
66
+ next();
67
+ }
68
+ else {
69
+ this.active[lane]--;
70
+ logger.debug({ lane, active: this.active[lane] }, 'Lane slot released');
71
+ }
72
+ };
73
+ }
74
+ }
75
+ export const lanes = new LaneController();
76
+ //# sourceMappingURL=lanes.js.map
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Clementine TypeScript — Notification dispatcher.
3
+ *
4
+ * Decouples heartbeat/cron DM sending from any specific channel.
5
+ * Each channel adapter registers a sender function on startup;
6
+ * the dispatcher fans out notifications to all registered channels.
7
+ */
8
+ import type { NotificationSender, NotificationContext } from '../types.js';
9
+ export interface SendResult {
10
+ delivered: boolean;
11
+ channelErrors: Record<string, string>;
12
+ }
13
+ export declare class NotificationDispatcher {
14
+ private senders;
15
+ private _retryQueue;
16
+ constructor();
17
+ register(channelName: string, senderFn: NotificationSender): void;
18
+ unregister(channelName: string): void;
19
+ get hasChannels(): boolean;
20
+ /** Get the retry queue size (for dashboard status). */
21
+ get pendingRetries(): number;
22
+ /** Send a notification; automatically queues for retry on total failure. */
23
+ send(text: string, context?: NotificationContext): Promise<SendResult>;
24
+ /** Direct send without retry queueing (used by retry queue itself). */
25
+ private sendDirect;
26
+ /** Stop the retry queue timer (for graceful shutdown). */
27
+ shutdown(): void;
28
+ }
29
+ //# sourceMappingURL=notifications.d.ts.map
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Clementine TypeScript — Notification dispatcher.
3
+ *
4
+ * Decouples heartbeat/cron DM sending from any specific channel.
5
+ * Each channel adapter registers a sender function on startup;
6
+ * the dispatcher fans out notifications to all registered channels.
7
+ */
8
+ import pino from 'pino';
9
+ import { DeliveryQueue } from './delivery-queue.js';
10
+ const logger = pino({ name: 'clementine.notifications' });
11
+ /** Safety cap — prevent runaway messages, but each channel handles its own chunking/limits. */
12
+ const MAX_MESSAGE_LENGTH = 8000;
13
+ export class NotificationDispatcher {
14
+ senders = new Map();
15
+ _retryQueue;
16
+ constructor() {
17
+ this._retryQueue = new DeliveryQueue();
18
+ this._retryQueue.setSender((text, ctx) => this.sendDirect(text, ctx));
19
+ this._retryQueue.start();
20
+ }
21
+ register(channelName, senderFn) {
22
+ this.senders.set(channelName, senderFn);
23
+ logger.info(`Notification sender registered: ${channelName}`);
24
+ }
25
+ unregister(channelName) {
26
+ this.senders.delete(channelName);
27
+ logger.info(`Notification sender unregistered: ${channelName}`);
28
+ }
29
+ get hasChannels() {
30
+ return this.senders.size > 0;
31
+ }
32
+ /** Get the retry queue size (for dashboard status). */
33
+ get pendingRetries() {
34
+ return this._retryQueue.size;
35
+ }
36
+ /** Send a notification; automatically queues for retry on total failure. */
37
+ async send(text, context) {
38
+ const result = await this.sendDirect(text, context);
39
+ // If delivery failed and there were actual senders (not "no channels"), queue for retry
40
+ if (!result.delivered && this.senders.size > 0) {
41
+ this._retryQueue.enqueue(text, context);
42
+ }
43
+ return result;
44
+ }
45
+ /** Direct send without retry queueing (used by retry queue itself). */
46
+ async sendDirect(text, context) {
47
+ if (this.senders.size === 0) {
48
+ logger.warn('No notification senders registered — message dropped');
49
+ return { delivered: false, channelErrors: { _: 'no channels registered' } };
50
+ }
51
+ // Sanity cap only — each channel sender handles its own chunking/truncation
52
+ const capped = text.length > MAX_MESSAGE_LENGTH
53
+ ? text.slice(0, MAX_MESSAGE_LENGTH - 20) + '\n\n_(truncated)_'
54
+ : text;
55
+ const channelErrors = {};
56
+ let anySuccess = false;
57
+ for (const [name, sender] of this.senders) {
58
+ try {
59
+ await sender(capped, context);
60
+ anySuccess = true;
61
+ }
62
+ catch (err) {
63
+ const errMsg = String(err).slice(0, 200);
64
+ channelErrors[name] = errMsg;
65
+ logger.error({ err, channel: name }, `Failed to send notification via ${name}`);
66
+ }
67
+ }
68
+ return { delivered: anySuccess, channelErrors };
69
+ }
70
+ /** Stop the retry queue timer (for graceful shutdown). */
71
+ shutdown() {
72
+ this._retryQueue.stop();
73
+ }
74
+ }
75
+ //# sourceMappingURL=notifications.js.map
@@ -0,0 +1,210 @@
1
+ /**
2
+ * Clementine TypeScript — Gateway router and session management.
3
+ *
4
+ * Routes messages between channel adapters and the agent layer.
5
+ * Manages per-user/channel sessions for conversation continuity.
6
+ */
7
+ import { PersonalAssistant, type ProjectMeta } from '../agent/assistant.js';
8
+ import type { OnTextCallback, OnToolActivityCallback, PlanProgressUpdate, PlanStep, SelfImproveConfig, SelfImproveExperiment, SessionProvenance, TeamMessage, VerboseLevel, WorkflowDefinition } from '../types.js';
9
+ import { AgentManager } from '../agent/agent-manager.js';
10
+ import { TeamRouter } from '../agent/team-router.js';
11
+ import { TeamBus } from '../agent/team-bus.js';
12
+ import type { NotificationDispatcher } from './notifications.js';
13
+ export type ChatErrorKind = 'rate_limit' | 'context_overflow' | 'auth' | 'transient' | 'unknown';
14
+ export declare function classifyChatError(err: unknown): ChatErrorKind;
15
+ /** Detect auth-like errors in response text that the SDK returned as "successful" results. */
16
+ export declare function looksLikeAuthError(text: string): boolean;
17
+ export declare class Gateway {
18
+ readonly assistant: PersonalAssistant;
19
+ /** Resolvers for pending approvals. `true` = approved, `false` = denied, `string` = revision feedback. */
20
+ private approvalResolvers;
21
+ private approvalCounter;
22
+ private sessions;
23
+ private auditLog;
24
+ private draining;
25
+ /** Persisted set of channel keys the owner has approved. Loaded lazily. */
26
+ private seenChannels;
27
+ private _authFailCount;
28
+ private _authFailSince;
29
+ private _authLastProbe;
30
+ private static readonly AUTH_FAIL_THRESHOLD;
31
+ private static readonly AUTH_PROBE_INTERVAL;
32
+ /** Returns true if the auth circuit is open (too many consecutive auth failures). */
33
+ get authCircuitOpen(): boolean;
34
+ /** Record an auth failure. On first crossing the threshold, notify the owner proactively. */
35
+ recordAuthFailure(): void;
36
+ /** Clear the auth circuit after a successful request. */
37
+ clearAuthFailure(): void;
38
+ /** Check if enough time has passed to allow an auth probe (one message let through). */
39
+ shouldProbeAuth(): boolean;
40
+ private _dispatcher?;
41
+ /** Register the notification dispatcher so deep mode / auto-escalation results can be pushed to channels. */
42
+ setDispatcher(d: NotificationDispatcher): void;
43
+ /** Derive a stable "channel key" from a session key (strips the per-user suffix). */
44
+ static channelKey(sessionKey: string): string | null;
45
+ private _loadSeenChannels;
46
+ private _saveSeenChannels;
47
+ /** Mark a channel as seen (owner approved or explicitly always-allowed). */
48
+ markChannelSeen(channelKey: string): void;
49
+ /**
50
+ * Deliver a deep-mode result back to the user.
51
+ * Routes through the agent's session so it responds conversationally,
52
+ * then pushes the agent's reply via the dispatcher so it actually reaches the channel.
53
+ * Falls back to pushing rawResult directly if the agent call fails.
54
+ */
55
+ private _deliverDeepResult;
56
+ private _agentManager?;
57
+ private _teamRouter?;
58
+ private _teamBus?;
59
+ private _botManager?;
60
+ private _slackBotManager?;
61
+ constructor(assistant: PersonalAssistant);
62
+ /** Get or create a session state entry. */
63
+ private getSession;
64
+ getAgentManager(): AgentManager;
65
+ getTeamRouter(): TeamRouter;
66
+ getTeamBus(): TeamBus;
67
+ /** Register the BotManager so TeamBus can resolve agent bot channels for delivery. */
68
+ setBotManager(botManager: import('../channels/discord-bot-manager.js').BotManager): void;
69
+ /** Register the SlackBotManager so TeamBus can resolve Slack agent channels for delivery. */
70
+ setSlackBotManager(slackBotManager: import('../channels/slack-bot-manager.js').SlackBotManager): void;
71
+ /** Route an inter-agent message through the team bus. */
72
+ handleTeamMessage(fromSlug: string, toSlug: string, content: string, depth?: number): Promise<TeamMessage>;
73
+ /**
74
+ * Register provenance for a session. Write-once: once set, spawnedBy,
75
+ * spawnDepth, role, and controlScope are immutable (prevents re-parenting
76
+ * or privilege escalation).
77
+ */
78
+ setProvenance(sessionKey: string, provenance: SessionProvenance): void;
79
+ getProvenance(sessionKey: string): SessionProvenance | undefined;
80
+ /**
81
+ * Create provenance from a session key using naming conventions.
82
+ * Called automatically on first message if no provenance exists.
83
+ */
84
+ private ensureProvenance;
85
+ /**
86
+ * Verify that a session is allowed to control (kill/steer) a target session.
87
+ * A session can only control sessions it directly spawned.
88
+ */
89
+ canControl(controllerKey: string, targetKey: string): boolean;
90
+ /** Derive provenance from session key naming conventions. */
91
+ static inferProvenance(sessionKey: string): SessionProvenance;
92
+ /**
93
+ * Create provenance for a spawned sub-session (e.g., !plan worker).
94
+ * Enforces depth limits and inherits source from parent.
95
+ */
96
+ spawnChildProvenance(parentKey: string, childKey: string, role?: 'orchestrator' | 'worker', maxDepth?: number): SessionProvenance | null;
97
+ setDraining(value: boolean): void;
98
+ isDraining(): boolean;
99
+ setUnleashedCompleteCallback(cb: (jobName: string, result: string) => void): void;
100
+ setPhaseCompleteCallback(cb: (jobName: string, phase: number, totalPhases: number, output: string) => void): void;
101
+ setPhaseProgressCallback(cb: (jobName: string, phase: number, summary: string) => void): void;
102
+ /** Wire the skill-proposed notification — called once at startup so new skills surface to owner. */
103
+ initSkillNotifications(): void;
104
+ handleSkill(action: string, args?: {
105
+ name?: string;
106
+ }): Promise<string>;
107
+ setSessionVerboseLevel(sessionKey: string, level: VerboseLevel): void;
108
+ getSessionVerboseLevel(sessionKey: string): VerboseLevel | undefined;
109
+ setSessionModel(sessionKey: string, modelId: string): void;
110
+ getSessionModel(sessionKey: string): string | undefined;
111
+ setSessionProject(sessionKey: string, project: ProjectMeta): void;
112
+ getSessionProject(sessionKey: string): ProjectMeta | undefined;
113
+ clearSessionProject(sessionKey: string): void;
114
+ setSessionProfile(sessionKey: string, slug: string): void;
115
+ getSessionProfile(sessionKey: string): string | undefined;
116
+ clearSessionProfile(sessionKey: string): void;
117
+ isSessionBusy(sessionKey: string): boolean;
118
+ /**
119
+ * Abort an in-progress chat query for a session.
120
+ * Returns true if there was an active query to abort.
121
+ */
122
+ stopSession(sessionKey: string): boolean;
123
+ /**
124
+ * Serialize access to a session. Returns a function to call when done,
125
+ * or waits for the current holder to finish first.
126
+ */
127
+ private acquireSessionLock;
128
+ handleMessage(sessionKey: string, text: string, onText?: OnTextCallback, model?: string, maxTurns?: number, onToolActivity?: OnToolActivityCallback): Promise<string>;
129
+ handleHeartbeat(standingInstructions: string, changesSummary?: string, timeContext?: string, dedupContext?: string, profile?: import('../types.js').AgentProfile | null): Promise<string>;
130
+ handleCronJob(jobName: string, jobPrompt: string, tier?: number, maxTurns?: number, model?: string, workDir?: string, mode?: 'standard' | 'unleashed', maxHours?: number, timeoutMs?: number, successCriteria?: string[]): Promise<string>;
131
+ /**
132
+ * Process a team message as an autonomous task — same multi-phase execution
133
+ * as cron unleashed jobs, so agents can work until done instead of being
134
+ * killed by the 5-minute interactive chat timeout.
135
+ */
136
+ handleTeamTask(fromName: string, fromSlug: string, content: string, profile: import('../types.js').AgentProfile, onText?: (token: string) => void): Promise<string>;
137
+ handlePlan(sessionKey: string, taskDescription: string, onProgress?: (updates: PlanProgressUpdate[]) => Promise<void>, onApproval?: (planSummary: string, steps: PlanStep[]) => Promise<boolean | string>): Promise<string>;
138
+ handleWorkflow(workflow: WorkflowDefinition, inputs?: Record<string, string>): Promise<string>;
139
+ /**
140
+ * Inject a command/response exchange into a session so follow-up
141
+ * conversation has context (e.g. cron output shown in DM).
142
+ */
143
+ injectContext(sessionKey: string, userText: string, assistantText: string): void;
144
+ /**
145
+ * Get recent transcript activity across all sessions.
146
+ * Used by heartbeat to know what happened since the last check.
147
+ */
148
+ getRecentActivity(sinceIso: string): Array<{
149
+ sessionKey: string;
150
+ role: string;
151
+ content: string;
152
+ createdAt: string;
153
+ }>;
154
+ /**
155
+ * Search memory (FTS5) for context relevant to a query.
156
+ * Used by heartbeat to enrich goal summaries with recent memory.
157
+ */
158
+ searchMemory(query: string, limit?: number): Array<{
159
+ sourceFile: string;
160
+ section: string;
161
+ content: string;
162
+ score: number;
163
+ }>;
164
+ /**
165
+ * Get the memory store instance for direct operations (consolidation, etc.).
166
+ * Returns null if the store hasn't been initialized yet.
167
+ */
168
+ getMemoryStore(): any;
169
+ /**
170
+ * Get and consume the terminal reason from the last SDK query.
171
+ * Used by the cron scheduler for precise error classification.
172
+ */
173
+ consumeLastTerminalReason(): string | undefined;
174
+ requestApproval(descriptionOrId: string, explicitId?: string): Promise<boolean | string>;
175
+ resolveApproval(requestId: string, result: boolean | string): void;
176
+ getPendingApprovals(): string[];
177
+ addAuditEntry(entry: string): void;
178
+ getAuditEntries(): string[];
179
+ getLaneStatus(): Record<import("./lanes.js").Lane, {
180
+ active: number;
181
+ limit: number;
182
+ queued: number;
183
+ }>;
184
+ getMcpStatus(): {
185
+ servers: Array<{
186
+ name: string;
187
+ status: string;
188
+ }>;
189
+ updatedAt: string;
190
+ };
191
+ getPresenceInfo(sessionKey: string): {
192
+ model: string;
193
+ project: string | null;
194
+ exchanges: number;
195
+ maxExchanges: number;
196
+ memoryCount: number;
197
+ };
198
+ clearSession(sessionKey: string): void;
199
+ /** Evict stale session entries (no activity in 48h, no active lock). */
200
+ evictStaleSessions(): number;
201
+ /** Get all active session provenance entries (for dashboard/monitoring). */
202
+ getAllProvenance(): Map<string, SessionProvenance>;
203
+ handleSelfImprove(action: string, args?: {
204
+ experimentId?: string;
205
+ config?: Partial<SelfImproveConfig>;
206
+ }, onProposal?: (experiment: SelfImproveExperiment) => Promise<void>): Promise<string>;
207
+ /** Extract a procedural skill from a successful cron execution (fire-and-forget). */
208
+ extractCronSkill(jobName: string, prompt: string, output: string, durationMs: number, agentSlug?: string): Promise<void>;
209
+ }
210
+ //# sourceMappingURL=router.d.ts.map