@askexenow/exe-os 0.9.65 → 0.9.67
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/deploy/stack-manifests/v0.9.json +54 -5
- package/dist/bin/age-ontology-load.js +61 -0
- package/dist/bin/agentic-ontology-backfill.js +4708 -0
- package/dist/bin/agentic-reflection-backfill.js +4144 -0
- package/dist/bin/{exe-link.js → agentic-semantic-label.js} +1532 -2173
- package/dist/bin/backfill-conversations.js +528 -20
- package/dist/bin/backfill-responses.js +528 -20
- package/dist/bin/backfill-vectors.js +255 -20
- package/dist/bin/bulk-sync-postgres.js +4876 -0
- package/dist/bin/cleanup-stale-review-tasks.js +529 -21
- package/dist/bin/cli.js +3471 -1491
- package/dist/bin/exe-agent-config.js +4 -0
- package/dist/bin/exe-agent.js +16 -0
- package/dist/bin/exe-assign.js +528 -20
- package/dist/bin/exe-boot.js +492 -54
- package/dist/bin/exe-call.js +16 -0
- package/dist/bin/exe-cloud.js +7415 -518
- package/dist/bin/exe-dispatch.js +540 -22
- package/dist/bin/exe-doctor.js +3404 -1225
- package/dist/bin/exe-export-behaviors.js +542 -24
- package/dist/bin/exe-forget.js +529 -21
- package/dist/bin/exe-gateway.js +595 -25
- package/dist/bin/exe-heartbeat.js +541 -24
- package/dist/bin/exe-kill.js +529 -21
- package/dist/bin/exe-launch-agent.js +2334 -1067
- package/dist/bin/exe-new-employee.js +324 -166
- package/dist/bin/exe-pending-messages.js +529 -21
- package/dist/bin/exe-pending-notifications.js +529 -21
- package/dist/bin/exe-pending-reviews.js +529 -21
- package/dist/bin/exe-rename.js +529 -21
- package/dist/bin/exe-review.js +529 -21
- package/dist/bin/exe-search.js +542 -24
- package/dist/bin/exe-session-cleanup.js +540 -22
- package/dist/bin/exe-settings.js +14 -0
- package/dist/bin/exe-start-codex.js +817 -144
- package/dist/bin/exe-start-opencode.js +776 -80
- package/dist/bin/exe-status.js +529 -21
- package/dist/bin/exe-team.js +529 -21
- package/dist/bin/git-sweep.js +540 -22
- package/dist/bin/graph-backfill.js +580 -21
- package/dist/bin/graph-export.js +529 -21
- package/dist/bin/graph-layer-benchmark.js +109 -0
- package/dist/bin/install.js +420 -289
- package/dist/bin/intercom-check.js +540 -22
- package/dist/bin/postgres-agentic-reflection-backfill.js +187 -0
- package/dist/bin/postgres-agentic-semantic-backfill.js +237 -0
- package/dist/bin/scan-tasks.js +540 -22
- package/dist/bin/setup.js +790 -206
- package/dist/bin/shard-migrate.js +528 -20
- package/dist/bin/update.js +4 -0
- package/dist/gateway/index.js +593 -23
- package/dist/hooks/bug-report-worker.js +651 -64
- package/dist/hooks/codex-stop-task-finalizer.js +540 -22
- package/dist/hooks/commit-complete.js +540 -22
- package/dist/hooks/error-recall.js +542 -24
- package/dist/hooks/exe-heartbeat-hook.js +4 -0
- package/dist/hooks/ingest-worker.js +4 -0
- package/dist/hooks/ingest.js +539 -22
- package/dist/hooks/instructions-loaded.js +529 -21
- package/dist/hooks/notification.js +529 -21
- package/dist/hooks/post-compact.js +529 -21
- package/dist/hooks/post-tool-combined.js +543 -25
- package/dist/hooks/pre-compact.js +772 -127
- package/dist/hooks/pre-tool-use.js +529 -21
- package/dist/hooks/prompt-submit.js +543 -25
- package/dist/hooks/session-end.js +673 -140
- package/dist/hooks/session-start.js +662 -26
- package/dist/hooks/stop.js +540 -23
- package/dist/hooks/subagent-stop.js +529 -21
- package/dist/hooks/summary-worker.js +571 -126
- package/dist/index.js +593 -23
- package/dist/lib/agent-config.js +4 -0
- package/dist/lib/cloud-sync.js +408 -47
- package/dist/lib/config.js +25 -1
- package/dist/lib/consolidation.js +5 -1
- package/dist/lib/database.js +128 -0
- package/dist/lib/db-daemon-client.js +4 -0
- package/dist/lib/db.js +128 -0
- package/dist/lib/device-registry.js +128 -0
- package/dist/lib/embedder.js +25 -1
- package/dist/lib/employee-templates.js +16 -0
- package/dist/lib/employees.js +4 -0
- package/dist/lib/exe-daemon-client.js +4 -0
- package/dist/lib/exe-daemon.js +3158 -930
- package/dist/lib/hybrid-search.js +542 -24
- package/dist/lib/identity.js +7 -0
- package/dist/lib/keychain.js +178 -22
- package/dist/lib/license.js +4 -0
- package/dist/lib/messaging.js +7 -0
- package/dist/lib/reminders.js +7 -0
- package/dist/lib/schedules.js +255 -20
- package/dist/lib/skill-learning.js +28 -1
- package/dist/lib/status-brief.js +39 -0
- package/dist/lib/store.js +528 -20
- package/dist/lib/task-router.js +4 -0
- package/dist/lib/tasks.js +28 -1
- package/dist/lib/tmux-routing.js +28 -1
- package/dist/lib/token-spend.js +7 -0
- package/dist/mcp/server.js +2739 -813
- package/dist/mcp/tools/complete-reminder.js +7 -0
- package/dist/mcp/tools/create-reminder.js +7 -0
- package/dist/mcp/tools/create-task.js +28 -1
- package/dist/mcp/tools/deactivate-behavior.js +7 -0
- package/dist/mcp/tools/list-reminders.js +7 -0
- package/dist/mcp/tools/list-tasks.js +7 -0
- package/dist/mcp/tools/send-message.js +7 -0
- package/dist/mcp/tools/update-task.js +28 -1
- package/dist/runtime/index.js +540 -22
- package/dist/tui/App.js +618 -29
- package/package.json +9 -5
- package/src/commands/exe/cloud.md +11 -8
- package/stack.release.json +3 -3
- package/src/commands/exe/link.md +0 -17
|
@@ -190,6 +190,11 @@ function normalizeAutoUpdate(raw) {
|
|
|
190
190
|
const userAU = raw.autoUpdate ?? {};
|
|
191
191
|
raw.autoUpdate = { ...defaultAU, ...userAU };
|
|
192
192
|
}
|
|
193
|
+
function normalizeOrchestration(raw) {
|
|
194
|
+
const defaultOrg = DEFAULT_CONFIG.orchestration;
|
|
195
|
+
const userOrg = raw.orchestration ?? {};
|
|
196
|
+
raw.orchestration = { ...defaultOrg, ...userOrg };
|
|
197
|
+
}
|
|
193
198
|
async function loadConfig() {
|
|
194
199
|
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
195
200
|
await ensurePrivateDir(dir);
|
|
@@ -214,10 +219,15 @@ async function loadConfig() {
|
|
|
214
219
|
normalizeScalingRoadmap(migratedCfg);
|
|
215
220
|
normalizeSessionLifecycle(migratedCfg);
|
|
216
221
|
normalizeAutoUpdate(migratedCfg);
|
|
222
|
+
normalizeOrchestration(migratedCfg);
|
|
217
223
|
const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
|
|
218
224
|
if (config.dbPath.startsWith("~")) {
|
|
219
225
|
config.dbPath = config.dbPath.replace(/^~/, os.homedir());
|
|
220
226
|
}
|
|
227
|
+
const envDbPath = path.join(dir, "memories.db");
|
|
228
|
+
if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync2(config.dbPath) && existsSync2(envDbPath)) {
|
|
229
|
+
config.dbPath = envDbPath;
|
|
230
|
+
}
|
|
221
231
|
return config;
|
|
222
232
|
} catch {
|
|
223
233
|
return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
|
|
@@ -289,6 +299,10 @@ var init_config = __esm({
|
|
|
289
299
|
checkOnBoot: true,
|
|
290
300
|
autoInstall: false,
|
|
291
301
|
checkIntervalMs: 24 * 60 * 60 * 1e3
|
|
302
|
+
},
|
|
303
|
+
orchestration: {
|
|
304
|
+
phase: "phase_1_coo",
|
|
305
|
+
phaseSetBy: "default"
|
|
292
306
|
}
|
|
293
307
|
};
|
|
294
308
|
CONFIG_MIGRATIONS = [
|
|
@@ -1745,6 +1759,9 @@ function getClient() {
|
|
|
1745
1759
|
if (_daemonClient && _daemonClient._isDaemonActive()) {
|
|
1746
1760
|
return _daemonClient;
|
|
1747
1761
|
}
|
|
1762
|
+
if (!_resilientClient) {
|
|
1763
|
+
return _adapterClient;
|
|
1764
|
+
}
|
|
1748
1765
|
return _resilientClient;
|
|
1749
1766
|
}
|
|
1750
1767
|
async function initDaemonClient() {
|
|
@@ -2777,6 +2794,127 @@ async function ensureSchema() {
|
|
|
2777
2794
|
VALUES (new.rowid, new.content, new.subject, new.predicate, new.object);
|
|
2778
2795
|
END;
|
|
2779
2796
|
`);
|
|
2797
|
+
await client.executeMultiple(`
|
|
2798
|
+
CREATE TABLE IF NOT EXISTS agent_sessions (
|
|
2799
|
+
id TEXT PRIMARY KEY,
|
|
2800
|
+
agent_id TEXT NOT NULL,
|
|
2801
|
+
project_name TEXT,
|
|
2802
|
+
started_at TEXT NOT NULL,
|
|
2803
|
+
last_event_at TEXT NOT NULL,
|
|
2804
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
2805
|
+
properties TEXT DEFAULT '{}'
|
|
2806
|
+
);
|
|
2807
|
+
|
|
2808
|
+
CREATE INDEX IF NOT EXISTS idx_agent_sessions_agent_time
|
|
2809
|
+
ON agent_sessions(agent_id, started_at);
|
|
2810
|
+
|
|
2811
|
+
CREATE TABLE IF NOT EXISTS agent_goals (
|
|
2812
|
+
id TEXT PRIMARY KEY,
|
|
2813
|
+
statement TEXT NOT NULL,
|
|
2814
|
+
owner_agent_id TEXT,
|
|
2815
|
+
project_name TEXT,
|
|
2816
|
+
status TEXT NOT NULL DEFAULT 'open',
|
|
2817
|
+
priority INTEGER NOT NULL DEFAULT 5,
|
|
2818
|
+
success_criteria TEXT,
|
|
2819
|
+
parent_goal_id TEXT,
|
|
2820
|
+
due_at TEXT,
|
|
2821
|
+
achieved_at TEXT,
|
|
2822
|
+
supersedes_id TEXT,
|
|
2823
|
+
created_at TEXT NOT NULL,
|
|
2824
|
+
updated_at TEXT NOT NULL,
|
|
2825
|
+
source_memory_id TEXT
|
|
2826
|
+
);
|
|
2827
|
+
|
|
2828
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goals_project_status
|
|
2829
|
+
ON agent_goals(project_name, status, priority);
|
|
2830
|
+
|
|
2831
|
+
CREATE TABLE IF NOT EXISTS agent_events (
|
|
2832
|
+
id TEXT PRIMARY KEY,
|
|
2833
|
+
event_type TEXT NOT NULL,
|
|
2834
|
+
occurred_at TEXT NOT NULL,
|
|
2835
|
+
sequence_index INTEGER NOT NULL,
|
|
2836
|
+
actor_agent_id TEXT,
|
|
2837
|
+
agent_role TEXT,
|
|
2838
|
+
project_name TEXT,
|
|
2839
|
+
session_id TEXT,
|
|
2840
|
+
task_id TEXT,
|
|
2841
|
+
goal_id TEXT,
|
|
2842
|
+
parent_event_id TEXT,
|
|
2843
|
+
intention TEXT,
|
|
2844
|
+
outcome TEXT,
|
|
2845
|
+
evidence_memory_id TEXT,
|
|
2846
|
+
impact TEXT,
|
|
2847
|
+
payload TEXT DEFAULT '{}',
|
|
2848
|
+
created_at TEXT NOT NULL
|
|
2849
|
+
);
|
|
2850
|
+
|
|
2851
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_time
|
|
2852
|
+
ON agent_events(occurred_at, sequence_index);
|
|
2853
|
+
|
|
2854
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_session_seq
|
|
2855
|
+
ON agent_events(session_id, sequence_index);
|
|
2856
|
+
|
|
2857
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_goal_time
|
|
2858
|
+
ON agent_events(goal_id, occurred_at);
|
|
2859
|
+
|
|
2860
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_memory
|
|
2861
|
+
ON agent_events(evidence_memory_id);
|
|
2862
|
+
|
|
2863
|
+
CREATE TABLE IF NOT EXISTS agent_goal_links (
|
|
2864
|
+
id TEXT PRIMARY KEY,
|
|
2865
|
+
goal_id TEXT NOT NULL,
|
|
2866
|
+
link_type TEXT NOT NULL,
|
|
2867
|
+
target_id TEXT NOT NULL,
|
|
2868
|
+
target_type TEXT NOT NULL,
|
|
2869
|
+
created_at TEXT NOT NULL
|
|
2870
|
+
);
|
|
2871
|
+
|
|
2872
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goal_links_goal
|
|
2873
|
+
ON agent_goal_links(goal_id, target_type);
|
|
2874
|
+
|
|
2875
|
+
CREATE TABLE IF NOT EXISTS agent_semantic_labels (
|
|
2876
|
+
id TEXT PRIMARY KEY,
|
|
2877
|
+
source_memory_id TEXT NOT NULL,
|
|
2878
|
+
event_id TEXT,
|
|
2879
|
+
labeler TEXT NOT NULL,
|
|
2880
|
+
schema_version INTEGER NOT NULL DEFAULT 1,
|
|
2881
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
2882
|
+
labels TEXT NOT NULL,
|
|
2883
|
+
created_at TEXT NOT NULL,
|
|
2884
|
+
updated_at TEXT NOT NULL
|
|
2885
|
+
);
|
|
2886
|
+
|
|
2887
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_memory
|
|
2888
|
+
ON agent_semantic_labels(source_memory_id, labeler);
|
|
2889
|
+
|
|
2890
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_event
|
|
2891
|
+
ON agent_semantic_labels(event_id);
|
|
2892
|
+
|
|
2893
|
+
CREATE TABLE IF NOT EXISTS agent_reflection_checkpoints (
|
|
2894
|
+
id TEXT PRIMARY KEY,
|
|
2895
|
+
project_name TEXT,
|
|
2896
|
+
session_id TEXT,
|
|
2897
|
+
window_start_at TEXT NOT NULL,
|
|
2898
|
+
window_end_at TEXT NOT NULL,
|
|
2899
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
2900
|
+
goal_count INTEGER NOT NULL DEFAULT 0,
|
|
2901
|
+
success_count INTEGER NOT NULL DEFAULT 0,
|
|
2902
|
+
failure_count INTEGER NOT NULL DEFAULT 0,
|
|
2903
|
+
risk_count INTEGER NOT NULL DEFAULT 0,
|
|
2904
|
+
summary TEXT NOT NULL,
|
|
2905
|
+
learnings TEXT NOT NULL DEFAULT '[]',
|
|
2906
|
+
next_actions TEXT NOT NULL DEFAULT '[]',
|
|
2907
|
+
evidence_event_ids TEXT NOT NULL DEFAULT '[]',
|
|
2908
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
2909
|
+
created_at TEXT NOT NULL
|
|
2910
|
+
);
|
|
2911
|
+
|
|
2912
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_project_time
|
|
2913
|
+
ON agent_reflection_checkpoints(project_name, window_end_at);
|
|
2914
|
+
|
|
2915
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_session_time
|
|
2916
|
+
ON agent_reflection_checkpoints(session_id, window_end_at);
|
|
2917
|
+
`);
|
|
2780
2918
|
try {
|
|
2781
2919
|
await client.execute({
|
|
2782
2920
|
sql: `ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3`,
|
|
@@ -3418,7 +3556,7 @@ var init_notifications = __esm({
|
|
|
3418
3556
|
|
|
3419
3557
|
// src/lib/keychain.ts
|
|
3420
3558
|
import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
|
|
3421
|
-
import { existsSync as existsSync13 } from "fs";
|
|
3559
|
+
import { existsSync as existsSync13, statSync as statSync2 } from "fs";
|
|
3422
3560
|
import { execSync as execSync4 } from "child_process";
|
|
3423
3561
|
import path14 from "path";
|
|
3424
3562
|
import os11 from "os";
|
|
@@ -3428,29 +3566,78 @@ function getKeyDir() {
|
|
|
3428
3566
|
function getKeyPath() {
|
|
3429
3567
|
return path14.join(getKeyDir(), "master.key");
|
|
3430
3568
|
}
|
|
3431
|
-
function
|
|
3569
|
+
function nativeKeychainAllowed() {
|
|
3570
|
+
return process.env.EXE_OS_DISABLE_NATIVE_KEYCHAIN !== "1";
|
|
3571
|
+
}
|
|
3572
|
+
function linuxSecretAvailable() {
|
|
3573
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3574
|
+
if (process.platform !== "linux") return false;
|
|
3575
|
+
if (linuxSecretAvailability !== null) return linuxSecretAvailability;
|
|
3576
|
+
try {
|
|
3577
|
+
execSync4("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
|
|
3578
|
+
} catch {
|
|
3579
|
+
linuxSecretAvailability = false;
|
|
3580
|
+
return false;
|
|
3581
|
+
}
|
|
3582
|
+
try {
|
|
3583
|
+
execSync4("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
|
|
3584
|
+
linuxSecretAvailability = true;
|
|
3585
|
+
} catch {
|
|
3586
|
+
linuxSecretAvailability = false;
|
|
3587
|
+
}
|
|
3588
|
+
return linuxSecretAvailability;
|
|
3589
|
+
}
|
|
3590
|
+
function isRootOnlyTrustedServerKeyFile(keyPath) {
|
|
3591
|
+
if (process.platform !== "linux") return false;
|
|
3592
|
+
try {
|
|
3593
|
+
const uid = typeof os11.userInfo().uid === "number" ? os11.userInfo().uid : -1;
|
|
3594
|
+
const st = statSync2(keyPath);
|
|
3595
|
+
if (!st.isFile() || (st.mode & 63) !== 0) return false;
|
|
3596
|
+
if (uid === 0) return true;
|
|
3597
|
+
const exeOsDir = process.env.EXE_OS_DIR;
|
|
3598
|
+
return Boolean(exeOsDir && path14.resolve(keyPath).startsWith(path14.resolve(exeOsDir) + path14.sep));
|
|
3599
|
+
} catch {
|
|
3600
|
+
return false;
|
|
3601
|
+
}
|
|
3602
|
+
}
|
|
3603
|
+
function macKeychainGet(service = SERVICE) {
|
|
3604
|
+
if (!nativeKeychainAllowed()) return null;
|
|
3432
3605
|
if (process.platform !== "darwin") return null;
|
|
3433
3606
|
try {
|
|
3434
3607
|
return execSync4(
|
|
3435
|
-
`security find-generic-password -s "${
|
|
3608
|
+
`security find-generic-password -s "${service}" -a "${ACCOUNT}" -w 2>/dev/null`,
|
|
3436
3609
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
3437
3610
|
).trim();
|
|
3438
3611
|
} catch {
|
|
3439
3612
|
return null;
|
|
3440
3613
|
}
|
|
3441
3614
|
}
|
|
3442
|
-
function macKeychainSet(value) {
|
|
3615
|
+
function macKeychainSet(value, service = SERVICE) {
|
|
3616
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3443
3617
|
if (process.platform !== "darwin") return false;
|
|
3444
3618
|
try {
|
|
3445
3619
|
try {
|
|
3446
3620
|
execSync4(
|
|
3447
|
-
`security delete-generic-password -s "${
|
|
3621
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
3448
3622
|
{ timeout: 5e3 }
|
|
3449
3623
|
);
|
|
3450
3624
|
} catch {
|
|
3451
3625
|
}
|
|
3452
3626
|
execSync4(
|
|
3453
|
-
`security add-generic-password -s "${
|
|
3627
|
+
`security add-generic-password -s "${service}" -a "${ACCOUNT}" -w "${value}"`,
|
|
3628
|
+
{ timeout: 5e3 }
|
|
3629
|
+
);
|
|
3630
|
+
return true;
|
|
3631
|
+
} catch {
|
|
3632
|
+
return false;
|
|
3633
|
+
}
|
|
3634
|
+
}
|
|
3635
|
+
function macKeychainDelete(service = SERVICE) {
|
|
3636
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3637
|
+
if (process.platform !== "darwin") return false;
|
|
3638
|
+
try {
|
|
3639
|
+
execSync4(
|
|
3640
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
3454
3641
|
{ timeout: 5e3 }
|
|
3455
3642
|
);
|
|
3456
3643
|
return true;
|
|
@@ -3458,22 +3645,35 @@ function macKeychainSet(value) {
|
|
|
3458
3645
|
return false;
|
|
3459
3646
|
}
|
|
3460
3647
|
}
|
|
3461
|
-
function linuxSecretGet() {
|
|
3462
|
-
if (
|
|
3648
|
+
function linuxSecretGet(service = SERVICE) {
|
|
3649
|
+
if (!linuxSecretAvailable()) return null;
|
|
3463
3650
|
try {
|
|
3464
3651
|
return execSync4(
|
|
3465
|
-
`secret-tool lookup service "${
|
|
3652
|
+
`secret-tool lookup service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3466
3653
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
3467
3654
|
).trim();
|
|
3468
3655
|
} catch {
|
|
3469
3656
|
return null;
|
|
3470
3657
|
}
|
|
3471
3658
|
}
|
|
3472
|
-
function linuxSecretSet(value) {
|
|
3659
|
+
function linuxSecretSet(value, service = SERVICE) {
|
|
3660
|
+
if (!linuxSecretAvailable()) return false;
|
|
3661
|
+
try {
|
|
3662
|
+
execSync4(
|
|
3663
|
+
`echo -n "${value}" | secret-tool store --label="exe-os master key" service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3664
|
+
{ timeout: 5e3 }
|
|
3665
|
+
);
|
|
3666
|
+
return true;
|
|
3667
|
+
} catch {
|
|
3668
|
+
return false;
|
|
3669
|
+
}
|
|
3670
|
+
}
|
|
3671
|
+
function linuxSecretDelete(service = SERVICE) {
|
|
3672
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3473
3673
|
if (process.platform !== "linux") return false;
|
|
3474
3674
|
try {
|
|
3475
3675
|
execSync4(
|
|
3476
|
-
`
|
|
3676
|
+
`secret-tool clear service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3477
3677
|
{ timeout: 5e3 }
|
|
3478
3678
|
);
|
|
3479
3679
|
return true;
|
|
@@ -3482,6 +3682,7 @@ function linuxSecretSet(value) {
|
|
|
3482
3682
|
}
|
|
3483
3683
|
}
|
|
3484
3684
|
async function tryKeytar() {
|
|
3685
|
+
if (!nativeKeychainAllowed()) return null;
|
|
3485
3686
|
try {
|
|
3486
3687
|
return await import("keytar");
|
|
3487
3688
|
} catch {
|
|
@@ -3555,7 +3756,19 @@ async function writeMachineBoundFileFallback(b64) {
|
|
|
3555
3756
|
return "plaintext";
|
|
3556
3757
|
}
|
|
3557
3758
|
async function getMasterKey() {
|
|
3558
|
-
|
|
3759
|
+
let nativeValue = macKeychainGet() ?? linuxSecretGet();
|
|
3760
|
+
if (!nativeValue) {
|
|
3761
|
+
const legacyValue = macKeychainGet(LEGACY_SERVICE) ?? linuxSecretGet(LEGACY_SERVICE);
|
|
3762
|
+
if (legacyValue) {
|
|
3763
|
+
const migrated = macKeychainSet(legacyValue) || linuxSecretSet(legacyValue);
|
|
3764
|
+
if (migrated) {
|
|
3765
|
+
macKeychainDelete(LEGACY_SERVICE);
|
|
3766
|
+
linuxSecretDelete(LEGACY_SERVICE);
|
|
3767
|
+
process.stderr.write("[keychain] Migrated keychain service from exe-mem to exe-os.\n");
|
|
3768
|
+
}
|
|
3769
|
+
nativeValue = legacyValue;
|
|
3770
|
+
}
|
|
3771
|
+
}
|
|
3559
3772
|
if (nativeValue) {
|
|
3560
3773
|
return Buffer.from(nativeValue, "base64");
|
|
3561
3774
|
}
|
|
@@ -3563,12 +3776,17 @@ async function getMasterKey() {
|
|
|
3563
3776
|
if (keytar) {
|
|
3564
3777
|
try {
|
|
3565
3778
|
const keytarValue = await keytar.getPassword(SERVICE, ACCOUNT);
|
|
3566
|
-
|
|
3567
|
-
|
|
3779
|
+
const legacyKeytarValue = keytarValue ?? await keytar.getPassword(LEGACY_SERVICE, ACCOUNT);
|
|
3780
|
+
if (legacyKeytarValue) {
|
|
3781
|
+
const migrated = macKeychainSet(legacyKeytarValue) || linuxSecretSet(legacyKeytarValue);
|
|
3568
3782
|
if (migrated) {
|
|
3569
3783
|
process.stderr.write("[keychain] Migrated key from keytar to native keychain.\n");
|
|
3784
|
+
try {
|
|
3785
|
+
await keytar.deletePassword(LEGACY_SERVICE, ACCOUNT);
|
|
3786
|
+
} catch {
|
|
3787
|
+
}
|
|
3570
3788
|
}
|
|
3571
|
-
return Buffer.from(
|
|
3789
|
+
return Buffer.from(legacyKeytarValue, "base64");
|
|
3572
3790
|
}
|
|
3573
3791
|
} catch {
|
|
3574
3792
|
}
|
|
@@ -3593,7 +3811,7 @@ async function getMasterKey() {
|
|
|
3593
3811
|
const decrypted = decryptWithMachineKey(content, machineKey);
|
|
3594
3812
|
if (!decrypted) {
|
|
3595
3813
|
process.stderr.write(
|
|
3596
|
-
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase: exe-os
|
|
3814
|
+
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase during setup: exe-os setup\n"
|
|
3597
3815
|
);
|
|
3598
3816
|
return null;
|
|
3599
3817
|
}
|
|
@@ -3602,6 +3820,9 @@ async function getMasterKey() {
|
|
|
3602
3820
|
b64Value = content;
|
|
3603
3821
|
}
|
|
3604
3822
|
const key = Buffer.from(b64Value, "base64");
|
|
3823
|
+
if (!content.startsWith(ENCRYPTED_PREFIX) && isRootOnlyTrustedServerKeyFile(keyPath)) {
|
|
3824
|
+
return key;
|
|
3825
|
+
}
|
|
3605
3826
|
const migrated = macKeychainSet(b64Value) || linuxSecretSet(b64Value);
|
|
3606
3827
|
if (migrated) {
|
|
3607
3828
|
process.stderr.write("[keychain] Migrated key from file to native keychain.\n");
|
|
@@ -3629,12 +3850,14 @@ async function getMasterKey() {
|
|
|
3629
3850
|
return null;
|
|
3630
3851
|
}
|
|
3631
3852
|
}
|
|
3632
|
-
var SERVICE, ACCOUNT, ENCRYPTED_PREFIX;
|
|
3853
|
+
var SERVICE, LEGACY_SERVICE, ACCOUNT, linuxSecretAvailability, ENCRYPTED_PREFIX;
|
|
3633
3854
|
var init_keychain = __esm({
|
|
3634
3855
|
"src/lib/keychain.ts"() {
|
|
3635
3856
|
"use strict";
|
|
3636
|
-
SERVICE = "exe-
|
|
3857
|
+
SERVICE = "exe-os";
|
|
3858
|
+
LEGACY_SERVICE = "exe-mem";
|
|
3637
3859
|
ACCOUNT = "master-key";
|
|
3860
|
+
linuxSecretAvailability = null;
|
|
3638
3861
|
ENCRYPTED_PREFIX = "enc:";
|
|
3639
3862
|
}
|
|
3640
3863
|
});
|
|
@@ -3904,7 +4127,7 @@ __export(shard_manager_exports, {
|
|
|
3904
4127
|
shardExists: () => shardExists
|
|
3905
4128
|
});
|
|
3906
4129
|
import path15 from "path";
|
|
3907
|
-
import { existsSync as existsSync14, mkdirSync as mkdirSync6, readdirSync as readdirSync3, renameSync as renameSync4, statSync as
|
|
4130
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync6, readdirSync as readdirSync3, renameSync as renameSync4, statSync as statSync3 } from "fs";
|
|
3908
4131
|
import { createClient as createClient2 } from "@libsql/client";
|
|
3909
4132
|
function initShardManager(encryptionKey) {
|
|
3910
4133
|
_encryptionKey = encryptionKey;
|
|
@@ -3968,7 +4191,7 @@ async function auditShardHealth(options = {}) {
|
|
|
3968
4191
|
const shards = [];
|
|
3969
4192
|
for (const name of names) {
|
|
3970
4193
|
const dbPath = path15.join(SHARDS_DIR, `${name}.db`);
|
|
3971
|
-
const stat =
|
|
4194
|
+
const stat = statSync3(dbPath);
|
|
3972
4195
|
const item = {
|
|
3973
4196
|
name,
|
|
3974
4197
|
path: dbPath,
|
|
@@ -4221,7 +4444,7 @@ async function getReadyShardClient(projectName) {
|
|
|
4221
4444
|
_shardLastAccess.delete(safeName);
|
|
4222
4445
|
const dbPath = path15.join(SHARDS_DIR, `${safeName}.db`);
|
|
4223
4446
|
if (existsSync14(dbPath)) {
|
|
4224
|
-
const stat =
|
|
4447
|
+
const stat = statSync3(dbPath);
|
|
4225
4448
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
4226
4449
|
const archivedPath = path15.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
4227
4450
|
renameSync4(dbPath, archivedPath);
|
|
@@ -4341,6 +4564,12 @@ var init_platform_procedures = __esm({
|
|
|
4341
4564
|
priority: "p0",
|
|
4342
4565
|
content: "Founder -> coordinator (the executive agent, internally routed as 'COO') -> CTO/CMO. CTO -> engineers. CMO -> content production. Never skip levels: the coordinator does not bypass managers for specialist work. Specialists report to their manager. If you need cross-team info, use ask_team_memory \u2014 don't read other agents' task folders. Each level owns dispatch downward and review upward."
|
|
4343
4566
|
},
|
|
4567
|
+
{
|
|
4568
|
+
title: "Customer orchestration maturity \u2014 recommend, never trap",
|
|
4569
|
+
domain: "workflow",
|
|
4570
|
+
priority: "p1",
|
|
4571
|
+
content: "New customers start best in Phase 1: founder \u2194 coordinator/Chief of Staff, building company context. Suggest Phase 2 executives when domain work repeats; suggest Phase 3 parallel execution only when review/permission gates are ready. This is guidance, not a blocker: users may jump phases anytime. Never overwrite their phase, role titles, identities, or custom org design."
|
|
4572
|
+
},
|
|
4344
4573
|
{
|
|
4345
4574
|
title: "Single dispatch path \u2014 create_task only",
|
|
4346
4575
|
domain: "workflow",
|
|
@@ -4399,6 +4628,12 @@ var init_platform_procedures = __esm({
|
|
|
4399
4628
|
priority: "p0",
|
|
4400
4629
|
content: "exe-build-adv is MANDATORY for ALL work touching 3+ files. Run /exe-build-adv --auto BEFORE implementation. Pipeline: Spec \u2192 AC \u2192 Tests \u2192 Evaluate \u2192 Fix. No multi-file feature ships without pipeline artifacts. No exceptions \u2014 managers reject work without them."
|
|
4401
4630
|
},
|
|
4631
|
+
{
|
|
4632
|
+
title: "Commit discipline \u2014 never leave verified work floating",
|
|
4633
|
+
domain: "workflow",
|
|
4634
|
+
priority: "p1",
|
|
4635
|
+
content: "After any code-change batch passes typecheck/tests/build, run git status, summarize changed files, and commit with a clear message before ending the session. If work must remain uncommitted for review/dogfood, explicitly say so, list the files, and state the blocker. Never imply work is complete while verified changes are still floating locally."
|
|
4636
|
+
},
|
|
4402
4637
|
{
|
|
4403
4638
|
title: "Desktop and TUI are the same product",
|
|
4404
4639
|
domain: "architecture",
|
|
@@ -4716,6 +4951,274 @@ var init_memory_cards = __esm({
|
|
|
4716
4951
|
}
|
|
4717
4952
|
});
|
|
4718
4953
|
|
|
4954
|
+
// src/lib/agentic-ontology.ts
|
|
4955
|
+
var agentic_ontology_exports = {};
|
|
4956
|
+
__export(agentic_ontology_exports, {
|
|
4957
|
+
clean: () => clean,
|
|
4958
|
+
extractGoalCandidates: () => extractGoalCandidates,
|
|
4959
|
+
inferIntention: () => inferIntention,
|
|
4960
|
+
inferOntologyEventType: () => inferOntologyEventType,
|
|
4961
|
+
inferOutcome: () => inferOutcome,
|
|
4962
|
+
inferSemanticLabel: () => inferSemanticLabel,
|
|
4963
|
+
insertOntologyForBatch: () => insertOntologyForBatch,
|
|
4964
|
+
insertOntologyForMemory: () => insertOntologyForMemory,
|
|
4965
|
+
ontologyPayload: () => ontologyPayload,
|
|
4966
|
+
stableId: () => stableId2
|
|
4967
|
+
});
|
|
4968
|
+
import { createHash as createHash3 } from "crypto";
|
|
4969
|
+
function stableId2(...parts) {
|
|
4970
|
+
return createHash3("sha256").update(parts.map((p) => String(p ?? "")).join("::")).digest("hex").slice(0, 32);
|
|
4971
|
+
}
|
|
4972
|
+
function clean(text, max = 240) {
|
|
4973
|
+
return text.replace(/\u0000/g, "").replace(/```[\s\S]*?```/g, " ").replace(/\s+/g, " ").trim().slice(0, max);
|
|
4974
|
+
}
|
|
4975
|
+
function inferOntologyEventType(row) {
|
|
4976
|
+
const lower = row.raw_text.toLowerCase();
|
|
4977
|
+
if (row.has_error) return "error";
|
|
4978
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published)\b/.test(lower)) return "milestone";
|
|
4979
|
+
if (/\b(blocked|failed|error|bug|regression|broken)\b/.test(lower)) return "problem";
|
|
4980
|
+
if (/\b(decided|decision|adr|we chose|approved|rejected)\b/.test(lower)) return "decision";
|
|
4981
|
+
if (/\b(goal|need to|we need|want to|trying to|objective)\b/.test(lower)) return "goal_signal";
|
|
4982
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) return "tool_action";
|
|
4983
|
+
if (row.tool_name.startsWith("memory_card")) return "memory_card";
|
|
4984
|
+
return "memory_observation";
|
|
4985
|
+
}
|
|
4986
|
+
function inferIntention(row) {
|
|
4987
|
+
if (row.intent) return clean(row.intent, 220);
|
|
4988
|
+
const text = clean(row.raw_text, 1e3);
|
|
4989
|
+
const patterns = [
|
|
4990
|
+
/(?:we need to|need to|let'?s|i want to|we should|goal is to|objective is to|trying to)\s+([^.!?\n]{8,220})/i,
|
|
4991
|
+
/(?:so that|in order to)\s+([^.!?\n]{8,220})/i,
|
|
4992
|
+
/(?:task|plan):\s*([^.!?\n]{8,220})/i
|
|
4993
|
+
];
|
|
4994
|
+
for (const p of patterns) {
|
|
4995
|
+
const m = text.match(p);
|
|
4996
|
+
if (m?.[1]) return clean(m[1], 220);
|
|
4997
|
+
}
|
|
4998
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) {
|
|
4999
|
+
return `${row.tool_name} during ${row.project_name}`;
|
|
5000
|
+
}
|
|
5001
|
+
return null;
|
|
5002
|
+
}
|
|
5003
|
+
function inferOutcome(row) {
|
|
5004
|
+
if (row.outcome) return clean(row.outcome, 220);
|
|
5005
|
+
if (row.has_error) return "error";
|
|
5006
|
+
const lower = row.raw_text.toLowerCase();
|
|
5007
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published|passed)\b/.test(lower)) return "success_signal";
|
|
5008
|
+
if (/\b(blocked|failed|error|regression|broken|not working|could not)\b/.test(lower)) return "failure_signal";
|
|
5009
|
+
if (/\b(warning|risk|concern|caveat)\b/.test(lower)) return "risk_signal";
|
|
5010
|
+
return null;
|
|
5011
|
+
}
|
|
5012
|
+
function extractGoalCandidates(row) {
|
|
5013
|
+
const text = clean(row.raw_text, 1600);
|
|
5014
|
+
const patterns = [
|
|
5015
|
+
/(?:we need to|need to|i want to|we should|goal is to|objective is to|trying to|let'?s)\s+([^.!?\n]{12,220})/gi,
|
|
5016
|
+
/(?:success means|success criteria|so that)\s+([^.!?\n]{12,220})/gi
|
|
5017
|
+
];
|
|
5018
|
+
const out = [];
|
|
5019
|
+
for (const pattern of patterns) {
|
|
5020
|
+
for (const m of text.matchAll(pattern)) {
|
|
5021
|
+
const candidate = clean(m[1] ?? "", 220);
|
|
5022
|
+
if (candidate.length >= 12 && !out.some((x) => x.toLowerCase() === candidate.toLowerCase())) out.push(candidate);
|
|
5023
|
+
if (out.length >= 3) return out;
|
|
5024
|
+
}
|
|
5025
|
+
}
|
|
5026
|
+
return out;
|
|
5027
|
+
}
|
|
5028
|
+
function uniq(values, max = 6) {
|
|
5029
|
+
const out = [];
|
|
5030
|
+
for (const value of values.map((v) => clean(v, 220)).filter(Boolean)) {
|
|
5031
|
+
if (!out.some((x) => x.toLowerCase() === value.toLowerCase())) out.push(value);
|
|
5032
|
+
if (out.length >= max) break;
|
|
5033
|
+
}
|
|
5034
|
+
return out;
|
|
5035
|
+
}
|
|
5036
|
+
function extractMatches(text, patterns, max = 5) {
|
|
5037
|
+
const out = [];
|
|
5038
|
+
for (const pattern of patterns) {
|
|
5039
|
+
for (const match of text.matchAll(pattern)) {
|
|
5040
|
+
const value = match[1] ?? match[0];
|
|
5041
|
+
if (value) out.push(value);
|
|
5042
|
+
if (out.length >= max) return uniq(out, max);
|
|
5043
|
+
}
|
|
5044
|
+
}
|
|
5045
|
+
return uniq(out, max);
|
|
5046
|
+
}
|
|
5047
|
+
function inferSemanticLabel(row) {
|
|
5048
|
+
const text = clean(row.raw_text, 2400);
|
|
5049
|
+
const eventType = inferOntologyEventType(row);
|
|
5050
|
+
const intention = inferIntention(row);
|
|
5051
|
+
const outcome = inferOutcome(row);
|
|
5052
|
+
const goals = extractGoalCandidates(row);
|
|
5053
|
+
const milestones = extractMatches(text, [
|
|
5054
|
+
/\b(?:completed|finished|fixed|resolved|shipped|deployed|published|pushed|passed)\b([^.!?\n]{0,180})/gi,
|
|
5055
|
+
/(?:milestone|done):\s*([^.!?\n]{8,220})/gi
|
|
5056
|
+
]);
|
|
5057
|
+
const problems = extractMatches(text, [
|
|
5058
|
+
/\b(?:blocked by|failed because|bug|regression|broken|not working|error)\b([^.!?\n]{0,180})/gi,
|
|
5059
|
+
/(?:problem|issue|risk):\s*([^.!?\n]{8,220})/gi
|
|
5060
|
+
]);
|
|
5061
|
+
const decisions = extractMatches(text, [
|
|
5062
|
+
/(?:decided|decision|adr|we chose|approved|rejected)\s+([^.!?\n]{8,220})/gi
|
|
5063
|
+
]);
|
|
5064
|
+
const temporalAnchors = extractMatches(text, [
|
|
5065
|
+
/\b(\d{4}-\d{2}-\d{2}(?:[T ][0-9:.+-Z]+)?)\b/g,
|
|
5066
|
+
/\b(today|yesterday|tomorrow|this week|next week|last week|morning|afternoon|tonight)\b/gi
|
|
5067
|
+
], 8);
|
|
5068
|
+
const nextActions = extractMatches(text, [
|
|
5069
|
+
/(?:next|todo|follow[- ]?up|remaining|need to)\s*:?\s*([^.!?\n]{8,220})/gi
|
|
5070
|
+
]);
|
|
5071
|
+
const actors = uniq([
|
|
5072
|
+
row.agent_id,
|
|
5073
|
+
...extractMatches(text, [/\b(?:agent|employee|owner|assignee)[:= ]+([a-zA-Z][a-zA-Z0-9_-]{1,40})/gi], 5)
|
|
5074
|
+
], 6);
|
|
5075
|
+
const successSignals = milestones.length ? milestones : outcome === "success_signal" ? [clean(text, 180)] : [];
|
|
5076
|
+
const failureSignals = problems.length ? problems : outcome === "failure_signal" || row.has_error ? [clean(text, 180)] : [];
|
|
5077
|
+
const impact = successSignals.length && failureSignals.length ? "mixed" : failureSignals.length ? "negative" : successSignals.length ? "positive" : "neutral";
|
|
5078
|
+
const signalCount = goals.length + milestones.length + problems.length + decisions.length + nextActions.length;
|
|
5079
|
+
return {
|
|
5080
|
+
labeler: "deterministic",
|
|
5081
|
+
schemaVersion: 1,
|
|
5082
|
+
eventType,
|
|
5083
|
+
intention,
|
|
5084
|
+
outcome,
|
|
5085
|
+
impact,
|
|
5086
|
+
confidence: Math.min(0.95, 0.45 + signalCount * 0.08 + (intention ? 0.1 : 0) + (outcome ? 0.1 : 0)),
|
|
5087
|
+
goals,
|
|
5088
|
+
milestones,
|
|
5089
|
+
problems,
|
|
5090
|
+
decisions,
|
|
5091
|
+
actors,
|
|
5092
|
+
temporalAnchors,
|
|
5093
|
+
successSignals,
|
|
5094
|
+
failureSignals,
|
|
5095
|
+
nextActions,
|
|
5096
|
+
summary: clean(text, 280)
|
|
5097
|
+
};
|
|
5098
|
+
}
|
|
5099
|
+
function ontologyPayload(row) {
|
|
5100
|
+
const semantic = inferSemanticLabel(row);
|
|
5101
|
+
return {
|
|
5102
|
+
tool_name: row.tool_name,
|
|
5103
|
+
memory_version: row.version ?? null,
|
|
5104
|
+
domain: row.domain ?? null,
|
|
5105
|
+
trajectory: row.trajectory ? safeJson(row.trajectory) : null,
|
|
5106
|
+
semantic
|
|
5107
|
+
};
|
|
5108
|
+
}
|
|
5109
|
+
function safeJson(value) {
|
|
5110
|
+
try {
|
|
5111
|
+
return JSON.parse(value);
|
|
5112
|
+
} catch {
|
|
5113
|
+
return value.slice(0, 1e3);
|
|
5114
|
+
}
|
|
5115
|
+
}
|
|
5116
|
+
async function resolveClient(client) {
|
|
5117
|
+
if (client) return client;
|
|
5118
|
+
const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
5119
|
+
return getClient2();
|
|
5120
|
+
}
|
|
5121
|
+
async function insertOntologyForMemory(row, client) {
|
|
5122
|
+
const db = await resolveClient(client);
|
|
5123
|
+
const occurredAt = row.timestamp;
|
|
5124
|
+
const sequence = Number(row.version ?? 0) || Math.floor(new Date(occurredAt).getTime() / 1e3);
|
|
5125
|
+
const eventType = inferOntologyEventType(row);
|
|
5126
|
+
const intention = inferIntention(row);
|
|
5127
|
+
const outcome = inferOutcome(row);
|
|
5128
|
+
const eventId = stableId2("event", row.id);
|
|
5129
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
5130
|
+
await db.execute({
|
|
5131
|
+
sql: `INSERT INTO agent_sessions (id, agent_id, project_name, started_at, last_event_at, event_count, properties)
|
|
5132
|
+
VALUES (?, ?, ?, ?, ?, 1, ?)
|
|
5133
|
+
ON CONFLICT(id) DO UPDATE SET last_event_at = MAX(last_event_at, excluded.last_event_at),
|
|
5134
|
+
event_count = event_count + 1`,
|
|
5135
|
+
args: [row.session_id, row.agent_id, row.project_name, occurredAt, occurredAt, JSON.stringify({ agent_role: row.agent_role })]
|
|
5136
|
+
});
|
|
5137
|
+
await db.execute({
|
|
5138
|
+
sql: `INSERT OR IGNORE INTO agent_events
|
|
5139
|
+
(id, event_type, occurred_at, sequence_index, actor_agent_id, agent_role, project_name,
|
|
5140
|
+
session_id, task_id, goal_id, parent_event_id, intention, outcome, evidence_memory_id,
|
|
5141
|
+
impact, payload, created_at)
|
|
5142
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, ?, ?, ?, ?, ?, ?)`,
|
|
5143
|
+
args: [
|
|
5144
|
+
eventId,
|
|
5145
|
+
eventType,
|
|
5146
|
+
occurredAt,
|
|
5147
|
+
sequence,
|
|
5148
|
+
row.agent_id,
|
|
5149
|
+
row.agent_role,
|
|
5150
|
+
row.project_name,
|
|
5151
|
+
row.session_id,
|
|
5152
|
+
row.task_id ?? null,
|
|
5153
|
+
intention,
|
|
5154
|
+
outcome,
|
|
5155
|
+
row.id,
|
|
5156
|
+
row.has_error ? "negative" : outcome === "success_signal" ? "positive" : "neutral",
|
|
5157
|
+
JSON.stringify(ontologyPayload(row)),
|
|
5158
|
+
now
|
|
5159
|
+
]
|
|
5160
|
+
});
|
|
5161
|
+
const semantic = inferSemanticLabel(row);
|
|
5162
|
+
await db.execute({
|
|
5163
|
+
sql: `INSERT INTO agent_semantic_labels
|
|
5164
|
+
(id, source_memory_id, event_id, labeler, schema_version, confidence, labels, created_at, updated_at)
|
|
5165
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
5166
|
+
ON CONFLICT(id) DO UPDATE SET confidence = excluded.confidence,
|
|
5167
|
+
labels = excluded.labels, updated_at = excluded.updated_at`,
|
|
5168
|
+
args: [
|
|
5169
|
+
stableId2("semantic", row.id, semantic.labeler, semantic.schemaVersion),
|
|
5170
|
+
row.id,
|
|
5171
|
+
eventId,
|
|
5172
|
+
semantic.labeler,
|
|
5173
|
+
semantic.schemaVersion,
|
|
5174
|
+
semantic.confidence,
|
|
5175
|
+
JSON.stringify(semantic),
|
|
5176
|
+
now,
|
|
5177
|
+
now
|
|
5178
|
+
]
|
|
5179
|
+
});
|
|
5180
|
+
for (const statement of extractGoalCandidates(row)) {
|
|
5181
|
+
const goalId = stableId2("goal", row.project_name, statement.toLowerCase());
|
|
5182
|
+
await db.execute({
|
|
5183
|
+
sql: `INSERT INTO agent_goals
|
|
5184
|
+
(id, statement, owner_agent_id, project_name, status, priority, success_criteria,
|
|
5185
|
+
parent_goal_id, due_at, achieved_at, supersedes_id, created_at, updated_at, source_memory_id)
|
|
5186
|
+
VALUES (?, ?, ?, ?, 'open', 5, NULL, NULL, NULL, NULL, NULL, ?, ?, ?)
|
|
5187
|
+
ON CONFLICT(id) DO UPDATE SET updated_at = excluded.updated_at`,
|
|
5188
|
+
args: [goalId, statement, row.agent_id, row.project_name, now, now, row.id]
|
|
5189
|
+
});
|
|
5190
|
+
await db.execute({
|
|
5191
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
5192
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
5193
|
+
VALUES (?, ?, 'evidence', ?, 'memory', ?)`,
|
|
5194
|
+
args: [stableId2("goal_link", goalId, row.id, "memory"), goalId, row.id, now]
|
|
5195
|
+
});
|
|
5196
|
+
await db.execute({
|
|
5197
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
5198
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
5199
|
+
VALUES (?, ?, 'event', ?, 'event', ?)`,
|
|
5200
|
+
args: [stableId2("goal_link", goalId, eventId, "event"), goalId, eventId, now]
|
|
5201
|
+
});
|
|
5202
|
+
}
|
|
5203
|
+
}
|
|
5204
|
+
async function insertOntologyForBatch(rows, client) {
|
|
5205
|
+
const db = await resolveClient(client);
|
|
5206
|
+
let count = 0;
|
|
5207
|
+
for (const row of rows) {
|
|
5208
|
+
try {
|
|
5209
|
+
await insertOntologyForMemory(row, db);
|
|
5210
|
+
count++;
|
|
5211
|
+
} catch {
|
|
5212
|
+
}
|
|
5213
|
+
}
|
|
5214
|
+
return count;
|
|
5215
|
+
}
|
|
5216
|
+
var init_agentic_ontology = __esm({
|
|
5217
|
+
"src/lib/agentic-ontology.ts"() {
|
|
5218
|
+
"use strict";
|
|
5219
|
+
}
|
|
5220
|
+
});
|
|
5221
|
+
|
|
4719
5222
|
// src/lib/store.ts
|
|
4720
5223
|
var store_exports = {};
|
|
4721
5224
|
__export(store_exports, {
|
|
@@ -5059,6 +5562,11 @@ async function flushBatch() {
|
|
|
5059
5562
|
await insertMemoryCardsForBatch2(batch);
|
|
5060
5563
|
} catch {
|
|
5061
5564
|
}
|
|
5565
|
+
try {
|
|
5566
|
+
const { insertOntologyForBatch: insertOntologyForBatch2 } = await Promise.resolve().then(() => (init_agentic_ontology(), agentic_ontology_exports));
|
|
5567
|
+
await insertOntologyForBatch2(batch);
|
|
5568
|
+
} catch {
|
|
5569
|
+
}
|
|
5062
5570
|
schedulePostWriteMemoryHygiene(batch.map((row) => row.id));
|
|
5063
5571
|
_pendingRecords.splice(0, batch.length);
|
|
5064
5572
|
try {
|