@fenixforce/kernel 0.1.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 (213) hide show
  1. package/dist/agent/execution-result.d.ts +27 -0
  2. package/dist/agent-loop.d.ts +55 -0
  3. package/dist/api/dashboard.d.ts +260 -0
  4. package/dist/api/index.d.ts +9 -0
  5. package/dist/api/middleware.d.ts +46 -0
  6. package/dist/api/openai-compat.d.ts +163 -0
  7. package/dist/api/server.d.ts +44 -0
  8. package/dist/api/streaming.d.ts +15 -0
  9. package/dist/api/webhook-triggers.d.ts +139 -0
  10. package/dist/billing/cost-meter.d.ts +123 -0
  11. package/dist/billing/index.d.ts +2 -0
  12. package/dist/boot.d.ts +109 -0
  13. package/dist/channels/discord.d.ts +99 -0
  14. package/dist/channels/email.d.ts +88 -0
  15. package/dist/channels/http-api.d.ts +155 -0
  16. package/dist/channels/index.d.ts +20 -0
  17. package/dist/channels/mcp-channel.d.ts +75 -0
  18. package/dist/channels/mobile-hil.d.ts +88 -0
  19. package/dist/channels/openai-compat.d.ts +42 -0
  20. package/dist/channels/registry.d.ts +80 -0
  21. package/dist/channels/signal.d.ts +75 -0
  22. package/dist/channels/slack.d.ts +115 -0
  23. package/dist/channels/teams.d.ts +106 -0
  24. package/dist/channels/telegram.d.ts +164 -0
  25. package/dist/channels/types.d.ts +71 -0
  26. package/dist/channels/whatsapp.d.ts +83 -0
  27. package/dist/checkpoint.d.ts +77 -0
  28. package/dist/config/canary.d.ts +74 -0
  29. package/dist/config/constitution.d.ts +57 -0
  30. package/dist/config/defaults.d.ts +17 -0
  31. package/dist/config/index.d.ts +8 -0
  32. package/dist/config/loader.d.ts +11 -0
  33. package/dist/config/provider-config.d.ts +29 -0
  34. package/dist/config/schema.d.ts +118 -0
  35. package/dist/config/steering-rules.d.ts +28 -0
  36. package/dist/content/chunker.d.ts +42 -0
  37. package/dist/content/entity-extractor.d.ts +58 -0
  38. package/dist/content/index.d.ts +8 -0
  39. package/dist/content/ocr.d.ts +79 -0
  40. package/dist/content/pipeline.d.ts +153 -0
  41. package/dist/context-overflow.d.ts +19 -0
  42. package/dist/editions/mobile.d.ts +12 -0
  43. package/dist/editions/pro.d.ts +12 -0
  44. package/dist/editions/voices.d.ts +14 -0
  45. package/dist/events/block-manager.d.ts +37 -0
  46. package/dist/events/bus.d.ts +39 -0
  47. package/dist/events/index.d.ts +8 -0
  48. package/dist/events/session-manager.d.ts +59 -0
  49. package/dist/events/stream-adapter.d.ts +24 -0
  50. package/dist/events/types.d.ts +465 -0
  51. package/dist/events/websocket.d.ts +34 -0
  52. package/dist/extensions/defaults/05-session-repair.d.ts +6 -0
  53. package/dist/extensions/defaults/10-logging.d.ts +6 -0
  54. package/dist/extensions/defaults/15-loop-guard.d.ts +6 -0
  55. package/dist/extensions/defaults/20-cost-tracking.d.ts +7 -0
  56. package/dist/extensions/defaults/25-ssrf-protection.d.ts +6 -0
  57. package/dist/extensions/defaults/30-rate-limiting.d.ts +6 -0
  58. package/dist/extensions/defaults/35-shell-bleed.d.ts +6 -0
  59. package/dist/extensions/defaults/40-observation-capture.d.ts +7 -0
  60. package/dist/extensions/defaults/45-context-survival.d.ts +6 -0
  61. package/dist/extensions/defaults/50-context-budget.d.ts +6 -0
  62. package/dist/extensions/defaults/55-steering-rules.d.ts +7 -0
  63. package/dist/extensions/defaults/60-quality-gates.d.ts +7 -0
  64. package/dist/extensions/defaults/65-job-dispatch.d.ts +24 -0
  65. package/dist/extensions/defaults/70-skill-loader.d.ts +18 -0
  66. package/dist/extensions/hooks.d.ts +74 -0
  67. package/dist/extensions/index.d.ts +21 -0
  68. package/dist/extensions/intervention.d.ts +59 -0
  69. package/dist/extensions/manager.d.ts +63 -0
  70. package/dist/extensions/runner.d.ts +63 -0
  71. package/dist/hooks/hook-manager.d.ts +39 -0
  72. package/dist/hooks/hook-types.d.ts +60 -0
  73. package/dist/identity/assembler.d.ts +45 -0
  74. package/dist/identity/ccc-adapter.d.ts +33 -0
  75. package/dist/identity/index.d.ts +6 -0
  76. package/dist/identity/persona-parser.d.ts +24 -0
  77. package/dist/identity/soul-parser.d.ts +23 -0
  78. package/dist/identity/user-populator.d.ts +20 -0
  79. package/dist/index.d.ts +227 -0
  80. package/dist/index.js +579 -0
  81. package/dist/interrupt.d.ts +84 -0
  82. package/dist/job-queue.d.ts +69 -0
  83. package/dist/jobs/index.d.ts +12 -0
  84. package/dist/jobs/memory-queue.d.ts +23 -0
  85. package/dist/jobs/planned-tasks.d.ts +121 -0
  86. package/dist/jobs/queue.d.ts +79 -0
  87. package/dist/jobs/router.d.ts +23 -0
  88. package/dist/jobs/synthesize-memories.d.ts +26 -0
  89. package/dist/jobs/types.d.ts +47 -0
  90. package/dist/jobs/worker-pool.d.ts +25 -0
  91. package/dist/jobs/worker.d.ts +40 -0
  92. package/dist/loop/autonomous-controller.d.ts +91 -0
  93. package/dist/loop/backpressure.d.ts +64 -0
  94. package/dist/loop/fresh-context.d.ts +48 -0
  95. package/dist/loop/prd-importer.d.ts +134 -0
  96. package/dist/loop/stop-controller.d.ts +31 -0
  97. package/dist/loop-guard.d.ts +32 -0
  98. package/dist/mcp/tool-executor.d.ts +57 -0
  99. package/dist/memory/brain-artifacts.d.ts +25 -0
  100. package/dist/memory/dual-search.d.ts +67 -0
  101. package/dist/memory/episodic.d.ts +45 -0
  102. package/dist/memory/index.d.ts +27 -0
  103. package/dist/memory/knowledge-graph.d.ts +89 -0
  104. package/dist/memory/markdown-store.d.ts +64 -0
  105. package/dist/memory/metadata-filter.d.ts +29 -0
  106. package/dist/memory/mid-conversation-saves.d.ts +17 -0
  107. package/dist/memory/note-parser.d.ts +34 -0
  108. package/dist/memory/observation-store.d.ts +36 -0
  109. package/dist/memory/observation-thresholds.d.ts +26 -0
  110. package/dist/memory/progressive-search.d.ts +25 -0
  111. package/dist/memory/synthesis.d.ts +36 -0
  112. package/dist/memory/tree-index.d.ts +104 -0
  113. package/dist/memory/write-gate.d.ts +63 -0
  114. package/dist/mission-control.d.ts +34 -0
  115. package/dist/pre-classifier-widgets.d.ts +40 -0
  116. package/dist/pre-classifier.d.ts +19 -0
  117. package/dist/prompt/context-budget.d.ts +68 -0
  118. package/dist/prompt/index.d.ts +3 -0
  119. package/dist/prompt/system-prompt.d.ts +32 -0
  120. package/dist/prompt/templates.d.ts +11 -0
  121. package/dist/providers/anthropic.d.ts +24 -0
  122. package/dist/providers/auto-detect.d.ts +16 -0
  123. package/dist/providers/auto-discover.d.ts +28 -0
  124. package/dist/providers/bedrock.d.ts +38 -0
  125. package/dist/providers/cache-strategy.d.ts +58 -0
  126. package/dist/providers/circuit-breaker.d.ts +33 -0
  127. package/dist/providers/cost-meter.d.ts +74 -0
  128. package/dist/providers/cost-tracking.d.ts +36 -0
  129. package/dist/providers/google.d.ts +35 -0
  130. package/dist/providers/index.d.ts +32 -0
  131. package/dist/providers/interface.d.ts +98 -0
  132. package/dist/providers/json-repair.d.ts +10 -0
  133. package/dist/providers/key-rotation.d.ts +36 -0
  134. package/dist/providers/manager.d.ts +64 -0
  135. package/dist/providers/model-registry.d.ts +50 -0
  136. package/dist/providers/openai-compatible.d.ts +26 -0
  137. package/dist/providers/optimization-modes.d.ts +38 -0
  138. package/dist/providers/provider-manager.d.ts +71 -0
  139. package/dist/providers/runtime-crud.d.ts +68 -0
  140. package/dist/providers/sidecar-lifecycle.d.ts +40 -0
  141. package/dist/providers/stream-wrapper.d.ts +21 -0
  142. package/dist/providers/structured-verify.d.ts +31 -0
  143. package/dist/providers/versioning.d.ts +18 -0
  144. package/dist/quality-gates.d.ts +10 -0
  145. package/dist/scheduler/engine.d.ts +95 -0
  146. package/dist/scheduler/index.d.ts +4 -0
  147. package/dist/scheduler/webhook-handler.d.ts +37 -0
  148. package/dist/sdk/agent.d.ts +22 -0
  149. package/dist/sdk/cli.d.ts +2 -0
  150. package/dist/sdk/client.d.ts +19 -0
  151. package/dist/sdk/index.d.ts +24 -0
  152. package/dist/sdk/jobs.d.ts +25 -0
  153. package/dist/sdk/memory.d.ts +18 -0
  154. package/dist/sdk/types.d.ts +69 -0
  155. package/dist/security/approval-gates.d.ts +166 -0
  156. package/dist/security/content-wrapper.d.ts +38 -0
  157. package/dist/security/guard-rails.d.ts +6 -0
  158. package/dist/security/index.d.ts +21 -0
  159. package/dist/security/instruction-hierarchy.d.ts +109 -0
  160. package/dist/security/pii-tokenizer.d.ts +30 -0
  161. package/dist/security/reputation.d.ts +53 -0
  162. package/dist/security/secret-store.d.ts +41 -0
  163. package/dist/security/security-engine.d.ts +53 -0
  164. package/dist/security/shell-bleed.d.ts +15 -0
  165. package/dist/security/ssrf.d.ts +12 -0
  166. package/dist/security/taint-tracker.d.ts +63 -0
  167. package/dist/security/tool-access-control.d.ts +114 -0
  168. package/dist/session-compaction.d.ts +20 -0
  169. package/dist/session-orient.d.ts +22 -0
  170. package/dist/session-repair.d.ts +6 -0
  171. package/dist/storage/index.d.ts +24 -0
  172. package/dist/storage/interface.d.ts +245 -0
  173. package/dist/storage/postgres.d.ts +6 -0
  174. package/dist/storage/sqlite.d.ts +2 -0
  175. package/dist/streaming/reasoning.d.ts +67 -0
  176. package/dist/task-tracker.d.ts +26 -0
  177. package/dist/testing/action-cache.d.ts +39 -0
  178. package/dist/testing/incident-eval.d.ts +49 -0
  179. package/dist/testing/workflow-evals.d.ts +73 -0
  180. package/dist/tools/access-control.d.ts +60 -0
  181. package/dist/tools/browser-engine.d.ts +73 -0
  182. package/dist/tools/builtins/jobs-router.d.ts +7 -0
  183. package/dist/tools/builtins/tasks-router.d.ts +25 -0
  184. package/dist/tools/index.d.ts +20 -0
  185. package/dist/tools/map-reduce.d.ts +64 -0
  186. package/dist/tools/registry.d.ts +39 -0
  187. package/dist/tools/router.d.ts +30 -0
  188. package/dist/tools/routers/browser-router.d.ts +12 -0
  189. package/dist/tools/routers/code-router.d.ts +34 -0
  190. package/dist/tools/routers/file-router.d.ts +35 -0
  191. package/dist/tools/routers/memory-router.d.ts +21 -0
  192. package/dist/tools/routers/schedule-router.d.ts +31 -0
  193. package/dist/tools/routers/search-backends.d.ts +47 -0
  194. package/dist/tools/routers/task-router.d.ts +32 -0
  195. package/dist/tools/routers/web-router.d.ts +36 -0
  196. package/dist/tools/skill-discovery.d.ts +32 -0
  197. package/dist/tools/skill-loader.d.ts +76 -0
  198. package/dist/tools/skill-types.d.ts +21 -0
  199. package/dist/voice/audio-intelligence.d.ts +42 -0
  200. package/dist/voice/barge-in.d.ts +51 -0
  201. package/dist/voice/index.d.ts +22 -0
  202. package/dist/voice/marker-parser.d.ts +31 -0
  203. package/dist/voice/sidecar-manager.d.ts +68 -0
  204. package/dist/voice/speaker-focus.d.ts +41 -0
  205. package/dist/voice/speaker-voiceprint.d.ts +47 -0
  206. package/dist/voice/speech-intent.d.ts +51 -0
  207. package/dist/voice/speechmatics-stt.d.ts +77 -0
  208. package/dist/voice/speechmatics-tts.d.ts +39 -0
  209. package/dist/voice/stt-provider.d.ts +40 -0
  210. package/dist/voice/transcript.d.ts +19 -0
  211. package/dist/voice/turn-detection.d.ts +53 -0
  212. package/dist/wrapup.d.ts +15 -0
  213. package/package.json +39 -0
@@ -0,0 +1,73 @@
1
+ export type ToolExecutor = (input: Record<string, unknown>) => Promise<unknown>;
2
+ export interface MockScenario {
3
+ name: string;
4
+ match: Record<string, unknown>;
5
+ output: unknown;
6
+ }
7
+ export interface ToolDefinition {
8
+ name: string;
9
+ live: ToolExecutor;
10
+ mock?: ToolExecutor;
11
+ mockSchema?: MockScenario[];
12
+ }
13
+ export interface AgentInput {
14
+ prompt: string;
15
+ systemPrompt?: string;
16
+ tools?: string[];
17
+ context?: Record<string, unknown>;
18
+ }
19
+ export interface AgentEvent {
20
+ type: string;
21
+ tool?: string;
22
+ output?: unknown;
23
+ error?: string;
24
+ [key: string]: unknown;
25
+ }
26
+ export interface EvalCase {
27
+ name: string;
28
+ input: AgentInput;
29
+ /** Events that must fire during the run */
30
+ expectedEvents: Partial<AgentEvent>[];
31
+ /** Events that must NOT fire */
32
+ forbiddenEvents?: Partial<AgentEvent>[];
33
+ toolMode: "live" | "mock" | "mixed";
34
+ mockScenario?: string;
35
+ maxTurns: number;
36
+ timeout: number;
37
+ }
38
+ export interface EvalResult {
39
+ caseName: string;
40
+ passed: boolean;
41
+ /** Matched expected events */
42
+ matchedEvents: Partial<AgentEvent>[];
43
+ /** Expected events that were not found */
44
+ missingEvents: Partial<AgentEvent>[];
45
+ /** Forbidden events that were found */
46
+ violatedForbidden: Partial<AgentEvent>[];
47
+ /** All events that occurred */
48
+ actualEvents: AgentEvent[];
49
+ elapsedMs: number;
50
+ error?: string;
51
+ }
52
+ export type AgentRunnerFn = (input: AgentInput, tools: Map<string, ToolExecutor>, maxTurns: number) => Promise<AgentEvent[]>;
53
+ export declare class EvalToolRegistry {
54
+ private tools;
55
+ register(definition: ToolDefinition): void;
56
+ /**
57
+ * Build a tool executor map for a given eval mode and scenario.
58
+ */
59
+ resolveTools(mode: "live" | "mock" | "mixed", scenarioName?: string): Map<string, ToolExecutor>;
60
+ private buildMockExecutor;
61
+ }
62
+ /**
63
+ * Run a single eval case and return the result.
64
+ */
65
+ export declare function runEval(evalCase: EvalCase, registry: EvalToolRegistry, agentRunner: AgentRunnerFn): Promise<EvalResult>;
66
+ /**
67
+ * Run all eval cases and return aggregated results.
68
+ */
69
+ export declare function runEvalSuite(cases: EvalCase[], registry: EvalToolRegistry, agentRunner: AgentRunnerFn): Promise<{
70
+ results: EvalResult[];
71
+ passCount: number;
72
+ failCount: number;
73
+ }>;
@@ -0,0 +1,60 @@
1
+ import type { ToolDefinition, ToolContext } from "./registry.js";
2
+ export interface AccessDenied {
3
+ tool: string;
4
+ reason: string;
5
+ missing: string[];
6
+ }
7
+ export interface WorkspaceToolConfig {
8
+ /** If set, only these tools are available (whitelist).
9
+ * Supports exact names ("file.read") and prefix globs ("file.*"). */
10
+ whitelist?: string[];
11
+ /** If set, these tools are removed from availability (blacklist).
12
+ * Supports exact names and prefix globs. Blacklist wins over whitelist. */
13
+ blacklist?: string[];
14
+ }
15
+ export interface EditionToolConfig {
16
+ /** Tool names available in this edition. Use "*" for all. */
17
+ tools: string[];
18
+ /** Tool categories included (matched against tool name prefixes like "file.*"). */
19
+ categories?: string[];
20
+ }
21
+ export interface ACLCheckResult {
22
+ allowed: boolean;
23
+ tool: string;
24
+ reason: string;
25
+ }
26
+ export declare class AccessControl {
27
+ private workspaceConfig;
28
+ private editionConfig;
29
+ /**
30
+ * Check whether the context has all permissions required by the tool.
31
+ * Returns true if the tool has no required permissions, or if the
32
+ * context includes every required permission.
33
+ */
34
+ canAccess(tool: ToolDefinition, context: ToolContext): boolean;
35
+ /**
36
+ * Like canAccess but returns an AccessDenied descriptor on failure,
37
+ * or null if access is granted.
38
+ */
39
+ check(tool: ToolDefinition, context: ToolContext): AccessDenied | null;
40
+ /** Set workspace-level whitelist/blacklist restrictions. */
41
+ setWorkspaceConfig(config: WorkspaceToolConfig): void;
42
+ /** Get the current workspace config. */
43
+ getWorkspaceConfig(): WorkspaceToolConfig;
44
+ /** Set the active edition's tool configuration. */
45
+ setEditionConfig(config: EditionToolConfig): void;
46
+ /** Get the current edition config. */
47
+ getEditionConfig(): EditionToolConfig | null;
48
+ /**
49
+ * Full ACL check: edition → workspace → permissions.
50
+ * Returns whether a tool is accessible given all layers.
51
+ */
52
+ checkACL(tool: ToolDefinition, context: ToolContext): ACLCheckResult;
53
+ /**
54
+ * Filter a list of tools down to only those visible to the agent.
55
+ * Tools not passing the ACL are excluded from the system prompt.
56
+ */
57
+ filterVisible(tools: ToolDefinition[], context: ToolContext): ToolDefinition[];
58
+ private isToolInEdition;
59
+ private matchesPattern;
60
+ }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Browser Engine — wraps Playwright for web navigation, interaction,
3
+ * and content extraction. Single browser instance reused across calls.
4
+ *
5
+ * Content isolation: all extracted content is wrapped with
6
+ * [WEB_CONTENT_START]...[WEB_CONTENT_END] markers and tagged as
7
+ * web_content instruction source.
8
+ */
9
+ export interface BrowserPage {
10
+ goto(url: string, options?: {
11
+ waitUntil?: string;
12
+ }): Promise<{
13
+ status: () => number | null;
14
+ }>;
15
+ title(): Promise<string>;
16
+ click(selector: string): Promise<void>;
17
+ fill(selector: string, value: string): Promise<void>;
18
+ screenshot(options?: {
19
+ type?: string;
20
+ encoding?: string;
21
+ }): Promise<string | Buffer>;
22
+ evaluate<T>(fn: () => T): Promise<T>;
23
+ $eval<T>(selector: string, fn: (el: Element) => T): Promise<T>;
24
+ close(): Promise<void>;
25
+ content(): Promise<string>;
26
+ }
27
+ export interface Browser {
28
+ newPage(): Promise<BrowserPage>;
29
+ close(): Promise<void>;
30
+ }
31
+ export interface BrowserLauncher {
32
+ launch(options?: Record<string, unknown>): Promise<Browser>;
33
+ }
34
+ export interface NavigateResult {
35
+ title: string;
36
+ summary: string;
37
+ url: string;
38
+ }
39
+ export interface ExtractResult {
40
+ content: string;
41
+ title: string;
42
+ url: string;
43
+ }
44
+ export declare class BrowserEngine {
45
+ private browser;
46
+ private page;
47
+ private currentUrl;
48
+ private readonly launcher;
49
+ constructor(launcher: BrowserLauncher);
50
+ private ensurePage;
51
+ /** Navigate to URL, return page title and content summary. */
52
+ navigate(url: string): Promise<NavigateResult>;
53
+ /** Click an element by CSS selector. */
54
+ click(selector: string): Promise<{
55
+ clicked: boolean;
56
+ selector: string;
57
+ }>;
58
+ /** Fill an input field by CSS selector. */
59
+ type(selector: string, text: string): Promise<{
60
+ filled: boolean;
61
+ selector: string;
62
+ }>;
63
+ /** Extract cleaned page content, stripping nav/ads/scripts. */
64
+ extract(selector?: string): Promise<ExtractResult>;
65
+ /** Capture viewport as base64 PNG for vision LLM analysis. */
66
+ screenshot(): Promise<{
67
+ image: string;
68
+ format: string;
69
+ url: string;
70
+ }>;
71
+ /** Cleanup — call on agent:end. */
72
+ close(): Promise<void>;
73
+ }
@@ -0,0 +1,7 @@
1
+ import type { ToolDefinition } from "../registry.js";
2
+ import type { JobQueue } from "../../job-queue.js";
3
+ /**
4
+ * Create job management tools backed by the given JobQueue.
5
+ * Tools: jobs.submit, jobs.status, jobs.list, jobs.cancel
6
+ */
7
+ export declare function createJobsTools(queue: JobQueue): ToolDefinition[];
@@ -0,0 +1,25 @@
1
+ import type { ToolDefinition } from "../registry.js";
2
+ export type TaskStatus = "pending" | "in_progress" | "done";
3
+ export interface Task {
4
+ id: string;
5
+ title: string;
6
+ status: TaskStatus;
7
+ priority: "low" | "normal" | "high";
8
+ createdAt: number;
9
+ updatedAt: number;
10
+ }
11
+ export declare class TaskStore {
12
+ private tasks;
13
+ private nextId;
14
+ create(title: string, priority?: Task["priority"]): Task;
15
+ get(id: string): Task | undefined;
16
+ list(status?: TaskStatus): Task[];
17
+ update(id: string, fields: Partial<Pick<Task, "title" | "status" | "priority">>): Task;
18
+ delete(id: string): boolean;
19
+ get size(): number;
20
+ }
21
+ /**
22
+ * Create task management tools backed by the given store.
23
+ * Tools: tasks.create, tasks.get, tasks.list, tasks.update, tasks.delete
24
+ */
25
+ export declare function createTasksTools(store: TaskStore): ToolDefinition[];
@@ -0,0 +1,20 @@
1
+ export { ToolRouter, type ToolCall, type ToolResult } from "./router.js";
2
+ export { ToolRegistry, type ToolDefinition, type ToolContext, type ToolHandler, type ParameterDef } from "./registry.js";
3
+ export { AccessControl, type AccessDenied } from "./access-control.js";
4
+ export { createTasksTools, TaskStore, type Task, type TaskStatus } from "./builtins/tasks-router.js";
5
+ export { createMemoryTools } from "./routers/memory-router.js";
6
+ export { createWebTools } from "./routers/web-router.js";
7
+ export { createCodeTools } from "./routers/code-router.js";
8
+ export { createFileTools } from "./routers/file-router.js";
9
+ export { createScheduleTools } from "./routers/schedule-router.js";
10
+ export { createTaskPlanTools } from "./routers/task-router.js";
11
+ export { createBrowserTools } from "./routers/browser-router.js";
12
+ export { BrowserEngine } from "./browser-engine.js";
13
+ export type { BrowserPage, Browser, BrowserLauncher, NavigateResult, ExtractResult, } from "./browser-engine.js";
14
+ export { discoverSkills, extractFrontmatter, formatSkillForAgent, searchSkills, matchSkillsByTrigger } from "./skill-discovery.js";
15
+ export type { Skill, SkillValidationError } from "./skill-discovery.js";
16
+ export { LazySkillRegistry, loadSkillsLazy, loadSkills } from "./skill-loader.js";
17
+ export type { SkillLoaderConfig, SkillLoadResult, SkillStub } from "./skill-loader.js";
18
+ export type { SkillDefinition, SkillCategory, McpServerRef } from "./skill-types.js";
19
+ export { MapReduceEngine, countReducer, majorityVoteReducer, filterReducer } from "./map-reduce.js";
20
+ export type { ContentChunk as MapReduceChunk, StructuredOutputSchema, MapReduceOpts, MapResult, LLMMapCallFn, MapReduceConfig, } from "./map-reduce.js";
@@ -0,0 +1,64 @@
1
+ export interface ContentChunk {
2
+ id: string;
3
+ sourceId: string;
4
+ content: string;
5
+ chunkIndex: number;
6
+ metadata: Record<string, unknown>;
7
+ }
8
+ export interface StructuredOutputSchema {
9
+ type: string;
10
+ properties?: Record<string, unknown>;
11
+ enum?: string[];
12
+ description?: string;
13
+ }
14
+ export interface MapReduceOpts<MapOut, ReduceOut> {
15
+ chunks: ContentChunk[];
16
+ /** Prompt template — {content} is replaced with chunk content */
17
+ mapPrompt: string;
18
+ /** JSON schema for constrained map output */
19
+ mapSchema: StructuredOutputSchema;
20
+ /** Deterministic aggregation of validated map outputs */
21
+ reduce: (results: MapOut[]) => ReduceOut | Promise<ReduceOut>;
22
+ }
23
+ export interface MapResult<T> {
24
+ chunkId: string;
25
+ output: T;
26
+ success: boolean;
27
+ error?: string;
28
+ }
29
+ export type LLMMapCallFn = (prompt: string, schema: StructuredOutputSchema) => Promise<unknown>;
30
+ export type JobEnqueueFn = (type: string, payload: unknown) => Promise<string>;
31
+ export interface MapReduceConfig {
32
+ /** Max parallel map workers (default: 10) */
33
+ maxConcurrency: number;
34
+ /** LLM call function for map phase */
35
+ llmCall: LLMMapCallFn;
36
+ /** Optional: route map calls through job queue */
37
+ enqueueJob?: JobEnqueueFn;
38
+ }
39
+ export declare class MapReduceEngine {
40
+ private config;
41
+ constructor(config: MapReduceConfig);
42
+ /**
43
+ * Execute map-reduce over untrusted document chunks.
44
+ * Each chunk is processed in isolation — no cross-contamination.
45
+ */
46
+ mapReduce<MapOut, ReduceOut>(opts: MapReduceOpts<MapOut, ReduceOut>): Promise<ReduceOut>;
47
+ /** Get map results without reducing (for inspection/testing). */
48
+ map<MapOut>(chunks: ContentChunk[], mapPrompt: string, mapSchema: StructuredOutputSchema): Promise<MapResult<MapOut>[]>;
49
+ private executeMap;
50
+ private processChunk;
51
+ }
52
+ /** Count truthy values from boolean map outputs. */
53
+ export declare function countReducer(results: boolean[]): {
54
+ total: number;
55
+ truthy: number;
56
+ falsy: number;
57
+ };
58
+ /** Majority vote from enum/string map outputs. */
59
+ export declare function majorityVoteReducer(results: string[]): {
60
+ winner: string;
61
+ votes: Record<string, number>;
62
+ };
63
+ /** Filter and collect results matching a predicate. */
64
+ export declare function filterReducer<T>(predicate: (item: T) => boolean): (results: T[]) => T[];
@@ -0,0 +1,39 @@
1
+ export interface ParameterDef {
2
+ type: "string" | "number" | "boolean" | "object" | "array";
3
+ description?: string;
4
+ required?: boolean;
5
+ }
6
+ export interface ToolContext {
7
+ mode: string;
8
+ permissions: string[];
9
+ [key: string]: unknown;
10
+ }
11
+ export type ToolHandler = (params: Record<string, unknown>, context: ToolContext) => Promise<unknown>;
12
+ export interface ToolDefinition {
13
+ name: string;
14
+ description: string;
15
+ parameters?: Record<string, ParameterDef>;
16
+ handler: ToolHandler;
17
+ /** Restrict to these modes (empty/undefined = available in all modes) */
18
+ modes?: string[];
19
+ /** ACL permission tags required to invoke this tool */
20
+ requiredPermissions?: string[];
21
+ }
22
+ export declare class ToolRegistry {
23
+ private tools;
24
+ /** Register a tool definition. Throws on duplicate name. */
25
+ register(tool: ToolDefinition): void;
26
+ /** Register multiple tools at once. */
27
+ registerAll(tools: ToolDefinition[]): void;
28
+ /** Get a tool by name, or undefined. */
29
+ get(name: string): ToolDefinition | undefined;
30
+ /** Check if a tool is registered. */
31
+ has(name: string): boolean;
32
+ /**
33
+ * List tools, optionally filtered by mode.
34
+ * Tools with no mode restriction are always included.
35
+ */
36
+ list(mode?: string): ToolDefinition[];
37
+ /** Number of registered tools. */
38
+ get size(): number;
39
+ }
@@ -0,0 +1,30 @@
1
+ import type { ToolRegistry, ToolDefinition, ToolContext } from "./registry.js";
2
+ import { AccessControl } from "./access-control.js";
3
+ export interface ToolCall {
4
+ name: string;
5
+ arguments: Record<string, unknown>;
6
+ }
7
+ export interface ToolResult {
8
+ name: string;
9
+ result?: unknown;
10
+ error?: string;
11
+ }
12
+ export declare class ToolRouter {
13
+ private readonly registry;
14
+ private readonly acl;
15
+ constructor(registry: ToolRegistry, acl?: AccessControl);
16
+ /**
17
+ * Route a tool call to its handler.
18
+ *
19
+ * Checks:
20
+ * 1. Tool exists in registry
21
+ * 2. Tool is available in the current mode
22
+ * 3. Context has required permissions (ACL)
23
+ * 4. Invokes handler, catches errors
24
+ */
25
+ route(call: ToolCall, context: ToolContext): Promise<ToolResult>;
26
+ /**
27
+ * List tools available in the given context (mode + permissions).
28
+ */
29
+ listAvailable(context: ToolContext): ToolDefinition[];
30
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Browser Router — exposes BrowserEngine actions as tool definitions.
3
+ *
4
+ * Tools: browser.navigate, browser.click, browser.type,
5
+ * browser.extract, browser.screenshot
6
+ */
7
+ import type { ToolDefinition } from "../registry.js";
8
+ import type { BrowserEngine } from "../browser-engine.js";
9
+ /**
10
+ * Create browser tools backed by the given BrowserEngine instance.
11
+ */
12
+ export declare function createBrowserTools(engine: BrowserEngine): ToolDefinition[];
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Code Router — exposes code execution and analysis as tool definitions.
3
+ *
4
+ * Tools: code.execute (sandboxed), code.analyze, code.explain
5
+ *
6
+ * code.execute runs in a sandboxed environment with timeout.
7
+ * code.analyze performs static analysis on a code snippet.
8
+ * code.explain generates a natural-language explanation.
9
+ */
10
+ import type { ToolDefinition } from "../registry.js";
11
+ export interface CodeExecutionResult {
12
+ stdout: string;
13
+ stderr: string;
14
+ exitCode: number;
15
+ durationMs: number;
16
+ }
17
+ export interface CodeAnalysisResult {
18
+ language: string;
19
+ complexity: string;
20
+ issues: Array<{
21
+ line: number;
22
+ message: string;
23
+ severity: string;
24
+ }>;
25
+ }
26
+ export interface CodeBackend {
27
+ execute(code: string, language: string, timeoutMs?: number): Promise<CodeExecutionResult>;
28
+ analyze(code: string, language: string): Promise<CodeAnalysisResult>;
29
+ explain(code: string, language: string): Promise<string>;
30
+ }
31
+ /**
32
+ * Create code tools backed by the given CodeBackend.
33
+ */
34
+ export declare function createCodeTools(backend: CodeBackend): ToolDefinition[];
@@ -0,0 +1,35 @@
1
+ /**
2
+ * File Router — exposes file system operations as tool definitions.
3
+ *
4
+ * Tools: files.read, files.write, files.list, files.search
5
+ *
6
+ * All operations are scoped to an allowed base directory for security.
7
+ */
8
+ import type { ToolDefinition } from "../registry.js";
9
+ export interface FileEntry {
10
+ path: string;
11
+ name: string;
12
+ size: number;
13
+ isDirectory: boolean;
14
+ modifiedAt: Date;
15
+ }
16
+ export interface FileSearchResult {
17
+ path: string;
18
+ line: number;
19
+ content: string;
20
+ }
21
+ export interface FileBackend {
22
+ read(path: string): Promise<string>;
23
+ write(path: string, content: string): Promise<{
24
+ written: boolean;
25
+ path: string;
26
+ }>;
27
+ list(directory: string, recursive?: boolean): Promise<FileEntry[]>;
28
+ search(directory: string, pattern: string, opts?: {
29
+ limit?: number;
30
+ }): Promise<FileSearchResult[]>;
31
+ }
32
+ /**
33
+ * Create file tools backed by the given FileBackend.
34
+ */
35
+ export declare function createFileTools(backend: FileBackend): ToolDefinition[];
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Memory Router — exposes memory operations as tool definitions.
3
+ *
4
+ * Tools: memory.search, memory.expand, memory.context, memory.save,
5
+ * memory.forget, memory.list, memory.graph
6
+ */
7
+ import type { ToolDefinition } from "../registry.js";
8
+ import type { MemorySegment, MemorySearchResult } from "../../storage/interface.js";
9
+ export interface MemoryBackend {
10
+ search(userId: string, query: string, limit?: number): Promise<MemorySearchResult[]>;
11
+ searchByEmbedding(userId: string, embedding: number[], limit?: number): Promise<MemorySearchResult[]>;
12
+ save(userId: string, content: string, category: MemorySegment["category"]): Promise<MemorySegment>;
13
+ forget(segmentId: string): Promise<boolean>;
14
+ list(userId: string, category?: string, limit?: number): Promise<MemorySegment[]>;
15
+ getProfile(userId: string): Promise<string | null>;
16
+ graphQuery?(userId: string, entityName: string): Promise<unknown>;
17
+ }
18
+ /**
19
+ * Create memory tools backed by the given MemoryBackend.
20
+ */
21
+ export declare function createMemoryTools(backend: MemoryBackend): ToolDefinition[];
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Schedule Router — exposes scheduling operations as tool definitions.
3
+ *
4
+ * Tools: schedule.create, schedule.list, schedule.cancel
5
+ *
6
+ * Integrates with the job queue for deferred/recurring execution.
7
+ */
8
+ import type { ToolDefinition } from "../registry.js";
9
+ export interface ScheduleEntry {
10
+ id: string;
11
+ name: string;
12
+ cron?: string;
13
+ runAt?: Date;
14
+ payload: Record<string, unknown>;
15
+ status: "active" | "paused" | "cancelled" | "completed";
16
+ createdAt: Date;
17
+ }
18
+ export interface ScheduleBackend {
19
+ create(entry: {
20
+ name: string;
21
+ cron?: string;
22
+ runAt?: string;
23
+ payload: Record<string, unknown>;
24
+ }): Promise<ScheduleEntry>;
25
+ list(status?: string): Promise<ScheduleEntry[]>;
26
+ cancel(id: string): Promise<boolean>;
27
+ }
28
+ /**
29
+ * Create schedule tools backed by the given ScheduleBackend.
30
+ */
31
+ export declare function createScheduleTools(backend: ScheduleBackend): ToolDefinition[];
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Search Backends — concrete WebSearchProvider implementations.
3
+ *
4
+ * Cascade: Tavily (default) → SearXNG (self-hosted) → DuckDuckGo (fallback).
5
+ * Configurable per workspace via searchBackend option.
6
+ */
7
+ import type { WebSearchProvider, WebSearchResult } from "./web-router.js";
8
+ export declare class TavilySearchProvider implements WebSearchProvider {
9
+ private apiKey;
10
+ private baseUrl;
11
+ constructor(opts: {
12
+ apiKey: string;
13
+ baseUrl?: string;
14
+ });
15
+ search(query: string, opts?: {
16
+ limit?: number;
17
+ }): Promise<WebSearchResult[]>;
18
+ }
19
+ export declare class SearXNGSearchProvider implements WebSearchProvider {
20
+ private baseUrl;
21
+ constructor(opts: {
22
+ baseUrl: string;
23
+ });
24
+ search(query: string, opts?: {
25
+ limit?: number;
26
+ }): Promise<WebSearchResult[]>;
27
+ }
28
+ export declare class DuckDuckGoSearchProvider implements WebSearchProvider {
29
+ search(query: string, opts?: {
30
+ limit?: number;
31
+ }): Promise<WebSearchResult[]>;
32
+ }
33
+ export type SearchBackendType = "tavily" | "searxng" | "duckduckgo";
34
+ export interface SearchBackendConfig {
35
+ type: SearchBackendType;
36
+ apiKey?: string;
37
+ baseUrl?: string;
38
+ }
39
+ /**
40
+ * Build a primary + fallback search provider pair from config.
41
+ *
42
+ * Cascade: configured primary → DuckDuckGo fallback (unless primary IS DDG).
43
+ */
44
+ export declare function createSearchBackend(config: SearchBackendConfig): {
45
+ primary: WebSearchProvider;
46
+ fallback?: WebSearchProvider;
47
+ };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Task Router — exposes high-level task planning and management as tool definitions.
3
+ *
4
+ * Tools: tasks.plan, tasks.update, tasks.list, tasks.complete
5
+ *
6
+ * Distinct from builtins/tasks-router.ts which provides low-level CRUD.
7
+ * This router adds planning, decomposition, and completion semantics.
8
+ */
9
+ import type { ToolDefinition } from "../registry.js";
10
+ export interface TaskPlan {
11
+ id: string;
12
+ goal: string;
13
+ steps: TaskStep[];
14
+ status: "planning" | "active" | "completed" | "cancelled";
15
+ createdAt: number;
16
+ }
17
+ export interface TaskStep {
18
+ id: string;
19
+ description: string;
20
+ status: "pending" | "in_progress" | "done" | "skipped";
21
+ result?: string;
22
+ }
23
+ export interface TaskPlanBackend {
24
+ plan(goal: string, context?: string): Promise<TaskPlan>;
25
+ update(planId: string, stepId: string, status: TaskStep["status"], result?: string): Promise<TaskPlan>;
26
+ list(status?: TaskPlan["status"]): Promise<TaskPlan[]>;
27
+ complete(planId: string, summary: string): Promise<TaskPlan>;
28
+ }
29
+ /**
30
+ * Create task planning tools backed by the given TaskPlanBackend.
31
+ */
32
+ export declare function createTaskPlanTools(backend: TaskPlanBackend): ToolDefinition[];
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Web Router — exposes web search and fetch as tool definitions.
3
+ *
4
+ * Tools: web.search, web.fetch
5
+ *
6
+ * Search uses a primary provider (e.g. Tavily) with DuckDuckGo fallback.
7
+ * Fetch retrieves and extracts content from URLs with SSRF protection.
8
+ */
9
+ import type { ToolDefinition } from "../registry.js";
10
+ export interface WebSearchResult {
11
+ title: string;
12
+ url: string;
13
+ snippet: string;
14
+ score?: number;
15
+ }
16
+ export interface WebSearchProvider {
17
+ search(query: string, opts?: {
18
+ limit?: number;
19
+ }): Promise<WebSearchResult[]>;
20
+ }
21
+ export interface WebFetchProvider {
22
+ fetch(url: string): Promise<{
23
+ title: string;
24
+ content: string;
25
+ url: string;
26
+ }>;
27
+ }
28
+ export interface WebBackend {
29
+ primary: WebSearchProvider;
30
+ fallback?: WebSearchProvider;
31
+ fetcher: WebFetchProvider;
32
+ }
33
+ /**
34
+ * Create web tools backed by search and fetch providers.
35
+ */
36
+ export declare function createWebTools(backend: WebBackend): ToolDefinition[];