botinabox 2.3.2 → 2.4.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.
- package/dist/channels/slack/index.d.ts +1 -1
- package/dist/chat-pipeline-BWrtVqEP.d.ts +652 -0
- package/dist/index.d.ts +332 -192
- package/dist/index.js +394 -65
- package/package.json +2 -3
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { T as TokenUsage, L as LLMProvider, M as ModelInfo, R as ResolvedModel,
|
|
|
4
4
|
export { a as ChatParams, b as ChatResult, c as ContentBlock, d as ToolUse } from './provider-DLGUfnNx.js';
|
|
5
5
|
import { C as ConnectorConfig } from './connector-B4Mj0P1b.js';
|
|
6
6
|
export { A as AuthResult, a as Connector, b as ConnectorMeta, P as PushResult, S as SyncOptions, c as SyncResult } from './connector-B4Mj0P1b.js';
|
|
7
|
-
import { C as ChatResponderConfig, D as DataStore, H as HookBus } from './chat-pipeline-
|
|
8
|
-
export {
|
|
7
|
+
import { C as ChatResponderConfig, D as DataStore, H as HookBus, M as MessageStore, a as ChatResponder, b as MessageInterpreter, E as Extractor } from './chat-pipeline-BWrtVqEP.js';
|
|
8
|
+
export { c as ChatPipeline, d as ChatPipelineConfig, e as DataStoreError, f as EntityContextDef, g as EntityFileSpec, h as EntitySource, i as ExtractedFile, j as ExtractedMemory, k as ExtractedTask, l as ExtractedUserContext, F as Filter, m as HookHandler, n as HookOptions, o as HookRegistration, I as InterpretationResult, L as LLMCallFn, p as MessageInterpreterConfig, P as PkLookup, Q as QueryOptions, R as RelationDef, q as RoutingDecision, r as RoutingRule, s as Row, S as SeedItem, t as SqliteAdapter, u as StoreResult, v as StoredAttachment, T as TableDefinition, w as TableInfoRow, x as TriageRouter, y as TriageRouterConfig, U as Unsubscribe } from './chat-pipeline-BWrtVqEP.js';
|
|
9
9
|
import 'better-sqlite3';
|
|
10
10
|
|
|
11
11
|
/** Execution adapter types — Story 1.5 / 3.4 / 3.5 */
|
|
@@ -832,6 +832,324 @@ declare class NotificationQueue {
|
|
|
832
832
|
private processNext;
|
|
833
833
|
}
|
|
834
834
|
|
|
835
|
+
/**
|
|
836
|
+
* CircuitBreaker — prevents runaway agent failures with automatic escalation.
|
|
837
|
+
* Story 6.2
|
|
838
|
+
*
|
|
839
|
+
* States:
|
|
840
|
+
* CLOSED → normal operation, failures counted
|
|
841
|
+
* OPEN → tripped, all executions blocked, escalated to human
|
|
842
|
+
* HALF_OPEN → probe mode, one execution allowed to test recovery
|
|
843
|
+
*
|
|
844
|
+
* Integrates with LoopDetector and RunManager via HookBus events.
|
|
845
|
+
*/
|
|
846
|
+
|
|
847
|
+
declare enum BreakerState {
|
|
848
|
+
CLOSED = "closed",
|
|
849
|
+
OPEN = "open",
|
|
850
|
+
HALF_OPEN = "half_open"
|
|
851
|
+
}
|
|
852
|
+
interface CircuitBreakerConfig {
|
|
853
|
+
/** Failures before tripping. Default: 3 */
|
|
854
|
+
failureThreshold?: number;
|
|
855
|
+
/** Milliseconds to wait before half-open probe. Default: 300_000 (5 min) */
|
|
856
|
+
resetTimeoutMs?: number;
|
|
857
|
+
/** Log events to the database. Default: true */
|
|
858
|
+
persist?: boolean;
|
|
859
|
+
}
|
|
860
|
+
declare class CircuitBreaker {
|
|
861
|
+
private db;
|
|
862
|
+
private hooks;
|
|
863
|
+
private readonly breakers;
|
|
864
|
+
private readonly failureThreshold;
|
|
865
|
+
private readonly resetTimeoutMs;
|
|
866
|
+
private readonly persist;
|
|
867
|
+
constructor(db: DataStore, hooks: HookBus, config?: CircuitBreakerConfig);
|
|
868
|
+
/**
|
|
869
|
+
* Check if an agent is allowed to execute.
|
|
870
|
+
* Returns true if execution is allowed, false if circuit is open.
|
|
871
|
+
*/
|
|
872
|
+
canExecute(agentId: string): boolean;
|
|
873
|
+
/**
|
|
874
|
+
* Record a successful execution. Resets the breaker to CLOSED.
|
|
875
|
+
*/
|
|
876
|
+
recordSuccess(agentId: string): Promise<void>;
|
|
877
|
+
/**
|
|
878
|
+
* Record a failed execution. Increments failure count and may trip breaker.
|
|
879
|
+
*/
|
|
880
|
+
recordFailure(agentId: string, reason?: string): Promise<void>;
|
|
881
|
+
/**
|
|
882
|
+
* Trip the breaker to OPEN state and escalate to human.
|
|
883
|
+
*/
|
|
884
|
+
trip(agentId: string, reason: string): Promise<void>;
|
|
885
|
+
/**
|
|
886
|
+
* Manually reset a breaker (e.g. after human review).
|
|
887
|
+
*/
|
|
888
|
+
reset(agentId: string): Promise<void>;
|
|
889
|
+
/**
|
|
890
|
+
* Get the current state of a breaker.
|
|
891
|
+
*/
|
|
892
|
+
getState(agentId: string): BreakerState;
|
|
893
|
+
/**
|
|
894
|
+
* Get failure count for an agent.
|
|
895
|
+
*/
|
|
896
|
+
getFailureCount(agentId: string): number;
|
|
897
|
+
private logEvent;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
declare class RunManager {
|
|
901
|
+
private db;
|
|
902
|
+
private hooks;
|
|
903
|
+
private config?;
|
|
904
|
+
private locks;
|
|
905
|
+
private orphanTimer;
|
|
906
|
+
private readonly staleThresholdMs;
|
|
907
|
+
private circuitBreaker?;
|
|
908
|
+
constructor(db: DataStore, hooks: HookBus, config?: {
|
|
909
|
+
staleThresholdMs?: number;
|
|
910
|
+
maxBackoffMs?: number;
|
|
911
|
+
} | undefined);
|
|
912
|
+
/**
|
|
913
|
+
* Attach a CircuitBreaker to prevent retries on broken agents.
|
|
914
|
+
*/
|
|
915
|
+
setCircuitBreaker(cb: CircuitBreaker): void;
|
|
916
|
+
isLocked(agentId: string): boolean;
|
|
917
|
+
startRun(agentId: string, taskId: string, adapter?: string): Promise<string>;
|
|
918
|
+
finishRun(runId: string, result: {
|
|
919
|
+
exitCode: number;
|
|
920
|
+
output?: string;
|
|
921
|
+
costCents?: number;
|
|
922
|
+
usage?: unknown;
|
|
923
|
+
}): Promise<void>;
|
|
924
|
+
reapOrphans(): Promise<void>;
|
|
925
|
+
startOrphanReaper(intervalMs?: number): void;
|
|
926
|
+
stopOrphanReaper(): void;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
/**
|
|
930
|
+
* ExecutionEngine — generic task executor with pluggable tools and tool loop.
|
|
931
|
+
*
|
|
932
|
+
* Listens for task.created events, picks up tasks, runs them through an LLM
|
|
933
|
+
* with tools, and finishes the run with the result.
|
|
934
|
+
*
|
|
935
|
+
* Apps configure: model, tools, system prompt, max iterations.
|
|
936
|
+
* Framework handles: task pickup, locking, tool loop, cost tracking, result storage.
|
|
937
|
+
*/
|
|
938
|
+
|
|
939
|
+
interface ToolDefinition {
|
|
940
|
+
name: string;
|
|
941
|
+
description: string;
|
|
942
|
+
input_schema: Record<string, unknown>;
|
|
943
|
+
}
|
|
944
|
+
type ToolHandler = (input: Record<string, unknown>, context: ToolContext) => Promise<string>;
|
|
945
|
+
interface ToolContext {
|
|
946
|
+
taskId: string;
|
|
947
|
+
agentId: string;
|
|
948
|
+
hooks: HookBus;
|
|
949
|
+
db: DataStore;
|
|
950
|
+
/** Resolve a relative file path to an absolute path (environment-aware). */
|
|
951
|
+
resolveFilePath?: (path: string) => string;
|
|
952
|
+
}
|
|
953
|
+
interface ExecutionEngineConfig {
|
|
954
|
+
/** Anthropic client instance */
|
|
955
|
+
client: {
|
|
956
|
+
messages: {
|
|
957
|
+
create: (params: Record<string, unknown>) => Promise<{
|
|
958
|
+
content: Array<{
|
|
959
|
+
type: string;
|
|
960
|
+
text?: string;
|
|
961
|
+
id?: string;
|
|
962
|
+
name?: string;
|
|
963
|
+
input?: unknown;
|
|
964
|
+
}>;
|
|
965
|
+
stop_reason: string;
|
|
966
|
+
usage: {
|
|
967
|
+
input_tokens: number;
|
|
968
|
+
output_tokens: number;
|
|
969
|
+
};
|
|
970
|
+
}>;
|
|
971
|
+
};
|
|
972
|
+
};
|
|
973
|
+
/** Model to use. Default: claude-sonnet-4-20250514 */
|
|
974
|
+
model?: string;
|
|
975
|
+
/** Max tool loop iterations. Default: 5 */
|
|
976
|
+
maxIterations?: number;
|
|
977
|
+
/** Tools available to the agent */
|
|
978
|
+
tools?: Array<{
|
|
979
|
+
definition: ToolDefinition;
|
|
980
|
+
handler: ToolHandler;
|
|
981
|
+
}>;
|
|
982
|
+
/** Additional system prompt text (appended after system context) */
|
|
983
|
+
systemPromptSuffix?: string;
|
|
984
|
+
/** Include system context (users, files, etc). Default: true */
|
|
985
|
+
includeSystemContext?: boolean;
|
|
986
|
+
/** Resolve file paths from DB-relative to absolute (for cross-environment support). */
|
|
987
|
+
resolveFilePath?: (path: string) => string;
|
|
988
|
+
}
|
|
989
|
+
declare function registerExecutionEngine(opts: {
|
|
990
|
+
db: DataStore;
|
|
991
|
+
hooks: HookBus;
|
|
992
|
+
runs: RunManager;
|
|
993
|
+
config: ExecutionEngineConfig;
|
|
994
|
+
}): Promise<void>;
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* SystemContextBuilder — loads entity data from the database and formats
|
|
998
|
+
* it as markdown for injection into LLM system prompts.
|
|
999
|
+
*
|
|
1000
|
+
* Used by both the ChatPipeline (ack layer) and ExecutionEngine (agent layer)
|
|
1001
|
+
* to give LLMs awareness of the system state.
|
|
1002
|
+
*/
|
|
1003
|
+
|
|
1004
|
+
interface SystemContextOptions {
|
|
1005
|
+
/** Include users. Default: true */
|
|
1006
|
+
users?: boolean;
|
|
1007
|
+
/** Include agents. Default: true */
|
|
1008
|
+
agents?: boolean;
|
|
1009
|
+
/** Include projects. Default: true */
|
|
1010
|
+
projects?: boolean;
|
|
1011
|
+
/** Include clients. Default: true */
|
|
1012
|
+
clients?: boolean;
|
|
1013
|
+
/** Include files. Default: true */
|
|
1014
|
+
files?: boolean;
|
|
1015
|
+
/** Include org. Default: true */
|
|
1016
|
+
org?: boolean;
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Build a markdown-formatted system context string from the database.
|
|
1020
|
+
* Queries users, agents, projects, clients, files, and org.
|
|
1021
|
+
*/
|
|
1022
|
+
declare function buildSystemContext(db: DataStore, options?: SystemContextOptions): Promise<string>;
|
|
1023
|
+
|
|
1024
|
+
/**
|
|
1025
|
+
* ChatPipelineV2 — Primary Agent Architecture.
|
|
1026
|
+
*
|
|
1027
|
+
* Replaces the 6-layer "dumb ack + headless execution" pattern with a
|
|
1028
|
+
* 3-phase "conversational brain + tool delegation" pattern:
|
|
1029
|
+
*
|
|
1030
|
+
* Phase 1: RECEIVE — Store message, build history, emit typing indicator
|
|
1031
|
+
* Phase 2: THINK — Call primary agent LLM with history + tools in a loop
|
|
1032
|
+
* Phase 3: RESPOND — Deliver agent's text, run async memory extraction
|
|
1033
|
+
*
|
|
1034
|
+
* The primary agent is the conversational hub. It has full conversation
|
|
1035
|
+
* context and uses tools to answer directly (single-agent) or delegate
|
|
1036
|
+
* work (multi-agent). One response per message — no separate ack.
|
|
1037
|
+
*/
|
|
1038
|
+
|
|
1039
|
+
type ContentBlock = {
|
|
1040
|
+
type: string;
|
|
1041
|
+
text?: string;
|
|
1042
|
+
id?: string;
|
|
1043
|
+
name?: string;
|
|
1044
|
+
input?: unknown;
|
|
1045
|
+
};
|
|
1046
|
+
type MessageParam = {
|
|
1047
|
+
role: string;
|
|
1048
|
+
content: string | ContentBlock[];
|
|
1049
|
+
};
|
|
1050
|
+
interface ChatPipelineV2Config {
|
|
1051
|
+
/** Primary agent LLM call — supports tool use */
|
|
1052
|
+
llmCall: (params: {
|
|
1053
|
+
model: string;
|
|
1054
|
+
messages: MessageParam[];
|
|
1055
|
+
system?: string;
|
|
1056
|
+
maxTokens?: number;
|
|
1057
|
+
tools?: ToolDefinition[];
|
|
1058
|
+
tool_choice?: {
|
|
1059
|
+
type: string;
|
|
1060
|
+
};
|
|
1061
|
+
}) => Promise<{
|
|
1062
|
+
content: ContentBlock[];
|
|
1063
|
+
stop_reason: string;
|
|
1064
|
+
usage?: {
|
|
1065
|
+
input_tokens: number;
|
|
1066
|
+
output_tokens: number;
|
|
1067
|
+
};
|
|
1068
|
+
}>;
|
|
1069
|
+
/** System prompt for the primary agent */
|
|
1070
|
+
systemPrompt: string;
|
|
1071
|
+
/** Tools available to the primary agent */
|
|
1072
|
+
tools?: Array<{
|
|
1073
|
+
definition: ToolDefinition;
|
|
1074
|
+
handler: ToolHandler;
|
|
1075
|
+
}>;
|
|
1076
|
+
/** Model (default: 'claude-sonnet-4-6') */
|
|
1077
|
+
model?: string;
|
|
1078
|
+
/** Max tool loop iterations (default: 5) */
|
|
1079
|
+
maxIterations?: number;
|
|
1080
|
+
/** Max tokens for response (default: 4096) */
|
|
1081
|
+
maxTokens?: number;
|
|
1082
|
+
/** Optional message filter */
|
|
1083
|
+
messageFilter?: (msg: InboundMessage) => boolean;
|
|
1084
|
+
/** Channel (default: 'slack') */
|
|
1085
|
+
channel?: string;
|
|
1086
|
+
/** Dedup window ms (default: 300_000) */
|
|
1087
|
+
dedupWindowMs?: number;
|
|
1088
|
+
/** Conversation history config */
|
|
1089
|
+
history?: {
|
|
1090
|
+
maxMessages?: number;
|
|
1091
|
+
maxAgeDays?: number;
|
|
1092
|
+
includeAssistant?: boolean;
|
|
1093
|
+
};
|
|
1094
|
+
/** Include system context from DB (default: true) */
|
|
1095
|
+
includeSystemContext?: boolean;
|
|
1096
|
+
/** Options for buildSystemContext */
|
|
1097
|
+
systemContextOptions?: SystemContextOptions;
|
|
1098
|
+
/** TaskQueue for dispatch_task and sub-agent result delivery */
|
|
1099
|
+
tasks: {
|
|
1100
|
+
create(task: Record<string, unknown>): Promise<string>;
|
|
1101
|
+
update(id: string, changes: Record<string, unknown>): Promise<void>;
|
|
1102
|
+
get(id: string): Promise<Record<string, unknown> | undefined>;
|
|
1103
|
+
};
|
|
1104
|
+
/** WakeupQueue for agent wakeup */
|
|
1105
|
+
wakeups: {
|
|
1106
|
+
enqueue(agentId: string, source: string, context?: Record<string, unknown>): Promise<string>;
|
|
1107
|
+
};
|
|
1108
|
+
/** Custom extractors for async memory extraction */
|
|
1109
|
+
extractors?: Extractor[];
|
|
1110
|
+
/** Sub-agent result handling (default: 'passthrough') */
|
|
1111
|
+
subAgentResultMode?: 'passthrough' | 'synthesize';
|
|
1112
|
+
/** Resolve file paths from DB-relative to absolute */
|
|
1113
|
+
resolveFilePath?: (path: string) => string;
|
|
1114
|
+
}
|
|
1115
|
+
declare class ChatPipelineV2 {
|
|
1116
|
+
private db;
|
|
1117
|
+
private hooks;
|
|
1118
|
+
private config;
|
|
1119
|
+
readonly messageStore: MessageStore;
|
|
1120
|
+
readonly responder: ChatResponder;
|
|
1121
|
+
readonly interpreter: MessageInterpreter;
|
|
1122
|
+
private readonly channel;
|
|
1123
|
+
private readonly messageFilter?;
|
|
1124
|
+
private readonly dedupWindowMs;
|
|
1125
|
+
private readonly threadChannelMap;
|
|
1126
|
+
private readonly toolDefs;
|
|
1127
|
+
private readonly toolHandlers;
|
|
1128
|
+
constructor(db: DataStore, hooks: HookBus, config: ChatPipelineV2Config);
|
|
1129
|
+
/**
|
|
1130
|
+
* Resolve the channel ID for a thread (for response delivery).
|
|
1131
|
+
*/
|
|
1132
|
+
resolveChannel(threadId: string, taskId?: string): Promise<string | undefined>;
|
|
1133
|
+
private registerHandlers;
|
|
1134
|
+
/**
|
|
1135
|
+
* Primary agent tool loop — adapted from ExecutionEngine pattern.
|
|
1136
|
+
*/
|
|
1137
|
+
private think;
|
|
1138
|
+
/**
|
|
1139
|
+
* Build conversation history from channel messages.
|
|
1140
|
+
* Includes BOTH user and assistant messages (unlike v1 which excluded bot messages).
|
|
1141
|
+
*/
|
|
1142
|
+
private buildHistory;
|
|
1143
|
+
/**
|
|
1144
|
+
* Dedup check (same as v1).
|
|
1145
|
+
*/
|
|
1146
|
+
private isDuplicate;
|
|
1147
|
+
/**
|
|
1148
|
+
* Async memory extraction (non-blocking, non-fatal).
|
|
1149
|
+
*/
|
|
1150
|
+
private extractAsync;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
835
1153
|
/**
|
|
836
1154
|
* Text chunker — splits long text into chunks at natural boundaries.
|
|
837
1155
|
* Story 4.4
|
|
@@ -945,34 +1263,6 @@ interface DomainEntityContextOptions {
|
|
|
945
1263
|
*/
|
|
946
1264
|
declare function defineDomainEntityContexts(db: DataStore, options?: DomainEntityContextOptions): void;
|
|
947
1265
|
|
|
948
|
-
/**
|
|
949
|
-
* SystemContextBuilder — loads entity data from the database and formats
|
|
950
|
-
* it as markdown for injection into LLM system prompts.
|
|
951
|
-
*
|
|
952
|
-
* Used by both the ChatPipeline (ack layer) and ExecutionEngine (agent layer)
|
|
953
|
-
* to give LLMs awareness of the system state.
|
|
954
|
-
*/
|
|
955
|
-
|
|
956
|
-
interface SystemContextOptions {
|
|
957
|
-
/** Include users. Default: true */
|
|
958
|
-
users?: boolean;
|
|
959
|
-
/** Include agents. Default: true */
|
|
960
|
-
agents?: boolean;
|
|
961
|
-
/** Include projects. Default: true */
|
|
962
|
-
projects?: boolean;
|
|
963
|
-
/** Include clients. Default: true */
|
|
964
|
-
clients?: boolean;
|
|
965
|
-
/** Include files. Default: true */
|
|
966
|
-
files?: boolean;
|
|
967
|
-
/** Include org. Default: true */
|
|
968
|
-
org?: boolean;
|
|
969
|
-
}
|
|
970
|
-
/**
|
|
971
|
-
* Build a markdown-formatted system context string from the database.
|
|
972
|
-
* Queries users, agents, projects, clients, files, and org.
|
|
973
|
-
*/
|
|
974
|
-
declare function buildSystemContext(db: DataStore, options?: SystemContextOptions): Promise<string>;
|
|
975
|
-
|
|
976
1266
|
interface SanitizerOptions {
|
|
977
1267
|
fieldLengthLimits?: Record<string, number>;
|
|
978
1268
|
truncateSuffix?: string;
|
|
@@ -1139,100 +1429,6 @@ declare function autoUpdate(packages?: string[], opts?: {
|
|
|
1139
1429
|
quiet?: boolean;
|
|
1140
1430
|
}): Promise<UpdateResult>;
|
|
1141
1431
|
|
|
1142
|
-
/**
|
|
1143
|
-
* CircuitBreaker — prevents runaway agent failures with automatic escalation.
|
|
1144
|
-
* Story 6.2
|
|
1145
|
-
*
|
|
1146
|
-
* States:
|
|
1147
|
-
* CLOSED → normal operation, failures counted
|
|
1148
|
-
* OPEN → tripped, all executions blocked, escalated to human
|
|
1149
|
-
* HALF_OPEN → probe mode, one execution allowed to test recovery
|
|
1150
|
-
*
|
|
1151
|
-
* Integrates with LoopDetector and RunManager via HookBus events.
|
|
1152
|
-
*/
|
|
1153
|
-
|
|
1154
|
-
declare enum BreakerState {
|
|
1155
|
-
CLOSED = "closed",
|
|
1156
|
-
OPEN = "open",
|
|
1157
|
-
HALF_OPEN = "half_open"
|
|
1158
|
-
}
|
|
1159
|
-
interface CircuitBreakerConfig {
|
|
1160
|
-
/** Failures before tripping. Default: 3 */
|
|
1161
|
-
failureThreshold?: number;
|
|
1162
|
-
/** Milliseconds to wait before half-open probe. Default: 300_000 (5 min) */
|
|
1163
|
-
resetTimeoutMs?: number;
|
|
1164
|
-
/** Log events to the database. Default: true */
|
|
1165
|
-
persist?: boolean;
|
|
1166
|
-
}
|
|
1167
|
-
declare class CircuitBreaker {
|
|
1168
|
-
private db;
|
|
1169
|
-
private hooks;
|
|
1170
|
-
private readonly breakers;
|
|
1171
|
-
private readonly failureThreshold;
|
|
1172
|
-
private readonly resetTimeoutMs;
|
|
1173
|
-
private readonly persist;
|
|
1174
|
-
constructor(db: DataStore, hooks: HookBus, config?: CircuitBreakerConfig);
|
|
1175
|
-
/**
|
|
1176
|
-
* Check if an agent is allowed to execute.
|
|
1177
|
-
* Returns true if execution is allowed, false if circuit is open.
|
|
1178
|
-
*/
|
|
1179
|
-
canExecute(agentId: string): boolean;
|
|
1180
|
-
/**
|
|
1181
|
-
* Record a successful execution. Resets the breaker to CLOSED.
|
|
1182
|
-
*/
|
|
1183
|
-
recordSuccess(agentId: string): Promise<void>;
|
|
1184
|
-
/**
|
|
1185
|
-
* Record a failed execution. Increments failure count and may trip breaker.
|
|
1186
|
-
*/
|
|
1187
|
-
recordFailure(agentId: string, reason?: string): Promise<void>;
|
|
1188
|
-
/**
|
|
1189
|
-
* Trip the breaker to OPEN state and escalate to human.
|
|
1190
|
-
*/
|
|
1191
|
-
trip(agentId: string, reason: string): Promise<void>;
|
|
1192
|
-
/**
|
|
1193
|
-
* Manually reset a breaker (e.g. after human review).
|
|
1194
|
-
*/
|
|
1195
|
-
reset(agentId: string): Promise<void>;
|
|
1196
|
-
/**
|
|
1197
|
-
* Get the current state of a breaker.
|
|
1198
|
-
*/
|
|
1199
|
-
getState(agentId: string): BreakerState;
|
|
1200
|
-
/**
|
|
1201
|
-
* Get failure count for an agent.
|
|
1202
|
-
*/
|
|
1203
|
-
getFailureCount(agentId: string): number;
|
|
1204
|
-
private logEvent;
|
|
1205
|
-
}
|
|
1206
|
-
|
|
1207
|
-
declare class RunManager {
|
|
1208
|
-
private db;
|
|
1209
|
-
private hooks;
|
|
1210
|
-
private config?;
|
|
1211
|
-
private locks;
|
|
1212
|
-
private orphanTimer;
|
|
1213
|
-
private readonly staleThresholdMs;
|
|
1214
|
-
private circuitBreaker?;
|
|
1215
|
-
constructor(db: DataStore, hooks: HookBus, config?: {
|
|
1216
|
-
staleThresholdMs?: number;
|
|
1217
|
-
maxBackoffMs?: number;
|
|
1218
|
-
} | undefined);
|
|
1219
|
-
/**
|
|
1220
|
-
* Attach a CircuitBreaker to prevent retries on broken agents.
|
|
1221
|
-
*/
|
|
1222
|
-
setCircuitBreaker(cb: CircuitBreaker): void;
|
|
1223
|
-
isLocked(agentId: string): boolean;
|
|
1224
|
-
startRun(agentId: string, taskId: string, adapter?: string): Promise<string>;
|
|
1225
|
-
finishRun(runId: string, result: {
|
|
1226
|
-
exitCode: number;
|
|
1227
|
-
output?: string;
|
|
1228
|
-
costCents?: number;
|
|
1229
|
-
usage?: unknown;
|
|
1230
|
-
}): Promise<void>;
|
|
1231
|
-
reapOrphans(): Promise<void>;
|
|
1232
|
-
startOrphanReaper(intervalMs?: number): void;
|
|
1233
|
-
stopOrphanReaper(): void;
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
1432
|
declare class BudgetController {
|
|
1237
1433
|
private db;
|
|
1238
1434
|
private hooks;
|
|
@@ -1865,73 +2061,6 @@ declare class GateRunner {
|
|
|
1865
2061
|
}>;
|
|
1866
2062
|
}
|
|
1867
2063
|
|
|
1868
|
-
/**
|
|
1869
|
-
* ExecutionEngine — generic task executor with pluggable tools and tool loop.
|
|
1870
|
-
*
|
|
1871
|
-
* Listens for task.created events, picks up tasks, runs them through an LLM
|
|
1872
|
-
* with tools, and finishes the run with the result.
|
|
1873
|
-
*
|
|
1874
|
-
* Apps configure: model, tools, system prompt, max iterations.
|
|
1875
|
-
* Framework handles: task pickup, locking, tool loop, cost tracking, result storage.
|
|
1876
|
-
*/
|
|
1877
|
-
|
|
1878
|
-
interface ToolDefinition {
|
|
1879
|
-
name: string;
|
|
1880
|
-
description: string;
|
|
1881
|
-
input_schema: Record<string, unknown>;
|
|
1882
|
-
}
|
|
1883
|
-
type ToolHandler = (input: Record<string, unknown>, context: ToolContext) => Promise<string>;
|
|
1884
|
-
interface ToolContext {
|
|
1885
|
-
taskId: string;
|
|
1886
|
-
agentId: string;
|
|
1887
|
-
hooks: HookBus;
|
|
1888
|
-
db: DataStore;
|
|
1889
|
-
/** Resolve a relative file path to an absolute path (environment-aware). */
|
|
1890
|
-
resolveFilePath?: (path: string) => string;
|
|
1891
|
-
}
|
|
1892
|
-
interface ExecutionEngineConfig {
|
|
1893
|
-
/** Anthropic client instance */
|
|
1894
|
-
client: {
|
|
1895
|
-
messages: {
|
|
1896
|
-
create: (params: Record<string, unknown>) => Promise<{
|
|
1897
|
-
content: Array<{
|
|
1898
|
-
type: string;
|
|
1899
|
-
text?: string;
|
|
1900
|
-
id?: string;
|
|
1901
|
-
name?: string;
|
|
1902
|
-
input?: unknown;
|
|
1903
|
-
}>;
|
|
1904
|
-
stop_reason: string;
|
|
1905
|
-
usage: {
|
|
1906
|
-
input_tokens: number;
|
|
1907
|
-
output_tokens: number;
|
|
1908
|
-
};
|
|
1909
|
-
}>;
|
|
1910
|
-
};
|
|
1911
|
-
};
|
|
1912
|
-
/** Model to use. Default: claude-sonnet-4-20250514 */
|
|
1913
|
-
model?: string;
|
|
1914
|
-
/** Max tool loop iterations. Default: 5 */
|
|
1915
|
-
maxIterations?: number;
|
|
1916
|
-
/** Tools available to the agent */
|
|
1917
|
-
tools?: Array<{
|
|
1918
|
-
definition: ToolDefinition;
|
|
1919
|
-
handler: ToolHandler;
|
|
1920
|
-
}>;
|
|
1921
|
-
/** Additional system prompt text (appended after system context) */
|
|
1922
|
-
systemPromptSuffix?: string;
|
|
1923
|
-
/** Include system context (users, files, etc). Default: true */
|
|
1924
|
-
includeSystemContext?: boolean;
|
|
1925
|
-
/** Resolve file paths from DB-relative to absolute (for cross-environment support). */
|
|
1926
|
-
resolveFilePath?: (path: string) => string;
|
|
1927
|
-
}
|
|
1928
|
-
declare function registerExecutionEngine(opts: {
|
|
1929
|
-
db: DataStore;
|
|
1930
|
-
hooks: HookBus;
|
|
1931
|
-
runs: RunManager;
|
|
1932
|
-
config: ExecutionEngineConfig;
|
|
1933
|
-
}): Promise<void>;
|
|
1934
|
-
|
|
1935
2064
|
declare const sendFileTool: {
|
|
1936
2065
|
definition: ToolDefinition;
|
|
1937
2066
|
handler: ToolHandler;
|
|
@@ -2052,6 +2181,17 @@ declare const nativeTools: {
|
|
|
2052
2181
|
definition: ToolDefinition;
|
|
2053
2182
|
handler: ToolHandler;
|
|
2054
2183
|
}[];
|
|
2184
|
+
/**
|
|
2185
|
+
* Coordinator tools for multi-agent primary agent.
|
|
2186
|
+
* Orchestration + communication + awareness — no "work" tools.
|
|
2187
|
+
* Use with ChatPipelineV2 in multi-agent mode.
|
|
2188
|
+
*
|
|
2189
|
+
* Single-agent mode should use `nativeTools` instead (all tools).
|
|
2190
|
+
*/
|
|
2191
|
+
declare const coordinatorTools: {
|
|
2192
|
+
definition: ToolDefinition;
|
|
2193
|
+
handler: ToolHandler;
|
|
2194
|
+
}[];
|
|
2055
2195
|
|
|
2056
2196
|
interface SecretInput {
|
|
2057
2197
|
name: string;
|
|
@@ -2141,4 +2281,4 @@ declare function isLoginRequired(stdout: string): boolean;
|
|
|
2141
2281
|
/** Rewrite local image paths to prevent CLI auto-embedding as vision content. */
|
|
2142
2282
|
declare function deactivateLocalImagePaths(prompt: string): string;
|
|
2143
2283
|
|
|
2144
|
-
export { AGENT_STATUSES, type AgentConfig, type AgentDefinition, type AgentFilter, type AgentRecord, AgentRegistry, type AgentStatus, ApiExecutionAdapter, type ApprovalResponse, type ApprovalStatus, AuditEmitter, type AuditEvent, BackupManager, type BotConfig, BreakerState, type BudgetCheck, type BudgetConfig, BudgetController, CORE_MIGRATIONS, ChannelAdapter, ChannelRegistry, ChannelRegistryError, type ChatConfig, ChatMessage, ChatResponderConfig, ChatSessionManager, CircuitBreaker, type CircuitBreakerConfig, CliExecutionAdapter, type ColumnValidator, ColumnValidatorImpl, type ConfigLoadError, type ConfigLoadResult, ConnectorConfig, DEFAULTS, DEFAULT_CONFIG, type DataConfig, DataStore, type DefaultLLMCallConfig, DeterministicAdapter, type DeterministicConfig, type DomainEntityContextOptions, type DomainSchemaOptions, DriftGate, EVENTS, type EntityColumnDef, type EntityConfig, type ExecutionAdapter, type ExecutionConfig, type ExecutionEngineConfig, type FeedbackEntry, type GateFinding, type GateInput, type GateResult, GateRunner, type GateVerdict, GovernanceGate, HealthStatus, HookBus, InboundMessage, LLMProvider, LearningPipeline, type LearningPipelineConfig, type LoopDetection, LoopDetector, type LoopDetectorConfig, LoopType, MAX_CHAIN_DEPTH, MessagePipeline, type ModelConfig, ModelInfo, ModelRouter, NdjsonLogger, NotificationQueue, type PackageMigration, type PackageUpdate, type ParsedStream, type PermissionPrompt, type PermissionProvider, PermissionRelay, type PermissionRelayConfig, type PlaybookEntry, ProviderRegistry, QAGate, QualityGate, RUN_STATUSES, type RenderConfig, ResolvedModel, type RetryPolicy, type RoutingConfig, type RunContext, RunManager, type RunResult, type RunStatus, type SafetyConfig, type SanitizerOptions, type Schedule, type ScheduleDef, Scheduler, type SchemaError, type SecretInput, type SecretMeta, SecretStore, type SecurityConfig, SessionKey, SessionManager, type SkillEntry, type StepRef, type SystemContextOptions, TASK_STATUSES, type TaskDefinition, TaskQueue, type TaskRecord, type TaskStatus, TokenUsage, type ToolContext, type ToolDefinition, type ToolHandler, UpdateChecker, type UpdateConfig, UpdateManager, type UpdateManifest, type UsageSummary, type User, type UserInput, UserRegistry, WakeupQueue, type WorkflowConfigEntry, type WorkflowDefinition$1 as WorkflowDefinition, WorkflowEngine, type WorkflowRunRecord, type WorkflowRunStatus, type WorkflowStep$1 as WorkflowStep, type WorkflowStepConfig, type WorkflowTrigger, _resetConfig, addTaskCommentTool, areDependenciesMet, autoUpdate, buildAgentBindings, buildChainOrigin, buildProcessEnv, buildSystemContext, cancelTaskTool, checkAllowlist, checkChainDepth, checkMentionGate, chunkText, classifyUpdate, compareVersions, createAgentTool, createConfigRevision, createDefaultLLMCall, createProjectTool, deactivateLocalImagePaths, defineCoreEntityContexts, defineCoreTables, defineDomainEntityContexts, defineDomainTables, detectCycle, discoverChannels, discoverProviders, dispatchTaskTool, formatText, getActiveTasksTool, getAgentDetailTool, getAgentStatusTool, getConfig, getSystemStatusTool, getTaskStatusTool, initConfig, interpolate, interpolateEnv, isLoginRequired, isMaxTurns, listAgentsTool, listFilesTool, listProjectsTool, loadConfig, nativeTools, parseClaudeStream, parseVersion, readConversationTool, readFileTool, reassignTaskTool, registerExecutionEngine, registerFileTool, runPackageMigrations, sanitize, searchConversationTool, sendFileTool, sendMessageTool, topologicalSort, truncateAtWord, validateConfig };
|
|
2284
|
+
export { AGENT_STATUSES, type AgentConfig, type AgentDefinition, type AgentFilter, type AgentRecord, AgentRegistry, type AgentStatus, ApiExecutionAdapter, type ApprovalResponse, type ApprovalStatus, AuditEmitter, type AuditEvent, BackupManager, type BotConfig, BreakerState, type BudgetCheck, type BudgetConfig, BudgetController, CORE_MIGRATIONS, ChannelAdapter, ChannelRegistry, ChannelRegistryError, type ChatConfig, ChatMessage, ChatPipelineV2, type ChatPipelineV2Config, ChatResponder, ChatResponderConfig, ChatSessionManager, CircuitBreaker, type CircuitBreakerConfig, CliExecutionAdapter, type ColumnValidator, ColumnValidatorImpl, type ConfigLoadError, type ConfigLoadResult, ConnectorConfig, DEFAULTS, DEFAULT_CONFIG, type DataConfig, DataStore, type DefaultLLMCallConfig, DeterministicAdapter, type DeterministicConfig, type DomainEntityContextOptions, type DomainSchemaOptions, DriftGate, EVENTS, type EntityColumnDef, type EntityConfig, type ExecutionAdapter, type ExecutionConfig, type ExecutionEngineConfig, Extractor, type FeedbackEntry, type GateFinding, type GateInput, type GateResult, GateRunner, type GateVerdict, GovernanceGate, HealthStatus, HookBus, InboundMessage, LLMProvider, LearningPipeline, type LearningPipelineConfig, type LoopDetection, LoopDetector, type LoopDetectorConfig, LoopType, MAX_CHAIN_DEPTH, MessageInterpreter, MessagePipeline, MessageStore, type ModelConfig, ModelInfo, ModelRouter, NdjsonLogger, NotificationQueue, type PackageMigration, type PackageUpdate, type ParsedStream, type PermissionPrompt, type PermissionProvider, PermissionRelay, type PermissionRelayConfig, type PlaybookEntry, ProviderRegistry, QAGate, QualityGate, RUN_STATUSES, type RenderConfig, ResolvedModel, type RetryPolicy, type RoutingConfig, type RunContext, RunManager, type RunResult, type RunStatus, type SafetyConfig, type SanitizerOptions, type Schedule, type ScheduleDef, Scheduler, type SchemaError, type SecretInput, type SecretMeta, SecretStore, type SecurityConfig, SessionKey, SessionManager, type SkillEntry, type StepRef, type SystemContextOptions, TASK_STATUSES, type TaskDefinition, TaskQueue, type TaskRecord, type TaskStatus, TokenUsage, type ToolContext, type ToolDefinition, type ToolHandler, UpdateChecker, type UpdateConfig, UpdateManager, type UpdateManifest, type UsageSummary, type User, type UserInput, UserRegistry, WakeupQueue, type WorkflowConfigEntry, type WorkflowDefinition$1 as WorkflowDefinition, WorkflowEngine, type WorkflowRunRecord, type WorkflowRunStatus, type WorkflowStep$1 as WorkflowStep, type WorkflowStepConfig, type WorkflowTrigger, _resetConfig, addTaskCommentTool, areDependenciesMet, autoUpdate, buildAgentBindings, buildChainOrigin, buildProcessEnv, buildSystemContext, cancelTaskTool, checkAllowlist, checkChainDepth, checkMentionGate, chunkText, classifyUpdate, compareVersions, coordinatorTools, createAgentTool, createConfigRevision, createDefaultLLMCall, createProjectTool, deactivateLocalImagePaths, defineCoreEntityContexts, defineCoreTables, defineDomainEntityContexts, defineDomainTables, detectCycle, discoverChannels, discoverProviders, dispatchTaskTool, formatText, getActiveTasksTool, getAgentDetailTool, getAgentStatusTool, getConfig, getSystemStatusTool, getTaskStatusTool, initConfig, interpolate, interpolateEnv, isLoginRequired, isMaxTurns, listAgentsTool, listFilesTool, listProjectsTool, loadConfig, nativeTools, parseClaudeStream, parseVersion, readConversationTool, readFileTool, reassignTaskTool, registerExecutionEngine, registerFileTool, runPackageMigrations, sanitize, searchConversationTool, sendFileTool, sendMessageTool, topologicalSort, truncateAtWord, validateConfig };
|