@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
package/dist/bin/exe-dispatch.js
CHANGED
|
@@ -442,6 +442,11 @@ function normalizeAutoUpdate(raw) {
|
|
|
442
442
|
const userAU = raw.autoUpdate ?? {};
|
|
443
443
|
raw.autoUpdate = { ...defaultAU, ...userAU };
|
|
444
444
|
}
|
|
445
|
+
function normalizeOrchestration(raw) {
|
|
446
|
+
const defaultOrg = DEFAULT_CONFIG.orchestration;
|
|
447
|
+
const userOrg = raw.orchestration ?? {};
|
|
448
|
+
raw.orchestration = { ...defaultOrg, ...userOrg };
|
|
449
|
+
}
|
|
445
450
|
async function loadConfig() {
|
|
446
451
|
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
447
452
|
await ensurePrivateDir(dir);
|
|
@@ -466,10 +471,15 @@ async function loadConfig() {
|
|
|
466
471
|
normalizeScalingRoadmap(migratedCfg);
|
|
467
472
|
normalizeSessionLifecycle(migratedCfg);
|
|
468
473
|
normalizeAutoUpdate(migratedCfg);
|
|
474
|
+
normalizeOrchestration(migratedCfg);
|
|
469
475
|
const config = { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db"), ...migratedCfg };
|
|
470
476
|
if (config.dbPath.startsWith("~")) {
|
|
471
477
|
config.dbPath = config.dbPath.replace(/^~/, os2.homedir());
|
|
472
478
|
}
|
|
479
|
+
const envDbPath = path2.join(dir, "memories.db");
|
|
480
|
+
if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync3(config.dbPath) && existsSync3(envDbPath)) {
|
|
481
|
+
config.dbPath = envDbPath;
|
|
482
|
+
}
|
|
473
483
|
return config;
|
|
474
484
|
} catch {
|
|
475
485
|
return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
|
|
@@ -489,7 +499,16 @@ function loadConfigSync() {
|
|
|
489
499
|
normalizeScalingRoadmap(migratedCfg);
|
|
490
500
|
normalizeSessionLifecycle(migratedCfg);
|
|
491
501
|
normalizeAutoUpdate(migratedCfg);
|
|
492
|
-
|
|
502
|
+
normalizeOrchestration(migratedCfg);
|
|
503
|
+
const config = { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db"), ...migratedCfg };
|
|
504
|
+
if (config.dbPath.startsWith("~")) {
|
|
505
|
+
config.dbPath = config.dbPath.replace(/^~/, os2.homedir());
|
|
506
|
+
}
|
|
507
|
+
const envDbPath = path2.join(dir, "memories.db");
|
|
508
|
+
if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync3(config.dbPath) && existsSync3(envDbPath)) {
|
|
509
|
+
config.dbPath = envDbPath;
|
|
510
|
+
}
|
|
511
|
+
return config;
|
|
493
512
|
} catch {
|
|
494
513
|
return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
|
|
495
514
|
}
|
|
@@ -510,6 +529,7 @@ async function loadConfigFrom(configPath) {
|
|
|
510
529
|
normalizeScalingRoadmap(migratedCfg);
|
|
511
530
|
normalizeSessionLifecycle(migratedCfg);
|
|
512
531
|
normalizeAutoUpdate(migratedCfg);
|
|
532
|
+
normalizeOrchestration(migratedCfg);
|
|
513
533
|
return { ...DEFAULT_CONFIG, ...migratedCfg };
|
|
514
534
|
} catch {
|
|
515
535
|
return { ...DEFAULT_CONFIG };
|
|
@@ -581,6 +601,10 @@ var init_config = __esm({
|
|
|
581
601
|
checkOnBoot: true,
|
|
582
602
|
autoInstall: false,
|
|
583
603
|
checkIntervalMs: 24 * 60 * 60 * 1e3
|
|
604
|
+
},
|
|
605
|
+
orchestration: {
|
|
606
|
+
phase: "phase_1_coo",
|
|
607
|
+
phaseSetBy: "default"
|
|
584
608
|
}
|
|
585
609
|
};
|
|
586
610
|
CONFIG_MIGRATIONS = [
|
|
@@ -2313,6 +2337,9 @@ function getClient() {
|
|
|
2313
2337
|
if (_daemonClient && _daemonClient._isDaemonActive()) {
|
|
2314
2338
|
return _daemonClient;
|
|
2315
2339
|
}
|
|
2340
|
+
if (!_resilientClient) {
|
|
2341
|
+
return _adapterClient;
|
|
2342
|
+
}
|
|
2316
2343
|
return _resilientClient;
|
|
2317
2344
|
}
|
|
2318
2345
|
async function initDaemonClient() {
|
|
@@ -3345,6 +3372,127 @@ async function ensureSchema() {
|
|
|
3345
3372
|
VALUES (new.rowid, new.content, new.subject, new.predicate, new.object);
|
|
3346
3373
|
END;
|
|
3347
3374
|
`);
|
|
3375
|
+
await client.executeMultiple(`
|
|
3376
|
+
CREATE TABLE IF NOT EXISTS agent_sessions (
|
|
3377
|
+
id TEXT PRIMARY KEY,
|
|
3378
|
+
agent_id TEXT NOT NULL,
|
|
3379
|
+
project_name TEXT,
|
|
3380
|
+
started_at TEXT NOT NULL,
|
|
3381
|
+
last_event_at TEXT NOT NULL,
|
|
3382
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
3383
|
+
properties TEXT DEFAULT '{}'
|
|
3384
|
+
);
|
|
3385
|
+
|
|
3386
|
+
CREATE INDEX IF NOT EXISTS idx_agent_sessions_agent_time
|
|
3387
|
+
ON agent_sessions(agent_id, started_at);
|
|
3388
|
+
|
|
3389
|
+
CREATE TABLE IF NOT EXISTS agent_goals (
|
|
3390
|
+
id TEXT PRIMARY KEY,
|
|
3391
|
+
statement TEXT NOT NULL,
|
|
3392
|
+
owner_agent_id TEXT,
|
|
3393
|
+
project_name TEXT,
|
|
3394
|
+
status TEXT NOT NULL DEFAULT 'open',
|
|
3395
|
+
priority INTEGER NOT NULL DEFAULT 5,
|
|
3396
|
+
success_criteria TEXT,
|
|
3397
|
+
parent_goal_id TEXT,
|
|
3398
|
+
due_at TEXT,
|
|
3399
|
+
achieved_at TEXT,
|
|
3400
|
+
supersedes_id TEXT,
|
|
3401
|
+
created_at TEXT NOT NULL,
|
|
3402
|
+
updated_at TEXT NOT NULL,
|
|
3403
|
+
source_memory_id TEXT
|
|
3404
|
+
);
|
|
3405
|
+
|
|
3406
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goals_project_status
|
|
3407
|
+
ON agent_goals(project_name, status, priority);
|
|
3408
|
+
|
|
3409
|
+
CREATE TABLE IF NOT EXISTS agent_events (
|
|
3410
|
+
id TEXT PRIMARY KEY,
|
|
3411
|
+
event_type TEXT NOT NULL,
|
|
3412
|
+
occurred_at TEXT NOT NULL,
|
|
3413
|
+
sequence_index INTEGER NOT NULL,
|
|
3414
|
+
actor_agent_id TEXT,
|
|
3415
|
+
agent_role TEXT,
|
|
3416
|
+
project_name TEXT,
|
|
3417
|
+
session_id TEXT,
|
|
3418
|
+
task_id TEXT,
|
|
3419
|
+
goal_id TEXT,
|
|
3420
|
+
parent_event_id TEXT,
|
|
3421
|
+
intention TEXT,
|
|
3422
|
+
outcome TEXT,
|
|
3423
|
+
evidence_memory_id TEXT,
|
|
3424
|
+
impact TEXT,
|
|
3425
|
+
payload TEXT DEFAULT '{}',
|
|
3426
|
+
created_at TEXT NOT NULL
|
|
3427
|
+
);
|
|
3428
|
+
|
|
3429
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_time
|
|
3430
|
+
ON agent_events(occurred_at, sequence_index);
|
|
3431
|
+
|
|
3432
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_session_seq
|
|
3433
|
+
ON agent_events(session_id, sequence_index);
|
|
3434
|
+
|
|
3435
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_goal_time
|
|
3436
|
+
ON agent_events(goal_id, occurred_at);
|
|
3437
|
+
|
|
3438
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_memory
|
|
3439
|
+
ON agent_events(evidence_memory_id);
|
|
3440
|
+
|
|
3441
|
+
CREATE TABLE IF NOT EXISTS agent_goal_links (
|
|
3442
|
+
id TEXT PRIMARY KEY,
|
|
3443
|
+
goal_id TEXT NOT NULL,
|
|
3444
|
+
link_type TEXT NOT NULL,
|
|
3445
|
+
target_id TEXT NOT NULL,
|
|
3446
|
+
target_type TEXT NOT NULL,
|
|
3447
|
+
created_at TEXT NOT NULL
|
|
3448
|
+
);
|
|
3449
|
+
|
|
3450
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goal_links_goal
|
|
3451
|
+
ON agent_goal_links(goal_id, target_type);
|
|
3452
|
+
|
|
3453
|
+
CREATE TABLE IF NOT EXISTS agent_semantic_labels (
|
|
3454
|
+
id TEXT PRIMARY KEY,
|
|
3455
|
+
source_memory_id TEXT NOT NULL,
|
|
3456
|
+
event_id TEXT,
|
|
3457
|
+
labeler TEXT NOT NULL,
|
|
3458
|
+
schema_version INTEGER NOT NULL DEFAULT 1,
|
|
3459
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
3460
|
+
labels TEXT NOT NULL,
|
|
3461
|
+
created_at TEXT NOT NULL,
|
|
3462
|
+
updated_at TEXT NOT NULL
|
|
3463
|
+
);
|
|
3464
|
+
|
|
3465
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_memory
|
|
3466
|
+
ON agent_semantic_labels(source_memory_id, labeler);
|
|
3467
|
+
|
|
3468
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_event
|
|
3469
|
+
ON agent_semantic_labels(event_id);
|
|
3470
|
+
|
|
3471
|
+
CREATE TABLE IF NOT EXISTS agent_reflection_checkpoints (
|
|
3472
|
+
id TEXT PRIMARY KEY,
|
|
3473
|
+
project_name TEXT,
|
|
3474
|
+
session_id TEXT,
|
|
3475
|
+
window_start_at TEXT NOT NULL,
|
|
3476
|
+
window_end_at TEXT NOT NULL,
|
|
3477
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
3478
|
+
goal_count INTEGER NOT NULL DEFAULT 0,
|
|
3479
|
+
success_count INTEGER NOT NULL DEFAULT 0,
|
|
3480
|
+
failure_count INTEGER NOT NULL DEFAULT 0,
|
|
3481
|
+
risk_count INTEGER NOT NULL DEFAULT 0,
|
|
3482
|
+
summary TEXT NOT NULL,
|
|
3483
|
+
learnings TEXT NOT NULL DEFAULT '[]',
|
|
3484
|
+
next_actions TEXT NOT NULL DEFAULT '[]',
|
|
3485
|
+
evidence_event_ids TEXT NOT NULL DEFAULT '[]',
|
|
3486
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
3487
|
+
created_at TEXT NOT NULL
|
|
3488
|
+
);
|
|
3489
|
+
|
|
3490
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_project_time
|
|
3491
|
+
ON agent_reflection_checkpoints(project_name, window_end_at);
|
|
3492
|
+
|
|
3493
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_session_time
|
|
3494
|
+
ON agent_reflection_checkpoints(session_id, window_end_at);
|
|
3495
|
+
`);
|
|
3348
3496
|
try {
|
|
3349
3497
|
await client.execute({
|
|
3350
3498
|
sql: `ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3`,
|
|
@@ -6726,7 +6874,7 @@ var init_tmux_routing = __esm({
|
|
|
6726
6874
|
|
|
6727
6875
|
// src/lib/keychain.ts
|
|
6728
6876
|
import { readFile as readFile4, writeFile as writeFile5, unlink, mkdir as mkdir4, chmod as chmod2 } from "fs/promises";
|
|
6729
|
-
import { existsSync as existsSync16 } from "fs";
|
|
6877
|
+
import { existsSync as existsSync16, statSync as statSync2 } from "fs";
|
|
6730
6878
|
import { execSync as execSync7 } from "child_process";
|
|
6731
6879
|
import path19 from "path";
|
|
6732
6880
|
import os12 from "os";
|
|
@@ -6736,29 +6884,78 @@ function getKeyDir() {
|
|
|
6736
6884
|
function getKeyPath() {
|
|
6737
6885
|
return path19.join(getKeyDir(), "master.key");
|
|
6738
6886
|
}
|
|
6739
|
-
function
|
|
6887
|
+
function nativeKeychainAllowed() {
|
|
6888
|
+
return process.env.EXE_OS_DISABLE_NATIVE_KEYCHAIN !== "1";
|
|
6889
|
+
}
|
|
6890
|
+
function linuxSecretAvailable() {
|
|
6891
|
+
if (!nativeKeychainAllowed()) return false;
|
|
6892
|
+
if (process.platform !== "linux") return false;
|
|
6893
|
+
if (linuxSecretAvailability !== null) return linuxSecretAvailability;
|
|
6894
|
+
try {
|
|
6895
|
+
execSync7("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
|
|
6896
|
+
} catch {
|
|
6897
|
+
linuxSecretAvailability = false;
|
|
6898
|
+
return false;
|
|
6899
|
+
}
|
|
6900
|
+
try {
|
|
6901
|
+
execSync7("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
|
|
6902
|
+
linuxSecretAvailability = true;
|
|
6903
|
+
} catch {
|
|
6904
|
+
linuxSecretAvailability = false;
|
|
6905
|
+
}
|
|
6906
|
+
return linuxSecretAvailability;
|
|
6907
|
+
}
|
|
6908
|
+
function isRootOnlyTrustedServerKeyFile(keyPath) {
|
|
6909
|
+
if (process.platform !== "linux") return false;
|
|
6910
|
+
try {
|
|
6911
|
+
const uid = typeof os12.userInfo().uid === "number" ? os12.userInfo().uid : -1;
|
|
6912
|
+
const st = statSync2(keyPath);
|
|
6913
|
+
if (!st.isFile() || (st.mode & 63) !== 0) return false;
|
|
6914
|
+
if (uid === 0) return true;
|
|
6915
|
+
const exeOsDir = process.env.EXE_OS_DIR;
|
|
6916
|
+
return Boolean(exeOsDir && path19.resolve(keyPath).startsWith(path19.resolve(exeOsDir) + path19.sep));
|
|
6917
|
+
} catch {
|
|
6918
|
+
return false;
|
|
6919
|
+
}
|
|
6920
|
+
}
|
|
6921
|
+
function macKeychainGet(service = SERVICE) {
|
|
6922
|
+
if (!nativeKeychainAllowed()) return null;
|
|
6740
6923
|
if (process.platform !== "darwin") return null;
|
|
6741
6924
|
try {
|
|
6742
6925
|
return execSync7(
|
|
6743
|
-
`security find-generic-password -s "${
|
|
6926
|
+
`security find-generic-password -s "${service}" -a "${ACCOUNT}" -w 2>/dev/null`,
|
|
6744
6927
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
6745
6928
|
).trim();
|
|
6746
6929
|
} catch {
|
|
6747
6930
|
return null;
|
|
6748
6931
|
}
|
|
6749
6932
|
}
|
|
6750
|
-
function macKeychainSet(value) {
|
|
6933
|
+
function macKeychainSet(value, service = SERVICE) {
|
|
6934
|
+
if (!nativeKeychainAllowed()) return false;
|
|
6751
6935
|
if (process.platform !== "darwin") return false;
|
|
6752
6936
|
try {
|
|
6753
6937
|
try {
|
|
6754
6938
|
execSync7(
|
|
6755
|
-
`security delete-generic-password -s "${
|
|
6939
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
6756
6940
|
{ timeout: 5e3 }
|
|
6757
6941
|
);
|
|
6758
6942
|
} catch {
|
|
6759
6943
|
}
|
|
6760
6944
|
execSync7(
|
|
6761
|
-
`security add-generic-password -s "${
|
|
6945
|
+
`security add-generic-password -s "${service}" -a "${ACCOUNT}" -w "${value}"`,
|
|
6946
|
+
{ timeout: 5e3 }
|
|
6947
|
+
);
|
|
6948
|
+
return true;
|
|
6949
|
+
} catch {
|
|
6950
|
+
return false;
|
|
6951
|
+
}
|
|
6952
|
+
}
|
|
6953
|
+
function macKeychainDelete(service = SERVICE) {
|
|
6954
|
+
if (!nativeKeychainAllowed()) return false;
|
|
6955
|
+
if (process.platform !== "darwin") return false;
|
|
6956
|
+
try {
|
|
6957
|
+
execSync7(
|
|
6958
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
6762
6959
|
{ timeout: 5e3 }
|
|
6763
6960
|
);
|
|
6764
6961
|
return true;
|
|
@@ -6766,22 +6963,35 @@ function macKeychainSet(value) {
|
|
|
6766
6963
|
return false;
|
|
6767
6964
|
}
|
|
6768
6965
|
}
|
|
6769
|
-
function linuxSecretGet() {
|
|
6770
|
-
if (
|
|
6966
|
+
function linuxSecretGet(service = SERVICE) {
|
|
6967
|
+
if (!linuxSecretAvailable()) return null;
|
|
6771
6968
|
try {
|
|
6772
6969
|
return execSync7(
|
|
6773
|
-
`secret-tool lookup service "${
|
|
6970
|
+
`secret-tool lookup service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
6774
6971
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
6775
6972
|
).trim();
|
|
6776
6973
|
} catch {
|
|
6777
6974
|
return null;
|
|
6778
6975
|
}
|
|
6779
6976
|
}
|
|
6780
|
-
function linuxSecretSet(value) {
|
|
6977
|
+
function linuxSecretSet(value, service = SERVICE) {
|
|
6978
|
+
if (!linuxSecretAvailable()) return false;
|
|
6979
|
+
try {
|
|
6980
|
+
execSync7(
|
|
6981
|
+
`echo -n "${value}" | secret-tool store --label="exe-os master key" service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
6982
|
+
{ timeout: 5e3 }
|
|
6983
|
+
);
|
|
6984
|
+
return true;
|
|
6985
|
+
} catch {
|
|
6986
|
+
return false;
|
|
6987
|
+
}
|
|
6988
|
+
}
|
|
6989
|
+
function linuxSecretDelete(service = SERVICE) {
|
|
6990
|
+
if (!nativeKeychainAllowed()) return false;
|
|
6781
6991
|
if (process.platform !== "linux") return false;
|
|
6782
6992
|
try {
|
|
6783
6993
|
execSync7(
|
|
6784
|
-
`
|
|
6994
|
+
`secret-tool clear service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
6785
6995
|
{ timeout: 5e3 }
|
|
6786
6996
|
);
|
|
6787
6997
|
return true;
|
|
@@ -6790,6 +7000,7 @@ function linuxSecretSet(value) {
|
|
|
6790
7000
|
}
|
|
6791
7001
|
}
|
|
6792
7002
|
async function tryKeytar() {
|
|
7003
|
+
if (!nativeKeychainAllowed()) return null;
|
|
6793
7004
|
try {
|
|
6794
7005
|
return await import("keytar");
|
|
6795
7006
|
} catch {
|
|
@@ -6863,7 +7074,19 @@ async function writeMachineBoundFileFallback(b64) {
|
|
|
6863
7074
|
return "plaintext";
|
|
6864
7075
|
}
|
|
6865
7076
|
async function getMasterKey() {
|
|
6866
|
-
|
|
7077
|
+
let nativeValue = macKeychainGet() ?? linuxSecretGet();
|
|
7078
|
+
if (!nativeValue) {
|
|
7079
|
+
const legacyValue = macKeychainGet(LEGACY_SERVICE) ?? linuxSecretGet(LEGACY_SERVICE);
|
|
7080
|
+
if (legacyValue) {
|
|
7081
|
+
const migrated = macKeychainSet(legacyValue) || linuxSecretSet(legacyValue);
|
|
7082
|
+
if (migrated) {
|
|
7083
|
+
macKeychainDelete(LEGACY_SERVICE);
|
|
7084
|
+
linuxSecretDelete(LEGACY_SERVICE);
|
|
7085
|
+
process.stderr.write("[keychain] Migrated keychain service from exe-mem to exe-os.\n");
|
|
7086
|
+
}
|
|
7087
|
+
nativeValue = legacyValue;
|
|
7088
|
+
}
|
|
7089
|
+
}
|
|
6867
7090
|
if (nativeValue) {
|
|
6868
7091
|
return Buffer.from(nativeValue, "base64");
|
|
6869
7092
|
}
|
|
@@ -6871,12 +7094,17 @@ async function getMasterKey() {
|
|
|
6871
7094
|
if (keytar) {
|
|
6872
7095
|
try {
|
|
6873
7096
|
const keytarValue = await keytar.getPassword(SERVICE, ACCOUNT);
|
|
6874
|
-
|
|
6875
|
-
|
|
7097
|
+
const legacyKeytarValue = keytarValue ?? await keytar.getPassword(LEGACY_SERVICE, ACCOUNT);
|
|
7098
|
+
if (legacyKeytarValue) {
|
|
7099
|
+
const migrated = macKeychainSet(legacyKeytarValue) || linuxSecretSet(legacyKeytarValue);
|
|
6876
7100
|
if (migrated) {
|
|
6877
7101
|
process.stderr.write("[keychain] Migrated key from keytar to native keychain.\n");
|
|
7102
|
+
try {
|
|
7103
|
+
await keytar.deletePassword(LEGACY_SERVICE, ACCOUNT);
|
|
7104
|
+
} catch {
|
|
7105
|
+
}
|
|
6878
7106
|
}
|
|
6879
|
-
return Buffer.from(
|
|
7107
|
+
return Buffer.from(legacyKeytarValue, "base64");
|
|
6880
7108
|
}
|
|
6881
7109
|
} catch {
|
|
6882
7110
|
}
|
|
@@ -6901,7 +7129,7 @@ async function getMasterKey() {
|
|
|
6901
7129
|
const decrypted = decryptWithMachineKey(content, machineKey);
|
|
6902
7130
|
if (!decrypted) {
|
|
6903
7131
|
process.stderr.write(
|
|
6904
|
-
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase: exe-os
|
|
7132
|
+
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase during setup: exe-os setup\n"
|
|
6905
7133
|
);
|
|
6906
7134
|
return null;
|
|
6907
7135
|
}
|
|
@@ -6910,6 +7138,9 @@ async function getMasterKey() {
|
|
|
6910
7138
|
b64Value = content;
|
|
6911
7139
|
}
|
|
6912
7140
|
const key = Buffer.from(b64Value, "base64");
|
|
7141
|
+
if (!content.startsWith(ENCRYPTED_PREFIX) && isRootOnlyTrustedServerKeyFile(keyPath)) {
|
|
7142
|
+
return key;
|
|
7143
|
+
}
|
|
6913
7144
|
const migrated = macKeychainSet(b64Value) || linuxSecretSet(b64Value);
|
|
6914
7145
|
if (migrated) {
|
|
6915
7146
|
process.stderr.write("[keychain] Migrated key from file to native keychain.\n");
|
|
@@ -6937,12 +7168,14 @@ async function getMasterKey() {
|
|
|
6937
7168
|
return null;
|
|
6938
7169
|
}
|
|
6939
7170
|
}
|
|
6940
|
-
var SERVICE, ACCOUNT, ENCRYPTED_PREFIX;
|
|
7171
|
+
var SERVICE, LEGACY_SERVICE, ACCOUNT, linuxSecretAvailability, ENCRYPTED_PREFIX;
|
|
6941
7172
|
var init_keychain = __esm({
|
|
6942
7173
|
"src/lib/keychain.ts"() {
|
|
6943
7174
|
"use strict";
|
|
6944
|
-
SERVICE = "exe-
|
|
7175
|
+
SERVICE = "exe-os";
|
|
7176
|
+
LEGACY_SERVICE = "exe-mem";
|
|
6945
7177
|
ACCOUNT = "master-key";
|
|
7178
|
+
linuxSecretAvailability = null;
|
|
6946
7179
|
ENCRYPTED_PREFIX = "enc:";
|
|
6947
7180
|
}
|
|
6948
7181
|
});
|
|
@@ -7157,7 +7390,7 @@ __export(shard_manager_exports, {
|
|
|
7157
7390
|
shardExists: () => shardExists
|
|
7158
7391
|
});
|
|
7159
7392
|
import path20 from "path";
|
|
7160
|
-
import { existsSync as existsSync17, mkdirSync as mkdirSync8, readdirSync as readdirSync4, renameSync as renameSync4, statSync as
|
|
7393
|
+
import { existsSync as existsSync17, mkdirSync as mkdirSync8, readdirSync as readdirSync4, renameSync as renameSync4, statSync as statSync3 } from "fs";
|
|
7161
7394
|
import { createClient as createClient2 } from "@libsql/client";
|
|
7162
7395
|
function initShardManager(encryptionKey) {
|
|
7163
7396
|
_encryptionKey = encryptionKey;
|
|
@@ -7221,7 +7454,7 @@ async function auditShardHealth(options = {}) {
|
|
|
7221
7454
|
const shards = [];
|
|
7222
7455
|
for (const name of names) {
|
|
7223
7456
|
const dbPath = path20.join(SHARDS_DIR, `${name}.db`);
|
|
7224
|
-
const stat =
|
|
7457
|
+
const stat = statSync3(dbPath);
|
|
7225
7458
|
const item = {
|
|
7226
7459
|
name,
|
|
7227
7460
|
path: dbPath,
|
|
@@ -7474,7 +7707,7 @@ async function getReadyShardClient(projectName) {
|
|
|
7474
7707
|
_shardLastAccess.delete(safeName);
|
|
7475
7708
|
const dbPath = path20.join(SHARDS_DIR, `${safeName}.db`);
|
|
7476
7709
|
if (existsSync17(dbPath)) {
|
|
7477
|
-
const stat =
|
|
7710
|
+
const stat = statSync3(dbPath);
|
|
7478
7711
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
7479
7712
|
const archivedPath = path20.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
7480
7713
|
renameSync4(dbPath, archivedPath);
|
|
@@ -7594,6 +7827,12 @@ var init_platform_procedures = __esm({
|
|
|
7594
7827
|
priority: "p0",
|
|
7595
7828
|
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."
|
|
7596
7829
|
},
|
|
7830
|
+
{
|
|
7831
|
+
title: "Customer orchestration maturity \u2014 recommend, never trap",
|
|
7832
|
+
domain: "workflow",
|
|
7833
|
+
priority: "p1",
|
|
7834
|
+
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."
|
|
7835
|
+
},
|
|
7597
7836
|
{
|
|
7598
7837
|
title: "Single dispatch path \u2014 create_task only",
|
|
7599
7838
|
domain: "workflow",
|
|
@@ -7652,6 +7891,12 @@ var init_platform_procedures = __esm({
|
|
|
7652
7891
|
priority: "p0",
|
|
7653
7892
|
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."
|
|
7654
7893
|
},
|
|
7894
|
+
{
|
|
7895
|
+
title: "Commit discipline \u2014 never leave verified work floating",
|
|
7896
|
+
domain: "workflow",
|
|
7897
|
+
priority: "p1",
|
|
7898
|
+
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."
|
|
7899
|
+
},
|
|
7655
7900
|
{
|
|
7656
7901
|
title: "Desktop and TUI are the same product",
|
|
7657
7902
|
domain: "architecture",
|
|
@@ -7969,6 +8214,274 @@ var init_memory_cards = __esm({
|
|
|
7969
8214
|
}
|
|
7970
8215
|
});
|
|
7971
8216
|
|
|
8217
|
+
// src/lib/agentic-ontology.ts
|
|
8218
|
+
var agentic_ontology_exports = {};
|
|
8219
|
+
__export(agentic_ontology_exports, {
|
|
8220
|
+
clean: () => clean,
|
|
8221
|
+
extractGoalCandidates: () => extractGoalCandidates,
|
|
8222
|
+
inferIntention: () => inferIntention,
|
|
8223
|
+
inferOntologyEventType: () => inferOntologyEventType,
|
|
8224
|
+
inferOutcome: () => inferOutcome,
|
|
8225
|
+
inferSemanticLabel: () => inferSemanticLabel,
|
|
8226
|
+
insertOntologyForBatch: () => insertOntologyForBatch,
|
|
8227
|
+
insertOntologyForMemory: () => insertOntologyForMemory,
|
|
8228
|
+
ontologyPayload: () => ontologyPayload,
|
|
8229
|
+
stableId: () => stableId2
|
|
8230
|
+
});
|
|
8231
|
+
import { createHash as createHash3 } from "crypto";
|
|
8232
|
+
function stableId2(...parts) {
|
|
8233
|
+
return createHash3("sha256").update(parts.map((p) => String(p ?? "")).join("::")).digest("hex").slice(0, 32);
|
|
8234
|
+
}
|
|
8235
|
+
function clean(text, max = 240) {
|
|
8236
|
+
return text.replace(/\u0000/g, "").replace(/```[\s\S]*?```/g, " ").replace(/\s+/g, " ").trim().slice(0, max);
|
|
8237
|
+
}
|
|
8238
|
+
function inferOntologyEventType(row) {
|
|
8239
|
+
const lower = row.raw_text.toLowerCase();
|
|
8240
|
+
if (row.has_error) return "error";
|
|
8241
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published)\b/.test(lower)) return "milestone";
|
|
8242
|
+
if (/\b(blocked|failed|error|bug|regression|broken)\b/.test(lower)) return "problem";
|
|
8243
|
+
if (/\b(decided|decision|adr|we chose|approved|rejected)\b/.test(lower)) return "decision";
|
|
8244
|
+
if (/\b(goal|need to|we need|want to|trying to|objective)\b/.test(lower)) return "goal_signal";
|
|
8245
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) return "tool_action";
|
|
8246
|
+
if (row.tool_name.startsWith("memory_card")) return "memory_card";
|
|
8247
|
+
return "memory_observation";
|
|
8248
|
+
}
|
|
8249
|
+
function inferIntention(row) {
|
|
8250
|
+
if (row.intent) return clean(row.intent, 220);
|
|
8251
|
+
const text = clean(row.raw_text, 1e3);
|
|
8252
|
+
const patterns = [
|
|
8253
|
+
/(?: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,
|
|
8254
|
+
/(?:so that|in order to)\s+([^.!?\n]{8,220})/i,
|
|
8255
|
+
/(?:task|plan):\s*([^.!?\n]{8,220})/i
|
|
8256
|
+
];
|
|
8257
|
+
for (const p of patterns) {
|
|
8258
|
+
const m = text.match(p);
|
|
8259
|
+
if (m?.[1]) return clean(m[1], 220);
|
|
8260
|
+
}
|
|
8261
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) {
|
|
8262
|
+
return `${row.tool_name} during ${row.project_name}`;
|
|
8263
|
+
}
|
|
8264
|
+
return null;
|
|
8265
|
+
}
|
|
8266
|
+
function inferOutcome(row) {
|
|
8267
|
+
if (row.outcome) return clean(row.outcome, 220);
|
|
8268
|
+
if (row.has_error) return "error";
|
|
8269
|
+
const lower = row.raw_text.toLowerCase();
|
|
8270
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published|passed)\b/.test(lower)) return "success_signal";
|
|
8271
|
+
if (/\b(blocked|failed|error|regression|broken|not working|could not)\b/.test(lower)) return "failure_signal";
|
|
8272
|
+
if (/\b(warning|risk|concern|caveat)\b/.test(lower)) return "risk_signal";
|
|
8273
|
+
return null;
|
|
8274
|
+
}
|
|
8275
|
+
function extractGoalCandidates(row) {
|
|
8276
|
+
const text = clean(row.raw_text, 1600);
|
|
8277
|
+
const patterns = [
|
|
8278
|
+
/(?: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,
|
|
8279
|
+
/(?:success means|success criteria|so that)\s+([^.!?\n]{12,220})/gi
|
|
8280
|
+
];
|
|
8281
|
+
const out = [];
|
|
8282
|
+
for (const pattern of patterns) {
|
|
8283
|
+
for (const m of text.matchAll(pattern)) {
|
|
8284
|
+
const candidate = clean(m[1] ?? "", 220);
|
|
8285
|
+
if (candidate.length >= 12 && !out.some((x) => x.toLowerCase() === candidate.toLowerCase())) out.push(candidate);
|
|
8286
|
+
if (out.length >= 3) return out;
|
|
8287
|
+
}
|
|
8288
|
+
}
|
|
8289
|
+
return out;
|
|
8290
|
+
}
|
|
8291
|
+
function uniq(values, max = 6) {
|
|
8292
|
+
const out = [];
|
|
8293
|
+
for (const value of values.map((v) => clean(v, 220)).filter(Boolean)) {
|
|
8294
|
+
if (!out.some((x) => x.toLowerCase() === value.toLowerCase())) out.push(value);
|
|
8295
|
+
if (out.length >= max) break;
|
|
8296
|
+
}
|
|
8297
|
+
return out;
|
|
8298
|
+
}
|
|
8299
|
+
function extractMatches(text, patterns, max = 5) {
|
|
8300
|
+
const out = [];
|
|
8301
|
+
for (const pattern of patterns) {
|
|
8302
|
+
for (const match of text.matchAll(pattern)) {
|
|
8303
|
+
const value = match[1] ?? match[0];
|
|
8304
|
+
if (value) out.push(value);
|
|
8305
|
+
if (out.length >= max) return uniq(out, max);
|
|
8306
|
+
}
|
|
8307
|
+
}
|
|
8308
|
+
return uniq(out, max);
|
|
8309
|
+
}
|
|
8310
|
+
function inferSemanticLabel(row) {
|
|
8311
|
+
const text = clean(row.raw_text, 2400);
|
|
8312
|
+
const eventType = inferOntologyEventType(row);
|
|
8313
|
+
const intention = inferIntention(row);
|
|
8314
|
+
const outcome = inferOutcome(row);
|
|
8315
|
+
const goals = extractGoalCandidates(row);
|
|
8316
|
+
const milestones = extractMatches(text, [
|
|
8317
|
+
/\b(?:completed|finished|fixed|resolved|shipped|deployed|published|pushed|passed)\b([^.!?\n]{0,180})/gi,
|
|
8318
|
+
/(?:milestone|done):\s*([^.!?\n]{8,220})/gi
|
|
8319
|
+
]);
|
|
8320
|
+
const problems = extractMatches(text, [
|
|
8321
|
+
/\b(?:blocked by|failed because|bug|regression|broken|not working|error)\b([^.!?\n]{0,180})/gi,
|
|
8322
|
+
/(?:problem|issue|risk):\s*([^.!?\n]{8,220})/gi
|
|
8323
|
+
]);
|
|
8324
|
+
const decisions = extractMatches(text, [
|
|
8325
|
+
/(?:decided|decision|adr|we chose|approved|rejected)\s+([^.!?\n]{8,220})/gi
|
|
8326
|
+
]);
|
|
8327
|
+
const temporalAnchors = extractMatches(text, [
|
|
8328
|
+
/\b(\d{4}-\d{2}-\d{2}(?:[T ][0-9:.+-Z]+)?)\b/g,
|
|
8329
|
+
/\b(today|yesterday|tomorrow|this week|next week|last week|morning|afternoon|tonight)\b/gi
|
|
8330
|
+
], 8);
|
|
8331
|
+
const nextActions = extractMatches(text, [
|
|
8332
|
+
/(?:next|todo|follow[- ]?up|remaining|need to)\s*:?\s*([^.!?\n]{8,220})/gi
|
|
8333
|
+
]);
|
|
8334
|
+
const actors = uniq([
|
|
8335
|
+
row.agent_id,
|
|
8336
|
+
...extractMatches(text, [/\b(?:agent|employee|owner|assignee)[:= ]+([a-zA-Z][a-zA-Z0-9_-]{1,40})/gi], 5)
|
|
8337
|
+
], 6);
|
|
8338
|
+
const successSignals = milestones.length ? milestones : outcome === "success_signal" ? [clean(text, 180)] : [];
|
|
8339
|
+
const failureSignals = problems.length ? problems : outcome === "failure_signal" || row.has_error ? [clean(text, 180)] : [];
|
|
8340
|
+
const impact = successSignals.length && failureSignals.length ? "mixed" : failureSignals.length ? "negative" : successSignals.length ? "positive" : "neutral";
|
|
8341
|
+
const signalCount = goals.length + milestones.length + problems.length + decisions.length + nextActions.length;
|
|
8342
|
+
return {
|
|
8343
|
+
labeler: "deterministic",
|
|
8344
|
+
schemaVersion: 1,
|
|
8345
|
+
eventType,
|
|
8346
|
+
intention,
|
|
8347
|
+
outcome,
|
|
8348
|
+
impact,
|
|
8349
|
+
confidence: Math.min(0.95, 0.45 + signalCount * 0.08 + (intention ? 0.1 : 0) + (outcome ? 0.1 : 0)),
|
|
8350
|
+
goals,
|
|
8351
|
+
milestones,
|
|
8352
|
+
problems,
|
|
8353
|
+
decisions,
|
|
8354
|
+
actors,
|
|
8355
|
+
temporalAnchors,
|
|
8356
|
+
successSignals,
|
|
8357
|
+
failureSignals,
|
|
8358
|
+
nextActions,
|
|
8359
|
+
summary: clean(text, 280)
|
|
8360
|
+
};
|
|
8361
|
+
}
|
|
8362
|
+
function ontologyPayload(row) {
|
|
8363
|
+
const semantic = inferSemanticLabel(row);
|
|
8364
|
+
return {
|
|
8365
|
+
tool_name: row.tool_name,
|
|
8366
|
+
memory_version: row.version ?? null,
|
|
8367
|
+
domain: row.domain ?? null,
|
|
8368
|
+
trajectory: row.trajectory ? safeJson(row.trajectory) : null,
|
|
8369
|
+
semantic
|
|
8370
|
+
};
|
|
8371
|
+
}
|
|
8372
|
+
function safeJson(value) {
|
|
8373
|
+
try {
|
|
8374
|
+
return JSON.parse(value);
|
|
8375
|
+
} catch {
|
|
8376
|
+
return value.slice(0, 1e3);
|
|
8377
|
+
}
|
|
8378
|
+
}
|
|
8379
|
+
async function resolveClient(client) {
|
|
8380
|
+
if (client) return client;
|
|
8381
|
+
const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
8382
|
+
return getClient2();
|
|
8383
|
+
}
|
|
8384
|
+
async function insertOntologyForMemory(row, client) {
|
|
8385
|
+
const db = await resolveClient(client);
|
|
8386
|
+
const occurredAt = row.timestamp;
|
|
8387
|
+
const sequence = Number(row.version ?? 0) || Math.floor(new Date(occurredAt).getTime() / 1e3);
|
|
8388
|
+
const eventType = inferOntologyEventType(row);
|
|
8389
|
+
const intention = inferIntention(row);
|
|
8390
|
+
const outcome = inferOutcome(row);
|
|
8391
|
+
const eventId = stableId2("event", row.id);
|
|
8392
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
8393
|
+
await db.execute({
|
|
8394
|
+
sql: `INSERT INTO agent_sessions (id, agent_id, project_name, started_at, last_event_at, event_count, properties)
|
|
8395
|
+
VALUES (?, ?, ?, ?, ?, 1, ?)
|
|
8396
|
+
ON CONFLICT(id) DO UPDATE SET last_event_at = MAX(last_event_at, excluded.last_event_at),
|
|
8397
|
+
event_count = event_count + 1`,
|
|
8398
|
+
args: [row.session_id, row.agent_id, row.project_name, occurredAt, occurredAt, JSON.stringify({ agent_role: row.agent_role })]
|
|
8399
|
+
});
|
|
8400
|
+
await db.execute({
|
|
8401
|
+
sql: `INSERT OR IGNORE INTO agent_events
|
|
8402
|
+
(id, event_type, occurred_at, sequence_index, actor_agent_id, agent_role, project_name,
|
|
8403
|
+
session_id, task_id, goal_id, parent_event_id, intention, outcome, evidence_memory_id,
|
|
8404
|
+
impact, payload, created_at)
|
|
8405
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, ?, ?, ?, ?, ?, ?)`,
|
|
8406
|
+
args: [
|
|
8407
|
+
eventId,
|
|
8408
|
+
eventType,
|
|
8409
|
+
occurredAt,
|
|
8410
|
+
sequence,
|
|
8411
|
+
row.agent_id,
|
|
8412
|
+
row.agent_role,
|
|
8413
|
+
row.project_name,
|
|
8414
|
+
row.session_id,
|
|
8415
|
+
row.task_id ?? null,
|
|
8416
|
+
intention,
|
|
8417
|
+
outcome,
|
|
8418
|
+
row.id,
|
|
8419
|
+
row.has_error ? "negative" : outcome === "success_signal" ? "positive" : "neutral",
|
|
8420
|
+
JSON.stringify(ontologyPayload(row)),
|
|
8421
|
+
now
|
|
8422
|
+
]
|
|
8423
|
+
});
|
|
8424
|
+
const semantic = inferSemanticLabel(row);
|
|
8425
|
+
await db.execute({
|
|
8426
|
+
sql: `INSERT INTO agent_semantic_labels
|
|
8427
|
+
(id, source_memory_id, event_id, labeler, schema_version, confidence, labels, created_at, updated_at)
|
|
8428
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
8429
|
+
ON CONFLICT(id) DO UPDATE SET confidence = excluded.confidence,
|
|
8430
|
+
labels = excluded.labels, updated_at = excluded.updated_at`,
|
|
8431
|
+
args: [
|
|
8432
|
+
stableId2("semantic", row.id, semantic.labeler, semantic.schemaVersion),
|
|
8433
|
+
row.id,
|
|
8434
|
+
eventId,
|
|
8435
|
+
semantic.labeler,
|
|
8436
|
+
semantic.schemaVersion,
|
|
8437
|
+
semantic.confidence,
|
|
8438
|
+
JSON.stringify(semantic),
|
|
8439
|
+
now,
|
|
8440
|
+
now
|
|
8441
|
+
]
|
|
8442
|
+
});
|
|
8443
|
+
for (const statement of extractGoalCandidates(row)) {
|
|
8444
|
+
const goalId = stableId2("goal", row.project_name, statement.toLowerCase());
|
|
8445
|
+
await db.execute({
|
|
8446
|
+
sql: `INSERT INTO agent_goals
|
|
8447
|
+
(id, statement, owner_agent_id, project_name, status, priority, success_criteria,
|
|
8448
|
+
parent_goal_id, due_at, achieved_at, supersedes_id, created_at, updated_at, source_memory_id)
|
|
8449
|
+
VALUES (?, ?, ?, ?, 'open', 5, NULL, NULL, NULL, NULL, NULL, ?, ?, ?)
|
|
8450
|
+
ON CONFLICT(id) DO UPDATE SET updated_at = excluded.updated_at`,
|
|
8451
|
+
args: [goalId, statement, row.agent_id, row.project_name, now, now, row.id]
|
|
8452
|
+
});
|
|
8453
|
+
await db.execute({
|
|
8454
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
8455
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
8456
|
+
VALUES (?, ?, 'evidence', ?, 'memory', ?)`,
|
|
8457
|
+
args: [stableId2("goal_link", goalId, row.id, "memory"), goalId, row.id, now]
|
|
8458
|
+
});
|
|
8459
|
+
await db.execute({
|
|
8460
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
8461
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
8462
|
+
VALUES (?, ?, 'event', ?, 'event', ?)`,
|
|
8463
|
+
args: [stableId2("goal_link", goalId, eventId, "event"), goalId, eventId, now]
|
|
8464
|
+
});
|
|
8465
|
+
}
|
|
8466
|
+
}
|
|
8467
|
+
async function insertOntologyForBatch(rows, client) {
|
|
8468
|
+
const db = await resolveClient(client);
|
|
8469
|
+
let count = 0;
|
|
8470
|
+
for (const row of rows) {
|
|
8471
|
+
try {
|
|
8472
|
+
await insertOntologyForMemory(row, db);
|
|
8473
|
+
count++;
|
|
8474
|
+
} catch {
|
|
8475
|
+
}
|
|
8476
|
+
}
|
|
8477
|
+
return count;
|
|
8478
|
+
}
|
|
8479
|
+
var init_agentic_ontology = __esm({
|
|
8480
|
+
"src/lib/agentic-ontology.ts"() {
|
|
8481
|
+
"use strict";
|
|
8482
|
+
}
|
|
8483
|
+
});
|
|
8484
|
+
|
|
7972
8485
|
// src/lib/store.ts
|
|
7973
8486
|
var store_exports = {};
|
|
7974
8487
|
__export(store_exports, {
|
|
@@ -8312,6 +8825,11 @@ async function flushBatch() {
|
|
|
8312
8825
|
await insertMemoryCardsForBatch2(batch);
|
|
8313
8826
|
} catch {
|
|
8314
8827
|
}
|
|
8828
|
+
try {
|
|
8829
|
+
const { insertOntologyForBatch: insertOntologyForBatch2 } = await Promise.resolve().then(() => (init_agentic_ontology(), agentic_ontology_exports));
|
|
8830
|
+
await insertOntologyForBatch2(batch);
|
|
8831
|
+
} catch {
|
|
8832
|
+
}
|
|
8315
8833
|
schedulePostWriteMemoryHygiene(batch.map((row) => row.id));
|
|
8316
8834
|
_pendingRecords.splice(0, batch.length);
|
|
8317
8835
|
try {
|