botinabox 2.9.1 → 2.9.3
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/README.md +2 -1
- package/bin/botinabox.mjs +1 -1
- package/dist/channels/discord/adapter.d.ts +32 -0
- package/dist/channels/discord/inbound.d.ts +25 -0
- package/dist/channels/discord/index.d.ts +8 -84
- package/dist/channels/discord/models.d.ts +8 -0
- package/dist/channels/discord/outbound.d.ts +14 -0
- package/dist/channels/slack/adapter.d.ts +33 -0
- package/dist/channels/slack/bolt-adapter.d.ts +31 -0
- package/dist/channels/slack/enrichers/enrich.d.ts +12 -0
- package/dist/channels/slack/enrichers/image-enricher.d.ts +10 -0
- package/dist/channels/slack/enrichers/index.d.ts +4 -0
- package/dist/channels/slack/enrichers/pdf-enricher.d.ts +8 -0
- package/dist/channels/slack/enrichers/types.d.ts +33 -0
- package/dist/channels/slack/inbound.d.ts +59 -0
- package/dist/channels/slack/index.d.ts +13 -252
- package/dist/channels/slack/media-type.d.ts +14 -0
- package/dist/channels/slack/models.d.ts +9 -0
- package/dist/channels/slack/outbound.d.ts +12 -0
- package/dist/channels/slack/transcribe.d.ts +41 -0
- package/dist/channels/webhook/adapter.d.ts +23 -0
- package/dist/channels/webhook/hmac.d.ts +13 -0
- package/dist/channels/webhook/index.d.ts +7 -70
- package/dist/channels/webhook/models.d.ts +9 -0
- package/dist/channels/webhook/server.d.ts +20 -0
- package/dist/cli/templates/config.yml.d.ts +7 -0
- package/dist/cli/templates/env.d.ts +1 -0
- package/dist/cli/templates/index.ts.d.ts +2 -0
- package/dist/cli/templates/package.json.d.ts +5 -0
- package/dist/cli.d.ts +1 -3
- package/dist/connectors/google/calendar-connector.d.ts +40 -0
- package/dist/connectors/google/drive-connector.d.ts +43 -0
- package/dist/connectors/google/drive-read.d.ts +81 -0
- package/dist/connectors/google/gmail-connector.d.ts +42 -0
- package/dist/connectors/google/index.d.ts +10 -369
- package/dist/connectors/google/oauth.d.ts +48 -0
- package/dist/connectors/google/types.d.ts +110 -0
- package/dist/core/chat/auto-discovery.d.ts +16 -0
- package/dist/core/chat/channel-registry.d.ts +45 -0
- package/dist/core/chat/chat-pipeline-v2.d.ts +138 -0
- package/dist/core/chat/chat-pipeline.d.ts +116 -0
- package/dist/core/chat/chat-responder.d.ts +94 -0
- package/dist/core/chat/formatter.d.ts +11 -0
- package/dist/core/chat/index.d.ts +26 -0
- package/dist/core/chat/message-interpreter.d.ts +91 -0
- package/dist/core/chat/message-store.d.ts +71 -0
- package/dist/core/chat/notification-queue.d.ts +34 -0
- package/dist/core/chat/pipeline.d.ts +38 -0
- package/dist/core/chat/policies.d.ts +16 -0
- package/dist/core/chat/routing.d.ts +17 -0
- package/dist/core/chat/session-key.d.ts +30 -0
- package/dist/core/chat/session-manager.d.ts +17 -0
- package/dist/core/chat/text-chunker.d.ts +9 -0
- package/dist/core/chat/triage-router.d.ts +75 -0
- package/dist/core/chat/types.d.ts +5 -0
- package/dist/core/config/defaults.d.ts +2 -0
- package/dist/core/config/index.d.ts +6 -0
- package/dist/core/config/interpolate.d.ts +5 -0
- package/dist/core/config/loader.d.ts +24 -0
- package/dist/core/config/schema.d.ts +5 -0
- package/dist/core/data/context-builder.d.ts +27 -0
- package/dist/core/data/core-entity-contexts.d.ts +14 -0
- package/dist/core/data/core-migrations.d.ts +5 -0
- package/dist/core/data/core-schema.d.ts +6 -0
- package/dist/core/data/data-store.d.ts +67 -0
- package/dist/core/data/domain-entity-contexts.d.ts +35 -0
- package/dist/core/data/domain-schema.d.ts +36 -0
- package/dist/core/data/index.d.ts +8 -0
- package/dist/core/data/types.d.ts +111 -0
- package/dist/core/hooks/hook-bus.d.ts +24 -0
- package/dist/core/hooks/index.d.ts +2 -0
- package/dist/core/hooks/types.d.ts +19 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/llm/auto-discovery.d.ts +11 -0
- package/dist/core/llm/cost-tracker.d.ts +6 -0
- package/dist/core/llm/default-llm-call.d.ts +35 -0
- package/dist/core/llm/index.d.ts +6 -0
- package/dist/core/llm/model-router.d.ts +25 -0
- package/dist/core/llm/provider-registry.d.ts +9 -0
- package/dist/core/llm/types.d.ts +2 -0
- package/dist/core/orchestrator/adapters/api-adapter.d.ts +34 -0
- package/dist/core/orchestrator/adapters/cli-adapter.d.ts +62 -0
- package/dist/core/orchestrator/adapters/deterministic-adapter.d.ts +35 -0
- package/dist/core/orchestrator/adapters/env-whitelist.d.ts +4 -0
- package/dist/core/orchestrator/adapters/output-extractor.d.ts +11 -0
- package/dist/core/orchestrator/adapters/process-manager.d.ts +15 -0
- package/dist/core/orchestrator/adapters/tool-loop.d.ts +22 -0
- package/dist/core/orchestrator/agent-registry.d.ts +31 -0
- package/dist/core/orchestrator/budget-controller.d.ts +19 -0
- package/dist/core/orchestrator/chain-guard.d.ts +14 -0
- package/dist/core/orchestrator/circuit-breaker.d.ts +65 -0
- package/dist/core/orchestrator/claude-stream-parser.d.ts +31 -0
- package/dist/core/orchestrator/config-revisions.d.ts +6 -0
- package/dist/core/orchestrator/dependency-resolver.d.ts +20 -0
- package/dist/core/orchestrator/execution-engine.d.ts +99 -0
- package/dist/core/orchestrator/governance-gate.d.ts +110 -0
- package/dist/core/orchestrator/learning-pipeline.d.ts +112 -0
- package/dist/core/orchestrator/loop-detector.d.ts +51 -0
- package/dist/core/orchestrator/ndjson-logger.d.ts +6 -0
- package/dist/core/orchestrator/permission-relay.d.ts +72 -0
- package/dist/core/orchestrator/run-manager.d.ts +31 -0
- package/dist/core/orchestrator/scheduler.d.ts +74 -0
- package/dist/core/orchestrator/secret-store.d.ts +57 -0
- package/dist/core/orchestrator/session-manager.d.ts +13 -0
- package/dist/core/orchestrator/task-queue.d.ts +34 -0
- package/dist/core/orchestrator/template-interpolate.d.ts +5 -0
- package/dist/core/orchestrator/tools/file-ops.d.ts +12 -0
- package/dist/core/orchestrator/tools/index.d.ts +47 -0
- package/dist/core/orchestrator/tools/management.d.ts +12 -0
- package/dist/core/orchestrator/tools/messaging.d.ts +21 -0
- package/dist/core/orchestrator/tools/read-file.d.ts +5 -0
- package/dist/core/orchestrator/tools/resolve-agent.d.ts +9 -0
- package/dist/core/orchestrator/tools/roster.d.ts +16 -0
- package/dist/core/orchestrator/tools/send-file.d.ts +5 -0
- package/dist/core/orchestrator/tools/status.d.ts +20 -0
- package/dist/core/orchestrator/tools/task-ops.d.ts +13 -0
- package/dist/core/orchestrator/user-registry.d.ts +47 -0
- package/dist/core/orchestrator/wakeup-queue.d.ts +9 -0
- package/dist/core/orchestrator/workflow-engine.d.ts +47 -0
- package/dist/core/security/audit.d.ts +20 -0
- package/dist/core/security/column-validator.d.ts +20 -0
- package/dist/core/security/index.d.ts +5 -0
- package/dist/core/security/process-env.d.ts +13 -0
- package/dist/core/security/sanitizer.d.ts +11 -0
- package/dist/core/security/types.d.ts +11 -0
- package/dist/core/update/auto-update.d.ts +21 -0
- package/dist/core/update/backup-manager.d.ts +7 -0
- package/dist/core/update/index.d.ts +8 -0
- package/dist/core/update/migration-hooks.d.ts +11 -0
- package/dist/core/update/types.d.ts +11 -0
- package/dist/core/update/update-checker.d.ts +11 -0
- package/dist/core/update/update-manager.d.ts +25 -0
- package/dist/core/update/version-utils.d.ts +6 -0
- package/dist/index.d.ts +38 -2366
- package/dist/index.js +117 -10
- package/dist/providers/anthropic/index.d.ts +5 -20
- package/dist/providers/anthropic/models.d.ts +2 -0
- package/dist/providers/anthropic/provider.d.ts +13 -0
- package/dist/providers/anthropic/tool-converter.d.ts +10 -0
- package/dist/providers/ollama/index.d.ts +4 -22
- package/dist/providers/ollama/provider.d.ts +17 -0
- package/dist/providers/openai/index.d.ts +5 -20
- package/dist/providers/openai/models.d.ts +2 -0
- package/dist/providers/openai/provider.d.ts +13 -0
- package/dist/providers/openai/tool-converter.d.ts +10 -0
- package/dist/shared/constants.d.ts +50 -0
- package/dist/shared/index.d.ts +14 -0
- package/dist/shared/types/agent.d.ts +36 -0
- package/dist/{channel-CVm1AWUF.d.ts → shared/types/channel.d.ts} +13 -17
- package/dist/shared/types/config.d.ts +160 -0
- package/dist/shared/types/connector.d.ts +77 -0
- package/dist/shared/types/execution.d.ts +29 -0
- package/dist/{provider-BHkqkSdq.d.ts → shared/types/provider.d.ts} +10 -12
- package/dist/shared/types/task.d.ts +47 -0
- package/dist/shared/types/workflow.d.ts +39 -0
- package/dist/shared/utils.d.ts +6 -0
- package/dist/update-check.d.ts +5 -0
- package/package.json +3 -3
- package/dist/channel-DziSPayj.d.ts +0 -73
- package/dist/chat-pipeline-BGgmH_ap.d.ts +0 -655
- package/dist/chat-pipeline-BWrtVqEP.d.ts +0 -652
- package/dist/chat-pipeline-aBSj7a4E.d.ts +0 -655
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LearningPipeline — turns execution experience into durable knowledge.
|
|
3
|
+
* Story 6.5
|
|
4
|
+
*
|
|
5
|
+
* Promotion ladder:
|
|
6
|
+
* Execution → Feedback (structured capture)
|
|
7
|
+
* → 3+ similar → Playbook (generalized rule)
|
|
8
|
+
* → 3+ projects → Skill (executable behavior)
|
|
9
|
+
* → Agent-Skill Matrix → Per-Agent Context
|
|
10
|
+
*
|
|
11
|
+
* Two-axis evaluation:
|
|
12
|
+
* - Accuracy: was the output correct?
|
|
13
|
+
* - Efficiency: how fast / how many tokens?
|
|
14
|
+
*/
|
|
15
|
+
import type { DataStore } from '../data/data-store.js';
|
|
16
|
+
import type { HookBus } from '../hooks/hook-bus.js';
|
|
17
|
+
export interface FeedbackEntry {
|
|
18
|
+
agentId: string;
|
|
19
|
+
userId?: string;
|
|
20
|
+
taskId?: string;
|
|
21
|
+
issue: string;
|
|
22
|
+
rootCause?: string;
|
|
23
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
24
|
+
repeatable: boolean;
|
|
25
|
+
accuracyScore?: number;
|
|
26
|
+
efficiencyScore?: number;
|
|
27
|
+
tags?: string[];
|
|
28
|
+
}
|
|
29
|
+
export interface PlaybookEntry {
|
|
30
|
+
pattern: string;
|
|
31
|
+
rule: string;
|
|
32
|
+
feedbackIds: string[];
|
|
33
|
+
projectScoped: boolean;
|
|
34
|
+
clientId?: string;
|
|
35
|
+
agentIds?: string[];
|
|
36
|
+
}
|
|
37
|
+
export interface SkillEntry {
|
|
38
|
+
name: string;
|
|
39
|
+
slug: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
behavior: string;
|
|
42
|
+
sourcePlaybookIds: string[];
|
|
43
|
+
category?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface LearningPipelineConfig {
|
|
46
|
+
/** Feedback count threshold for playbook promotion. Default: 3 */
|
|
47
|
+
playbookThreshold?: number;
|
|
48
|
+
/** Project count threshold for skill promotion. Default: 3 */
|
|
49
|
+
skillThreshold?: number;
|
|
50
|
+
/** Auto-promote when thresholds are met. Default: false */
|
|
51
|
+
autoPromote?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export declare class LearningPipeline {
|
|
54
|
+
private db;
|
|
55
|
+
private hooks;
|
|
56
|
+
private readonly playbookThreshold;
|
|
57
|
+
private readonly skillThreshold;
|
|
58
|
+
private readonly autoPromote;
|
|
59
|
+
constructor(db: DataStore, hooks: HookBus, config?: LearningPipelineConfig);
|
|
60
|
+
/**
|
|
61
|
+
* Capture a structured feedback record from an execution.
|
|
62
|
+
*/
|
|
63
|
+
captureFeedback(entry: FeedbackEntry): Promise<string>;
|
|
64
|
+
/**
|
|
65
|
+
* Get all feedback records, optionally filtered.
|
|
66
|
+
*/
|
|
67
|
+
listFeedback(filter?: {
|
|
68
|
+
agentId?: string;
|
|
69
|
+
userId?: string;
|
|
70
|
+
severity?: string;
|
|
71
|
+
repeatable?: boolean;
|
|
72
|
+
}): Promise<Array<Record<string, unknown>>>;
|
|
73
|
+
/**
|
|
74
|
+
* Check if feedback records with similar issues should be promoted to a playbook.
|
|
75
|
+
* Groups by issue text similarity (exact match for now).
|
|
76
|
+
*/
|
|
77
|
+
checkPlaybookPromotion(issue: string): Promise<string | undefined>;
|
|
78
|
+
/**
|
|
79
|
+
* Manually create a playbook from a set of feedback records.
|
|
80
|
+
*/
|
|
81
|
+
promoteToPlaybook(entry: PlaybookEntry): Promise<string>;
|
|
82
|
+
/**
|
|
83
|
+
* List playbooks, optionally filtered.
|
|
84
|
+
*/
|
|
85
|
+
listPlaybooks(filter?: {
|
|
86
|
+
projectScoped?: boolean;
|
|
87
|
+
}): Promise<Array<Record<string, unknown>>>;
|
|
88
|
+
/**
|
|
89
|
+
* Check if a playbook should be promoted to a skill.
|
|
90
|
+
* A playbook becomes a skill when it works across multiple projects
|
|
91
|
+
* (indicated by being referenced by agents in different contexts).
|
|
92
|
+
*/
|
|
93
|
+
checkSkillPromotion(playbookId: string): Promise<string | undefined>;
|
|
94
|
+
/**
|
|
95
|
+
* Manually promote a playbook to a reusable skill.
|
|
96
|
+
*/
|
|
97
|
+
promoteToSkill(entry: SkillEntry): Promise<string>;
|
|
98
|
+
/**
|
|
99
|
+
* Assign a skill to an agent.
|
|
100
|
+
*/
|
|
101
|
+
assignSkill(agentId: string, skillId: string): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Get learning metrics for an agent.
|
|
104
|
+
*/
|
|
105
|
+
getMetrics(agentId: string): Promise<{
|
|
106
|
+
feedbackCount: number;
|
|
107
|
+
avgAccuracy: number | null;
|
|
108
|
+
avgEfficiency: number | null;
|
|
109
|
+
playbookCount: number;
|
|
110
|
+
skillCount: number;
|
|
111
|
+
}>;
|
|
112
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LoopDetector — pattern-based loop detection for agent routing.
|
|
3
|
+
* Story 6.2
|
|
4
|
+
*
|
|
5
|
+
* Complements chain-guard's depth limit with active pattern detection:
|
|
6
|
+
* - Self-loop: agent routes a task back to itself
|
|
7
|
+
* - Ping-pong: two agents bounce tasks between each other (A→B→A→B)
|
|
8
|
+
* - Blocked re-entry: a task re-enters the system after being blocked
|
|
9
|
+
*/
|
|
10
|
+
import type { DataStore } from '../data/data-store.js';
|
|
11
|
+
export declare enum LoopType {
|
|
12
|
+
SELF_LOOP = "self_loop",
|
|
13
|
+
PING_PONG = "ping_pong",
|
|
14
|
+
BLOCKED_REENTRY = "blocked_reentry"
|
|
15
|
+
}
|
|
16
|
+
export interface LoopDetection {
|
|
17
|
+
type: LoopType;
|
|
18
|
+
agents: string[];
|
|
19
|
+
taskId: string;
|
|
20
|
+
chainOriginId?: string;
|
|
21
|
+
message: string;
|
|
22
|
+
}
|
|
23
|
+
export interface LoopDetectorConfig {
|
|
24
|
+
/** Number of recent followup records to scan. Default: 10 */
|
|
25
|
+
windowSize?: number;
|
|
26
|
+
/** Minimum repetitions to confirm ping-pong. Default: 2 */
|
|
27
|
+
pingPongThreshold?: number;
|
|
28
|
+
}
|
|
29
|
+
export declare class LoopDetector {
|
|
30
|
+
private db;
|
|
31
|
+
private readonly windowSize;
|
|
32
|
+
private readonly pingPongThreshold;
|
|
33
|
+
constructor(db: DataStore, config?: LoopDetectorConfig);
|
|
34
|
+
/**
|
|
35
|
+
* Check for loops before creating a followup task.
|
|
36
|
+
* Returns a LoopDetection if a loop pattern is found, undefined otherwise.
|
|
37
|
+
*/
|
|
38
|
+
check(sourceAgentId: string, targetAgentId: string, taskId: string, chainOriginId?: string): Promise<LoopDetection | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Check if an agent is routing to itself.
|
|
41
|
+
*/
|
|
42
|
+
private checkSelfLoop;
|
|
43
|
+
/**
|
|
44
|
+
* Check if a previously blocked task is being re-entered.
|
|
45
|
+
*/
|
|
46
|
+
private checkBlockedReentry;
|
|
47
|
+
/**
|
|
48
|
+
* Check for A→B→A→B ping-pong by scanning recent tasks in the chain.
|
|
49
|
+
*/
|
|
50
|
+
private checkPingPong;
|
|
51
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PermissionRelay — remote approval for unattended agent execution.
|
|
3
|
+
* Story 6.6
|
|
4
|
+
*
|
|
5
|
+
* When an agent needs human approval but the operator is away:
|
|
6
|
+
* 1. Post the approval prompt to a messaging platform (Slack, Discord, etc.)
|
|
7
|
+
* 2. Poll for response (approve/deny)
|
|
8
|
+
* 3. Relay the decision back to the agent
|
|
9
|
+
*
|
|
10
|
+
* Dual approval: local terminal + remote messaging. First response wins.
|
|
11
|
+
* Race condition handled by atomic state transition.
|
|
12
|
+
*/
|
|
13
|
+
import type { HookBus } from '../hooks/hook-bus.js';
|
|
14
|
+
export type ApprovalStatus = 'pending' | 'approved' | 'denied' | 'expired';
|
|
15
|
+
export interface PermissionPrompt {
|
|
16
|
+
id: string;
|
|
17
|
+
agentId: string;
|
|
18
|
+
action: string;
|
|
19
|
+
context?: string;
|
|
20
|
+
requestedAt: string;
|
|
21
|
+
expiresAt?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ApprovalResponse {
|
|
24
|
+
promptId: string;
|
|
25
|
+
status: 'approved' | 'denied';
|
|
26
|
+
respondedBy: string;
|
|
27
|
+
respondedAt: string;
|
|
28
|
+
comment?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Provider interface — implement for each messaging platform.
|
|
32
|
+
*/
|
|
33
|
+
export interface PermissionProvider {
|
|
34
|
+
readonly id: string;
|
|
35
|
+
/** Post an approval request, return a handle for polling. */
|
|
36
|
+
sendPrompt(prompt: PermissionPrompt): Promise<string>;
|
|
37
|
+
/** Check for a response. Returns undefined if still pending. */
|
|
38
|
+
pollResponse(handle: string): Promise<ApprovalResponse | undefined>;
|
|
39
|
+
/** Cancel a pending prompt (e.g. after local approval). */
|
|
40
|
+
cancelPrompt(handle: string): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
export interface PermissionRelayConfig {
|
|
43
|
+
/** Registered providers (e.g. Slack, Discord adapters) */
|
|
44
|
+
providers: PermissionProvider[];
|
|
45
|
+
/** Poll interval in ms. Default: 5000 */
|
|
46
|
+
pollIntervalMs?: number;
|
|
47
|
+
/** Timeout for pending approvals in ms. Default: 300_000 (5 min) */
|
|
48
|
+
timeoutMs?: number;
|
|
49
|
+
}
|
|
50
|
+
export declare class PermissionRelay {
|
|
51
|
+
private hooks;
|
|
52
|
+
private readonly providers;
|
|
53
|
+
private readonly pollIntervalMs;
|
|
54
|
+
private readonly timeoutMs;
|
|
55
|
+
private readonly pending;
|
|
56
|
+
constructor(hooks: HookBus, config: PermissionRelayConfig);
|
|
57
|
+
/**
|
|
58
|
+
* Request approval from all configured providers.
|
|
59
|
+
* Returns when the first provider responds (approve or deny).
|
|
60
|
+
*/
|
|
61
|
+
requestApproval(prompt: PermissionPrompt): Promise<ApprovalResponse>;
|
|
62
|
+
/**
|
|
63
|
+
* Provide a local approval (from terminal).
|
|
64
|
+
* Resolves the pending request and cancels remote providers.
|
|
65
|
+
*/
|
|
66
|
+
approveLocally(promptId: string, approved: boolean): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Get all pending approval requests.
|
|
69
|
+
*/
|
|
70
|
+
getPending(): PermissionPrompt[];
|
|
71
|
+
private cancelOtherProviders;
|
|
72
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { DataStore } from '../data/data-store.js';
|
|
2
|
+
import type { HookBus } from '../hooks/hook-bus.js';
|
|
3
|
+
import type { CircuitBreaker } from './circuit-breaker.js';
|
|
4
|
+
export declare class RunManager {
|
|
5
|
+
private db;
|
|
6
|
+
private hooks;
|
|
7
|
+
private config?;
|
|
8
|
+
private locks;
|
|
9
|
+
private orphanTimer;
|
|
10
|
+
private readonly staleThresholdMs;
|
|
11
|
+
private circuitBreaker?;
|
|
12
|
+
constructor(db: DataStore, hooks: HookBus, config?: {
|
|
13
|
+
staleThresholdMs?: number;
|
|
14
|
+
maxBackoffMs?: number;
|
|
15
|
+
} | undefined);
|
|
16
|
+
/**
|
|
17
|
+
* Attach a CircuitBreaker to prevent retries on broken agents.
|
|
18
|
+
*/
|
|
19
|
+
setCircuitBreaker(cb: CircuitBreaker): void;
|
|
20
|
+
isLocked(agentId: string): boolean;
|
|
21
|
+
startRun(agentId: string, taskId: string, adapter?: string): Promise<string>;
|
|
22
|
+
finishRun(runId: string, result: {
|
|
23
|
+
exitCode: number;
|
|
24
|
+
output?: string;
|
|
25
|
+
costCents?: number;
|
|
26
|
+
usage?: unknown;
|
|
27
|
+
}): Promise<void>;
|
|
28
|
+
reapOrphans(): Promise<void>;
|
|
29
|
+
startOrphanReaper(intervalMs?: number): void;
|
|
30
|
+
stopOrphanReaper(): void;
|
|
31
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scheduler — database-backed job scheduling with cron expressions.
|
|
3
|
+
*
|
|
4
|
+
* Supports one-time and recurring schedules. When a schedule fires,
|
|
5
|
+
* it emits the schedule's `action` as a hook event with the
|
|
6
|
+
* `action_config` payload. Consumers subscribe to handle the action.
|
|
7
|
+
*
|
|
8
|
+
* Supports one-time and recurring use cases.
|
|
9
|
+
*/
|
|
10
|
+
import type { DataStore } from "../data/data-store.js";
|
|
11
|
+
import type { HookBus } from "../hooks/hook-bus.js";
|
|
12
|
+
import type { CircuitBreaker } from "./circuit-breaker.js";
|
|
13
|
+
export interface ScheduleDef {
|
|
14
|
+
name: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
/** Cron expression for recurring schedules */
|
|
17
|
+
cron?: string;
|
|
18
|
+
/** ISO 8601 datetime for one-time schedules */
|
|
19
|
+
runAt?: string;
|
|
20
|
+
/** Hook event name to emit when fired */
|
|
21
|
+
action: string;
|
|
22
|
+
/** JSON-serializable payload passed to the hook */
|
|
23
|
+
actionConfig?: Record<string, unknown>;
|
|
24
|
+
timezone?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface Schedule {
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
description: string | null;
|
|
30
|
+
type: "one_time" | "recurring";
|
|
31
|
+
cron: string | null;
|
|
32
|
+
run_at: string | null;
|
|
33
|
+
timezone: string;
|
|
34
|
+
enabled: number;
|
|
35
|
+
action: string;
|
|
36
|
+
action_config: string;
|
|
37
|
+
last_fired_at: string | null;
|
|
38
|
+
next_fire_at: string | null;
|
|
39
|
+
created_at: string;
|
|
40
|
+
updated_at: string;
|
|
41
|
+
deleted_at: string | null;
|
|
42
|
+
}
|
|
43
|
+
export declare class Scheduler {
|
|
44
|
+
private db;
|
|
45
|
+
private hooks;
|
|
46
|
+
private timer;
|
|
47
|
+
private breaker?;
|
|
48
|
+
constructor(db: DataStore, hooks: HookBus);
|
|
49
|
+
/** Wire a CircuitBreaker for connector.sync actions. */
|
|
50
|
+
setCircuitBreaker(cb: CircuitBreaker): void;
|
|
51
|
+
/**
|
|
52
|
+
* Start the scheduler. Computes initial next_fire_at for schedules
|
|
53
|
+
* that don't have one, then polls for due schedules.
|
|
54
|
+
*/
|
|
55
|
+
start(pollIntervalMs?: number): Promise<void>;
|
|
56
|
+
stop(): void;
|
|
57
|
+
/** Check for and fire due schedules. */
|
|
58
|
+
tick(): Promise<void>;
|
|
59
|
+
/** Register a new schedule. */
|
|
60
|
+
register(def: ScheduleDef): Promise<string>;
|
|
61
|
+
/** Update an existing schedule. */
|
|
62
|
+
update(id: string, changes: Partial<Pick<ScheduleDef, "name" | "cron" | "runAt" | "action" | "actionConfig" | "timezone" | "description">> & {
|
|
63
|
+
enabled?: boolean;
|
|
64
|
+
}): Promise<void>;
|
|
65
|
+
/** Soft-delete a schedule. */
|
|
66
|
+
unregister(id: string): Promise<void>;
|
|
67
|
+
/** List schedules, optionally filtered. */
|
|
68
|
+
list(filter?: {
|
|
69
|
+
enabled?: boolean;
|
|
70
|
+
action?: string;
|
|
71
|
+
}): Promise<Schedule[]>;
|
|
72
|
+
/** Compute next_fire_at for any enabled schedule missing it. */
|
|
73
|
+
private initializeNextFireTimes;
|
|
74
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { DataStore } from "../data/data-store.js";
|
|
2
|
+
import type { HookBus } from "../hooks/hook-bus.js";
|
|
3
|
+
export interface SecretInput {
|
|
4
|
+
name: string;
|
|
5
|
+
type?: string;
|
|
6
|
+
environment?: string;
|
|
7
|
+
value?: string;
|
|
8
|
+
location?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
rotation_schedule?: string;
|
|
11
|
+
expires_at?: string;
|
|
12
|
+
notes?: string;
|
|
13
|
+
org_id?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface SecretMeta {
|
|
16
|
+
id: string;
|
|
17
|
+
org_id: string | null;
|
|
18
|
+
name: string;
|
|
19
|
+
type: string;
|
|
20
|
+
environment: string;
|
|
21
|
+
location: string | null;
|
|
22
|
+
description: string | null;
|
|
23
|
+
rotation_schedule: string | null;
|
|
24
|
+
expires_at: string | null;
|
|
25
|
+
notes: string | null;
|
|
26
|
+
created_at: string;
|
|
27
|
+
updated_at: string;
|
|
28
|
+
}
|
|
29
|
+
export declare class SecretStore {
|
|
30
|
+
private readonly db;
|
|
31
|
+
private readonly hooks;
|
|
32
|
+
private readonly encKey;
|
|
33
|
+
/**
|
|
34
|
+
* @param db - DataStore instance
|
|
35
|
+
* @param hooks - HookBus instance
|
|
36
|
+
* @param encryptionKey - Optional master key for encrypting secrets at rest.
|
|
37
|
+
* When provided, all new secrets are encrypted with AES-256-GCM.
|
|
38
|
+
* Existing plaintext secrets are read transparently (passthrough on decrypt).
|
|
39
|
+
*/
|
|
40
|
+
constructor(db: DataStore, hooks: HookBus, encryptionKey?: string);
|
|
41
|
+
set(input: SecretInput): Promise<SecretMeta>;
|
|
42
|
+
get(name: string, environment?: string): Promise<string | null>;
|
|
43
|
+
getMeta(name: string, environment?: string): Promise<SecretMeta | null>;
|
|
44
|
+
list(): Promise<SecretMeta[]>;
|
|
45
|
+
rotate(name: string, newValue: string, environment?: string): Promise<void>;
|
|
46
|
+
delete(name: string, environment?: string): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Load a sync cursor by key. Returns undefined if not found.
|
|
49
|
+
* Cursors are stored as secrets with type='sync_cursor'.
|
|
50
|
+
*/
|
|
51
|
+
loadCursor(key: string): Promise<string | undefined>;
|
|
52
|
+
/**
|
|
53
|
+
* Persist a sync cursor by key. Creates or updates the secret.
|
|
54
|
+
*/
|
|
55
|
+
saveCursor(key: string, value: string): Promise<void>;
|
|
56
|
+
private _toMeta;
|
|
57
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DataStore } from '../data/data-store.js';
|
|
2
|
+
export declare class SessionManager {
|
|
3
|
+
private db;
|
|
4
|
+
constructor(db: DataStore);
|
|
5
|
+
save(agentId: string, channelId: string, peerId: string, params: Record<string, unknown>): Promise<string>;
|
|
6
|
+
load(agentId: string, channelId: string, peerId: string): Promise<Record<string, unknown> | undefined>;
|
|
7
|
+
clear(agentId: string, channelId: string, peerId: string): Promise<void>;
|
|
8
|
+
shouldClear(session: Record<string, unknown>, opts: {
|
|
9
|
+
maxRuns?: number;
|
|
10
|
+
maxAgeHours?: number;
|
|
11
|
+
}): Promise<boolean>;
|
|
12
|
+
private _find;
|
|
13
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { DataStore } from '../data/data-store.js';
|
|
2
|
+
import type { HookBus } from '../hooks/hook-bus.js';
|
|
3
|
+
import { MAX_CHAIN_DEPTH } from './chain-guard.js';
|
|
4
|
+
export { MAX_CHAIN_DEPTH };
|
|
5
|
+
export declare class TaskQueue {
|
|
6
|
+
private db;
|
|
7
|
+
private hooks;
|
|
8
|
+
private config?;
|
|
9
|
+
private pollTimer;
|
|
10
|
+
private readonly pollIntervalMs;
|
|
11
|
+
private readonly staleThresholdMs;
|
|
12
|
+
constructor(db: DataStore, hooks: HookBus, config?: {
|
|
13
|
+
pollIntervalMs?: number;
|
|
14
|
+
staleThresholdMs?: number;
|
|
15
|
+
} | undefined);
|
|
16
|
+
create(task: {
|
|
17
|
+
title: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
assignee_id?: string;
|
|
20
|
+
priority?: number;
|
|
21
|
+
chain_depth?: number;
|
|
22
|
+
chain_origin_id?: string;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}): Promise<string>;
|
|
25
|
+
update(id: string, changes: Record<string, unknown>): Promise<void>;
|
|
26
|
+
get(id: string): Promise<Record<string, unknown> | undefined>;
|
|
27
|
+
list(filter?: {
|
|
28
|
+
status?: string;
|
|
29
|
+
assignee_id?: string;
|
|
30
|
+
}): Promise<Record<string, unknown>[]>;
|
|
31
|
+
startPolling(): void;
|
|
32
|
+
stopPolling(): void;
|
|
33
|
+
private poll;
|
|
34
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in tools: File operations — list, register, send, read.
|
|
3
|
+
*/
|
|
4
|
+
import type { ToolDefinition, ToolHandler } from '../execution-engine.js';
|
|
5
|
+
export declare const listFilesTool: {
|
|
6
|
+
definition: ToolDefinition;
|
|
7
|
+
handler: ToolHandler;
|
|
8
|
+
};
|
|
9
|
+
export declare const registerFileTool: {
|
|
10
|
+
definition: ToolDefinition;
|
|
11
|
+
handler: ToolHandler;
|
|
12
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in tools for the ExecutionEngine.
|
|
3
|
+
* 20 tools across 6 modules. All channel-agnostic.
|
|
4
|
+
*/
|
|
5
|
+
import type { ToolDefinition, ToolHandler } from '../execution-engine.js';
|
|
6
|
+
import { sendFileTool } from './send-file.js';
|
|
7
|
+
import { readFileTool } from './read-file.js';
|
|
8
|
+
import { listFilesTool, registerFileTool } from './file-ops.js';
|
|
9
|
+
import { dispatchTaskTool, cancelTaskTool, reassignTaskTool } from './task-ops.js';
|
|
10
|
+
import { getTaskStatusTool, getAgentStatusTool, getSystemStatusTool, getActiveTasksTool } from './status.js';
|
|
11
|
+
import { listAgentsTool, listProjectsTool, getAgentDetailTool } from './roster.js';
|
|
12
|
+
import { sendMessageTool, addTaskCommentTool, readConversationTool, searchConversationTool } from './messaging.js';
|
|
13
|
+
import { resolveAgent } from './resolve-agent.js';
|
|
14
|
+
import { createAgentTool, createProjectTool } from './management.js';
|
|
15
|
+
export { sendFileTool, readFileTool, listFilesTool, registerFileTool, dispatchTaskTool, cancelTaskTool, reassignTaskTool, getTaskStatusTool, getAgentStatusTool, getSystemStatusTool, getActiveTasksTool, listAgentsTool, listProjectsTool, getAgentDetailTool, sendMessageTool, addTaskCommentTool, readConversationTool, searchConversationTool, createAgentTool, createProjectTool, resolveAgent, };
|
|
16
|
+
/**
|
|
17
|
+
* All native tools bundled for convenience.
|
|
18
|
+
* Apps can pass this directly to ExecutionEngine config:
|
|
19
|
+
* tools: nativeTools
|
|
20
|
+
* or spread to add custom tools:
|
|
21
|
+
* tools: [...nativeTools, myCustomTool]
|
|
22
|
+
*/
|
|
23
|
+
export declare const nativeTools: {
|
|
24
|
+
definition: ToolDefinition;
|
|
25
|
+
handler: ToolHandler;
|
|
26
|
+
}[];
|
|
27
|
+
/**
|
|
28
|
+
* Coordinator tools for multi-agent primary agent.
|
|
29
|
+
* Orchestration + communication + awareness — no "work" tools.
|
|
30
|
+
* Use with ChatPipelineV2 in multi-agent mode.
|
|
31
|
+
*
|
|
32
|
+
* Single-agent mode should use `nativeTools` instead (all tools).
|
|
33
|
+
*/
|
|
34
|
+
export declare const coordinatorTools: {
|
|
35
|
+
definition: ToolDefinition;
|
|
36
|
+
handler: ToolHandler;
|
|
37
|
+
}[];
|
|
38
|
+
export type Tool = {
|
|
39
|
+
definition: ToolDefinition;
|
|
40
|
+
handler: ToolHandler;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Merge multiple tool sets into a single array with unique names.
|
|
44
|
+
* Later tool sets override earlier ones — consumer tools win over built-ins.
|
|
45
|
+
* Logs a warning on each override so the collision is visible in logs.
|
|
46
|
+
*/
|
|
47
|
+
export declare function mergeTools(...toolSets: ReadonlyArray<ReadonlyArray<Tool>>): Tool[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in tools: Entity creation — agents, projects.
|
|
3
|
+
*/
|
|
4
|
+
import type { ToolDefinition, ToolHandler } from '../execution-engine.js';
|
|
5
|
+
export declare const createAgentTool: {
|
|
6
|
+
definition: ToolDefinition;
|
|
7
|
+
handler: ToolHandler;
|
|
8
|
+
};
|
|
9
|
+
export declare const createProjectTool: {
|
|
10
|
+
definition: ToolDefinition;
|
|
11
|
+
handler: ToolHandler;
|
|
12
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in tools: Communication — send messages, read conversations, search history.
|
|
3
|
+
* All messaging is channel-agnostic: slack, email, discord, sms — same tools.
|
|
4
|
+
*/
|
|
5
|
+
import type { ToolDefinition, ToolHandler } from '../execution-engine.js';
|
|
6
|
+
export declare const sendMessageTool: {
|
|
7
|
+
definition: ToolDefinition;
|
|
8
|
+
handler: ToolHandler;
|
|
9
|
+
};
|
|
10
|
+
export declare const addTaskCommentTool: {
|
|
11
|
+
definition: ToolDefinition;
|
|
12
|
+
handler: ToolHandler;
|
|
13
|
+
};
|
|
14
|
+
export declare const readConversationTool: {
|
|
15
|
+
definition: ToolDefinition;
|
|
16
|
+
handler: ToolHandler;
|
|
17
|
+
};
|
|
18
|
+
export declare const searchConversationTool: {
|
|
19
|
+
definition: ToolDefinition;
|
|
20
|
+
handler: ToolHandler;
|
|
21
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared agent resolution: slug → role → name (case-insensitive).
|
|
3
|
+
*
|
|
4
|
+
* LLMs see list_agents output like "AgentName (role)" and naturally use
|
|
5
|
+
* the role as the identifier. All agent-resolving tools must accept
|
|
6
|
+
* slug, role, OR name — not just slug.
|
|
7
|
+
*/
|
|
8
|
+
import type { DataStore } from '../../data/data-store.js';
|
|
9
|
+
export declare function resolveAgent(db: DataStore, ref: string): Promise<Record<string, unknown> | null>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in tools: Entity lookup — agents, projects, details.
|
|
3
|
+
*/
|
|
4
|
+
import type { ToolDefinition, ToolHandler } from '../execution-engine.js';
|
|
5
|
+
export declare const listAgentsTool: {
|
|
6
|
+
definition: ToolDefinition;
|
|
7
|
+
handler: ToolHandler;
|
|
8
|
+
};
|
|
9
|
+
export declare const listProjectsTool: {
|
|
10
|
+
definition: ToolDefinition;
|
|
11
|
+
handler: ToolHandler;
|
|
12
|
+
};
|
|
13
|
+
export declare const getAgentDetailTool: {
|
|
14
|
+
definition: ToolDefinition;
|
|
15
|
+
handler: ToolHandler;
|
|
16
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in tools: System awareness — task status, agent status, system health.
|
|
3
|
+
*/
|
|
4
|
+
import type { ToolDefinition, ToolHandler } from '../execution-engine.js';
|
|
5
|
+
export declare const getTaskStatusTool: {
|
|
6
|
+
definition: ToolDefinition;
|
|
7
|
+
handler: ToolHandler;
|
|
8
|
+
};
|
|
9
|
+
export declare const getAgentStatusTool: {
|
|
10
|
+
definition: ToolDefinition;
|
|
11
|
+
handler: ToolHandler;
|
|
12
|
+
};
|
|
13
|
+
export declare const getSystemStatusTool: {
|
|
14
|
+
definition: ToolDefinition;
|
|
15
|
+
handler: ToolHandler;
|
|
16
|
+
};
|
|
17
|
+
export declare const getActiveTasksTool: {
|
|
18
|
+
definition: ToolDefinition;
|
|
19
|
+
handler: ToolHandler;
|
|
20
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ToolDefinition, ToolHandler } from '../execution-engine.js';
|
|
2
|
+
export declare const dispatchTaskTool: {
|
|
3
|
+
definition: ToolDefinition;
|
|
4
|
+
handler: ToolHandler;
|
|
5
|
+
};
|
|
6
|
+
export declare const cancelTaskTool: {
|
|
7
|
+
definition: ToolDefinition;
|
|
8
|
+
handler: ToolHandler;
|
|
9
|
+
};
|
|
10
|
+
export declare const reassignTaskTool: {
|
|
11
|
+
definition: ToolDefinition;
|
|
12
|
+
handler: ToolHandler;
|
|
13
|
+
};
|