ohwow 0.1.12 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +17 -17
- package/README.md +120 -166
- package/dist/api.d.ts +91 -0
- package/dist/api.js +2 -0
- package/dist/index.d.ts +1 -90
- package/dist/index.js +1754 -588
- package/dist/mcp-server/index.js +10 -49
- package/dist/migrations/001-data-plane-tables.sql +1 -1
- package/dist/migrations/002-agents-table.sql +1 -1
- package/dist/migrations/017-openclaw-call-logs.sql +15 -0
- package/dist/migrations/038-peer-queue-tracking.sql +5 -0
- package/dist/migrations/039-task-delegation.sql +5 -0
- package/dist/migrations/040-self-improvement-tables.sql +109 -0
- package/dist/migrations/041-session-metadata.sql +3 -0
- package/dist/migrations/042-memory-sync.sql +45 -0
- package/dist/migrations/043-multi-connection.sql +18 -0
- package/dist/migrations/044-multi-connection-fixes.sql +32 -0
- package/dist/migrations/045-task-state.sql +21 -0
- package/dist/migrations/046-state-changelog.sql +18 -0
- package/dist/migrations/047-outbound-queue.sql +9 -0
- package/dist/migrations/048-tasks-column-alignment.sql +37 -0
- package/dist/migrations/049-agents-column-alignment.sql +25 -0
- package/dist/migrations/050-workflows-trigger-alignment.sql +25 -0
- package/dist/migrations/051-execution-engine-tables.sql +132 -0
- package/dist/migrations/052-a2a-rate-limit-alignment.sql +8 -0
- package/dist/migrations/053-llm-cache.sql +20 -0
- package/dist/migrations/054-task-checkpoints.sql +13 -0
- package/dist/migrations/055-resource-usage.sql +12 -0
- package/dist/migrations/056-sandbox-tables.sql +35 -0
- package/dist/web/assets/{index-DSojxPLI.css → index-1Wga6dwZ.css} +1 -1
- package/dist/web/assets/{index-D6DkPUkA.js → index-BHeLTE3N.js} +26 -26
- package/dist/web/index.html +2 -2
- package/package.json +59 -14
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
--
|
|
1
|
+
-- Local Runtime: Agents table (mirrors cloud schema for service compatibility)
|
|
2
2
|
-- This allows shared services to query agent_workforce_agents locally.
|
|
3
3
|
|
|
4
4
|
CREATE TABLE IF NOT EXISTS agent_workforce_agents (
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
-- OpenClaw skill call audit log
|
|
2
|
+
CREATE TABLE IF NOT EXISTS openclaw_call_logs (
|
|
3
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
4
|
+
timestamp TEXT NOT NULL,
|
|
5
|
+
skill_id TEXT NOT NULL,
|
|
6
|
+
agent_id TEXT NOT NULL,
|
|
7
|
+
input TEXT NOT NULL DEFAULT '',
|
|
8
|
+
output TEXT NOT NULL DEFAULT '',
|
|
9
|
+
duration_ms INTEGER NOT NULL DEFAULT 0,
|
|
10
|
+
success INTEGER NOT NULL DEFAULT 0,
|
|
11
|
+
error TEXT
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
CREATE INDEX IF NOT EXISTS idx_openclaw_call_logs_skill ON openclaw_call_logs(skill_id);
|
|
15
|
+
CREATE INDEX IF NOT EXISTS idx_openclaw_call_logs_timestamp ON openclaw_call_logs(timestamp);
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
-- Self-Improvement Tables (E13-E27)
|
|
2
|
+
-- Supports the self-improvement subsystem: routing stats, skills,
|
|
3
|
+
-- principles, digital twin, practice sessions, discovered processes,
|
|
4
|
+
-- proactive runs, and action journal.
|
|
5
|
+
|
|
6
|
+
-- E14: Thompson Sampling routing stats
|
|
7
|
+
CREATE TABLE IF NOT EXISTS agent_workforce_routing_stats (
|
|
8
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
9
|
+
workspace_id TEXT NOT NULL,
|
|
10
|
+
agent_id TEXT NOT NULL,
|
|
11
|
+
task_type TEXT NOT NULL,
|
|
12
|
+
attempts INTEGER NOT NULL DEFAULT 0,
|
|
13
|
+
successes INTEGER NOT NULL DEFAULT 0,
|
|
14
|
+
success_rate REAL NOT NULL DEFAULT 0,
|
|
15
|
+
avg_truth_score REAL DEFAULT 0,
|
|
16
|
+
avg_cost_cents REAL DEFAULT 0,
|
|
17
|
+
created_at TEXT DEFAULT (datetime('now')),
|
|
18
|
+
updated_at TEXT DEFAULT (datetime('now')),
|
|
19
|
+
UNIQUE(workspace_id, agent_id, task_type)
|
|
20
|
+
);
|
|
21
|
+
CREATE INDEX IF NOT EXISTS idx_routing_stats_workspace ON agent_workforce_routing_stats(workspace_id, task_type);
|
|
22
|
+
|
|
23
|
+
-- E22: Synthesized skills
|
|
24
|
+
CREATE TABLE IF NOT EXISTS agent_workforce_skills (
|
|
25
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
26
|
+
workspace_id TEXT NOT NULL,
|
|
27
|
+
name TEXT NOT NULL,
|
|
28
|
+
description TEXT,
|
|
29
|
+
skill_type TEXT NOT NULL DEFAULT 'procedure',
|
|
30
|
+
source_type TEXT NOT NULL DEFAULT 'synthesized',
|
|
31
|
+
definition TEXT NOT NULL DEFAULT '{}',
|
|
32
|
+
agent_ids TEXT NOT NULL DEFAULT '[]',
|
|
33
|
+
pattern_support INTEGER DEFAULT 0,
|
|
34
|
+
is_active INTEGER NOT NULL DEFAULT 1,
|
|
35
|
+
created_at TEXT DEFAULT (datetime('now')),
|
|
36
|
+
updated_at TEXT DEFAULT (datetime('now'))
|
|
37
|
+
);
|
|
38
|
+
CREATE INDEX IF NOT EXISTS idx_skills_workspace ON agent_workforce_skills(workspace_id, is_active);
|
|
39
|
+
|
|
40
|
+
-- E24: Digital twin causal model snapshots
|
|
41
|
+
CREATE TABLE IF NOT EXISTS agent_workforce_digital_twin_snapshots (
|
|
42
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
43
|
+
workspace_id TEXT NOT NULL,
|
|
44
|
+
causal_graph TEXT NOT NULL DEFAULT '{}',
|
|
45
|
+
metrics_snapshot TEXT NOT NULL DEFAULT '[]',
|
|
46
|
+
confidence REAL DEFAULT 0,
|
|
47
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
48
|
+
);
|
|
49
|
+
CREATE INDEX IF NOT EXISTS idx_twin_snapshots_workspace ON agent_workforce_digital_twin_snapshots(workspace_id, created_at DESC);
|
|
50
|
+
|
|
51
|
+
-- E25: Practice sessions
|
|
52
|
+
CREATE TABLE IF NOT EXISTS agent_workforce_practice_sessions (
|
|
53
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
54
|
+
workspace_id TEXT NOT NULL,
|
|
55
|
+
agent_id TEXT NOT NULL,
|
|
56
|
+
source_task_id TEXT,
|
|
57
|
+
scenario TEXT NOT NULL DEFAULT '{}',
|
|
58
|
+
result TEXT,
|
|
59
|
+
verification_score REAL,
|
|
60
|
+
learnings_extracted INTEGER DEFAULT 0,
|
|
61
|
+
cost_cents REAL DEFAULT 0,
|
|
62
|
+
status TEXT NOT NULL DEFAULT 'pending',
|
|
63
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
64
|
+
);
|
|
65
|
+
CREATE INDEX IF NOT EXISTS idx_practice_workspace ON agent_workforce_practice_sessions(workspace_id, agent_id);
|
|
66
|
+
|
|
67
|
+
-- E26: Strategic principles
|
|
68
|
+
CREATE TABLE IF NOT EXISTS agent_workforce_principles (
|
|
69
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
70
|
+
workspace_id TEXT NOT NULL,
|
|
71
|
+
agent_id TEXT,
|
|
72
|
+
rule TEXT NOT NULL,
|
|
73
|
+
category TEXT NOT NULL DEFAULT 'strategy',
|
|
74
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
75
|
+
utility_score REAL NOT NULL DEFAULT 0,
|
|
76
|
+
source_memory_ids TEXT NOT NULL DEFAULT '[]',
|
|
77
|
+
times_applied INTEGER NOT NULL DEFAULT 0,
|
|
78
|
+
is_active INTEGER NOT NULL DEFAULT 1,
|
|
79
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
80
|
+
);
|
|
81
|
+
CREATE INDEX IF NOT EXISTS idx_principles_workspace ON agent_workforce_principles(workspace_id, is_active);
|
|
82
|
+
|
|
83
|
+
-- E27: Discovered processes
|
|
84
|
+
CREATE TABLE IF NOT EXISTS agent_workforce_discovered_processes (
|
|
85
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
86
|
+
workspace_id TEXT NOT NULL,
|
|
87
|
+
name TEXT NOT NULL,
|
|
88
|
+
description TEXT,
|
|
89
|
+
steps TEXT NOT NULL DEFAULT '[]',
|
|
90
|
+
frequency INTEGER NOT NULL DEFAULT 0,
|
|
91
|
+
avg_duration_ms INTEGER DEFAULT 0,
|
|
92
|
+
involved_agent_ids TEXT NOT NULL DEFAULT '[]',
|
|
93
|
+
confidence REAL DEFAULT 0,
|
|
94
|
+
status TEXT NOT NULL DEFAULT 'discovered',
|
|
95
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
96
|
+
);
|
|
97
|
+
CREATE INDEX IF NOT EXISTS idx_discovered_processes_workspace ON agent_workforce_discovered_processes(workspace_id, status);
|
|
98
|
+
|
|
99
|
+
-- E21: Proactive task engine run log
|
|
100
|
+
CREATE TABLE IF NOT EXISTS agent_workforce_proactive_runs (
|
|
101
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
102
|
+
workspace_id TEXT NOT NULL,
|
|
103
|
+
signals_evaluated INTEGER NOT NULL DEFAULT 0,
|
|
104
|
+
tasks_created INTEGER NOT NULL DEFAULT 0,
|
|
105
|
+
tasks_skipped INTEGER NOT NULL DEFAULT 0,
|
|
106
|
+
skip_reasons TEXT DEFAULT '{}',
|
|
107
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
108
|
+
);
|
|
109
|
+
CREATE INDEX IF NOT EXISTS idx_proactive_runs_workspace ON agent_workforce_proactive_runs(workspace_id, created_at DESC);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
-- Memory Sync Support
|
|
2
|
+
-- Adds confidentiality classification, sync policy, device tracking, and local-only flag
|
|
3
|
+
-- to support privacy-aware memory synchronization between local and cloud.
|
|
4
|
+
|
|
5
|
+
-- 1. Add confidentiality_level to memory entries (derived from taint tracker labels)
|
|
6
|
+
ALTER TABLE agent_workforce_agent_memory
|
|
7
|
+
ADD COLUMN confidentiality_level TEXT NOT NULL DEFAULT 'workspace'
|
|
8
|
+
CHECK (confidentiality_level IN ('public', 'workspace', 'confidential', 'secret'));
|
|
9
|
+
|
|
10
|
+
-- 2. Add source_device_id to track which device created the memory
|
|
11
|
+
ALTER TABLE agent_workforce_agent_memory
|
|
12
|
+
ADD COLUMN source_device_id TEXT DEFAULT NULL;
|
|
13
|
+
|
|
14
|
+
-- 3. Add is_local_only flag — user can mark individual memories as never-syncable
|
|
15
|
+
ALTER TABLE agent_workforce_agent_memory
|
|
16
|
+
ADD COLUMN is_local_only INTEGER NOT NULL DEFAULT 0;
|
|
17
|
+
|
|
18
|
+
-- 4. Add source_agent_id for cross-agent memory provenance tracking
|
|
19
|
+
ALTER TABLE agent_workforce_agent_memory
|
|
20
|
+
ADD COLUMN source_agent_id TEXT DEFAULT NULL;
|
|
21
|
+
|
|
22
|
+
-- 5. Add memory_sync_policy to agent configs (per-agent sync control)
|
|
23
|
+
-- 'none' = all memories stay local (default)
|
|
24
|
+
-- 'behavioral' = sync skills, feedback, procedures, efficiency only
|
|
25
|
+
-- 'full' = sync all memory types
|
|
26
|
+
ALTER TABLE agent_workforce_agents
|
|
27
|
+
ADD COLUMN memory_sync_policy TEXT NOT NULL DEFAULT 'none'
|
|
28
|
+
CHECK (memory_sync_policy IN ('none', 'behavioral', 'full'));
|
|
29
|
+
|
|
30
|
+
-- 6. Add workspace-level memory sync master switch
|
|
31
|
+
INSERT OR IGNORE INTO runtime_settings (key, value, updated_at)
|
|
32
|
+
VALUES ('memory_sync_enabled', 'false', datetime('now'));
|
|
33
|
+
|
|
34
|
+
-- 7. Index for sync queries (find syncable memories by device)
|
|
35
|
+
CREATE INDEX IF NOT EXISTS idx_memory_sync
|
|
36
|
+
ON agent_workforce_agent_memory (source_device_id, is_local_only, confidentiality_level)
|
|
37
|
+
WHERE is_active = 1;
|
|
38
|
+
|
|
39
|
+
-- 8. Add orchestrator memory confidentiality (same classification)
|
|
40
|
+
ALTER TABLE orchestrator_memory
|
|
41
|
+
ADD COLUMN confidentiality_level TEXT NOT NULL DEFAULT 'workspace'
|
|
42
|
+
CHECK (confidentiality_level IN ('public', 'workspace', 'confidential', 'secret'));
|
|
43
|
+
|
|
44
|
+
ALTER TABLE orchestrator_memory
|
|
45
|
+
ADD COLUMN is_local_only INTEGER NOT NULL DEFAULT 0;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
-- Migration 043: Multi-connection support for WhatsApp and Telegram
|
|
2
|
+
-- Allows multiple WhatsApp numbers and Telegram bots per workspace.
|
|
3
|
+
|
|
4
|
+
-- WhatsApp: add label, device_id, is_default columns
|
|
5
|
+
ALTER TABLE whatsapp_connections ADD COLUMN label TEXT;
|
|
6
|
+
ALTER TABLE whatsapp_connections ADD COLUMN device_id TEXT;
|
|
7
|
+
ALTER TABLE whatsapp_connections ADD COLUMN is_default INTEGER NOT NULL DEFAULT 0;
|
|
8
|
+
|
|
9
|
+
-- Telegram: add connection_id to message history for multi-bot support
|
|
10
|
+
ALTER TABLE telegram_chat_messages ADD COLUMN connection_id TEXT REFERENCES telegram_connections(id) ON DELETE SET NULL;
|
|
11
|
+
|
|
12
|
+
-- Telegram: add label, device_id, is_default columns
|
|
13
|
+
ALTER TABLE telegram_connections ADD COLUMN label TEXT;
|
|
14
|
+
ALTER TABLE telegram_connections ADD COLUMN device_id TEXT;
|
|
15
|
+
ALTER TABLE telegram_connections ADD COLUMN is_default INTEGER NOT NULL DEFAULT 0;
|
|
16
|
+
|
|
17
|
+
-- Index for looking up messages by connection
|
|
18
|
+
CREATE INDEX IF NOT EXISTS idx_tg_messages_connection ON telegram_chat_messages(connection_id, chat_id, created_at DESC);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
-- Migration 044: Multi-connection fixes
|
|
2
|
+
-- 1. Drop UNIQUE(workspace_id) on telegram_connections (SQLite requires table recreation)
|
|
3
|
+
-- 2. Add connection_locks table for preventing two devices from connecting the same WA number
|
|
4
|
+
|
|
5
|
+
-- Recreate telegram_connections without the implicit UNIQUE constraint on workspace_id
|
|
6
|
+
CREATE TABLE telegram_connections_new (
|
|
7
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
8
|
+
workspace_id TEXT NOT NULL,
|
|
9
|
+
bot_token TEXT NOT NULL,
|
|
10
|
+
bot_username TEXT,
|
|
11
|
+
bot_id TEXT,
|
|
12
|
+
status TEXT NOT NULL DEFAULT 'disconnected',
|
|
13
|
+
label TEXT,
|
|
14
|
+
device_id TEXT,
|
|
15
|
+
is_default INTEGER NOT NULL DEFAULT 0,
|
|
16
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
17
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
18
|
+
);
|
|
19
|
+
INSERT INTO telegram_connections_new SELECT
|
|
20
|
+
id, workspace_id, bot_token, bot_username, bot_id, status,
|
|
21
|
+
label, device_id, is_default, created_at, updated_at
|
|
22
|
+
FROM telegram_connections;
|
|
23
|
+
DROP TABLE telegram_connections;
|
|
24
|
+
ALTER TABLE telegram_connections_new RENAME TO telegram_connections;
|
|
25
|
+
|
|
26
|
+
-- Connection locks: prevent two devices from connecting the same WhatsApp number
|
|
27
|
+
CREATE TABLE IF NOT EXISTS connection_locks (
|
|
28
|
+
connection_id TEXT PRIMARY KEY,
|
|
29
|
+
device_id TEXT NOT NULL,
|
|
30
|
+
locked_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
31
|
+
heartbeat_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
32
|
+
);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
-- Cross-task state store: persistent key-value state per agent/schedule/goal
|
|
2
|
+
-- Enables agents to maintain structured state across task runs (e.g. "12/30 posts done")
|
|
3
|
+
|
|
4
|
+
CREATE TABLE IF NOT EXISTS agent_workforce_task_state (
|
|
5
|
+
id TEXT PRIMARY KEY,
|
|
6
|
+
workspace_id TEXT NOT NULL,
|
|
7
|
+
agent_id TEXT NOT NULL,
|
|
8
|
+
scope TEXT NOT NULL DEFAULT 'agent',
|
|
9
|
+
scope_id TEXT,
|
|
10
|
+
key TEXT NOT NULL,
|
|
11
|
+
value TEXT NOT NULL,
|
|
12
|
+
value_type TEXT NOT NULL DEFAULT 'string',
|
|
13
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
14
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_task_state_lookup
|
|
18
|
+
ON agent_workforce_task_state(workspace_id, agent_id, scope, scope_id, key);
|
|
19
|
+
|
|
20
|
+
CREATE INDEX IF NOT EXISTS idx_task_state_agent
|
|
21
|
+
ON agent_workforce_task_state(workspace_id, agent_id);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
-- State change audit log for tracking all set/delete operations on agent state.
|
|
2
|
+
-- Enables debugging, rollback analysis, and compliance auditing for long-running workflows.
|
|
3
|
+
|
|
4
|
+
CREATE TABLE IF NOT EXISTS agent_workforce_state_changelog (
|
|
5
|
+
id TEXT PRIMARY KEY,
|
|
6
|
+
workspace_id TEXT NOT NULL,
|
|
7
|
+
agent_id TEXT NOT NULL,
|
|
8
|
+
task_id TEXT,
|
|
9
|
+
key TEXT NOT NULL,
|
|
10
|
+
old_value TEXT,
|
|
11
|
+
new_value TEXT,
|
|
12
|
+
operation TEXT NOT NULL CHECK (operation IN ('set', 'delete')),
|
|
13
|
+
scope TEXT NOT NULL DEFAULT 'agent',
|
|
14
|
+
scope_id TEXT,
|
|
15
|
+
created_at TEXT NOT NULL
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
CREATE INDEX IF NOT EXISTS idx_state_changelog_agent ON agent_workforce_state_changelog(workspace_id, agent_id);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- Outbound queue for buffering control-plane reports when offline
|
|
2
|
+
CREATE TABLE IF NOT EXISTS outbound_queue (
|
|
3
|
+
id TEXT PRIMARY KEY,
|
|
4
|
+
type TEXT NOT NULL,
|
|
5
|
+
payload TEXT NOT NULL,
|
|
6
|
+
created_at TEXT NOT NULL,
|
|
7
|
+
attempts INTEGER NOT NULL DEFAULT 0,
|
|
8
|
+
last_attempt_at TEXT
|
|
9
|
+
);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
-- =====================================================================
|
|
2
|
+
-- Migration 048: Tasks Column Alignment
|
|
3
|
+
-- Add missing columns that exist in cloud but not locally
|
|
4
|
+
-- =====================================================================
|
|
5
|
+
|
|
6
|
+
-- @statement
|
|
7
|
+
ALTER TABLE agent_workforce_tasks ADD COLUMN assigned_to TEXT;
|
|
8
|
+
-- @statement
|
|
9
|
+
ALTER TABLE agent_workforce_tasks ADD COLUMN assignee_type TEXT DEFAULT 'agent';
|
|
10
|
+
-- @statement
|
|
11
|
+
ALTER TABLE agent_workforce_tasks ADD COLUMN assigned_by TEXT;
|
|
12
|
+
-- @statement
|
|
13
|
+
ALTER TABLE agent_workforce_tasks ADD COLUMN assigned_at TEXT;
|
|
14
|
+
-- @statement
|
|
15
|
+
ALTER TABLE agent_workforce_tasks ADD COLUMN context_notes TEXT;
|
|
16
|
+
-- @statement
|
|
17
|
+
ALTER TABLE agent_workforce_tasks ADD COLUMN source_type TEXT DEFAULT 'manual';
|
|
18
|
+
-- @statement
|
|
19
|
+
ALTER TABLE agent_workforce_tasks ADD COLUMN source_signal TEXT;
|
|
20
|
+
-- @statement
|
|
21
|
+
ALTER TABLE agent_workforce_tasks ADD COLUMN sipoc_trace TEXT;
|
|
22
|
+
-- @statement
|
|
23
|
+
ALTER TABLE agent_workforce_tasks ADD COLUMN truth_score INTEGER;
|
|
24
|
+
-- @statement
|
|
25
|
+
ALTER TABLE agent_workforce_tasks ADD COLUMN truth_score_details TEXT;
|
|
26
|
+
-- @statement
|
|
27
|
+
ALTER TABLE agent_workforce_tasks ADD COLUMN session_id TEXT;
|
|
28
|
+
-- @statement
|
|
29
|
+
ALTER TABLE agent_workforce_tasks ADD COLUMN checkpoint TEXT;
|
|
30
|
+
-- @statement
|
|
31
|
+
ALTER TABLE agent_workforce_tasks ADD COLUMN checkpoint_iteration INTEGER;
|
|
32
|
+
-- @statement
|
|
33
|
+
ALTER TABLE agent_workforce_tasks ADD COLUMN max_duration_seconds INTEGER;
|
|
34
|
+
-- @statement
|
|
35
|
+
ALTER TABLE agent_workforce_tasks ADD COLUMN pause_requested INTEGER DEFAULT 0;
|
|
36
|
+
-- @statement
|
|
37
|
+
CREATE INDEX IF NOT EXISTS idx_tasks_workspace_status ON agent_workforce_tasks(workspace_id, status);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
-- =====================================================================
|
|
2
|
+
-- Migration 049: Agents Column Alignment
|
|
3
|
+
-- Add missing columns that exist in cloud but not locally
|
|
4
|
+
-- =====================================================================
|
|
5
|
+
|
|
6
|
+
-- @statement
|
|
7
|
+
ALTER TABLE agent_workforce_agents ADD COLUMN sipoc_profile TEXT;
|
|
8
|
+
-- @statement
|
|
9
|
+
ALTER TABLE agent_workforce_agents ADD COLUMN autonomy_level INTEGER DEFAULT 2;
|
|
10
|
+
-- @statement
|
|
11
|
+
ALTER TABLE agent_workforce_agents ADD COLUMN autonomy_budget TEXT;
|
|
12
|
+
-- @statement
|
|
13
|
+
ALTER TABLE agent_workforce_agents ADD COLUMN point_person_id TEXT;
|
|
14
|
+
-- @statement
|
|
15
|
+
ALTER TABLE agent_workforce_agents ADD COLUMN archived_at TEXT;
|
|
16
|
+
-- @statement
|
|
17
|
+
ALTER TABLE agent_workforce_agents ADD COLUMN total_tasks INTEGER DEFAULT 0;
|
|
18
|
+
-- @statement
|
|
19
|
+
ALTER TABLE agent_workforce_agents ADD COLUMN completed_tasks INTEGER DEFAULT 0;
|
|
20
|
+
-- @statement
|
|
21
|
+
ALTER TABLE agent_workforce_agents ADD COLUMN failed_tasks INTEGER DEFAULT 0;
|
|
22
|
+
-- @statement
|
|
23
|
+
ALTER TABLE agent_workforce_agents ADD COLUMN tokens_used INTEGER DEFAULT 0;
|
|
24
|
+
-- @statement
|
|
25
|
+
ALTER TABLE agent_workforce_agents ADD COLUMN cost_cents_total INTEGER DEFAULT 0;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
-- =====================================================================
|
|
2
|
+
-- Migration 050: Workflows Trigger Alignment
|
|
3
|
+
-- Add missing trigger/automation columns from cloud schema
|
|
4
|
+
-- =====================================================================
|
|
5
|
+
|
|
6
|
+
-- @statement
|
|
7
|
+
ALTER TABLE agent_workforce_workflows ADD COLUMN definition TEXT DEFAULT '{}';
|
|
8
|
+
-- @statement
|
|
9
|
+
ALTER TABLE agent_workforce_workflows ADD COLUMN graph_definition TEXT;
|
|
10
|
+
-- @statement
|
|
11
|
+
ALTER TABLE agent_workforce_workflows ADD COLUMN trigger_type TEXT DEFAULT 'manual';
|
|
12
|
+
-- @statement
|
|
13
|
+
ALTER TABLE agent_workforce_workflows ADD COLUMN trigger_config TEXT DEFAULT '{}';
|
|
14
|
+
-- @statement
|
|
15
|
+
ALTER TABLE agent_workforce_workflows ADD COLUMN enabled INTEGER DEFAULT 1;
|
|
16
|
+
-- @statement
|
|
17
|
+
ALTER TABLE agent_workforce_workflows ADD COLUMN cooldown_seconds INTEGER DEFAULT 0;
|
|
18
|
+
-- @statement
|
|
19
|
+
ALTER TABLE agent_workforce_workflows ADD COLUMN last_fired_at TEXT;
|
|
20
|
+
-- @statement
|
|
21
|
+
ALTER TABLE agent_workforce_workflows ADD COLUMN fire_count INTEGER DEFAULT 0;
|
|
22
|
+
-- @statement
|
|
23
|
+
ALTER TABLE agent_workforce_workflows ADD COLUMN sample_payload TEXT;
|
|
24
|
+
-- @statement
|
|
25
|
+
ALTER TABLE agent_workforce_workflows ADD COLUMN sample_fields TEXT;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
-- =====================================================================
|
|
2
|
+
-- Migration 051: Execution Engine Tables
|
|
3
|
+
-- Add 6 tables needed for local feature parity with cloud service layer
|
|
4
|
+
-- =====================================================================
|
|
5
|
+
|
|
6
|
+
-- 1. Workflow Runs (workflow-execution.service.ts)
|
|
7
|
+
-- @statement
|
|
8
|
+
CREATE TABLE IF NOT EXISTS agent_workforce_workflow_runs (
|
|
9
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
10
|
+
workflow_id TEXT NOT NULL,
|
|
11
|
+
workspace_id TEXT NOT NULL,
|
|
12
|
+
status TEXT DEFAULT 'pending' CHECK (status IN ('pending','running','completed','failed','cancelled')),
|
|
13
|
+
current_step_index INTEGER DEFAULT 0,
|
|
14
|
+
total_steps INTEGER NOT NULL DEFAULT 0,
|
|
15
|
+
step_results TEXT DEFAULT '[]',
|
|
16
|
+
started_at TEXT,
|
|
17
|
+
completed_at TEXT,
|
|
18
|
+
error_message TEXT,
|
|
19
|
+
failed_step_index INTEGER,
|
|
20
|
+
checkpoint TEXT,
|
|
21
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
22
|
+
);
|
|
23
|
+
-- @statement
|
|
24
|
+
CREATE INDEX IF NOT EXISTS idx_workflow_runs_workflow ON agent_workforce_workflow_runs(workflow_id);
|
|
25
|
+
-- @statement
|
|
26
|
+
CREATE INDEX IF NOT EXISTS idx_workflow_runs_workspace ON agent_workforce_workflow_runs(workspace_id, status);
|
|
27
|
+
|
|
28
|
+
-- 2. Sessions (session.service.ts — cross-task context)
|
|
29
|
+
-- @statement
|
|
30
|
+
CREATE TABLE IF NOT EXISTS agent_workforce_sessions (
|
|
31
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
32
|
+
workspace_id TEXT NOT NULL,
|
|
33
|
+
agent_id TEXT NOT NULL,
|
|
34
|
+
title TEXT,
|
|
35
|
+
started_at TEXT DEFAULT (datetime('now')),
|
|
36
|
+
last_active_at TEXT DEFAULT (datetime('now')),
|
|
37
|
+
expires_at TEXT,
|
|
38
|
+
context_summary TEXT,
|
|
39
|
+
status TEXT DEFAULT 'active' CHECK (status IN ('active','expired','closed'))
|
|
40
|
+
);
|
|
41
|
+
-- @statement
|
|
42
|
+
CREATE INDEX IF NOT EXISTS idx_sessions_agent_active ON agent_workforce_sessions(agent_id, status);
|
|
43
|
+
-- @statement
|
|
44
|
+
CREATE INDEX IF NOT EXISTS idx_sessions_workspace ON agent_workforce_sessions(workspace_id);
|
|
45
|
+
|
|
46
|
+
-- 3. Action Journal (action-journal.service.ts — tool reversibility)
|
|
47
|
+
-- @statement
|
|
48
|
+
CREATE TABLE IF NOT EXISTS agent_workforce_action_journal (
|
|
49
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
50
|
+
workspace_id TEXT NOT NULL,
|
|
51
|
+
agent_id TEXT,
|
|
52
|
+
task_id TEXT,
|
|
53
|
+
tool_name TEXT NOT NULL,
|
|
54
|
+
tool_input TEXT DEFAULT '{}',
|
|
55
|
+
tool_output TEXT DEFAULT '{}',
|
|
56
|
+
reversibility TEXT DEFAULT 'reversible',
|
|
57
|
+
compensating_action TEXT,
|
|
58
|
+
status TEXT DEFAULT 'active',
|
|
59
|
+
created_at TEXT DEFAULT (datetime('now')),
|
|
60
|
+
expires_at TEXT
|
|
61
|
+
);
|
|
62
|
+
-- @statement
|
|
63
|
+
CREATE INDEX IF NOT EXISTS idx_action_journal_workspace ON agent_workforce_action_journal(workspace_id, created_at DESC);
|
|
64
|
+
-- @statement
|
|
65
|
+
CREATE INDEX IF NOT EXISTS idx_action_journal_task ON agent_workforce_action_journal(task_id, created_at DESC);
|
|
66
|
+
-- @statement
|
|
67
|
+
CREATE INDEX IF NOT EXISTS idx_action_journal_active ON agent_workforce_action_journal(status);
|
|
68
|
+
|
|
69
|
+
-- 4. Autonomy History (autonomy-history.service.ts — auto-graduation)
|
|
70
|
+
-- @statement
|
|
71
|
+
CREATE TABLE IF NOT EXISTS agent_workforce_autonomy_history (
|
|
72
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
73
|
+
workspace_id TEXT NOT NULL,
|
|
74
|
+
agent_id TEXT NOT NULL,
|
|
75
|
+
task_id TEXT,
|
|
76
|
+
autonomy_level INTEGER NOT NULL CHECK (autonomy_level BETWEEN 1 AND 5),
|
|
77
|
+
decision TEXT NOT NULL CHECK (decision IN ('executed','escalated','self_corrected','chained')),
|
|
78
|
+
escalation_reason TEXT,
|
|
79
|
+
truth_score INTEGER,
|
|
80
|
+
anomaly_detected INTEGER DEFAULT 0,
|
|
81
|
+
tool_names TEXT DEFAULT '[]',
|
|
82
|
+
cost_cents REAL DEFAULT 0,
|
|
83
|
+
outcome TEXT CHECK (outcome IN ('success','failure','approval_granted','approval_denied','self_corrected')),
|
|
84
|
+
outcome_recorded_at TEXT,
|
|
85
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
86
|
+
);
|
|
87
|
+
-- @statement
|
|
88
|
+
CREATE INDEX IF NOT EXISTS idx_autonomy_history_agent ON agent_workforce_autonomy_history(agent_id, created_at DESC);
|
|
89
|
+
|
|
90
|
+
-- 5. Prompt Versions (prompt-version.service.ts — evolution tracking)
|
|
91
|
+
-- @statement
|
|
92
|
+
CREATE TABLE IF NOT EXISTS agent_workforce_prompt_versions (
|
|
93
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
94
|
+
workspace_id TEXT NOT NULL,
|
|
95
|
+
agent_id TEXT NOT NULL,
|
|
96
|
+
version INTEGER NOT NULL,
|
|
97
|
+
prompt_text TEXT NOT NULL,
|
|
98
|
+
change_type TEXT DEFAULT 'initial' CHECK (change_type IN ('initial','manual','evolution','rollback','cross_agent')),
|
|
99
|
+
change_description TEXT,
|
|
100
|
+
avg_truth_score REAL,
|
|
101
|
+
task_count INTEGER DEFAULT 0,
|
|
102
|
+
success_rate REAL,
|
|
103
|
+
is_active INTEGER DEFAULT 1,
|
|
104
|
+
rolled_back_at TEXT,
|
|
105
|
+
rolled_back_reason TEXT,
|
|
106
|
+
created_at TEXT DEFAULT (datetime('now')),
|
|
107
|
+
updated_at TEXT DEFAULT (datetime('now'))
|
|
108
|
+
);
|
|
109
|
+
-- @statement
|
|
110
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_prompt_versions_active ON agent_workforce_prompt_versions(agent_id) WHERE is_active = 1;
|
|
111
|
+
-- @statement
|
|
112
|
+
CREATE INDEX IF NOT EXISTS idx_prompt_versions_agent ON agent_workforce_prompt_versions(agent_id, version DESC);
|
|
113
|
+
|
|
114
|
+
-- 6. Data Store (data-store.ts — agent-accessible collections)
|
|
115
|
+
-- @statement
|
|
116
|
+
CREATE TABLE IF NOT EXISTS agent_workforce_data_store (
|
|
117
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
118
|
+
workspace_id TEXT NOT NULL,
|
|
119
|
+
collection TEXT NOT NULL,
|
|
120
|
+
key TEXT,
|
|
121
|
+
data TEXT DEFAULT '{}',
|
|
122
|
+
recorded_at TEXT DEFAULT (datetime('now')),
|
|
123
|
+
agent_id TEXT,
|
|
124
|
+
created_at TEXT DEFAULT (datetime('now')),
|
|
125
|
+
updated_at TEXT DEFAULT (datetime('now'))
|
|
126
|
+
);
|
|
127
|
+
-- @statement
|
|
128
|
+
CREATE INDEX IF NOT EXISTS idx_data_store_collection ON agent_workforce_data_store(workspace_id, collection);
|
|
129
|
+
-- @statement
|
|
130
|
+
CREATE INDEX IF NOT EXISTS idx_data_store_key ON agent_workforce_data_store(workspace_id, collection, key);
|
|
131
|
+
-- @statement
|
|
132
|
+
CREATE INDEX IF NOT EXISTS idx_data_store_recorded ON agent_workforce_data_store(workspace_id, collection, recorded_at);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
-- =====================================================================
|
|
2
|
+
-- Migration 052: A2A Rate Limit Alignment
|
|
3
|
+
-- Reduce default rate limits to match production-safe values
|
|
4
|
+
-- =====================================================================
|
|
5
|
+
|
|
6
|
+
-- @statement
|
|
7
|
+
UPDATE a2a_connections SET rate_limit_per_minute = 30, rate_limit_per_hour = 500
|
|
8
|
+
WHERE rate_limit_per_minute = 60 AND rate_limit_per_hour = 1000;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
-- Agent OS: LLM Response Cache
|
|
2
|
+
-- Stores and retrieves LLM responses using BM25 similarity matching.
|
|
3
|
+
|
|
4
|
+
CREATE TABLE IF NOT EXISTS llm_response_cache (
|
|
5
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
6
|
+
workspace_id TEXT NOT NULL,
|
|
7
|
+
request_text TEXT NOT NULL,
|
|
8
|
+
request_hash TEXT NOT NULL,
|
|
9
|
+
model TEXT NOT NULL,
|
|
10
|
+
system_prompt_hash TEXT NOT NULL,
|
|
11
|
+
response_content TEXT NOT NULL,
|
|
12
|
+
response_tokens TEXT DEFAULT '{}',
|
|
13
|
+
quality_score REAL DEFAULT 1.0,
|
|
14
|
+
usage_count INTEGER DEFAULT 1,
|
|
15
|
+
last_used_at TEXT DEFAULT (datetime('now')),
|
|
16
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
CREATE INDEX IF NOT EXISTS idx_llm_cache_hash ON llm_response_cache(workspace_id, request_hash);
|
|
20
|
+
CREATE INDEX IF NOT EXISTS idx_llm_cache_usage ON llm_response_cache(workspace_id, usage_count DESC, last_used_at DESC);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
-- Agent OS: Task Checkpointing
|
|
2
|
+
-- Add checkpoint columns to tasks table for pause/resume support.
|
|
3
|
+
-- Note: these columns are also added in 048; the @statement directives
|
|
4
|
+
-- allow this migration to run idempotently if 048 was applied first.
|
|
5
|
+
|
|
6
|
+
-- @statement
|
|
7
|
+
ALTER TABLE agent_workforce_tasks ADD COLUMN checkpoint TEXT DEFAULT NULL;
|
|
8
|
+
-- @statement
|
|
9
|
+
ALTER TABLE agent_workforce_tasks ADD COLUMN checkpoint_iteration INTEGER DEFAULT NULL;
|
|
10
|
+
-- @statement
|
|
11
|
+
ALTER TABLE agent_workforce_tasks ADD COLUMN pause_requested INTEGER DEFAULT 0;
|
|
12
|
+
-- @statement
|
|
13
|
+
ALTER TABLE agent_workforce_tasks ADD COLUMN max_duration_seconds INTEGER DEFAULT NULL;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-- Agent OS: Resource Usage Tracking
|
|
2
|
+
|
|
3
|
+
CREATE TABLE IF NOT EXISTS resource_usage_daily (
|
|
4
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
5
|
+
workspace_id TEXT NOT NULL,
|
|
6
|
+
date TEXT NOT NULL,
|
|
7
|
+
concurrent_peak INTEGER DEFAULT 0,
|
|
8
|
+
total_tasks INTEGER DEFAULT 0,
|
|
9
|
+
total_tokens INTEGER DEFAULT 0,
|
|
10
|
+
total_cost_cents INTEGER DEFAULT 0,
|
|
11
|
+
UNIQUE(workspace_id, date)
|
|
12
|
+
);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
-- Agent OS: Digital Twin Sandbox Tables
|
|
2
|
+
|
|
3
|
+
CREATE TABLE IF NOT EXISTS agent_workforce_tool_recordings (
|
|
4
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
5
|
+
workspace_id TEXT NOT NULL,
|
|
6
|
+
agent_id TEXT NOT NULL,
|
|
7
|
+
task_id TEXT NOT NULL,
|
|
8
|
+
tool_name TEXT NOT NULL,
|
|
9
|
+
tool_input TEXT NOT NULL DEFAULT '{}',
|
|
10
|
+
tool_output TEXT NOT NULL DEFAULT '',
|
|
11
|
+
is_error INTEGER DEFAULT 0,
|
|
12
|
+
input_hash TEXT NOT NULL,
|
|
13
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
CREATE INDEX IF NOT EXISTS idx_tool_recordings_lookup
|
|
17
|
+
ON agent_workforce_tool_recordings(agent_id, tool_name, input_hash);
|
|
18
|
+
|
|
19
|
+
CREATE TABLE IF NOT EXISTS agent_workforce_shadow_runs (
|
|
20
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
21
|
+
workspace_id TEXT NOT NULL,
|
|
22
|
+
agent_id TEXT NOT NULL,
|
|
23
|
+
shadow_config TEXT NOT NULL DEFAULT '{}',
|
|
24
|
+
tasks_evaluated INTEGER DEFAULT 0,
|
|
25
|
+
production_metrics TEXT DEFAULT '{}',
|
|
26
|
+
shadow_metrics TEXT DEFAULT '{}',
|
|
27
|
+
verdict TEXT NOT NULL DEFAULT 'needs_review',
|
|
28
|
+
confidence_score REAL DEFAULT 0,
|
|
29
|
+
regressions TEXT DEFAULT '[]',
|
|
30
|
+
cost_cents REAL DEFAULT 0,
|
|
31
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
CREATE INDEX IF NOT EXISTS idx_shadow_runs_agent
|
|
35
|
+
ON agent_workforce_shadow_runs(agent_id, created_at DESC);
|