@miller-tech/uap 1.40.0 → 1.40.1

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 (92) hide show
  1. package/README.md +109 -642
  2. package/docs/INDEX.md +48 -286
  3. package/docs/architecture/OVERVIEW.md +328 -0
  4. package/docs/architecture/PROTOCOL.md +204 -0
  5. package/docs/benchmarks/README.md +17 -192
  6. package/docs/getting-started/CONFIGURATION.md +237 -0
  7. package/docs/getting-started/INSTALLATION.md +125 -0
  8. package/docs/getting-started/QUICKSTART.md +115 -0
  9. package/docs/guides/COORDINATION.md +162 -0
  10. package/docs/guides/DELIVER.md +115 -0
  11. package/docs/guides/DEPLOY_BATCHING.md +212 -0
  12. package/docs/guides/DROIDS_AND_SKILLS.md +202 -0
  13. package/docs/guides/LOCAL_MODELS.md +148 -0
  14. package/docs/guides/MCP_ROUTER.md +195 -0
  15. package/docs/guides/MEMORY.md +235 -0
  16. package/docs/guides/MULTI_MODEL.md +223 -0
  17. package/docs/guides/POLICIES.md +190 -0
  18. package/docs/guides/WORKTREE_WORKFLOW.md +185 -0
  19. package/docs/integrations/MCP_ROUTER.md +147 -0
  20. package/docs/integrations/RTK.md +102 -0
  21. package/docs/reference/API.md +485 -0
  22. package/docs/reference/CLI.md +719 -0
  23. package/docs/reference/CONFIGURATION.md +90 -193
  24. package/docs/reference/DATABASE_SCHEMA.md +110 -344
  25. package/docs/reference/FEATURES.md +176 -472
  26. package/docs/reference/PATTERNS.md +102 -0
  27. package/docs/reference/PLATFORMS.md +83 -0
  28. package/package.json +1 -1
  29. package/docs/AGENTS.md +0 -423
  30. package/docs/DOCUMENTATION_AUDIT_REPORT.md +0 -131
  31. package/docs/GETTING_STARTED.md +0 -288
  32. package/docs/PROJECT_ANALYSIS_REPORT.md +0 -510
  33. package/docs/architecture/COMPLETE_ARCHITECTURE.md +0 -748
  34. package/docs/architecture/EXPERT_STACK.md +0 -137
  35. package/docs/architecture/MULTI_MODEL.md +0 -224
  36. package/docs/architecture/PLATFORM_GATING.md +0 -68
  37. package/docs/architecture/SYSTEM_ANALYSIS.md +0 -334
  38. package/docs/architecture/UAP_COMPLIANCE.md +0 -217
  39. package/docs/architecture/UAP_PROTOCOL.md +0 -339
  40. package/docs/architecture/UAP_STRICT_DROIDS.md +0 -172
  41. package/docs/archive/BALLS_MODE_SELF_ANALYSIS.md +0 -260
  42. package/docs/archive/BENCHMARK_GAPS_AND_PLAN.md +0 -146
  43. package/docs/archive/FAILING_TASKS_SOLUTION_PLAN.md +0 -668
  44. package/docs/archive/JINJA2-SYSTEM-MESSAGE-FIX.md +0 -209
  45. package/docs/archive/MODEL_ROUTING_IMPLEMENTATION_SUMMARY.md +0 -281
  46. package/docs/archive/MODEL_ROUTING_OPTIMIZATION_PLAN.md +0 -320
  47. package/docs/archive/NPM-PUBLISH-V0.9.1.md +0 -240
  48. package/docs/archive/OPTIMIZATION_OPTIONS.md +0 -334
  49. package/docs/archive/PARALLELISM_GAPS_AND_OPTIONS.md +0 -422
  50. package/docs/archive/POLICY_GATE_IMPLEMENTATION.md +0 -245
  51. package/docs/archive/SETUP_IMPROVEMENTS.md +0 -213
  52. package/docs/archive/UAP_GENERIC_OPTIMIZATION_PLAN.md +0 -270
  53. package/docs/archive/UAP_OPTIMIZATION_PLAN.md +0 -701
  54. package/docs/archive/UAP_V103_PATTERN_DESIGN.md +0 -315
  55. package/docs/archive/UAP_V104_COMPLIANCE_DESIGN.md +0 -223
  56. package/docs/archive/changelog/2026-03-10_uap-100-compliance.md +0 -77
  57. package/docs/archive/changelog/2026-03-10_uap-full-system-verification.md +0 -109
  58. package/docs/archive/opencode-integration-guide.md +0 -740
  59. package/docs/archive/opencode-integration-quickref.md +0 -180
  60. package/docs/benchmarks/OVERNIGHT_RUNNER.md +0 -341
  61. package/docs/benchmarks/SPECULATIVE_DECODING_JOURNEY_2026-03.md +0 -221
  62. package/docs/benchmarks/VALIDATION_PLAN.md +0 -568
  63. package/docs/blog/SPECULATIVE_DECODING_PRODUCTION_PLAYBOOK.md +0 -139
  64. package/docs/blog/local-coding-agents.md +0 -266
  65. package/docs/blog/x-thread.md +0 -254
  66. package/docs/deployment/DEPLOYMENT.md +0 -895
  67. package/docs/deployment/DEPLOYMENT_STRATEGIES.md +0 -518
  68. package/docs/deployment/DEPLOY_BATCHER_ANALYSIS.md +0 -224
  69. package/docs/deployment/DEPLOY_BATCHING.md +0 -273
  70. package/docs/deployment/DEPLOY_BUCKETING_ANALYSIS.md +0 -420
  71. package/docs/deployment/QWEN35_LLAMA_CPP.md +0 -426
  72. package/docs/deployment/UAP_LLAMA_ANTHROPIC_PROXY_BOOTSTRAP.md +0 -279
  73. package/docs/getting-started/INTEGRATION.md +0 -628
  74. package/docs/getting-started/OVERVIEW.md +0 -324
  75. package/docs/getting-started/SETUP.md +0 -377
  76. package/docs/integrations/MCP_ROUTER_SETUP.md +0 -445
  77. package/docs/integrations/RTK_INTEGRATION.md +0 -468
  78. package/docs/operations/TROUBLESHOOTING.md +0 -660
  79. package/docs/pr/PR_SPECULATIVE_DOCS_TEMPLATE.md +0 -146
  80. package/docs/pr/UPSTREAM_PRS.md +0 -424
  81. package/docs/reference/API_REFERENCE.md +0 -903
  82. package/docs/reference/EXPERT_DROIDS.md +0 -219
  83. package/docs/reference/HARNESS-MATRIX.md +0 -318
  84. package/docs/reference/PATTERN_LIBRARY.md +0 -636
  85. package/docs/reference/UAP_CLI_REFERENCE.md +0 -620
  86. package/docs/research/BEHAVIORAL_PATTERNS.md +0 -228
  87. package/docs/research/DOMAIN_STRATEGIES.md +0 -316
  88. package/docs/research/MEMORY_SYSTEMS_COMPARISON.md +0 -812
  89. package/docs/research/PATTERN_ANALYSIS_2026-01-18.md +0 -436
  90. package/docs/research/PERFORMANCE_ANALYSIS_2026-01-18.md +0 -209
  91. package/docs/research/PERFORMANCE_TEST_PLAN.md +0 -383
  92. package/docs/research/TERMINAL_BENCH_LEARNINGS.md +0 -217
@@ -0,0 +1,485 @@
1
+ # UAP Programmatic API Reference
2
+
3
+ > Public API of the `@miller-tech/uap` package. Version v1.40.0.
4
+
5
+ Install and import:
6
+
7
+ ```bash
8
+ npm install @miller-tech/uap
9
+ ```
10
+
11
+ ```ts
12
+ import { analyzeProject, getHierarchicalMemoryManager, McpRouter } from '@miller-tech/uap';
13
+ ```
14
+
15
+ The package entry point is `dist/index.js` (`main`). Everything documented here
16
+ is re-exported from the package root unless noted otherwise.
17
+
18
+ > **Note on the delivery loop.** The convergence engine that powers
19
+ > `uap deliver` (`ConvergenceLoop`) lives in `src/delivery/` and is **not**
20
+ > re-exported from the package root, and the package defines no subpath
21
+ > `exports`. Drive the delivery loop through the [`uap deliver`](./CLI.md#deliver)
22
+ > CLI rather than importing it programmatically.
23
+
24
+ ## Contents
25
+
26
+ - [Project analysis & generation](#project-analysis--generation)
27
+ - [Multi-model architecture](#multi-model-architecture)
28
+ - [Memory system](#memory-system)
29
+ - [Knowledge graph (L4)](#knowledge-graph-l4)
30
+ - [MCP router](#mcp-router)
31
+ - [Coordination](#coordination)
32
+ - [Tasks](#tasks)
33
+ - [Utilities](#utilities)
34
+ - [Type modules](#type-modules)
35
+
36
+ ---
37
+
38
+ ## Project analysis & generation
39
+
40
+ ```ts
41
+ function analyzeProject(projectPath?: string): Promise<ProjectAnalysis>;
42
+ function generateClaudeMd(analysis: ProjectAnalysis, options?: GenerateOptions): string;
43
+ ```
44
+
45
+ - `analyzeProject` — inspect a project directory and return structured metadata
46
+ (languages, frameworks, structure) used to drive context generation.
47
+ - `generateClaudeMd` — render a CLAUDE.md document from an analysis result.
48
+
49
+ ---
50
+
51
+ ## Multi-model architecture
52
+
53
+ Imported from the package root (originating in `src/models/`). Routes tasks to
54
+ models by complexity, plans multi-step work, and executes plans with
55
+ retry/fallback.
56
+
57
+ ### Factory functions
58
+
59
+ ```ts
60
+ function createRouter(config: MultiModelConfig): ModelRouter;
61
+ function createCostOptimizedRouter(): ModelRouter;
62
+ function createPerformanceRouter(): ModelRouter;
63
+ function createPlanner(router: ModelRouter, config: MultiModelConfig, options?: PlannerOptions): TaskPlanner;
64
+ function createExecutor(router: ModelRouter, config: MultiModelConfig, client: ModelClient, options?: ExecutorOptions): TaskExecutor;
65
+ function createUnifiedRouter(config: MultiModelConfig, benchmarkConfig?: Partial<RoutingConfig>): UnifiedRoutingService;
66
+ function createPlanValidator(config?: PlanValidationConfig): PlanValidator;
67
+ function getModelAnalytics(): ModelAnalytics; // singleton
68
+ ```
69
+
70
+ ### `ModelRouter`
71
+
72
+ Classifies tasks and selects models per role.
73
+
74
+ ```ts
75
+ class ModelRouter {
76
+ constructor(config: MultiModelConfig);
77
+ classifyTask(taskDescription: string): TaskClassificationResult;
78
+ selectModel(complexity: TaskComplexity, taskType: string, keywords: string[]): ModelSelection;
79
+ estimateCost(model: ModelConfig, inputTokens: number, outputTokens: number): number;
80
+ getModel(modelId: string): ModelConfig | undefined;
81
+ getModelForRole(role: ModelRole): ModelConfig | undefined;
82
+ getAllModels(): ModelConfig[];
83
+ analyzeRouting(taskDescription: string): { classification: TaskClassificationResult; matchedRules: unknown[]; costComparison: Array<{ model: string; cost: number }> };
84
+ }
85
+ ```
86
+
87
+ ### `TaskPlanner`
88
+
89
+ Decomposes a task into an `ExecutionPlan`.
90
+
91
+ ```ts
92
+ class TaskPlanner {
93
+ constructor(router: ModelRouter, config: MultiModelConfig, options?: PlannerOptions);
94
+ createPlan(taskDescription: string): Promise<ExecutionPlan>;
95
+ getExecutionOrder(plan: ExecutionPlan): string[][];
96
+ visualizePlan(plan: ExecutionPlan): string;
97
+ }
98
+ ```
99
+
100
+ ### `TaskExecutor`
101
+
102
+ Executes a plan's subtasks against a `ModelClient`.
103
+
104
+ ```ts
105
+ class TaskExecutor {
106
+ constructor(router: ModelRouter, config: MultiModelConfig, client: ModelClient, options?: ExecutorOptions);
107
+ executePlan(plan: ExecutionPlan, planner: TaskPlanner, onResult?: (r: ExecutionResult) => void): Promise<ExecutionResult[]>;
108
+ executeSubtask(subtask: Subtask, plan: ExecutionPlan): Promise<ExecutionResult>;
109
+ getResults(planId: string): ExecutionResult[] | undefined;
110
+ getTotalCost(planId: string): number;
111
+ getSuccessRate(planId: string): number;
112
+ generateSummary(planId: string): string;
113
+ }
114
+ ```
115
+
116
+ ### `ModelClient` and `MockModelClient`
117
+
118
+ The seam executors call to reach an LLM.
119
+
120
+ ```ts
121
+ interface ModelClient {
122
+ complete(
123
+ model: ModelConfig,
124
+ prompt: string,
125
+ options?: { maxTokens?: number; timeout?: number; temperature?: number }
126
+ ): Promise<{ content: string; tokensUsed: { input: number; output: number }; latencyMs: number }>;
127
+ }
128
+
129
+ class MockModelClient implements ModelClient {
130
+ constructor(responses?: Record<string, string>, latency?: number);
131
+ }
132
+ ```
133
+
134
+ ### `ModelPresets`
135
+
136
+ A lookup record of built-in model configs (not a function), keyed by preset id
137
+ (e.g. `'opus-4.6'`, `'qwen35-a3b'`, `'haiku'`, `'gpt-5.4'`).
138
+
139
+ ```ts
140
+ const ModelPresets: Record<string, ModelConfig>;
141
+ ```
142
+
143
+ ### Execution profiles
144
+
145
+ ```ts
146
+ function getExecutionProfile(profileId: string): ExecutionProfile | undefined;
147
+ function detectExecutionProfile(modelName: string): ExecutionProfile;
148
+ function getExecutionConfig(modelName: string, userOverrides?: Partial<AgentExecutionConfig>): { profile: ExecutionProfile; config: AgentExecutionConfig };
149
+ function listExecutionProfiles(): ExecutionProfile[];
150
+ ```
151
+
152
+ ### `PlanValidator` and `ModelAnalytics`
153
+
154
+ ```ts
155
+ class PlanValidator {
156
+ constructor(config?: PlanValidationConfig);
157
+ validatePlan(plan: ExecutionPlan): Promise<PlanValidationResult>;
158
+ getConfig(): PlanValidationConfig;
159
+ updateConfig(config: PlanValidationConfig): void;
160
+ }
161
+
162
+ class ModelAnalytics {
163
+ constructor(dbPath?: string);
164
+ recordOutcome(outcome: TaskOutcome): void;
165
+ getSuccessRate(modelId: string, taskType?: string): number;
166
+ getAvgLatency(modelId: string, taskType?: string): number;
167
+ getMetrics(modelId?: string): ModelMetrics[];
168
+ getCostBreakdown(since?: Date): CostBreakdown[];
169
+ getSessionUsage(): SessionModelUsage[];
170
+ getOptimalRouting(): Record<string, string>;
171
+ getTotalCost(): number;
172
+ close(): void;
173
+ }
174
+ ```
175
+
176
+ ### Example
177
+
178
+ ```ts
179
+ import { createRouter, createPlanner, createExecutor, MockModelClient, ModelPresets } from '@miller-tech/uap';
180
+
181
+ const config = {
182
+ enabled: true,
183
+ models: ['opus-4.6', 'qwen35-a3b'],
184
+ roles: { planner: 'opus-4.6', executor: 'qwen35-a3b', fallback: 'qwen35-a3b' },
185
+ routingStrategy: 'balanced' as const,
186
+ };
187
+
188
+ const router = createRouter(config);
189
+ const planner = createPlanner(router, config);
190
+ const plan = await planner.createPlan('Add OAuth2 login with JWT and tests');
191
+
192
+ const executor = createExecutor(router, config, new MockModelClient());
193
+ const results = await executor.executePlan(plan, planner);
194
+ console.log(executor.generateSummary(plan.id));
195
+ ```
196
+
197
+ ---
198
+
199
+ ## Memory system
200
+
201
+ ### Embeddings
202
+
203
+ ```ts
204
+ function getEmbeddingService(): EmbeddingService; // honors UAP_EMBEDDING_ENDPOINT
205
+ function generateEmbedding(text: string): Promise<number[]>;
206
+ function generateEmbeddings(texts: string[]): Promise<number[][]>;
207
+
208
+ class OllamaEmbeddingProvider {
209
+ constructor(endpoint?: string, model?: string); // defaults: localhost:11434, nomic-embed-text (768-dim)
210
+ }
211
+ ```
212
+
213
+ ### Hierarchical (tiered) memory
214
+
215
+ Hot/warm/cold tiered store with automatic promotion, demotion, decay, and a
216
+ token budget.
217
+
218
+ ```ts
219
+ class HierarchicalMemoryManager {
220
+ constructor(config?: Partial<HierarchicalConfig>);
221
+ add(entry: Omit<MemoryEntry, 'accessCount' | 'lastAccessed' | 'tier'>): void;
222
+ access(id: string): MemoryEntry | null;
223
+ query(queryText: string, limit?: number): Promise<MemoryEntry[]>;
224
+ getHotContext(): { entries: MemoryEntry[]; tokens: number };
225
+ consolidate(): Promise<void>;
226
+ pruneStale(): number;
227
+ enforceTokenBudget(): number;
228
+ getStats(): { hot: { count: number; tokens: number }; warm: { count: number; tokens: number }; cold: { count: number; tokens: number }; total: { count: number; tokens: number } };
229
+ export(): TieredMemory;
230
+ import(data: TieredMemory): void;
231
+ }
232
+
233
+ function getHierarchicalMemoryManager(config?: Partial<HierarchicalConfig>, dbPath?: string): HierarchicalMemoryManager;
234
+ function saveHierarchicalMemory(dbPath?: string): void;
235
+ function persistToSQLite(manager: HierarchicalMemoryManager, dbPath: string): void;
236
+ function loadFromSQLite(dbPath: string): TieredMemory | null;
237
+ function calculateEffectiveImportance(entry: MemoryEntry, decayRate?: number): number;
238
+ ```
239
+
240
+ ```ts
241
+ interface MemoryEntry {
242
+ id: string;
243
+ content: string;
244
+ type: 'action' | 'observation' | 'thought' | 'goal';
245
+ timestamp: string;
246
+ importance: number;
247
+ accessCount: number;
248
+ lastAccessed: string;
249
+ embedding?: number[];
250
+ compressed?: string;
251
+ tier?: 'hot' | 'warm' | 'cold';
252
+ }
253
+
254
+ interface TieredMemory { hot: MemoryEntry[]; warm: MemoryEntry[]; cold: MemoryEntry[]; }
255
+ ```
256
+
257
+ ### Dynamic retrieval
258
+
259
+ ```ts
260
+ function retrieveDynamicMemoryContext(
261
+ taskInstruction: string,
262
+ projectRoot?: string,
263
+ options?: { maxTokens?: number; useSemanticCompression?: boolean; taskMetadata?: TaskMetadata }
264
+ ): Promise<DynamicMemoryContext>;
265
+ ```
266
+
267
+ Returns a token-budget-bounded memory context scaled to query complexity.
268
+
269
+ ### Write gate
270
+
271
+ Quality filter that decides whether a candidate memory is worth persisting.
272
+
273
+ ```ts
274
+ function evaluateWriteGate(content: string, config?: WriteGateConfig): WriteGateResult;
275
+ function formatGateResult(result: WriteGateResult): string;
276
+
277
+ interface WriteGateResult { passed: boolean; score: number; criteria: GateCriteria[]; rejectionReason?: string; }
278
+ interface WriteGateConfig { minScore: number; enableFuzzyMatching: boolean; } // default { minScore: 0.3, enableFuzzyMatching: true }
279
+ ```
280
+
281
+ ### Other memory exports
282
+
283
+ | Symbol | Kind | Purpose |
284
+ |--------|------|---------|
285
+ | `classifyTask`, `extractTaskEntities`, `getSuggestedMemoryQueries` | functions | Classify a task and derive memory queries |
286
+ | `compressMemoryEntry`, `compressMemoryBatch`, `summarizeMemories`, `estimateTokens`, `ContextBudget` | functions/class | Context compression and token budgeting |
287
+ | `extractAtomicFacts`, `compressToSemanticUnits`, `createSemanticUnit`, `serializeSemanticUnit` | functions | Semantic compression |
288
+ | `calculateEntropy`, `calculateInformationDensity` | functions | Entropy-aware compression metrics |
289
+ | `SpeculativeCache`, `getSpeculativeCache` | class/fn | Prefetch cache for likely-next memories |
290
+ | `MemoryConsolidator`, `getMemoryConsolidator`, `autoStartConsolidation` | class/fns | Background consolidation |
291
+ | `ServerlessQdrantManager`, `getServerlessQdrantManager`, `initServerlessQdrant` | class/fns | Embedded Qdrant management |
292
+ | `DailyLog`, `ensureDailyLogSchema` | class/fn | Staging area for memory writes |
293
+ | `propagateCorrection`, `getSupersededHistory` | functions | Correction propagation across tiers |
294
+ | `runMaintenance`, `getHealthSummary` | functions | Decay / prune / archive / dedupe |
295
+ | `PredictiveMemoryService`, `getPredictiveMemoryService` | class/fn | Predictive prefetch + learning |
296
+ | `ContextPruner` | class | Token-budget-aware context pruning |
297
+ | `detectAmbiguity`, `formatAmbiguityForContext` | functions | Ambiguity detection (P37 pattern) |
298
+ | `routeTaskToModel`, `recordTaskOutcome`, `explainRouting` | functions | Memory-layer model router with feedback |
299
+
300
+ ---
301
+
302
+ ## Knowledge graph (L4)
303
+
304
+ SQLite-backed entity/relationship graph.
305
+
306
+ ```ts
307
+ class KnowledgeGraph {
308
+ constructor(dbPath: string);
309
+ upsertEntity(type: string, name: string, description?: string): Entity;
310
+ getEntity(type: string, name: string): Entity | null;
311
+ getEntitiesByType(type: string, limit?: number): Entity[];
312
+ searchEntities(query: string, limit?: number): Entity[];
313
+ deleteEntity(id: number): boolean;
314
+ addRelationship(sourceId: number, targetId: number, relation: string, strength?: number): Relationship;
315
+ getRelationships(entityId: number): Relationship[];
316
+ queryEntityGraph(type: string, name: string): GraphQueryResult | null;
317
+ traverseGraph(entityId: number, maxDepth?: number): Entity[];
318
+ getStats(): { entityCount: number; relationshipCount: number; entityTypes: string[] };
319
+ close(): void;
320
+ }
321
+ ```
322
+
323
+ ---
324
+
325
+ ## MCP router
326
+
327
+ Hierarchical router exposing two meta-tools (discover + execute) for 98%+ token
328
+ reduction versus exposing every server's full tool list.
329
+
330
+ ```ts
331
+ class McpRouter {
332
+ constructor(options?: RouterOptions); // { configPath?, autoDiscover?, verbose? }
333
+ loadTools(): Promise<void>;
334
+ getToolDefinitions(): Array<ToolDefinition>;
335
+ handleToolCall(name: string, args: unknown): Promise<unknown>;
336
+ getStats(): RouterStats;
337
+ getConfig(): McpConfig;
338
+ shutdown(): Promise<void>;
339
+ }
340
+
341
+ function runStdioServer(options?: RouterOptions): Promise<void>;
342
+ function loadConfigFromPaths(): McpConfig; // merges known platform config paths
343
+ function loadConfigFromFile(path: string): McpConfig;
344
+ function mergeConfigs(...configs: McpConfig[]): McpConfig;
345
+ function handleDiscoverTools(args: DiscoverToolsArgs, searchIndex: ToolSearchIndex): { tools: ToolSearchResult[]; hint: string };
346
+ function handleExecuteTool(args: ExecuteToolArgs, searchIndex: ToolSearchIndex, clientPool: McpClientPool): Promise<unknown>;
347
+ ```
348
+
349
+ Also exported: `ToolSearchIndex`, `McpClient`, `McpClientPool`,
350
+ `DISCOVER_TOOLS_DEFINITION`, `EXECUTE_TOOL_DEFINITION`,
351
+ `estimateDiscoverToolsTokens`, `estimateExecuteToolTokens`.
352
+
353
+ ```ts
354
+ import { runStdioServer } from '@miller-tech/uap';
355
+ await runStdioServer({ configPath: './mcp.json', verbose: true });
356
+ ```
357
+
358
+ ---
359
+
360
+ ## Coordination
361
+
362
+ Imported from the package root (originating in `src/coordination/`). The main
363
+ class is `CoordinationService` — agent registry, resource claims, work
364
+ announcements, messaging, and deploy batching, all backed by SQLite.
365
+
366
+ ```ts
367
+ class CoordinationService {
368
+ constructor(config?: CoordinationServiceConfig);
369
+
370
+ // lifecycle
371
+ register(name: string, capabilities?: string[], worktreeBranch?: string, id?: string): string;
372
+ heartbeat(agentId: string): void;
373
+ updateStatus(agentId: string, status: AgentStatus, currentTask?: string): void;
374
+ deregister(agentId: string): void;
375
+ getActiveAgents(): AgentRegistryEntry[];
376
+ cleanupStaleAgents(): number;
377
+
378
+ // resource claims
379
+ claimResource(agentId: string, resource: string, claimType?: ClaimType): boolean;
380
+ releaseResource(agentId: string, resource: string): void;
381
+ isResourceClaimed(resource: string): string | null;
382
+
383
+ // work announcements & overlap
384
+ announceWork(...): void;
385
+ completeWork(agentId: string, resource: string): void;
386
+ getActiveWork(): WorkAnnouncement[];
387
+ detectOverlaps(resource: string, excludeAgentId?: string): WorkOverlap[];
388
+
389
+ // messaging
390
+ broadcast(...): void;
391
+ send(fromAgent: string, toAgent: string, payload: MessagePayload, priority?: number): void;
392
+ receive(agentId: string, channel?: MessageChannel, markAsRead?: boolean): AgentMessage[];
393
+
394
+ // deploy batching
395
+ queueDeploy(...): void;
396
+ getReadyDeploys(): DeployAction[];
397
+ flushDeploys(options?: { dryRun?: boolean }): Promise<{ executed: number; failed: number }>;
398
+
399
+ getStatus(): CoordinationStatus;
400
+ cleanup(): void;
401
+ }
402
+ ```
403
+
404
+ The coordination module also exports the deploy batcher, capability router,
405
+ auto-agent, and pattern router helpers (see `src/coordination/index.ts`).
406
+
407
+ ---
408
+
409
+ ## Tasks
410
+
411
+ Imported from the package root (originating in `src/tasks/`). The main class is
412
+ `TaskService`.
413
+
414
+ ```ts
415
+ class TaskService {
416
+ constructor(config?: TaskServiceConfig);
417
+ create(input: CreateTaskInput): Task;
418
+ get(id: string): Task | null;
419
+ getWithRelations(id: string): TaskWithRelations | null;
420
+ update(id: string, input: UpdateTaskInput): Task | null;
421
+ close(id: string, reason?: string): Task | null;
422
+ delete(id: string): boolean;
423
+ list(filter?: TaskFilter): Task[];
424
+ ready(): TaskWithRelations[];
425
+ blocked(): TaskWithRelations[];
426
+ addDependency(...): void;
427
+ removeDependency(fromTask: string, toTask: string): boolean;
428
+ getBlockers(taskId: string): Task[];
429
+ getHistory(taskId: string): TaskHistoryEntry[];
430
+ getStats(): TaskStats;
431
+ exportToJSONL(): string;
432
+ saveToJSONL(): void;
433
+ importFromJSONL(): number;
434
+ compact(olderThanDays?: number): TaskSummary | null;
435
+ }
436
+ ```
437
+
438
+ ### Task event bus
439
+
440
+ Pub/sub for task lifecycle events.
441
+
442
+ ```ts
443
+ class TaskEventBus {
444
+ on(type: TaskEventType, handler: TaskEventHandler): () => void;
445
+ onAny(handler: TaskEventHandler): () => void;
446
+ emit(event: TaskEvent): Promise<void>;
447
+ clear(): void;
448
+ listenerCount(type?: TaskEventType): number;
449
+ }
450
+
451
+ function getTaskEventBus(): TaskEventBus; // singleton
452
+ ```
453
+
454
+ ---
455
+
456
+ ## Utilities
457
+
458
+ | Symbol | Kind | Purpose |
459
+ |--------|------|---------|
460
+ | `jaccardSimilarity`, `cosineSimilarity`, `textSimilarity`, `fuzzyKeywordMatch`, `contentHash`, `simpleStem`, `estimateTokensAccurate` | functions | String / vector similarity helpers |
461
+ | `AdaptiveCache`, `createPatternCache` | class/fn | Adaptive TTL cache |
462
+ | `RateLimiter` | class | Token-bucket rate limiting |
463
+ | `PerformanceMonitor`, `getPerformanceMonitor`, `monitorFunction` | class/fns | Performance instrumentation |
464
+ | `retry`, `withTimeout`, `parallelWithFallback`, `concurrentMap`, `concurrentMapSettled` | functions | Concurrency helpers |
465
+ | `createLogger`, `logger`, `setLogLevel`, `getLogLevel` | fns/obj | Structured logging |
466
+ | `isPathInsideWorktree`, `isExemptFromWorktree` | functions | Worktree guard utilities |
467
+ | `WebBrowser`, `createWebBrowser` | class/fn | Browser automation wrapper |
468
+ | `getDashboardData`, `startDashboardServer` | functions | Dashboard data service + server |
469
+
470
+ ---
471
+
472
+ ## Type modules
473
+
474
+ The package re-exports its full type surface. Key barrels:
475
+
476
+ - `export * from './types/index.js'` — core config and domain types.
477
+ - `export * from './telemetry/index.js'` — telemetry types and helpers.
478
+ - `export * from './policies/index.js'` — policy enforcement (`getPolicyGate`,
479
+ `getPolicyMemoryManager`, `getPolicyToolRegistry`, and policy types).
480
+
481
+ Multi-model types available from the root include `MultiModelConfig`,
482
+ `ModelRole`, `TaskComplexity`, `TaskClassificationResult`, `ExecutionPlan`,
483
+ `Subtask`, `ExecutionResult`, `ModelSelection`, `PlannerOptions`,
484
+ `ExecutorOptions`, `ExecutionProfile`, `ModelMetrics`, `CostBreakdown`, and
485
+ `SessionModelUsage`.